Save miniwindows states

This commit is contained in:
Henrique Santiago
2012-06-21 16:31:22 -03:00
parent 96c363d997
commit a7c17cec2e
22 changed files with 317 additions and 60 deletions

View File

@@ -35,7 +35,7 @@ function HealthBar.init()
connect(g_game, { onGameEnd = HealthBar.offline })
healthBarWindow = displayUI('healthbar.otui', GameInterface.getLeftPanel())
healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', tr('Health Bar'), 'healthbar.png', HealthBar.toggle)
healthBarButton:setOn(true)
healthBar = healthBarWindow:recursiveGetChildById('healthBar')
@@ -71,9 +71,17 @@ function HealthBar.terminate()
end
function HealthBar.toggle()
local visible = not healthBarWindow:isExplicitlyVisible()
healthBarWindow:setVisible(visible)
healthBarButton:setOn(visible)
if healthBarButton:isOn() then
healthBarWindow:close()
healthBarButton:setOn(false)
else
healthBarWindow:open()
healthBarButton:setOn(true)
end
end
function HealthBar.onMiniWindowClose()
healthBarButton:setOn(false)
end
function HealthBar.offline()

View File

@@ -45,7 +45,7 @@ MiniWindow
id: healthBarWindow
!text: tr('Health Bar')
height: 86
@onClose: HealthBar.toggle()
@onClose: HealthBar.onMiniWindowClose()
MiniWindowContents
HealthBar
@@ -61,4 +61,3 @@ MiniWindow
margin-top: 5
anchors.top: prev.bottom
anchors.horizontalcenter: parent.horizontalcenter