From caf86a9fc677b39812b7368eebcc6e8656a919a7 Mon Sep 17 00:00:00 2001 From: BeniS Date: Wed, 23 Jan 2013 13:15:46 +1300 Subject: [PATCH] Fixes! Closes #235 and more: * Hotkeys now save by server & player rather than just player * Added double clicking to module dialog options * Fixed a bug in the modal dialog for > pv970 (protocol changed) * Fixed a login bug for pv970. WARNING: Will remove all your current hotkeys. --- modules/game_cooldown/cooldown.lua | 2 ++ modules/game_hotkeys/hotkeys_manager.lua | 18 +++++++++++++----- modules/game_modaldialog/modaldialog.lua | 2 ++ src/client/protocolgameparse.cpp | 18 ++++++++++++------ src/client/protocolgamesend.cpp | 2 +- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/modules/game_cooldown/cooldown.lua b/modules/game_cooldown/cooldown.lua index 0e72a00d..9bdb8b88 100644 --- a/modules/game_cooldown/cooldown.lua +++ b/modules/game_cooldown/cooldown.lua @@ -53,6 +53,8 @@ function show() if g_game.getFeature(GameSpellList) then cooldownWindow:show() cooldownButton:show() + else + hide() end end diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index ea790274..53716219 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -91,10 +91,14 @@ function load() local hotkeySettings = g_settings.getNode('HotkeysManager') local hasCombos = false if not table.empty(hotkeySettings) then - local playerHotkeySettings = hotkeySettings[g_game.getLocalPlayer():getName()] + local serverHotkeys = hotkeySettings[G.host] - if not table.empty(playerHotkeySettings) then - for k, setting in pairs(playerHotkeySettings) do + local hotkeys + if not table.empty(serverHotkeys) then + hotkeys = serverHotkeys[g_game.getLocalPlayer():getName()] + end + if not table.empty(hotkeys) then + for k, setting in pairs(hotkeys) do addKeyCombo(nil, setting.keyCombo, setting) hasCombos = true end @@ -109,11 +113,15 @@ end function save() local char = g_game.getLocalPlayer():getName() + local server = G.host + local hotkeySettings = g_settings.getNode('HotkeysManager') or {} - hotkeySettings[char] = {} + hotkeySettings[server] = {} + hotkeySettings[server][char] = {} + for i=1, currentHotkeysList:getChildCount() do local child = currentHotkeysList:getChildByIndex(i) - table.insert(hotkeySettings[char], { + table.insert(hotkeySettings[server][char], { keyCombo = child.keyCombo, autoSend = child.autoSend, itemId = child.itemId, diff --git a/modules/game_modaldialog/modaldialog.lua b/modules/game_modaldialog/modaldialog.lua index c5ec2f12..3a13ecf9 100644 --- a/modules/game_modaldialog/modaldialog.lua +++ b/modules/game_modaldialog/modaldialog.lua @@ -59,6 +59,8 @@ function onModalDialog(id, title, message, enterId, enterText, escapeId, escapeT g_game.answerModalDialog(id, escapeId, choiceList:getFocusedChild().choiceId) destroy() end + + choiceList.onDoubleClick = enterFunc enterButton.onClick = enterFunc modalDialog.onEnter = enterFunc diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 3b89724a..98d0daa9 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1500,20 +1500,26 @@ void ProtocolGame::parseShowModalDialog(const InputMessagePtr& msg) choiceList.push_back(std::make_tuple(id, value)); } - int enterButton = msg->getU8(); - int escapeButton = msg->getU8(); + int enterButton, escapeButton; + if(g_game.getProtocolVersion() > 970) { + escapeButton = msg->getU8(); + enterButton = msg->getU8(); + } + else { + enterButton = msg->getU8(); + escapeButton = msg->getU8(); + } + msg->getU8(); // popup value (no clue what it is for) std::map::iterator itEnter = buttonList.find(enterButton); - if(itEnter == buttonList.end()) - { + if(itEnter == buttonList.end()) { g_logger.info(stdext::format("Enter button does not exist for dialog id: %d", id)); return; } std::map::iterator itEscape = buttonList.find(escapeButton); - if(itEscape == buttonList.end()) - { + if(itEscape == buttonList.end()) { g_logger.info(stdext::format("Escape button does not exist for dialog id: %d", id)); return; } diff --git a/src/client/protocolgamesend.cpp b/src/client/protocolgamesend.cpp index 76ef2ab5..c6c2c007 100644 --- a/src/client/protocolgamesend.cpp +++ b/src/client/protocolgamesend.cpp @@ -64,7 +64,7 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando msg->addU16(g_game.getProtocolVersion()); - if(g_game.getProtocolVersion() >= 970) { + if(g_game.getProtocolVersion() >= 971) { msg->addU32(g_game.getClientVersion()); msg->addU8(0); // clientType }