fix(P.3.4): correct aabb_contains_point signature + SPOREL_CI self-exit

- hit() now passes rect-table as single arg (not destructured) per
  engine.spatial.aabb_contains_point(rect, px, py) signature.
- update() honors SPOREL_CI=1 via 60-frame self-exit (matches spine-
  prototype pattern). Required for headless smoke (P0-S15).
This commit is contained in:
Calic
2026-05-12 23:38:38 +02:00
parent 4db760bc60
commit 5dde5b28c9

View File

@@ -10,6 +10,11 @@ local modules = {} -- [{id, version, name, rect={x,y,w,h}}]
local quit_buttons = {} -- {yes = rect, no = rect}
local screen_w, screen_h = 1280, 720 -- matched ENGINE_WINDOW_DEFAULT_WIDTH/HEIGHT
-- CI-conditional self-exit (matches spine-prototype's pattern).
-- Interactive runs (no SPOREL_CI=1) loop until ESC or quit-confirm.
local frames = 0
local CI_FRAMES = 60
local TITLE = "Sporel Launcher"
local QUIT_PROMPT = "Sporel beenden?"
local YES_LABEL = "Ja"
@@ -63,6 +68,12 @@ function init(ctx)
end
function update(ctx, dt)
frames = frames + 1
if os.getenv("SPOREL_CI") == "1" and frames >= CI_FRAMES then
engine.exit(0)
return
end
local mx, my = engine.input.get_mouse_pos()
if state == STATE_LIST then
@@ -70,7 +81,7 @@ function update(ctx, dt)
state = fsm.next(state, "esc")
elseif input.was_action_pressed("ui_click") then
for _, m in ipairs(modules) do
if hit(m.rect.x, m.rect.y, m.rect.w, m.rect.h, mx, my) then
if hit(m.rect, mx, my) then
engine.switch_module(m.id)
return
end
@@ -82,9 +93,9 @@ function update(ctx, dt)
elseif input.was_action_pressed("ui_confirm") then
engine.exit(0); return
elseif input.was_action_pressed("ui_click") then
if hit(quit_buttons.yes.x, quit_buttons.yes.y, quit_buttons.yes.w, quit_buttons.yes.h, mx, my) then
if hit(quit_buttons.yes, mx, my) then
engine.exit(0); return
elseif hit(quit_buttons.no.x, quit_buttons.no.y, quit_buttons.no.w, quit_buttons.no.h, mx, my) then
elseif hit(quit_buttons.no, mx, my) then
state = fsm.next(state, "click_no")
end
end
@@ -103,7 +114,7 @@ function render(ctx)
engine.render.draw_text(EMPTY_LABEL, (screen_w - ew) / 2, screen_h / 2, FONT_BUTTON, COLOR_TEXT)
else
for _, m in ipairs(modules) do
local color = hit(m.rect.x, m.rect.y, m.rect.w, m.rect.h, mx, my) and COLOR_HOVER or COLOR_BTN
local color = hit(m.rect, mx, my) and COLOR_HOVER or COLOR_BTN
engine.render.draw_rect(m.rect.x, m.rect.y, m.rect.w, m.rect.h, color)
local lw = engine.render.measure_text(m.name, FONT_BUTTON)
engine.render.draw_text(m.name, m.rect.x + (m.rect.w - lw) / 2, m.rect.y + PAD_Y, FONT_BUTTON, COLOR_TEXT)
@@ -119,7 +130,7 @@ function render(ctx)
for _, key in ipairs({ "yes", "no" }) do
local b = quit_buttons[key]
local color = hit(b.x, b.y, b.w, b.h, mx, my) and COLOR_HOVER or COLOR_BTN
local color = hit(b, mx, my) and COLOR_HOVER or COLOR_BTN
engine.render.draw_rect(b.x, b.y, b.w, b.h, color)
local label = (key == "yes") and YES_LABEL or NO_LABEL
local lw = engine.render.measure_text(label, FONT_BUTTON)