From 35e5dd8af817fb56dc60697f6df8c05e5a6e3da1 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 1 Feb 2013 14:47:15 +1300 Subject: [PATCH] Topmenu fix * Will no longer duplicate topmenu buttons (no need to destroy in the module now) * Menu items will no longer change position when reloaded. --- modules/client_entergame/entergame.lua | 6 ------ modules/client_modulemanager/modulemanager.lua | 2 -- modules/client_options/options.lua | 4 ---- modules/client_terminal/terminal.lua | 2 -- modules/client_topmenu/topmenu.lua | 13 ++++++++----- modules/game_combatcontrols/combatcontrols.lua | 1 - modules/game_cooldown/cooldown.lua | 1 - modules/game_healthinfo/healthinfo.lua | 1 - modules/game_hotkeys/hotkeys_manager.lua | 1 - modules/game_interface/gameinterface.lua | 1 - modules/game_inventory/inventory.lua | 1 - modules/game_minimap/minimap.lua | 1 - modules/game_questlog/questlog.lua | 3 --- modules/game_skills/skills.lua | 1 - modules/game_spelllist/spelllist.lua | 2 -- 15 files changed, 8 insertions(+), 32 deletions(-) diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 4ed01279..9c244a39 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -136,17 +136,11 @@ function EnterGame.terminate() removeEvent(autoLoginEvent) enterGame:destroy() enterGame = nil - enterGameButton:destroy() - enterGameButton = nil protocolBox = nil if motdWindow then motdWindow:destroy() motdWindow = nil end - if motdButton then - motdButton:destroy() - motdButton = nil - end if loadBox then loadBox:destroy() loadBox = nil diff --git a/modules/client_modulemanager/modulemanager.lua b/modules/client_modulemanager/modulemanager.lua index 7b903e85..551ffe7f 100644 --- a/modules/client_modulemanager/modulemanager.lua +++ b/modules/client_modulemanager/modulemanager.lua @@ -23,8 +23,6 @@ end function terminate() moduleManagerWindow:destroy() moduleManagerWindow = nil - moduleManagerButton:destroy() - moduleManagerButton = nil moduleList = nil end diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 6e34ead5..7fad6be4 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -119,15 +119,11 @@ function terminate() g_keyboard.unbindKeyDown('Ctrl+Shift+F') optionsWindow:destroy() optionsWindow = nil - optionsButton:destroy() - optionsButton = nil optionsTabBar = nil generalPanel = nil consolePanel = nil graphicsPanel = nil audioPanel = nil - audioButton:destroy() - audioButton = nil end function toggle() diff --git a/modules/client_terminal/terminal.lua b/modules/client_terminal/terminal.lua index 9f3d4729..21ee66d5 100644 --- a/modules/client_terminal/terminal.lua +++ b/modules/client_terminal/terminal.lua @@ -150,8 +150,6 @@ function terminate() g_settings.setList('terminal-history', commandHistory) g_keyboard.unbindKeyDown('Ctrl+T') g_logger.setOnLog(nil) - terminalButton:destroy() - terminalButton = nil commandTextEdit = nil terminalBuffer = nil terminalWindow:destroy() diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index 30cc9d11..396a57a4 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -14,11 +14,14 @@ local function addButton(id, description, icon, callback, panel, toggle, front) class = 'TopButton' end - local button = g_ui.createWidget(class) - if front then - panel:insertChild(1, button) - else - panel:addChild(button) + local button = panel:getChildById(id) + if not button then + button = g_ui.createWidget(class) + if front then + panel:insertChild(1, button) + else + panel:addChild(button) + end end button:setId(id) button:setTooltip(description) diff --git a/modules/game_combatcontrols/combatcontrols.lua b/modules/game_combatcontrols/combatcontrols.lua index ed57bfb3..695e25bf 100644 --- a/modules/game_combatcontrols/combatcontrols.lua +++ b/modules/game_combatcontrols/combatcontrols.lua @@ -50,7 +50,6 @@ function terminate() end fightModeRadioGroup:destroy() - combatControlsButton:destroy() combatControlsWindow:destroy() disconnect(g_game, { diff --git a/modules/game_cooldown/cooldown.lua b/modules/game_cooldown/cooldown.lua index b6c37372..0feb22d5 100644 --- a/modules/game_cooldown/cooldown.lua +++ b/modules/game_cooldown/cooldown.lua @@ -35,7 +35,6 @@ function terminate() onSpellGroupCooldown = onSpellGroupCooldown, onSpellCooldown = onSpellCooldown }) - cooldownButton:destroy() cooldownWindow:destroy() end diff --git a/modules/game_healthinfo/healthinfo.lua b/modules/game_healthinfo/healthinfo.lua index be650649..d6319cad 100644 --- a/modules/game_healthinfo/healthinfo.lua +++ b/modules/game_healthinfo/healthinfo.lua @@ -70,7 +70,6 @@ function terminate() disconnect(g_game, { onGameEnd = offline }) healthInfoWindow:destroy() - healthInfoButton:destroy() healthInfoWindow = nil healthInfoButton = nil diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index 67a3c124..38449996 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -88,7 +88,6 @@ function terminate() unload() hotkeysWindow:destroy() - hotkeysButton:destroy() mouseGrabberWidget:destroy() end diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index fe244457..40d754d0 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -123,7 +123,6 @@ function terminate() disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange }) - logoutButton:destroy() gameRootPanel:destroy() end diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index 4e2c87a2..60a01a72 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -39,7 +39,6 @@ function terminate() g_keyboard.unbindKeyDown('Ctrl+I') inventoryWindow:destroy() - inventoryButton:destroy() end function refresh() diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index 95bc93cd..4ffacb94 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -48,7 +48,6 @@ function terminate() g_keyboard.unbindKeyPress('Alt+Down', gameRootPanel) g_keyboard.unbindKeyDown('Ctrl+M') - minimapButton:destroy() minimapWindow:destroy() end diff --git a/modules/game_questlog/questlog.lua b/modules/game_questlog/questlog.lua index ef0e64dd..afb2de5f 100644 --- a/modules/game_questlog/questlog.lua +++ b/modules/game_questlog/questlog.lua @@ -17,9 +17,6 @@ function terminate() onQuestLine = onGameQuestLine, onGameEnd = destroyWindows}) - if questLogButton then - questLogButton:destroy() - end destroyWindows() end diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index 181d50d9..a72c19ba 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -60,7 +60,6 @@ function terminate() }) g_keyboard.unbindKeyDown('Ctrl+S') - skillsButton:destroy() skillsWindow:destroy() end diff --git a/modules/game_spelllist/spelllist.lua b/modules/game_spelllist/spelllist.lua index 622772b1..df432b51 100644 --- a/modules/game_spelllist/spelllist.lua +++ b/modules/game_spelllist/spelllist.lua @@ -172,8 +172,6 @@ function terminate() updateSpellInformation(focusedChild) end }) - spelllistButton:destroy() - spelllistButton = nil spelllistWindow:destroy() spelllistWindow = nil