ui: style all text inputs as light e-ink grooves with dark borders

This commit is contained in:
ZHU MINCHAO committed 2026-11-04 10:32:20 +08:00
1 parent 6cc546cd67
commit 9f0bc5d180
3 files changed
+41 -1

No files matched your search

+9
View File
@@ -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')
Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

+32 -1
View File
@@ -56,6 +56,35 @@ namespace Decentralized
img.color = Color.white;
}
/// <summary>把输入框切片为墨水屏凹槽:浅色底、1 像素深墨边框(1:1 像素映射)。</summary>
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;
}
/// <summary>屏上的选择按钮(币种、档位、子页):选中的一个画成白底黑框黑字、四角带准星角标。</summary>
public static void Pick(CustomUIBuilder b, string text, bool selected, Action onClick, ICollection<GameObject> 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<TMP_InputField>(true))
{
var bg = inp.GetComponent<Image>() ?? 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;
}