feat(daily): add daily rooms, streaks, and profile frames

A deterministic daily room rotates through the 30-level pool and tracks current and best streaks in save version 3. Daily wins are separate from campaign progress. The new Profile screen shows framed Crumb, stats, and selectable frames unlocked by rooms or best streak.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 22:29:32 -06:00
1 parent 77ff5b48de
commit 7e6a338240
11 files changed
+680 -44

No files matched your search

+202
View File
@@ -0,0 +1,202 @@
extends Control
signal back_pressed
var portrait_holder: CenterContainer
var rooms_label: Label
var streak_label: Label
var best_label: Label
var frame_grid: GridContainer
var status_label: Label
var portrait_frame_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", 12)
margin.add_theme_constant_override("margin_right", 12)
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 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("Crumb's Profile", 22)
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
top.add_child(title)
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)
var content := VBoxContainer.new()
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
content.add_theme_constant_override("separation", 8)
scroll.add_child(content)
portrait_holder = CenterContainer.new()
content.add_child(portrait_holder)
content.add_child(UI.label("Crumb", 20, Palette.INK, true))
content.add_child(UI.label("Innkeeper · always in", 11, Palette.MUTED))
var stats := HBoxContainer.new()
stats.add_theme_constant_override("separation", 6)
content.add_child(stats)
rooms_label = _stat_card(stats, "Rooms", "0 / 30")
streak_label = _stat_card(stats, "Streak", "0")
best_label = _stat_card(stats, "Best", "0")
content.add_child(UI.heading("Frames", 18))
frame_grid = GridContainer.new()
frame_grid.columns = 2
frame_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
frame_grid.add_theme_constant_override("h_separation", 6)
frame_grid.add_theme_constant_override("v_separation", 6)
content.add_child(frame_grid)
status_label = UI.label("Tap an unlocked frame to wear it.", 11, Palette.MUTED)
status_label.custom_minimum_size = Vector2(0, 22)
content.add_child(status_label)
UI.pass_scroll_input(content)
SaveGame.progress_changed.connect(refresh)
refresh()
func _stat_card(parent: HBoxContainer, title: String, value: String) -> Label:
var panel := UI.panel(Palette.PAPER, 12, 6)
panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
var box := VBoxContainer.new()
box.add_theme_constant_override("separation", 0)
panel.add_child(box)
box.add_child(UI.label(title, 10, Palette.MUTED))
var number := UI.label(value, 16)
box.add_child(number)
parent.add_child(panel)
return number
func refresh() -> void:
rooms_label.text = "%d / 30" % SaveGame.rooms_completed()
streak_label.text = str(SaveGame.daily_streak())
best_label.text = str(SaveGame.best_streak())
_build_portrait()
_build_frames()
func _build_portrait() -> void:
var selected := SaveGame.selected_frame()
if portrait_frame_id == selected and portrait_holder.get_child_count() > 0:
return
for child in portrait_holder.get_children():
child.free()
var frame := Frames.frame_panel(selected, 118)
var head := TextureRect.new()
head.texture = load("res://art/crumb_head.png")
head.custom_minimum_size = Vector2(96, 96)
head.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
head.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
head.mouse_filter = Control.MOUSE_FILTER_IGNORE
frame.add_child(head)
portrait_holder.add_child(frame)
portrait_frame_id = selected
func _build_frames() -> void:
for child in frame_grid.get_children():
child.free()
var selected := SaveGame.selected_frame()
for frame in Frames.all():
var id := str(frame.get("id", ""))
var unlocked := Frames.is_unlocked(id)
var card := Button.new()
card.custom_minimum_size = Vector2(148, 92)
card.flat = true
card.add_theme_stylebox_override("normal", _card_style(Palette.PAPER))
card.add_theme_stylebox_override("hover", _card_style(Palette.PAPER_DARK))
card.add_theme_stylebox_override("pressed", _card_style(Palette.GOLD))
card.pressed.connect(_on_frame_pressed.bind(id, unlocked))
var row := HBoxContainer.new()
row.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
row.add_theme_constant_override("separation", 6)
row.mouse_filter = Control.MOUSE_FILTER_IGNORE
card.add_child(row)
var badge := Frames.frame_panel(id, 46)
badge.mouse_filter = Control.MOUSE_FILTER_IGNORE
var head := TextureRect.new()
head.texture = load("res://art/crumb_head.png")
head.custom_minimum_size = Vector2(30, 30)
head.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
head.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
head.mouse_filter = Control.MOUSE_FILTER_IGNORE
badge.add_child(head)
row.add_child(badge)
var text := VBoxContainer.new()
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
text.add_theme_constant_override("separation", 0)
text.mouse_filter = Control.MOUSE_FILTER_IGNORE
row.add_child(text)
var name := UI.label(str(frame.get("name", "")), 12)
name.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(name)
var detail := ""
if id == selected:
detail = "Wearing"
elif unlocked:
detail = "Unlocked"
else:
detail = Frames.requirement_text(id)
var sub := UI.label(detail, 9, Palette.MUTED if unlocked else Palette.RED)
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
text.add_child(sub)
if not unlocked:
card.modulate = Color(1, 1, 1, 0.55)
frame_grid.add_child(card)
UI.pass_scroll_input(frame_grid)
func _on_frame_pressed(id: String, unlocked: bool) -> void:
if not unlocked:
status_label.text = "Locked: %s." % Frames.requirement_text(id)
status_label.add_theme_color_override("font_color", Palette.RED)
return
SaveGame.select_frame(id)
status_label.text = "Now wearing %s." % str(Frames.by_id(id).get("name", id))
status_label.add_theme_color_override("font_color", Palette.MUTED)
func _card_style(color: Color) -> StyleBoxFlat:
var style := StyleBoxFlat.new()
style.bg_color = color
style.corner_radius_top_left = 12
style.corner_radius_top_right = 12
style.corner_radius_bottom_left = 12
style.corner_radius_bottom_right = 12
style.content_margin_left = 6
style.content_margin_right = 6
style.content_margin_top = 6
style.content_margin_bottom = 6
return style