refactor(launcher): remove dead button-list helpers after panel refactor

draw_module_row, tooltip_for, and apply_update were the v0.2.0
button-list rendering helpers. The master-detail panel refactor in
41b28ff moved rendering into panels/list.lua + panels/detail.lua,
leaving these three functions with no call sites. Also drops the
now-unused icons import and ICON_GAP/ICON_STRIP_W constants that only
the deleted helpers referenced; FONT_BUTTON, COLOR_DIM and COLOR_MODAL
stay because the quit-confirm modal still uses them.

Verified by grep that none of the removed symbols have remaining
references in init.lua or sibling files. CI boot is clean:
init ok, modules=6 + BOOTING -> RUNNING -> SHUTTING_DOWN, no FATAL.

init.lua drops 443 -> 302 lines; function count drops 14 -> 11.
This commit is contained in:
Calic
2026-06-11 01:52:51 +02:00
parent 332a37e155
commit f2b2a8859b

145
init.lua
View File

@@ -1,12 +1,11 @@
local input = require("lib-core.input") local input = require("lib-core.input")
local git = require("lib-core.git") local git = require("lib-core.git")
local depf = require("lib-management.dep-fetcher") local depf = require("lib-management.dep-fetcher")
-- fsm.lua + icons.lua live in this module's dir; engine_lua_lib's searcher -- fsm.lua lives in this module's dir; engine_lua_lib's searcher only
-- only resolves declared lib-deps, so multi-file modules use dofile + -- resolves declared lib-deps, so multi-file modules use dofile +
-- engine.module.dir_of. -- engine.module.dir_of.
local MODULE_DIR = engine.module.dir_of("lib-management.launcher") local MODULE_DIR = engine.module.dir_of("lib-management.launcher")
local fsm = dofile(MODULE_DIR .. "/fsm.lua") local fsm = dofile(MODULE_DIR .. "/fsm.lua")
local icons = dofile(MODULE_DIR .. "/icons.lua")
local function require_panel(name) local function require_panel(name)
return dofile(MODULE_DIR .. "/panels/" .. name .. ".lua") return dofile(MODULE_DIR .. "/panels/" .. name .. ".lua")
@@ -38,8 +37,6 @@ local FONT_TITLE = 28
local FONT_BUTTON = 20 local FONT_BUTTON = 20
local PAD_X = 16 local PAD_X = 16
local PAD_Y = 8 local PAD_Y = 8
local ICON_GAP = 4
local ICON_STRIP_W = 140 -- reserved right-edge area inside each button
local COLOR_BG = 0x202020FF local COLOR_BG = 0x202020FF
local COLOR_BTN = 0x404040FF local COLOR_BTN = 0x404040FF
@@ -142,83 +139,6 @@ local function run_dep_check(m)
end end
end end
-- Build the tooltip text for whichever icon the mouse is over.
-- Returns nil when no icon is hovered.
local function tooltip_for(m, mx, my)
local s = m.status
if s.error_rect and hit(s.error_rect, mx, my) then
local r = s.dep_check_result
if r then
if #r.conflicts > 0 then
local c = r.conflicts[1]
return "Pin-Konflikt: " .. c.lib_id
.. " (" .. tostring(#c.pins) .. " Versionen)"
elseif #r.errors > 0 then
local e = r.errors[1]
return "Fehler: " .. e.lib_id .. "" .. (e.message or e.kind)
end
end
return "Modul nicht startbereit"
end
if s.badge_rect and hit(s.badge_rect, mx, my) then
return "Update verfuegbar: " .. (s.update_latest_tag or "?")
.. " — klicken zum Aktualisieren"
end
if s.warn_rect and hit(s.warn_rect, mx, my) then
if s.update_check_result == "fail" then
local k = s.update_check_fail_kind
if k == "auth-required" then
return "Privat — SPOREL_GITEA_TOKEN setzen fuer Update-Check"
end
return "Updates konnten nicht geprueft werden (" .. (k or "fail") .. ")"
end
local r = s.dep_check_result
if r and #r.warnings > 0 then
local w = r.warnings[1]
return "Dirty: " .. w.lib_id .. " (" .. (w.kind or "warn") .. ")"
end
return "Warnung"
end
if s.local_rect and hit(s.local_rect, mx, my) then
return "Nur lokal vorhanden (kein Server-Repo)"
end
if s.spinner_rect and hit(s.spinner_rect, mx, my) then
return "Pruefe auf Updates..."
end
return nil
end
-- Update flow: fetch + checkout + dep-recheck + kick fresh update-check.
local function apply_update(m)
local url = module_repo_url(m.id)
local module_dir = engine.install_root() .. "/modules/" .. m.id
if git.is_repo(module_dir) then
local ok1, err1 = git.fetch(url, module_dir)
if ok1 then
local ok2, err2 = git.checkout(module_dir,
m.status.update_latest_tag)
if ok2 then
refresh_module_version(m)
else
engine.print("launcher: checkout failed for " .. m.id
.. ": " .. tostring(err2))
end
else
engine.print("launcher: fetch failed for " .. m.id
.. ": " .. tostring(err1))
end
else
-- Packaged install without .git (cmake --install excludes it).
-- Clone-into-temp-and-swap is slice-8 bundle work; for now
-- surface a clear log message and let the dep-check error path
-- show the user a red icon on next interaction.
engine.print("launcher: module " .. m.id
.. " has no .git — update flow requires a dev install")
end
run_dep_check(m)
start_update_check(m)
end
-- ----- lifecycle ----------------------------------------------------- -- ----- lifecycle -----------------------------------------------------
function init(ctx) function init(ctx)
@@ -347,67 +267,6 @@ function update(ctx, dt)
end end
end end
local function draw_module_row(m)
local mx, my = engine.input.get_mouse_pos()
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)
-- Label left-aligned with PAD_X margin (room reserved on right
-- for the icon strip).
engine.render.draw_text(m.name, m.rect.x + PAD_X,
m.rect.y + PAD_Y, FONT_BUTTON, COLOR_TEXT)
-- Icon strip: right-edge anchored, laid out right-to-left so the
-- rightmost icon's x stays stable across state changes.
local row_y = m.rect.y + (m.rect.h - icons.ICON_H) / 2
local right = m.rect.x + m.rect.w - PAD_X - icons.ICON_W
-- Reset rects each frame so stale hit-areas don't linger when a
-- status icon disappears.
m.status.spinner_rect = nil
m.status.warn_rect = nil
m.status.badge_rect = nil
m.status.error_rect = nil
m.status.local_rect = nil
local dep = m.status.dep_check_result
local uchk = m.status.update_check_result
-- 1. Error icon (rightmost) — conflict or error from dep-check.
if dep and (not dep.ok) then
m.status.error_rect = icons.draw_error(right, row_y)
right = right - icons.ICON_W - ICON_GAP
end
-- 2. Update badge — variable width; subtract its returned width.
if uchk == "available" and m.status.update_latest_tag then
local r = icons.draw_update_badge(
right - 40, row_y, m.status.update_latest_tag)
m.status.badge_rect = r
right = r.x - ICON_GAP - icons.ICON_W
end
-- 3. Warn icon — update-check failed (auth/network) or dirty deps.
-- Local-only is NOT a warn — it's an informational state below.
local warn_needed = (uchk == "fail")
or (dep and dep.ok and dep.warnings and #dep.warnings > 0)
if warn_needed then
m.status.warn_rect = icons.draw_warn(right, row_y)
right = right - icons.ICON_W - ICON_GAP
end
-- 3b. Local-only marker — repo not on server (404 even with creds).
if uchk == "local-only" then
m.status.local_rect = icons.draw_local(right, row_y)
right = right - icons.ICON_W - ICON_GAP
end
-- 4. Spinner — leftmost in the strip, still-pending update-check.
if uchk == "pending" then
m.status.spinner_rect = icons.draw_spinner(right, row_y, frames)
end
end
function render(ctx) function render(ctx)
local mx, my = engine.input.get_mouse_pos() local mx, my = engine.input.get_mouse_pos()