feat: guest-of-day mascot and Windows export preset
The Home mascot now features a deterministic guest of the day, tap-cycles unlocked guests with a story teaser, and scales cleanly at large text sizes. Screens stay centered at 360dp on wide aspect ratios. Adds a Windows Desktop export preset.
This commit is contained in:
1 parent
9e2776f7c4
commit
25c918e6a2
5 files changed
+149
-22
No files matched your search
+91
-18
@@ -24,6 +24,11 @@ var event_progress: Label
|
||||
var event_claim: Button
|
||||
var mascot_card: PanelContainer
|
||||
var mascot_art: Control
|
||||
var mascot_button: Button
|
||||
var mascot_note: Label
|
||||
var mascot_id := ""
|
||||
var mascot_art_id := ""
|
||||
var mascot_cycling := false
|
||||
var avatar_holder: CenterContainer
|
||||
var avatar_frame_id := ""
|
||||
var avatar_portrait_id := ""
|
||||
@@ -116,14 +121,23 @@ func _ready() -> void:
|
||||
var card := UI.panel(Palette.CREAM, 26, 12)
|
||||
mascot_card = card
|
||||
card.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
var mascot := _make_mascot()
|
||||
var mascot := _make_mascot("crumb")
|
||||
mascot_art = mascot
|
||||
mascot_art.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
card.add_child(mascot)
|
||||
mascot_button = Button.new()
|
||||
mascot_button.flat = true
|
||||
mascot_button.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
mascot_button.pressed.connect(_on_mascot_pressed)
|
||||
mascot_button.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
card.add_child(mascot_button)
|
||||
column.add_child(card)
|
||||
_apply_mascot_scale()
|
||||
|
||||
mascot_caption = UI.label("Crumb, innkeeper", 12, Palette.MUTED)
|
||||
column.add_child(mascot_caption)
|
||||
mascot_note = UI.label("Guest of the day · tap to cycle", 10, Palette.MUTED)
|
||||
column.add_child(mascot_note)
|
||||
hint_label = UI.label(UI.place_hint(), 11, Palette.MUTED)
|
||||
column.add_child(hint_label)
|
||||
|
||||
@@ -168,10 +182,13 @@ 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)
|
||||
var card_base := 140 if mascot_cycling else 160
|
||||
var art_base := 120 if mascot_cycling else 138
|
||||
var card_size := int(card_base / scale)
|
||||
var art_size := int(art_base / scale)
|
||||
mascot_card.custom_minimum_size = Vector2(card_size, card_size)
|
||||
mascot_art.custom_minimum_size = Vector2(art_size, art_size)
|
||||
mascot_button.custom_minimum_size = Vector2(card_size, card_size)
|
||||
|
||||
|
||||
func _build_event_layer() -> void:
|
||||
@@ -240,15 +257,7 @@ func _claim_event() -> void:
|
||||
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"))
|
||||
]
|
||||
_refresh_mascot()
|
||||
daily_button.text = _daily_text()
|
||||
var event := SaveGame.current_event()
|
||||
if event.is_empty():
|
||||
@@ -277,10 +286,10 @@ func refresh() -> void:
|
||||
func _daily_text() -> String:
|
||||
var streak := SaveGame.daily_streak()
|
||||
if SaveGame.daily_completed_today():
|
||||
return "Daily done · %d-day streak" % streak
|
||||
return "Daily done · %dd" % streak
|
||||
if streak > 0:
|
||||
return "Daily room · %d-day streak" % streak
|
||||
return "Daily room · start a streak"
|
||||
return "Daily · %dd streak" % streak
|
||||
return "Daily room"
|
||||
|
||||
|
||||
func _build_avatar() -> void:
|
||||
@@ -311,11 +320,75 @@ func _refresh_avatar() -> void:
|
||||
_build_avatar()
|
||||
|
||||
|
||||
func _make_mascot() -> Control:
|
||||
if ResourceLoader.exists("res://art/crumb.png"):
|
||||
func _make_mascot(id: String) -> Control:
|
||||
var path := "res://art/crumb.png" if id == "crumb" else Guests.portrait(id, "cards")
|
||||
if ResourceLoader.exists(path):
|
||||
var texture_rect := TextureRect.new()
|
||||
texture_rect.texture = load("res://art/crumb.png")
|
||||
texture_rect.texture = load(path)
|
||||
texture_rect.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
texture_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
return texture_rect
|
||||
return RatPortrait.new()
|
||||
|
||||
|
||||
func _unlocked_mascot_ids() -> Array:
|
||||
var out: Array = ["crumb"]
|
||||
for guest in Guests.all():
|
||||
var id := str(guest.get("id", ""))
|
||||
if id != "crumb" and SaveGame.is_guest_unlocked(id):
|
||||
out.append(id)
|
||||
return out
|
||||
|
||||
|
||||
func _mascot_guest(id: String) -> Dictionary:
|
||||
if id == "crumb":
|
||||
return {"name": "Crumb", "role": "Innkeeper", "stories": []}
|
||||
return Guests.by_id(id)
|
||||
|
||||
|
||||
func _on_mascot_pressed() -> void:
|
||||
var ids := _unlocked_mascot_ids()
|
||||
if ids.is_empty():
|
||||
return
|
||||
var index := ids.find(mascot_id)
|
||||
mascot_cycling = true
|
||||
mascot_id = str(ids[(index + 1) % ids.size()])
|
||||
UI.haptic(false)
|
||||
_refresh_mascot()
|
||||
|
||||
|
||||
func _refresh_mascot() -> void:
|
||||
var ids := _unlocked_mascot_ids()
|
||||
if ids.is_empty():
|
||||
return
|
||||
if not mascot_cycling:
|
||||
mascot_id = str(ids[Daily.day_number(Daily.today_key()) % ids.size()])
|
||||
elif not ids.has(mascot_id):
|
||||
mascot_id = str(ids[0])
|
||||
|
||||
if mascot_art_id != mascot_id:
|
||||
for child in mascot_card.get_children():
|
||||
if child != mascot_button:
|
||||
mascot_card.remove_child(child)
|
||||
child.queue_free()
|
||||
mascot_art = _make_mascot(mascot_id)
|
||||
mascot_art.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
mascot_card.add_child(mascot_art)
|
||||
mascot_button.move_to_front()
|
||||
mascot_art_id = mascot_id
|
||||
_apply_mascot_scale()
|
||||
|
||||
var guest := _mascot_guest(mascot_id)
|
||||
mascot_caption.text = "%s · %s" % [
|
||||
str(guest.get("name", mascot_id)),
|
||||
str(guest.get("role", "Guest"))
|
||||
]
|
||||
if mascot_cycling:
|
||||
var stories: Array = guest.get("stories", [])
|
||||
if stories.is_empty():
|
||||
mascot_note.text = "Always in · tap to cycle"
|
||||
else:
|
||||
var line := str(stories[0])
|
||||
mascot_note.text = line if line.length() <= 52 else (line.substr(0, 49) + "…")
|
||||
else:
|
||||
mascot_note.text = "Guest of the day · tap to cycle"
|
||||
+14
-2
@@ -88,7 +88,7 @@ func _ready() -> void:
|
||||
|
||||
settings_sheet = SettingsSheetScene.instantiate()
|
||||
add_child(settings_sheet)
|
||||
settings_sheet.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_center_control(settings_sheet)
|
||||
settings_sheet.visible = false
|
||||
settings_sheet.closed.connect(close_settings)
|
||||
settings_sheet.restart_requested.connect(_on_restart_requested)
|
||||
@@ -149,9 +149,21 @@ func _update_music() -> void:
|
||||
music_player.stop()
|
||||
|
||||
|
||||
## Keep the 360dp design centered on wide screens instead of stretching it.
|
||||
func _center_control(control: Control) -> void:
|
||||
control.anchor_left = 0.5
|
||||
control.anchor_right = 0.5
|
||||
control.anchor_top = 0.0
|
||||
control.anchor_bottom = 1.0
|
||||
control.offset_left = -180
|
||||
control.offset_right = 180
|
||||
control.offset_top = 0
|
||||
control.offset_bottom = 0
|
||||
|
||||
|
||||
func _add_screen(screen: Control) -> void:
|
||||
add_child(screen)
|
||||
screen.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_center_control(screen)
|
||||
screen.visible = false
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user