From 9f0bc5d180a51f88c756bff207dd8841c8da8728 Mon Sep 17 00:00:00 2001 From: ZHU MINCHAO <48154958+MinchaoZhu@users.noreply.github.com> Date: Wed, 4 Nov 2026 10:32:20 +0800 Subject: [PATCH] ui: style all text inputs as light e-ink grooves with dark borders --- art/sprites.py | 9 +++++ .../ModFiles/Textures/Items/ui_hw_groove.png | Bin 0 -> 86 bytes src/Decentralized/PledgerSkin.cs | 33 +++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Decentralized/ModFiles/Textures/Items/ui_hw_groove.png diff --git a/art/sprites.py b/art/sprites.py index 1a83c01..49d4482 100644 --- a/art/sprites.py +++ b/art/sprites.py @@ -739,11 +739,20 @@ def hw_selected(): return c +def hw_groove(): + """PLEDGER 墨水屏输入框凹槽(12×12,九宫格边 2):浅色底、1 像素深墨边。""" + c = Canvas(12, 12) + c.rect(0, 0, 11, 11, 'n') + c.rect(1, 1, 10, 10, 'P') + return c + + UI_ICONS = {'ui_bank': ui_bank, 'ui_poinbase': ui_poinbase, 'ui_web3': ui_web3} UI_ICONS['ui_hw_shell'] = lambda: rounded(32, 7, 'K', 'E', 'z') UI_ICONS['ui_hw_bezel'] = lambda: rounded(16, 4, 'n') UI_ICONS['ui_hw_paper'] = lambda: rounded(12, 2, 'P') UI_ICONS['ui_hw_sel'] = hw_selected +UI_ICONS['ui_hw_groove'] = hw_groove UI_ICONS['ui_hw_ok'] = lambda: hw_button('ok') UI_ICONS['ui_hw_no'] = lambda: hw_button('no') diff --git a/src/Decentralized/ModFiles/Textures/Items/ui_hw_groove.png b/src/Decentralized/ModFiles/Textures/Items/ui_hw_groove.png new file mode 100644 index 0000000000000000000000000000000000000000..163ef61f3a2228f55a5f10bae5378d68eef76cd8 GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kSx*把输入框切片为墨水屏凹槽:浅色底、1 像素深墨边框(1:1 像素映射)。 + public static void SliceGroove(Image img) + { + if (img == null) return; + if (!Sliced.TryGetValue("ui_hw_groove", out var sp)) + { + var src = Items.ModSprite("ui_hw_groove"); + if (src != null) + { + src.texture.filterMode = FilterMode.Point; + sp = Sprite.Create(src.texture, src.rect, new Vector2(0.5f, 0.5f), src.pixelsPerUnit, 0, SpriteMeshType.FullRect, new Vector4(2, 2, 2, 2)); + } + else + { + var tex = new Texture2D(12, 12, TextureFormat.RGBA32, false) { filterMode = FilterMode.Point }; + for (int y = 0; y < 12; y++) + for (int x = 0; x < 12; x++) + tex.SetPixel(x, y, (x == 0 || x == 11 || y == 0 || y == 11) ? Ink : Paper); + tex.Apply(); + sp = Sprite.Create(tex, new Rect(0, 0, 12, 12), new Vector2(0.5f, 0.5f), 100f, 0, SpriteMeshType.FullRect, new Vector4(2, 2, 2, 2)); + } + Sliced["ui_hw_groove"] = sp; + } + img.sprite = sp; + img.type = Image.Type.Sliced; + img.pixelsPerUnitMultiplier = 100f / sp.pixelsPerUnit; + img.color = Color.white; + } + /// 屏上的选择按钮(币种、档位、子页):选中的一个画成白底黑框黑字、四角带准星角标。 public static void Pick(CustomUIBuilder b, string text, bool selected, Action onClick, ICollection picked) { @@ -155,9 +184,11 @@ namespace Decentralized t.color = t.gameObject.name.Contains("_note") ? Alert : t.gameObject.name.Contains("_dim") ? Dim : Ink; } - // 屏上输入框 + // 屏上输入框:墨水屏凹槽样式(浅色底、深墨 1px 边、深墨文字、灰色占位符) foreach (var inp in screen.GetComponentsInChildren(true)) { + var bg = inp.GetComponent() ?? inp.targetGraphic as Image; + if (bg != null) SliceGroove(bg); if (inp.textComponent != null) inp.textComponent.color = Ink; if (inp.placeholder is TextMeshProUGUI ph) ph.color = Dim; }