diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..8badbca --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,30 @@ +-- .luacheckrc +-- Configuration for luacheck +-- +-- The CI lint step aborts on any warning, so both the project's own globals +-- and the TIC-80 API functions this game calls have to be declared here. + +globals = { + -- the game's own globals + "Context", + "init_game", + + -- TIC-80 callbacks and API + "TIC", + "btn", + "btnp", + "cls", + "exit", + "keyp", + "mget", + "mset", + "rect", + "rectb", + "spr", +} + +-- The INPUT_KEY_* constants are a coherent set (LEFT/RIGHT/A/B/X/Y); some are +-- not bound yet, and dropping them would leave gaps in the mapping. +ignore = { "211/INPUT_KEY_.*" } + +std = "lua51" -- TIC-80 runs Lua 5.1 diff --git a/inc/system/system.main.lua b/inc/system/system.main.lua index db93d45..bb52ac6 100644 --- a/inc/system/system.main.lua +++ b/inc/system/system.main.lua @@ -45,7 +45,7 @@ function init_game() end function TIC() - init_game() + init_game() cls(Config.colors.black) local handler = STATE_HANDLERS[Context.active_window] diff --git a/inc/system/system.ui.lua b/inc/system/system.ui.lua index 879939f..2f6ffda 100644 --- a/inc/system/system.ui.lua +++ b/inc/system/system.ui.lua @@ -35,7 +35,7 @@ end function UI.word_wrap(text, max_chars_per_line) if text == nil then return {""} end local lines = {} - + for input_line in (text .. "\n"):gmatch("(.-)\n") do local current_line = "" local words_in_line = 0 @@ -50,18 +50,18 @@ function UI.word_wrap(text, max_chars_per_line) current_line = word end end - + if words_in_line > 0 then table.insert(lines, current_line) else table.insert(lines, "") end end - + if #lines == 0 then return {""} end - + return lines end diff --git a/inc/window/window.configuration.lua b/inc/window/window.configuration.lua index b933959..ceb4805 100644 --- a/inc/window/window.configuration.lua +++ b/inc/window/window.configuration.lua @@ -39,15 +39,15 @@ function ConfigurationWindow.draw() for i, control in ipairs(ConfigurationWindow.controls) do local current_y = y_start + (i - 1) * 12 local color = Config.colors.green - + if control.type == "numeric_stepper" then local value = control.get() local label_text = control.label local value_text = string.format(control.format, value) - + -- Calculate x position for right-aligned value local value_x = x_value_right_align - (#value_text * char_width) - + if i == ConfigurationWindow.selected_control then color = Config.colors.item Print.text("<", x_start -8, current_y, color) @@ -70,7 +70,7 @@ function ConfigurationWindow.draw() end end end - + Print.text("Press B to go back", x_start, 120, Config.colors.light_grey) end diff --git a/inc/window/window.intro.lua b/inc/window/window.intro.lua index d18f3e2..cb0ea52 100644 --- a/inc/window/window.intro.lua +++ b/inc/window/window.intro.lua @@ -1,9 +1,9 @@ -function IntroWindow.draw() +function IntroWindow.draw() local x = (Config.screen.width - 132) / 2 -- Centered text Print.text(Context.intro.text, x, Context.intro.y, Config.colors.green) end -function IntroWindow.update() +function IntroWindow.update() Context.intro.y = Context.intro.y - Context.intro.speed -- Count lines in intro text to determine when scrolling is done diff --git a/inc/window/window.menu.lua b/inc/window/window.menu.lua index bbf7765..33b7ff0 100644 --- a/inc/window/window.menu.lua +++ b/inc/window/window.menu.lua @@ -53,7 +53,7 @@ function MenuWindow.refresh_menu_items() table.insert(Context.menu_items, {label = "Load Game", action = MenuWindow.load_game}) table.insert(Context.menu_items, {label = "Configuration", action = MenuWindow.configuration}) table.insert(Context.menu_items, {label = "Exit", action = MenuWindow.exit}) - + Context.selected_menu_item = 1 -- Reset selection after refreshing end diff --git a/inc/window/window.popup.lua b/inc/window/window.popup.lua index f053bb7..3c08e15 100644 --- a/inc/window/window.popup.lua +++ b/inc/window/window.popup.lua @@ -52,7 +52,7 @@ function PopupWindow.update() selected_item.action() end end - + if Input.menu_back() then GameWindow.set_state(WINDOW_GAME) end @@ -92,7 +92,7 @@ function PopupWindow.draw() Print.text(line, 50, current_y, Config.colors.light_grey) current_y = current_y + 8 -- Move to the next line (8 pixels for default font height + padding) end - + -- Adjust menu position based on the number of wrapped lines if not Context.dialog.showing_description then UI.draw_menu(Context.dialog.menu_items, Context.dialog.selected_menu_item, 50, current_y + 2)