fix(ui): safe areas, centered top hub, compact settings sheet

This commit is contained in:
Ratdoku Builder committed 2026-12-02 10:54:33 -06:00
1 parent c6a86d74d9
commit 5402541f59
7 files changed
+95 -58

No files matched your search

+2 -2
View File
@@ -41,8 +41,8 @@ func _build_ui() -> void:
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 12)
margin.add_theme_constant_override("margin_right", 12)
margin.add_theme_constant_override("margin_top", 10)
margin.add_theme_constant_override("margin_bottom", 10)
margin.add_theme_constant_override("margin_top", UI.safe_top())
margin.add_theme_constant_override("margin_bottom", UI.safe_bottom())
add_child(margin)
var column := VBoxContainer.new()
+2 -2
View File
@@ -20,8 +20,8 @@ func _ready() -> void:
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 12)
margin.add_theme_constant_override("margin_right", 12)
margin.add_theme_constant_override("margin_top", 8)
margin.add_theme_constant_override("margin_bottom", 10)
margin.add_theme_constant_override("margin_top", UI.safe_top())
margin.add_theme_constant_override("margin_bottom", UI.safe_bottom())
add_child(margin)
var column := VBoxContainer.new()
+19 -15
View File
@@ -14,8 +14,8 @@ func _ready() -> void:
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", UI.MARGIN)
margin.add_theme_constant_override("margin_right", UI.MARGIN)
margin.add_theme_constant_override("margin_top", 12)
margin.add_theme_constant_override("margin_bottom", 14)
margin.add_theme_constant_override("margin_top", UI.safe_top())
margin.add_theme_constant_override("margin_bottom", UI.safe_bottom())
add_child(margin)
var column := VBoxContainer.new()
@@ -23,7 +23,7 @@ func _ready() -> void:
margin.add_child(column)
var hub := HBoxContainer.new()
hub.add_theme_constant_override("separation", 8)
hub.add_theme_constant_override("separation", 0)
column.add_child(hub)
var avatar := Button.new()
@@ -31,30 +31,34 @@ func _ready() -> void:
avatar.flat = true
avatar.icon = load("res://art/crumb_head.png")
avatar.expand_icon = true
avatar.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
avatar.alignment = HORIZONTAL_ALIGNMENT_CENTER
avatar.tooltip_text = "Guest Book"
avatar.pressed.connect(func() -> void: guest_book_pressed.emit())
hub.add_child(avatar)
var left_space := Control.new()
left_space.size_flags_horizontal = Control.SIZE_EXPAND_FILL
left_space.mouse_filter = Control.MOUSE_FILTER_IGNORE
hub.add_child(left_space)
var left := CenterContainer.new()
left.custom_minimum_size = Vector2(52, 52)
left.add_child(avatar)
hub.add_child(left)
var center := CenterContainer.new()
center.size_flags_horizontal = Control.SIZE_EXPAND_FILL
hub.add_child(center)
progress_pill = UI.button("5 / 25 guests", false, 38)
progress_pill.custom_minimum_size = Vector2(130, 38)
progress_pill.add_theme_font_size_override("font_size", 13)
progress_pill.size_flags_vertical = Control.SIZE_SHRINK_CENTER
progress_pill.pressed.connect(func() -> void: guest_book_pressed.emit())
hub.add_child(progress_pill)
var right_space := Control.new()
right_space.size_flags_horizontal = Control.SIZE_EXPAND_FILL
right_space.mouse_filter = Control.MOUSE_FILTER_IGNORE
hub.add_child(right_space)
center.add_child(progress_pill)
var settings := UI.round_button("res://assets/icons/settings.svg", 48)
settings.tooltip_text = "Settings"
settings.pressed.connect(func() -> void: settings_pressed.emit())
hub.add_child(settings)
var right := CenterContainer.new()
right.custom_minimum_size = Vector2(52, 52)
right.add_child(settings)
hub.add_child(right)
column.add_child(UI.spacer(4))
column.add_child(UI.heading("Ratdoku", 46))
+14 -8
View File
@@ -13,8 +13,8 @@ func _ready() -> void:
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
margin.add_theme_constant_override("margin_left", 12)
margin.add_theme_constant_override("margin_right", 12)
margin.add_theme_constant_override("margin_top", 8)
margin.add_theme_constant_override("margin_bottom", 10)
margin.add_theme_constant_override("margin_top", UI.safe_top())
margin.add_theme_constant_override("margin_bottom", UI.safe_bottom())
add_child(margin)
var column := VBoxContainer.new()
@@ -44,20 +44,20 @@ func _ready() -> void:
content.add_theme_constant_override("separation", 6)
scroll.add_child(content)
content.add_child(UI.heading("Welcome to the Rat Hotel", 18))
content.add_child(_heading("Welcome to the Rat Hotel", 18))
content.add_child(_body("Crumb runs a small hotel for travelling rats. Every guest wants a room of their own — and a little space from the neighbours."))
content.add_child(UI.heading("The four house rules", 18))
content.add_child(_heading("The four house rules", 18))
content.add_child(_rule_row("One guest per room", "Each coloured room holds exactly one rat.", "region"))
content.add_child(_rule_row("One guest per floor", "Each row holds exactly one rat.", "row"))
content.add_child(_rule_row("One guest per corridor", "Each column holds exactly one rat.", "col"))
content.add_child(_rule_row("No shared walls or corners", "Rats cannot touch, not even diagonally.", "touch"))
content.add_child(UI.heading("Checking in", 18))
content.add_child(_heading("Checking in", 18))
content.add_child(_body("Tap or left-click to mark X. Tap an X or a guest to clear it. Hold or right-click to check a guest in. Gold-ringed guests are already in."))
content.add_child(_body("Undo is unlimited. Hints are free and explain the next sensible move."))
content.add_child(UI.heading("Try a tiny room", 18))
content.add_child(_heading("Try a tiny room", 18))
content.add_child(_body("One guest is already checked in. Place the other four."))
var board_center := CenterContainer.new()
@@ -87,10 +87,10 @@ func _ready() -> void:
tutorial_status = UI.label("Tap = X · Hold or right-click = check in", 10, Palette.MUTED)
content.add_child(tutorial_status)
content.add_child(UI.heading("Housekeeping tips", 18))
content.add_child(_heading("Housekeeping tips", 18))
content.add_child(_body("Start with the smallest room. If a room's open cells all sit in one row, that row's guest belongs to that room. Every room has one solution and never requires guessing."))
content.add_child(UI.heading("Questions", 18))
content.add_child(_heading("Questions", 18))
content.add_child(_body("Why can't the rats touch? Every guest is a little grumpy after a long journey and wants their own space."))
content.add_child(_body("Why do some guests have gold rings? They checked in early. They are part of the puzzle, not a mistake."))
@@ -105,6 +105,12 @@ func _body(text: String) -> Label:
return label
func _heading(text: String, font_size: int = 18) -> Label:
var label := UI.heading(text, font_size)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
return label
func _rule_row(title: String, body: String, mode: String) -> PanelContainer:
var panel := UI.panel(Palette.PAPER, 14, 7)
var row := HBoxContainer.new()
+43 -31
View File
@@ -9,8 +9,7 @@ var game_mode := false
var toggles := {}
var hold_slider: HSlider
var hold_value: Label
var restart_row: Control
var lobby_row: Control
var game_actions: HBoxContainer
var reset_row: Control
var resume_button: Button
var restart_dialog: ConfirmationDialog
@@ -35,8 +34,8 @@ func _ready() -> void:
panel.anchor_right = 1.0
panel.anchor_top = 1.0
panel.anchor_bottom = 1.0
panel.offset_top = -540
panel.offset_bottom = 0
panel.offset_top = -610
panel.offset_bottom = -UI.safe_bottom()
panel.offset_left = 0
panel.offset_right = 0
var style := StyleBoxFlat.new()
@@ -88,22 +87,34 @@ func _ready() -> void:
_add_hold_row(list)
list.add_child(UI.spacer(2))
var rules := UI.button("How to play", false, 46)
rules.add_theme_font_size_override("font_size", 16)
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)
restart_row = _action_row("Restart room", "Clear this room and start it again.", Palette.RED, _on_restart)
list.add_child(restart_row)
lobby_row = _action_row("Back to lobby", "Return to the hotel lobby.", Palette.MUTED, _on_lobby)
list.add_child(lobby_row)
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)
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
@@ -126,8 +137,7 @@ func _ready() -> void:
func open_sheet(mode: String) -> void:
game_mode = mode == "game"
restart_row.visible = game_mode
lobby_row.visible = game_mode
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"
@@ -145,15 +155,15 @@ func refresh() -> void:
func _add_pattern_row(parent: VBoxContainer) -> void:
var panel := UI.panel(Palette.PAPER, 16, 10)
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", 20, Palette.INK)
var icon := UI.icon("res://assets/icons/leaf.svg", 18, Palette.INK)
row.add_child(icon)
var label := UI.label("Room patterns", 16)
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)
@@ -167,20 +177,21 @@ func _add_pattern_row(parent: VBoxContainer) -> void:
func _add_toggle(parent: VBoxContainer, title: String, detail: String, key: String) -> void:
var panel := UI.panel(Palette.PAPER, 16, 10)
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, 15)
var label := UI.label(title, 14)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(label)
var sub := UI.label(detail, 11, Palette.MUTED)
var sub := UI.label(detail, 10, Palette.MUTED)
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(sub)
@@ -193,16 +204,16 @@ func _add_toggle(parent: VBoxContainer, title: String, detail: String, key: Stri
func _add_hold_row(parent: VBoxContainer) -> void:
var panel := UI.panel(Palette.PAPER, 16, 10)
var panel := UI.panel(Palette.PAPER, 14, 8)
var column := VBoxContainer.new()
column.add_theme_constant_override("separation", 4)
column.add_theme_constant_override("separation", 2)
panel.add_child(column)
var label := UI.label("Hold time", 15)
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.", 11, Palette.MUTED)
var sub := UI.label("How long to press before checking in.", 10, Palette.MUTED)
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
column.add_child(sub)
@@ -219,34 +230,35 @@ func _add_hold_row(parent: VBoxContainer) -> void:
hold_slider.value_changed.connect(_on_hold_changed)
row.add_child(hold_slider)
hold_value = UI.label("%.2f s" % hold_slider.value, 12, Palette.MUTED)
hold_value.custom_minimum_size = Vector2(50, 0)
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, 16, 10)
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, 15, color)
var label := UI.label(title, 14, color)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(label)
var sub := UI.label(detail, 11, Palette.MUTED)
var sub := UI.label(detail, 10, Palette.MUTED)
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(sub)
var go := UI.button("›", false, 36)
go.custom_minimum_size = Vector2(40, 36)
go.add_theme_font_size_override("font_size", 20)
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)
+10
View File
@@ -87,6 +87,8 @@ static func round_button(icon_path: String, size: int = 48) -> Button:
b.custom_minimum_size = Vector2(size, size)
b.icon = load(icon_path)
b.expand_icon = false
b.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
b.alignment = HORIZONTAL_ALIGNMENT_CENTER
b.add_theme_stylebox_override("normal", _round_style(Palette.PAPER))
b.add_theme_stylebox_override("hover", _round_style(Palette.PAPER.lightened(0.04)))
b.add_theme_stylebox_override("pressed", _round_style(Palette.PAPER.darkened(0.06)))
@@ -132,6 +134,14 @@ static func spacer(height: int = GAP) -> Control:
return c
static func safe_top() -> int:
return 30 if OS.has_feature("mobile") else 20
static func safe_bottom() -> int:
return 24 if OS.has_feature("mobile") else 14
static func _button_style(color: Color) -> StyleBoxFlat:
var s := StyleBoxFlat.new()
s.bg_color = color