From 5049ebec64aed4508a16eb418ced200a0d24a50f Mon Sep 17 00:00:00 2001 From: wusumac <736139669@qq.com> Date: Fri, 20 Nov 2026 12:17:18 +0800 Subject: [PATCH] chore: commit leftover skin text keys + reenter-battle regression Settings-page skin labels and the earlier palette-based skin generator were left uncommitted from the parchment skin work. Also strengthens battle_exit_test to assert re-entering battle restores a visible HUD layer (hiding must not be permanent). 107 gates pass. --- data/ui_text.en_US.json | 5 +- data/ui_text.zh_CN.json | 5 +- p2_godot_sample/data/ui_text.en_US.json | 5 +- p2_godot_sample/data/ui_text.zh_CN.json | 5 +- p2_godot_sample/scripts/battle_exit_test.gd | 11 +++ tools/fullgame/gen_ui_skin.py | 81 +++++++++++++++++++++ 6 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 tools/fullgame/gen_ui_skin.py diff --git a/data/ui_text.en_US.json b/data/ui_text.en_US.json index e22fd3b..768133d 100644 --- a/data/ui_text.en_US.json +++ b/data/ui_text.en_US.json @@ -930,7 +930,10 @@ "shell.endless.step": "Advance Zone", "shell.endless.run": "Auto Advance", "shell.endless.upgrade": "Upgrade Heroes (+5 levels)", - "shell.endless.log": "Recent Zone Log" + "shell.endless.log": "Recent Zone Log", + "shell.settings.skin": "UI Skin", + "shell.settings.skin_name.default": "Default", + "shell.settings.skin_name.parchment": "Parchment" }, "shell.interact.board_kill": "Purge: battle wins {prog}/{step}, pays 5 crystal ({avail} ready)", "shell.interact.board_clear": "Advance: nodes cleared {prog}/{step}, pays 5 crystal ({avail} ready)", diff --git a/data/ui_text.zh_CN.json b/data/ui_text.zh_CN.json index d3c82b3..fd07409 100644 --- a/data/ui_text.zh_CN.json +++ b/data/ui_text.zh_CN.json @@ -930,7 +930,10 @@ "shell.endless.step": "推进一区", "shell.endless.run": "连续推进", "shell.endless.upgrade": "升级英雄(+5级)", - "shell.endless.log": "最近区域记录" + "shell.endless.log": "最近区域记录", + "shell.settings.skin": "界面皮肤", + "shell.settings.skin_name.default": "默认", + "shell.settings.skin_name.parchment": "羊皮纸" }, "shell.interact.board_kill": "清剿委托:战斗胜利 {prog}/{step},奖励 5 风晶({avail} 待领)", "shell.interact.board_clear": "推进委托:通关节点 {prog}/{step},奖励 5 风晶({avail} 待领)", diff --git a/p2_godot_sample/data/ui_text.en_US.json b/p2_godot_sample/data/ui_text.en_US.json index e22fd3b..768133d 100644 --- a/p2_godot_sample/data/ui_text.en_US.json +++ b/p2_godot_sample/data/ui_text.en_US.json @@ -930,7 +930,10 @@ "shell.endless.step": "Advance Zone", "shell.endless.run": "Auto Advance", "shell.endless.upgrade": "Upgrade Heroes (+5 levels)", - "shell.endless.log": "Recent Zone Log" + "shell.endless.log": "Recent Zone Log", + "shell.settings.skin": "UI Skin", + "shell.settings.skin_name.default": "Default", + "shell.settings.skin_name.parchment": "Parchment" }, "shell.interact.board_kill": "Purge: battle wins {prog}/{step}, pays 5 crystal ({avail} ready)", "shell.interact.board_clear": "Advance: nodes cleared {prog}/{step}, pays 5 crystal ({avail} ready)", diff --git a/p2_godot_sample/data/ui_text.zh_CN.json b/p2_godot_sample/data/ui_text.zh_CN.json index d3c82b3..fd07409 100644 --- a/p2_godot_sample/data/ui_text.zh_CN.json +++ b/p2_godot_sample/data/ui_text.zh_CN.json @@ -930,7 +930,10 @@ "shell.endless.step": "推进一区", "shell.endless.run": "连续推进", "shell.endless.upgrade": "升级英雄(+5级)", - "shell.endless.log": "最近区域记录" + "shell.endless.log": "最近区域记录", + "shell.settings.skin": "界面皮肤", + "shell.settings.skin_name.default": "默认", + "shell.settings.skin_name.parchment": "羊皮纸" }, "shell.interact.board_kill": "清剿委托:战斗胜利 {prog}/{step},奖励 5 风晶({avail} 待领)", "shell.interact.board_clear": "推进委托:通关节点 {prog}/{step},奖励 5 风晶({avail} 待领)", diff --git a/p2_godot_sample/scripts/battle_exit_test.gd b/p2_godot_sample/scripts/battle_exit_test.gd index 5c68fb6..1d2387d 100644 --- a/p2_godot_sample/scripts/battle_exit_test.gd +++ b/p2_godot_sample/scripts/battle_exit_test.gd @@ -64,6 +64,17 @@ func _run() -> void: if _battle_hud_layer_visible(shell, battle): _problems.append("tab %s: battle HUD layer still visible after exit" % page) + # Re-entering battle must build a FRESH visible HUD (hiding must not be + # permanent): otherwise the player could never see a fight again. + shell.start_node("R1-C01-N01") + await process_frame + await process_frame + var fresh := shell.get_battle() + var fresh_hud_visible := _battle_hud_layer_visible(shell, fresh) + _records.append({"stage": "reenter", "hud_layer_visible": fresh_hud_visible}) + if not fresh_hud_visible: + _problems.append("re-entered battle HUD must be visible again") + var payload := {"records": _records, "problems": _problems} var dir := ProjectSettings.globalize_path("res://artifacts") DirAccess.make_dir_recursive_absolute(dir) diff --git a/tools/fullgame/gen_ui_skin.py b/tools/fullgame/gen_ui_skin.py new file mode 100644 index 0000000..ff07d4b --- /dev/null +++ b/tools/fullgame/gen_ui_skin.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""Generate clean 48x48 nine-slice UI frames from a skin palette. + +AI-generated frame art is beautiful but not a valid nine-slice (complex corner +ornaments smear when stretched). This builds STRUCTURALLY CORRECT 48x48 frames +using the same cut-corner geometry as the shipped frame, with colors sampled +from each AI skin. Output: panel/button/button_pressed/tab PNGs, 6px margin. + +Usage: python3 gen_ui_skin.py +""" +import sys +from pathlib import Path +from PIL import Image + +MARGIN = 6 +SIZE = 48 + + +def build_frame(bg, edge, accent, *, pressed=False, tab=False) -> Image.Image: + img = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0)) + px = img.load() + # cut corners: transparent triangle in each 6x6 corner (same geometry as shipped) + def solid(x, y): + # corner cut: skip cells where x+y < MARGIN (top-left), etc. + if x < MARGIN and y < MARGIN and (x + y) < MARGIN - 1: + return False + if x >= SIZE - MARGIN and y < MARGIN and ((SIZE - 1 - x) + y) < MARGIN - 1: + return False + if x < MARGIN and y >= SIZE - MARGIN and (x + (SIZE - 1 - y)) < MARGIN - 1: + return False + if x >= SIZE - MARGIN and y >= SIZE - MARGIN and ((SIZE - 1 - x) + (SIZE - 1 - y)) < MARGIN - 1: + return False + return True + for y in range(SIZE): + for x in range(SIZE): + if not solid(x, y): + continue + in_border = x < MARGIN or x >= SIZE - MARGIN or y < MARGIN or y >= SIZE - MARGIN + if in_border: + # accent rivets at the 4 corner blocks + corner = ((x < MARGIN and y < MARGIN) or + (x >= SIZE - MARGIN and y < MARGIN) or + (x < MARGIN and y >= SIZE - MARGIN) or + (x >= SIZE - MARGIN and y >= SIZE - MARGIN)) + c = accent if corner else edge + if pressed: + c = tuple(int(v * 0.8) for v in c) + px[x, y] = c + (255,) + else: + px[x, y] = bg + (255,) + # inner hairline (1px accent just inside border) for depth + for i in range(MARGIN, SIZE - MARGIN): + for p in ((i, MARGIN), (i, SIZE - MARGIN - 1), (MARGIN, i), (SIZE - MARGIN - 1, i)): + if solid(*p): + px[p] = accent + (255,) + return img + + +def main(): + name = sys.argv[1] + bg = tuple(map(int, sys.argv[2].split(","))) + edge = tuple(map(int, sys.argv[3].split(","))) + accent = tuple(map(int, sys.argv[4].split(","))) + out = Path(sys.argv[5]) + out.mkdir(parents=True, exist_ok=True) + specs = [ + ("ui_frame_panel.png", dict()), + ("ui_frame_button.png", dict()), + ("ui_frame_button_pressed.png", dict(pressed=True)), + ("ui_frame_tab.png", dict(tab=True)), + ] + for fn, kw in specs: + build_frame(bg, edge, accent, **kw).save(out / fn) + # contact sheet preview: panel scaled 4x + prev = build_frame(bg, edge, accent).resize((SIZE * 6, SIZE * 6), Image.NEAREST) + prev.save(out / "preview.png") + print(f"wrote {len(specs)} frames + preview to {out}") + + +if __name__ == "__main__": + main()