From 7f5dda5c8febce673b5c1127dc424123d2bee716 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 1 Feb 2013 17:32:15 +1300 Subject: [PATCH] Re-add destroying for unloading, other clean up: * Cleaned some module terminate code * Fixed "reload all" issues --- modules/client_background/background.lua | 1 - modules/client_entergame/entergame.lua | 6 ++++ .../client_modulemanager/modulemanager.lua | 2 +- modules/client_options/options.lua | 3 +- modules/client_terminal/terminal.lua | 4 +-- modules/client_topmenu/topmenu.lua | 6 ---- .../game_combatcontrols/combatcontrols.lua | 1 + modules/game_console/console.lua | 16 +++------- modules/game_cooldown/cooldown.lua | 1 + modules/game_healthinfo/healthinfo.lua | 14 +------- modules/game_hotkeys/hotkeys_manager.lua | 1 + modules/game_interface/gameinterface.lua | 6 ++-- modules/game_inventory/inventory.lua | 1 + modules/game_market/market.lua | 4 +-- modules/game_minimap/minimap.lua | 1 + modules/game_playerdeath/playerdeath.lua | 1 - modules/game_playermount/playermount.lua | 1 + modules/game_questlog/questlog.lua | 3 +- modules/game_skills/skills.lua | 3 ++ modules/game_spelllist/spelllist.lua | 32 +------------------ modules/game_viplist/viplist.lua | 1 - 21 files changed, 31 insertions(+), 77 deletions(-) diff --git a/modules/client_background/background.lua b/modules/client_background/background.lua index a3cc7eea..2af57648 100644 --- a/modules/client_background/background.lua +++ b/modules/client_background/background.lua @@ -25,7 +25,6 @@ function terminate() g_effects.cancelFade(background:getChildById('clientVersionLabel')) background:destroy() - background = nil Background = nil end diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 9c244a39..4ed01279 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -136,11 +136,17 @@ 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 551ffe7f..b2966ba2 100644 --- a/modules/client_modulemanager/modulemanager.lua +++ b/modules/client_modulemanager/modulemanager.lua @@ -22,7 +22,7 @@ end function terminate() moduleManagerWindow:destroy() - moduleManagerWindow = nil + moduleManagerButton:destroy() moduleList = nil end diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 7fad6be4..98d0588a 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -118,7 +118,8 @@ function terminate() --g_keyboard.unbindKeyDown('Ctrl+D') g_keyboard.unbindKeyDown('Ctrl+Shift+F') optionsWindow:destroy() - optionsWindow = nil + optionsButton:destroy() + audioButton:destroy() optionsTabBar = nil generalPanel = nil consolePanel = nil diff --git a/modules/client_terminal/terminal.lua b/modules/client_terminal/terminal.lua index 21ee66d5..49601f38 100644 --- a/modules/client_terminal/terminal.lua +++ b/modules/client_terminal/terminal.lua @@ -150,10 +150,8 @@ function terminate() g_settings.setList('terminal-history', commandHistory) g_keyboard.unbindKeyDown('Ctrl+T') g_logger.setOnLog(nil) - commandTextEdit = nil - terminalBuffer = nil terminalWindow:destroy() - terminalWindow = nil + terminalButton:destroy() commandEnv = nil end diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index 396a57a4..aeb75ba3 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -57,13 +57,7 @@ function terminate() disconnect(g_game, { onGameStart = showGameButtons, onGameEnd = hideGameButtons }) - leftButtonsPanel = nil - rightButtonsPanel = nil - leftGameButtonsPanel = nil - rightGameButtonsPanel = nil - topMenu:destroy() - topMenu = nil end function addLeftButton(id, description, icon, callback, front) diff --git a/modules/game_combatcontrols/combatcontrols.lua b/modules/game_combatcontrols/combatcontrols.lua index 695e25bf..1f04b2fc 100644 --- a/modules/game_combatcontrols/combatcontrols.lua +++ b/modules/game_combatcontrols/combatcontrols.lua @@ -51,6 +51,7 @@ function terminate() fightModeRadioGroup:destroy() combatControlsWindow:destroy() + combatControlsButton:destroy() disconnect(g_game, { onGameStart = online, diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 466c3d97..66df893c 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -73,9 +73,9 @@ violationWindow = nil violationReportTab = nil local ignoreSettings = { - privateMessages = false, - yelling = false, - players = {} + privateMessages = false, + yelling = false, + players = {} } function init() @@ -164,25 +164,17 @@ function terminate() if channelsWindow then channelsWindow:destroy() - channelsWindow = nil end if ignoreWindow then ignoreWindow:destroy() - ignoreWindow = nil end if violationWindow then violationWindow:destroy() - violationWindow = nil end - + consolePanel:destroy() - consolePanel = nil - consoleTextEdit = nil - consoleContentPanel = nil - consoleTabBar = nil - ownPrivateName = nil Console = nil diff --git a/modules/game_cooldown/cooldown.lua b/modules/game_cooldown/cooldown.lua index 0feb22d5..3a59a7e2 100644 --- a/modules/game_cooldown/cooldown.lua +++ b/modules/game_cooldown/cooldown.lua @@ -36,6 +36,7 @@ function terminate() onSpellCooldown = onSpellCooldown }) cooldownWindow:destroy() + cooldownButton:destroy() end function onMiniWindowClose() diff --git a/modules/game_healthinfo/healthinfo.lua b/modules/game_healthinfo/healthinfo.lua index d6319cad..1ab7b2f2 100644 --- a/modules/game_healthinfo/healthinfo.lua +++ b/modules/game_healthinfo/healthinfo.lua @@ -70,19 +70,7 @@ function terminate() disconnect(g_game, { onGameEnd = offline }) healthInfoWindow:destroy() - healthInfoWindow = nil - healthInfoButton = nil - - healthBar = nil - manaBar = nil - soulBar = nil - - healthLabel = nil - manaLabel = nil - soulLabel = nil - capLabel = nil - - HealthInfo = nil + healthInfoButton:destroy() end function toggle() diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index 38449996..67a3c124 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -88,6 +88,7 @@ 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 40d754d0..3905181d 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -123,11 +123,11 @@ function terminate() disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange }) + logoutButton:destroy() gameRootPanel:destroy() end function onGameStart() - logoutButton:setTooltip(tr('Logout')) show() -- open tibia has delay in auto walking @@ -139,7 +139,6 @@ function onGameStart() end function onGameEnd() - logoutButton:setTooltip(tr('Exit')) setupViewMode(0) hide() end @@ -151,10 +150,13 @@ function show() gameRootPanel:focus() gameMapPanel:followCreature(g_game.getLocalPlayer()) updateStretchShrink() + logoutButton:setTooltip(tr('Logout')) end function hide() disconnect(g_app, { onClose = tryExit }) + logoutButton:setTooltip(tr('Exit')) + if logoutWindow then logoutWindow:destroy() logoutWindow = nil diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index 60a01a72..4e2c87a2 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -39,6 +39,7 @@ function terminate() g_keyboard.unbindKeyDown('Ctrl+I') inventoryWindow:destroy() + inventoryButton:destroy() end function refresh() diff --git a/modules/game_market/market.lua b/modules/game_market/market.lua index 41574820..f76be950 100644 --- a/modules/game_market/market.lua +++ b/modules/game_market/market.lua @@ -737,9 +737,7 @@ function terminate() disconnect(g_game, { onGameEnd = Market.reset }) disconnect(g_game, { onGameEnd = Market.close }) - if marketWindow then - marketWindow:destroy() - end + marketWindow:destroy() Market = nil end diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index 4ffacb94..4a32570f 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -49,6 +49,7 @@ function terminate() g_keyboard.unbindKeyDown('Ctrl+M') minimapWindow:destroy() + minimapButton:destroy() end function toggle() diff --git a/modules/game_playerdeath/playerdeath.lua b/modules/game_playerdeath/playerdeath.lua index 338d18ca..34ed40e6 100644 --- a/modules/game_playerdeath/playerdeath.lua +++ b/modules/game_playerdeath/playerdeath.lua @@ -17,7 +17,6 @@ end function reset() if deathWindow then deathWindow:destroy() - deathWindow = nil end end diff --git a/modules/game_playermount/playermount.lua b/modules/game_playermount/playermount.lua index 660f852c..391d19f8 100644 --- a/modules/game_playermount/playermount.lua +++ b/modules/game_playermount/playermount.lua @@ -11,6 +11,7 @@ function terminate() onGameStart = online, onGameEnd = offline }) + offline() end function online() diff --git a/modules/game_questlog/questlog.lua b/modules/game_questlog/questlog.lua index afb2de5f..a7b1c8b6 100644 --- a/modules/game_questlog/questlog.lua +++ b/modules/game_questlog/questlog.lua @@ -18,17 +18,16 @@ function terminate() onGameEnd = destroyWindows}) destroyWindows() + questLogButton:destroy() end function destroyWindows() if questLogWindow then questLogWindow:destroy() - questLogWindow = nil end if questLineWindow then questLineWindow:destroy() - questLineWindow = nil end end diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index a72c19ba..1e0f065f 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -61,6 +61,7 @@ function terminate() g_keyboard.unbindKeyDown('Ctrl+S') skillsWindow:destroy() + skillsButton:destroy() end function expForLevel(level) @@ -231,6 +232,8 @@ end function checkExpSpeed() local player = g_game.getLocalPlayer() + if not player then return end + local currentExp = player:getExperience() local currentTime = g_clock.seconds() if player.lastExps ~= nil then diff --git a/modules/game_spelllist/spelllist.lua b/modules/game_spelllist/spelllist.lua index df432b51..d2facf65 100644 --- a/modules/game_spelllist/spelllist.lua +++ b/modules/game_spelllist/spelllist.lua @@ -173,41 +173,11 @@ function terminate() end }) spelllistWindow:destroy() - spelllistWindow = nil + spelllistButton:destroy() vocationRadioGroup:destroy() - vocationRadioGroup = nil groupRadioGroup:destroy() - groupRadioGroup = nil premiumRadioGroup:destroy() - premiumRadioGroup = nil - - spellList = nil - nameValueLabel = nil - formulaValueLabel = nil - vocationValueLabel = nil - groupValueLabel = nil - typeValueLabel = nil - cooldownValueLabel = nil - levelValueLabel = nil - manaValueLabel = nil - premiumValueLabel = nil - descriptionValueLabel = nil - - vocationBoxAny = nil - vocationBoxSorcerer = nil - vocationBoxDruid = nil - vocationBoxPaladin = nil - vocationBoxKnight = nil - - groupBoxAny = nil - groupBoxAttack = nil - groupBoxHealing = nil - groupBoxSupport = nil - - premiumBoxAny = nil - premiumBoxNo = nil - premiumBoxYes = nil end function initialiseSpelllist() diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 7ad90f07..af705159 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -35,7 +35,6 @@ function refresh() end vipWindow:setContentMinimumHeight(38) - --vipWindow:setContentMaximumHeight(256) end function clear()