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.
This commit is contained in:
1 parent
e0fd33c25e
commit
9e2776f7c4
27 files changed
+1559
-99
No files matched your search
@@ -556,6 +556,7 @@ func _set_cell(cell: Vector2i, value: int) -> void:
|
||||
if value == RAT:
|
||||
last_placed = cell
|
||||
pop_time = 0.0 if reduce_motion else 0.26
|
||||
UI.haptic(false)
|
||||
|
||||
_after_change()
|
||||
|
||||
|
||||
@@ -33,6 +33,30 @@ const DEFS := [
|
||||
"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,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -51,6 +75,9 @@ 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))
|
||||
@@ -60,6 +87,8 @@ 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:
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
class_name FreePlay
|
||||
extends RefCounted
|
||||
|
||||
## Deterministic free-play variants of the verified levels.json boards.
|
||||
##
|
||||
## Only structure-preserving maps are used:
|
||||
## * a dihedral symmetry of the square (rotation / mirror) applied to every
|
||||
## cell, to `solution` (row -> column) and to the `clues` coordinates;
|
||||
## * a one-to-one relabeling of region ids applied to every cell of `regions`.
|
||||
##
|
||||
## Both maps are automorphisms of the puzzle. They keep one rat per row, column
|
||||
## and region, the "no two rats touching (even diagonally)" rule, and the exact
|
||||
## number of solutions: a D4 symmetry is a bijection of cells that preserves
|
||||
## adjacency and region membership, and a region relabeling preserves the
|
||||
## equality relation between cells. Consequently every solution of the source
|
||||
## (including any alternate one) maps to exactly one solution of the variant
|
||||
## and back, so the verified uniqueness is preserved rather than re-guessed.
|
||||
## The source solution is transported through the same map; no new solution is
|
||||
## invented.
|
||||
##
|
||||
## Board.gd derives each region's guest portrait from the region id and the
|
||||
## level id, so relabeling region ids relabels the associated guest ids too;
|
||||
## the level dictionaries carry no separate guest-id array to transform.
|
||||
##
|
||||
## `id` is deliberately kept from the source so that applying the inverse map
|
||||
## recovers the source entry byte-for-byte at the value level.
|
||||
|
||||
const LEVELS_PATH := "res://data/levels.json"
|
||||
const N := 8
|
||||
const SYMMETRY_COUNT := 8
|
||||
|
||||
|
||||
## Loads and parses the verified level pack. Returns only dictionary entries.
|
||||
static func all_source_levels() -> Array:
|
||||
if not FileAccess.file_exists(LEVELS_PATH):
|
||||
push_warning("FreePlay: no level file at %s" % LEVELS_PATH)
|
||||
return []
|
||||
|
||||
var file := FileAccess.open(LEVELS_PATH, FileAccess.READ)
|
||||
if file == null:
|
||||
push_warning("FreePlay: could not open %s" % LEVELS_PATH)
|
||||
return []
|
||||
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
|
||||
if typeof(parsed) != TYPE_ARRAY:
|
||||
push_warning("FreePlay: %s is not a JSON array" % LEVELS_PATH)
|
||||
return []
|
||||
|
||||
var levels: Array = []
|
||||
for entry in parsed:
|
||||
if typeof(entry) == TYPE_DICTIONARY:
|
||||
levels.append(entry)
|
||||
return levels
|
||||
|
||||
|
||||
## Deterministic parameters shared by variant() and the QA inverse check.
|
||||
## source_index picks a verified level; symmetry is a D4 index; region_map is a
|
||||
## permutation of 0..N-1 applied to region ids, with its inverse provided too.
|
||||
static func variant_params(seed: int, index: int) -> Dictionary:
|
||||
var levels := all_source_levels()
|
||||
var count := levels.size()
|
||||
if count == 0:
|
||||
return {}
|
||||
|
||||
var source_index := _mod(seed + index, count)
|
||||
|
||||
# An explicit seed keeps results identical across runs and platforms.
|
||||
var rng := RandomNumberGenerator.new()
|
||||
rng.seed = seed ^ (index * 2654435761)
|
||||
|
||||
var symmetry := rng.randi_range(0, SYMMETRY_COUNT - 1)
|
||||
var region_map: Array = []
|
||||
for i in N:
|
||||
region_map.append(i)
|
||||
for i in range(N - 1, 0, -1):
|
||||
var j := rng.randi_range(0, i)
|
||||
var tmp = region_map[i]
|
||||
region_map[i] = region_map[j]
|
||||
region_map[j] = tmp
|
||||
|
||||
var inverse_map: Array = []
|
||||
inverse_map.resize(N)
|
||||
for i in N:
|
||||
inverse_map[int(region_map[i])] = i
|
||||
|
||||
return {
|
||||
"source_index": source_index,
|
||||
"symmetry": symmetry,
|
||||
"region_map": region_map,
|
||||
"inverse_map": inverse_map,
|
||||
}
|
||||
|
||||
|
||||
## Maps one cell coordinate through D4 symmetry `symmetry` on an n x n board:
|
||||
## 0 identity; 1 rot90 cw; 2 rot180; 3 rot270 cw;
|
||||
## 4 mirror left/right; 5 mirror top/bottom;
|
||||
## 6 main-diagonal flip; 7 anti-diagonal flip.
|
||||
static func transform_cell(r: int, c: int, symmetry: int, n: int = N) -> Vector2i:
|
||||
var last := n - 1
|
||||
match symmetry:
|
||||
0:
|
||||
return Vector2i(r, c)
|
||||
1:
|
||||
return Vector2i(c, last - r)
|
||||
2:
|
||||
return Vector2i(last - r, last - c)
|
||||
3:
|
||||
return Vector2i(last - c, r)
|
||||
4:
|
||||
return Vector2i(r, last - c)
|
||||
5:
|
||||
return Vector2i(last - r, c)
|
||||
6:
|
||||
return Vector2i(c, r)
|
||||
7:
|
||||
return Vector2i(last - c, last - r)
|
||||
return Vector2i(r, c)
|
||||
|
||||
|
||||
## The inverse of each D4 element. Four of them are self-inverse.
|
||||
static func inverse_symmetry(symmetry: int) -> int:
|
||||
match symmetry:
|
||||
1:
|
||||
return 3
|
||||
3:
|
||||
return 1
|
||||
_:
|
||||
return symmetry
|
||||
|
||||
|
||||
## Returns a variant level in exactly the same shape as a levels.json entry:
|
||||
## { clues, id, n, regions, solution }, with the same float value types.
|
||||
static func variant(seed: int, index: int) -> Dictionary:
|
||||
var params := variant_params(seed, index)
|
||||
if params.is_empty():
|
||||
return {}
|
||||
|
||||
var levels := all_source_levels()
|
||||
var source: Dictionary = levels[int(params["source_index"])]
|
||||
var n := int(source.get("n", N))
|
||||
var symmetry := int(params["symmetry"])
|
||||
var region_map: Array = params["region_map"]
|
||||
|
||||
var src_regions: Array = source.get("regions", [])
|
||||
var src_solution: Array = source.get("solution", [])
|
||||
var src_clues: Array = source.get("clues", [])
|
||||
|
||||
var regions: Array = []
|
||||
for r in n:
|
||||
var row: Array = []
|
||||
for c in n:
|
||||
row.append(0.0)
|
||||
regions.append(row)
|
||||
|
||||
# Move every cell (and its relabeled region id) to its mirrored position.
|
||||
for r in n:
|
||||
for c in n:
|
||||
var dest := transform_cell(r, c, symmetry, n)
|
||||
var old_id := int(src_regions[r][c])
|
||||
var new_id: int = old_id
|
||||
if old_id >= 0 and old_id < region_map.size():
|
||||
new_id = int(region_map[old_id])
|
||||
regions[dest.x][dest.y] = float(new_id)
|
||||
|
||||
# solution[row] is the rat's column; a symmetry permutes rows, so write
|
||||
# each transported rat into its new row.
|
||||
var solution: Array = []
|
||||
solution.resize(n)
|
||||
for r in n:
|
||||
var c := int(src_solution[r])
|
||||
var dest := transform_cell(r, c, symmetry, n)
|
||||
solution[dest.x] = float(dest.y)
|
||||
|
||||
# Clues are [row, column] coordinates of fixed rats.
|
||||
var clues: Array = []
|
||||
for clue in src_clues:
|
||||
var r := int(clue[0])
|
||||
var c := int(clue[1])
|
||||
var dest := transform_cell(r, c, symmetry, n)
|
||||
clues.append([float(dest.x), float(dest.y)])
|
||||
|
||||
return {
|
||||
"clues": clues,
|
||||
"id": str(source.get("id", "")),
|
||||
"n": float(n),
|
||||
"regions": regions,
|
||||
"solution": solution,
|
||||
}
|
||||
|
||||
|
||||
static func _mod(value: int, modulus: int) -> int:
|
||||
var result := value % modulus
|
||||
if result < 0:
|
||||
result += modulus
|
||||
return result
|
||||
@@ -0,0 +1 @@
|
||||
uid://r1xo7agldkxm
|
||||
+78
-7
@@ -14,6 +14,8 @@ var elapsed_ms := 0
|
||||
var win_shown := false
|
||||
var current_level_id := ""
|
||||
var daily_mode := false
|
||||
var free_mode := false
|
||||
var free_seed := 0
|
||||
var restoring := false
|
||||
var daily_key := ""
|
||||
var ui_paused := false
|
||||
@@ -33,6 +35,7 @@ var win_next: Button
|
||||
var new_guest_box: HBoxContainer
|
||||
var new_guest_label: Label
|
||||
var new_guest_portrait: TextureRect
|
||||
var new_guest_story: Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -130,13 +133,13 @@ func _build_ui() -> void:
|
||||
|
||||
var undo := UI.button("Undo", false, 48)
|
||||
undo.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
undo.add_theme_font_size_override("font_size", 17)
|
||||
UI.set_font_size(undo, 17)
|
||||
undo.pressed.connect(_on_undo)
|
||||
actions.add_child(undo)
|
||||
|
||||
var hint := UI.button("Hint", true, 48)
|
||||
hint.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hint.add_theme_font_size_override("font_size", 17)
|
||||
UI.set_font_size(hint, 17)
|
||||
hint.pressed.connect(_on_hint)
|
||||
actions.add_child(hint)
|
||||
|
||||
@@ -212,14 +215,20 @@ func _build_win_overlay() -> void:
|
||||
new_guest_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
new_guest_box.add_child(new_guest_label)
|
||||
|
||||
new_guest_story = UI.label("", 11, Palette.MUTED)
|
||||
new_guest_story.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
new_guest_story.custom_minimum_size = Vector2(0, 0)
|
||||
new_guest_story.visible = false
|
||||
box.add_child(new_guest_story)
|
||||
|
||||
var next := UI.button("Next room", true, 48)
|
||||
next.add_theme_font_size_override("font_size", 17)
|
||||
UI.set_font_size(next, 17)
|
||||
box.add_child(next)
|
||||
next.pressed.connect(_on_next)
|
||||
win_next = next
|
||||
|
||||
var book := UI.button("Guest Book", false, 42)
|
||||
book.add_theme_font_size_override("font_size", 15)
|
||||
UI.set_font_size(book, 15)
|
||||
box.add_child(book)
|
||||
book.pressed.connect(func() -> void: guest_book_pressed.emit())
|
||||
|
||||
@@ -253,6 +262,7 @@ func start_level(index: int, daily: bool = false, key: String = "") -> void:
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
new_guest_box.visible = false
|
||||
new_guest_story.visible = false
|
||||
var difficulty := str(SaveGame.get_setting("difficulty"))
|
||||
rule_strip.visible = difficulty == "easy" or difficulty == "zen" or daily_mode or level_index < 3
|
||||
timer_label.visible = bool(SaveGame.get_setting("show_timer")) and difficulty != "zen"
|
||||
@@ -267,11 +277,33 @@ func start_daily(index: int, key: String) -> void:
|
||||
start_level(index, true, key)
|
||||
|
||||
|
||||
func _load_free_levels(seed: int) -> void:
|
||||
free_seed = seed
|
||||
levels.clear()
|
||||
for i in range(30):
|
||||
var level := FreePlay.variant(seed, i)
|
||||
if not level.is_empty():
|
||||
levels.append(level)
|
||||
|
||||
|
||||
## Free play uses verified, symmetry-shuffled boards. It never writes progress,
|
||||
## unlocks, achievements or guest story visits.
|
||||
func start_free(seed: int) -> void:
|
||||
_load_free_levels(seed)
|
||||
free_mode = true
|
||||
daily_mode = false
|
||||
daily_key = ""
|
||||
start_level(0, false, "")
|
||||
level_label.text = "Free room 1"
|
||||
|
||||
|
||||
func snapshot() -> Dictionary:
|
||||
var snap := board.snapshot()
|
||||
snap["level_index"] = level_index
|
||||
snap["daily_mode"] = daily_mode
|
||||
snap["daily_key"] = daily_key
|
||||
snap["free_mode"] = free_mode
|
||||
snap["free_seed"] = free_seed
|
||||
snap["elapsed_ms"] = elapsed_ms
|
||||
return snap
|
||||
|
||||
@@ -279,9 +311,15 @@ func snapshot() -> Dictionary:
|
||||
func restore(snapshot: Dictionary) -> bool:
|
||||
if snapshot.is_empty() or levels.is_empty():
|
||||
return false
|
||||
var free := bool(snapshot.get("free_mode", false))
|
||||
if free:
|
||||
_load_free_levels(int(snapshot.get("free_seed", 0)))
|
||||
free_mode = free
|
||||
var index := clampi(int(snapshot.get("level_index", 0)), 0, levels.size() - 1)
|
||||
restoring = true
|
||||
start_level(index, bool(snapshot.get("daily_mode", false)), str(snapshot.get("daily_key", "")))
|
||||
if free:
|
||||
level_label.text = "Free room %d" % (index + 1)
|
||||
var ok := board.restore_state(snapshot)
|
||||
restoring = false
|
||||
if not ok:
|
||||
@@ -292,13 +330,19 @@ func restore(snapshot: Dictionary) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _board_mode() -> String:
|
||||
if free_mode:
|
||||
return "free"
|
||||
return "daily" if daily_mode else "campaign"
|
||||
|
||||
|
||||
func clear_saved_board() -> void:
|
||||
SaveGame.clear_board("daily" if daily_mode else "campaign")
|
||||
SaveGame.clear_board(_board_mode())
|
||||
|
||||
|
||||
func save_board() -> void:
|
||||
if not restoring and not win_shown:
|
||||
SaveGame.save_board("daily" if daily_mode else "campaign", snapshot())
|
||||
SaveGame.save_board(_board_mode(), snapshot())
|
||||
|
||||
|
||||
func _refresh_legend() -> void:
|
||||
@@ -411,6 +455,7 @@ func _on_solved() -> void:
|
||||
if win_shown:
|
||||
return
|
||||
win_shown = true
|
||||
UI.haptic(true)
|
||||
clear_saved_board()
|
||||
status_label.text = "Everyone checked in."
|
||||
status_label.add_theme_color_override("font_color", Palette.INK)
|
||||
@@ -418,6 +463,8 @@ func _on_solved() -> void:
|
||||
|
||||
if daily_mode:
|
||||
var extended := SaveGame.complete_daily(daily_key, int(elapsed_ms / 1000.0))
|
||||
_record_story_visit(level_index + 1)
|
||||
new_guest_story.visible = false
|
||||
var streak := SaveGame.daily_streak()
|
||||
var streak_text := "%d %s" % [streak, "day" if streak == 1 else "days"]
|
||||
win_title.text = "Daily room complete!"
|
||||
@@ -427,24 +474,46 @@ func _on_solved() -> void:
|
||||
]
|
||||
win_next.text = "Back to lobby"
|
||||
new_guest_box.visible = false
|
||||
elif free_mode:
|
||||
win_title.text = "Free room complete!"
|
||||
win_detail.text = "No progress saved · %s" % _format_time(elapsed_ms)
|
||||
win_next.text = "Back to lobby"
|
||||
new_guest_box.visible = false
|
||||
new_guest_story.visible = false
|
||||
else:
|
||||
win_title.text = "Everyone checked in!"
|
||||
win_detail.text = "Room %d · %s" % [level_index + 1, _format_time(elapsed_ms)]
|
||||
win_next.text = "Next room"
|
||||
var unlocked_id := SaveGame.complete_room(current_level_id, level_index + 1)
|
||||
var guest := _record_story_visit(level_index + 1)
|
||||
if unlocked_id != "":
|
||||
var guest := Guests.by_id(unlocked_id)
|
||||
new_guest_label.text = "New guest: %s the %s" % [str(guest.get("name", "")), str(guest.get("role", ""))]
|
||||
new_guest_portrait.texture = load(Guests.portrait(unlocked_id, "thumbs"))
|
||||
new_guest_box.visible = true
|
||||
var stories: Array = guest.get("stories", [])
|
||||
if not stories.is_empty():
|
||||
new_guest_story.text = str(stories[0])
|
||||
new_guest_story.visible = true
|
||||
else:
|
||||
new_guest_box.visible = false
|
||||
new_guest_story.visible = false
|
||||
|
||||
await get_tree().create_timer(0.45).timeout
|
||||
if win_shown:
|
||||
overlay.visible = true
|
||||
|
||||
|
||||
func _record_story_visit(room_number: int) -> Dictionary:
|
||||
var guest := Guests.for_room(room_number)
|
||||
if guest.is_empty():
|
||||
return {}
|
||||
var id := str(guest.get("id", ""))
|
||||
if id.is_empty() or not SaveGame.is_guest_unlocked(id):
|
||||
return {}
|
||||
SaveGame.record_guest_visit(id)
|
||||
return guest
|
||||
|
||||
|
||||
func _on_undo() -> void:
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
@@ -468,6 +537,8 @@ func _on_next() -> void:
|
||||
return
|
||||
if level_index + 1 < levels.size():
|
||||
start_level(level_index + 1)
|
||||
if free_mode:
|
||||
level_label.text = "Free room %d" % (level_index + 1)
|
||||
else:
|
||||
_on_back()
|
||||
|
||||
|
||||
+41
-3
@@ -21,6 +21,7 @@ var detail_meta: Label
|
||||
var detail_bio: Label
|
||||
var detail_snack: Label
|
||||
var detail_status: Label
|
||||
var detail_story_box: VBoxContainer
|
||||
var crumb_frame_holder: CenterContainer
|
||||
var crumb_frame_id := ""
|
||||
|
||||
@@ -296,13 +297,19 @@ func _build_detail() -> void:
|
||||
detail_layer.add_child(center)
|
||||
|
||||
var panel := UI.panel(Palette.CREAM, 24, 16)
|
||||
panel.custom_minimum_size = Vector2(320, 0)
|
||||
var view_size := get_viewport_rect().size
|
||||
panel.custom_minimum_size = Vector2(320, max(320, min(560, int(view_size.y) - 80)))
|
||||
panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
center.add_child(panel)
|
||||
|
||||
var detail_scroll := ScrollContainer.new()
|
||||
detail_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
detail_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
panel.add_child(detail_scroll)
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 4)
|
||||
panel.add_child(box)
|
||||
box.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
detail_scroll.add_child(box)
|
||||
|
||||
detail_portrait = TextureRect.new()
|
||||
detail_portrait.custom_minimum_size = Vector2(180, 180)
|
||||
@@ -326,10 +333,17 @@ func _build_detail() -> void:
|
||||
detail_status = UI.label("", 10, Palette.MUTED)
|
||||
box.add_child(detail_status)
|
||||
|
||||
box.add_child(UI.heading("Story", 16))
|
||||
detail_story_box = VBoxContainer.new()
|
||||
detail_story_box.add_theme_constant_override("separation", 6)
|
||||
box.add_child(detail_story_box)
|
||||
UI.pass_scroll_input(detail_story_box)
|
||||
|
||||
var close := UI.button("Close", false, 44)
|
||||
close.add_theme_font_size_override("font_size", 16)
|
||||
UI.set_font_size(close, 16)
|
||||
close.pressed.connect(_try_close_detail)
|
||||
box.add_child(close)
|
||||
UI.pass_scroll_input(box)
|
||||
|
||||
|
||||
func _show_detail(guest: Dictionary) -> void:
|
||||
@@ -345,6 +359,30 @@ func _show_detail(guest: Dictionary) -> void:
|
||||
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"
|
||||
|
||||
for child in detail_story_box.get_children():
|
||||
child.queue_free()
|
||||
var stories: Array = guest.get("stories", [])
|
||||
if not SaveGame.is_guest_unlocked(id):
|
||||
var hidden_line := UI.label("??? — check in from Room %d to hear their story." % int(guest.get("unlock_room", 0)), 11, Palette.MUTED)
|
||||
hidden_line.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
detail_story_box.add_child(hidden_line)
|
||||
else:
|
||||
var visits := SaveGame.guest_visits(id)
|
||||
detail_status.text += " · %d %s" % [visits, "visit" if visits == 1 else "visits"]
|
||||
var count := SaveGame.story_line_count(id)
|
||||
var needs := [0, 3, 7]
|
||||
for i in range(stories.size()):
|
||||
if i < count:
|
||||
var line := UI.label(str(stories[i]), 11)
|
||||
line.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
detail_story_box.add_child(line)
|
||||
else:
|
||||
var need := int(needs[clampi(i, 0, needs.size() - 1)])
|
||||
var teaser := UI.label("??? · Unlocks after %d visits" % need, 10, Palette.MUTED)
|
||||
teaser.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
detail_story_box.add_child(teaser)
|
||||
|
||||
_detail_opened_at = Time.get_ticks_msec()
|
||||
detail_layer.visible = true
|
||||
detail_layer.move_to_front()
|
||||
|
||||
+123
-8
@@ -7,13 +7,23 @@ 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 := ""
|
||||
@@ -48,7 +58,7 @@ func _ready() -> void:
|
||||
|
||||
progress_pill = UI.button("5 / 25 guests", false, 38)
|
||||
progress_pill.custom_minimum_size = Vector2(130, 38)
|
||||
progress_pill.add_theme_font_size_override("font_size", 13)
|
||||
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)
|
||||
@@ -65,17 +75,36 @@ func _ready() -> void:
|
||||
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
|
||||
daily_button.add_theme_font_size_override("font_size", 13)
|
||||
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(96, 40)
|
||||
streak_button.add_theme_font_size_override("font_size", 12)
|
||||
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)
|
||||
|
||||
@@ -85,12 +114,13 @@ func _ready() -> void:
|
||||
column.add_child(top_space)
|
||||
|
||||
var card := UI.panel(Palette.CREAM, 26, 12)
|
||||
card.custom_minimum_size = Vector2(160, 160)
|
||||
mascot_card = card
|
||||
card.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
var mascot := _make_mascot()
|
||||
mascot.custom_minimum_size = Vector2(138, 138)
|
||||
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)
|
||||
@@ -115,26 +145,101 @@ func _ready() -> void:
|
||||
|
||||
var book := UI.button("Guest Book", false, 46)
|
||||
book.custom_minimum_size = Vector2(146, 46)
|
||||
book.add_theme_font_size_override("font_size", 15)
|
||||
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)
|
||||
rules.add_theme_font_size_override("font_size", 15)
|
||||
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"
|
||||
@@ -145,6 +250,16 @@ func refresh() -> void:
|
||||
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)
|
||||
|
||||
@@ -49,6 +49,7 @@ func _ready() -> void:
|
||||
_setup_music()
|
||||
_refresh_background()
|
||||
SaveGame.settings_changed.connect(_refresh_background)
|
||||
SaveGame.settings_changed.connect(_apply_ui_scale)
|
||||
SaveGame.progress_changed.connect(_refresh_background)
|
||||
|
||||
home = HomeScene.instantiate()
|
||||
@@ -58,6 +59,7 @@ func _ready() -> void:
|
||||
home.settings_pressed.connect(func() -> void: open_settings("home"))
|
||||
home.rules_pressed.connect(func() -> void: show_screen("rules"))
|
||||
home.daily_pressed.connect(_on_daily)
|
||||
home.freeplay_pressed.connect(_on_freeplay)
|
||||
home.profile_pressed.connect(func() -> void: show_screen("profile"))
|
||||
home.streak_pressed.connect(func() -> void: show_screen("streak"))
|
||||
|
||||
@@ -120,6 +122,10 @@ func _refresh_background() -> void:
|
||||
_refresh_background_texture(background_rect)
|
||||
|
||||
|
||||
func _apply_ui_scale() -> void:
|
||||
UI.apply_scale(self)
|
||||
|
||||
|
||||
func _setup_music() -> void:
|
||||
music_player = AudioStreamPlayer.new()
|
||||
var stream = load("res://assets/audio/lounge_main.mp3")
|
||||
@@ -229,6 +235,15 @@ func _on_daily() -> void:
|
||||
game.start_daily(index, key)
|
||||
|
||||
|
||||
func _on_freeplay() -> void:
|
||||
show_screen("game")
|
||||
var seed := int(Time.get_unix_time_from_system()) % 1000000
|
||||
var saved := SaveGame.load_board("free")
|
||||
if not saved.is_empty() and bool(saved.get("free_mode", false)) and game.restore(saved):
|
||||
return
|
||||
game.start_free(seed)
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if music_player != null:
|
||||
music_player.stop()
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ func _ready() -> void:
|
||||
name_row.add_child(name_label)
|
||||
var edit_name := UI.button("Edit", false, 32)
|
||||
edit_name.custom_minimum_size = Vector2(52, 32)
|
||||
edit_name.add_theme_font_size_override("font_size", 11)
|
||||
UI.set_font_size(edit_name, 11)
|
||||
edit_name.pressed.connect(_show_rename)
|
||||
name_row.add_child(edit_name)
|
||||
player_id_label = UI.label("RAT-000000", 10, Palette.MUTED)
|
||||
@@ -101,7 +101,7 @@ func _ready() -> void:
|
||||
best_label = _stat_card(stats, "Best", "0")
|
||||
|
||||
var view_streak := UI.button("View daily streak ›", false, 40)
|
||||
view_streak.add_theme_font_size_override("font_size", 14)
|
||||
UI.set_font_size(view_streak, 14)
|
||||
view_streak.pressed.connect(func() -> void: streak_pressed.emit())
|
||||
content.add_child(view_streak)
|
||||
|
||||
|
||||
+2
-2
@@ -76,13 +76,13 @@ func _ready() -> void:
|
||||
|
||||
var reset := UI.button("Reset", false, 44)
|
||||
reset.custom_minimum_size = Vector2(100, 44)
|
||||
reset.add_theme_font_size_override("font_size", 15)
|
||||
UI.set_font_size(reset, 15)
|
||||
reset.pressed.connect(_on_tutorial_reset)
|
||||
controls.add_child(reset)
|
||||
|
||||
var hint := UI.button("Hint", true, 44)
|
||||
hint.custom_minimum_size = Vector2(100, 44)
|
||||
hint.add_theme_font_size_override("font_size", 15)
|
||||
UI.set_font_size(hint, 15)
|
||||
hint.pressed.connect(_on_tutorial_hint)
|
||||
controls.add_child(hint)
|
||||
|
||||
|
||||
+165
-10
@@ -20,6 +20,8 @@ const DEFAULTS := {
|
||||
"sfx_volume": 0.8,
|
||||
"difficulty": "normal",
|
||||
"theme": "cream",
|
||||
"ui_scale": 1.0,
|
||||
"haptics": true,
|
||||
}
|
||||
|
||||
var data := {}
|
||||
@@ -40,9 +42,11 @@ func _default_daily() -> Dictionary:
|
||||
|
||||
func _default_data() -> Dictionary:
|
||||
return {
|
||||
"version": 6,
|
||||
"version": 7,
|
||||
"completed_rooms": [],
|
||||
"unlocked_guests": [],
|
||||
"guest_notes": {},
|
||||
"events": {},
|
||||
"settings": DEFAULTS.duplicate(true),
|
||||
"last_room": 0,
|
||||
"daily": _default_daily(),
|
||||
@@ -63,7 +67,7 @@ func _new_player_id() -> String:
|
||||
|
||||
func load_game() -> void:
|
||||
data = _default_data()
|
||||
var stored_version := 6
|
||||
var stored_version := 7
|
||||
|
||||
if FileAccess.file_exists(PATH):
|
||||
var file := FileAccess.open(PATH, FileAccess.READ)
|
||||
@@ -112,12 +116,16 @@ func load_game() -> void:
|
||||
data["gift_claimed"] = []
|
||||
if typeof(data.get("saved_boards")) != TYPE_DICTIONARY:
|
||||
data["saved_boards"] = {}
|
||||
if typeof(data.get("guest_notes")) != TYPE_DICTIONARY:
|
||||
data["guest_notes"] = {}
|
||||
if typeof(data.get("events")) != TYPE_DICTIONARY:
|
||||
data["events"] = {}
|
||||
|
||||
var migrated := false
|
||||
# Version 2 made double-tap the default; version 3 added daily streaks and
|
||||
# profile frames; version 4 added avatars and streak history; version 5
|
||||
# added music; version 6 added identity, achievements, gifts, themes,
|
||||
# difficulty and saved boards.
|
||||
# difficulty and saved boards; version 7 added guest notes and events.
|
||||
if stored_version < 2:
|
||||
data["settings"]["double_tap_place"] = true
|
||||
migrated = true
|
||||
@@ -129,6 +137,8 @@ func load_game() -> void:
|
||||
migrated = true
|
||||
if stored_version < 6:
|
||||
migrated = true
|
||||
if stored_version < 7:
|
||||
migrated = true
|
||||
|
||||
if typeof(data.get("completed_rooms")) != TYPE_ARRAY:
|
||||
data["completed_rooms"] = []
|
||||
@@ -136,7 +146,7 @@ func load_game() -> void:
|
||||
data["unlocked_guests"] = []
|
||||
|
||||
if migrated:
|
||||
data["version"] = 6
|
||||
data["version"] = 7
|
||||
save_game()
|
||||
|
||||
|
||||
@@ -192,15 +202,12 @@ func reset_progress() -> void:
|
||||
data["unlocked_guests"] = []
|
||||
data["last_room"] = 0
|
||||
data["saved_boards"] = {}
|
||||
data["guest_notes"] = {}
|
||||
data["events"] = {}
|
||||
|
||||
# Room-based unlocks can disappear after a reset; never leave a locked
|
||||
# frame or guest avatar equipped.
|
||||
var frame := Frames.by_id(selected_frame())
|
||||
if (
|
||||
frame.is_empty()
|
||||
or rooms_completed() < int(frame.get("rooms", 0))
|
||||
or best_streak() < int(frame.get("streak", 0))
|
||||
):
|
||||
if not Frames.is_unlocked(selected_frame()):
|
||||
data["profile_frame"] = "plain"
|
||||
if not Avatars.is_unlocked(selected_avatar()):
|
||||
data["avatar_id"] = "crumb"
|
||||
@@ -221,6 +228,153 @@ func rooms_completed() -> int:
|
||||
return (data.get("completed_rooms") as Array).size()
|
||||
|
||||
|
||||
## Guest story progress. Free play never calls this; only campaign/daily rooms.
|
||||
func record_guest_visit(id: String) -> int:
|
||||
if id.is_empty() or not is_guest_unlocked(id):
|
||||
return guest_visits(id)
|
||||
var notes: Dictionary = data.get("guest_notes", {})
|
||||
var entry: Dictionary = notes.get(id, {})
|
||||
if typeof(entry) != TYPE_DICTIONARY:
|
||||
entry = {}
|
||||
entry["visits"] = int(entry.get("visits", 0)) + 1
|
||||
notes[id] = entry
|
||||
data["guest_notes"] = notes
|
||||
save_game()
|
||||
return int(entry["visits"])
|
||||
|
||||
|
||||
func guest_visits(id: String) -> int:
|
||||
var notes: Dictionary = data.get("guest_notes", {})
|
||||
var entry = notes.get(id, {})
|
||||
return int(entry.get("visits", 0)) if typeof(entry) == TYPE_DICTIONARY else 0
|
||||
|
||||
|
||||
func story_line_count(id: String) -> int:
|
||||
if not is_guest_unlocked(id):
|
||||
return 0
|
||||
var visits := guest_visits(id)
|
||||
if visits >= 7:
|
||||
return 3
|
||||
if visits >= 3:
|
||||
return 2
|
||||
return 1
|
||||
|
||||
|
||||
static var _events_cache: Array = []
|
||||
|
||||
|
||||
static func event_defs() -> Array:
|
||||
if _events_cache.is_empty():
|
||||
var path := "res://data/events.json"
|
||||
if FileAccess.file_exists(path):
|
||||
var file := FileAccess.open(path, FileAccess.READ)
|
||||
if file != null:
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_ARRAY:
|
||||
_events_cache = parsed
|
||||
return _events_cache
|
||||
|
||||
|
||||
static func event_cycle_length() -> int:
|
||||
var total := 0
|
||||
for event in event_defs():
|
||||
total += max(1, int(event.get("duration_days", 3)))
|
||||
return max(1, total)
|
||||
|
||||
|
||||
func current_event() -> Dictionary:
|
||||
var defs := event_defs()
|
||||
if defs.is_empty():
|
||||
return {}
|
||||
var day := int(floor(Time.get_unix_time_from_system() / 86400.0))
|
||||
var cycle := day / event_cycle_length()
|
||||
var position := day % event_cycle_length()
|
||||
var start := 0
|
||||
for event in defs:
|
||||
var duration := max(1, int(event.get("duration_days", 3)))
|
||||
if position < start + duration:
|
||||
var out: Dictionary = (event as Dictionary).duplicate(true)
|
||||
out["cycle"] = cycle
|
||||
out["day_in_event"] = position - start
|
||||
return out
|
||||
start += duration
|
||||
var out: Dictionary = (defs[defs.size() - 1] as Dictionary).duplicate(true)
|
||||
out["cycle"] = cycle
|
||||
out["day_in_event"] = max(0, position - start)
|
||||
return out
|
||||
|
||||
|
||||
func event_state(id: String, cycle: int) -> Dictionary:
|
||||
var events: Dictionary = data.get("events", {})
|
||||
var entry = events.get(id, {})
|
||||
if typeof(entry) != TYPE_DICTIONARY or int(entry.get("cycle", -1)) != cycle:
|
||||
return {"cycle": cycle, "progress": 0, "claimed": false, "last_date": ""}
|
||||
return (entry as Dictionary).duplicate(true)
|
||||
|
||||
|
||||
func record_daily_event_progress(date_key: String) -> void:
|
||||
var event := current_event()
|
||||
var id := str(event.get("id", ""))
|
||||
if id.is_empty():
|
||||
return
|
||||
var cycle := int(event.get("cycle", 0))
|
||||
var entry: Dictionary = event_state(id, cycle)
|
||||
if str(entry.get("last_date", "")) == date_key:
|
||||
return
|
||||
entry["cycle"] = cycle
|
||||
entry["last_date"] = date_key
|
||||
entry["progress"] = min(3, int(entry.get("progress", 0)) + 1)
|
||||
var events: Dictionary = data.get("events", {})
|
||||
events[id] = entry
|
||||
data["events"] = events
|
||||
save_game()
|
||||
|
||||
|
||||
func event_progress(id: String = "") -> int:
|
||||
var event := current_event()
|
||||
var event_id := id if not id.is_empty() else str(event.get("id", ""))
|
||||
return int(event_state(event_id, int(event.get("cycle", 0))).get("progress", 0))
|
||||
|
||||
|
||||
func event_claimable(id: String) -> bool:
|
||||
var event := current_event()
|
||||
var entry: Dictionary = event_state(id, int(event.get("cycle", 0)))
|
||||
return int(entry.get("progress", 0)) >= 3 and not bool(entry.get("claimed", false))
|
||||
|
||||
|
||||
func claim_event(id: String) -> bool:
|
||||
var event := current_event()
|
||||
var cycle := int(event.get("cycle", 0))
|
||||
var entry: Dictionary = event_state(id, cycle)
|
||||
if int(entry.get("progress", 0)) < 3 or bool(entry.get("claimed", false)):
|
||||
return false
|
||||
entry["claimed"] = true
|
||||
var events: Dictionary = data.get("events", {})
|
||||
events[id] = entry
|
||||
data["events"] = events
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
return true
|
||||
|
||||
|
||||
func event_claimed(id: String) -> bool:
|
||||
var events: Dictionary = data.get("events", {})
|
||||
var entry = events.get(id, {})
|
||||
return typeof(entry) == TYPE_DICTIONARY and bool(entry.get("claimed", false))
|
||||
|
||||
|
||||
func claimed_event_frames() -> Array:
|
||||
var out: Array = []
|
||||
var events: Dictionary = data.get("events", {})
|
||||
for def in event_defs():
|
||||
var id := str(def.get("id", ""))
|
||||
var entry = events.get(id, {})
|
||||
if typeof(entry) == TYPE_DICTIONARY and bool(entry.get("claimed", false)):
|
||||
out.append(str(def.get("reward_frame", "")))
|
||||
return out
|
||||
|
||||
|
||||
func daily_data() -> Dictionary:
|
||||
if typeof(data.get("daily")) != TYPE_DICTIONARY:
|
||||
data["daily"] = _default_daily()
|
||||
@@ -275,6 +429,7 @@ func complete_daily(key: String, seconds: int = 0) -> bool:
|
||||
history.pop_front()
|
||||
daily["history"] = history
|
||||
data["daily"] = daily
|
||||
record_daily_event_progress(key)
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
return true
|
||||
|
||||
+126
-10
@@ -12,10 +12,14 @@ var hold_value: Label
|
||||
var hold_panel: PanelContainer
|
||||
var music_volume_slider: HSlider
|
||||
var difficulty_button: Button
|
||||
var ui_scale_button: Button
|
||||
var theme_button: Button
|
||||
var wallpaper_layer: ColorRect
|
||||
var wallpaper_grid: GridContainer
|
||||
var pending_theme := "cream"
|
||||
var difficulty_layer: ColorRect
|
||||
var difficulty_grid: VBoxContainer
|
||||
var pending_difficulty := "normal"
|
||||
var game_actions: HBoxContainer
|
||||
var reset_row: Control
|
||||
var resume_button: Button
|
||||
@@ -77,7 +81,7 @@ func _ready() -> void:
|
||||
|
||||
var close := UI.button("×", false, 36)
|
||||
close.custom_minimum_size = Vector2(42, 36)
|
||||
close.add_theme_font_size_override("font_size", 24)
|
||||
UI.set_font_size(close, 24)
|
||||
close.pressed.connect(_close)
|
||||
header.add_child(close)
|
||||
|
||||
@@ -95,12 +99,16 @@ func _ready() -> void:
|
||||
_add_pattern_row(list)
|
||||
_add_toggle(list, "Show timer", "Keep the clock visible while you solve.", "show_timer")
|
||||
_add_toggle(list, "Reduce motion", "Stop the bob and placement pop.", "reduce_motion")
|
||||
_add_toggle(list, "Haptics", "Light vibration on Android.", "haptics")
|
||||
_add_toggle(list, "Double-tap to place", "Tap = mark · double-tap = check in.", "double_tap_place")
|
||||
_add_toggle(list, "Music", "Play the hotel lounge loop.", "music")
|
||||
_add_toggle(list, "Sound effects", "UI and completion chimes.", "sfx")
|
||||
_add_slider_row(list, "Music volume", "Lounge loop loudness.", "music_volume")
|
||||
ui_scale_button = UI.button("Text size: Normal", false, 40)
|
||||
ui_scale_button.pressed.connect(_cycle_ui_scale)
|
||||
list.add_child(ui_scale_button)
|
||||
difficulty_button = UI.button("Difficulty: Normal", false, 40)
|
||||
difficulty_button.pressed.connect(_cycle_difficulty)
|
||||
difficulty_button.pressed.connect(_open_difficulty_picker)
|
||||
list.add_child(difficulty_button)
|
||||
theme_button = UI.button("Wallpaper: Cream", false, 40)
|
||||
theme_button.pressed.connect(_open_wallpaper_picker)
|
||||
@@ -109,7 +117,7 @@ func _ready() -> void:
|
||||
|
||||
list.add_child(UI.spacer(2))
|
||||
var rules := UI.button("How to play", false, 44)
|
||||
rules.add_theme_font_size_override("font_size", 15)
|
||||
UI.set_font_size(rules, 15)
|
||||
rules.pressed.connect(func() -> void: rules_requested.emit())
|
||||
list.add_child(rules)
|
||||
|
||||
@@ -124,6 +132,7 @@ func _ready() -> void:
|
||||
UI.pass_scroll_input(list)
|
||||
|
||||
_build_wallpaper_picker()
|
||||
_build_difficulty_picker()
|
||||
|
||||
game_actions = HBoxContainer.new()
|
||||
game_actions.add_theme_constant_override("separation", 6)
|
||||
@@ -131,14 +140,14 @@ func _ready() -> void:
|
||||
|
||||
var restart := UI.button("Restart", false, 40)
|
||||
restart.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
restart.add_theme_font_size_override("font_size", 14)
|
||||
UI.set_font_size(restart, 14)
|
||||
restart.add_theme_color_override("font_color", Palette.RED)
|
||||
restart.pressed.connect(_on_restart)
|
||||
game_actions.add_child(restart)
|
||||
|
||||
var lobby := UI.button("Lobby", false, 40)
|
||||
lobby.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
lobby.add_theme_font_size_override("font_size", 14)
|
||||
UI.set_font_size(lobby, 14)
|
||||
lobby.pressed.connect(_on_lobby)
|
||||
game_actions.add_child(lobby)
|
||||
|
||||
@@ -246,6 +255,10 @@ func refresh() -> void:
|
||||
music_volume_slider.set_value_no_signal(float(SaveGame.get_setting("music_volume")))
|
||||
if difficulty_button != null:
|
||||
difficulty_button.text = "Difficulty: %s" % str(SaveGame.get_setting("difficulty")).capitalize()
|
||||
if ui_scale_button != null:
|
||||
var scale := float(SaveGame.get_setting("ui_scale"))
|
||||
var size_name := "Normal" if is_equal_approx(scale, 1.0) else ("Large" if is_equal_approx(scale, 1.15) else "Extra large")
|
||||
ui_scale_button.text = "Text size: %s" % size_name
|
||||
if theme_button != null:
|
||||
var theme: Dictionary = SaveGame.THEMES.get(SaveGame.theme_id(), {})
|
||||
theme_button.text = "Wallpaper: %s" % str(theme.get("name", "Cream"))
|
||||
@@ -324,11 +337,114 @@ func _add_slider_row(parent: VBoxContainer, title: String, detail: String, key:
|
||||
music_volume_slider = slider
|
||||
|
||||
|
||||
func _cycle_difficulty() -> void:
|
||||
var order := ["zen", "easy", "normal"]
|
||||
var current := str(SaveGame.get_setting("difficulty"))
|
||||
func _cycle_ui_scale() -> void:
|
||||
var order := [1.0, 1.15, 1.3]
|
||||
var current := float(SaveGame.get_setting("ui_scale"))
|
||||
var next_index := (order.find(current) + 1) % order.size()
|
||||
SaveGame.set_setting("difficulty", order[next_index])
|
||||
SaveGame.set_setting("ui_scale", order[next_index])
|
||||
refresh()
|
||||
|
||||
|
||||
func _open_difficulty_picker() -> void:
|
||||
pending_difficulty = str(SaveGame.get_setting("difficulty"))
|
||||
_build_difficulty_grid()
|
||||
difficulty_layer.visible = true
|
||||
difficulty_layer.move_to_front()
|
||||
|
||||
|
||||
func _build_difficulty_picker() -> void:
|
||||
difficulty_layer = ColorRect.new()
|
||||
difficulty_layer.color = Color(0.18, 0.12, 0.08, 0.62)
|
||||
difficulty_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
difficulty_layer.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
difficulty_layer.gui_input.connect(func(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
difficulty_layer.visible = false
|
||||
)
|
||||
difficulty_layer.visible = false
|
||||
add_child(difficulty_layer)
|
||||
|
||||
var center := CenterContainer.new()
|
||||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
difficulty_layer.add_child(center)
|
||||
var panel := UI.panel(Palette.CREAM, 24, 16)
|
||||
var view_size := get_viewport_rect().size
|
||||
panel.custom_minimum_size = Vector2(min(360, max(280, int(view_size.x) - 32)), max(280, min(400, int(view_size.y) - 96)))
|
||||
center.add_child(panel)
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(box)
|
||||
box.add_child(UI.heading("Difficulty", 20))
|
||||
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.custom_minimum_size = Vector2(0, 190)
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
box.add_child(scroll)
|
||||
difficulty_grid = VBoxContainer.new()
|
||||
difficulty_grid.add_theme_constant_override("separation", 6)
|
||||
difficulty_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
scroll.add_child(difficulty_grid)
|
||||
|
||||
var actions := HBoxContainer.new()
|
||||
actions.add_theme_constant_override("separation", 8)
|
||||
box.add_child(actions)
|
||||
var cancel := UI.button("Cancel", false, 46)
|
||||
cancel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
cancel.pressed.connect(func() -> void: difficulty_layer.visible = false)
|
||||
actions.add_child(cancel)
|
||||
var confirm := UI.button("Apply", true, 46)
|
||||
confirm.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
confirm.pressed.connect(_apply_difficulty)
|
||||
actions.add_child(confirm)
|
||||
|
||||
|
||||
func _difficulty_detail(id: String) -> String:
|
||||
if id == "zen":
|
||||
return "No timer. Rule strip always shown. Take your time."
|
||||
if id == "easy":
|
||||
return "Timer visible. Rule strip always shown."
|
||||
return "Timer visible. Rule strip only in the first rooms."
|
||||
|
||||
|
||||
func _build_difficulty_grid() -> void:
|
||||
for child in difficulty_grid.get_children():
|
||||
child.queue_free()
|
||||
for id in ["zen", "easy", "normal"]:
|
||||
var card := Button.new()
|
||||
card.custom_minimum_size = Vector2(0, 62)
|
||||
card.flat = true
|
||||
card.add_theme_stylebox_override("normal", _card_style(Palette.GOLD if id == pending_difficulty else Palette.PAPER))
|
||||
card.add_theme_stylebox_override("hover", _card_style(Palette.PAPER_DARK))
|
||||
card.pressed.connect(_select_pending_difficulty.bind(str(id)))
|
||||
var column := VBoxContainer.new()
|
||||
column.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
column.add_theme_constant_override("separation", 2)
|
||||
column.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
card.add_child(column)
|
||||
var title := UI.label(str(id).capitalize(), 14)
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
column.add_child(title)
|
||||
var detail := UI.label(_difficulty_detail(str(id)), 10, Palette.MUTED)
|
||||
detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
column.add_child(detail)
|
||||
difficulty_grid.add_child(card)
|
||||
UI.pass_scroll_input(difficulty_grid)
|
||||
|
||||
|
||||
func _select_pending_difficulty(id: String) -> void:
|
||||
call_deferred("_set_pending_difficulty", id)
|
||||
|
||||
|
||||
func _set_pending_difficulty(id: String) -> void:
|
||||
pending_difficulty = id
|
||||
_build_difficulty_grid()
|
||||
|
||||
|
||||
func _apply_difficulty() -> void:
|
||||
SaveGame.set_setting("difficulty", pending_difficulty)
|
||||
difficulty_layer.visible = false
|
||||
refresh()
|
||||
|
||||
|
||||
@@ -533,7 +649,7 @@ func _action_row(title: String, detail: String, color: Color, callback: Callable
|
||||
|
||||
var go := UI.button("›", false, 34)
|
||||
go.custom_minimum_size = Vector2(38, 34)
|
||||
go.add_theme_font_size_override("font_size", 18)
|
||||
UI.set_font_size(go, 18)
|
||||
go.pressed.connect(callback)
|
||||
row.add_child(go)
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ func _ready() -> void:
|
||||
content.add_child(gift_status)
|
||||
|
||||
var share := UI.button("Share result", false, 44)
|
||||
share.add_theme_font_size_override("font_size", 14)
|
||||
UI.set_font_size(share, 14)
|
||||
share.pressed.connect(_share_result)
|
||||
content.add_child(share)
|
||||
|
||||
|
||||
+59
-3
@@ -40,13 +40,66 @@ static func body_font() -> Font:
|
||||
return _body_font
|
||||
|
||||
|
||||
## The SaveGame autoload, fetched dynamically so helper scripts can compile
|
||||
## before autoloads are registered (headless --script runs do exactly that).
|
||||
static func _save_node() -> Node:
|
||||
var loop := Engine.get_main_loop()
|
||||
if loop is SceneTree:
|
||||
return (loop as SceneTree).root.get_node_or_null("SaveGame")
|
||||
return null
|
||||
|
||||
|
||||
## User-facing UI scale (1.0 / 1.15 / 1.3), defaulting to 1.0 if missing or bad.
|
||||
static func ui_scale() -> float:
|
||||
var save := _save_node()
|
||||
if save == null:
|
||||
return 1.0
|
||||
var value: Variant = save.get_setting("ui_scale")
|
||||
var type := typeof(value)
|
||||
if type == TYPE_FLOAT or type == TYPE_INT or type == TYPE_STRING:
|
||||
var scale := float(value)
|
||||
if scale > 0.0 and is_finite(scale):
|
||||
return scale
|
||||
return 1.0
|
||||
|
||||
|
||||
## Font size with the UI scale applied, never below the 8 px minimum.
|
||||
static func _scaled_font_size(base_size: int) -> int:
|
||||
return int(max(8, round(base_size * ui_scale())))
|
||||
|
||||
|
||||
## Light haptic feedback on Android. Strong is used for wins and unlocks.
|
||||
static func haptic(strong: bool = false) -> void:
|
||||
var save := _save_node()
|
||||
if save == null or not bool(save.get_setting("haptics")):
|
||||
return
|
||||
if OS.get_name() == "Android":
|
||||
Input.vibrate_handheld(55 if strong else 18)
|
||||
|
||||
|
||||
## Sets a per-control font size while keeping it eligible for live text scaling.
|
||||
static func set_font_size(control: Control, base_size: int) -> void:
|
||||
control.set_meta("base_font_size", base_size)
|
||||
control.add_theme_font_size_override("font_size", _scaled_font_size(base_size))
|
||||
|
||||
|
||||
## Re-applies the saved text scale to controls that are already on screen.
|
||||
static func apply_scale(root: Node) -> void:
|
||||
if root is Control and root.has_meta("base_font_size"):
|
||||
var base := int(root.get_meta("base_font_size"))
|
||||
root.add_theme_font_size_override("font_size", _scaled_font_size(base))
|
||||
for child in root.get_children():
|
||||
apply_scale(child)
|
||||
|
||||
|
||||
static func label(text: String, font_size: int = BODY, color: Color = Palette.INK, heading: bool = false) -> Label:
|
||||
var l := Label.new()
|
||||
l.text = text
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
l.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
l.add_theme_font_size_override("font_size", font_size)
|
||||
l.set_meta("base_font_size", font_size)
|
||||
l.add_theme_font_size_override("font_size", _scaled_font_size(font_size))
|
||||
l.add_theme_color_override("font_color", color)
|
||||
l.add_theme_font_override("font", heading_font() if (heading or font_size >= 28) else body_font())
|
||||
return l
|
||||
@@ -68,8 +121,9 @@ static func button(text: String, primary: bool = false, min_height: int = BTN_H)
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.custom_minimum_size = Vector2(0, min_height)
|
||||
b.set_meta("base_font_size", BTN_FONT)
|
||||
b.add_theme_font_override("font", heading_font())
|
||||
b.add_theme_font_size_override("font_size", BTN_FONT)
|
||||
b.add_theme_font_size_override("font_size", _scaled_font_size(BTN_FONT))
|
||||
b.add_theme_color_override("font_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_color_override("font_hover_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_color_override("font_pressed_color", Palette.WHITE if primary else Palette.INK)
|
||||
@@ -157,7 +211,9 @@ static func pass_scroll_input(root: Node, skip: Array = []) -> void:
|
||||
|
||||
## Short control hint that follows the saved placement mode.
|
||||
static func place_hint() -> String:
|
||||
if bool(SaveGame.get_setting("double_tap_place")):
|
||||
var save := _save_node()
|
||||
var double_tap := true if save == null else bool(save.get_setting("double_tap_place"))
|
||||
if double_tap:
|
||||
return "Tap = X · Double-tap or right-click = check in"
|
||||
return "Tap = X · Hold or right-click = check in"
|
||||
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
class_name Version
|
||||
extends RefCounted
|
||||
|
||||
const NUMBER := "0.8.1-alpha"
|
||||
const CODENAME := "UI Polish"
|
||||
const BUILD_DATE := "2026-12-04"
|
||||
const BUILD_LABEL := "v0.8.1-alpha · build 2026-12-04"
|
||||
const NUMBER := "0.9.0-alpha"
|
||||
const CODENAME := "Hotel Life"
|
||||
const BUILD_DATE := "2026-12-05"
|
||||
const BUILD_LABEL := "v0.9.0-alpha · build 2026-12-05"
|
||||
Reference in new issue
Block a user