Re-add destroying for unloading, other clean up:

* Cleaned some module terminate code
* Fixed "reload all" issues
This commit is contained in:
BeniS 2013-02-01 17:32:15 +13:00
parent 35e5dd8af8
commit 7f5dda5c8f
21 changed files with 31 additions and 77 deletions

View File

@ -25,7 +25,6 @@ function terminate()
g_effects.cancelFade(background:getChildById('clientVersionLabel')) g_effects.cancelFade(background:getChildById('clientVersionLabel'))
background:destroy() background:destroy()
background = nil
Background = nil Background = nil
end end

View File

@ -136,11 +136,17 @@ function EnterGame.terminate()
removeEvent(autoLoginEvent) removeEvent(autoLoginEvent)
enterGame:destroy() enterGame:destroy()
enterGame = nil enterGame = nil
enterGameButton:destroy()
enterGameButton = nil
protocolBox = nil protocolBox = nil
if motdWindow then if motdWindow then
motdWindow:destroy() motdWindow:destroy()
motdWindow = nil motdWindow = nil
end end
if motdButton then
motdButton:destroy()
motdButton = nil
end
if loadBox then if loadBox then
loadBox:destroy() loadBox:destroy()
loadBox = nil loadBox = nil

View File

@ -22,7 +22,7 @@ end
function terminate() function terminate()
moduleManagerWindow:destroy() moduleManagerWindow:destroy()
moduleManagerWindow = nil moduleManagerButton:destroy()
moduleList = nil moduleList = nil
end end

View File

@ -118,7 +118,8 @@ function terminate()
--g_keyboard.unbindKeyDown('Ctrl+D') --g_keyboard.unbindKeyDown('Ctrl+D')
g_keyboard.unbindKeyDown('Ctrl+Shift+F') g_keyboard.unbindKeyDown('Ctrl+Shift+F')
optionsWindow:destroy() optionsWindow:destroy()
optionsWindow = nil optionsButton:destroy()
audioButton:destroy()
optionsTabBar = nil optionsTabBar = nil
generalPanel = nil generalPanel = nil
consolePanel = nil consolePanel = nil

View File

@ -150,10 +150,8 @@ function terminate()
g_settings.setList('terminal-history', commandHistory) g_settings.setList('terminal-history', commandHistory)
g_keyboard.unbindKeyDown('Ctrl+T') g_keyboard.unbindKeyDown('Ctrl+T')
g_logger.setOnLog(nil) g_logger.setOnLog(nil)
commandTextEdit = nil
terminalBuffer = nil
terminalWindow:destroy() terminalWindow:destroy()
terminalWindow = nil terminalButton:destroy()
commandEnv = nil commandEnv = nil
end end

View File

@ -57,13 +57,7 @@ function terminate()
disconnect(g_game, { onGameStart = showGameButtons, disconnect(g_game, { onGameStart = showGameButtons,
onGameEnd = hideGameButtons }) onGameEnd = hideGameButtons })
leftButtonsPanel = nil
rightButtonsPanel = nil
leftGameButtonsPanel = nil
rightGameButtonsPanel = nil
topMenu:destroy() topMenu:destroy()
topMenu = nil
end end
function addLeftButton(id, description, icon, callback, front) function addLeftButton(id, description, icon, callback, front)

View File

@ -51,6 +51,7 @@ function terminate()
fightModeRadioGroup:destroy() fightModeRadioGroup:destroy()
combatControlsWindow:destroy() combatControlsWindow:destroy()
combatControlsButton:destroy()
disconnect(g_game, { disconnect(g_game, {
onGameStart = online, onGameStart = online,

View File

@ -164,25 +164,17 @@ function terminate()
if channelsWindow then if channelsWindow then
channelsWindow:destroy() channelsWindow:destroy()
channelsWindow = nil
end end
if ignoreWindow then if ignoreWindow then
ignoreWindow:destroy() ignoreWindow:destroy()
ignoreWindow = nil
end end
if violationWindow then if violationWindow then
violationWindow:destroy() violationWindow:destroy()
violationWindow = nil
end end
consolePanel:destroy() consolePanel:destroy()
consolePanel = nil
consoleTextEdit = nil
consoleContentPanel = nil
consoleTabBar = nil
ownPrivateName = nil ownPrivateName = nil
Console = nil Console = nil

View File

@ -36,6 +36,7 @@ function terminate()
onSpellCooldown = onSpellCooldown }) onSpellCooldown = onSpellCooldown })
cooldownWindow:destroy() cooldownWindow:destroy()
cooldownButton:destroy()
end end
function onMiniWindowClose() function onMiniWindowClose()

View File

@ -70,19 +70,7 @@ function terminate()
disconnect(g_game, { onGameEnd = offline }) disconnect(g_game, { onGameEnd = offline })
healthInfoWindow:destroy() healthInfoWindow:destroy()
healthInfoWindow = nil healthInfoButton:destroy()
healthInfoButton = nil
healthBar = nil
manaBar = nil
soulBar = nil
healthLabel = nil
manaLabel = nil
soulLabel = nil
capLabel = nil
HealthInfo = nil
end end
function toggle() function toggle()

View File

@ -88,6 +88,7 @@ function terminate()
unload() unload()
hotkeysWindow:destroy() hotkeysWindow:destroy()
hotkeysButton:destroy()
mouseGrabberWidget:destroy() mouseGrabberWidget:destroy()
end end

View File

@ -123,11 +123,11 @@ function terminate()
disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange }) disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })
logoutButton:destroy()
gameRootPanel:destroy() gameRootPanel:destroy()
end end
function onGameStart() function onGameStart()
logoutButton:setTooltip(tr('Logout'))
show() show()
-- open tibia has delay in auto walking -- open tibia has delay in auto walking
@ -139,7 +139,6 @@ function onGameStart()
end end
function onGameEnd() function onGameEnd()
logoutButton:setTooltip(tr('Exit'))
setupViewMode(0) setupViewMode(0)
hide() hide()
end end
@ -151,10 +150,13 @@ function show()
gameRootPanel:focus() gameRootPanel:focus()
gameMapPanel:followCreature(g_game.getLocalPlayer()) gameMapPanel:followCreature(g_game.getLocalPlayer())
updateStretchShrink() updateStretchShrink()
logoutButton:setTooltip(tr('Logout'))
end end
function hide() function hide()
disconnect(g_app, { onClose = tryExit }) disconnect(g_app, { onClose = tryExit })
logoutButton:setTooltip(tr('Exit'))
if logoutWindow then if logoutWindow then
logoutWindow:destroy() logoutWindow:destroy()
logoutWindow = nil logoutWindow = nil

View File

@ -39,6 +39,7 @@ function terminate()
g_keyboard.unbindKeyDown('Ctrl+I') g_keyboard.unbindKeyDown('Ctrl+I')
inventoryWindow:destroy() inventoryWindow:destroy()
inventoryButton:destroy()
end end
function refresh() function refresh()

View File

@ -737,9 +737,7 @@ function terminate()
disconnect(g_game, { onGameEnd = Market.reset }) disconnect(g_game, { onGameEnd = Market.reset })
disconnect(g_game, { onGameEnd = Market.close }) disconnect(g_game, { onGameEnd = Market.close })
if marketWindow then
marketWindow:destroy() marketWindow:destroy()
end
Market = nil Market = nil
end end

View File

@ -49,6 +49,7 @@ function terminate()
g_keyboard.unbindKeyDown('Ctrl+M') g_keyboard.unbindKeyDown('Ctrl+M')
minimapWindow:destroy() minimapWindow:destroy()
minimapButton:destroy()
end end
function toggle() function toggle()

View File

@ -17,7 +17,6 @@ end
function reset() function reset()
if deathWindow then if deathWindow then
deathWindow:destroy() deathWindow:destroy()
deathWindow = nil
end end
end end

View File

@ -11,6 +11,7 @@ function terminate()
onGameStart = online, onGameStart = online,
onGameEnd = offline onGameEnd = offline
}) })
offline()
end end
function online() function online()

View File

@ -18,17 +18,16 @@ function terminate()
onGameEnd = destroyWindows}) onGameEnd = destroyWindows})
destroyWindows() destroyWindows()
questLogButton:destroy()
end end
function destroyWindows() function destroyWindows()
if questLogWindow then if questLogWindow then
questLogWindow:destroy() questLogWindow:destroy()
questLogWindow = nil
end end
if questLineWindow then if questLineWindow then
questLineWindow:destroy() questLineWindow:destroy()
questLineWindow = nil
end end
end end

View File

@ -61,6 +61,7 @@ function terminate()
g_keyboard.unbindKeyDown('Ctrl+S') g_keyboard.unbindKeyDown('Ctrl+S')
skillsWindow:destroy() skillsWindow:destroy()
skillsButton:destroy()
end end
function expForLevel(level) function expForLevel(level)
@ -231,6 +232,8 @@ end
function checkExpSpeed() function checkExpSpeed()
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if not player then return end
local currentExp = player:getExperience() local currentExp = player:getExperience()
local currentTime = g_clock.seconds() local currentTime = g_clock.seconds()
if player.lastExps ~= nil then if player.lastExps ~= nil then

View File

@ -173,41 +173,11 @@ function terminate()
end }) end })
spelllistWindow:destroy() spelllistWindow:destroy()
spelllistWindow = nil spelllistButton:destroy()
vocationRadioGroup:destroy() vocationRadioGroup:destroy()
vocationRadioGroup = nil
groupRadioGroup:destroy() groupRadioGroup:destroy()
groupRadioGroup = nil
premiumRadioGroup:destroy() 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 end
function initialiseSpelllist() function initialiseSpelllist()

View File

@ -35,7 +35,6 @@ function refresh()
end end
vipWindow:setContentMinimumHeight(38) vipWindow:setContentMinimumHeight(38)
--vipWindow:setContentMaximumHeight(256)
end end
function clear() function clear()