Local-only v0.8.1 build. Achievement rows pass touch drags, avatars use head crops and hide locked identities, difficulty cycles Zen/Easy/Normal, wallpaper setting opens a preview picker, Brie uses the approved render with a text-free sheet, and the app icon is regenerated in gouache style.
618 lines
20 KiB
GDScript
618 lines
20 KiB
GDScript
extends Control
|
||
|
||
signal closed
|
||
signal restart_requested
|
||
signal lobby_requested
|
||
signal rules_requested
|
||
|
||
var game_mode := false
|
||
var toggles := {}
|
||
var hold_slider: HSlider
|
||
var hold_value: Label
|
||
var hold_panel: PanelContainer
|
||
var music_volume_slider: HSlider
|
||
var difficulty_button: Button
|
||
var theme_button: Button
|
||
var wallpaper_layer: ColorRect
|
||
var wallpaper_grid: GridContainer
|
||
var pending_theme := "cream"
|
||
var game_actions: HBoxContainer
|
||
var reset_row: Control
|
||
var resume_button: Button
|
||
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)
|
||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||
visible = false
|
||
|
||
var scrim := ColorRect.new()
|
||
scrim.color = Color(0.18, 0.12, 0.08, 0.55)
|
||
scrim.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
scrim.mouse_filter = Control.MOUSE_FILTER_STOP
|
||
scrim.gui_input.connect(_on_scrim_input)
|
||
add_child(scrim)
|
||
|
||
var panel := PanelContainer.new()
|
||
panel.anchor_left = 0.0
|
||
panel.anchor_right = 1.0
|
||
panel.anchor_top = 1.0
|
||
panel.anchor_bottom = 1.0
|
||
panel.offset_top = -610
|
||
panel.offset_bottom = -UI.safe_bottom()
|
||
panel.offset_left = 0
|
||
panel.offset_right = 0
|
||
var style := StyleBoxFlat.new()
|
||
style.bg_color = Palette.CREAM
|
||
style.corner_radius_top_left = 26
|
||
style.corner_radius_top_right = 26
|
||
style.content_margin_left = 16
|
||
style.content_margin_right = 16
|
||
style.content_margin_top = 12
|
||
style.content_margin_bottom = 16
|
||
style.shadow_color = Color(0.18, 0.12, 0.08, 0.24)
|
||
style.shadow_size = 10
|
||
panel.add_theme_stylebox_override("panel", style)
|
||
add_child(panel)
|
||
|
||
var column := VBoxContainer.new()
|
||
column.add_theme_constant_override("separation", 8)
|
||
panel.add_child(column)
|
||
|
||
var header := HBoxContainer.new()
|
||
header.add_theme_constant_override("separation", 8)
|
||
column.add_child(header)
|
||
|
||
var title := UI.label("Settings", 24)
|
||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
header.add_child(title)
|
||
|
||
var close := UI.button("×", false, 36)
|
||
close.custom_minimum_size = Vector2(42, 36)
|
||
close.add_theme_font_size_override("font_size", 24)
|
||
close.pressed.connect(_close)
|
||
header.add_child(close)
|
||
|
||
var scroll := ScrollContainer.new()
|
||
scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||
column.add_child(scroll)
|
||
|
||
var list := VBoxContainer.new()
|
||
list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
list.add_theme_constant_override("separation", 8)
|
||
scroll.add_child(list)
|
||
|
||
_add_pattern_row(list)
|
||
_add_toggle(list, "Show timer", "Keep the clock visible while you solve.", "show_timer")
|
||
_add_toggle(list, "Reduce motion", "Stop the bob and placement pop.", "reduce_motion")
|
||
_add_toggle(list, "Double-tap to place", "Tap = mark · double-tap = check in.", "double_tap_place")
|
||
_add_toggle(list, "Music", "Play the hotel lounge loop.", "music")
|
||
_add_toggle(list, "Sound effects", "UI and completion chimes.", "sfx")
|
||
_add_slider_row(list, "Music volume", "Lounge loop loudness.", "music_volume")
|
||
difficulty_button = UI.button("Difficulty: Normal", false, 40)
|
||
difficulty_button.pressed.connect(_cycle_difficulty)
|
||
list.add_child(difficulty_button)
|
||
theme_button = UI.button("Wallpaper: Cream", false, 40)
|
||
theme_button.pressed.connect(_open_wallpaper_picker)
|
||
list.add_child(theme_button)
|
||
_add_hold_row(list)
|
||
|
||
list.add_child(UI.spacer(2))
|
||
var rules := UI.button("How to play", false, 44)
|
||
rules.add_theme_font_size_override("font_size", 15)
|
||
rules.pressed.connect(func() -> void: rules_requested.emit())
|
||
list.add_child(rules)
|
||
|
||
reset_row = _action_row("Reset progress", "Clear completed rooms and unlocked guests.", Palette.RED, _on_reset)
|
||
list.add_child(reset_row)
|
||
|
||
reset_status = UI.label("", 10, Palette.MUTED)
|
||
list.add_child(reset_status)
|
||
|
||
# Let swipes reach the sheet's ScrollContainer even when they start on a
|
||
# label, toggle, or button.
|
||
UI.pass_scroll_input(list)
|
||
|
||
_build_wallpaper_picker()
|
||
|
||
game_actions = HBoxContainer.new()
|
||
game_actions.add_theme_constant_override("separation", 6)
|
||
column.add_child(game_actions)
|
||
|
||
var restart := UI.button("Restart", false, 40)
|
||
restart.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
restart.add_theme_font_size_override("font_size", 14)
|
||
restart.add_theme_color_override("font_color", Palette.RED)
|
||
restart.pressed.connect(_on_restart)
|
||
game_actions.add_child(restart)
|
||
|
||
var lobby := UI.button("Lobby", false, 40)
|
||
lobby.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
lobby.add_theme_font_size_override("font_size", 14)
|
||
lobby.pressed.connect(_on_lobby)
|
||
game_actions.add_child(lobby)
|
||
|
||
var resume := UI.button("Resume", true, 52)
|
||
resume.pressed.connect(_close)
|
||
resume_button = resume
|
||
column.add_child(resume)
|
||
|
||
column.add_child(UI.label(Version.BUILD_LABEL, 9, Palette.MUTED))
|
||
|
||
_build_confirm()
|
||
|
||
|
||
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:
|
||
game_mode = mode == "game"
|
||
game_actions.visible = game_mode
|
||
reset_row.visible = not game_mode
|
||
reset_status.visible = not game_mode
|
||
resume_button.text = "Resume" if game_mode else "Close"
|
||
refresh()
|
||
visible = true
|
||
move_to_front()
|
||
|
||
|
||
func refresh() -> void:
|
||
for key in toggles:
|
||
toggles[key].button_pressed = bool(SaveGame.get_setting(key))
|
||
if hold_slider != null:
|
||
hold_slider.set_value_no_signal(float(SaveGame.get_setting("hold_seconds")))
|
||
hold_value.text = "%.2f s" % hold_slider.value
|
||
if music_volume_slider != null:
|
||
music_volume_slider.set_value_no_signal(float(SaveGame.get_setting("music_volume")))
|
||
if difficulty_button != null:
|
||
difficulty_button.text = "Difficulty: %s" % str(SaveGame.get_setting("difficulty")).capitalize()
|
||
if theme_button != null:
|
||
var theme: Dictionary = SaveGame.THEMES.get(SaveGame.theme_id(), {})
|
||
theme_button.text = "Wallpaper: %s" % str(theme.get("name", "Cream"))
|
||
_update_hold_availability()
|
||
|
||
|
||
func _add_pattern_row(parent: VBoxContainer) -> void:
|
||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||
var row := HBoxContainer.new()
|
||
row.add_theme_constant_override("separation", 8)
|
||
panel.add_child(row)
|
||
|
||
var icon := UI.icon("res://assets/icons/leaf.svg", 18, Palette.INK)
|
||
row.add_child(icon)
|
||
|
||
var label := UI.label("Room patterns", 15)
|
||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
row.add_child(label)
|
||
|
||
var check := CheckButton.new()
|
||
check.button_pressed = bool(SaveGame.get_setting("patterns"))
|
||
check.toggled.connect(func(on: bool) -> void: SaveGame.set_setting("patterns", on))
|
||
row.add_child(check)
|
||
toggles["patterns"] = check
|
||
parent.add_child(panel)
|
||
|
||
|
||
func _add_toggle(parent: VBoxContainer, title: String, detail: String, key: String) -> void:
|
||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||
var row := HBoxContainer.new()
|
||
row.add_theme_constant_override("separation", 8)
|
||
panel.add_child(row)
|
||
|
||
var text := VBoxContainer.new()
|
||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
text.add_theme_constant_override("separation", 0)
|
||
row.add_child(text)
|
||
|
||
var label := UI.label(title, 14)
|
||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
text.add_child(label)
|
||
|
||
var sub := UI.label(detail, 10, Palette.MUTED)
|
||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
text.add_child(sub)
|
||
|
||
var check := CheckButton.new()
|
||
check.button_pressed = bool(SaveGame.get_setting(key))
|
||
check.toggled.connect(func(on: bool) -> void:
|
||
SaveGame.set_setting(key, on)
|
||
_update_hold_availability()
|
||
)
|
||
row.add_child(check)
|
||
toggles[key] = check
|
||
parent.add_child(panel)
|
||
|
||
|
||
func _add_slider_row(parent: VBoxContainer, title: String, detail: String, key: String) -> void:
|
||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||
var column := VBoxContainer.new()
|
||
column.add_theme_constant_override("separation", 2)
|
||
panel.add_child(column)
|
||
column.add_child(UI.label(title, 14))
|
||
column.add_child(UI.label(detail, 10, Palette.MUTED))
|
||
var slider := HSlider.new()
|
||
slider.min_value = 0.0
|
||
slider.max_value = 1.0
|
||
slider.step = 0.05
|
||
slider.value = float(SaveGame.get_setting(key))
|
||
slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
slider.value_changed.connect(func(value: float) -> void: SaveGame.set_setting(key, snapped(value, 0.05)))
|
||
column.add_child(slider)
|
||
parent.add_child(panel)
|
||
if key == "music_volume":
|
||
music_volume_slider = slider
|
||
|
||
|
||
func _cycle_difficulty() -> void:
|
||
var order := ["zen", "easy", "normal"]
|
||
var current := str(SaveGame.get_setting("difficulty"))
|
||
var next_index := (order.find(current) + 1) % order.size()
|
||
SaveGame.set_setting("difficulty", order[next_index])
|
||
refresh()
|
||
|
||
|
||
func _open_wallpaper_picker() -> void:
|
||
pending_theme = SaveGame.theme_id()
|
||
_build_wallpaper_grid()
|
||
wallpaper_layer.visible = true
|
||
wallpaper_layer.move_to_front()
|
||
|
||
|
||
func _build_wallpaper_picker() -> void:
|
||
wallpaper_layer = ColorRect.new()
|
||
wallpaper_layer.color = Color(0.18, 0.12, 0.08, 0.62)
|
||
wallpaper_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
wallpaper_layer.mouse_filter = Control.MOUSE_FILTER_STOP
|
||
wallpaper_layer.gui_input.connect(func(event: InputEvent) -> void:
|
||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||
wallpaper_layer.visible = false
|
||
)
|
||
wallpaper_layer.visible = false
|
||
add_child(wallpaper_layer)
|
||
|
||
var center := CenterContainer.new()
|
||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
wallpaper_layer.add_child(center)
|
||
var panel := UI.panel(Palette.CREAM, 24, 16)
|
||
var max_width: int = max(280, int(get_viewport_rect().size.x) - 32)
|
||
panel.custom_minimum_size = Vector2(min(360, max_width), 0)
|
||
center.add_child(panel)
|
||
var box := VBoxContainer.new()
|
||
box.add_theme_constant_override("separation", 8)
|
||
panel.add_child(box)
|
||
box.add_child(UI.heading("Wallpapers", 20))
|
||
|
||
var scroll := ScrollContainer.new()
|
||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||
box.add_child(scroll)
|
||
wallpaper_grid = GridContainer.new()
|
||
wallpaper_grid.columns = 2
|
||
wallpaper_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
wallpaper_grid.add_theme_constant_override("h_separation", 6)
|
||
wallpaper_grid.add_theme_constant_override("v_separation", 6)
|
||
scroll.add_child(wallpaper_grid)
|
||
|
||
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(func() -> void: wallpaper_layer.visible = false)
|
||
actions.add_child(cancel)
|
||
var confirm := UI.button("Apply", true, 46)
|
||
confirm.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
confirm.pressed.connect(_apply_wallpaper)
|
||
actions.add_child(confirm)
|
||
|
||
|
||
func _theme_requirement(def: Dictionary) -> String:
|
||
if str(def.get("name", "")) == "Gold":
|
||
return "Open the 7-day gift"
|
||
var rooms := int(def.get("rooms", 0))
|
||
var streak := int(def.get("streak", 0))
|
||
if rooms > 0 and streak > 0:
|
||
return "%d rooms · %d-day streak" % [rooms, streak]
|
||
if rooms > 0:
|
||
return "Complete %d rooms" % rooms
|
||
if streak > 0:
|
||
return "%d-day best streak" % streak
|
||
return "Always available"
|
||
|
||
|
||
func _build_wallpaper_grid() -> void:
|
||
for child in wallpaper_grid.get_children():
|
||
child.queue_free()
|
||
for id in SaveGame.THEMES.keys():
|
||
var def: Dictionary = SaveGame.THEMES[id]
|
||
var unlocked := SaveGame.is_theme_unlocked(id)
|
||
var card := Button.new()
|
||
card.custom_minimum_size = Vector2(150, 118)
|
||
card.flat = true
|
||
card.add_theme_stylebox_override("normal", _card_style(Palette.GOLD if id == pending_theme else Palette.PAPER))
|
||
card.add_theme_stylebox_override("hover", _card_style(Palette.PAPER_DARK))
|
||
card.pressed.connect(_select_pending_theme.bind(str(id), unlocked))
|
||
|
||
var column := VBoxContainer.new()
|
||
column.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
column.add_theme_constant_override("separation", 2)
|
||
column.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
card.add_child(column)
|
||
var preview := TextureRect.new()
|
||
preview.custom_minimum_size = Vector2(0, 68)
|
||
preview.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
preview.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||
preview.stretch_mode = TextureRect.STRETCH_SCALE
|
||
preview.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
var path := "res://assets/backgrounds/%s.png" % str(id)
|
||
if ResourceLoader.exists(path):
|
||
preview.texture = load(path)
|
||
column.add_child(preview)
|
||
var title := UI.label(str(def.get("name", id)), 11, Palette.INK)
|
||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
column.add_child(title)
|
||
var state := "Selected" if id == pending_theme else ("Unlocked" if unlocked else _theme_requirement(def))
|
||
var sub := UI.label(state, 9, Palette.GOLD if id == pending_theme else (Palette.MUTED if unlocked else Palette.RED))
|
||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
column.add_child(sub)
|
||
if not unlocked:
|
||
card.modulate = Color(1, 1, 1, 0.72)
|
||
wallpaper_grid.add_child(card)
|
||
UI.pass_scroll_input(wallpaper_grid)
|
||
|
||
|
||
func _select_pending_theme(id: String, unlocked: bool) -> void:
|
||
if not unlocked:
|
||
return
|
||
call_deferred("_set_pending_theme", id)
|
||
|
||
|
||
func _set_pending_theme(id: String) -> void:
|
||
pending_theme = id
|
||
_build_wallpaper_grid()
|
||
|
||
|
||
func _apply_wallpaper() -> void:
|
||
SaveGame.select_theme(pending_theme)
|
||
wallpaper_layer.visible = false
|
||
refresh()
|
||
|
||
|
||
func _card_style(color: Color) -> StyleBoxFlat:
|
||
var style := StyleBoxFlat.new()
|
||
style.bg_color = color
|
||
style.corner_radius_top_left = 12
|
||
style.corner_radius_top_right = 12
|
||
style.corner_radius_bottom_left = 12
|
||
style.corner_radius_bottom_right = 12
|
||
style.content_margin_left = 6
|
||
style.content_margin_right = 6
|
||
style.content_margin_top = 6
|
||
style.content_margin_bottom = 6
|
||
return style
|
||
|
||
|
||
func _add_hold_row(parent: VBoxContainer) -> void:
|
||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||
hold_panel = panel
|
||
var column := VBoxContainer.new()
|
||
column.add_theme_constant_override("separation", 2)
|
||
panel.add_child(column)
|
||
|
||
var label := UI.label("Hold time", 14)
|
||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
column.add_child(label)
|
||
|
||
var sub := UI.label("How long to press before checking in.", 10, Palette.MUTED)
|
||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
column.add_child(sub)
|
||
|
||
var row := HBoxContainer.new()
|
||
row.add_theme_constant_override("separation", 8)
|
||
column.add_child(row)
|
||
|
||
hold_slider = HSlider.new()
|
||
hold_slider.min_value = 0.20
|
||
hold_slider.max_value = 0.50
|
||
hold_slider.step = 0.05
|
||
hold_slider.value = float(SaveGame.get_setting("hold_seconds"))
|
||
hold_slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
hold_slider.value_changed.connect(_on_hold_changed)
|
||
row.add_child(hold_slider)
|
||
|
||
hold_value = UI.label("%.2f s" % hold_slider.value, 11, Palette.MUTED)
|
||
hold_value.custom_minimum_size = Vector2(46, 0)
|
||
row.add_child(hold_value)
|
||
|
||
parent.add_child(panel)
|
||
|
||
|
||
func _action_row(title: String, detail: String, color: Color, callback: Callable) -> Control:
|
||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||
var row := HBoxContainer.new()
|
||
row.add_theme_constant_override("separation", 8)
|
||
panel.add_child(row)
|
||
|
||
var text := VBoxContainer.new()
|
||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
text.add_theme_constant_override("separation", 0)
|
||
row.add_child(text)
|
||
|
||
var label := UI.label(title, 14, color)
|
||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
text.add_child(label)
|
||
|
||
var sub := UI.label(detail, 10, Palette.MUTED)
|
||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
text.add_child(sub)
|
||
|
||
var go := UI.button("›", false, 34)
|
||
go.custom_minimum_size = Vector2(38, 34)
|
||
go.add_theme_font_size_override("font_size", 18)
|
||
go.pressed.connect(callback)
|
||
row.add_child(go)
|
||
|
||
return panel
|
||
|
||
|
||
func _on_hold_changed(value: float) -> void:
|
||
var snapped: float = snapped(value, 0.05)
|
||
hold_value.text = "%.2f s" % snapped
|
||
SaveGame.set_setting("hold_seconds", snapped)
|
||
|
||
|
||
func _update_hold_availability() -> void:
|
||
if hold_slider == null or hold_panel == null:
|
||
return
|
||
var enabled := not bool(SaveGame.get_setting("double_tap_place"))
|
||
hold_slider.editable = enabled
|
||
hold_slider.mouse_filter = Control.MOUSE_FILTER_PASS if enabled else Control.MOUSE_FILTER_IGNORE
|
||
hold_panel.modulate = Color(1, 1, 1, 1.0 if enabled else 0.45)
|
||
|
||
|
||
func _on_scrim_input(event: InputEvent) -> void:
|
||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||
_close()
|
||
|
||
|
||
func _close() -> void:
|
||
visible = false
|
||
closed.emit()
|
||
|
||
|
||
func _on_restart() -> void:
|
||
_show_confirm(
|
||
"Restart room?",
|
||
"This clears the current board and timer.",
|
||
"Restart",
|
||
func() -> void: restart_requested.emit()
|
||
)
|
||
|
||
|
||
func _on_lobby() -> void:
|
||
visible = false
|
||
lobby_requested.emit()
|
||
|
||
|
||
func _on_reset() -> void:
|
||
_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:
|
||
SaveGame.reset_progress()
|
||
reset_status.text = "Progress reset."
|
||
reset_status.add_theme_color_override("font_color", Palette.INK)
|