refact
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

This commit is contained in:
2026-02-22 18:15:24 +01:00
parent d9febf16e0
commit 62d4863a1a
33 changed files with 328 additions and 313 deletions

View File

@@ -1,27 +0,0 @@
--- Stops current music.
function Audio.music_stop() music() end
--- Plays main menu music.
function Audio.music_play_mainmenu() end
--- Plays waking up music.
function Audio.music_play_wakingup() end
--- Plays room morning music.
function Audio.music_play_room_morning() end
--- Plays room street 1 music.
function Audio.music_play_room_street_1() end
--- Plays room street 2 music.
function Audio.music_play_room_street_2() end
--- Plays room music.
function Audio.music_play_room_() end
--- Plays room work music.
function Audio.music_play_room_work() end
--- Plays select sound effect.
function Audio.sfx_select() sfx(17, 'C-7', 30) end
--- Plays deselect sound effect.
function Audio.sfx_deselect() sfx(18, 'C-7', 30) end
--- Plays beep sound effect.
function Audio.sfx_beep() sfx(19, 'C-6', 30) end
--- Plays success sound effect.
function Audio.sfx_success() sfx(16, 'C-7', 60) end
--- Plays bloop sound effect.
function Audio.sfx_bloop() sfx(21, 'C-3', 60) end

View File

@@ -1,53 +1,10 @@
local STATE_HANDLERS = {
[WINDOW_SPLASH] = function()
SplashWindow.update()
SplashWindow.draw()
end,
[WINDOW_INTRO] = function()
IntroWindow.update()
IntroWindow.draw()
end,
[WINDOW_MENU] = function()
MenuWindow.update()
MenuWindow.draw()
end,
[WINDOW_GAME] = function()
GameWindow.update()
GameWindow.draw()
end,
[WINDOW_POPUP] = function()
GameWindow.draw()
PopupWindow.update()
PopupWindow.draw()
end,
[WINDOW_CONFIGURATION] = function()
ConfigurationWindow.update()
ConfigurationWindow.draw()
end,
[WINDOW_AUDIOTEST] = function()
AudioTestWindow.update()
AudioTestWindow.draw()
end,
[WINDOW_MINIGAME_BUTTON_MASH] = function()
MinigameButtonMashWindow.update()
MinigameButtonMashWindow.draw()
end,
[WINDOW_MINIGAME_RHYTHM] = function()
MinigameRhythmWindow.update()
MinigameRhythmWindow.draw()
end,
[WINDOW_MINIGAME_DDR] = function()
MinigameDDRWindow.update()
MinigameDDRWindow.draw()
end,
}
local initialized_game = false
--- Initializes game state.
local function init_game()
if initialized_game then return end
Context.reset()
Window.set_current("splash") -- Set initial window using new manager
MenuWindow.refresh_menu_items()
initialized_game = true
end
@@ -56,7 +13,7 @@ end
function TIC()
init_game()
cls(Config.colors.black)
local handler = STATE_HANDLERS[Context.active_window]
local handler = Window.get_current_handler() -- Get handler from Window manager
if handler then
handler()
end

View File

@@ -12,10 +12,26 @@ end
--- Navigates to a screen by its ID.
-- @param screen_id string The ID of the screen to go to.
function Util.go_to_screen_by_id(screen_id)
local screen_index = Context.screen_indices_by_id[screen_id]
if screen_index then
Context.current_screen = screen_index
Context.selected_decision_index = 1 else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"})
local screen = Screen.get_by_id(screen_id)
if screen then
Context.game.current_screen = screen_id
local all_decisions_for_screen = Decision.get_for_screen(screen)
Context.game.decisions = Decision.filter_available(all_decisions_for_screen)
Context.game.selected_decision_index = 1
screen.init() -- Initialize the new screen
else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
end
end
-- Checks if a table contains a specific value.
-- @param t table The table to check.
-- @param value any The value to look for.
function Util.contains(t, value)
for i = 1, #t do
if t[i] == value then
return true
end
end
return false
end