WIP: 360dp lobby redesign
Port the project to a 360x640 canvas with the redesigned lobby, settings sheet, and refreshed UI.
This commit is contained in:
1 parent
f6fd807e9a
commit
46b5764144
34 files changed
+1299
-261
No files matched your search
+176
-62
@@ -2,9 +2,10 @@ extends Control
|
||||
|
||||
signal back_pressed
|
||||
signal guest_book_pressed
|
||||
signal settings_pressed
|
||||
|
||||
const BoardScene = preload("res://scenes/Board.tscn")
|
||||
const DEFAULT_STATUS := "One guest per room, floor and corridor.\nTap = X · Hold or right-click = check in."
|
||||
const DEFAULT_STATUS := "One guest per room, row and column."
|
||||
|
||||
var levels: Array = []
|
||||
var level_index := 0
|
||||
@@ -12,13 +13,18 @@ var started_at := 0
|
||||
var elapsed_ms := 0
|
||||
var win_shown := false
|
||||
var current_level_id := ""
|
||||
var ui_paused := false
|
||||
|
||||
var board: Board
|
||||
var level_label: Label
|
||||
var guest_label: Label
|
||||
var timer_label: Label
|
||||
var status_label: Label
|
||||
var win_detail: Label
|
||||
var overlay: ColorRect
|
||||
var rule_strip: HBoxContainer
|
||||
var legend_row: HBoxContainer
|
||||
var legend_chips: Array = []
|
||||
var new_guest_box: HBoxContainer
|
||||
var new_guest_label: Label
|
||||
var new_guest_portrait: TextureRect
|
||||
@@ -33,40 +39,66 @@ func _ready() -> void:
|
||||
func _build_ui() -> void:
|
||||
var margin := MarginContainer.new()
|
||||
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
margin.add_theme_constant_override("margin_left", 20)
|
||||
margin.add_theme_constant_override("margin_right", 20)
|
||||
margin.add_theme_constant_override("margin_top", 18)
|
||||
margin.add_theme_constant_override("margin_bottom", 18)
|
||||
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)
|
||||
add_child(margin)
|
||||
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 10)
|
||||
column.add_theme_constant_override("separation", 6)
|
||||
margin.add_child(column)
|
||||
|
||||
# Top bar
|
||||
var top := HBoxContainer.new()
|
||||
top.add_theme_constant_override("separation", 10)
|
||||
top.add_theme_constant_override("separation", 8)
|
||||
column.add_child(top)
|
||||
|
||||
var back := UI.button("‹", false, 44)
|
||||
back.custom_minimum_size = Vector2(48, 44)
|
||||
back.add_theme_font_size_override("font_size", 30)
|
||||
var back := UI.round_button("res://assets/icons/arrow-left.svg", 44)
|
||||
back.pressed.connect(_on_back)
|
||||
top.add_child(back)
|
||||
|
||||
level_label = UI.label("Room 1", 20, Palette.MUTED)
|
||||
level_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
level_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
top.add_child(level_label)
|
||||
var center := VBoxContainer.new()
|
||||
center.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
center.add_theme_constant_override("separation", 0)
|
||||
top.add_child(center)
|
||||
|
||||
timer_label = UI.label("00:00", 18, Palette.MUTED)
|
||||
timer_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
timer_label.custom_minimum_size = Vector2(72, 0)
|
||||
top.add_child(timer_label)
|
||||
level_label = UI.label("Room 1", 18)
|
||||
center.add_child(level_label)
|
||||
|
||||
var sub := HBoxContainer.new()
|
||||
sub.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
sub.add_theme_constant_override("separation", 8)
|
||||
center.add_child(sub)
|
||||
|
||||
guest_label = UI.label("0 / 8", 11, Palette.MUTED)
|
||||
sub.add_child(guest_label)
|
||||
|
||||
timer_label = UI.label("00:00", 11, Palette.MUTED)
|
||||
sub.add_child(timer_label)
|
||||
|
||||
var gear := UI.round_button("res://assets/icons/settings.svg", 44)
|
||||
gear.pressed.connect(func() -> void: settings_pressed.emit())
|
||||
top.add_child(gear)
|
||||
|
||||
# Rule chips, first three rooms
|
||||
rule_strip = HBoxContainer.new()
|
||||
rule_strip.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
rule_strip.add_theme_constant_override("separation", 4)
|
||||
column.add_child(rule_strip)
|
||||
rule_strip.add_child(_rule_chip("1 per room", "region"))
|
||||
rule_strip.add_child(_rule_chip("1 per row/col", "row"))
|
||||
rule_strip.add_child(_rule_chip("No touching", "touch"))
|
||||
|
||||
# Room legend: one guest per colour
|
||||
legend_row = HBoxContainer.new()
|
||||
legend_row.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
legend_row.add_theme_constant_override("separation", 3)
|
||||
column.add_child(legend_row)
|
||||
|
||||
# Board
|
||||
board = BoardScene.instantiate() as Board
|
||||
board.custom_minimum_size = Vector2(320, 320)
|
||||
board.custom_minimum_size = Vector2(300, 300)
|
||||
board.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
board.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
board.changed.connect(_on_board_changed)
|
||||
@@ -75,34 +107,50 @@ func _build_ui() -> void:
|
||||
column.add_child(board)
|
||||
|
||||
# Status
|
||||
status_label = UI.label(DEFAULT_STATUS, 17, Palette.MUTED)
|
||||
status_label.custom_minimum_size = Vector2(0, 56)
|
||||
status_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
status_label = UI.label(DEFAULT_STATUS, 12, Palette.MUTED)
|
||||
status_label.custom_minimum_size = Vector2(0, 26)
|
||||
column.add_child(status_label)
|
||||
|
||||
# Bottom actions
|
||||
# Actions
|
||||
var actions := HBoxContainer.new()
|
||||
actions.add_theme_constant_override("separation", 8)
|
||||
column.add_child(actions)
|
||||
|
||||
var undo := UI.button("Undo", false, 52)
|
||||
var undo := UI.button("Undo", false, 48)
|
||||
undo.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
undo.add_theme_font_size_override("font_size", 17)
|
||||
undo.pressed.connect(_on_undo)
|
||||
actions.add_child(undo)
|
||||
|
||||
var restart := UI.button("Restart", false, 52)
|
||||
restart.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
restart.pressed.connect(_on_restart)
|
||||
actions.add_child(restart)
|
||||
|
||||
var hint := UI.button("Hint", true, 52)
|
||||
var hint := UI.button("Hint", true, 48)
|
||||
hint.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hint.add_theme_font_size_override("font_size", 17)
|
||||
hint.pressed.connect(_on_hint)
|
||||
actions.add_child(hint)
|
||||
|
||||
_build_win_overlay()
|
||||
|
||||
|
||||
func _rule_chip(text: String, mode: String) -> PanelContainer:
|
||||
var panel := UI.panel(Palette.PAPER, 12, 5)
|
||||
panel.custom_minimum_size = Vector2(102, 42)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 3)
|
||||
panel.add_child(row)
|
||||
|
||||
var diagram := MiniDiagram.new()
|
||||
diagram.mode = mode
|
||||
diagram.custom_minimum_size = Vector2(30, 30)
|
||||
row.add_child(diagram)
|
||||
|
||||
var label := UI.label(text, 9, Palette.MUTED)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
label.custom_minimum_size = Vector2(58, 0)
|
||||
row.add_child(label)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func _build_win_overlay() -> void:
|
||||
overlay = ColorRect.new()
|
||||
overlay.color = Color(0.18, 0.12, 0.08, 0.48)
|
||||
@@ -115,48 +163,49 @@ func _build_win_overlay() -> void:
|
||||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
overlay.add_child(center)
|
||||
|
||||
var panel := UI.panel(Palette.CREAM, 34, 28)
|
||||
panel.custom_minimum_size = Vector2(420, 0)
|
||||
var panel := UI.panel(Palette.CREAM, 26, 18)
|
||||
panel.custom_minimum_size = Vector2(320, 0)
|
||||
center.add_child(panel)
|
||||
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 10)
|
||||
box.add_theme_constant_override("separation", 6)
|
||||
panel.add_child(box)
|
||||
|
||||
var portrait_center := CenterContainer.new()
|
||||
box.add_child(portrait_center)
|
||||
var portrait := _make_win_portrait()
|
||||
portrait.custom_minimum_size = Vector2(170, 170)
|
||||
portrait.custom_minimum_size = Vector2(110, 110)
|
||||
portrait_center.add_child(portrait)
|
||||
|
||||
box.add_child(UI.label("Everyone checked in!", 34))
|
||||
win_detail = UI.label("Room 1 · 00:00", 18, Palette.MUTED)
|
||||
box.add_child(UI.heading("Everyone checked in!", 26))
|
||||
win_detail = UI.label("Room 1 · 00:00", 13, Palette.MUTED)
|
||||
box.add_child(win_detail)
|
||||
box.add_child(UI.label("Sweet dreams, little guests.", 18, Palette.MUTED))
|
||||
box.add_child(UI.label("Sweet dreams, little guests.", 12, Palette.MUTED))
|
||||
|
||||
new_guest_box = HBoxContainer.new()
|
||||
new_guest_box.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
new_guest_box.add_theme_constant_override("separation", 8)
|
||||
new_guest_box.add_theme_constant_override("separation", 6)
|
||||
new_guest_box.visible = false
|
||||
box.add_child(new_guest_box)
|
||||
|
||||
new_guest_portrait = TextureRect.new()
|
||||
new_guest_portrait.custom_minimum_size = Vector2(64, 64)
|
||||
new_guest_portrait.custom_minimum_size = Vector2(42, 42)
|
||||
new_guest_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
new_guest_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
new_guest_box.add_child(new_guest_portrait)
|
||||
|
||||
new_guest_label = UI.label("", 14, Palette.INK)
|
||||
new_guest_label.custom_minimum_size = Vector2(250, 0)
|
||||
new_guest_label = UI.label("", 11, Palette.INK)
|
||||
new_guest_label.custom_minimum_size = Vector2(190, 0)
|
||||
new_guest_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
new_guest_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
new_guest_box.add_child(new_guest_label)
|
||||
|
||||
var next := UI.button("Next room", true, 56)
|
||||
var next := UI.button("Next room", true, 48)
|
||||
next.add_theme_font_size_override("font_size", 17)
|
||||
box.add_child(next)
|
||||
next.pressed.connect(_on_next)
|
||||
|
||||
var book := UI.button("Guest Book", false, 46)
|
||||
var book := UI.button("Guest Book", false, 42)
|
||||
book.add_theme_font_size_override("font_size", 15)
|
||||
box.add_child(book)
|
||||
book.pressed.connect(func() -> void: guest_book_pressed.emit())
|
||||
|
||||
@@ -173,7 +222,7 @@ func _make_win_portrait() -> Control:
|
||||
|
||||
func start_level(index: int) -> void:
|
||||
if levels.is_empty():
|
||||
status_label.text = "No rooms yet — run tools/generate_levels.gd in Godot."
|
||||
status_label.text = "No rooms yet."
|
||||
status_label.add_theme_color_override("font_color", Palette.RED)
|
||||
return
|
||||
|
||||
@@ -182,22 +231,84 @@ func start_level(index: int) -> void:
|
||||
current_level_id = str(level.get("id", ""))
|
||||
board.set_level(level)
|
||||
|
||||
level_label.text = "Room %d of %d" % [level_index + 1, levels.size()]
|
||||
level_label.text = "Room %d" % (level_index + 1)
|
||||
started_at = Time.get_ticks_msec()
|
||||
elapsed_ms = 0
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
new_guest_box.visible = false
|
||||
if level.get("clues", []).size() > 0:
|
||||
status_label.text = "Gold-ringed guests are already checked in.\nTap = X · Hold or right-click = check in."
|
||||
else:
|
||||
status_label.text = DEFAULT_STATUS
|
||||
rule_strip.visible = level_index < 3
|
||||
status_label.text = "Gold rings are already in." if level.get("clues", []).size() > 0 else DEFAULT_STATUS
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
_refresh_legend()
|
||||
_update_guest_count()
|
||||
|
||||
|
||||
func _refresh_legend() -> void:
|
||||
for child in legend_row.get_children():
|
||||
child.free()
|
||||
legend_chips.clear()
|
||||
if board.region_rats.is_empty():
|
||||
return
|
||||
|
||||
for region in range(board.n):
|
||||
var id := str(board.region_rats[region])
|
||||
var color: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
|
||||
var chip := PanelContainer.new()
|
||||
chip.custom_minimum_size = Vector2(32, 32)
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = color
|
||||
style.corner_radius_top_left = 9
|
||||
style.corner_radius_top_right = 9
|
||||
style.corner_radius_bottom_left = 9
|
||||
style.corner_radius_bottom_right = 9
|
||||
style.border_width_left = 1
|
||||
style.border_width_right = 1
|
||||
style.border_width_top = 1
|
||||
style.border_width_bottom = 1
|
||||
style.border_color = Color(1, 1, 1, 0.55)
|
||||
chip.add_theme_stylebox_override("panel", style)
|
||||
chip.tooltip_text = str(Guests.by_id(id).get("name", id))
|
||||
legend_row.add_child(chip)
|
||||
|
||||
var texture := TextureRect.new()
|
||||
texture.texture = board.region_textures.get(region)
|
||||
texture.custom_minimum_size = Vector2(28, 28)
|
||||
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
texture.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
chip.add_child(texture)
|
||||
|
||||
legend_chips.append(chip)
|
||||
|
||||
|
||||
func _update_legend() -> void:
|
||||
for region in range(legend_chips.size()):
|
||||
var chip := legend_chips[region]
|
||||
var solved := false
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
if int(board.cells[r][c]) == Board.RAT and int(board.regions[r][c]) == region:
|
||||
solved = true
|
||||
break
|
||||
if solved:
|
||||
break
|
||||
var style: StyleBoxFlat = chip.get_theme_stylebox("panel")
|
||||
if style != null:
|
||||
style.border_color = Palette.GOLD if solved else Color(1, 1, 1, 0.55)
|
||||
style.border_width_left = 3 if solved else 1
|
||||
style.border_width_right = 3 if solved else 1
|
||||
style.border_width_top = 3 if solved else 1
|
||||
style.border_width_bottom = 3 if solved else 1
|
||||
|
||||
|
||||
func _update_guest_count() -> void:
|
||||
guest_label.text = "%d / %d guests" % [Rules.count_rats(board.cells), board.n]
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
timer_label.visible = bool(SaveGame.get_setting("show_timer"))
|
||||
if not visible or win_shown or started_at == 0:
|
||||
if ui_paused or not visible or win_shown or started_at == 0:
|
||||
return
|
||||
elapsed_ms = Time.get_ticks_msec() - started_at
|
||||
timer_label.text = _format_time(elapsed_ms)
|
||||
@@ -210,15 +321,25 @@ func _format_time(ms: int) -> String:
|
||||
return "%02d:%02d" % [minutes, seconds]
|
||||
|
||||
|
||||
func set_ui_paused(value: bool) -> void:
|
||||
ui_paused = value
|
||||
|
||||
|
||||
func restart_room() -> void:
|
||||
start_level(level_index)
|
||||
|
||||
|
||||
func _on_board_changed() -> void:
|
||||
if win_shown:
|
||||
return
|
||||
status_label.text = DEFAULT_STATUS
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
_update_guest_count()
|
||||
_update_legend()
|
||||
|
||||
|
||||
func _on_mistake() -> void:
|
||||
status_label.text = "That room's already taken — undo or try another."
|
||||
status_label.text = "That room's taken — undo or try again."
|
||||
status_label.add_theme_color_override("font_color", Palette.RED)
|
||||
|
||||
|
||||
@@ -229,6 +350,7 @@ func _on_solved() -> void:
|
||||
status_label.text = "Everyone checked in."
|
||||
status_label.add_theme_color_override("font_color", Palette.INK)
|
||||
win_detail.text = "Room %d · %s" % [level_index + 1, _format_time(elapsed_ms)]
|
||||
_update_legend()
|
||||
|
||||
var unlocked_id := SaveGame.complete_room(current_level_id, level_index + 1)
|
||||
if unlocked_id != "":
|
||||
@@ -250,22 +372,14 @@ func _on_undo() -> void:
|
||||
board.undo()
|
||||
|
||||
|
||||
func _on_restart() -> void:
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
started_at = Time.get_ticks_msec()
|
||||
elapsed_ms = 0
|
||||
board.restart()
|
||||
|
||||
|
||||
func _on_hint() -> void:
|
||||
if board.hint():
|
||||
if not win_shown:
|
||||
status_label.text = "Crumb found a guest who was waiting."
|
||||
status_label.text = "Crumb found a guest."
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
else:
|
||||
if not win_shown:
|
||||
status_label.text = "Every guest is already checked in."
|
||||
status_label.text = "Everyone is already checked in."
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user