From a732b5cbfa8e157947486be09ad9e574c38351cf Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Tue, 3 Mar 2026 20:14:57 +0100 Subject: [PATCH] logic layer --- impostor.inc | 8 +-- .../system.day.lua => logic/logic.day.lua} | 0 .../logic.focus.lua} | 0 .../logic.meter.lua} | 0 .../logic.timer.lua} | 0 inc/system/system.ui.lua | 55 ------------------- inc/window/window.configuration.lua | 18 +++--- 7 files changed, 14 insertions(+), 67 deletions(-) rename inc/{system/system.day.lua => logic/logic.day.lua} (100%) rename inc/{system/system.focus.lua => logic/logic.focus.lua} (100%) rename inc/{system/system.meter.lua => logic/logic.meter.lua} (100%) rename inc/{system/system.timer.lua => logic/logic.timer.lua} (100%) diff --git a/impostor.inc b/impostor.inc index 2729974..e8d222a 100644 --- a/impostor.inc +++ b/impostor.inc @@ -3,13 +3,13 @@ init/init.module.lua init/init.config.lua init/init.minigame.lua init/init.context.lua -system/system.meter.lua system/system.util.lua system/system.print.lua system/system.input.lua -system/system.focus.lua -system/system.day.lua -system/system.timer.lua +logic/logic.meter.lua +logic/logic.focus.lua +logic/logic.day.lua +logic/logic.timer.lua system/system.ui.lua audio/audio.manager.lua audio/audio.songs.lua diff --git a/inc/system/system.day.lua b/inc/logic/logic.day.lua similarity index 100% rename from inc/system/system.day.lua rename to inc/logic/logic.day.lua diff --git a/inc/system/system.focus.lua b/inc/logic/logic.focus.lua similarity index 100% rename from inc/system/system.focus.lua rename to inc/logic/logic.focus.lua diff --git a/inc/system/system.meter.lua b/inc/logic/logic.meter.lua similarity index 100% rename from inc/system/system.meter.lua rename to inc/logic/logic.meter.lua diff --git a/inc/system/system.timer.lua b/inc/logic/logic.timer.lua similarity index 100% rename from inc/system/system.timer.lua rename to inc/logic/logic.timer.lua diff --git a/inc/system/system.ui.lua b/inc/system/system.ui.lua index 7f355c2..b101a60 100644 --- a/inc/system/system.ui.lua +++ b/inc/system/system.ui.lua @@ -8,12 +8,6 @@ function UI.draw_top_bar(title) Print.text(title, 3, 2, Config.colors.light_blue) 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.
@@ -86,55 +80,6 @@ function UI.word_wrap(text, max_chars_per_line) return lines 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.
---- @param min number The minimum value.
---- @param max number The maximum value.
---- @param step number The step increment.
---- @param[opt] format string The format string for displaying the value.
---- @return result table A numeric stepper control definition or nil.
---- Fields:
---- * label (string) The label for the stepper.
---- * get (function) Function to get the current value.
---- * set (function) Function to set the current value.
---- * min (number) The minimum value.
---- * max (number) The maximum value.
---- * step (number) The step increment.
---- * format (string) The format string for displaying the value.
---- * type (string) Control type identifier ("numeric_stepper").
-function UI.create_numeric_stepper(label, value_getter, value_setter, min, max, step, format) - return { - label = label, - get = value_getter, - set = value_setter, - min = min, - max = max, - step = step, - format = format or "%.1f", - type = "numeric_stepper" - } -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 result table An action item control definition or nil.
---- Fields:
---- * label (string) The label for the action item.
---- * action (function) The function to execute when the item is selected.
---- * type (string) Control type identifier ("action_item").
-function UI.create_action_item(label, action) - return { - label = label, - action = action, - type = "action_item" - } -end - --- Draws decision selector. --- @within UI --- @param decisions table A table of decision items.
diff --git a/inc/window/window.configuration.lua b/inc/window/window.configuration.lua index 3a843d8..12392f4 100644 --- a/inc/window/window.configuration.lua +++ b/inc/window/window.configuration.lua @@ -8,14 +8,16 @@ ConfigurationWindow = { --- @within ConfigurationWindow function ConfigurationWindow.init() ConfigurationWindow.controls = { - UI.create_action_item( - "Save", - function() Config.save() end - ), - UI.create_action_item( - "Restore Defaults", - function() Config.reset() end - ), + { + label = "Save", + action = function() Config.save() end, + type = "action_item" + }, + { + label = "Restore Defaults", + action = function() Config.reset() end, + type = "action_item" + }, } end