fix(ui): theme reset and restart confirmations

Replaced native confirmation dialogs with an in-app card using app colours, fonts, wrapped body text, and full-width Cancel/destructive buttons. Tapping outside cancels. Added UI QA coverage and a reset-dialog screenshot.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 23:13:47 -06:00
1 parent bbfc35f79c
commit ea0f80664f
3 files changed
+150 -14

No files matched your search

+117 -14
View File
@@ -13,10 +13,14 @@ var hold_panel: PanelContainer
var game_actions: HBoxContainer
var reset_row: Control
var resume_button: Button
var restart_dialog: ConfirmationDialog
var reset_dialog: ConfirmationDialog
var reset_status: Label
var confirm_layer: ColorRect
var confirm_title: Label
var confirm_body: Label
var confirm_button: Button
var confirm_callback := Callable()
func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
@@ -128,17 +132,80 @@ func _ready() -> void:
column.add_child(UI.label(Version.BUILD_LABEL, 9, Palette.MUTED))
restart_dialog = ConfirmationDialog.new()
restart_dialog.title = "Restart room?"
restart_dialog.dialog_text = "This clears the current board and timer."
restart_dialog.confirmed.connect(func() -> void: restart_requested.emit())
add_child(restart_dialog)
_build_confirm()
reset_dialog = ConfirmationDialog.new()
reset_dialog.title = "Reset progress?"
reset_dialog.dialog_text = "This clears completed rooms and unlocked guests. Settings stay."
reset_dialog.confirmed.connect(_on_reset_confirmed)
add_child(reset_dialog)
func _build_confirm() -> void:
confirm_layer = ColorRect.new()
confirm_layer.color = Color(0.18, 0.12, 0.08, 0.62)
confirm_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
confirm_layer.mouse_filter = Control.MOUSE_FILTER_STOP
confirm_layer.gui_input.connect(_on_confirm_scrim_input)
confirm_layer.visible = false
add_child(confirm_layer)
var center := CenterContainer.new()
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
confirm_layer.add_child(center)
var panel := UI.panel(Palette.CREAM, 24, 16)
var max_width: int = max(240, int(get_viewport_rect().size.x) - 32)
panel.custom_minimum_size = Vector2(min(320, max_width), 0)
panel.mouse_filter = Control.MOUSE_FILTER_STOP
center.add_child(panel)
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 10)
panel.add_child(box)
confirm_title = UI.heading("Reset progress?", 20)
confirm_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
box.add_child(confirm_title)
confirm_body = UI.label("", 13, Palette.MUTED)
confirm_body.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
box.add_child(confirm_body)
var actions := HBoxContainer.new()
actions.add_theme_constant_override("separation", 8)
box.add_child(actions)
var cancel := UI.button("Cancel", false, 46)
cancel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
cancel.pressed.connect(_hide_confirm)
actions.add_child(cancel)
confirm_button = UI.button("Reset", false, 46)
confirm_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
_apply_red_style(confirm_button)
confirm_button.pressed.connect(_on_confirm_pressed)
actions.add_child(confirm_button)
func _apply_red_style(button: Button) -> void:
button.add_theme_stylebox_override("normal", _red_box(Palette.RED))
button.add_theme_stylebox_override("hover", _red_box(Palette.RED.lightened(0.07)))
button.add_theme_stylebox_override("pressed", _red_box(Palette.RED.darkened(0.10)))
button.add_theme_stylebox_override("focus", _red_box(Palette.RED))
button.add_theme_color_override("font_color", Palette.WHITE)
button.add_theme_color_override("font_hover_color", Palette.WHITE)
button.add_theme_color_override("font_pressed_color", Palette.WHITE)
button.add_theme_color_override("font_focus_color", Palette.WHITE)
func _red_box(color: Color) -> StyleBoxFlat:
var style := StyleBoxFlat.new()
style.bg_color = color
style.corner_radius_top_left = 26
style.corner_radius_top_right = 26
style.corner_radius_bottom_left = 26
style.corner_radius_bottom_right = 26
style.content_margin_left = 16
style.content_margin_right = 16
style.content_margin_top = 10
style.content_margin_bottom = 10
return style
func open_sheet(mode: String) -> void:
@@ -302,7 +369,12 @@ func _close() -> void:
func _on_restart() -> void:
restart_dialog.popup_centered()
_show_confirm(
"Restart room?",
"This clears the current board and timer.",
"Restart",
func() -> void: restart_requested.emit()
)
func _on_lobby() -> void:
@@ -311,7 +383,38 @@ func _on_lobby() -> void:
func _on_reset() -> void:
reset_dialog.popup_centered()
_show_confirm(
"Reset progress?",
"This clears completed rooms and unlocked guests. Settings stay.",
"Reset",
_on_reset_confirmed
)
func _show_confirm(title: String, body: String, action: String, callback: Callable) -> void:
confirm_title.text = title
confirm_body.text = body
confirm_button.text = action
confirm_callback = callback
confirm_layer.visible = true
confirm_layer.move_to_front()
func _hide_confirm() -> void:
confirm_layer.visible = false
confirm_callback = Callable()
func _on_confirm_scrim_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
_hide_confirm()
func _on_confirm_pressed() -> void:
var callback := confirm_callback
_hide_confirm()
if callback.is_valid():
callback.call()
func _on_reset_confirmed() -> void: