cleanup
This commit is contained in:
+16
-8
@@ -1,13 +1,13 @@
|
||||
local menubg
|
||||
|
||||
function on_screen_changed(screen)
|
||||
if screen ~= "menu" then
|
||||
if menubg then
|
||||
menubg:destruct()
|
||||
menubg = nil
|
||||
end
|
||||
return
|
||||
local function clear_menu()
|
||||
if menubg then
|
||||
menubg:destruct()
|
||||
menubg = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function configure_menu()
|
||||
local controller = {}
|
||||
function controller.resize_menu_bg()
|
||||
local w, h = unpack(gui.get_viewport())
|
||||
@@ -19,8 +19,16 @@ function on_screen_changed(screen)
|
||||
end
|
||||
_GUI_ROOT.root:add(
|
||||
"<image id='menubg' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
||||
"z-index='-1000' interactive='true'/>", controller)
|
||||
"z-index='-1' interactive='true'/>", controller)
|
||||
menubg = _GUI_ROOT.menubg
|
||||
controller.resize_menu_bg()
|
||||
menu.page = "main"
|
||||
end
|
||||
|
||||
function on_screen_changed(screen)
|
||||
if screen ~= "menu" then
|
||||
clear_menu()
|
||||
else
|
||||
configure_menu()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user