diff --git a/inc/decision/decision.go_to_home.lua b/inc/decision/decision.go_to_home.lua index f6aeb1a..4b5e670 100644 --- a/inc/decision/decision.go_to_home.lua +++ b/inc/decision/decision.go_to_home.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Util.go_to_screen_by_id("home") end, - condition = function() return true end }) diff --git a/inc/decision/decision.go_to_office.lua b/inc/decision/decision.go_to_office.lua index baf50b7..4cd3f2d 100644 --- a/inc/decision/decision.go_to_office.lua +++ b/inc/decision/decision.go_to_office.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Util.go_to_screen_by_id("office") end, - condition = function() return true end }) diff --git a/inc/decision/decision.go_to_toilet.lua b/inc/decision/decision.go_to_toilet.lua index db80534..1a6d8b9 100644 --- a/inc/decision/decision.go_to_toilet.lua +++ b/inc/decision/decision.go_to_toilet.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Util.go_to_screen_by_id("toilet") end, - condition = function() return true end }) diff --git a/inc/decision/decision.go_to_walking_to_home.lua b/inc/decision/decision.go_to_walking_to_home.lua index d17e1da..842c639 100644 --- a/inc/decision/decision.go_to_walking_to_home.lua +++ b/inc/decision/decision.go_to_walking_to_home.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Util.go_to_screen_by_id("walking_to_home") end, - condition = function() return true end }) diff --git a/inc/decision/decision.go_to_walking_to_office.lua b/inc/decision/decision.go_to_walking_to_office.lua index 685141d..73e0594 100644 --- a/inc/decision/decision.go_to_walking_to_office.lua +++ b/inc/decision/decision.go_to_walking_to_office.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Util.go_to_screen_by_id("walking_to_office") end, - condition = function() return true end }) diff --git a/inc/decision/decision.have_a_coffee.lua b/inc/decision/decision.have_a_coffee.lua index e92e940..43d84f3 100644 --- a/inc/decision/decision.have_a_coffee.lua +++ b/inc/decision/decision.have_a_coffee.lua @@ -4,5 +4,4 @@ Decision.register({ handle = function() Situation.apply("drink_coffee") end, - condition = function() return true end }) diff --git a/inc/decision/decision.play_button_mash.lua b/inc/decision/decision.play_button_mash.lua index cbfd47a..b1f4820 100644 --- a/inc/decision/decision.play_button_mash.lua +++ b/inc/decision/decision.play_button_mash.lua @@ -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 }) diff --git a/inc/decision/decision.play_ddr.lua b/inc/decision/decision.play_ddr.lua index 2dcb4e0..57f8cf5 100644 --- a/inc/decision/decision.play_ddr.lua +++ b/inc/decision/decision.play_ddr.lua @@ -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 }) diff --git a/inc/decision/decision.play_rhythm.lua b/inc/decision/decision.play_rhythm.lua index 196a743..3c8312e 100644 --- a/inc/decision/decision.play_rhythm.lua +++ b/inc/decision/decision.play_rhythm.lua @@ -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 }) diff --git a/inc/init/init.context.lua b/inc/init/init.context.lua index cdc133a..8be51d2 100644 --- a/inc/init/init.context.lua +++ b/inc/init/init.context.lua @@ -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 diff --git a/inc/screen/screen.manager.lua b/inc/screen/screen.manager.lua index 42b50f3..48a9cc5 100644 --- a/inc/screen/screen.manager.lua +++ b/inc/screen/screen.manager.lua @@ -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 diff --git a/inc/situation/situation.manager.lua b/inc/situation/situation.manager.lua index 88c6b2d..33ff99a 100644 --- a/inc/situation/situation.manager.lua +++ b/inc/situation/situation.manager.lua @@ -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 diff --git a/inc/window/window.game.lua b/inc/window/window.game.lua index 85b9375..919fcd1 100644 --- a/inc/window/window.game.lua +++ b/inc/window/window.game.lua @@ -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