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

93 lines
3.4 KiB
GDScript

## VERTICAL SLICE - NOT FOR PRODUCTION
## 格态语义图例模态(自持 open/close 开关)。
class_name LegendOverlay
extends Control
signal closed
const ENTRIES := [
["#C9AF83", "完整覆尘地砖", "未开格——左键挖开(1AP,须相邻)· 右键封印(1AP)"],
["#B39A78", "碎裂裸土", "已开 0 格——可通行,左键移动(免费)"],
["#000000", "封印", "封印印记(呈现名·不能拔)——轮末自动判定标中;标空可左键直接挖开(安全格零奖励、危险格受挖掘惩罚)"],
["#2e86de", "小人", "探险者——8 向相邻未开格常驻微光 = 可挖域"],
["#F0A828", "金徽章", "已开格奖励身份 icon(封印之下、数值之上,不进数字区)"],
["#F0A828", "九徽章解码", "攻=攻击 · 守=护甲 · 爆=爆裂 · 医=回复 · 弱=削弱 · 穿=穿刺 · 魔=魔法 · 行=行动点 · 金=GP"],
["#33261B", "状态槽空态", "无状态效果时槽位隐藏,数据框上移补位——非异常"],
]
var _panel: PanelContainer
var _rap_cost := -1 # <0 = 不渲染 RAP 行(构造参数注表值,禁字面量)
func _init(rap_cost: int = -1) -> void:
_rap_cost = rap_cost
var shell := UiKit.modal_shell(self, Color(UiKit.DIM, 0.55), Vector2(520, 0), 6,
UiKit.panel_skinned(Vector4(12, 10, 12, 10))) # 石板皮(T2;缺位回退 flat)
_panel = shell.panel
(shell.dim as ColorRect).gui_input.connect(_on_dim_gui_input)
var box: VBoxContainer = shell.box
var title := UiKit.label("图例 · 格态",UiKit.FS_SUB, true, UiKit.INK_TITLE) # 亮底墨字(§7.2 数据素面)
box.add_child(title)
box.add_child(HSeparator.new())
for e in ENTRIES:
box.add_child(_legend_row(e))
box.add_child(HSeparator.new())
# RAP 行(表值驱动,禁字面量:刷新代价读行动经济表)
if _rap_cost >= 0:
var rap_row := HBoxContainer.new()
rap_row.add_theme_constant_override("separation", 8)
var rap_chip := ColorRect.new()
rap_chip.custom_minimum_size = Vector2(18, 18)
rap_chip.color = UiKit.GOLD # 同 #F0A828——金徽章同源单点(T4 裸色收口)
rap_row.add_child(rap_chip)
var rap_lab := UiKit.label("RAP 储备行动点 —— 停手时剩余 AP 转存;弃图刷新消耗 RAP−%d(旧板封印作废,AP 保留继续挖)" % _rap_cost,UiKit.FS_HINT, false, UiKit.INK_LABEL)
rap_lab.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
rap_lab.custom_minimum_size = Vector2(440, 0)
rap_row.add_child(rap_lab)
box.add_child(rap_row)
box.add_child(HSeparator.new())
var close_btn := UiKit.button("关闭")
close_btn.pressed.connect(close)
box.add_child(close_btn)
visible = false
## 单行域(循环体提函数——色块 chip+词条 18px 网格对齐)
func _legend_row(e: Array) -> HBoxContainer:
var row := HBoxContainer.new()
row.add_theme_constant_override("separation", 8)
var chip := ColorRect.new()
chip.custom_minimum_size = Vector2(18, 18)
chip.color = Color(e[0])
row.add_child(chip)
var lab := UiKit.label("%s —— %s" % [e[1], e[2]], 13, false, UiKit.INK_LABEL) # 亮底墨字(§7.2 数据素面)
lab.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
lab.custom_minimum_size = Vector2(440, 0)
row.add_child(lab)
return row
func is_open() -> bool:
return visible
func open() -> void:
visible = true
func close() -> void:
if not visible:
return
visible = false
closed.emit()
func _on_dim_gui_input(ev: InputEvent) -> void:
if ev is InputEventMouseButton and ev.pressed:
close()