screen exit handler #37
@@ -21,6 +21,9 @@ function Screen.register(screen_data)
|
|||||||
end
|
end
|
||||||
if not screen_data.init then
|
if not screen_data.init then
|
||||||
screen_data.init = function() end
|
screen_data.init = function() end
|
||||||
|
end
|
||||||
|
if not screen_data.exit then
|
||||||
|
screen_data.exit = function() end
|
||||||
end
|
end
|
||||||
if not screen_data.update then
|
if not screen_data.update then
|
||||||
screen_data.update = function() end
|
screen_data.update = function() end
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ end
|
|||||||
--- @within Util
|
--- @within Util
|
||||||
--- @param screen_id string The ID of the screen to go to.<br/>
|
--- @param screen_id string The ID of the screen to go to.<br/>
|
||||||
function Util.go_to_screen_by_id(screen_id)
|
function Util.go_to_screen_by_id(screen_id)
|
||||||
local screen = Screen.get_by_id(screen_id)
|
local prev_screen = Screen.get_by_id(Context.game.current_screen)
|
||||||
if screen then
|
local new_screen = Screen.get_by_id(screen_id)
|
||||||
|
if new_screen then
|
||||||
Context.game.current_screen = screen_id
|
Context.game.current_screen = screen_id
|
||||||
screen.init()
|
if prev_screen and prev_screen.exit then
|
||||||
|
prev_screen.exit()
|
||||||
|
end
|
||||||
|
new_screen.init()
|
||||||
else
|
else
|
||||||
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
|
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function EndWindow.update()
|
|||||||
else
|
else
|
||||||
-- NO: increment day and go home
|
-- NO: increment day and go home
|
||||||
Day.increase()
|
Day.increase()
|
||||||
Context.game.current_screen = "home"
|
Util.go_to_screen_by_id("home")
|
||||||
Window.set_current("game")
|
Window.set_current("game")
|
||||||
-- Initialize home screen
|
-- Initialize home screen
|
||||||
local home_screen = Screen.get_by_id("home")
|
local home_screen = Screen.get_by_id("home")
|
||||||
|
|||||||
Reference in New Issue
Block a user