section and within annotations for ldoc
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-25 23:24:53 +01:00
parent 297ee8b622
commit 777c27aa54
27 changed files with 175 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
--- @section Input
local INPUT_KEY_UP = 0
local INPUT_KEY_DOWN = 1
local INPUT_KEY_LEFT = 2
@@ -10,20 +11,29 @@ local INPUT_KEY_BACKSPACE = 51
local INPUT_KEY_ENTER = 50
--- Checks if Up is pressed.
--- @within Input
function Input.up() return btnp(INPUT_KEY_UP) end
--- Checks if Down is pressed.
--- @within Input
function Input.down() return btnp(INPUT_KEY_DOWN) end
--- Checks if Left is pressed.
--- @within Input
function Input.left() return btnp(INPUT_KEY_LEFT) end
--- Checks if Right is pressed.
--- @within Input
function Input.right() return btnp(INPUT_KEY_RIGHT) end
--- Checks if Select is pressed.
--- @within Input
function Input.select() return btnp(INPUT_KEY_A) or keyp(INPUT_KEY_SPACE) end
--- Checks if Menu Confirm is pressed.
--- @within Input
function Input.menu_confirm() return btnp(INPUT_KEY_A) or keyp(INPUT_KEY_ENTER) end
--- Checks if Player Interact is pressed.
--- @within Input
function Input.player_interact() return btnp(INPUT_KEY_B) or keyp(INPUT_KEY_ENTER) end
--- Checks if Menu Back is pressed.
--- @within Input
function Input.menu_back() return btnp(INPUT_KEY_Y) or keyp(INPUT_KEY_BACKSPACE) end
--- Checks if Toggle Popup is pressed.
--- @within Input
function Input.toggle_popup() return keyp(INPUT_KEY_ENTER) end

View File

@@ -1,6 +1,8 @@
--- @section Main
local initialized_game = false
--- Initializes game state.
--- @within Main
local function init_game()
if initialized_game then return end
Context.reset()
@@ -10,6 +12,7 @@ local function init_game()
end
--- Main game loop (TIC-80 callback).
--- @within Main
function TIC()
init_game()
cls(Config.colors.black)

View File

@@ -1,4 +1,7 @@
--- @section Print
--- Prints text with shadow.
--- @within Print
-- @param text string The text to print.
-- @param x number The x-coordinate.
-- @param y number The y-coordinate.
@@ -14,6 +17,7 @@ function Print.text(text, x, y, color, fixed, scale)
end
--- Prints centered text with shadow.
--- @within Print
-- @param text string The text to print.
-- @param x number The x-coordinate for centering.
-- @param y number The y-coordinate.

View File

@@ -1,4 +1,7 @@
--- @section UI
--- Draws the top bar.
--- @within UI
-- @param title string The title text to display.
function UI.draw_top_bar(title)
rect(0, 0, Config.screen.width, 10, Config.colors.dark_grey)
@@ -6,11 +9,13 @@ function UI.draw_top_bar(title)
end
--- Draws dialog window.
--- @within UI
function UI.draw_dialog()
PopupWindow.draw()
end
--- Draws a menu.
--- @within UI
-- @param items table A table of menu items.
-- @param selected_item number The index of the currently selected item.
-- @param x number The x-coordinate for the menu.
@@ -26,6 +31,7 @@ function UI.draw_menu(items, selected_item, x, y)
end
--- Updates menu selection.
--- @within UI
-- @param items table A table of menu items.
-- @param selected_item number The current index of the selected item.
-- @return number The updated index of the selected item.
@@ -47,6 +53,7 @@ function UI.update_menu(items, selected_item)
end
--- Wraps text.
--- @within UI
-- @param text string The text to wrap.
-- @param max_chars_per_line number The maximum characters per line.
-- @return table A table of wrapped lines.
@@ -80,6 +87,7 @@ function UI.word_wrap(text, max_chars_per_line)
end
--- Creates a numeric stepper.
--- @within UI
-- @param label string The label for the stepper.
-- @param value_getter function Function to get the current value.
-- @param value_setter function Function to set the current value.
@@ -102,6 +110,7 @@ function UI.create_numeric_stepper(label, value_getter, value_setter, min, max,
end
--- Creates an action item.
--- @within UI
-- @param label string The label for the action item.
-- @param action function The function to execute when the item is selected.
-- @return table An action item control definition.
@@ -114,6 +123,7 @@ function UI.create_action_item(label, action)
end
--- Draws decision selector.
--- @within UI
-- @param decisions table A table of decision items.
-- @param selected_decision_index number The index of the selected decision.
function UI.draw_decision_selector(decisions, selected_decision_index)
@@ -133,6 +143,7 @@ function UI.draw_decision_selector(decisions, selected_decision_index)
end
--- Draws meters.
--- @within UI
function UI.draw_meters()
if not Context or not Context.game_in_progress or not Context.meters then return end
if Context.meters.hidden then return end
@@ -166,6 +177,7 @@ function UI.draw_meters()
end
--- Updates decision selector.
--- @within UI
-- @param decisions table A table of decision items.
-- @param selected_decision_index number The current index of the selected decision.
-- @return number The updated index of the selected decision.

View File

@@ -1,5 +1,8 @@
--- @section Util
--- Safely wraps an index for an array.
--- @within Util
-- @param array table The array to index.
-- @param index number The desired index (can be out of bounds).
-- @return number The wrapped index within the array's bounds.
@@ -8,6 +11,7 @@ function Util.safeindex(array, index)
end
--- Navigates to a screen by its ID.
--- @within Util
-- @param screen_id string The ID of the screen to go to.
function Util.go_to_screen_by_id(screen_id)
local screen = Screen.get_by_id(screen_id)
@@ -20,6 +24,7 @@ function Util.go_to_screen_by_id(screen_id)
end
--- Checks if a table contains a specific value.
--- @within Util
-- @param t table The table to check.
-- @param value any The value to look for.
function Util.contains(t, value)