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 game_actions: HBoxContainer
var reset_row: Control var reset_row: Control
var resume_button: Button var resume_button: Button
var restart_dialog: ConfirmationDialog
var reset_dialog: ConfirmationDialog
var reset_status: Label 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: func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) 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)) column.add_child(UI.label(Version.BUILD_LABEL, 9, Palette.MUTED))
restart_dialog = ConfirmationDialog.new() _build_confirm()
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)
reset_dialog = ConfirmationDialog.new()
reset_dialog.title = "Reset progress?" func _build_confirm() -> void:
reset_dialog.dialog_text = "This clears completed rooms and unlocked guests. Settings stay." confirm_layer = ColorRect.new()
reset_dialog.confirmed.connect(_on_reset_confirmed) confirm_layer.color = Color(0.18, 0.12, 0.08, 0.62)
add_child(reset_dialog) 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: func open_sheet(mode: String) -> void:
@@ -302,7 +369,12 @@ func _close() -> void:
func _on_restart() -> 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: func _on_lobby() -> void:
@@ -311,7 +383,38 @@ func _on_lobby() -> void:
func _on_reset() -> 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: func _on_reset_confirmed() -> void:
+29
View File
@@ -101,6 +101,29 @@ func _test_settings(main, save) -> void:
toggles["double_tap_place"].button_pressed = true toggles["double_tap_place"].button_pressed = true
_check(bool(save.get_setting("double_tap_place")), "double-tap toggle should update SaveGame") _check(bool(save.get_setting("double_tap_place")), "double-tap toggle should update SaveGame")
_check(not main.settings_sheet.hold_slider.editable, "hold slider should be disabled with double-tap on") _check(not main.settings_sheet.hold_slider.editable, "hold slider should be disabled with double-tap on")
# Themed confirmation replaces the native popup on reset.
var sheet = main.settings_sheet
sheet._on_reset()
await process_frame
_check(sheet.confirm_layer.visible, "reset confirmation should be visible")
_check(sheet.confirm_title.text == "Reset progress?", "reset confirmation title")
_check(sheet.confirm_button.text == "Reset", "reset confirmation action text")
var panel: Control = sheet.confirm_layer.get_child(0).get_child(0)
var viewport_width: int = int(ProjectSettings.get_setting("display/window/size/viewport_width"))
_check(panel.custom_minimum_size.x <= viewport_width - 16, "confirmation panel should fit the screen")
var outside := InputEventMouseButton.new()
outside.button_index = MOUSE_BUTTON_LEFT
outside.pressed = true
sheet._on_confirm_scrim_input(outside)
_check(not sheet.confirm_layer.visible, "tapping outside should dismiss confirmation")
save.data["completed_rooms"].append("room-confirm")
sheet._on_reset()
await process_frame
sheet.confirm_button.pressed.emit()
await process_frame
_check((save.data.get("completed_rooms") as Array).is_empty(), "confirming reset should clear progress")
main.close_settings() main.close_settings()
await process_frame await process_frame
_check(not main.settings_sheet.visible, "settings sheet should close from home") _check(not main.settings_sheet.visible, "settings sheet should close from home")
@@ -112,6 +135,12 @@ func _test_settings(main, save) -> void:
_check(main.settings_sheet.resume_button.text == "Resume", "game settings should use Resume") _check(main.settings_sheet.resume_button.text == "Resume", "game settings should use Resume")
_check(main.settings_sheet.game_actions.visible, "game settings should show Restart/Lobby") _check(main.settings_sheet.game_actions.visible, "game settings should show Restart/Lobby")
_check(main.game.ui_paused, "game should pause while settings are open") _check(main.game.ui_paused, "game should pause while settings are open")
main.settings_sheet._on_restart()
await process_frame
_check(main.settings_sheet.confirm_layer.visible, "restart confirmation should be visible")
_check(main.settings_sheet.confirm_title.text == "Restart room?", "restart confirmation title")
_check(main.settings_sheet.confirm_button.text == "Restart", "restart confirmation action text")
main.settings_sheet._hide_confirm()
main.close_settings() main.close_settings()
await process_frame await process_frame
_check(not main.settings_sheet.visible, "settings sheet should close from game") _check(not main.settings_sheet.visible, "settings sheet should close from game")
+4
View File
@@ -32,6 +32,10 @@ func _run() -> void:
main.open_settings("home") main.open_settings("home")
await _settle() await _settle()
_save("res://screenshots/settings.png") _save("res://screenshots/settings.png")
main.settings_sheet._on_reset()
await _settle()
_save("res://screenshots/reset_confirm.png")
main.settings_sheet._hide_confirm()
main.close_settings() main.close_settings()
main.show_screen("guest_book") main.show_screen("guest_book")