feat(迭代26 T1): 按钮五态矩阵——悬停乙案/禁用甲案/焦点甲案+危险钮本族按压态

- ui_kit.gd _apply_button_skin 五态统一管线:hover=常态图+modulate 1.06 提亮(乙案·代拍板1·零新素材);
  disabled=本族底+α0.45 幽灵化(甲案·代拍板2,取代旧「disabled=按压图」错配);
  focus=INK 2px 内缩 1px 环(甲案·代拍板3,负 expand margin 实现,叠加绘制不遮钮底,主题层零新增)
- primary_button 补 disabled(烛光黄族 α0.45)+focus 环+font_disabled_color(本族墨 α0.45)
- danger_button 补本族 pressed(深红 darkened(0.18) 深档)+disabled 幽灵化+focus 环+font_focus/disabled 色
- 冒烟新增 _smoke_button_five_states() 35 断言(V1 五态非空/hover≠normal/disabled≠pressed/危险钮非石纹/
  焦点环参数锚定+V2 双红线维持);冒烟 987→1022/0;probe --click 全绿残留 0
This commit is contained in:
DKChan committed 2026-10-14 05:08:42 +08:00
1 parent 04ec2175b1
commit b6f0c66183
2 files changed
+111 -4

No files matched your search

+75
View File
@@ -107,6 +107,7 @@ func _run_core_smoke(db, rng) -> void:
_smoke_playtest_logger()
_smoke_battle_log_view()
_smoke_global_theme()
_smoke_button_five_states()
_smoke_encounter_roll()
_smoke_attack_chain_fresh_pool()
_smoke_clear_reward_chain()
@@ -5456,6 +5457,80 @@ func _smoke_global_theme() -> void:
tpanel.free(); tlabel.free(); cbx.free(); cbt.free(); pm.free(); ob.free(); lbl.free()
# ---- 按钮五态矩阵冒烟(迭代 26 T1——四工厂产物逐实例 override 断言;V1/V2)----
func _smoke_button_five_states() -> void:
print("--- UI 按钮五态矩阵(四工厂五态样式盒)---")
var uikit_s = load("res://presentation/views/ui_kit.gd")
var states := ["normal", "hover", "pressed", "disabled", "focus"]
# 普通钮(verb_button 同走 button() 打底——同断言覆盖)
var b = uikit_s.button("测试")
for st in states:
check(b.has_theme_stylebox_override(st), "V1 普通钮 %s 样式盒非空" % st)
var n_sb: StyleBox = b.get_theme_stylebox("normal")
var h_sb: StyleBox = b.get_theme_stylebox("hover")
var p_sb: StyleBox = b.get_theme_stylebox("pressed")
var d_sb: StyleBox = b.get_theme_stylebox("disabled")
var f_sb: StyleBox = b.get_theme_stylebox("focus")
check(n_sb is StyleBoxTexture and h_sb is StyleBoxTexture and d_sb is StyleBoxTexture,
"V1 普通钮 normal/hover/disabled 均为石纹九宫格贴图样式盒")
# 悬停=乙案:modulate 提亮(≠常态 WHITE——乙案判据)
var h_mod: Color = (h_sb as StyleBoxTexture).modulate_color
check(h_mod != Color.WHITE and h_mod.r > 1.0, "V1 普通钮 hover=modulate 提亮(乙案,异于常态 WHITE)")
# 禁用=甲案:本族底+α0.45 幽灵化
var d_mod: Color = (d_sb as StyleBoxTexture).modulate_color
check(is_equal_approx(d_mod.a, 0.45) and d_mod.r == 1.0 and d_mod.g == 1.0,
"V1 普通钮 disabled=本族底 α0.45 幽灵化(甲案)")
# 错配修正判据:disabled≠pressed(旧「禁用=按压图」)
check(d_sb != p_sb, "V1 普通钮 disabled≠pressed(旧错配已修正)")
# 焦点=甲案:INK 2px 内缩 1px 环、无底(叠加态不遮钮底)
check(f_sb is StyleBoxFlat, "V1 普通钮 focus 样式盒为扁平环(StyleBoxFlat)")
var fsb := f_sb as StyleBoxFlat
check(fsb.border_color == uikit_s.INK, "V1 焦点环色=INK(与 font_focus_color 同源)")
check(is_equal_approx(fsb.border_width_left, 2.0) and is_equal_approx(fsb.border_width_right, 2.0)
and is_equal_approx(fsb.border_width_top, 2.0) and is_equal_approx(fsb.border_width_bottom, 2.0),
"V1 焦点环宽=2px")
check(is_equal_approx(fsb.expand_margin_left, -1.0) and is_equal_approx(fsb.expand_margin_top, -1.0)
and is_equal_approx(fsb.expand_margin_right, -1.0) and is_equal_approx(fsb.expand_margin_bottom, -1.0),
"V1 焦点环内缩=1px")
check(not fsb.draw_center and fsb.bg_color.a < 0.001, "V1 焦点环无底(叠加态不遮钮底)")
b.free()
# 主钮:五态非空+本族平涂(pressed/disabled 非石纹)+disabled≠pressed+hover 提亮档承现行
var pb = uikit_s.primary_button("测试")
for st in states:
check(pb.has_theme_stylebox_override(st), "V1 主钮 %s 样式盒非空" % st)
var ppn: StyleBox = pb.get_theme_stylebox("pressed")
var pdd: StyleBox = pb.get_theme_stylebox("disabled")
var phv: StyleBox = pb.get_theme_stylebox("hover")
check(ppn is StyleBoxFlat and pdd is StyleBoxFlat, "V1 主钮 pressed/disabled=本族平涂(非石纹)")
check((ppn as StyleBoxFlat).bg_color == Color8(214, 172, 88), "V1 主钮 pressed=烛光黄深档(现行值不动)")
check(is_equal_approx((pdd as StyleBoxFlat).bg_color.a, 0.45), "V1 主钮 disabled=本族底 α0.45 幽灵化")
check(pdd != ppn, "V1 主钮 disabled≠pressed")
check((phv as StyleBoxFlat).bg_color == uikit_s.CANDLE.lightened(0.06), "V1 主钮 hover=提亮档(承现行不动)")
pb.free()
# 危险钮:补本族 pressed(深档)+disabled 幽灵化+focus;pressed/disabled 非石纹
var db = uikit_s.danger_button("测试")
for st in states:
check(db.has_theme_stylebox_override(st), "V1 危险钮 %s 样式盒非空" % st)
var dpr: StyleBox = db.get_theme_stylebox("pressed")
var dds: StyleBox = db.get_theme_stylebox("disabled")
check(dpr is StyleBoxFlat and dds is StyleBoxFlat, "V1 危险钮 pressed/disabled=本族平涂(非石纹,旧错配已修正)")
check((dpr as StyleBoxFlat).bg_color.r < 180.0 / 255.0, "V1 危险钮 pressed=深红深档(暗于常态)")
check(is_equal_approx((dds as StyleBoxFlat).bg_color.a, 0.45), "V1 危险钮 disabled=本族底 α0.45 幽灵化")
check(dds != dpr, "V1 危险钮 disabled≠pressed")
db.free()
# V2 主题红线维持(Button 类型词条零接触+focus 族词条零定义)——与 _smoke_global_theme 同判据复述
var th := ThemeDB.get_project_theme()
if th != null:
check(not th.get_type_list().has("Button"), "V2 红线维持 Button 类型词条零接触")
var focus_hits := ""
for t in th.get_type_list():
for nm in (th.get_stylebox_list(t) + th.get_icon_list(t) + th.get_color_list(t)
+ th.get_font_list(t) + th.get_font_size_list(t) + th.get_constant_list(t)):
if "focus" in String(nm):
focus_hits += "%s/%s " % [t, nm]
check(focus_hits == "", "V2 红线维持 focus 族词条零定义%s" % ("" if focus_hits == "" else "(违例:" + focus_hits + ")"))
# ---- 存档序列化冒烟(SaveManager——读写往返/新档合法/余额拒花/锻造出域拒/高版本拒读禁写/
# 损坏兜底/迁移链/域界干净/摘要 cap/摘要集成/生涯终身计数域 v6)。测试文件统一 user://smoke_save_*.json 隔离,
# 段首清场+段尾清理——绝不碰 user://save.json(红线)。