78 lines
2.6 KiB
GDScript
78 lines
2.6 KiB
GDScript
# VERTICAL SLICE - NOT FOR PRODUCTION
|
|
# Date: 2026-09-29(迭代 8 二轮修改批 A——新冒险互斥确认弹窗化,用户目检裁决:
|
|
# 按钮文字换面 → 实底确认弹窗「开新冒险 + 取消」)
|
|
# 通用确认弹窗(实底石板皮面板,与营地/设置/图例同族视觉):open(text, confirm_label, cancel_label)
|
|
# 双钮外发 confirmed/cancelled——语义装配归调用方,本类零业务触碰(纯视图边界规范 1.3)。
|
|
class_name ConfirmDialog
|
|
extends Control
|
|
|
|
signal confirmed
|
|
signal cancelled
|
|
|
|
var _text: Label
|
|
var _confirm_btn: Button
|
|
var _cancel_btn: Button
|
|
|
|
|
|
func _init() -> void:
|
|
var dim := ColorRect.new()
|
|
dim.color = Color(UiKit.DIM, 0.55)
|
|
dim.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
add_child(dim)
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
dim.add_child(center)
|
|
var panel := PanelContainer.new()
|
|
panel.add_theme_stylebox_override("panel", UiKit.panel_skinned(Vector4(14, 12, 14, 12)))
|
|
center.add_child(panel)
|
|
var box := VBoxContainer.new()
|
|
box.custom_minimum_size = Vector2(460, 0)
|
|
box.add_theme_constant_override("separation", 12)
|
|
panel.add_child(box)
|
|
_text = UiKit.label("", 16, false)
|
|
_text.add_theme_color_override("font_color", UiKit.INK_TITLE)
|
|
_text.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
_text.custom_minimum_size = Vector2(430, 0)
|
|
box.add_child(_text)
|
|
box.add_child(HSeparator.new())
|
|
var btn_row := HBoxContainer.new()
|
|
btn_row.add_theme_constant_override("separation", 12)
|
|
btn_row.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
box.add_child(btn_row)
|
|
_cancel_btn = UiKit.button("取消")
|
|
_cancel_btn.pressed.connect(_emit_cancelled)
|
|
btn_row.add_child(_cancel_btn)
|
|
_confirm_btn = UiKit.button("确认")
|
|
_confirm_btn.pressed.connect(_emit_confirmed)
|
|
btn_row.add_child(_confirm_btn)
|
|
visible = false
|
|
|
|
|
|
func open(text: String, confirm_label: String, cancel_label: String = "取消") -> void:
|
|
_text.text = text
|
|
_confirm_btn.text = confirm_label
|
|
_cancel_btn.text = cancel_label
|
|
# z 序自提(三轮修改批 #1——用户实机实证:本弹窗构建序早于开始覆盖层,而开始层是组合根
|
|
# 尾部才 add_child 的(树序最末=绘制最上),弹窗被整层盖住——「看不见弹窗/离开菜单才显形」。
|
|
# 每次打开强制提到宿主子级最末,绘制序恒最上。)
|
|
var host := get_parent()
|
|
if host != null:
|
|
host.move_child(self, host.get_child_count() - 1)
|
|
visible = true
|
|
|
|
|
|
func close() -> void:
|
|
visible = false
|
|
|
|
|
|
func is_open() -> bool:
|
|
return visible
|
|
|
|
|
|
func _emit_confirmed() -> void:
|
|
confirmed.emit()
|
|
|
|
|
|
func _emit_cancelled() -> void:
|
|
cancelled.emit()
|