diff --git a/src/import/LauncherView.lua b/src/import/LauncherView.lua index 7be70f26..713db9a1 100644 --- a/src/import/LauncherView.lua +++ b/src/import/LauncherView.lua @@ -33,6 +33,7 @@ local Theme = require("src.ui.kit.Theme") local Layout = require("src.ui.kit.Layout") local Loader = require("src.ui.kit.Loader") local GameVersion = require("src.core.GameVersion") +local Version = require("src.core.Version") local Strings = require("src.core.Strings") local PAL = Theme.PAL @@ -340,6 +341,21 @@ local function buildHeader(imp, m) local rx = m.x + m.w - m.pad local by = y + (rowH - gear) / 2 + -- Switch-only: show the running app version opposite the settings gear so + -- players can confirm which build is on the microSD (OTA / zip updates). + if imp.isNX then + local label = "v" .. tostring(Version.engine or "?") + local tw = Kit.textWidth("small", label) + local padX = math.floor(12 * m.s) + local chipW = math.max(tw + 2 * padX, gear) + local lx = m.x + m.pad + Theme.fill(lx, by, chipW, gear, PAL.bg, 1) + Theme.stroke(lx, by, chipW, gear, PAL.yellow, Theme.A.hover, 1) + local th = Kit.textHeight("small") + Kit.text("small", label, lx + math.floor((chipW - tw) / 2), + by + math.floor((gear - th) / 2), PAL.yellow) + end + -- Settings gear, top-right corner. imp._gearIcon = imp._gearIcon or love.graphics.newImage("assets/launcher/gear.png") diff --git a/tests/engine/launcher_nx_version_chip_test.lua b/tests/engine/launcher_nx_version_chip_test.lua new file mode 100644 index 00000000..2a76e57e --- /dev/null +++ b/tests/engine/launcher_nx_version_chip_test.lua @@ -0,0 +1,26 @@ +-- Switch launcher shows the running engine version in the header (NX only). +-- Desktop/Android/iOS must not paint that chip. + +local function read(path) + local f = assert(io.open(path, "r")) + local s = f:read("*a") + f:close() + return s +end + +local src = read("src/import/LauncherView.lua") + +assert(src:find('local Version = require%("src%.core%.Version"%)') + or src:find('require%("src%.core%.Version"%)'), + "LauncherView must require Version") + +assert(src:find("imp%.isNX", 1, false), "version chip must gate on isNX") + +-- The chip is inside an isNX block and prints Version.engine +local nxBlock = src:match("if imp%.isNX then(.-)end\n\n %-%- Settings gear") +assert(nxBlock, "expected Switch-only version chip before the settings gear") +assert(nxBlock:find("Version%.engine", 1, false), "chip must show Version.engine") +assert(nxBlock:find('"v"', 1, true) or nxBlock:find('"v" %.%.', 1, false), + "chip label should be a v-prefixed version") + +print("ok — Switch launcher version chip is NX-gated and uses Version.engine")