Minor bug fixes

This commit is contained in:
OTCv8
2020-01-31 19:11:08 +01:00
parent 6bc4188d7a
commit dbfad99ca4
3 changed files with 37 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ function timeleftTranslation(timeleft, forPreyTimeleft) -- in seconds
end
function init()
connect(g_game, {
onGameStart = check,
onGameEnd = hide,
onResourceBalance = onResourceBalance,
@@ -73,11 +74,14 @@ function init()
})
preyWindow = g_ui.displayUI('prey')
preyWindow:hide()
preyWindow:hide()
if g_game.isOnline() then
check()
end
end
function terminate()
disconnect(g_game, {
onGameStart = check,
onGameEnd = hide,
onResourceBalance = onResourceBalance,
@@ -89,7 +93,9 @@ function terminate()
onPreyActive = onPreyActive,
onPreySelection = onPreySelection
})
if preyButton then
preyButton:destroy()
end
preyWindow:destroy()
if msgWindow then
@@ -97,6 +103,17 @@ function terminate()
msgWindow = nil
end
end
function check()
if g_game.getFeature(GamePrey) then
if not preyButton then
preyButton = modules.client_topmenu.addRightGameToggleButton('preyButton', tr('Preys'), '/images/topbuttons/prey', toggle)
end
elseif preyButton then
preyButton:destroy()
preyButton = nil
end
end
function hide()
preyWindow:hide()
@@ -106,6 +123,9 @@ function hide()
end
end
function show()
if not g_game.getFeature(GamePrey) then
return hide()
end
preyWindow:show()
preyWindow:raise()