Files
Ratdoku/scripts/Frames.gd
T
Ratdoku Builder 9e2776f7c4 feat: guest stories, accessibility and cozy events
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.
2026-12-05 16:44:39 -06:00

136 lines
4.4 KiB
GDScript

class_name Frames
extends RefCounted
## Profile frame definitions. Unlocks use campaign room count and the best
## daily streak, so a frame is never lost when a streak resets.
const DEFS := [
{
"id": "plain", "name": "Plain", "rooms": 0, "streak": 0,
"border": Palette.WALL, "width": 2, "shadow": Color(0, 0, 0, 0), "shadow_size": 0,
},
{
"id": "paper", "name": "Paper", "rooms": 5, "streak": 0,
"border": Palette.MUTED, "width": 3, "shadow": Color(0, 0, 0, 0), "shadow_size": 0,
},
{
"id": "gold", "name": "Gold", "rooms": 10, "streak": 0,
"border": Palette.GOLD, "width": 4, "shadow": Palette.GOLD, "shadow_size": 5,
},
{
"id": "bell", "name": "Bellhop", "rooms": 20, "streak": 0,
"border": Palette.INK, "width": 3, "shadow": Palette.ORANGE, "shadow_size": 4,
},
{
"id": "star", "name": "Star guest", "rooms": 30, "streak": 0,
"border": Palette.GOLD, "width": 4, "shadow": Palette.WHITE, "shadow_size": 7,
},
{
"id": "regular", "name": "Regular", "rooms": 0, "streak": 3,
"border": Palette.ORANGE, "width": 4, "shadow": Palette.ORANGE, "shadow_size": 6,
},
{
"id": "night", "name": "Night owl", "rooms": 0, "streak": 7,
"border": Palette.INK, "width": 4, "shadow": Palette.GOLD, "shadow_size": 8,
},
{
"id": "event_rain", "name": "Puddle boots", "rooms": 0, "streak": 0,
"border": Palette.MUTED, "width": 3, "shadow": Palette.ROSE, "shadow_size": 5,
},
{
"id": "event_tea", "name": "Tea set", "rooms": 0, "streak": 0,
"border": Palette.ORANGE, "width": 3, "shadow": Palette.GOLD, "shadow_size": 5,
},
{
"id": "event_harvest", "name": "Harvest", "rooms": 0, "streak": 0,
"border": Palette.GOLD, "width": 4, "shadow": Palette.ORANGE_DARK, "shadow_size": 6,
},
{
"id": "event_lantern", "name": "Lantern", "rooms": 0, "streak": 0,
"border": Palette.ORANGE_DARK, "width": 3, "shadow": Palette.GOLD, "shadow_size": 8,
},
{
"id": "event_book", "name": "Book club", "rooms": 0, "streak": 0,
"border": Palette.WALL, "width": 3, "shadow": Palette.PAPER, "shadow_size": 5,
},
{
"id": "event_spring", "name": "Fresh linen", "rooms": 0, "streak": 0,
"border": Palette.ROSE, "width": 3, "shadow": Palette.WHITE, "shadow_size": 6,
},
]
static func all() -> Array:
return DEFS
static func by_id(id: String) -> Dictionary:
for frame in DEFS:
if str(frame.get("id", "")) == id:
return frame
return {}
static func is_unlocked(id: String) -> bool:
var frame := by_id(id)
if frame.is_empty():
return false
var frame_id := str(frame.get("id", ""))
if frame_id.begins_with("event_"):
return SaveGame.claimed_event_frames().has(frame_id)
var rooms: int = SaveGame.rooms_completed()
var streak: int = SaveGame.best_streak()
return rooms >= int(frame.get("rooms", 0)) and streak >= int(frame.get("streak", 0))
static func requirement_text(id: String) -> String:
var frame := by_id(id)
if frame.is_empty():
return ""
if str(frame.get("id", "")).begins_with("event_"):
return "Event reward"
var rooms := int(frame.get("rooms", 0))
var streak := int(frame.get("streak", 0))
if rooms > 0 and streak > 0:
return "%d rooms · %d-day streak" % [rooms, streak]
if rooms > 0:
return "Complete %d rooms" % rooms
if streak > 0:
return "%d-day best streak" % streak
return "Always available"
static func style_for(id: String, size: int) -> StyleBoxFlat:
var frame := by_id(id)
if frame.is_empty():
frame = DEFS[0]
var radius: int = max(6, int(size * 0.45))
var width: int = int(frame.get("width", 2))
var style := StyleBoxFlat.new()
style.bg_color = Color(0, 0, 0, 0)
style.corner_radius_top_left = radius
style.corner_radius_top_right = radius
style.corner_radius_bottom_left = radius
style.corner_radius_bottom_right = radius
style.border_width_left = width
style.border_width_right = width
style.border_width_top = width
style.border_width_bottom = width
style.border_color = frame.get("border", Palette.WALL)
style.shadow_color = frame.get("shadow", Color(0, 0, 0, 0))
style.shadow_size = int(frame.get("shadow_size", 0))
style.shadow_offset = Vector2(0, 2)
style.content_margin_left = width + 2
style.content_margin_right = width + 2
style.content_margin_top = width + 2
style.content_margin_bottom = width + 2
return style
## A sized PanelContainer with the frame border. Add the avatar inside it.
static func frame_panel(id: String, size: int) -> PanelContainer:
var panel := PanelContainer.new()
panel.custom_minimum_size = Vector2(size, size)
panel.add_theme_stylebox_override("panel", style_for(id, size))
return panel