Files
gplan-2/game/presentation/views/ui_kit.gd
T

105 lines
5.0 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# VERTICAL SLICE - NOT FOR PRODUCTION
# Date: 2026-09-11(2026-09-20 样式收敛批:全站色板与 StyleBox 工厂单点化)
# 呈现层共享小部件工厂 + 全站取色/描边唯一出口——各视图禁再内联 Color8/StyleBoxFlat
# 字面量;美术批换皮只改本文件(值 = 收敛时各视图现值快照,本批零视觉变化)。
class_name UiKit
extends RefCounted
# ── 色板(语义族;值 = 2026-09-20 收敛时现值) ──
const INK := Color8(51, 38, 27) # 墨族——正文/数字(对格底 ≥4.5:1)
const INK_LABEL := Color8(46, 34, 24) # 标签深墨
const INK_TITLE := Color8(30, 26, 22) # 亮底标题墨
const INK_ROUTE := Color8(24, 20, 16) # 节点图最深墨
const INK_ON_GOLD := Color8(60, 44, 20) # 金底上的深墨
const PANEL_HERO := Color8(232, 220, 196) # 面板底·主角侧(英雄卡/角色信息框)
const PANEL_ENEMY := Color8(226, 212, 190) # 面板底·敌方卡
const PANEL_DATA := Color8(226, 210, 182) # 面板底·数据框(AP 条/状态槽)
const PANEL_STAGE := Color8(216, 200, 172) # 面板底·战斗画面区
const PANEL_BORDER := Color8(120, 106, 88) # 面板细线框;兼熄灭点阵(DOT_OFF 别名)
const GOLD := Color8(240, 168, 40) # 奖励金
const GOLD_DEEP := Color8(176, 122, 20) # 深金(金框描边/达意金)
const GOLD_LIT := Color8(230, 190, 90) # 亮金(候选高亮)
const GOLD_DIM := Color8(140, 116, 60) # 暗金(已过节点)
const FLAG_RED := Color8(198, 61, 34) # 旗朱
const RED_DEEP := Color8(150, 60, 48) # 深朱(敌卡框/敌像)
const RED_MINE := Color8(150, 44, 36) # 引爆雷字朱(已开雷格"雷"字)
const RED_FORBID := Color8(120, 60, 50) # 禁止框朱
const RED_ALERT := Color8(200, 60, 48) # 报错朱
const HERO_BLUE := Color8(46, 110, 142) # 小人蓝
const BOSS_PURPLE := Color8(143, 47, 106) # 紫赤(Boss 专属)
const DEBUFF_PURPLE := Color8(122, 66, 148) # 妨害紫(意图 ☠)
const DUSK := Color8(90, 108, 140) # 暮蓝(全作唯一暮蓝档——失败终局)
const WARM := Color8(240, 226, 200) # 暖白(暗底正文)
const WARM_SOFT := Color8(200, 188, 166) # 暖白次级(说明文)
const WARM_FAINT := Color8(178, 166, 146) # 暖白弱化(帮助文)
const WARM_ROUTE_SUB := Color8(210, 196, 170) # 节点图编号暖白
const STONE := Color8(120, 110, 98) # 灰石(通道/箭头/失效)
const STONE_FAINT := Color8(140, 124, 100) # 灰石弱化(占位提示文)
const DARK_UPCOMING := Color8(64, 58, 52) # 未达暗字(底/文同值)
const DARK_TEXT_FAINT := Color8(160, 150, 138)# 未达节点文字
const BRICK := Color8(201, 175, 131) # 棋盘·未开掩尘地砖 #C9AF83
const FLOOR := Color8(179, 154, 120) # 棋盘·已开裸土 #B39A78
const DIG_EDGE := Color8(120, 190, 120) # 可挖域呼吸微光绿
const DIG_EDGE_DEEP := Color8(46, 80, 60) # 可挖域呼吸暗端(lerp 目标)
const BG_ROOT := Color8(30, 25, 20) # 屏幕根底
const BG_OVERLAY := Color8(28, 22, 18) # 模态遮罩底
const DIM := Color(0.08, 0.06, 0.05) # 遮罩基色(用时乘 alpha)
const TOAST_BG := Color(0.94, 0.91, 0.84, 0.95) # toast 面底
const TIP_BG := Color(0.16, 0.12, 0.09, 0.96) # tooltip 深底
# BBCode 十六进制(RichTextLabel 用;与上同值)
const HEX_GOLD := "f0a828"
const HEX_INK := "33261b"
const HEX_ON_GOLD := "3a2a08"
# 语义别名(同值异名——语义站点用别名,值仍单点)
const DOT_OFF := PANEL_BORDER
# ── 减动效(battle.md §Transitions 内建承诺:开启时时长减半;结算逐行兑现为信息载体降速不跳过)──
# 切片期入口 = TunePanel 开关(设置独立于存档两分制——正式设置层载体随设置批落位)
static var motion_scale := 1.0 # 1.0 常态 / 0.5 减动效
# 全部呈现层 tween 时长经本函数包装——新增动效一律 UiKit.motion(秒),禁再写裸时长字面量
static func motion(dur: float) -> float:
return dur * motion_scale
# ── StyleBox 工厂 ──
# margin = (左, 上, 右, 下);border_w = 0 即无边框(根底/遮罩用)
static func panel_flat(bg: Color, border: Color, corner: int = 0, border_w: int = 1, margin: Vector4 = Vector4.ZERO) -> StyleBoxFlat:
var sb := StyleBoxFlat.new()
sb.bg_color = bg
sb.set_corner_radius_all(corner)
sb.set_border_width_all(border_w)
sb.border_color = border
sb.content_margin_left = margin.x
sb.content_margin_top = margin.y
sb.content_margin_right = margin.z
sb.content_margin_bottom = margin.w
return sb
static func label(text: String, size: int, bold: bool) -> Label:
var l := Label.new()
l.text = text
l.add_theme_font_size_override("font_size", size)
if bold:
l.add_theme_color_override("font_color", INK_LABEL)
return l
static func button(text: String) -> Button:
var b := Button.new()
b.text = text
return b