From a475384b733d977838ec3a26023dcbb5407b427f Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 29 Mar 2012 16:25:04 -0300 Subject: [PATCH] ui fixes * fix viplist * fix skills update * fix mouse grabber * minimize send interval * add api to get world name --- modules/client_entergame/characterlist.lua | 2 +- modules/game/gameinterface.lua | 14 ++++++-------- modules/game_skills/skills.lua | 18 ++++++------------ modules/game_viplist/viplist.lua | 2 +- src/framework/net/connection.h | 2 +- src/otclient/core/game.cpp | 4 +++- src/otclient/core/game.h | 5 ++++- src/otclient/core/localplayer.cpp | 2 +- src/otclient/luafunctions.cpp | 3 ++- 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 7904e89e..7bab4180 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -40,7 +40,7 @@ local function tryLogin(charInfo, tries) CharacterList.destroyLoadBox() - g_game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldHost, charInfo.worldPort, charInfo.characterName) + g_game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName) loadBox = displayCancelBox('Please wait', 'Connecting to game server...') connect(loadBox, { onCancel = function() diff --git a/modules/game/gameinterface.lua b/modules/game/gameinterface.lua index 144bc922..d16d6f68 100644 --- a/modules/game/gameinterface.lua +++ b/modules/game/gameinterface.lua @@ -7,7 +7,7 @@ local gameRightPanel local gameLeftPanel local gameBottomPanel local logoutButton -local m_mouseGrabberWidget +local mouseGrabberWidget function GameInterface.init() connect(g_game, { onGameStart = GameInterface.show }, true) @@ -17,9 +17,9 @@ function GameInterface.init() gameRootPanel:hide() gameRootPanel:lower() - m_mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber') - connect(m_mouseGrabberWidget, { onMouseRelease = GameInterface.onUseWithMouseRelease }) - + mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber') + mouseGrabberWidget.onMouseRelease = GameInterface.onUseWithMouseRelease + gameMapPanel = gameRootPanel:getChildById('gameMapPanel') gameRightPanel = gameRootPanel:getChildById('gameRightPanel') gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel') @@ -60,7 +60,6 @@ end function GameInterface.terminate() disconnect(g_game, { onGameStart = GameInterface.show }) disconnect(g_game, { onGameEnd = GameInterface.hide }) - disconnect(m_mouseGrabberWidget, { onMouseRelease = onUseWithMouseRelease }) logoutButton:destroy() logoutButton = nil @@ -70,9 +69,8 @@ function GameInterface.terminate() gameRightPanel = nil gameLeftPanel = nil gameBottomPanel = nil + mouseGrabberWidget = nil GameInterface = nil - m_mouseGrabberWidget:destroy() - m_mouseGrabberWidget = nil end function GameInterface.show() @@ -128,7 +126,7 @@ end function GameInterface.startUseWith(thing) GameInterface.selectedThing = thing - m_mouseGrabberWidget:grabMouse() + mouseGrabberWidget:grabMouse() Mouse.setTargetCursor() end diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index bb44bd3e..0c99d39a 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -20,23 +20,17 @@ end local function setSkillValue(id, value) local skill = skillsWindow:recursiveGetChildById(id) - - if skill then - local widget = skill:getChildById('value') - widget:setText(value) - end + local widget = skill:getChildById('value') + widget:setText(value) end local function setSkillPercent(id, percent, tooltip) local skill = skillsWindow:recursiveGetChildById(id) + local widget = skill:getChildById('percent') + widget:setPercent(percent) - if skill then - local widget = skill:getChildById('percent') - widget:setPercent(percent) - - if tooltip then - widget:setTooltip(tooltip) - end + if tooltip then + widget:setTooltip(tooltip) end end diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 69f45846..ac46f857 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -101,7 +101,7 @@ function VipList.onAddVip(id, name, online) end function VipList.onVipStateChange(id, online) - local vipList = vipWindow:getChildById('vipList') + local vipList = vipWindow:getChildById('contentsPanel') local label = vipList:getChildById('vip' .. id) local text = label:getText() vipList:removeChild(label) diff --git a/src/framework/net/connection.h b/src/framework/net/connection.h index f78a7e07..b1ff1409 100644 --- a/src/framework/net/connection.h +++ b/src/framework/net/connection.h @@ -36,7 +36,7 @@ class Connection : public std::enable_shared_from_this, boost::nonco enum { READ_TIMEOUT = 30, WRITE_TIMEOUT = 30, - SEND_INTERVAL = 10, + SEND_INTERVAL = 1, SEND_BUFFER_SIZE = 65536, RECV_BUFFER_SIZE = 65536 }; diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 3485e520..207aef95 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -315,14 +315,16 @@ void Game::processWalkCancel(Otc::Direction direction) m_localPlayer->cancelWalk(direction); } -void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldHost, int worldPort, const std::string& characterName) +void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName) { if(m_protocolGame || isOnline()) { logTraceError("unable to login into a world while already online or logging"); return; } + m_protocolGame = ProtocolGamePtr(new ProtocolGame); m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName); + m_worldName = worldName; } void Game::cancelLogin() diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 27ca9e1e..1ea0ffd4 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -114,7 +114,8 @@ protected: public: // login related void loginWorld(const std::string& account, - const std::string& password, + const std::string& password, + const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName); void cancelLogin(); @@ -223,6 +224,7 @@ public: LocalPlayerPtr getLocalPlayer() { return m_localPlayer; } ProtocolGamePtr getProtocolGame() { return m_protocolGame; } int getProtocolVersion() { return PROTOCOL; } + std::string getWorldName() { return m_worldName; } private: void setAttackingCreature(const CreaturePtr& creature); @@ -238,6 +240,7 @@ private: Otc::FightModes m_fightMode; Otc::ChaseModes m_chaseMode; bool m_safeFight; + std::string m_worldName; }; extern Game g_game; diff --git a/src/otclient/core/localplayer.cpp b/src/otclient/core/localplayer.cpp index 30745ac8..bff37a32 100644 --- a/src/otclient/core/localplayer.cpp +++ b/src/otclient/core/localplayer.cpp @@ -182,7 +182,7 @@ void LocalPlayer::setSkill(Otc::Skill skill, int level, int levelPercent) int oldLevel = m_skillsLevel[skill]; int oldLevelPercent = m_skillsLevelPercent[skill]; - if(level != oldLevel && levelPercent != oldLevelPercent) { + if(level != oldLevel || levelPercent != oldLevelPercent) { m_skillsLevel[skill] = level; m_skillsLevelPercent[skill] = levelPercent; diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index a160e3a5..e2de3764 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -78,7 +78,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("g_map", "findPath", std::bind(&Map::findPath, &g_map, _1, _2, _3)); g_lua.registerStaticClass("g_game"); - g_lua.bindClassStaticFunction("g_game", "loginWorld", std::bind(&Game::loginWorld, &g_game, _1, _2, _3, _4, _5)); + g_lua.bindClassStaticFunction("g_game", "loginWorld", std::bind(&Game::loginWorld, &g_game, _1, _2, _3, _4, _5, _6)); g_lua.bindClassStaticFunction("g_game", "cancelLogin", std::bind(&Game::cancelLogin, &g_game)); g_lua.bindClassStaticFunction("g_game", "forceLogout", std::bind(&Game::forceLogout, &g_game)); g_lua.bindClassStaticFunction("g_game", "safeLogout", std::bind(&Game::safeLogout, &g_game)); @@ -153,6 +153,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("g_game", "getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindClassStaticFunction("g_game", "getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.bindClassStaticFunction("g_game", "getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); + g_lua.bindClassStaticFunction("g_game", "getWorldName", std::bind(&Game::getWorldName, &g_game)); g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor);