Port the project to a 360x640 canvas with the redesigned lobby, settings sheet, and refreshed UI.
251 lines
8.5 KiB
GDScript
251 lines
8.5 KiB
GDScript
extends Control
|
|
|
|
signal back_pressed
|
|
|
|
var grid: GridContainer
|
|
var progress_label: Label
|
|
var status_label: Label
|
|
var detail_layer: ColorRect
|
|
var detail_portrait: TextureRect
|
|
var detail_name: Label
|
|
var detail_role: Label
|
|
var detail_meta: Label
|
|
var detail_bio: Label
|
|
var detail_snack: Label
|
|
var detail_status: Label
|
|
|
|
|
|
func _ready() -> void:
|
|
var margin := MarginContainer.new()
|
|
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)
|
|
add_child(margin)
|
|
|
|
var column := VBoxContainer.new()
|
|
column.add_theme_constant_override("separation", 6)
|
|
margin.add_child(column)
|
|
|
|
var top := HBoxContainer.new()
|
|
top.add_theme_constant_override("separation", 6)
|
|
column.add_child(top)
|
|
|
|
var back := UI.round_button("res://assets/icons/arrow-left.svg", 40)
|
|
back.pressed.connect(func() -> void: back_pressed.emit())
|
|
top.add_child(back)
|
|
|
|
var title := UI.label("The Guest Book", 22)
|
|
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
|
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
top.add_child(title)
|
|
|
|
progress_label = UI.label("5 of 25", 10, Palette.MUTED)
|
|
progress_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
|
progress_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
|
progress_label.custom_minimum_size = Vector2(70, 0)
|
|
top.add_child(progress_label)
|
|
|
|
column.add_child(_make_crumb_card())
|
|
|
|
status_label = UI.label("Tap a guest to read their card.", 10, Palette.MUTED)
|
|
status_label.custom_minimum_size = Vector2(0, 20)
|
|
column.add_child(status_label)
|
|
|
|
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)
|
|
|
|
grid = GridContainer.new()
|
|
grid.columns = 3
|
|
grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
grid.add_theme_constant_override("h_separation", 5)
|
|
grid.add_theme_constant_override("v_separation", 5)
|
|
scroll.add_child(grid)
|
|
|
|
_build_detail()
|
|
|
|
SaveGame.progress_changed.connect(refresh)
|
|
refresh()
|
|
|
|
|
|
func _make_crumb_card() -> PanelContainer:
|
|
var panel := UI.panel(Palette.PAPER, 14, 8)
|
|
var row := HBoxContainer.new()
|
|
row.add_theme_constant_override("separation", 8)
|
|
panel.add_child(row)
|
|
|
|
var portrait := TextureRect.new()
|
|
portrait.custom_minimum_size = Vector2(50, 50)
|
|
portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
if ResourceLoader.exists("res://art/crumb_head.png"):
|
|
portrait.texture = load("res://art/crumb_head.png")
|
|
row.add_child(portrait)
|
|
|
|
var text := VBoxContainer.new()
|
|
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
text.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
text.add_theme_constant_override("separation", 0)
|
|
row.add_child(text)
|
|
|
|
var name := UI.label("Crumb", 16)
|
|
name.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
|
text.add_child(name)
|
|
|
|
var role := UI.label("Innkeeper · always in", 10, Palette.MUTED)
|
|
role.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
|
text.add_child(role)
|
|
|
|
return panel
|
|
|
|
|
|
func refresh() -> void:
|
|
if grid == null:
|
|
return
|
|
for child in grid.get_children():
|
|
child.free()
|
|
|
|
var guests := Guests.all()
|
|
var unlocked := SaveGame.unlocked_count(guests)
|
|
progress_label.text = "%d/%d" % [unlocked, guests.size()]
|
|
|
|
for guest in guests:
|
|
grid.add_child(_make_card(guest))
|
|
|
|
|
|
func _make_card(guest: Dictionary) -> PanelContainer:
|
|
var id := str(guest["id"])
|
|
var locked := not SaveGame.is_guest_unlocked(id)
|
|
var accent := Color(str(guest.get("accent", "#8c7460")))
|
|
|
|
var panel := UI.panel(Palette.PAPER, 12, 5)
|
|
panel.custom_minimum_size = Vector2(105, 148)
|
|
panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
panel.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
|
panel.gui_input.connect(_on_card_input.bind(guest, locked))
|
|
|
|
var box := VBoxContainer.new()
|
|
box.add_theme_constant_override("separation", 1)
|
|
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
panel.add_child(box)
|
|
|
|
var portrait := Control.new()
|
|
portrait.custom_minimum_size = Vector2(94, 96)
|
|
portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
box.add_child(portrait)
|
|
|
|
var texture := TextureRect.new()
|
|
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
texture.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
texture.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
texture.texture = load(Guests.portrait(id, "thumbs"))
|
|
portrait.add_child(texture)
|
|
|
|
if locked:
|
|
texture.modulate = Color(1, 1, 1, 0.18)
|
|
var veil := ColorRect.new()
|
|
veil.color = Color(0.98, 0.93, 0.84, 0.78)
|
|
veil.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
veil.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
portrait.add_child(veil)
|
|
|
|
var mystery := UI.label("???", 22, Palette.INK)
|
|
mystery.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
mystery.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
|
mystery.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
portrait.add_child(mystery)
|
|
|
|
var name_label := UI.label("???" if locked else str(guest["name"]), 12)
|
|
name_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
box.add_child(name_label)
|
|
|
|
var role_text := "Room %d" % int(guest.get("unlock_room", 0)) if locked else str(guest["role"])
|
|
var role_label := UI.label(role_text, 9, Palette.MUTED if locked else accent)
|
|
role_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
box.add_child(role_label)
|
|
|
|
return panel
|
|
|
|
|
|
func _on_card_input(event: InputEvent, guest: Dictionary, locked: bool) -> void:
|
|
if not (event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT):
|
|
return
|
|
if locked:
|
|
var room := int(guest.get("unlock_room", 0))
|
|
status_label.text = "Check in a guest from Room %d to meet them." % room
|
|
status_label.add_theme_color_override("font_color", Palette.RED)
|
|
else:
|
|
status_label.text = "Tap a guest to read their card."
|
|
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
|
_show_detail(guest)
|
|
|
|
|
|
func _build_detail() -> void:
|
|
detail_layer = ColorRect.new()
|
|
detail_layer.color = Color(0.18, 0.12, 0.08, 0.52)
|
|
detail_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
detail_layer.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
detail_layer.visible = false
|
|
add_child(detail_layer)
|
|
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
detail_layer.add_child(center)
|
|
|
|
var panel := UI.panel(Palette.CREAM, 24, 16)
|
|
panel.custom_minimum_size = Vector2(320, 0)
|
|
center.add_child(panel)
|
|
|
|
var box := VBoxContainer.new()
|
|
box.add_theme_constant_override("separation", 4)
|
|
panel.add_child(box)
|
|
|
|
detail_portrait = TextureRect.new()
|
|
detail_portrait.custom_minimum_size = Vector2(180, 180)
|
|
detail_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
detail_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
box.add_child(detail_portrait)
|
|
|
|
detail_name = UI.heading("Name", 22)
|
|
box.add_child(detail_name)
|
|
detail_role = UI.label("Role", 13, Palette.MUTED)
|
|
box.add_child(detail_role)
|
|
detail_meta = UI.label("Variety", 11, Palette.MUTED)
|
|
box.add_child(detail_meta)
|
|
|
|
detail_bio = UI.label("", 12)
|
|
detail_bio.custom_minimum_size = Vector2(0, 38)
|
|
box.add_child(detail_bio)
|
|
|
|
detail_snack = UI.label("", 11, Palette.MUTED)
|
|
box.add_child(detail_snack)
|
|
detail_status = UI.label("", 10, Palette.MUTED)
|
|
box.add_child(detail_status)
|
|
|
|
var close := UI.button("Close", false, 44)
|
|
close.add_theme_font_size_override("font_size", 16)
|
|
close.pressed.connect(func() -> void: detail_layer.visible = false)
|
|
box.add_child(close)
|
|
|
|
|
|
func _show_detail(guest: Dictionary) -> void:
|
|
var id := str(guest["id"])
|
|
var accent := Color(str(guest.get("accent", "#8c7460")))
|
|
detail_portrait.texture = load(Guests.portrait(id, "cards"))
|
|
detail_name.text = str(guest["name"])
|
|
detail_role.text = "%s · %s" % [str(guest["role"]), str(guest.get("pronouns", ""))]
|
|
detail_role.add_theme_color_override("font_color", accent)
|
|
detail_meta.text = "%s coat · %s" % [str(guest.get("variety", "")), str(guest.get("coat", ""))]
|
|
detail_bio.text = str(guest.get("personality", ""))
|
|
detail_snack.text = "Favourite snack: %s" % str(guest.get("snack", ""))
|
|
detail_status.text = "Checked in · Room %d" % int(guest.get("unlock_room", 0))
|
|
if int(guest.get("unlock_room", 0)) == 0:
|
|
detail_status.text = "Resident · always in"
|
|
detail_layer.visible = true
|