screen init, update, optional decision condition #11
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Util.go_to_screen_by_id("home")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Util.go_to_screen_by_id("office")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Util.go_to_screen_by_id("toilet")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Util.go_to_screen_by_id("walking_to_home")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Util.go_to_screen_by_id("walking_to_office")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -4,5 +4,4 @@ Decision.register({
|
||||
handle = function()
|
||||
Situation.apply("drink_coffee")
|
||||
end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -2,5 +2,4 @@ Decision.register({
|
||||
id = "play_button_mash",
|
||||
label = "Play Button Mash",
|
||||
handle = function() Meters.hide() MinigameButtonMashWindow.start(WINDOW_GAME) end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -2,5 +2,4 @@ Decision.register({
|
||||
id = "play_ddr",
|
||||
label = "Play DDR (Random)",
|
||||
handle = function() Meters.hide() MinigameDDRWindow.start(WINDOW_GAME, nil) end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -2,5 +2,4 @@ Decision.register({
|
||||
id = "play_rhythm",
|
||||
label = "Play Rhythm Game",
|
||||
handle = function() Meters.hide() MinigameRhythmWindow.start(WINDOW_GAME) end,
|
||||
condition = function() return true end
|
||||
})
|
||||
|
||||
@@ -85,6 +85,7 @@ function Context.new_game()
|
||||
reset_context_to_initial_state()
|
||||
Context.game_in_progress = true
|
||||
MenuWindow.refresh_menu_items()
|
||||
Context.screens[Context.current_screen].init()
|
||||
end
|
||||
|
||||
function Context.save_game()
|
||||
@@ -105,4 +106,5 @@ function Context.load_game()
|
||||
|
||||
Context.game_in_progress = true
|
||||
MenuWindow.refresh_menu_items()
|
||||
Context.screens[Context.current_screen].init()
|
||||
end
|
||||
|
||||
@@ -7,6 +7,12 @@ function Screen.register(screen_data)
|
||||
if not screen_data.situations then
|
||||
screen_data.situations = {}
|
||||
end
|
||||
if not screen_data.init then
|
||||
screen_data.init = function() end
|
||||
end
|
||||
if not screen_data.update then
|
||||
screen_data.update = function() end
|
||||
end
|
||||
_screens[screen_data.id] = screen_data
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ function Situation.register(situation)
|
||||
if not situation.handle then
|
||||
situation.handle = function() end
|
||||
end
|
||||
if not situation.update then
|
||||
situation.update = function() end
|
||||
end
|
||||
if _situations[situation.id] then
|
||||
trace("Warning: Overwriting situation with id: " .. situation.id)
|
||||
end
|
||||
|
||||
@@ -18,6 +18,8 @@ function GameWindow.draw()
|
||||
end
|
||||
|
||||
function GameWindow.update()
|
||||
local previous_screen_index = Context.current_screen
|
||||
|
||||
if Input.menu_back() then
|
||||
Context.active_window = WINDOW_MENU
|
||||
MenuWindow.refresh_menu_items()
|
||||
@@ -37,6 +39,19 @@ function GameWindow.update()
|
||||
Context.selected_decision_index = 1 end
|
||||
|
||||
local screen = Context.screens[Context.current_screen]
|
||||
screen.update()
|
||||
|
||||
if previous_screen_index ~= Context.current_screen then
|
||||
screen.init()
|
||||
end
|
||||
|
||||
if Context.current_situation then
|
||||
local current_situation_obj = Situation.get(Context.current_situation)
|
||||
if current_situation_obj and current_situation_obj.update then
|
||||
current_situation_obj.update()
|
||||
end
|
||||
end
|
||||
|
||||
if screen and screen.decisions and #screen.decisions > 0 then
|
||||
local available_decisions = {}
|
||||
for _, decision_id in ipairs(screen.decisions) do
|
||||
|
||||
Reference in New Issue
Block a user