Adds the Guest Book, Settings, House Rules, and guest unlocks on the 20-room board. Rats still use the shared Crumb token.
255 lines
8.6 KiB
GDScript
255 lines
8.6 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", 20)
|
||
margin.add_theme_constant_override("margin_right", 20)
|
||
margin.add_theme_constant_override("margin_top", 16)
|
||
margin.add_theme_constant_override("margin_bottom", 16)
|
||
add_child(margin)
|
||
|
||
var column := VBoxContainer.new()
|
||
column.add_theme_constant_override("separation", 10)
|
||
margin.add_child(column)
|
||
|
||
var top := HBoxContainer.new()
|
||
top.add_theme_constant_override("separation", 10)
|
||
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)
|
||
back.pressed.connect(func() -> void: back_pressed.emit())
|
||
top.add_child(back)
|
||
|
||
var title := UI.label("The Guest Book", 30)
|
||
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 checked in", 15, Palette.MUTED)
|
||
progress_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||
progress_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||
progress_label.custom_minimum_size = Vector2(150, 0)
|
||
progress_label.size_flags_horizontal = Control.SIZE_SHRINK_END
|
||
top.add_child(progress_label)
|
||
|
||
var crumb := _make_crumb_card()
|
||
column.add_child(crumb)
|
||
|
||
status_label = UI.label("Tap a guest to read their card.", 14, Palette.MUTED)
|
||
status_label.custom_minimum_size = Vector2(0, 28)
|
||
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", 8)
|
||
grid.add_theme_constant_override("v_separation", 8)
|
||
scroll.add_child(grid)
|
||
|
||
_build_detail()
|
||
|
||
SaveGame.progress_changed.connect(refresh)
|
||
refresh()
|
||
|
||
|
||
func _make_crumb_card() -> PanelContainer:
|
||
var panel := UI.panel(Palette.PAPER, 20, 12)
|
||
var row := HBoxContainer.new()
|
||
row.add_theme_constant_override("separation", 12)
|
||
panel.add_child(row)
|
||
|
||
var portrait := TextureRect.new()
|
||
portrait.custom_minimum_size = Vector2(86, 86)
|
||
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")
|
||
elif ResourceLoader.exists("res://art/crumb.png"):
|
||
portrait.texture = load("res://art/crumb.png")
|
||
row.add_child(portrait)
|
||
|
||
var text := VBoxContainer.new()
|
||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
text.alignment = BoxContainer.ALIGNMENT_CENTER
|
||
row.add_child(text)
|
||
|
||
var name := UI.label("Crumb", 22)
|
||
name.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||
text.add_child(name)
|
||
|
||
var role := UI.label("Innkeeper · always in", 14, 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 of %d checked in" % [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, 18, 8)
|
||
panel.custom_minimum_size = Vector2(188, 224)
|
||
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", 2)
|
||
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
panel.add_child(box)
|
||
|
||
var portrait := Control.new()
|
||
portrait.custom_minimum_size = Vector2(170, 170)
|
||
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.0, 1.0, 1.0, 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("???", 34, 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"]), 17)
|
||
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, 13, 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, 32, 24)
|
||
panel.custom_minimum_size = Vector2(420, 0)
|
||
center.add_child(panel)
|
||
|
||
var box := VBoxContainer.new()
|
||
box.add_theme_constant_override("separation", 8)
|
||
panel.add_child(box)
|
||
|
||
detail_portrait = TextureRect.new()
|
||
detail_portrait.custom_minimum_size = Vector2(300, 300)
|
||
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.label("Name", 30)
|
||
box.add_child(detail_name)
|
||
detail_role = UI.label("Role", 18, Palette.MUTED)
|
||
box.add_child(detail_role)
|
||
detail_meta = UI.label("Variety", 15, Palette.MUTED)
|
||
box.add_child(detail_meta)
|
||
|
||
detail_bio = UI.label("", 17)
|
||
detail_bio.custom_minimum_size = Vector2(0, 52)
|
||
box.add_child(detail_bio)
|
||
|
||
detail_snack = UI.label("", 15, Palette.MUTED)
|
||
box.add_child(detail_snack)
|
||
detail_status = UI.label("", 14, Palette.MUTED)
|
||
box.add_child(detail_status)
|
||
|
||
var close := UI.button("Close", false, 50)
|
||
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
|