Compare commits

...

3 Commits

Author SHA1 Message Date
7e1dd28808 screen init, update, optional decision condition
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
2026-02-21 23:35:00 +01:00
0b25ecc793 set window objects to global
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-02-21 23:18:42 +01:00
f08e4ad1d4 Merge pull request 'sprite handling' (#10) from feature/sprite-handling into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #10
2026-02-21 22:13:31 +00:00
15 changed files with 46 additions and 19 deletions

View File

@@ -14,6 +14,16 @@ globals = {
"Context",
"Meters",
"Minigames",
"SplashWindow",
"IntroWindow",
"MenuWindow",
"GameWindow",
"PopupWindow",
"ConfigurationWindow",
"AudioTestWindow",
"MinigameButtonMashWindow",
"MinigameRhythmWindow",
"MinigameDDRWindow",
"mset",
"mget",
"btnp",

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Util.go_to_screen_by_id("home")
end,
condition = function() return true end
})

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Util.go_to_screen_by_id("office")
end,
condition = function() return true end
})

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Util.go_to_screen_by_id("toilet")
end,
condition = function() return true end
})

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Util.go_to_screen_by_id("walking_to_home")
end,
condition = function() return true end
})

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Util.go_to_screen_by_id("walking_to_office")
end,
condition = function() return true end
})

View File

@@ -4,5 +4,4 @@ Decision.register({
handle = function()
Situation.apply("drink_coffee")
end,
condition = function() return true end
})

View File

@@ -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
})

View File

@@ -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
})

View File

@@ -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
})

View File

@@ -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

View File

@@ -1,13 +1,13 @@
local SplashWindow = {}
local IntroWindow = {}
local MenuWindow = {}
local GameWindow = {}
local PopupWindow = {}
local ConfigurationWindow = {}
local AudioTestWindow = {}
local MinigameButtonMashWindow = {}
local MinigameRhythmWindow = {}
local MinigameDDRWindow = {}
SplashWindow = {}
IntroWindow = {}
MenuWindow = {}
GameWindow = {}
PopupWindow = {}
ConfigurationWindow = {}
AudioTestWindow = {}
MinigameButtonMashWindow = {}
MinigameRhythmWindow = {}
MinigameDDRWindow = {}
Util = {}
Meters = {}
Minigames = {}

View File

@@ -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

View File

@@ -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

View File

@@ -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