Compare commits

...

4 Commits

Author SHA1 Message Date
Zsolt Tasnadi
39e06d1d09 refact by claude
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2026-02-23 10:22:41 +01:00
272a54ea87 fix colors
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-02-22 21:32:24 +01:00
14b14ffc0c window.register.lua
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-02-22 21:26:59 +01:00
7e87a78a15 Merge pull request 'feature/context-refactoring' (#13) from feature/context-refactoring into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #13
2026-02-22 19:19:02 +00:00
11 changed files with 64 additions and 55 deletions

View File

@@ -58,8 +58,8 @@ export: build
@ls -lh $(PROJECT)-$(VERSION).* $(PROJECT).tic $(PROJECT).html.zip 2>/dev/null || true @ls -lh $(PROJECT)-$(VERSION).* $(PROJECT).tic $(PROJECT).html.zip 2>/dev/null || true
watch: watch:
make build $(MAKE) build
fswatch -o $(SRC_DIR) $(ORDER) assets | while read; do make build; done fswatch -o $(SRC_DIR) $(ORDER) assets | while read; do $(MAKE) build; done
import_assets: $(OUTPUT) import_assets: $(OUTPUT)
@TIC_CMD="load $(OUTPUT) &"; \ @TIC_CMD="load $(OUTPUT) &"; \
@@ -221,10 +221,3 @@ docs: build
.PHONY: all build export watch import_assets export_assets clean lint ci-version ci-export ci-upload ci-update install_precommit_hook docs .PHONY: all build export watch import_assets export_assets clean lint ci-version ci-export ci-upload ci-update install_precommit_hook docs
#-- <WAVES>
#-- 000:224578acdeeeeddcba95434567653100
#-- </WAVES>
#
#-- <SFX>
#-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000
#-- </SFX>

View File

@@ -3,7 +3,6 @@ init/init.module.lua
init/init.config.lua init/init.config.lua
init/init.minigame.lua init/init.minigame.lua
init/init.meter.lua init/init.meter.lua
init/init.window.lua
init/init.context.lua init/init.context.lua
system/system.util.lua system/system.util.lua
system/system.print.lua system/system.print.lua
@@ -34,6 +33,7 @@ screen/screen.walking_to_office.lua
screen/screen.office.lua screen/screen.office.lua
screen/screen.walking_to_home.lua screen/screen.walking_to_home.lua
window/window.manager.lua window/window.manager.lua
window/window.register.lua
window/window.splash.lua window/window.splash.lua
window/window.intro.lua window/window.intro.lua
window/window.menu.lua window/window.menu.lua

View File

@@ -11,6 +11,7 @@ function Audio.music_play_room_street_1() end
--- Plays room street 2 music. --- Plays room street 2 music.
function Audio.music_play_room_street_2() end function Audio.music_play_room_street_2() end
--- Plays room music. --- Plays room music.
-- TODO: function name is incomplete, determine the correct room identifier
function Audio.music_play_room_() end function Audio.music_play_room_() end
--- Plays room work music. --- Plays room work music.
function Audio.music_play_room_work() end function Audio.music_play_room_work() end

View File

@@ -7,11 +7,11 @@ function Config.initial_data()
height = 136 height = 136
}, },
colors = { colors = {
black = 0, black = 2,
light_grey = 13, light_grey = 13,
dark_grey = 14, dark_grey = 14,
red = 2, red = 0,
green = 6, green = 7,
blue = 9, blue = 9,
white = 12, white = 12,
item = 12, item = 12,

View File

@@ -123,10 +123,13 @@ function UI.draw_decision_selector(decisions, selected_decision_index)
if #decisions > 0 then if #decisions > 0 then
local selected_decision = decisions[selected_decision_index] local selected_decision = decisions[selected_decision_index]
local decision_label = selected_decision.label local decision_label = selected_decision.label
local text_width = #decision_label * 4 local text_y = bar_y + 4 local text_width = #decision_label * 4
local text_x = (Config.screen.width - text_width) / 2 local text_y = bar_y + 4
Print.text("<", 2, text_y, Config.colors.green) local text_x = (Config.screen.width - text_width) / 2
Print.text(decision_label, text_x, text_y, Config.colors.item) Print.text(">", Config.screen.width - 6, text_y, Config.colors.green) end Print.text("<", 2, text_y, Config.colors.green)
Print.text(decision_label, text_x, text_y, Config.colors.item)
Print.text(">", Config.screen.width - 6, text_y, Config.colors.green)
end
end end
--- Draws meters. --- Draws meters.

View File

@@ -19,7 +19,7 @@ function AudioTestWindow.generate_menuitems(list_func, index_func)
if current_func then if current_func then
current_func() current_func()
else else
trace("Invalid Audio function: " .. list_func[index_menu]) trace("Invalid Audio function: " .. list_func[index_func])
end end
end end
}, },

View File

@@ -6,13 +6,13 @@ ConfigurationWindow = {
--- Initializes configuration window. --- Initializes configuration window.
function ConfigurationWindow.init() function ConfigurationWindow.init()
ConfigurationWindow.controls = { ConfigurationWindow.controls = {
UI.create_decision_item( UI.create_action_item(
"Save", "Save",
function() Config.save() end function() Config.save() end
), ),
UI.create_decision_item( UI.create_action_item(
"Restore Defaults", "Restore Defaults",
function() Config.restore_defaults() end function() Config.reset() end
), ),
} }
end end
@@ -21,7 +21,8 @@ end
function ConfigurationWindow.draw() function ConfigurationWindow.draw()
UI.draw_top_bar("Configuration") UI.draw_top_bar("Configuration")
local x_start = 10 local y_start = 40 local x_start = 10
local y_start = 40
local x_value_right_align = Config.screen.width - 10 local x_value_right_align = Config.screen.width - 10
local char_width = 4 local char_width = 4
for i, control in ipairs(ConfigurationWindow.controls) do for i, control in ipairs(ConfigurationWindow.controls) do
@@ -31,22 +32,23 @@ function ConfigurationWindow.draw()
local value = control.get() local value = control.get()
local label_text = control.label local label_text = control.label
local value_text = string.format(control.format, value) local value_text = string.format(control.format, value)
local value_x = x_value_right_align - (#value_text * char_width)
local value_x = x_value_right_align - (#value_text * char_width)
if i == ConfigurationWindow.selected_control then if i == ConfigurationWindow.selected_control then
color = Config.colors.item color = Config.colors.item
Print.text("<", x_start -8, current_y, color) Print.text("<", x_start - 8, current_y, color)
Print.text(label_text, x_start, current_y, color) Print.text(value_text, value_x, current_y, color) Print.text(label_text, x_start, current_y, color)
Print.text(">", x_value_right_align + 4, current_y, color) else Print.text(value_text, value_x, current_y, color)
Print.text(">", x_value_right_align + 4, current_y, color)
else
Print.text(label_text, x_start, current_y, color) Print.text(label_text, x_start, current_y, color)
Print.text(value_text, value_x, current_y, color) Print.text(value_text, value_x, current_y, color)
end end
elseif control.type == "decision_item" then elseif control.type == "action_item" then
local label_text = control.label local label_text = control.label
if i == ConfigurationWindow.selected_control then if i == ConfigurationWindow.selected_control then
color = Config.colors.item color = Config.colors.item
Print.text("<", x_start -8, current_y, color) Print.text("<", x_start - 8, current_y, color)
Print.text(label_text, x_start, current_y, color) Print.text(label_text, x_start, current_y, color)
Print.text(">", x_start + 8 + (#label_text * char_width) + 4, current_y, color) Print.text(">", x_start + 8 + (#label_text * char_width) + 4, current_y, color)
else else
@@ -80,14 +82,16 @@ function ConfigurationWindow.update()
if control then if control then
if control.type == "numeric_stepper" then if control.type == "numeric_stepper" then
local current_value = control.get() local current_value = control.get()
if btnp(2) then local new_value = math.max(control.min, current_value - control.step) if Input.left() then
local new_value = math.max(control.min, current_value - control.step)
control.set(new_value) control.set(new_value)
elseif btnp(3) then local new_value = math.min(control.max, current_value + control.step) elseif Input.right() then
local new_value = math.min(control.max, current_value + control.step)
control.set(new_value) control.set(new_value)
end end
elseif control.type == "decision_item" then elseif control.type == "action_item" then
if Input.menu_confirm() then if Input.menu_confirm() then
control.decision() control.action()
end end
end end
end end

View File

@@ -15,7 +15,7 @@ end
--- Updates the game window logic. --- Updates the game window logic.
function GameWindow.update() function GameWindow.update()
if Input.menu_back() then if Input.menu_back() then
Context.current_window = "menu" Window.set_current("menu")
MenuWindow.refresh_menu_items() MenuWindow.refresh_menu_items()
return return
end end

View File

@@ -41,24 +41,3 @@ function Window.get_current_handler()
return function() trace("Error: No handler for window: " .. tostring(Context.current_window)) end return function() trace("Error: No handler for window: " .. tostring(Context.current_window)) end
end end
end end
SplashWindow = {}
IntroWindow = {}
MenuWindow = {}
GameWindow = {}
PopupWindow = {}
ConfigurationWindow = {}
AudioTestWindow = {}
MinigameButtonMashWindow = {}
MinigameRhythmWindow = {}
MinigameDDRWindow = {}
-- Registration of all window modules
Window.register("splash", SplashWindow)
Window.register("intro", IntroWindow)
Window.register("menu", MenuWindow)
Window.register("game", GameWindow)
Window.register("popup", PopupWindow)
Window.register("configuration", ConfigurationWindow)
Window.register("audiotest", AudioTestWindow)
Window.register("minigame_button_mash", MinigameButtonMashWindow)
Window.register("minigame_rhythm", MinigameRhythmWindow)
Window.register("minigame_ddr", MinigameDDRWindow)

View File

@@ -0,0 +1,29 @@
SplashWindow = {}
Window.register("splash", SplashWindow)
IntroWindow = {}
Window.register("intro", IntroWindow)
MenuWindow = {}
Window.register("menu", MenuWindow)
GameWindow = {}
Window.register("game", GameWindow)
PopupWindow = {}
Window.register("popup", PopupWindow)
ConfigurationWindow = {}
Window.register("configuration", ConfigurationWindow)
AudioTestWindow = {}
Window.register("audiotest", AudioTestWindow)
MinigameButtonMashWindow = {}
Window.register("minigame_button_mash", MinigameButtonMashWindow)
MinigameRhythmWindow = {}
Window.register("minigame_rhythm", MinigameRhythmWindow)
MinigameDDRWindow = {}
Window.register("minigame_ddr", MinigameDDRWindow)