按 code-conventions §1.4.1 第三轮定稿执行:core 22+schemas 18+presentation 根 14+views 28,全部头注 #→##、删日期/变更叙事/GDD 与架构反向链接/字段与域清单/机制描述,保留职责摘要+真实使用约束(防事故禁令/单一入口/信号契约每信号一行)。main.gd 31→5 行、save_manager 45→5 行、adventure_runner 37→5 行为最大单件。子代理分模块执行(波一 core+schemas、波二 presentation+views,并发≤2)。验收=tools/verify_comment_only_change.py 逐字节校验(82 文件头注区外逐行一致=零行为变更)+audit_file_headers 全绿;纯注释批免冒烟(先例 5843270)
54 lines
1.9 KiB
GDScript
54 lines
1.9 KiB
GDScript
## VERTICAL SLICE - NOT FOR PRODUCTION
|
||
## 非模态 toast 槽:三槽堆叠自动消退(2.5s),info/warn/gold 三调性。
|
||
## 弹什么文案归组合根决定——本类只管槽位堆叠与消退,不做提示内容决策。
|
||
class_name ToastStack
|
||
extends Control
|
||
|
||
const LIFE_SEC := 2.5
|
||
const MAX_SLOTS := 3
|
||
const COL_INFO := UiKit.INK
|
||
const COL_WARN := UiKit.RED_MINE # 危险红族——拒绝/作废(旗朱退役 2026-09-26)
|
||
const COL_GOLD := UiKit.GOLD_DEEP # 奖励金族——提示/达成(深金档)
|
||
|
||
var _slot_box: VBoxContainer
|
||
|
||
|
||
func _init() -> void:
|
||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
set_anchors_preset(Control.PRESET_TOP_WIDE)
|
||
custom_minimum_size = Vector2(0, 84)
|
||
_slot_box = VBoxContainer.new()
|
||
_slot_box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
_slot_box.alignment = BoxContainer.ALIGNMENT_BEGIN
|
||
_slot_box.add_theme_constant_override("separation", 2)
|
||
add_child(_slot_box)
|
||
|
||
|
||
func show_toast(text: String, tone: String = "info") -> void:
|
||
while _slot_box.get_child_count() >= MAX_SLOTS:
|
||
var old: Control = _slot_box.get_child(0)
|
||
_slot_box.remove_child(old)
|
||
old.queue_free()
|
||
var row := PanelContainer.new()
|
||
row.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
row.clip_contents = true # 缺陷①约束:固定槽高裁剪,不回流布局
|
||
row.custom_minimum_size = Vector2(0, 24)
|
||
var sb := UiKit.panel_flat(UiKit.TOAST_BG, COL_INFO,UiKit.RADIUS_OBJECT, 1, Vector4(8, 2, 8, 2))
|
||
var col := COL_INFO
|
||
if tone == "warn":
|
||
col = COL_WARN
|
||
elif tone == "gold":
|
||
col = COL_GOLD
|
||
sb.border_color = col
|
||
row.add_theme_stylebox_override("panel", sb)
|
||
var lab := UiKit.label(("⚠ " if tone == "warn" else "") + text,UiKit.FS_HINT, tone != "info", col)
|
||
lab.clip_text = true
|
||
row.add_child(lab)
|
||
_slot_box.add_child(row)
|
||
var tw := row.create_tween()
|
||
tw.tween_interval(LIFE_SEC)
|
||
tw.tween_property(row, "modulate:a", 0.0, 0.35)
|
||
tw.tween_callback(func():
|
||
if is_instance_valid(row):
|
||
row.queue_free())
|