v0.9.0-alpha local build. Adds per-guest story vignettes, a scrollable Guest Book story section, live text scaling, Android haptics, a difficulty picker with descriptions, six repeating cosmetic hotel events, and isolated free play using verified symmetry variants. Save format v7 with automatic migration. QA is 9/9 including the free-play uniqueness suite.
322 lines
11 KiB
GDScript
322 lines
11 KiB
GDScript
extends Control
|
||
|
||
signal play_pressed
|
||
signal guest_book_pressed
|
||
signal settings_pressed
|
||
signal rules_pressed
|
||
signal daily_pressed
|
||
signal profile_pressed
|
||
signal streak_pressed
|
||
signal freeplay_pressed
|
||
|
||
var progress_pill: Button
|
||
var primary: Button
|
||
var hint_label: Label
|
||
var mascot_caption: Label
|
||
var daily_button: Button
|
||
var freeplay_button: Button
|
||
var streak_button: Button
|
||
var event_button: Button
|
||
var event_layer: ColorRect
|
||
var event_title: Label
|
||
var event_body: Label
|
||
var event_progress: Label
|
||
var event_claim: Button
|
||
var mascot_card: PanelContainer
|
||
var mascot_art: Control
|
||
var avatar_holder: CenterContainer
|
||
var avatar_frame_id := ""
|
||
var avatar_portrait_id := ""
|
||
|
||
|
||
func _ready() -> void:
|
||
var margin := MarginContainer.new()
|
||
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", UI.safe_top())
|
||
margin.add_theme_constant_override("margin_bottom", UI.safe_bottom())
|
||
add_child(margin)
|
||
|
||
var column := VBoxContainer.new()
|
||
column.add_theme_constant_override("separation", 6)
|
||
margin.add_child(column)
|
||
|
||
var hub := HBoxContainer.new()
|
||
hub.add_theme_constant_override("separation", 0)
|
||
column.add_child(hub)
|
||
|
||
var left := CenterContainer.new()
|
||
left.custom_minimum_size = Vector2(56, 56)
|
||
avatar_holder = left
|
||
hub.add_child(left)
|
||
_build_avatar()
|
||
|
||
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)
|
||
UI.set_font_size(progress_pill, 13)
|
||
progress_pill.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||
progress_pill.pressed.connect(func() -> void: guest_book_pressed.emit())
|
||
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())
|
||
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))
|
||
column.add_child(UI.label("A cozy rat hotel puzzle", 15, Palette.MUTED))
|
||
|
||
event_button = UI.button("Hotel event", false, 34)
|
||
event_button.custom_minimum_size = Vector2(0, 34)
|
||
UI.set_font_size(event_button, 12)
|
||
event_button.clip_text = true
|
||
event_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
event_button.pressed.connect(_open_event)
|
||
column.add_child(event_button)
|
||
|
||
daily_button = UI.button("Daily room", false, 40)
|
||
daily_button.custom_minimum_size = Vector2(0, 40)
|
||
daily_button.clip_text = true
|
||
daily_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
UI.set_font_size(daily_button, 11)
|
||
daily_button.pressed.connect(func() -> void: daily_pressed.emit())
|
||
freeplay_button = UI.button("Free play", false, 40)
|
||
freeplay_button.custom_minimum_size = Vector2(0, 40)
|
||
freeplay_button.clip_text = true
|
||
freeplay_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
UI.set_font_size(freeplay_button, 11)
|
||
freeplay_button.pressed.connect(func() -> void: freeplay_pressed.emit())
|
||
streak_button = UI.button("Streak ›", false, 40)
|
||
streak_button.custom_minimum_size = Vector2(0, 40)
|
||
streak_button.clip_text = true
|
||
streak_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
UI.set_font_size(streak_button, 11)
|
||
streak_button.pressed.connect(func() -> void: streak_pressed.emit())
|
||
var daily_row := HBoxContainer.new()
|
||
daily_row.add_theme_constant_override("separation", 6)
|
||
daily_row.add_child(daily_button)
|
||
daily_row.add_child(freeplay_button)
|
||
daily_row.add_child(streak_button)
|
||
column.add_child(daily_row)
|
||
|
||
var top_space := Control.new()
|
||
top_space.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
top_space.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
column.add_child(top_space)
|
||
|
||
var card := UI.panel(Palette.CREAM, 26, 12)
|
||
mascot_card = card
|
||
card.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||
var mascot := _make_mascot()
|
||
mascot_art = mascot
|
||
card.add_child(mascot)
|
||
column.add_child(card)
|
||
_apply_mascot_scale()
|
||
|
||
mascot_caption = UI.label("Crumb, innkeeper", 12, Palette.MUTED)
|
||
column.add_child(mascot_caption)
|
||
hint_label = UI.label(UI.place_hint(), 11, Palette.MUTED)
|
||
column.add_child(hint_label)
|
||
|
||
var bottom_space := Control.new()
|
||
bottom_space.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||
bottom_space.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
column.add_child(bottom_space)
|
||
|
||
primary = UI.button("Check in", true, 54)
|
||
primary.custom_minimum_size = Vector2(300, 54)
|
||
primary.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||
primary.pressed.connect(func() -> void: play_pressed.emit())
|
||
column.add_child(primary)
|
||
|
||
var secondary := HBoxContainer.new()
|
||
secondary.alignment = BoxContainer.ALIGNMENT_CENTER
|
||
secondary.add_theme_constant_override("separation", 8)
|
||
column.add_child(secondary)
|
||
|
||
var book := UI.button("Guest Book", false, 46)
|
||
book.custom_minimum_size = Vector2(146, 46)
|
||
UI.set_font_size(book, 15)
|
||
book.pressed.connect(func() -> void: guest_book_pressed.emit())
|
||
secondary.add_child(book)
|
||
|
||
var rules := UI.button("House Rules", false, 46)
|
||
rules.custom_minimum_size = Vector2(146, 46)
|
||
UI.set_font_size(rules, 15)
|
||
rules.pressed.connect(func() -> void: rules_pressed.emit())
|
||
secondary.add_child(rules)
|
||
|
||
column.add_child(UI.label("No ads. No lives. Just rats.", 10, Palette.MUTED))
|
||
column.add_child(UI.label(Version.BUILD_LABEL, 9, Palette.MUTED))
|
||
|
||
_build_event_layer()
|
||
SaveGame.progress_changed.connect(refresh)
|
||
SaveGame.settings_changed.connect(refresh)
|
||
refresh()
|
||
|
||
|
||
func _apply_mascot_scale() -> void:
|
||
if mascot_card == null or mascot_art == null:
|
||
return
|
||
var scale := UI.ui_scale()
|
||
var card_size := int(160 / scale)
|
||
var art_size := int(138 / scale)
|
||
mascot_card.custom_minimum_size = Vector2(card_size, card_size)
|
||
mascot_art.custom_minimum_size = Vector2(art_size, art_size)
|
||
|
||
|
||
func _build_event_layer() -> void:
|
||
event_layer = ColorRect.new()
|
||
event_layer.color = Color(0.18, 0.12, 0.08, 0.62)
|
||
event_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
event_layer.mouse_filter = Control.MOUSE_FILTER_STOP
|
||
event_layer.gui_input.connect(func(event: InputEvent) -> void:
|
||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||
event_layer.visible = false
|
||
)
|
||
event_layer.visible = false
|
||
add_child(event_layer)
|
||
|
||
var center := CenterContainer.new()
|
||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
event_layer.add_child(center)
|
||
var panel := UI.panel(Palette.CREAM, 24, 16)
|
||
panel.custom_minimum_size = Vector2(min(340, max(280, int(get_viewport_rect().size.x) - 32)), 0)
|
||
center.add_child(panel)
|
||
var box := VBoxContainer.new()
|
||
box.add_theme_constant_override("separation", 8)
|
||
panel.add_child(box)
|
||
|
||
event_title = UI.heading("Hotel event", 20)
|
||
box.add_child(event_title)
|
||
event_body = UI.label("", 12)
|
||
event_body.custom_minimum_size = Vector2(0, 90)
|
||
box.add_child(event_body)
|
||
event_progress = UI.label("", 11, Palette.MUTED)
|
||
box.add_child(event_progress)
|
||
event_claim = UI.button("Claim gift", true, 44)
|
||
event_claim.pressed.connect(_claim_event)
|
||
box.add_child(event_claim)
|
||
var close := UI.button("Close", false, 44)
|
||
close.pressed.connect(func() -> void: event_layer.visible = false)
|
||
box.add_child(close)
|
||
|
||
|
||
func _open_event() -> void:
|
||
var event := SaveGame.current_event()
|
||
if event.is_empty():
|
||
return
|
||
var id := str(event.get("id", ""))
|
||
var guest := Guests.by_id(str(event.get("featured_guest", "")))
|
||
event_title.text = str(event.get("name", "Hotel event"))
|
||
event_body.text = "%s\n\nFeatured guest: %s" % [str(event.get("description", "")), str(guest.get("name", "Crumb"))]
|
||
var progress := SaveGame.event_progress(id)
|
||
event_progress.text = "Daily rooms during this visit: %d / 3" % progress
|
||
var claimed := SaveGame.event_claimed(id)
|
||
event_claim.text = "Gift claimed" if claimed else ("Claim: %s" % str(event.get("gift", "Treat")))
|
||
event_claim.disabled = claimed or not SaveGame.event_claimable(id)
|
||
event_layer.visible = true
|
||
event_layer.move_to_front()
|
||
|
||
|
||
func _claim_event() -> void:
|
||
var id := str(SaveGame.current_event().get("id", ""))
|
||
if SaveGame.claim_event(id):
|
||
event_claim.text = "Gift claimed"
|
||
event_claim.disabled = true
|
||
refresh()
|
||
|
||
|
||
func refresh() -> void:
|
||
hint_label.text = UI.place_hint()
|
||
_apply_mascot_scale()
|
||
var avatar_id := SaveGame.selected_avatar()
|
||
if avatar_id == "crumb":
|
||
mascot_caption.text = "Crumb, innkeeper"
|
||
else:
|
||
var guest := Guests.by_id(avatar_id)
|
||
mascot_caption.text = "%s · %s" % [
|
||
str(guest.get("name", avatar_id)),
|
||
str(guest.get("role", "Guest"))
|
||
]
|
||
daily_button.text = _daily_text()
|
||
var event := SaveGame.current_event()
|
||
if event.is_empty():
|
||
event_button.text = "Hotel event"
|
||
else:
|
||
var id := str(event.get("id", ""))
|
||
var progress := SaveGame.event_progress(id)
|
||
var state := "Gift ready" if SaveGame.event_claimable(id) else (
|
||
"Gift claimed" if SaveGame.event_claimed(id) else "%d/3 daily rooms" % progress
|
||
)
|
||
event_button.text = "%s · %s" % [str(event.get("name", "Event")), state]
|
||
_refresh_avatar()
|
||
var guests := Guests.all()
|
||
var unlocked := SaveGame.unlocked_count(guests)
|
||
progress_pill.text = "%d / %d guests" % [unlocked, guests.size()]
|
||
|
||
var last := int(SaveGame.data.get("last_room", 0))
|
||
if last <= 0:
|
||
primary.text = "Check in"
|
||
elif last >= 30:
|
||
primary.text = "Replay Room 30"
|
||
else:
|
||
primary.text = "Continue Room %d" % (last + 1)
|
||
|
||
|
||
func _daily_text() -> String:
|
||
var streak := SaveGame.daily_streak()
|
||
if SaveGame.daily_completed_today():
|
||
return "Daily done · %d-day streak" % streak
|
||
if streak > 0:
|
||
return "Daily room · %d-day streak" % streak
|
||
return "Daily room · start a streak"
|
||
|
||
|
||
func _build_avatar() -> void:
|
||
var frame := Frames.frame_panel(SaveGame.selected_frame(), 56)
|
||
var avatar := Button.new()
|
||
avatar.custom_minimum_size = Vector2(44, 44)
|
||
avatar.flat = true
|
||
avatar.icon = load(Avatars.head_path(SaveGame.selected_avatar()))
|
||
avatar.expand_icon = true
|
||
avatar.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
avatar.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
avatar.tooltip_text = "Profile"
|
||
avatar.pressed.connect(func() -> void: profile_pressed.emit())
|
||
frame.add_child(avatar)
|
||
avatar_holder.add_child(frame)
|
||
avatar_frame_id = SaveGame.selected_frame()
|
||
avatar_portrait_id = SaveGame.selected_avatar()
|
||
|
||
|
||
func _refresh_avatar() -> void:
|
||
if (
|
||
avatar_frame_id == SaveGame.selected_frame()
|
||
and avatar_portrait_id == SaveGame.selected_avatar()
|
||
):
|
||
return
|
||
for child in avatar_holder.get_children():
|
||
child.queue_free()
|
||
_build_avatar()
|
||
|
||
|
||
func _make_mascot() -> Control:
|
||
if ResourceLoader.exists("res://art/crumb.png"):
|
||
var texture_rect := TextureRect.new()
|
||
texture_rect.texture = load("res://art/crumb.png")
|
||
texture_rect.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||
texture_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||
return texture_rect
|
||
return RatPortrait.new()
|