Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbfc35f79c | ||
|
|
077c08bb5f | ||
|
|
48c14864a4 | ||
|
|
3c2ead0be1 | ||
|
|
04eba25286 | ||
|
|
7e6a338240 | ||
|
|
77ff5b48de | ||
|
|
82c5691d2e | ||
|
|
15e79ae38c | ||
|
|
d679a12e1d | ||
|
|
dffdee63a6 | ||
|
|
af4951baf8 | ||
|
|
bed81a2e05 | ||
|
|
5402541f59 | ||
|
|
c6a86d74d9 | ||
|
|
089f5d6171 | ||
|
|
46b5764144 | ||
|
|
f6fd807e9a | ||
|
|
f957cd3c4e |
No files matched your search
@@ -2,6 +2,71 @@
|
||||
|
||||
All notable alpha milestones for Ratdoku.
|
||||
|
||||
## v0.5.1-alpha — QA & Stability
|
||||
|
||||
- Fixed a crash when selecting a profile frame: the frame grid no longer frees the card that is still emitting `pressed`.
|
||||
- Frame, avatar, and Guest Book frame rebuilds now use deferred/queued deletion so signal handlers never free live nodes.
|
||||
- Added QA suites for save migrations, daily streaks, frames, level data, navigation, and input gestures.
|
||||
- Added `tools/qa_all.ps1`: one command runs the class scan, every test suite, screenshots, an optional APK build, and fails on any engine error in the log.
|
||||
- Android debug APK rebuilt at version `0.5.1` (version code 9).
|
||||
|
||||
## v0.5.0-alpha — Daily Rooms & Frames
|
||||
|
||||
- New **Daily room**: one of the 30 verified rooms each day, chosen deterministically from the local date.
|
||||
- Daily streak tracking with current and best streak; replaying the same day never counts twice, and a gap resets the streak.
|
||||
- Daily completion is separate from campaign progress and does not unlock guests. Undo and hints still work.
|
||||
- New **Profile** screen reached from the framed Crumb avatar: rooms completed, streak stats, and a selectable frame grid.
|
||||
- Seven profile frames unlock at 5/10/20/30 rooms and 3/7-day best streaks; unlocks are permanent and selection persists.
|
||||
- Save format moves to version 3 with a one-time migration from older saves.
|
||||
- Android debug APK rebuilt at version `0.5.0` (version code 8).
|
||||
|
||||
## v0.4.3-alpha — Tap Twice
|
||||
|
||||
- Double-tap placement is now the default: tap marks X, two quick taps on the same cell check a guest in or out.
|
||||
- Existing version 1 saves migrate once to double-tap. Turning **Double-tap to place** off restores hold-to-place and keeps that choice.
|
||||
- Right-click still places guests in both modes.
|
||||
- Android debug APK rebuilt at version `0.4.3` (version code 7).
|
||||
|
||||
## v0.4.2-alpha — Swipe & Scroll
|
||||
|
||||
- Finger swipes now scroll the Guest Book even when they start on a card.
|
||||
- House Rules content passes swipes through labels and buttons, so the page scrolls anywhere outside the practice board.
|
||||
- Settings rows pass swipes through too, keeping every row scrollable while toggles, sliders, and buttons still tap normally.
|
||||
- Android debug APK rebuilt at version `0.4.2` (version code 6).
|
||||
|
||||
## v0.4.1-alpha — Front Desk Polish
|
||||
|
||||
- Guest Book cards only open on a short, stationary tap; dragging or flinging the list scrolls without opening a card.
|
||||
- The detail sheet ignores Close for a moment after opening, so the opening tap cannot dismiss it.
|
||||
- New **Double-tap to place** setting: tap marks X, two quick taps on the same cell check a guest in or out.
|
||||
- Hold remains the default; right-click places guests in both modes, and the hold-time slider dims in double-tap mode.
|
||||
- Home, House Rules, and the in-level hints follow the active placement mode.
|
||||
- Android debug APK rebuilt at version `0.4.1` (version code 5).
|
||||
|
||||
## v0.4.0-alpha — Lobby Redesign
|
||||
|
||||
- 360×640 dp layout with safe-area spacing on mobile.
|
||||
- Playful rounded-tile board, eight room motifs, and a per-level room legend.
|
||||
- Guest Book, Settings sheet, and Home restyled; in-level settings keeps Resume primary.
|
||||
- Smoke and UI tests updated; Android debug APK at version `0.4.0` (version code 4).
|
||||
|
||||
## v0.3.0-alpha — Thirty Rooms & Unique Guests
|
||||
|
||||
- 30 verified 8×8 rooms: 20 guest rooms plus 10 bonus rooms.
|
||||
- Unique guest head token per room on the board, deterministic per level.
|
||||
- Rooms 21–30 reuse the 25-guest cast on the board without unlocking new Guest Book entries.
|
||||
- Android debug APK rebuilt at version `0.3.0` (version code 3).
|
||||
- Includes the level generator and smoke/UI tests under `tools/`.
|
||||
|
||||
## v0.2.0-alpha — Guest Book & House Rules
|
||||
|
||||
- 20 verified 8×8 rooms and the 25-guest cast.
|
||||
- Guest Book gallery with five residents unlocked from the start and one guest unlocked per room.
|
||||
- Settings screen: region patterns, timer, reduce motion, hold-time slider, reset progress.
|
||||
- House Rules screen with illustrated rules, controls, tips, FAQ, and a 5×5 practice board.
|
||||
- Win overlay shows the newly unlocked guest.
|
||||
- Rats still use the shared Crumb head token; per-room guest tokens were not in this build.
|
||||
|
||||
## v0.1.0-alpha — First playable
|
||||
|
||||
- 20 verified 8×8 rooms.
|
||||
|
||||
@@ -1,69 +1,243 @@
|
||||
# Ratdoku — v0.1.0-alpha "First playable"
|
||||
# Ratdoku
|
||||
|
||||
A cozy rat-hotel logic puzzle. Every guest gets a room, a floor, a corridor, and a little space from the neighbours.
|
||||
|
||||
This is the reconstructed first playable alpha: **20 rooms**, the Crumb head token on the board, and the core Home → Game loop. The Guest Book, Settings, and House Rules screens did not exist yet.
|
||||
|
||||
## Run it
|
||||
|
||||
1. Install **Godot 4.7 or newer** (standard edition, not .NET).
|
||||
2. Open this folder in Godot (`project.godot`).
|
||||
3. Press **F5**.
|
||||
|
||||
The project uses a portrait 720×1280 canvas, scaled to a 540×960 desktop window.
|
||||
The project uses a portrait **360×640 dp canvas**, scaled to a 540×960 desktop window. On a tall phone it expands vertically instead of stretching the UI.
|
||||
|
||||
## How to play
|
||||
|
||||
- **Tap / left-click** a cell to mark it with an X. Tap an X or a guest to clear it.
|
||||
- **Press and hold** (mobile) or **right-click** (PC) to check a guest in.
|
||||
- **Undo**, **Restart**, and **Hint** are at the bottom.
|
||||
- **Double-tap** a cell to check a guest in or out. **Double-tap is on by default.**
|
||||
- Prefer holding? Turn off **Double-tap to place** in Settings, then **press and hold** (mobile) or **right-click** (PC) to check a guest in. Right-click keeps working in both modes.
|
||||
- In hold mode, a gold ring fills while you hold; at the hold threshold (default 0.35 s) the guest is placed.
|
||||
- **Undo** and **Hint** are at the bottom. **Restart room** and **Back to lobby** live in the in-level settings sheet.
|
||||
- The **Daily room** changes each day and tracks a streak. Replaying the same day never counts twice.
|
||||
- Tap **Crumb** in the top-left to open your Profile, where you can wear unlocked frames.
|
||||
- A **gold ring** around a guest means they are already checked in and cannot be moved.
|
||||
- Win when every room, floor, and corridor has exactly one rat and no two rats touch — even diagonally.
|
||||
- **No guessing is required.** Every room has exactly one solution.
|
||||
|
||||
Every rat uses Crumb's head token in this alpha; per-room guest tokens arrived with the Guest Book.
|
||||
## Each room has its own guest
|
||||
|
||||
Every level assigns **eight distinct guests** to its eight coloured rooms. The guest is the same across the whole room, so a blue room is always one specific rat, the yellow room another, and so on. The assignment is deterministic per level, and a level never repeats a guest across two rooms.
|
||||
|
||||
The board uses circular **head tokens** from `art/guests/heads/`. Crumb remains the host and appears on Home and in the win overlay.
|
||||
|
||||
### Pattern mode and the room legend
|
||||
|
||||
- **Pattern mode is on by default.** Each room carries a distinct motif — paw, cheese, key, bed, bell, leaf, fish, star — drawn over the colour. Turn it off in Settings for flat colours.
|
||||
- A **room legend** above the board shows the eight guests for the level, one per region colour. Solved rooms get a gold ring.
|
||||
- The **gear in the top-right opens settings over the puzzle**, so patterns, timer, motion, and placement mode can change without leaving the room. **Resume** is the primary action; restarting is deliberately secondary.
|
||||
|
||||
## Screens
|
||||
|
||||
- **Home** — top hub with framed Crumb avatar, guest progress, and settings; daily room card; Continue/Check in; Guest Book; House Rules.
|
||||
- **Game** — top bar, rule strip for the first three rooms, room legend, board, timer, undo/hint, in-level settings, win overlay.
|
||||
- **The Guest Book** — 25 guests: five residents unlocked from the start, the other 20 unlocked one per room. Locked cards show a very faint portrait under `???` and their room number. Tapping a card opens a detail sheet; swiping anywhere in the gallery scrolls it, including over cards.
|
||||
- **Settings** — a bottom sheet over Home or the board: room patterns, timer, reduce motion, double-tap placement (on by default), hold time, how to play, restart/back, reset progress.
|
||||
- **Profile** — Crumb's framed portrait, rooms completed, current and best daily streaks, and a selectable frame grid.
|
||||
- **House Rules** — four illustrated rules, controls, tips, FAQ, and an interactive 5×5 practice board.
|
||||
|
||||
## Unlocks
|
||||
|
||||
- **Residents** (available from the start): Miso, Hilde, Pip, Nana Fig, Biscuit.
|
||||
- **Room guests**: Pepper (Room 1) through Marmalade (Room 20).
|
||||
- **Rooms 21–30** are bonus rooms. They use the same guest cast on the board but do not unlock a new Guest Book entry.
|
||||
- Completing a room unlocks its guest and adds a “New guest” card to the win overlay.
|
||||
- Crumb is the host and has a pinned card; she is not one of the 25.
|
||||
|
||||
## Levels
|
||||
|
||||
`data/levels.json` contains **20 verified 8×8 puzzles**, each starting with three gold-ringed guests.
|
||||
`data/levels.json` contains **30 verified 8×8 puzzles**: 20 guest rooms plus 10 bonus rooms. Every board is generated from a legal solution, split into eight connected rooms, and checked for a single solution. Each starts with three gold-ringed guests.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
scenes/
|
||||
Main.tscn entry point + screen navigation
|
||||
Home.tscn title screen
|
||||
Game.tscn board screen + HUD + win overlay
|
||||
Board.tscn custom-drawn board
|
||||
Main.tscn entry point + screen navigation
|
||||
Home.tscn title screen
|
||||
Game.tscn board screen + HUD + win overlay
|
||||
Board.tscn custom-drawn board
|
||||
GuestBook.tscn gallery
|
||||
SettingsSheet.tscn bottom-sheet settings
|
||||
Rulebook.tscn house rules + interactive tutorial
|
||||
scripts/
|
||||
Main.gd navigation/back stack
|
||||
Home.gd home screen
|
||||
Game.gd level flow, timer, win overlay
|
||||
Board.gd drawing, input, undo, hints
|
||||
Rules.gd pure win/conflict rules
|
||||
Levels.gd JSON level loader
|
||||
Guests.gd guest manifest loader
|
||||
SaveGame.gd autoload: settings + progress
|
||||
Palette.gd colours
|
||||
UI.gd button/label/panel helpers
|
||||
RatPortrait.gd fallback vector mascot
|
||||
Main.gd navigation/back stack + sheet routing
|
||||
Home.gd top hub + home screen
|
||||
Game.gd level flow, legend, rule strip, timer, win overlay
|
||||
Board.gd rounded tiles, motifs, input, undo, hints, per-room guests
|
||||
Rules.gd pure win/conflict rules
|
||||
Levels.gd JSON level loader
|
||||
Guests.gd guest manifest loader
|
||||
SaveGame.gd autoload: settings + progress
|
||||
GuestBook.gd gallery, locked cards, detail sheet
|
||||
SettingsSheet.gd shared settings sheet
|
||||
Rulebook.gd handbook content + 5×5 tutorial
|
||||
MiniDiagram.gd rule illustrations
|
||||
Palette.gd colours
|
||||
UI.gd 360dp tokens, fonts, buttons, icons
|
||||
Version.gd version/build label
|
||||
RatPortrait.gd fallback vector mascot
|
||||
assets/
|
||||
fonts/ Fredoka + Nunito (OFL)
|
||||
icons/ Lucide SVG icon set
|
||||
art/
|
||||
crumb.png, crumb_head.png
|
||||
guests/{cards,thumbs,heads}/<id>.png
|
||||
crumb.png full mascot
|
||||
crumb_head.png circular head token used on Home/win
|
||||
guests/
|
||||
cards/<id>.png 512 detail portraits
|
||||
thumbs/<id>.png 256 gallery thumbnails
|
||||
heads/<id>.png 256 circular board tokens
|
||||
source/ 1024 originals, raw renders, contact sheets (ignored by Godot/export)
|
||||
data/
|
||||
levels.json 20 verified 8×8 puzzles
|
||||
guests.json 25 guest entries
|
||||
tutorial.json 5×5 practice puzzle
|
||||
levels.json 30 verified 8×8 puzzles
|
||||
guests.json 25 guest entries
|
||||
tutorial.json 5×5 practice puzzle
|
||||
tools/
|
||||
generate_levels.gd headless 8×8 generator (appends new rooms)
|
||||
smoke_test.gd rules/board smoke test
|
||||
ui_test.gd settings/gallery/unlock/tutorial test
|
||||
screenshot.gd dev screenshots
|
||||
build_android.ps1 Android export helper
|
||||
workflows/ Krea2 guest-generation variants
|
||||
export_presets.cfg Android debug preset
|
||||
build/Ratdoku.apk installable debug APK
|
||||
```
|
||||
|
||||
## Save data
|
||||
|
||||
`user://ratdoku_save.json` stores completed rooms, `last_room`, and settings.
|
||||
`user://ratdoku_save.json` stores completed rooms, unlocked guests, `last_room`, and settings. “Reset progress” clears rooms and unlocks but keeps settings.
|
||||
|
||||
## Regenerate levels
|
||||
|
||||
```powershell
|
||||
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
|
||||
--headless --path . --script res://tools/generate_levels.gd
|
||||
```
|
||||
|
||||
The generator appends until `data/levels.json` contains 30 rooms. It keeps the existing pack and only creates the missing rooms.
|
||||
|
||||
## Guest art
|
||||
|
||||
The 25 guest portraits were generated from the `Krea2_Turbo_Uncensored` ComfyUI workflow with a shared chibi/gouache prompt and per-character props. The final prompt variants are in `tools/workflows/final_guests/`.
|
||||
|
||||
Runtime assets:
|
||||
|
||||
- `art/guests/heads/<id>.png` — board tokens
|
||||
- `art/guests/cards/<id>.png` — detail portraits
|
||||
- `art/guests/thumbs/<id>.png` — gallery thumbnails
|
||||
|
||||
Source 1024 renders and contact sheets live in `art/guests/source/` and are excluded from the Android export.
|
||||
|
||||
## Android APK
|
||||
|
||||
`build/Ratdoku-v0.1.0-alpha.apk` is a debug-signed, arm64-v8a build:
|
||||
The current APK is:
|
||||
|
||||
```
|
||||
build/Ratdoku.apk
|
||||
```
|
||||
|
||||
It is a **debug-signed, arm64-v8a** APK:
|
||||
|
||||
- Package: `com.ratdoku.game`
|
||||
- Version: `0.1.0` (version code 1)
|
||||
- Version: `0.5.1` (version code 9)
|
||||
- Min SDK: 24 (Android 7.0)
|
||||
- Target SDK: 36
|
||||
- Size: about 41 MB
|
||||
- Portrait orientation
|
||||
- Build label: `v0.5.1-alpha · build 2026-12-02`
|
||||
|
||||
To install, copy the APK to the phone, open it, and allow “Install unknown apps” for the file manager/browser. Or with a USB-connected phone and USB debugging:
|
||||
|
||||
```powershell
|
||||
& "E:\AndroidTools\sdk\platform-tools\adb.exe" install -r "E:\Ahri\Documents\Ratdoku\Development\build\Ratdoku.apk"
|
||||
```
|
||||
|
||||
### Toolchain
|
||||
|
||||
The local Android build uses:
|
||||
|
||||
- JDK: `E:\AndroidTools\jdk-17.0.21.1+2`
|
||||
- Android SDK: `E:\AndroidTools\sdk`
|
||||
- Build tools: `35.0.0`
|
||||
- Godot editor settings: `export/android/android_sdk_path`, `java_sdk_path`, debug keystore.
|
||||
|
||||
Rebuild with:
|
||||
|
||||
```powershell
|
||||
.\tools\build_android.ps1
|
||||
```
|
||||
|
||||
If you want a Play Store build, switch `gradle_build/export_format` to AAB, use a release keystore, and set `package/signed` appropriately. The current APK is for direct testing, not store upload.
|
||||
|
||||
## Tests
|
||||
|
||||
```powershell
|
||||
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
|
||||
--headless --path . --script res://tools/smoke_test.gd
|
||||
```
|
||||
|
||||
```powershell
|
||||
& "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe" `
|
||||
--headless --path . --script res://tools/ui_test.gd
|
||||
```
|
||||
|
||||
`ui_test.gd` checks the double-tap default and version 1 migration, daily streak math and level selection, frame unlocks and selection persistence, settings propagation, hold/double-tap placement, tap-vs-drag guards in the Guest Book, scroll pass-through over cards and rules rows, the close guard, room-1 → Pepper unlock, gallery progress, and the interactive 5×5 tutorial. Both tests reset the save when they finish.
|
||||
|
||||
Run the whole QA suite (class scan, every test script, log-error scan, optional screenshots, optional APK build) with:
|
||||
|
||||
```powershell
|
||||
.\tools\qa_all.ps1 -Screenshots -Build
|
||||
```
|
||||
|
||||
`qa_all.ps1` fails if any suite is missing, a script does not print its PASS marker, or Godot logs any `ERROR` / `SCRIPT ERROR`. The `qa_core.gd`, `qa_ui.gd`, and `qa_input.gd` suites cover save migrations, daily and frame data, navigation and win overlays, and all input gestures.
|
||||
|
||||
## Versioning and releases
|
||||
|
||||
The current development build is **v0.5.1-alpha** (“QA & Stability”) with the build label on Home and in Settings.
|
||||
|
||||
Gitea repository:
|
||||
|
||||
`https://gitea.nyxara.cc/Ahri-the-Vastaya/Ratdoku`
|
||||
|
||||
Alpha releases (all marked prerelease, each with a debug APK and source archive):
|
||||
|
||||
- **v0.1.0-alpha** — first playable 20-room prototype
|
||||
- **v0.2.0-alpha** — Guest Book, Settings, House Rules, 25 guests
|
||||
- **v0.3.0-alpha** — 30 rooms, unique guest per room, Android APK
|
||||
- **v0.4.0-alpha** — 360dp redesign, pattern motifs, room legend, in-level settings
|
||||
- **v0.4.1-alpha** — Guest Book tap/scroll guards, close guard, double-tap placement
|
||||
- **v0.4.2-alpha** — finger scrolling works over Guest Book cards, House Rules rows, and Settings rows
|
||||
- **v0.4.3-alpha** — double-tap placement is the default, with a one-time migration for older saves
|
||||
- **v0.5.0-alpha** — daily room with streaks, Profile screen, and selectable profile frames
|
||||
- **v0.5.1-alpha** — profile frame selection crash fix, QA suites, and log-guarded test runner
|
||||
|
||||
https://gitea.nyxara.cc/Ahri-the-Vastaya/Ratdoku/releases/tag/v0.5.1-alpha
|
||||
|
||||
The v0.5.1-alpha APK is also at:
|
||||
|
||||
`https://gitea.nyxara.cc/Ahri-the-Vastaya/Ratdoku/releases/download/v0.5.1-alpha/Ratdoku-v0.5.1-alpha.apk`
|
||||
|
||||
`redesign-360` is the branch with the current 360dp work; it is tagged `v0.5.1-alpha`.
|
||||
|
||||
The version is set in three places: `project.godot` (`config/version`), `scripts/Version.gd` (display label), and `export_presets.cfg` (`version/name`, `version/code`).
|
||||
|
||||
## Current scope
|
||||
|
||||
- 30 verified 8×8 rooms (20 guest rooms + 10 bonus)
|
||||
- Unique guest per room per level
|
||||
- 360dp layout, Fredoka/Nunito typography, Lucide icons
|
||||
- Playful rounded tiles, 8 pattern motifs, room legend
|
||||
- In-level settings sheet with patterns/timer/motion/placement mode/restart/lobby
|
||||
- Interactive 5×5 tutorial
|
||||
- 25 guest portraits + Crumb
|
||||
- Settings, gallery, rulebook, unlock flow
|
||||
- Daily room with streaks, Profile screen, selectable frames (save version 3)
|
||||
- Installable Android debug APK
|
||||
- No audio yet, no release keystore/AAB yet
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2016 The Fredoka Project Authors (https://github.com/hafontia/Fredoka-One)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2014 The Nunito Project Authors (https://github.com/googlefonts/nunito)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m12 19-7-7 7-7" />
|
||||
<path d="M19 12H5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 262 B |
@@ -0,0 +1,16 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M2 4v16" />
|
||||
<path d="M2 8h18a2 2 0 0 1 2 2v10" />
|
||||
<path d="M2 17h20" />
|
||||
<path d="M6 8v9" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 317 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M10.268 21a2 2 0 0 0 3.464 0" />
|
||||
<path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 393 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 5v16" />
|
||||
<path d="M20.001 19A2 2 0 0 0 22 17V5a2 2 0 0 0-1.999-2L16 3.002A5 5 0 0 0 12 5a5 5 0 0 0-4-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 1.999 2H8a5 5 0 0 1 4 2 5 5 0 0 1 4-2z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 400 B |
@@ -0,0 +1,13 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m6 9 6 6 6-6" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 236 B |
@@ -0,0 +1,18 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M6.5 12c.94-3.46 4.94-6 8.5-6s6.06 2.54 7 6c-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6" />
|
||||
<path d="M18 12v.5" />
|
||||
<path d="M16 17.93a9.77 9.77 0 0 1 0-11.86" />
|
||||
<path d="M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33" />
|
||||
<path d="M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4" />
|
||||
<path d="m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 660 B |
@@ -0,0 +1,13 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 314 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="m2 21 9.6-9.6" />
|
||||
<path d="m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19" />
|
||||
<circle cx="15.5" cy="7.5" r="5.5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 356 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M11 20a10 10 0 0 0 10-10 25.9 25.9 0 0 0-1.04-7.281 1 1 0 0 0-1.755-.325C15.833 5.5 13 5.5 9.8 6.1A7 7 0 0 0 11 20" />
|
||||
<path d="M2 21a5 5 0 0 1 2.911-4.544C7.613 15.212 8.351 15.24 11 13" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 412 B |
@@ -0,0 +1,15 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" />
|
||||
<path d="M9 18h6" />
|
||||
<path d="M10 22h4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 371 B |
@@ -0,0 +1,16 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="4" r="2" />
|
||||
<circle cx="18" cy="8" r="2" />
|
||||
<circle cx="20" cy="16" r="2" />
|
||||
<path d="M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045q-.64-2.065-2.7-2.705A3.5 3.5 0 0 1 5.5 10Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 418 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
||||
<path d="M3 3v5h5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 297 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 586 B |
@@ -0,0 +1,13 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.12 2.12 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 578 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M9 14 4 9l5-5" />
|
||||
<path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5 5.5 5.5 0 0 1-5.5 5.5H11" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 309 B |
@@ -9,7 +9,7 @@ custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter="data/*.json"
|
||||
exclude_filter="art/guests/source/*"
|
||||
export_path="build/Ratdoku-v0.1.0-alpha.apk"
|
||||
export_path="build/Ratdoku.apk"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
@@ -32,8 +32,8 @@ architectures/armeabi-v7a=false
|
||||
architectures/arm64-v8a=true
|
||||
architectures/x86=false
|
||||
architectures/x86_64=false
|
||||
version/code=1
|
||||
version/name="0.1.0"
|
||||
version/code=9
|
||||
version/name="0.5.1"
|
||||
package/unique_name="com.ratdoku.game"
|
||||
package/name="Ratdoku"
|
||||
package/signed=true
|
||||
|
||||
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="Ratdoku"
|
||||
run/main_scene="res://scenes/Main.tscn"
|
||||
config/version="0.1.0-alpha"
|
||||
config/version="0.5.1-alpha"
|
||||
config/features=PackedStringArray("4.7", "GL Compatibility")
|
||||
config/icon="res://icon.png"
|
||||
|
||||
@@ -22,8 +22,8 @@ SaveGame="*res://scripts/SaveGame.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=720
|
||||
window/size/viewport_height=1280
|
||||
window/size/viewport_width=360
|
||||
window/size/viewport_height=640
|
||||
window/size/window_width_override=540
|
||||
window/size/window_height_override=960
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/GuestBook.gd" id="1_guestbook"]
|
||||
|
||||
[node name="GuestBook" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_guestbook")
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Profile.gd" id="1_profile"]
|
||||
|
||||
[node name="Profile" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_profile")
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Rulebook.gd" id="1_rulebook"]
|
||||
|
||||
[node name="Rulebook" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_rulebook")
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/SettingsSheet.gd" id="1_settings_sheet"]
|
||||
|
||||
[node name="SettingsSheet" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_settings_sheet")
|
||||
@@ -11,6 +11,7 @@ signal mistake
|
||||
const EMPTY := 0
|
||||
const X := 1
|
||||
const RAT := 2
|
||||
const DOUBLE_TAP_MS := 220
|
||||
|
||||
var n := 8
|
||||
var regions: Array = []
|
||||
@@ -33,10 +34,15 @@ var hold_fired := false
|
||||
var hold_seconds := 0.35
|
||||
var show_patterns := true
|
||||
var reduce_motion := false
|
||||
var double_tap_place := false
|
||||
var pending_tap_cell := Vector2i(-1, -1)
|
||||
var pending_tap_at := 0
|
||||
var region_rats: Array = []
|
||||
var region_textures := {}
|
||||
|
||||
var rat_texture: Texture2D = null
|
||||
var cell_styles: Array = []
|
||||
var board_style: StyleBoxFlat
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -45,11 +51,36 @@ func _ready() -> void:
|
||||
if ResourceLoader.exists("res://art/crumb_head.png"):
|
||||
rat_texture = load("res://art/crumb_head.png")
|
||||
|
||||
for color in Palette.REGION_COLORS:
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = color
|
||||
style.corner_radius_top_left = 7
|
||||
style.corner_radius_top_right = 7
|
||||
style.corner_radius_bottom_left = 7
|
||||
style.corner_radius_bottom_right = 7
|
||||
cell_styles.append(style)
|
||||
|
||||
board_style = StyleBoxFlat.new()
|
||||
board_style.bg_color = Palette.WHITE
|
||||
board_style.corner_radius_top_left = 20
|
||||
board_style.corner_radius_top_right = 20
|
||||
board_style.corner_radius_bottom_left = 20
|
||||
board_style.corner_radius_bottom_right = 20
|
||||
board_style.border_width_left = 3
|
||||
board_style.border_width_right = 3
|
||||
board_style.border_width_top = 3
|
||||
board_style.border_width_bottom = 3
|
||||
board_style.border_color = Palette.WALL
|
||||
board_style.shadow_color = Color(0.29, 0.20, 0.14, 0.14)
|
||||
board_style.shadow_size = 8
|
||||
board_style.shadow_offset = Vector2(0, 4)
|
||||
|
||||
var save := get_node_or_null("/root/SaveGame")
|
||||
if save != null:
|
||||
show_patterns = bool(save.get_setting("patterns"))
|
||||
reduce_motion = bool(save.get_setting("reduce_motion"))
|
||||
hold_seconds = float(save.get_setting("hold_seconds"))
|
||||
double_tap_place = bool(save.get_setting("double_tap_place"))
|
||||
save.settings_changed.connect(_on_settings_changed)
|
||||
|
||||
|
||||
@@ -60,6 +91,15 @@ func _on_settings_changed() -> void:
|
||||
show_patterns = bool(save.get_setting("patterns"))
|
||||
reduce_motion = bool(save.get_setting("reduce_motion"))
|
||||
hold_seconds = float(save.get_setting("hold_seconds"))
|
||||
double_tap_place = bool(save.get_setting("double_tap_place"))
|
||||
if not double_tap_place and pending_tap_cell.x >= 0:
|
||||
var pending := pending_tap_cell
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
_tap(pending)
|
||||
elif double_tap_place:
|
||||
# Leave hold mode cleanly if it was mid-press.
|
||||
press_cell = Vector2i(-1, -1)
|
||||
hold_fired = false
|
||||
queue_redraw()
|
||||
|
||||
|
||||
@@ -68,7 +108,13 @@ func _process(delta: float) -> void:
|
||||
pop_time = max(0.0, pop_time - delta)
|
||||
queue_redraw()
|
||||
|
||||
if press_cell.x >= 0 and not hold_fired:
|
||||
if pending_tap_cell.x >= 0 and Time.get_ticks_msec() - pending_tap_at >= DOUBLE_TAP_MS:
|
||||
var pending := pending_tap_cell
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
_tap(pending)
|
||||
queue_redraw()
|
||||
|
||||
if not double_tap_place and press_cell.x >= 0 and not hold_fired:
|
||||
press_elapsed += delta
|
||||
if press_elapsed >= hold_seconds:
|
||||
hold_fired = true
|
||||
@@ -111,6 +157,7 @@ func set_level(level: Dictionary) -> void:
|
||||
fixed[Vector2i(r, c)] = true
|
||||
|
||||
history.clear()
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
conflict_cells.clear()
|
||||
last_placed = Vector2i(-1, -1)
|
||||
pop_time = 0.0
|
||||
@@ -123,54 +170,22 @@ func set_level(level: Dictionary) -> void:
|
||||
func _draw() -> void:
|
||||
if regions.size() != n or n <= 0:
|
||||
return
|
||||
if cell_styles.is_empty() or board_style == null:
|
||||
return
|
||||
|
||||
_update_layout()
|
||||
var side := cell_size * n
|
||||
var board_rect := Rect2(board_origin, Vector2(side, side))
|
||||
var card_rect := Rect2(board_origin - Vector2(8, 8), Vector2(side + 16, side + 16))
|
||||
draw_style_box(board_style, card_rect)
|
||||
|
||||
# Soft drop shadow
|
||||
draw_rect(Rect2(board_rect.position + Vector2(5, 8), board_rect.size), Color(0.29, 0.20, 0.14, 0.10))
|
||||
|
||||
# Room fills and patterns
|
||||
# Rounded tiles with small gaps. The gaps and colours define the rooms.
|
||||
for r in n:
|
||||
for c in n:
|
||||
var rect := _cell_rect(r, c)
|
||||
var region := int(regions[r][c])
|
||||
var color: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
|
||||
draw_rect(rect.grow(0.6), color)
|
||||
_draw_pattern(rect, region)
|
||||
|
||||
# Hairline grid
|
||||
for i in range(n + 1):
|
||||
var x := board_origin.x + i * cell_size
|
||||
var y := board_origin.y + i * cell_size
|
||||
draw_line(Vector2(x, board_origin.y), Vector2(x, board_origin.y + side), Palette.GRID, 1.0, true)
|
||||
draw_line(Vector2(board_origin.x, y), Vector2(board_origin.x + side, y), Palette.GRID, 1.0, true)
|
||||
|
||||
# Thick walls between rooms
|
||||
var wall_width: float = max(3.0, cell_size * 0.07)
|
||||
for r in n:
|
||||
for c in n:
|
||||
var rect := _cell_rect(r, c)
|
||||
if c == n - 1 or int(regions[r][c]) != int(regions[r][c + 1]):
|
||||
draw_line(
|
||||
rect.position + Vector2(cell_size, 0),
|
||||
rect.position + Vector2(cell_size, cell_size),
|
||||
Palette.WALL,
|
||||
wall_width,
|
||||
true
|
||||
)
|
||||
if r == n - 1 or int(regions[r][c]) != int(regions[r + 1][c]):
|
||||
draw_line(
|
||||
rect.position + Vector2(0, cell_size),
|
||||
rect.position + Vector2(cell_size, cell_size),
|
||||
Palette.WALL,
|
||||
wall_width,
|
||||
true
|
||||
)
|
||||
|
||||
# Outer frame
|
||||
draw_rect(board_rect, Palette.WALL, false, wall_width + 1.0, true)
|
||||
var tile := _cell_rect(r, c).grow(-1.6)
|
||||
draw_style_box(cell_styles[region % cell_styles.size()], tile)
|
||||
_draw_pattern(tile, region)
|
||||
|
||||
# Marks and rats
|
||||
for r in n:
|
||||
@@ -179,9 +194,9 @@ func _draw() -> void:
|
||||
if value == RAT:
|
||||
_draw_rat(Vector2i(r, c))
|
||||
elif value == X:
|
||||
_draw_x(_cell_rect(r, c), Color(0.29, 0.20, 0.14, 0.62))
|
||||
_draw_x(_cell_rect(r, c), Color(0.29, 0.20, 0.14, 0.52))
|
||||
elif auto_x[r][c]:
|
||||
_draw_x(_cell_rect(r, c), Color(0.29, 0.20, 0.14, 0.28))
|
||||
_draw_x(_cell_rect(r, c), Color(0.29, 0.20, 0.14, 0.20))
|
||||
|
||||
# Soft red ring around any rat that breaks a rule.
|
||||
for cell in conflict_cells:
|
||||
@@ -189,14 +204,14 @@ func _draw() -> void:
|
||||
draw_arc(center, cell_size * 0.42, 0.0, TAU, 32, Palette.RED, 3.0, true)
|
||||
|
||||
# Hold progress: fills a gold ring before checking a guest in.
|
||||
if press_cell.x >= 0 and not hold_fired:
|
||||
if press_cell.x >= 0 and not hold_fired and not double_tap_place:
|
||||
var center := _cell_rect(press_cell.x, press_cell.y).get_center()
|
||||
var t: float = clamp(press_elapsed / hold_seconds, 0.0, 1.0)
|
||||
draw_arc(center, cell_size * 0.40, -PI * 0.5, -PI * 0.5 + TAU * t, 32, Palette.GOLD, 3.0, true)
|
||||
|
||||
|
||||
func _update_layout() -> void:
|
||||
var side: float = min(size.x, size.y) - 12.0
|
||||
var side: float = min(size.x, size.y) - 16.0
|
||||
side = max(0.0, side)
|
||||
cell_size = side / float(n)
|
||||
board_origin = (size - Vector2(side, side)) * 0.5
|
||||
@@ -212,48 +227,89 @@ func _cell_rect(r: int, c: int) -> Rect2:
|
||||
func _draw_pattern(rect: Rect2, region: int) -> void:
|
||||
if not show_patterns:
|
||||
return
|
||||
var pattern := region % 5
|
||||
var tint := Color(0.29, 0.20, 0.14, 0.09)
|
||||
var s := rect.size.x
|
||||
var motif := region % 8
|
||||
var tint := Color(0.25, 0.16, 0.10, 0.18)
|
||||
var base: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
|
||||
for p in [Vector2(0.30, 0.30), Vector2(0.70, 0.70)]:
|
||||
_draw_motif(rect.position + p * s, s * 0.24, motif, tint, base)
|
||||
|
||||
if pattern == 0:
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
var p := rect.position + Vector2((i + 0.5) * s / 3.0, (j + 0.5) * s / 3.0)
|
||||
draw_circle(p, max(1.0, s * 0.018), tint)
|
||||
elif pattern == 1:
|
||||
for i in [0.33, 0.66]:
|
||||
draw_line(rect.position + Vector2(0, s * i), rect.position + Vector2(s, s * i), tint, max(1.0, s * 0.012), true)
|
||||
elif pattern == 2:
|
||||
for i in [0.33, 0.66]:
|
||||
draw_line(rect.position + Vector2(s * i, 0), rect.position + Vector2(s * i, s), tint, max(1.0, s * 0.012), true)
|
||||
elif pattern == 3:
|
||||
for i in [0.33, 0.66]:
|
||||
draw_line(rect.position + Vector2(0, s * i), rect.position + Vector2(s, s * i), tint, max(1.0, s * 0.010), true)
|
||||
draw_line(rect.position + Vector2(0, s * (1.0 - i)), rect.position + Vector2(s, s * (1.0 - i)), tint, max(1.0, s * 0.010), true)
|
||||
else:
|
||||
for i in range(2):
|
||||
for j in range(2):
|
||||
var p := rect.position + Vector2((i + 0.5) * s / 2.0, (j + 0.5) * s / 2.0)
|
||||
draw_circle(p, max(1.5, s * 0.034), tint)
|
||||
|
||||
func _draw_motif(center: Vector2, size: float, motif: int, tint: Color, base: Color) -> void:
|
||||
match motif:
|
||||
0:
|
||||
# Paw print
|
||||
draw_circle(center + Vector2(0, 0.16) * size, size * 0.30, tint)
|
||||
for off in [Vector2(-0.32, -0.18), Vector2(-0.16, -0.34), Vector2(0.16, -0.34), Vector2(0.32, -0.18)]:
|
||||
draw_circle(center + off * size, size * 0.15, tint)
|
||||
1:
|
||||
# Cheese wedge
|
||||
var tri := PackedVector2Array([
|
||||
center + Vector2(-0.48, -0.30) * size,
|
||||
center + Vector2(0.48, -0.30) * size,
|
||||
center + Vector2(0.0, 0.48) * size,
|
||||
])
|
||||
draw_colored_polygon(tri, tint)
|
||||
draw_circle(center + Vector2(-0.14, 0.02) * size, size * 0.075, base)
|
||||
draw_circle(center + Vector2(0.14, 0.16) * size, size * 0.05, base)
|
||||
2:
|
||||
# Key
|
||||
draw_circle(center + Vector2(0, -0.34) * size, size * 0.17, tint)
|
||||
draw_circle(center + Vector2(0, -0.34) * size, size * 0.07, base)
|
||||
draw_rect(Rect2(center + Vector2(-0.05, -0.18) * size, Vector2(0.10, 0.55) * size), tint)
|
||||
draw_rect(Rect2(center + Vector2(0.03, 0.20) * size, Vector2(0.22, 0.08) * size), tint)
|
||||
3:
|
||||
# Bed
|
||||
draw_rect(Rect2(center + Vector2(-0.46, -0.10) * size, Vector2(0.92, 0.34) * size), tint)
|
||||
draw_rect(Rect2(center + Vector2(-0.46, -0.28) * size, Vector2(0.28, 0.18) * size), tint)
|
||||
draw_line(center + Vector2(-0.46, 0.30) * size, center + Vector2(0.46, 0.30) * size, tint, size * 0.08, true)
|
||||
4:
|
||||
# Bell
|
||||
draw_arc(center + Vector2(0, 0.04) * size, size * 0.31, PI, TAU, 14, tint, size * 0.15, true)
|
||||
draw_line(center + Vector2(-0.31, 0.04) * size, center + Vector2(0.31, 0.04) * size, tint, size * 0.12, true)
|
||||
draw_circle(center + Vector2(0, 0.36) * size, size * 0.08, tint)
|
||||
5:
|
||||
# Leaf
|
||||
var leaf := PackedVector2Array()
|
||||
for i in range(10):
|
||||
var ang := TAU * i / 10.0
|
||||
leaf.append(center + Vector2(cos(ang) * 0.34, sin(ang) * 0.48) * size)
|
||||
draw_colored_polygon(leaf, tint)
|
||||
draw_line(center + Vector2(-0.24, 0.30) * size, center + Vector2(0.24, -0.30) * size, tint, size * 0.05, true)
|
||||
6:
|
||||
# Fish
|
||||
var body := PackedVector2Array()
|
||||
for i in range(8):
|
||||
var ang := TAU * i / 8.0
|
||||
body.append(center + Vector2(cos(ang) * 0.40, sin(ang) * 0.24) * size)
|
||||
draw_colored_polygon(body, tint)
|
||||
draw_colored_polygon(PackedVector2Array([
|
||||
center + Vector2(-0.34, 0) * size,
|
||||
center + Vector2(-0.58, -0.22) * size,
|
||||
center + Vector2(-0.58, 0.22) * size,
|
||||
]), tint)
|
||||
draw_circle(center + Vector2(0.22, -0.04) * size, size * 0.05, base)
|
||||
7:
|
||||
# Star
|
||||
var star := PackedVector2Array()
|
||||
for i in range(10):
|
||||
var ang := -PI * 0.5 + TAU * i / 10.0
|
||||
var radius := 0.48 if i % 2 == 0 else 0.22
|
||||
star.append(center + Vector2(cos(ang), sin(ang)) * radius * size)
|
||||
draw_colored_polygon(star, tint)
|
||||
|
||||
|
||||
func _draw_x(rect: Rect2, color: Color) -> void:
|
||||
var inset := rect.size.x * 0.30
|
||||
var inset := rect.size.x * 0.32
|
||||
var a := rect.position + Vector2(inset, inset)
|
||||
var b := rect.position + Vector2(rect.size.x - inset, rect.size.y - inset)
|
||||
var c := rect.position + Vector2(rect.size.x - inset, inset)
|
||||
var d := rect.position + Vector2(inset, rect.size.y - inset)
|
||||
draw_line(a, b, color, max(2.0, rect.size.x * 0.045), true)
|
||||
draw_line(c, d, color, max(2.0, rect.size.x * 0.045), true)
|
||||
draw_line(a, b, color, max(1.4, rect.size.x * 0.035), true)
|
||||
draw_line(c, d, color, max(1.4, rect.size.x * 0.035), true)
|
||||
|
||||
|
||||
func _assign_region_rats() -> void:
|
||||
# v0.1.0-alpha: no per-room guest tokens yet. Leave the table empty so every
|
||||
# rat on the board falls back to the shared Crumb head token.
|
||||
if true:
|
||||
return
|
||||
|
||||
region_rats.clear()
|
||||
region_textures.clear()
|
||||
|
||||
@@ -382,7 +438,10 @@ func _gui_input(event: InputEvent) -> void:
|
||||
hold_fired = false
|
||||
queue_redraw()
|
||||
if not fired and was_cell.x >= 0 and cell == was_cell:
|
||||
_tap(was_cell)
|
||||
if double_tap_place:
|
||||
_handle_tap(was_cell)
|
||||
else:
|
||||
_tap(was_cell)
|
||||
accept_event()
|
||||
|
||||
elif event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
|
||||
@@ -417,10 +476,33 @@ func _tap(cell: Vector2i) -> void:
|
||||
_set_cell(cell, X)
|
||||
|
||||
|
||||
## Double-tap mode: defer the single-tap action briefly so a second tap
|
||||
## on the same cell can check a guest in instead.
|
||||
func _handle_tap(cell: Vector2i) -> void:
|
||||
if fixed.has(cell):
|
||||
return
|
||||
var now := Time.get_ticks_msec()
|
||||
if pending_tap_cell == cell and now - pending_tap_at <= DOUBLE_TAP_MS:
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
_toggle_rat(cell)
|
||||
return
|
||||
|
||||
if pending_tap_cell.x >= 0:
|
||||
var old := pending_tap_cell
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
_tap(old)
|
||||
|
||||
pending_tap_cell = cell
|
||||
pending_tap_at = now
|
||||
|
||||
|
||||
## Hold (mobile/PC) or right-click (PC): check a guest in or out.
|
||||
func _toggle_rat(cell: Vector2i) -> void:
|
||||
if fixed.has(cell):
|
||||
return
|
||||
# A right-click or hold overrides any tap still waiting for a partner.
|
||||
if pending_tap_cell == cell:
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
if int(cells[cell.x][cell.y]) == RAT:
|
||||
_set_cell(cell, EMPTY)
|
||||
else:
|
||||
@@ -469,11 +551,13 @@ func _copy_cells() -> Array:
|
||||
func undo() -> void:
|
||||
if history.is_empty():
|
||||
return
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
cells = history.pop_back()
|
||||
_after_change()
|
||||
|
||||
|
||||
func restart() -> void:
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
_push_history()
|
||||
for r in n:
|
||||
for c in n:
|
||||
@@ -485,6 +569,7 @@ func restart() -> void:
|
||||
func hint() -> bool:
|
||||
if solution.size() != n:
|
||||
return false
|
||||
pending_tap_cell = Vector2i(-1, -1)
|
||||
for r in n:
|
||||
var c := int(solution[r])
|
||||
if int(cells[r][c]) == RAT:
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
class_name Daily
|
||||
extends RefCounted
|
||||
|
||||
## Date helpers for the daily room. Everything is keyed by the player's
|
||||
## local calendar date so the same key is used on save and on display.
|
||||
|
||||
static func today_key() -> String:
|
||||
var d := Time.get_date_dict_from_system()
|
||||
return "%04d-%02d-%02d" % [int(d.get("year", 0)), int(d.get("month", 0)), int(d.get("day", 0))]
|
||||
|
||||
|
||||
static func day_number(key: String) -> int:
|
||||
var parts := key.split("-")
|
||||
if parts.size() != 3:
|
||||
return 0
|
||||
var stamp := Time.get_unix_time_from_datetime_dict({
|
||||
"year": int(parts[0]),
|
||||
"month": int(parts[1]),
|
||||
"day": int(parts[2]),
|
||||
"hour": 0,
|
||||
"minute": 0,
|
||||
"second": 0,
|
||||
})
|
||||
return int(floor(float(stamp) / 86400.0))
|
||||
|
||||
|
||||
static func key_from_day_number(day: int) -> String:
|
||||
var d := Time.get_datetime_dict_from_unix_time(day * 86400)
|
||||
return "%04d-%02d-%02d" % [int(d.get("year", 0)), int(d.get("month", 0)), int(d.get("day", 0))]
|
||||
|
||||
|
||||
## Stable per-date room choice. With 30 rooms the pool repeats monthly.
|
||||
static func level_index(level_count: int, key: String = "") -> int:
|
||||
if level_count <= 0:
|
||||
return -1
|
||||
var date_key := key if key != "" else today_key()
|
||||
return absi(("ratdoku-daily-" + date_key).hash()) % level_count
|
||||
@@ -0,0 +1 @@
|
||||
uid://cl1qlq4fvdtij
|
||||
@@ -0,0 +1,106 @@
|
||||
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,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
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 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 ""
|
||||
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
|
||||
@@ -0,0 +1 @@
|
||||
uid://dsv7pdhabtyyg
|
||||
@@ -1,9 +1,11 @@
|
||||
extends Control
|
||||
|
||||
signal back_pressed
|
||||
signal guest_book_pressed
|
||||
signal settings_pressed
|
||||
|
||||
const BoardScene = preload("res://scenes/Board.tscn")
|
||||
const DEFAULT_STATUS := "One guest per room, floor and corridor.\nTap = X · Hold or right-click = check in."
|
||||
const DEFAULT_STATUS := "One guest per room, row and column."
|
||||
|
||||
var levels: Array = []
|
||||
var level_index := 0
|
||||
@@ -11,13 +13,25 @@ var started_at := 0
|
||||
var elapsed_ms := 0
|
||||
var win_shown := false
|
||||
var current_level_id := ""
|
||||
var daily_mode := false
|
||||
var daily_key := ""
|
||||
var ui_paused := false
|
||||
|
||||
var board: Board
|
||||
var level_label: Label
|
||||
var guest_label: Label
|
||||
var timer_label: Label
|
||||
var status_label: Label
|
||||
var win_detail: Label
|
||||
var overlay: ColorRect
|
||||
var rule_strip: HBoxContainer
|
||||
var legend_row: HBoxContainer
|
||||
var legend_chips: Array = []
|
||||
var win_title: Label
|
||||
var win_next: Button
|
||||
var new_guest_box: HBoxContainer
|
||||
var new_guest_label: Label
|
||||
var new_guest_portrait: TextureRect
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -29,40 +43,73 @@ func _ready() -> void:
|
||||
func _build_ui() -> void:
|
||||
var margin := MarginContainer.new()
|
||||
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
margin.add_theme_constant_override("margin_left", 20)
|
||||
margin.add_theme_constant_override("margin_right", 20)
|
||||
margin.add_theme_constant_override("margin_top", 18)
|
||||
margin.add_theme_constant_override("margin_bottom", 18)
|
||||
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", 10)
|
||||
column.add_theme_constant_override("separation", 6)
|
||||
margin.add_child(column)
|
||||
|
||||
# Top bar
|
||||
var top := HBoxContainer.new()
|
||||
top.add_theme_constant_override("separation", 10)
|
||||
top.add_theme_constant_override("separation", 8)
|
||||
top.custom_minimum_size = Vector2(0, 44)
|
||||
column.add_child(top)
|
||||
|
||||
var back := UI.button("‹", false, 44)
|
||||
back.custom_minimum_size = Vector2(48, 44)
|
||||
back.add_theme_font_size_override("font_size", 30)
|
||||
var back := UI.round_button("res://assets/icons/arrow-left.svg", 44)
|
||||
back.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
back.pressed.connect(_on_back)
|
||||
top.add_child(back)
|
||||
|
||||
level_label = UI.label("Room 1", 20, Palette.MUTED)
|
||||
level_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
level_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
top.add_child(level_label)
|
||||
var center := VBoxContainer.new()
|
||||
center.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
center.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
center.add_theme_constant_override("separation", 0)
|
||||
top.add_child(center)
|
||||
|
||||
timer_label = UI.label("00:00", 18, Palette.MUTED)
|
||||
timer_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
timer_label.custom_minimum_size = Vector2(72, 0)
|
||||
top.add_child(timer_label)
|
||||
level_label = UI.label("Room 1", 18)
|
||||
level_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
center.add_child(level_label)
|
||||
|
||||
var sub := HBoxContainer.new()
|
||||
sub.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
sub.add_theme_constant_override("separation", 8)
|
||||
center.add_child(sub)
|
||||
|
||||
guest_label = UI.label("0 / 8", 11, Palette.MUTED)
|
||||
guest_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
sub.add_child(guest_label)
|
||||
|
||||
timer_label = UI.label("00:00", 11, Palette.MUTED)
|
||||
timer_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
sub.add_child(timer_label)
|
||||
|
||||
var gear := UI.round_button("res://assets/icons/settings.svg", 44)
|
||||
gear.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
gear.pressed.connect(func() -> void: settings_pressed.emit())
|
||||
top.add_child(gear)
|
||||
|
||||
# Rule chips, first three rooms
|
||||
rule_strip = HBoxContainer.new()
|
||||
rule_strip.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
rule_strip.add_theme_constant_override("separation", 4)
|
||||
column.add_child(rule_strip)
|
||||
rule_strip.add_child(_rule_chip("1 per room", "region"))
|
||||
rule_strip.add_child(_rule_chip("Row & col", "row"))
|
||||
rule_strip.add_child(_rule_chip("No touching", "touch"))
|
||||
|
||||
# Room legend: one guest per colour
|
||||
legend_row = HBoxContainer.new()
|
||||
legend_row.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
legend_row.add_theme_constant_override("separation", 3)
|
||||
column.add_child(legend_row)
|
||||
|
||||
# Board
|
||||
board = BoardScene.instantiate() as Board
|
||||
board.custom_minimum_size = Vector2(320, 320)
|
||||
board.custom_minimum_size = Vector2(300, 300)
|
||||
board.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
board.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
board.changed.connect(_on_board_changed)
|
||||
@@ -71,34 +118,50 @@ func _build_ui() -> void:
|
||||
column.add_child(board)
|
||||
|
||||
# Status
|
||||
status_label = UI.label(DEFAULT_STATUS, 17, Palette.MUTED)
|
||||
status_label.custom_minimum_size = Vector2(0, 56)
|
||||
status_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
status_label = UI.label(DEFAULT_STATUS, 12, Palette.MUTED)
|
||||
status_label.custom_minimum_size = Vector2(0, 26)
|
||||
column.add_child(status_label)
|
||||
|
||||
# Bottom actions
|
||||
# Actions
|
||||
var actions := HBoxContainer.new()
|
||||
actions.add_theme_constant_override("separation", 8)
|
||||
column.add_child(actions)
|
||||
|
||||
var undo := UI.button("Undo", false, 52)
|
||||
var undo := UI.button("Undo", false, 48)
|
||||
undo.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
undo.add_theme_font_size_override("font_size", 17)
|
||||
undo.pressed.connect(_on_undo)
|
||||
actions.add_child(undo)
|
||||
|
||||
var restart := UI.button("Restart", false, 52)
|
||||
restart.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
restart.pressed.connect(_on_restart)
|
||||
actions.add_child(restart)
|
||||
|
||||
var hint := UI.button("Hint", true, 52)
|
||||
var hint := UI.button("Hint", true, 48)
|
||||
hint.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hint.add_theme_font_size_override("font_size", 17)
|
||||
hint.pressed.connect(_on_hint)
|
||||
actions.add_child(hint)
|
||||
|
||||
_build_win_overlay()
|
||||
|
||||
|
||||
func _rule_chip(text: String, mode: String) -> PanelContainer:
|
||||
var panel := UI.panel(Palette.PAPER, 12, 5)
|
||||
panel.custom_minimum_size = Vector2(104, 42)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 3)
|
||||
panel.add_child(row)
|
||||
|
||||
var diagram := MiniDiagram.new()
|
||||
diagram.mode = mode
|
||||
diagram.custom_minimum_size = Vector2(30, 30)
|
||||
row.add_child(diagram)
|
||||
|
||||
var label := UI.label(text, 10, Palette.MUTED)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
label.custom_minimum_size = Vector2(58, 0)
|
||||
row.add_child(label)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func _build_win_overlay() -> void:
|
||||
overlay = ColorRect.new()
|
||||
overlay.color = Color(0.18, 0.12, 0.08, 0.48)
|
||||
@@ -111,28 +174,53 @@ func _build_win_overlay() -> void:
|
||||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
overlay.add_child(center)
|
||||
|
||||
var panel := UI.panel(Palette.CREAM, 34, 28)
|
||||
panel.custom_minimum_size = Vector2(420, 0)
|
||||
var panel := UI.panel(Palette.CREAM, 26, 18)
|
||||
panel.custom_minimum_size = Vector2(320, 0)
|
||||
center.add_child(panel)
|
||||
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 10)
|
||||
box.add_theme_constant_override("separation", 6)
|
||||
panel.add_child(box)
|
||||
|
||||
var portrait_center := CenterContainer.new()
|
||||
box.add_child(portrait_center)
|
||||
var portrait := _make_win_portrait()
|
||||
portrait.custom_minimum_size = Vector2(170, 170)
|
||||
portrait.custom_minimum_size = Vector2(110, 110)
|
||||
portrait_center.add_child(portrait)
|
||||
|
||||
box.add_child(UI.label("Everyone checked in!", 34))
|
||||
win_detail = UI.label("Room 1 · 00:00", 18, Palette.MUTED)
|
||||
win_title = UI.heading("Everyone checked in!", 26)
|
||||
box.add_child(win_title)
|
||||
win_detail = UI.label("Room 1 · 00:00", 13, Palette.MUTED)
|
||||
box.add_child(win_detail)
|
||||
box.add_child(UI.label("Sweet dreams, little guests.", 18, Palette.MUTED))
|
||||
box.add_child(UI.label("Sweet dreams, little guests.", 12, Palette.MUTED))
|
||||
|
||||
var next := UI.button("Next room", true, 56)
|
||||
new_guest_box = HBoxContainer.new()
|
||||
new_guest_box.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
new_guest_box.add_theme_constant_override("separation", 6)
|
||||
new_guest_box.visible = false
|
||||
box.add_child(new_guest_box)
|
||||
|
||||
new_guest_portrait = TextureRect.new()
|
||||
new_guest_portrait.custom_minimum_size = Vector2(42, 42)
|
||||
new_guest_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
new_guest_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
new_guest_box.add_child(new_guest_portrait)
|
||||
|
||||
new_guest_label = UI.label("", 11, Palette.INK)
|
||||
new_guest_label.custom_minimum_size = Vector2(190, 0)
|
||||
new_guest_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
new_guest_box.add_child(new_guest_label)
|
||||
|
||||
var next := UI.button("Next room", true, 48)
|
||||
next.add_theme_font_size_override("font_size", 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)
|
||||
box.add_child(book)
|
||||
book.pressed.connect(func() -> void: guest_book_pressed.emit())
|
||||
|
||||
|
||||
func _make_win_portrait() -> Control:
|
||||
@@ -145,32 +233,102 @@ func _make_win_portrait() -> Control:
|
||||
return RatPortrait.new()
|
||||
|
||||
|
||||
func start_level(index: int) -> void:
|
||||
func start_level(index: int, daily: bool = false, key: String = "") -> void:
|
||||
if levels.is_empty():
|
||||
status_label.text = "No rooms found — check data/levels.json."
|
||||
status_label.text = "No rooms yet."
|
||||
status_label.add_theme_color_override("font_color", Palette.RED)
|
||||
return
|
||||
|
||||
daily_mode = daily
|
||||
daily_key = key
|
||||
level_index = clampi(index, 0, levels.size() - 1)
|
||||
var level: Dictionary = levels[level_index]
|
||||
current_level_id = str(level.get("id", ""))
|
||||
board.set_level(level)
|
||||
|
||||
level_label.text = "Room %d of %d" % [level_index + 1, levels.size()]
|
||||
level_label.text = "Daily room" if daily_mode else "Room %d" % (level_index + 1)
|
||||
started_at = Time.get_ticks_msec()
|
||||
elapsed_ms = 0
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
if level.get("clues", []).size() > 0:
|
||||
status_label.text = "Gold-ringed guests are already checked in.\nTap = X · Hold or right-click = check in."
|
||||
else:
|
||||
status_label.text = DEFAULT_STATUS
|
||||
new_guest_box.visible = false
|
||||
rule_strip.visible = daily_mode or level_index < 3
|
||||
status_label.text = "Gold rings are already in." if level.get("clues", []).size() > 0 else DEFAULT_STATUS
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
_refresh_legend()
|
||||
_update_legend()
|
||||
_update_guest_count()
|
||||
|
||||
|
||||
func start_daily(index: int, key: String) -> void:
|
||||
start_level(index, true, key)
|
||||
|
||||
|
||||
func _refresh_legend() -> void:
|
||||
for child in legend_row.get_children():
|
||||
child.queue_free()
|
||||
legend_chips.clear()
|
||||
if board.region_rats.is_empty():
|
||||
return
|
||||
|
||||
for region in range(board.n):
|
||||
var id := str(board.region_rats[region])
|
||||
var color: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
|
||||
var chip := PanelContainer.new()
|
||||
chip.custom_minimum_size = Vector2(32, 32)
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = color
|
||||
style.corner_radius_top_left = 9
|
||||
style.corner_radius_top_right = 9
|
||||
style.corner_radius_bottom_left = 9
|
||||
style.corner_radius_bottom_right = 9
|
||||
style.border_width_left = 1
|
||||
style.border_width_right = 1
|
||||
style.border_width_top = 1
|
||||
style.border_width_bottom = 1
|
||||
style.border_color = Color(1, 1, 1, 0.55)
|
||||
chip.add_theme_stylebox_override("panel", style)
|
||||
chip.tooltip_text = str(Guests.by_id(id).get("name", id))
|
||||
legend_row.add_child(chip)
|
||||
|
||||
var texture := TextureRect.new()
|
||||
texture.texture = board.region_textures.get(region)
|
||||
texture.custom_minimum_size = Vector2(28, 28)
|
||||
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
texture.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
chip.add_child(texture)
|
||||
|
||||
legend_chips.append(chip)
|
||||
|
||||
|
||||
func _update_legend() -> void:
|
||||
for region in range(legend_chips.size()):
|
||||
var chip: Control = legend_chips[region]
|
||||
var solved := false
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
if int(board.cells[r][c]) == Board.RAT and int(board.regions[r][c]) == region:
|
||||
solved = true
|
||||
break
|
||||
if solved:
|
||||
break
|
||||
var style: StyleBoxFlat = chip.get_theme_stylebox("panel")
|
||||
if style != null:
|
||||
style.border_color = Palette.GOLD if solved else Color(1, 1, 1, 0.55)
|
||||
style.border_width_left = 3 if solved else 1
|
||||
style.border_width_right = 3 if solved else 1
|
||||
style.border_width_top = 3 if solved else 1
|
||||
style.border_width_bottom = 3 if solved else 1
|
||||
|
||||
|
||||
func _update_guest_count() -> void:
|
||||
guest_label.text = "%d / %d guests" % [Rules.count_rats(board.cells), board.n]
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
timer_label.visible = bool(SaveGame.get_setting("show_timer"))
|
||||
if not visible or win_shown or started_at == 0:
|
||||
if ui_paused or not visible or win_shown or started_at == 0:
|
||||
return
|
||||
elapsed_ms = Time.get_ticks_msec() - started_at
|
||||
timer_label.text = _format_time(elapsed_ms)
|
||||
@@ -183,15 +341,25 @@ func _format_time(ms: int) -> String:
|
||||
return "%02d:%02d" % [minutes, seconds]
|
||||
|
||||
|
||||
func set_ui_paused(value: bool) -> void:
|
||||
ui_paused = value
|
||||
|
||||
|
||||
func restart_room() -> void:
|
||||
start_level(level_index, daily_mode, daily_key)
|
||||
|
||||
|
||||
func _on_board_changed() -> void:
|
||||
if win_shown:
|
||||
return
|
||||
status_label.text = DEFAULT_STATUS
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
_update_guest_count()
|
||||
_update_legend()
|
||||
|
||||
|
||||
func _on_mistake() -> void:
|
||||
status_label.text = "That room's already taken — undo or try another."
|
||||
status_label.text = "That room's taken — undo or try again."
|
||||
status_label.add_theme_color_override("font_color", Palette.RED)
|
||||
|
||||
|
||||
@@ -201,9 +369,31 @@ func _on_solved() -> void:
|
||||
win_shown = true
|
||||
status_label.text = "Everyone checked in."
|
||||
status_label.add_theme_color_override("font_color", Palette.INK)
|
||||
win_detail.text = "Room %d · %s" % [level_index + 1, _format_time(elapsed_ms)]
|
||||
_update_legend()
|
||||
|
||||
SaveGame.complete_room(current_level_id, level_index + 1)
|
||||
if daily_mode:
|
||||
var extended := SaveGame.complete_daily(daily_key)
|
||||
var streak := SaveGame.daily_streak()
|
||||
var streak_text := "%d %s" % [streak, "day" if streak == 1 else "days"]
|
||||
win_title.text = "Daily room complete!"
|
||||
win_detail.text = "%s · %s" % [
|
||||
("Streak: " + streak_text) if extended else ("Replay · " + streak_text),
|
||||
_format_time(elapsed_ms)
|
||||
]
|
||||
win_next.text = "Back to lobby"
|
||||
new_guest_box.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)
|
||||
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
|
||||
else:
|
||||
new_guest_box.visible = false
|
||||
|
||||
await get_tree().create_timer(0.45).timeout
|
||||
if win_shown:
|
||||
@@ -216,26 +406,21 @@ func _on_undo() -> void:
|
||||
board.undo()
|
||||
|
||||
|
||||
func _on_restart() -> void:
|
||||
win_shown = false
|
||||
overlay.visible = false
|
||||
started_at = Time.get_ticks_msec()
|
||||
elapsed_ms = 0
|
||||
board.restart()
|
||||
|
||||
|
||||
func _on_hint() -> void:
|
||||
if board.hint():
|
||||
if not win_shown:
|
||||
status_label.text = "Crumb found a guest who was waiting."
|
||||
status_label.text = "Crumb found a guest."
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
else:
|
||||
if not win_shown:
|
||||
status_label.text = "Every guest is already checked in."
|
||||
status_label.text = "Everyone is already checked in."
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
|
||||
|
||||
func _on_next() -> void:
|
||||
if daily_mode:
|
||||
_on_back()
|
||||
return
|
||||
if level_index + 1 < levels.size():
|
||||
start_level(level_index + 1)
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
extends Control
|
||||
|
||||
signal back_pressed
|
||||
|
||||
## A tap is only trusted when it is short and stationary. Anything that
|
||||
## drifts or moves the scroll container is treated as a scroll gesture.
|
||||
const TAP_MAX_MOVE := 12.0
|
||||
const TAP_MAX_MS := 500
|
||||
const DRAG_SUPPRESS_MS := 180
|
||||
const DETAIL_CLOSE_GUARD_MS := 250
|
||||
|
||||
var grid: GridContainer
|
||||
var progress_label: Label
|
||||
var status_label: Label
|
||||
var scroll: ScrollContainer
|
||||
var detail_layer: ColorRect
|
||||
var detail_portrait: TextureRect
|
||||
var detail_name: Label
|
||||
var detail_role: Label
|
||||
var detail_meta: Label
|
||||
var detail_bio: Label
|
||||
var detail_snack: Label
|
||||
var detail_status: Label
|
||||
var crumb_frame_holder: CenterContainer
|
||||
var crumb_frame_id := ""
|
||||
|
||||
var _press_active := false
|
||||
var _press_at := 0
|
||||
var _press_pos := Vector2.ZERO
|
||||
var _press_scroll := 0
|
||||
var _dragged := false
|
||||
var _suppress_until := 0
|
||||
var _detail_opened_at := 0
|
||||
|
||||
|
||||
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("The Guest Book", 22)
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
top.add_child(title)
|
||||
|
||||
progress_label = UI.label("5 of 25", 10, Palette.MUTED)
|
||||
progress_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
progress_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
progress_label.custom_minimum_size = Vector2(70, 0)
|
||||
top.add_child(progress_label)
|
||||
|
||||
column.add_child(_make_crumb_card())
|
||||
|
||||
status_label = UI.label("Tap a guest to read their card.", 10, Palette.MUTED)
|
||||
status_label.custom_minimum_size = Vector2(0, 20)
|
||||
column.add_child(status_label)
|
||||
|
||||
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
|
||||
scroll.scroll_started.connect(_on_scroll_started)
|
||||
scroll.scroll_ended.connect(_on_scroll_ended)
|
||||
column.add_child(scroll)
|
||||
|
||||
grid = GridContainer.new()
|
||||
grid.columns = 3
|
||||
grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
grid.add_theme_constant_override("h_separation", 5)
|
||||
grid.add_theme_constant_override("v_separation", 5)
|
||||
scroll.add_child(grid)
|
||||
|
||||
_build_detail()
|
||||
|
||||
SaveGame.progress_changed.connect(refresh)
|
||||
refresh()
|
||||
|
||||
|
||||
func _build_crumb_frame() -> void:
|
||||
if crumb_frame_holder == null:
|
||||
return
|
||||
var selected := SaveGame.selected_frame()
|
||||
if crumb_frame_id == selected and crumb_frame_holder.get_child_count() > 0:
|
||||
return
|
||||
for child in crumb_frame_holder.get_children():
|
||||
child.queue_free()
|
||||
var frame := Frames.frame_panel(selected, 56)
|
||||
var portrait := TextureRect.new()
|
||||
portrait.custom_minimum_size = Vector2(44, 44)
|
||||
portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
portrait.texture = load("res://art/crumb_head.png")
|
||||
portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
frame.add_child(portrait)
|
||||
crumb_frame_holder.add_child(frame)
|
||||
crumb_frame_id = selected
|
||||
|
||||
|
||||
func _make_crumb_card() -> PanelContainer:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(row)
|
||||
|
||||
crumb_frame_holder = CenterContainer.new()
|
||||
crumb_frame_holder.custom_minimum_size = Vector2(56, 56)
|
||||
row.add_child(crumb_frame_holder)
|
||||
_build_crumb_frame()
|
||||
|
||||
var text := VBoxContainer.new()
|
||||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
text.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
text.add_theme_constant_override("separation", 0)
|
||||
row.add_child(text)
|
||||
|
||||
var name := UI.label("Crumb", 16)
|
||||
name.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(name)
|
||||
|
||||
var role := UI.label("Innkeeper · always in", 10, Palette.MUTED)
|
||||
role.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(role)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
if grid == null:
|
||||
return
|
||||
_build_crumb_frame()
|
||||
for child in grid.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var guests := Guests.all()
|
||||
var unlocked := SaveGame.unlocked_count(guests)
|
||||
progress_label.text = "%d/%d" % [unlocked, guests.size()]
|
||||
|
||||
for guest in guests:
|
||||
grid.add_child(_make_card(guest))
|
||||
|
||||
# Let a finger drag reach the ScrollContainer even when it starts on a
|
||||
# card; the card still gets its own press/release for tap detection.
|
||||
UI.pass_scroll_input(grid)
|
||||
|
||||
|
||||
func _make_card(guest: Dictionary) -> PanelContainer:
|
||||
var id := str(guest["id"])
|
||||
var locked := not SaveGame.is_guest_unlocked(id)
|
||||
var accent := Color(str(guest.get("accent", "#8c7460")))
|
||||
|
||||
var panel := UI.panel(Palette.PAPER, 12, 5)
|
||||
panel.custom_minimum_size = Vector2(105, 148)
|
||||
panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
panel.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
panel.gui_input.connect(_on_card_input.bind(guest, locked))
|
||||
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 1)
|
||||
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
panel.add_child(box)
|
||||
|
||||
var portrait := Control.new()
|
||||
portrait.custom_minimum_size = Vector2(94, 96)
|
||||
portrait.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
box.add_child(portrait)
|
||||
|
||||
var texture := TextureRect.new()
|
||||
texture.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
texture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
texture.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
texture.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
texture.texture = load(Guests.portrait(id, "thumbs"))
|
||||
portrait.add_child(texture)
|
||||
|
||||
if locked:
|
||||
texture.modulate = Color(1, 1, 1, 0.18)
|
||||
var veil := ColorRect.new()
|
||||
veil.color = Color(0.98, 0.93, 0.84, 0.78)
|
||||
veil.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
veil.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
portrait.add_child(veil)
|
||||
|
||||
var mystery := UI.label("???", 22, Palette.INK)
|
||||
mystery.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
mystery.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
mystery.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
portrait.add_child(mystery)
|
||||
|
||||
var name_label := UI.label("???" if locked else str(guest["name"]), 12)
|
||||
name_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
box.add_child(name_label)
|
||||
|
||||
var role_text := "Room %d" % int(guest.get("unlock_room", 0)) if locked else str(guest["role"])
|
||||
var role_label := UI.label(role_text, 9, Palette.MUTED if locked else accent)
|
||||
role_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
box.add_child(role_label)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func _on_scroll_started() -> void:
|
||||
_dragged = true
|
||||
|
||||
|
||||
func _on_scroll_ended() -> void:
|
||||
_dragged = true
|
||||
_suppress_until = max(_suppress_until, Time.get_ticks_msec() + DRAG_SUPPRESS_MS)
|
||||
|
||||
|
||||
func _on_card_input(event: InputEvent, guest: Dictionary, locked: bool) -> void:
|
||||
if event is InputEventMouseMotion and _press_active:
|
||||
var motion := event as InputEventMouseMotion
|
||||
if motion.global_position.distance_to(_press_pos) > TAP_MAX_MOVE:
|
||||
_dragged = true
|
||||
return
|
||||
|
||||
if not (event is InputEventMouseButton):
|
||||
return
|
||||
var button := event as InputEventMouseButton
|
||||
if button.button_index != MOUSE_BUTTON_LEFT:
|
||||
return
|
||||
|
||||
if button.pressed:
|
||||
# Remember where and when the finger landed, and how far the list
|
||||
# was scrolled, so a release can be checked against it.
|
||||
_press_active = true
|
||||
_press_at = Time.get_ticks_msec()
|
||||
_press_pos = button.global_position
|
||||
_press_scroll = scroll.scroll_vertical if scroll != null else 0
|
||||
_dragged = false
|
||||
return
|
||||
|
||||
if not _press_active:
|
||||
return
|
||||
_press_active = false
|
||||
|
||||
var now := Time.get_ticks_msec()
|
||||
var moved: float = button.global_position.distance_to(_press_pos)
|
||||
var scroll_now := scroll.scroll_vertical if scroll != null else 0
|
||||
var scrolled := _dragged or absi(scroll_now - _press_scroll) > 1
|
||||
var is_tap: bool = (
|
||||
not scrolled
|
||||
and moved <= TAP_MAX_MOVE
|
||||
and now - _press_at <= TAP_MAX_MS
|
||||
and now >= _suppress_until
|
||||
)
|
||||
|
||||
if scrolled:
|
||||
_suppress_until = now + DRAG_SUPPRESS_MS
|
||||
|
||||
# Do not consume the event: the ScrollContainer needs the release to end
|
||||
# its drag. A real tap is still safe because the detail sheet guards
|
||||
# Close for 250ms after opening.
|
||||
if not is_tap:
|
||||
return
|
||||
|
||||
if locked:
|
||||
var room := int(guest.get("unlock_room", 0))
|
||||
status_label.text = "Check in a guest from Room %d to meet them." % room
|
||||
status_label.add_theme_color_override("font_color", Palette.RED)
|
||||
else:
|
||||
status_label.text = "Tap a guest to read their card."
|
||||
status_label.add_theme_color_override("font_color", Palette.MUTED)
|
||||
_show_detail(guest)
|
||||
|
||||
|
||||
func _build_detail() -> void:
|
||||
detail_layer = ColorRect.new()
|
||||
detail_layer.color = Color(0.18, 0.12, 0.08, 0.52)
|
||||
detail_layer.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
detail_layer.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
detail_layer.visible = false
|
||||
detail_layer.gui_input.connect(_on_detail_input)
|
||||
add_child(detail_layer)
|
||||
|
||||
var center := CenterContainer.new()
|
||||
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
detail_layer.add_child(center)
|
||||
|
||||
var panel := UI.panel(Palette.CREAM, 24, 16)
|
||||
panel.custom_minimum_size = Vector2(320, 0)
|
||||
panel.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
center.add_child(panel)
|
||||
|
||||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 4)
|
||||
panel.add_child(box)
|
||||
|
||||
detail_portrait = TextureRect.new()
|
||||
detail_portrait.custom_minimum_size = Vector2(180, 180)
|
||||
detail_portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
detail_portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
box.add_child(detail_portrait)
|
||||
|
||||
detail_name = UI.heading("Name", 22)
|
||||
box.add_child(detail_name)
|
||||
detail_role = UI.label("Role", 13, Palette.MUTED)
|
||||
box.add_child(detail_role)
|
||||
detail_meta = UI.label("Variety", 11, Palette.MUTED)
|
||||
box.add_child(detail_meta)
|
||||
|
||||
detail_bio = UI.label("", 12)
|
||||
detail_bio.custom_minimum_size = Vector2(0, 38)
|
||||
box.add_child(detail_bio)
|
||||
|
||||
detail_snack = UI.label("", 11, Palette.MUTED)
|
||||
box.add_child(detail_snack)
|
||||
detail_status = UI.label("", 10, Palette.MUTED)
|
||||
box.add_child(detail_status)
|
||||
|
||||
var close := UI.button("Close", false, 44)
|
||||
close.add_theme_font_size_override("font_size", 16)
|
||||
close.pressed.connect(_try_close_detail)
|
||||
box.add_child(close)
|
||||
|
||||
|
||||
func _show_detail(guest: Dictionary) -> void:
|
||||
var id := str(guest["id"])
|
||||
var accent := Color(str(guest.get("accent", "#8c7460")))
|
||||
detail_portrait.texture = load(Guests.portrait(id, "cards"))
|
||||
detail_name.text = str(guest["name"])
|
||||
detail_role.text = "%s · %s" % [str(guest["role"]), str(guest.get("pronouns", ""))]
|
||||
detail_role.add_theme_color_override("font_color", accent)
|
||||
detail_meta.text = "%s coat · %s" % [str(guest.get("variety", "")), str(guest.get("coat", ""))]
|
||||
detail_bio.text = str(guest.get("personality", ""))
|
||||
detail_snack.text = "Favourite snack: %s" % str(guest.get("snack", ""))
|
||||
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"
|
||||
_detail_opened_at = Time.get_ticks_msec()
|
||||
detail_layer.visible = true
|
||||
detail_layer.move_to_front()
|
||||
|
||||
|
||||
func _on_detail_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
|
||||
_try_close_detail()
|
||||
|
||||
|
||||
func _try_close_detail() -> void:
|
||||
# The opening tap can land where the sheet appears. Ignore close input
|
||||
# for a moment so one deliberate tap opens and a second one closes.
|
||||
if Time.get_ticks_msec() - _detail_opened_at < DETAIL_CLOSE_GUARD_MS:
|
||||
return
|
||||
detail_layer.visible = false
|
||||
@@ -0,0 +1 @@
|
||||
uid://cfdurhj51k6me
|
||||
@@ -1,55 +1,173 @@
|
||||
extends Control
|
||||
|
||||
signal play_pressed
|
||||
signal guest_book_pressed
|
||||
signal settings_pressed
|
||||
signal rules_pressed
|
||||
signal daily_pressed
|
||||
signal profile_pressed
|
||||
|
||||
var progress_pill: Button
|
||||
var primary: Button
|
||||
var hint_label: Label
|
||||
var daily_button: Button
|
||||
var avatar_holder: CenterContainer
|
||||
var avatar_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", 28)
|
||||
margin.add_theme_constant_override("margin_right", 28)
|
||||
margin.add_theme_constant_override("margin_top", 28)
|
||||
margin.add_theme_constant_override("margin_bottom", 28)
|
||||
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.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
column.add_theme_constant_override("separation", 10)
|
||||
column.add_theme_constant_override("separation", 6)
|
||||
margin.add_child(column)
|
||||
|
||||
column.add_child(UI.label("Ratdoku", 68))
|
||||
column.add_child(UI.label("A cozy rat hotel puzzle", 24, Palette.MUTED))
|
||||
var hub := HBoxContainer.new()
|
||||
hub.add_theme_constant_override("separation", 0)
|
||||
column.add_child(hub)
|
||||
|
||||
var gap := Control.new()
|
||||
gap.custom_minimum_size = Vector2(0, 14)
|
||||
column.add_child(gap)
|
||||
var left := CenterContainer.new()
|
||||
left.custom_minimum_size = Vector2(56, 56)
|
||||
avatar_holder = left
|
||||
hub.add_child(left)
|
||||
_build_avatar()
|
||||
|
||||
var portrait_center := CenterContainer.new()
|
||||
column.add_child(portrait_center)
|
||||
var card := UI.panel(Palette.CREAM, 40, 18)
|
||||
card.custom_minimum_size = Vector2(340, 340)
|
||||
portrait_center.add_child(card)
|
||||
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)
|
||||
progress_pill.add_theme_font_size_override("font_size", 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))
|
||||
|
||||
daily_button = UI.button("Daily room", false, 40)
|
||||
daily_button.custom_minimum_size = Vector2(0, 40)
|
||||
daily_button.add_theme_font_size_override("font_size", 13)
|
||||
daily_button.pressed.connect(func() -> void: daily_pressed.emit())
|
||||
column.add_child(daily_button)
|
||||
|
||||
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)
|
||||
card.custom_minimum_size = Vector2(160, 160)
|
||||
card.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
var mascot := _make_mascot()
|
||||
mascot.custom_minimum_size = Vector2(300, 300)
|
||||
mascot.custom_minimum_size = Vector2(138, 138)
|
||||
card.add_child(mascot)
|
||||
column.add_child(card)
|
||||
|
||||
column.add_child(UI.label("Crumb, innkeeper", 16, Palette.MUTED))
|
||||
column.add_child(UI.label("Every guest gets a room of their own.", 20))
|
||||
column.add_child(UI.label("Tap = X · Hold or right-click = check in", 16, Palette.MUTED))
|
||||
column.add_child(UI.label("Crumb, innkeeper", 12, Palette.MUTED))
|
||||
hint_label = UI.label(UI.place_hint(), 11, Palette.MUTED)
|
||||
column.add_child(hint_label)
|
||||
|
||||
var gap2 := Control.new()
|
||||
gap2.custom_minimum_size = Vector2(0, 10)
|
||||
column.add_child(gap2)
|
||||
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)
|
||||
|
||||
var play := UI.button("Check in", true, 64)
|
||||
play.custom_minimum_size = Vector2(280, 64)
|
||||
var play_center := CenterContainer.new()
|
||||
play_center.add_child(play)
|
||||
column.add_child(play_center)
|
||||
play.pressed.connect(func() -> void: play_pressed.emit())
|
||||
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)
|
||||
|
||||
column.add_child(UI.label("No ads. No lives. Just rats.", 16, Palette.MUTED))
|
||||
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)
|
||||
book.add_theme_font_size_override("font_size", 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)
|
||||
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))
|
||||
|
||||
SaveGame.progress_changed.connect(refresh)
|
||||
SaveGame.settings_changed.connect(refresh)
|
||||
refresh()
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
hint_label.text = UI.place_hint()
|
||||
daily_button.text = _daily_text()
|
||||
_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("res://art/crumb_head.png")
|
||||
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()
|
||||
|
||||
|
||||
func _refresh_avatar() -> void:
|
||||
if avatar_frame_id == SaveGame.selected_frame():
|
||||
return
|
||||
for child in avatar_holder.get_children():
|
||||
child.queue_free()
|
||||
_build_avatar()
|
||||
|
||||
|
||||
func _make_mascot() -> Control:
|
||||
|
||||
@@ -2,9 +2,17 @@ extends Control
|
||||
|
||||
const HomeScene = preload("res://scenes/Home.tscn")
|
||||
const GameScene = preload("res://scenes/Game.tscn")
|
||||
const GuestBookScene = preload("res://scenes/GuestBook.tscn")
|
||||
const RulebookScene = preload("res://scenes/Rulebook.tscn")
|
||||
const ProfileScene = preload("res://scenes/Profile.tscn")
|
||||
const SettingsSheetScene = preload("res://scenes/SettingsSheet.tscn")
|
||||
|
||||
var home
|
||||
var game
|
||||
var guest_book
|
||||
var rulebook
|
||||
var profile
|
||||
var settings_sheet
|
||||
var screens := {}
|
||||
var current := "home"
|
||||
var nav_stack: Array[String] = []
|
||||
@@ -20,14 +28,45 @@ func _ready() -> void:
|
||||
home = HomeScene.instantiate()
|
||||
_add_screen(home)
|
||||
home.play_pressed.connect(_on_play)
|
||||
home.guest_book_pressed.connect(func() -> void: show_screen("guest_book"))
|
||||
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.profile_pressed.connect(func() -> void: show_screen("profile"))
|
||||
|
||||
game = GameScene.instantiate()
|
||||
_add_screen(game)
|
||||
game.back_pressed.connect(go_back)
|
||||
game.guest_book_pressed.connect(func() -> void: show_screen("guest_book"))
|
||||
game.settings_pressed.connect(func() -> void: open_settings("game"))
|
||||
|
||||
guest_book = GuestBookScene.instantiate()
|
||||
_add_screen(guest_book)
|
||||
guest_book.back_pressed.connect(go_back)
|
||||
|
||||
rulebook = RulebookScene.instantiate()
|
||||
_add_screen(rulebook)
|
||||
rulebook.back_pressed.connect(go_back)
|
||||
|
||||
profile = ProfileScene.instantiate()
|
||||
_add_screen(profile)
|
||||
profile.back_pressed.connect(go_back)
|
||||
|
||||
settings_sheet = SettingsSheetScene.instantiate()
|
||||
add_child(settings_sheet)
|
||||
settings_sheet.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
settings_sheet.visible = false
|
||||
settings_sheet.closed.connect(close_settings)
|
||||
settings_sheet.restart_requested.connect(_on_restart_requested)
|
||||
settings_sheet.lobby_requested.connect(_on_lobby_requested)
|
||||
settings_sheet.rules_requested.connect(_on_rules_requested)
|
||||
|
||||
screens = {
|
||||
"home": home,
|
||||
"game": game,
|
||||
"guest_book": guest_book,
|
||||
"rules": rulebook,
|
||||
"profile": profile,
|
||||
}
|
||||
|
||||
show_screen("home", false)
|
||||
@@ -42,6 +81,8 @@ func _add_screen(screen: Control) -> void:
|
||||
func show_screen(name: String, push: bool = true) -> void:
|
||||
if not screens.has(name):
|
||||
return
|
||||
if settings_sheet != null and settings_sheet.visible:
|
||||
close_settings()
|
||||
if name == current:
|
||||
screens[name].visible = true
|
||||
return
|
||||
@@ -53,6 +94,9 @@ func show_screen(name: String, push: bool = true) -> void:
|
||||
|
||||
current = name
|
||||
|
||||
if name == "guest_book":
|
||||
guest_book.refresh()
|
||||
|
||||
|
||||
func go_back() -> void:
|
||||
if nav_stack.is_empty():
|
||||
@@ -62,8 +106,48 @@ func go_back() -> void:
|
||||
show_screen(previous, false)
|
||||
|
||||
|
||||
func open_settings(mode: String) -> void:
|
||||
if settings_sheet == null:
|
||||
return
|
||||
if mode == "game":
|
||||
game.set_ui_paused(true)
|
||||
settings_sheet.open_sheet(mode)
|
||||
|
||||
|
||||
func close_settings() -> void:
|
||||
if settings_sheet == null:
|
||||
return
|
||||
if settings_sheet.visible:
|
||||
settings_sheet.visible = false
|
||||
game.set_ui_paused(false)
|
||||
|
||||
|
||||
func _on_restart_requested() -> void:
|
||||
game.restart_room()
|
||||
close_settings()
|
||||
|
||||
|
||||
func _on_lobby_requested() -> void:
|
||||
close_settings()
|
||||
nav_stack.clear()
|
||||
current = ""
|
||||
show_screen("home", false)
|
||||
|
||||
|
||||
func _on_rules_requested() -> void:
|
||||
close_settings()
|
||||
show_screen("rules")
|
||||
|
||||
|
||||
func _on_play() -> void:
|
||||
var max_index: int = max(0, game.levels.size() - 1)
|
||||
var start_index: int = clampi(int(SaveGame.data.get("last_room", 0)), 0, max_index)
|
||||
show_screen("game")
|
||||
game.start_level(start_index)
|
||||
|
||||
|
||||
func _on_daily() -> void:
|
||||
var key := Daily.today_key()
|
||||
var index := Daily.level_index(game.levels.size(), key)
|
||||
show_screen("game")
|
||||
game.start_daily(index, key)
|
||||
@@ -0,0 +1,103 @@
|
||||
class_name MiniDiagram
|
||||
extends Control
|
||||
|
||||
## Tiny 5x5 rule illustrations for the House Rules page.
|
||||
|
||||
const REGIONS := [
|
||||
[0, 0, 0, 0, 0],
|
||||
[1, 1, 1, 1, 0],
|
||||
[3, 1, 4, 2, 2],
|
||||
[3, 3, 4, 2, 2],
|
||||
[3, 4, 4, 4, 2],
|
||||
]
|
||||
|
||||
var mode := "row"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var side: float = min(size.x, size.y)
|
||||
var cell := side / 5.0
|
||||
var origin := (size - Vector2(side, side)) * 0.5
|
||||
var board := Rect2(origin, Vector2(side, side))
|
||||
|
||||
for r in 5:
|
||||
for c in 5:
|
||||
var rect := Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell))
|
||||
var region := int(REGIONS[r][c])
|
||||
var color: Color = Palette.REGION_COLORS[region % Palette.REGION_COLORS.size()]
|
||||
draw_rect(rect.grow(0.5), color)
|
||||
|
||||
# Highlight
|
||||
var accent := Color(0.91, 0.71, 0.36, 0.38)
|
||||
if mode == "row":
|
||||
draw_rect(Rect2(origin + Vector2(0, 2 * cell), Vector2(side, cell)), accent)
|
||||
elif mode == "col":
|
||||
draw_rect(Rect2(origin + Vector2(2 * cell, 0), Vector2(cell, side)), accent)
|
||||
elif mode == "region":
|
||||
for r in 5:
|
||||
for c in 5:
|
||||
if int(REGIONS[r][c]) == 0:
|
||||
draw_rect(Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell)), accent)
|
||||
|
||||
# Grid and room walls
|
||||
for i in range(6):
|
||||
var x := origin.x + i * cell
|
||||
var y := origin.y + i * cell
|
||||
draw_line(Vector2(x, origin.y), Vector2(x, origin.y + side), Palette.GRID, 1.0, true)
|
||||
draw_line(Vector2(origin.x, y), Vector2(origin.x + side, y), Palette.GRID, 1.0, true)
|
||||
for r in 5:
|
||||
for c in 5:
|
||||
var rect := Rect2(origin + Vector2(c * cell, r * cell), Vector2(cell, cell))
|
||||
if c == 4 or int(REGIONS[r][c]) != int(REGIONS[r][c + 1]):
|
||||
draw_line(rect.position + Vector2(cell, 0), rect.position + Vector2(cell, cell), Palette.WALL, 3.0, true)
|
||||
if r == 4 or int(REGIONS[r][c]) != int(REGIONS[r + 1][c]):
|
||||
draw_line(rect.position + Vector2(0, cell), rect.position + Vector2(cell, cell), Palette.WALL, 3.0, true)
|
||||
draw_rect(board, Palette.WALL, false, 4.0, true)
|
||||
|
||||
var rat_cell := Vector2i(2, 2)
|
||||
if mode == "region":
|
||||
rat_cell = Vector2i(0, 2)
|
||||
|
||||
_draw_rat(origin, cell, rat_cell)
|
||||
|
||||
if mode == "touch":
|
||||
for dr in range(-1, 2):
|
||||
for dc in range(-1, 2):
|
||||
if dr == 0 and dc == 0:
|
||||
continue
|
||||
var r := rat_cell.x + dr
|
||||
var c := rat_cell.y + dc
|
||||
if r >= 0 and r < 5 and c >= 0 and c < 5:
|
||||
_draw_x(origin, cell, Vector2i(r, c))
|
||||
var center := origin + (Vector2(rat_cell) + Vector2(0.5, 0.5)) * cell
|
||||
draw_arc(center, cell * 0.40, 0.0, TAU, 24, Palette.RED, 2.5, true)
|
||||
|
||||
|
||||
func _draw_rat(origin: Vector2, cell: float, at: Vector2i) -> void:
|
||||
var c := origin + (Vector2(at) + Vector2(0.5, 0.5)) * cell
|
||||
var fur := Color("8f6a4a")
|
||||
var ear := Color("e0a29a")
|
||||
draw_circle(c + Vector2(-0.16, -0.14) * cell, cell * 0.12, fur)
|
||||
draw_circle(c + Vector2(0.16, -0.14) * cell, cell * 0.12, fur)
|
||||
draw_circle(c + Vector2(-0.16, -0.14) * cell, cell * 0.07, ear)
|
||||
draw_circle(c + Vector2(0.16, -0.14) * cell, cell * 0.07, ear)
|
||||
draw_circle(c, cell * 0.22, fur)
|
||||
draw_circle(c + Vector2(0, 0.08) * cell, cell * 0.12, Color("f6e4c6"))
|
||||
draw_circle(c + Vector2(-0.08, -0.02) * cell, cell * 0.025, Palette.INK)
|
||||
draw_circle(c + Vector2(0.08, -0.02) * cell, cell * 0.025, Palette.INK)
|
||||
draw_circle(c + Vector2(0, 0.08) * cell, cell * 0.02, Color("c9736b"))
|
||||
|
||||
|
||||
func _draw_x(origin: Vector2, cell: float, at: Vector2i) -> void:
|
||||
var rect := Rect2(origin + Vector2(at.x * cell, at.y * cell), Vector2(cell, cell))
|
||||
var inset := cell * 0.30
|
||||
var a := rect.position + Vector2(inset, inset)
|
||||
var b := rect.position + Vector2(cell - inset, cell - inset)
|
||||
var c := rect.position + Vector2(cell - inset, inset)
|
||||
var d := rect.position + Vector2(inset, cell - inset)
|
||||
draw_line(a, b, Palette.RED, 2.0, true)
|
||||
draw_line(c, d, Palette.RED, 2.0, true)
|
||||
@@ -0,0 +1 @@
|
||||
uid://pss1icj4438q
|
||||
@@ -12,6 +12,8 @@ const MUTED := Color("8c7460")
|
||||
const WALL := Color("6e5039")
|
||||
const GRID := Color(0.43, 0.31, 0.22, 0.16)
|
||||
const GOLD := Color("e7b45c")
|
||||
const ORANGE := Color("e89a3c")
|
||||
const ORANGE_DARK := Color("c97924")
|
||||
const ROSE := Color("d98c86")
|
||||
const RED := Color("c65b4e")
|
||||
const WHITE := Color("fffaf0")
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
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.queue_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.queue_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
|
||||
# Never rebuild the card grid while the card's own `pressed` signal is
|
||||
# still on the stack; Godot locks the emitting node during the call.
|
||||
call_deferred("_apply_frame", id)
|
||||
|
||||
|
||||
func _apply_frame(id: String) -> void:
|
||||
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
|
||||
@@ -0,0 +1 @@
|
||||
uid://w44h7f4ea2ao
|
||||
@@ -0,0 +1,197 @@
|
||||
extends Control
|
||||
|
||||
signal back_pressed
|
||||
|
||||
const BoardScene = preload("res://scenes/Board.tscn")
|
||||
|
||||
var tutorial_board: Board
|
||||
var tutorial_status: Label
|
||||
var checkin_body: Label
|
||||
|
||||
|
||||
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("House Rules", 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
|
||||
column.add_child(scroll)
|
||||
|
||||
var content := VBoxContainer.new()
|
||||
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
content.add_theme_constant_override("separation", 6)
|
||||
scroll.add_child(content)
|
||||
|
||||
content.add_child(_heading("Welcome to the Rat Hotel", 18))
|
||||
content.add_child(_body("Crumb runs a small hotel for travelling rats. Every guest wants a room of their own — and a little space from the neighbours."))
|
||||
|
||||
content.add_child(_heading("The four house rules", 18))
|
||||
content.add_child(_rule_row("One guest per room", "Each coloured room holds exactly one rat.", "region"))
|
||||
content.add_child(_rule_row("One guest per floor", "Each row holds exactly one rat.", "row"))
|
||||
content.add_child(_rule_row("One guest per corridor", "Each column holds exactly one rat.", "col"))
|
||||
content.add_child(_rule_row("No shared walls or corners", "Rats cannot touch, not even diagonally.", "touch"))
|
||||
|
||||
content.add_child(_heading("Checking in", 18))
|
||||
checkin_body = _body(_checkin_text())
|
||||
content.add_child(checkin_body)
|
||||
content.add_child(_body("Undo is unlimited. Hints are free and explain the next sensible move."))
|
||||
|
||||
content.add_child(_heading("Try a tiny room", 18))
|
||||
content.add_child(_body("One guest is already checked in. Place the other four."))
|
||||
|
||||
var board_center := CenterContainer.new()
|
||||
content.add_child(board_center)
|
||||
tutorial_board = BoardScene.instantiate() as Board
|
||||
tutorial_board.custom_minimum_size = Vector2(240, 240)
|
||||
tutorial_board.solved.connect(_on_tutorial_solved)
|
||||
board_center.add_child(tutorial_board)
|
||||
|
||||
var controls := HBoxContainer.new()
|
||||
controls.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
controls.add_theme_constant_override("separation", 8)
|
||||
content.add_child(controls)
|
||||
|
||||
var reset := UI.button("Reset", false, 44)
|
||||
reset.custom_minimum_size = Vector2(100, 44)
|
||||
reset.add_theme_font_size_override("font_size", 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)
|
||||
hint.pressed.connect(_on_tutorial_hint)
|
||||
controls.add_child(hint)
|
||||
|
||||
tutorial_status = UI.label(UI.place_hint(), 10, Palette.MUTED)
|
||||
content.add_child(tutorial_status)
|
||||
SaveGame.settings_changed.connect(_refresh_hints)
|
||||
|
||||
content.add_child(_heading("Housekeeping tips", 18))
|
||||
content.add_child(_body("Start with the smallest room. If a room's open cells all sit in one row, that row's guest belongs to that room. Every room has one solution and never requires guessing."))
|
||||
|
||||
content.add_child(_heading("Questions", 18))
|
||||
content.add_child(_body("Why can't the rats touch? Every guest is a little grumpy after a long journey and wants their own space."))
|
||||
content.add_child(_body("Why do some guests have gold rings? They checked in early. They are part of the puzzle, not a mistake."))
|
||||
|
||||
var tutorial := _load_tutorial()
|
||||
if not tutorial.is_empty():
|
||||
tutorial_board.set_level(tutorial)
|
||||
|
||||
# Everything in the rules list passes drags to the ScrollContainer, so
|
||||
# a swipe works over labels and buttons. The practice board keeps its
|
||||
# own input.
|
||||
UI.pass_scroll_input(content, [tutorial_board])
|
||||
|
||||
|
||||
func _body(text: String) -> Label:
|
||||
var label := UI.label(text, 12, Palette.MUTED)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
return label
|
||||
|
||||
|
||||
func _heading(text: String, font_size: int = 18) -> Label:
|
||||
var label := UI.heading(text, font_size)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
return label
|
||||
|
||||
|
||||
func _rule_row(title: String, body: String, mode: String) -> PanelContainer:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 7)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(row)
|
||||
|
||||
var diagram := MiniDiagram.new()
|
||||
diagram.mode = mode
|
||||
diagram.custom_minimum_size = Vector2(72, 72)
|
||||
row.add_child(diagram)
|
||||
|
||||
var text := VBoxContainer.new()
|
||||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
text.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
text.add_theme_constant_override("separation", 0)
|
||||
row.add_child(text)
|
||||
|
||||
var heading := UI.label(title, 14)
|
||||
heading.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(heading)
|
||||
|
||||
var detail := UI.label(body, 10, Palette.MUTED)
|
||||
detail.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(detail)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func _load_tutorial() -> Dictionary:
|
||||
if not FileAccess.file_exists("res://data/tutorial.json"):
|
||||
return {}
|
||||
var file := FileAccess.open("res://data/tutorial.json", FileAccess.READ)
|
||||
if file == null:
|
||||
return {}
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
return parsed
|
||||
return {}
|
||||
|
||||
|
||||
func _checkin_text() -> String:
|
||||
var place := "Double-tap or right-click to check a guest in."
|
||||
if not bool(SaveGame.get_setting("double_tap_place")):
|
||||
place = "Hold or right-click to check a guest in."
|
||||
return "Tap or left-click to mark X. Tap an X or a guest to clear it. %s Gold-ringed guests are already in." % place
|
||||
|
||||
|
||||
func _refresh_hints() -> void:
|
||||
if checkin_body != null:
|
||||
checkin_body.text = _checkin_text()
|
||||
if tutorial_status != null and (
|
||||
tutorial_status.text == "Tap = X · Hold or right-click = check in"
|
||||
or tutorial_status.text == "Tap = X · Double-tap or right-click = check in"
|
||||
):
|
||||
tutorial_status.text = UI.place_hint()
|
||||
|
||||
|
||||
func _on_tutorial_reset() -> void:
|
||||
tutorial_board.restart()
|
||||
tutorial_status.text = UI.place_hint()
|
||||
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
|
||||
|
||||
|
||||
func _on_tutorial_hint() -> void:
|
||||
if tutorial_board.hint():
|
||||
tutorial_status.text = "Crumb tapped the right room."
|
||||
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
|
||||
else:
|
||||
tutorial_status.text = "Everyone is already checked in."
|
||||
tutorial_status.add_theme_color_override("font_color", Palette.MUTED)
|
||||
|
||||
|
||||
func _on_tutorial_solved() -> void:
|
||||
tutorial_status.text = "Everyone checked in. Nicely done."
|
||||
tutorial_status.add_theme_color_override("font_color", Palette.INK)
|
||||
@@ -0,0 +1 @@
|
||||
uid://0wfmdeab7oh3
|
||||
@@ -13,6 +13,7 @@ const DEFAULTS := {
|
||||
"show_timer": true,
|
||||
"reduce_motion": false,
|
||||
"hold_seconds": 0.35,
|
||||
"double_tap_place": true,
|
||||
}
|
||||
|
||||
var data := {}
|
||||
@@ -22,18 +23,29 @@ func _ready() -> void:
|
||||
load_game()
|
||||
|
||||
|
||||
func _default_daily() -> Dictionary:
|
||||
return {
|
||||
"last_completed": "",
|
||||
"streak": 0,
|
||||
"best_streak": 0,
|
||||
}
|
||||
|
||||
|
||||
func _default_data() -> Dictionary:
|
||||
return {
|
||||
"version": 1,
|
||||
"version": 3,
|
||||
"completed_rooms": [],
|
||||
"unlocked_guests": [],
|
||||
"settings": DEFAULTS.duplicate(true),
|
||||
"last_room": 0,
|
||||
"daily": _default_daily(),
|
||||
"profile_frame": "plain",
|
||||
}
|
||||
|
||||
|
||||
func load_game() -> void:
|
||||
data = _default_data()
|
||||
var stored_version := 3
|
||||
|
||||
if FileAccess.file_exists(PATH):
|
||||
var file := FileAccess.open(PATH, FileAccess.READ)
|
||||
@@ -41,6 +53,7 @@ func load_game() -> void:
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
stored_version = int(parsed.get("version", 1))
|
||||
for key in parsed:
|
||||
data[key] = parsed[key]
|
||||
|
||||
@@ -50,11 +63,34 @@ func load_game() -> void:
|
||||
if not data["settings"].has(key):
|
||||
data["settings"][key] = DEFAULTS[key]
|
||||
|
||||
var daily_defaults := _default_daily()
|
||||
if typeof(data.get("daily")) != TYPE_DICTIONARY:
|
||||
data["daily"] = daily_defaults
|
||||
else:
|
||||
for key in daily_defaults:
|
||||
if not data["daily"].has(key):
|
||||
data["daily"][key] = daily_defaults[key]
|
||||
if typeof(data.get("profile_frame")) != TYPE_STRING or str(data["profile_frame"]).is_empty():
|
||||
data["profile_frame"] = "plain"
|
||||
|
||||
var migrated := false
|
||||
# Version 2 made double-tap the default; version 3 added daily streaks
|
||||
# and profile frames. Both migrations are one-time.
|
||||
if stored_version < 2:
|
||||
data["settings"]["double_tap_place"] = true
|
||||
migrated = true
|
||||
if stored_version < 3:
|
||||
migrated = true
|
||||
|
||||
if typeof(data.get("completed_rooms")) != TYPE_ARRAY:
|
||||
data["completed_rooms"] = []
|
||||
if typeof(data.get("unlocked_guests")) != TYPE_ARRAY:
|
||||
data["unlocked_guests"] = []
|
||||
|
||||
if migrated:
|
||||
data["version"] = 3
|
||||
save_game()
|
||||
|
||||
|
||||
func save_game() -> void:
|
||||
var file := FileAccess.open(PATH, FileAccess.WRITE)
|
||||
@@ -117,3 +153,60 @@ func unlocked_count(guests: Array) -> int:
|
||||
if is_guest_unlocked(str(guest["id"])):
|
||||
total += 1
|
||||
return total
|
||||
|
||||
|
||||
func rooms_completed() -> int:
|
||||
return (data.get("completed_rooms") as Array).size()
|
||||
|
||||
|
||||
func daily_data() -> Dictionary:
|
||||
if typeof(data.get("daily")) != TYPE_DICTIONARY:
|
||||
data["daily"] = _default_daily()
|
||||
return data["daily"]
|
||||
|
||||
|
||||
func daily_streak() -> int:
|
||||
var daily := daily_data()
|
||||
var last := Daily.day_number(str(daily.get("last_completed", "")))
|
||||
var today := Daily.day_number(Daily.today_key())
|
||||
if last == today or last == today - 1:
|
||||
return int(daily.get("streak", 0))
|
||||
return 0
|
||||
|
||||
|
||||
func best_streak() -> int:
|
||||
return int(daily_data().get("best_streak", 0))
|
||||
|
||||
|
||||
func daily_completed_today() -> bool:
|
||||
return str(daily_data().get("last_completed", "")) == Daily.today_key()
|
||||
|
||||
|
||||
func complete_daily(key: String) -> bool:
|
||||
# Only today's room counts, and only once per local day.
|
||||
if key.is_empty() or key != Daily.today_key():
|
||||
return false
|
||||
var daily := daily_data()
|
||||
if str(daily.get("last_completed", "")) == key:
|
||||
return false
|
||||
|
||||
var today := Daily.day_number(key)
|
||||
var last := Daily.day_number(str(daily.get("last_completed", "")))
|
||||
var streak := int(daily.get("streak", 0)) + 1 if last == today - 1 else 1
|
||||
daily["streak"] = streak
|
||||
daily["last_completed"] = key
|
||||
daily["best_streak"] = max(int(daily.get("best_streak", 0)), streak)
|
||||
data["daily"] = daily
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
return true
|
||||
|
||||
|
||||
func selected_frame() -> String:
|
||||
return str(data.get("profile_frame", "plain"))
|
||||
|
||||
|
||||
func select_frame(id: String) -> void:
|
||||
data["profile_frame"] = id
|
||||
save_game()
|
||||
progress_changed.emit()
|
||||
@@ -0,0 +1,320 @@
|
||||
extends Control
|
||||
|
||||
signal closed
|
||||
signal restart_requested
|
||||
signal lobby_requested
|
||||
signal rules_requested
|
||||
|
||||
var game_mode := false
|
||||
var toggles := {}
|
||||
var hold_slider: HSlider
|
||||
var hold_value: Label
|
||||
var hold_panel: PanelContainer
|
||||
var game_actions: HBoxContainer
|
||||
var reset_row: Control
|
||||
var resume_button: Button
|
||||
var restart_dialog: ConfirmationDialog
|
||||
var reset_dialog: ConfirmationDialog
|
||||
var reset_status: Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
visible = false
|
||||
|
||||
var scrim := ColorRect.new()
|
||||
scrim.color = Color(0.18, 0.12, 0.08, 0.55)
|
||||
scrim.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
scrim.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
scrim.gui_input.connect(_on_scrim_input)
|
||||
add_child(scrim)
|
||||
|
||||
var panel := PanelContainer.new()
|
||||
panel.anchor_left = 0.0
|
||||
panel.anchor_right = 1.0
|
||||
panel.anchor_top = 1.0
|
||||
panel.anchor_bottom = 1.0
|
||||
panel.offset_top = -610
|
||||
panel.offset_bottom = -UI.safe_bottom()
|
||||
panel.offset_left = 0
|
||||
panel.offset_right = 0
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = Palette.CREAM
|
||||
style.corner_radius_top_left = 26
|
||||
style.corner_radius_top_right = 26
|
||||
style.content_margin_left = 16
|
||||
style.content_margin_right = 16
|
||||
style.content_margin_top = 12
|
||||
style.content_margin_bottom = 16
|
||||
style.shadow_color = Color(0.18, 0.12, 0.08, 0.24)
|
||||
style.shadow_size = 10
|
||||
panel.add_theme_stylebox_override("panel", style)
|
||||
add_child(panel)
|
||||
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(column)
|
||||
|
||||
var header := HBoxContainer.new()
|
||||
header.add_theme_constant_override("separation", 8)
|
||||
column.add_child(header)
|
||||
|
||||
var title := UI.label("Settings", 24)
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
header.add_child(title)
|
||||
|
||||
var close := UI.button("×", false, 36)
|
||||
close.custom_minimum_size = Vector2(42, 36)
|
||||
close.add_theme_font_size_override("font_size", 24)
|
||||
close.pressed.connect(_close)
|
||||
header.add_child(close)
|
||||
|
||||
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 list := VBoxContainer.new()
|
||||
list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
list.add_theme_constant_override("separation", 8)
|
||||
scroll.add_child(list)
|
||||
|
||||
_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, "Double-tap to place", "Tap = mark · double-tap = check in.", "double_tap_place")
|
||||
_add_hold_row(list)
|
||||
|
||||
list.add_child(UI.spacer(2))
|
||||
var rules := UI.button("How to play", false, 44)
|
||||
rules.add_theme_font_size_override("font_size", 15)
|
||||
rules.pressed.connect(func() -> void: rules_requested.emit())
|
||||
list.add_child(rules)
|
||||
|
||||
reset_row = _action_row("Reset progress", "Clear completed rooms and unlocked guests.", Palette.RED, _on_reset)
|
||||
list.add_child(reset_row)
|
||||
|
||||
reset_status = UI.label("", 10, Palette.MUTED)
|
||||
list.add_child(reset_status)
|
||||
|
||||
# Let swipes reach the sheet's ScrollContainer even when they start on a
|
||||
# label, toggle, or button.
|
||||
UI.pass_scroll_input(list)
|
||||
|
||||
game_actions = HBoxContainer.new()
|
||||
game_actions.add_theme_constant_override("separation", 6)
|
||||
column.add_child(game_actions)
|
||||
|
||||
var restart := UI.button("Restart", false, 40)
|
||||
restart.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
restart.add_theme_font_size_override("font_size", 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)
|
||||
lobby.pressed.connect(_on_lobby)
|
||||
game_actions.add_child(lobby)
|
||||
|
||||
var resume := UI.button("Resume", true, 52)
|
||||
resume.pressed.connect(_close)
|
||||
resume_button = resume
|
||||
column.add_child(resume)
|
||||
|
||||
column.add_child(UI.label(Version.BUILD_LABEL, 9, Palette.MUTED))
|
||||
|
||||
restart_dialog = ConfirmationDialog.new()
|
||||
restart_dialog.title = "Restart room?"
|
||||
restart_dialog.dialog_text = "This clears the current board and timer."
|
||||
restart_dialog.confirmed.connect(func() -> void: restart_requested.emit())
|
||||
add_child(restart_dialog)
|
||||
|
||||
reset_dialog = ConfirmationDialog.new()
|
||||
reset_dialog.title = "Reset progress?"
|
||||
reset_dialog.dialog_text = "This clears completed rooms and unlocked guests. Settings stay."
|
||||
reset_dialog.confirmed.connect(_on_reset_confirmed)
|
||||
add_child(reset_dialog)
|
||||
|
||||
|
||||
func open_sheet(mode: String) -> void:
|
||||
game_mode = mode == "game"
|
||||
game_actions.visible = game_mode
|
||||
reset_row.visible = not game_mode
|
||||
reset_status.visible = not game_mode
|
||||
resume_button.text = "Resume" if game_mode else "Close"
|
||||
refresh()
|
||||
visible = true
|
||||
move_to_front()
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
for key in toggles:
|
||||
toggles[key].button_pressed = bool(SaveGame.get_setting(key))
|
||||
if hold_slider != null:
|
||||
hold_slider.set_value_no_signal(float(SaveGame.get_setting("hold_seconds")))
|
||||
hold_value.text = "%.2f s" % hold_slider.value
|
||||
_update_hold_availability()
|
||||
|
||||
|
||||
func _add_pattern_row(parent: VBoxContainer) -> void:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(row)
|
||||
|
||||
var icon := UI.icon("res://assets/icons/leaf.svg", 18, Palette.INK)
|
||||
row.add_child(icon)
|
||||
|
||||
var label := UI.label("Room patterns", 15)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row.add_child(label)
|
||||
|
||||
var check := CheckButton.new()
|
||||
check.button_pressed = bool(SaveGame.get_setting("patterns"))
|
||||
check.toggled.connect(func(on: bool) -> void: SaveGame.set_setting("patterns", on))
|
||||
row.add_child(check)
|
||||
toggles["patterns"] = check
|
||||
parent.add_child(panel)
|
||||
|
||||
|
||||
func _add_toggle(parent: VBoxContainer, title: String, detail: String, key: String) -> void:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(row)
|
||||
|
||||
var text := VBoxContainer.new()
|
||||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
text.add_theme_constant_override("separation", 0)
|
||||
row.add_child(text)
|
||||
|
||||
var label := UI.label(title, 14)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(label)
|
||||
|
||||
var sub := UI.label(detail, 10, Palette.MUTED)
|
||||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(sub)
|
||||
|
||||
var check := CheckButton.new()
|
||||
check.button_pressed = bool(SaveGame.get_setting(key))
|
||||
check.toggled.connect(func(on: bool) -> void:
|
||||
SaveGame.set_setting(key, on)
|
||||
_update_hold_availability()
|
||||
)
|
||||
row.add_child(check)
|
||||
toggles[key] = check
|
||||
parent.add_child(panel)
|
||||
|
||||
|
||||
func _add_hold_row(parent: VBoxContainer) -> void:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||||
hold_panel = panel
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 2)
|
||||
panel.add_child(column)
|
||||
|
||||
var label := UI.label("Hold time", 14)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
column.add_child(label)
|
||||
|
||||
var sub := UI.label("How long to press before checking in.", 10, Palette.MUTED)
|
||||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
column.add_child(sub)
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
column.add_child(row)
|
||||
|
||||
hold_slider = HSlider.new()
|
||||
hold_slider.min_value = 0.20
|
||||
hold_slider.max_value = 0.50
|
||||
hold_slider.step = 0.05
|
||||
hold_slider.value = float(SaveGame.get_setting("hold_seconds"))
|
||||
hold_slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
hold_slider.value_changed.connect(_on_hold_changed)
|
||||
row.add_child(hold_slider)
|
||||
|
||||
hold_value = UI.label("%.2f s" % hold_slider.value, 11, Palette.MUTED)
|
||||
hold_value.custom_minimum_size = Vector2(46, 0)
|
||||
row.add_child(hold_value)
|
||||
|
||||
parent.add_child(panel)
|
||||
|
||||
|
||||
func _action_row(title: String, detail: String, color: Color, callback: Callable) -> Control:
|
||||
var panel := UI.panel(Palette.PAPER, 14, 8)
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
panel.add_child(row)
|
||||
|
||||
var text := VBoxContainer.new()
|
||||
text.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
text.add_theme_constant_override("separation", 0)
|
||||
row.add_child(text)
|
||||
|
||||
var label := UI.label(title, 14, color)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(label)
|
||||
|
||||
var sub := UI.label(detail, 10, Palette.MUTED)
|
||||
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
text.add_child(sub)
|
||||
|
||||
var go := UI.button("›", false, 34)
|
||||
go.custom_minimum_size = Vector2(38, 34)
|
||||
go.add_theme_font_size_override("font_size", 18)
|
||||
go.pressed.connect(callback)
|
||||
row.add_child(go)
|
||||
|
||||
return panel
|
||||
|
||||
|
||||
func _on_hold_changed(value: float) -> void:
|
||||
var snapped: float = snapped(value, 0.05)
|
||||
hold_value.text = "%.2f s" % snapped
|
||||
SaveGame.set_setting("hold_seconds", snapped)
|
||||
|
||||
|
||||
func _update_hold_availability() -> void:
|
||||
if hold_slider == null or hold_panel == null:
|
||||
return
|
||||
var enabled := not bool(SaveGame.get_setting("double_tap_place"))
|
||||
hold_slider.editable = enabled
|
||||
hold_slider.mouse_filter = Control.MOUSE_FILTER_PASS if enabled else Control.MOUSE_FILTER_IGNORE
|
||||
hold_panel.modulate = Color(1, 1, 1, 1.0 if enabled else 0.45)
|
||||
|
||||
|
||||
func _on_scrim_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
_close()
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
visible = false
|
||||
closed.emit()
|
||||
|
||||
|
||||
func _on_restart() -> void:
|
||||
restart_dialog.popup_centered()
|
||||
|
||||
|
||||
func _on_lobby() -> void:
|
||||
visible = false
|
||||
lobby_requested.emit()
|
||||
|
||||
|
||||
func _on_reset() -> void:
|
||||
reset_dialog.popup_centered()
|
||||
|
||||
|
||||
func _on_reset_confirmed() -> void:
|
||||
SaveGame.reset_progress()
|
||||
reset_status.text = "Progress reset."
|
||||
reset_status.add_theme_color_override("font_color", Palette.INK)
|
||||
@@ -0,0 +1 @@
|
||||
uid://csmjxuqhlpp0i
|
||||
@@ -1,10 +1,46 @@
|
||||
class_name UI
|
||||
extends RefCounted
|
||||
|
||||
## Small helpers so the screens stay readable.
|
||||
## Every control is built in code for now; we can move to .tscn layouts later.
|
||||
## 360dp design tokens. All sizes here are dp-like canvas units.
|
||||
|
||||
static func label(text: String, font_size: int, color: Color = Palette.INK) -> Label:
|
||||
const MARGIN := 16
|
||||
const GAP := 12
|
||||
const BTN_H := 54
|
||||
const BTN_FONT := 19
|
||||
const BODY := 16
|
||||
const SMALL := 14
|
||||
const CAPTION := 12
|
||||
const H1 := 44
|
||||
const H2 := 26
|
||||
const H3 := 21
|
||||
const RADIUS := 22
|
||||
|
||||
const FONT_HEADING_BASE := preload("res://assets/fonts/Fredoka-Variable.ttf")
|
||||
const FONT_BODY_BASE := preload("res://assets/fonts/Nunito-Variable.ttf")
|
||||
|
||||
static var _heading_font: FontVariation
|
||||
static var _body_font: FontVariation
|
||||
|
||||
|
||||
static func heading_font() -> Font:
|
||||
if _heading_font == null:
|
||||
_heading_font = FontVariation.new()
|
||||
_heading_font.base_font = FONT_HEADING_BASE
|
||||
var ts := TextServerManager.get_primary_interface()
|
||||
_heading_font.variation_opentype = { ts.name_to_tag("wght"): 600 }
|
||||
return _heading_font
|
||||
|
||||
|
||||
static func body_font() -> Font:
|
||||
if _body_font == null:
|
||||
_body_font = FontVariation.new()
|
||||
_body_font.base_font = FONT_BODY_BASE
|
||||
var ts := TextServerManager.get_primary_interface()
|
||||
_body_font.variation_opentype = { ts.name_to_tag("wght"): 400 }
|
||||
return _body_font
|
||||
|
||||
|
||||
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
|
||||
@@ -12,27 +48,67 @@ static func label(text: String, font_size: int, color: Color = Palette.INK) -> L
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
l.add_theme_font_size_override("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
|
||||
|
||||
|
||||
static func button(text: String, primary: bool = false, min_height: int = 58) -> Button:
|
||||
static func heading(text: String, font_size: int = H2, color: Color = Palette.INK) -> Label:
|
||||
return label(text, font_size, color, true)
|
||||
|
||||
|
||||
static func body(text: String, color: Color = Palette.INK, font_size: int = BODY) -> Label:
|
||||
return label(text, font_size, color, false)
|
||||
|
||||
|
||||
static func caption(text: String, color: Color = Palette.MUTED) -> Label:
|
||||
return label(text, CAPTION, color, false)
|
||||
|
||||
|
||||
static func button(text: String, primary: bool = false, min_height: int = BTN_H) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.custom_minimum_size = Vector2(0, min_height)
|
||||
b.add_theme_font_size_override("font_size", 22)
|
||||
b.add_theme_color_override("font_color", Palette.INK)
|
||||
b.add_theme_color_override("font_hover_color", Palette.INK)
|
||||
b.add_theme_color_override("font_pressed_color", Palette.INK)
|
||||
b.add_theme_color_override("font_focus_color", Palette.INK)
|
||||
b.add_theme_stylebox_override("normal", _button_style(Palette.GOLD if primary else Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _button_style((Palette.GOLD if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_stylebox_override("pressed", _button_style((Palette.GOLD if primary else Palette.PAPER).darkened(0.07)))
|
||||
b.add_theme_stylebox_override("focus", _button_style((Palette.GOLD if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_font_override("font", heading_font())
|
||||
b.add_theme_font_size_override("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)
|
||||
b.add_theme_color_override("font_focus_color", Palette.WHITE if primary else Palette.INK)
|
||||
b.add_theme_stylebox_override("normal", _button_style(Palette.ORANGE if primary else Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _button_style((Palette.ORANGE if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.add_theme_stylebox_override("pressed", _button_style((Palette.ORANGE if primary else Palette.PAPER).darkened(0.07)))
|
||||
b.add_theme_stylebox_override("focus", _button_style((Palette.ORANGE if primary else Palette.PAPER).lightened(0.05)))
|
||||
b.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
return b
|
||||
|
||||
|
||||
static func panel(color: Color = Palette.PAPER, radius: int = 28, margin: int = 24) -> PanelContainer:
|
||||
static func round_button(icon_path: String, size: int = 48) -> Button:
|
||||
var b := Button.new()
|
||||
b.custom_minimum_size = Vector2(size, size)
|
||||
b.icon = load(icon_path)
|
||||
b.expand_icon = false
|
||||
b.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
b.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
b.add_theme_stylebox_override("normal", _round_style(Palette.PAPER))
|
||||
b.add_theme_stylebox_override("hover", _round_style(Palette.PAPER.lightened(0.04)))
|
||||
b.add_theme_stylebox_override("pressed", _round_style(Palette.PAPER.darkened(0.06)))
|
||||
b.add_theme_stylebox_override("focus", _round_style(Palette.PAPER.lightened(0.04)))
|
||||
b.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
return b
|
||||
|
||||
|
||||
static func icon(icon_path: String, size: int = 20, color: Color = Palette.MUTED) -> TextureRect:
|
||||
var t := TextureRect.new()
|
||||
t.texture = load(icon_path)
|
||||
t.custom_minimum_size = Vector2(size, size)
|
||||
t.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
t.modulate = color
|
||||
t.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
return t
|
||||
|
||||
|
||||
static func panel(color: Color = Palette.PAPER, radius: int = RADIUS, margin: int = 16) -> PanelContainer:
|
||||
var p := PanelContainer.new()
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
@@ -45,24 +121,72 @@ static func panel(color: Color = Palette.PAPER, radius: int = 28, margin: int =
|
||||
s.content_margin_top = margin
|
||||
s.content_margin_bottom = margin
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.12)
|
||||
s.shadow_size = 6
|
||||
s.shadow_offset = Vector2(0, 4)
|
||||
s.shadow_size = 5
|
||||
s.shadow_offset = Vector2(0, 3)
|
||||
p.add_theme_stylebox_override("panel", s)
|
||||
return p
|
||||
|
||||
|
||||
static func spacer(height: int = GAP) -> Control:
|
||||
var c := Control.new()
|
||||
c.custom_minimum_size = Vector2(0, height)
|
||||
c.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
return c
|
||||
|
||||
|
||||
static func safe_top() -> int:
|
||||
return 30 if OS.has_feature("mobile") else 20
|
||||
|
||||
|
||||
static func safe_bottom() -> int:
|
||||
return 24 if OS.has_feature("mobile") else 14
|
||||
|
||||
|
||||
## Godot's ScrollContainer only sees a touch drag when the controls under the
|
||||
## finger let the event through. PASS keeps buttons clickable while allowing
|
||||
## the parent ScrollContainer to handle the same gesture. `skip` protects
|
||||
## controls that must own their input, such as the tutorial Board.
|
||||
static func pass_scroll_input(root: Node, skip: Array = []) -> void:
|
||||
if root is Control and not skip.has(root):
|
||||
root.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
for child in root.get_children():
|
||||
if skip.has(child):
|
||||
continue
|
||||
pass_scroll_input(child, skip)
|
||||
|
||||
|
||||
## Short control hint that follows the saved placement mode.
|
||||
static func place_hint() -> String:
|
||||
if bool(SaveGame.get_setting("double_tap_place")):
|
||||
return "Tap = X · Double-tap or right-click = check in"
|
||||
return "Tap = X · Hold or right-click = check in"
|
||||
|
||||
|
||||
static func _button_style(color: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
s.corner_radius_top_left = 18
|
||||
s.corner_radius_top_right = 18
|
||||
s.corner_radius_bottom_left = 18
|
||||
s.corner_radius_bottom_right = 18
|
||||
s.corner_radius_top_left = 26
|
||||
s.corner_radius_top_right = 26
|
||||
s.corner_radius_bottom_left = 26
|
||||
s.corner_radius_bottom_right = 26
|
||||
s.content_margin_left = 18
|
||||
s.content_margin_right = 18
|
||||
s.content_margin_top = 10
|
||||
s.content_margin_bottom = 10
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.14)
|
||||
s.shadow_size = 4
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.16)
|
||||
s.shadow_size = 5
|
||||
s.shadow_offset = Vector2(0, 3)
|
||||
return s
|
||||
|
||||
|
||||
static func _round_style(color: Color) -> StyleBoxFlat:
|
||||
var s := StyleBoxFlat.new()
|
||||
s.bg_color = color
|
||||
s.corner_radius_top_left = 26
|
||||
s.corner_radius_top_right = 26
|
||||
s.corner_radius_bottom_left = 26
|
||||
s.corner_radius_bottom_right = 26
|
||||
s.shadow_color = Color(0.29, 0.20, 0.14, 0.12)
|
||||
s.shadow_size = 4
|
||||
s.shadow_offset = Vector2(0, 2)
|
||||
return s
|
||||
@@ -0,0 +1,7 @@
|
||||
class_name Version
|
||||
extends RefCounted
|
||||
|
||||
const NUMBER := "0.5.1-alpha"
|
||||
const CODENAME := "QA & Stability"
|
||||
const BUILD_DATE := "2026-12-02"
|
||||
const BUILD_LABEL := "v0.5.1-alpha · build 2026-12-02"
|
||||
@@ -0,0 +1 @@
|
||||
uid://d354au72oeytm
|
||||
@@ -0,0 +1,25 @@
|
||||
param(
|
||||
[string]$Godot = "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe",
|
||||
[string]$Jdk = "E:\AndroidTools\jdk-17.0.21.1+2",
|
||||
[string]$Sdk = "E:\AndroidTools\sdk",
|
||||
[string]$Out = "build/Ratdoku.apk"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$project = Split-Path $PSScriptRoot -Parent
|
||||
$env:JAVA_HOME = $Jdk
|
||||
$env:ANDROID_HOME = $Sdk
|
||||
$env:ANDROID_SDK_ROOT = $Sdk
|
||||
$env:Path = "$Jdk\bin;$Sdk\platform-tools;$Sdk\build-tools\35.0.0;$env:Path"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $project "build") | Out-Null
|
||||
|
||||
Write-Host "Exporting $Out ..."
|
||||
& $Godot --headless --path $project --export-debug "Android" $Out
|
||||
|
||||
$apk = Join-Path $project $Out
|
||||
if (Test-Path $apk) {
|
||||
Get-Item $apk | Select-Object FullName, Length, LastWriteTime
|
||||
} else {
|
||||
throw "Export did not produce $apk"
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless puzzle generator.
|
||||
## Run from the project folder:
|
||||
## <godot> --headless --script res://tools/generate_levels.gd
|
||||
##
|
||||
## Writes data/levels.json.
|
||||
##
|
||||
## How it works:
|
||||
## 1. Pick a legal solution (one rat per row and column, none touching).
|
||||
## 2. Grow eight connected rooms around those eight rats.
|
||||
## 3. Ask the solver for alternate solutions.
|
||||
## 4. If the board is ambiguous, pin down a few of the intended rats as
|
||||
## "already checked in" clues until the solution is unique.
|
||||
##
|
||||
## Clues are capped at three. If a board needs more than that, it is rejected
|
||||
## and we start over. A later version can replace clues with room-shape
|
||||
## refinement, but for the prototype this keeps every puzzle provably unique.
|
||||
|
||||
const N := 8
|
||||
const COUNT := 30
|
||||
const MAX_CLUES := 3
|
||||
const OUT := "res://data/levels.json"
|
||||
const DIRS := [Vector2i(1, 0), Vector2i(-1, 0), Vector2i(0, 1), Vector2i(0, -1)]
|
||||
|
||||
var _n := 0
|
||||
var _regions: Array = []
|
||||
var _cap := 2
|
||||
var _found: Array = []
|
||||
var _used_cols := {}
|
||||
var _used_regions := {}
|
||||
var _clue_cols := {}
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
var rng := RandomNumberGenerator.new()
|
||||
rng.seed = 20261201
|
||||
|
||||
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path("res://data"))
|
||||
|
||||
var levels: Array = []
|
||||
var attempts := 0
|
||||
var rejected_ambiguous := 0
|
||||
var rejected_shape := 0
|
||||
|
||||
# Append to an existing pack instead of replacing it.
|
||||
if FileAccess.file_exists(OUT):
|
||||
var existing := FileAccess.open(OUT, FileAccess.READ)
|
||||
if existing != null:
|
||||
var parsed = JSON.parse_string(existing.get_as_text())
|
||||
existing.close()
|
||||
if typeof(parsed) == TYPE_ARRAY:
|
||||
levels = parsed
|
||||
|
||||
var starting_count := levels.size()
|
||||
print("Existing levels: %d, target: %d" % [starting_count, COUNT])
|
||||
|
||||
while levels.size() < COUNT and attempts < 60000:
|
||||
attempts += 1
|
||||
var sol := _sample_solution(rng)
|
||||
if sol.is_empty():
|
||||
continue
|
||||
|
||||
var regs := _grow_regions(sol, rng)
|
||||
if regs.is_empty():
|
||||
continue
|
||||
|
||||
if not _shape_ok(regs, sol):
|
||||
rejected_shape += 1
|
||||
continue
|
||||
|
||||
var clues = _find_clue_set(regs, sol, MAX_CLUES)
|
||||
if clues == null:
|
||||
rejected_ambiguous += 1
|
||||
continue
|
||||
if typeof(clues) != TYPE_ARRAY:
|
||||
rejected_ambiguous += 1
|
||||
continue
|
||||
|
||||
levels.append({
|
||||
"id": "room-%02d" % (levels.size() + 1),
|
||||
"n": N,
|
||||
"regions": regs,
|
||||
"solution": sol,
|
||||
"clues": clues,
|
||||
})
|
||||
|
||||
if levels.size() % 5 == 0:
|
||||
print("Accepted %d rooms after %d attempts." % [levels.size(), attempts])
|
||||
|
||||
var file := FileAccess.open(OUT, FileAccess.WRITE)
|
||||
if file == null:
|
||||
push_error("Could not write %s" % OUT)
|
||||
quit(1)
|
||||
return
|
||||
file.store_string(JSON.stringify(levels, "\t"))
|
||||
file.close()
|
||||
|
||||
print("Generated %d levels in %d attempts -> %s" % [levels.size(), attempts, OUT])
|
||||
print("New rooms this run: %d" % (levels.size() - starting_count))
|
||||
print("Rejects: shape=%d ambiguous=%d" % [rejected_shape, rejected_ambiguous])
|
||||
quit()
|
||||
|
||||
|
||||
func _sample_solution(rng: RandomNumberGenerator) -> Array:
|
||||
for attempt in range(600):
|
||||
var cols := []
|
||||
for i in N:
|
||||
cols.append(i)
|
||||
_shuffle(cols, rng)
|
||||
|
||||
var ok := true
|
||||
for i in range(N - 1):
|
||||
if abs(int(cols[i + 1]) - int(cols[i])) < 2:
|
||||
ok = false
|
||||
break
|
||||
if ok:
|
||||
return cols
|
||||
return []
|
||||
|
||||
|
||||
func _grow_regions(sol: Array, rng: RandomNumberGenerator) -> Array:
|
||||
var regions := []
|
||||
for r in N:
|
||||
var row := []
|
||||
for c in N:
|
||||
row.append(-1)
|
||||
regions.append(row)
|
||||
|
||||
var sizes := []
|
||||
for i in N:
|
||||
sizes.append(1)
|
||||
|
||||
for r in N:
|
||||
regions[r][int(sol[r])] = r
|
||||
|
||||
var remaining := N * N - N
|
||||
var guard := 0
|
||||
|
||||
while remaining > 0 and guard < 4000:
|
||||
guard += 1
|
||||
var order := []
|
||||
for i in N:
|
||||
order.append(i)
|
||||
_shuffle(order, rng)
|
||||
|
||||
for region in order:
|
||||
var candidates := _frontier(regions, region)
|
||||
if candidates.is_empty():
|
||||
continue
|
||||
var pick: Vector2i = candidates[rng.randi_range(0, candidates.size() - 1)]
|
||||
regions[pick.x][pick.y] = region
|
||||
sizes[region] += 1
|
||||
remaining -= 1
|
||||
|
||||
# Fill any enclosed pocket with its smallest neighbouring region.
|
||||
var progress := true
|
||||
while remaining > 0 and progress:
|
||||
progress = false
|
||||
for r in N:
|
||||
for c in N:
|
||||
if int(regions[r][c]) != -1:
|
||||
continue
|
||||
var neighbours := {}
|
||||
for d in DIRS:
|
||||
var nr: int = r + d.x
|
||||
var nc: int = c + d.y
|
||||
if nr >= 0 and nr < N and nc >= 0 and nc < N and int(regions[nr][nc]) >= 0:
|
||||
neighbours[int(regions[nr][nc])] = true
|
||||
if neighbours.is_empty():
|
||||
continue
|
||||
|
||||
var best := -1
|
||||
var best_size := 9999
|
||||
for reg in neighbours.keys():
|
||||
if int(sizes[reg]) < best_size:
|
||||
best_size = int(sizes[reg])
|
||||
best = int(reg)
|
||||
regions[r][c] = best
|
||||
sizes[best] += 1
|
||||
remaining -= 1
|
||||
progress = true
|
||||
|
||||
if remaining != 0:
|
||||
return []
|
||||
|
||||
return regions
|
||||
|
||||
|
||||
func _frontier(regions: Array, region: int) -> Array:
|
||||
var out: Array[Vector2i] = []
|
||||
for r in N:
|
||||
for c in N:
|
||||
if int(regions[r][c]) != region:
|
||||
continue
|
||||
for d in DIRS:
|
||||
var nr: int = r + d.x
|
||||
var nc: int = c + d.y
|
||||
if nr >= 0 and nr < N and nc >= 0 and nc < N and int(regions[nr][nc]) == -1:
|
||||
var cell := Vector2i(nr, nc)
|
||||
if not out.has(cell):
|
||||
out.append(cell)
|
||||
return out
|
||||
|
||||
|
||||
func _sizes(regions: Array) -> Array:
|
||||
var sizes := []
|
||||
for i in N:
|
||||
sizes.append(0)
|
||||
for r in N:
|
||||
for c in N:
|
||||
var region := int(regions[r][c])
|
||||
if region >= 0:
|
||||
sizes[region] += 1
|
||||
return sizes
|
||||
|
||||
|
||||
func _shape_ok(regions: Array, sol: Array) -> bool:
|
||||
var sizes := _sizes(regions)
|
||||
var total := 0
|
||||
for s in sizes:
|
||||
if int(s) < 3 or int(s) > 18:
|
||||
return false
|
||||
total += int(s)
|
||||
|
||||
var mean := float(total) / float(N)
|
||||
for s in sizes:
|
||||
if float(s) / mean > 2.4:
|
||||
return false
|
||||
|
||||
var seeds := {}
|
||||
for r in N:
|
||||
var reg := int(regions[r][int(sol[r])])
|
||||
if seeds.has(reg):
|
||||
return false
|
||||
seeds[reg] = true
|
||||
|
||||
return seeds.size() == N
|
||||
|
||||
|
||||
func _find_clue_set(regions: Array, sol: Array, max_clues: int) -> Variant:
|
||||
# Prefer zero clues, then one, then two, then three.
|
||||
if _find_solutions(regions, [], 2).size() == 1:
|
||||
return []
|
||||
|
||||
if max_clues >= 1:
|
||||
for r1 in N:
|
||||
var one := [[r1, int(sol[r1])]]
|
||||
if _find_solutions(regions, one, 2).size() == 1:
|
||||
return one
|
||||
|
||||
if max_clues >= 2:
|
||||
for r1 in N:
|
||||
for r2 in range(r1 + 1, N):
|
||||
var two := [[r1, int(sol[r1])], [r2, int(sol[r2])]]
|
||||
if _find_solutions(regions, two, 2).size() == 1:
|
||||
return two
|
||||
|
||||
if max_clues >= 3:
|
||||
for r1 in N:
|
||||
for r2 in range(r1 + 1, N):
|
||||
for r3 in range(r2 + 1, N):
|
||||
var three := [[r1, int(sol[r1])], [r2, int(sol[r2])], [r3, int(sol[r3])]]
|
||||
if _find_solutions(regions, three, 2).size() == 1:
|
||||
return three
|
||||
|
||||
return null
|
||||
|
||||
|
||||
func _find_solutions(regions: Array, clues: Array, cap: int) -> Array:
|
||||
_regions = regions
|
||||
_n = N
|
||||
_cap = cap
|
||||
_found = []
|
||||
_used_cols = {}
|
||||
_used_regions = {}
|
||||
_clue_cols = {}
|
||||
|
||||
for clue in clues:
|
||||
_clue_cols[int(clue[0])] = int(clue[1])
|
||||
|
||||
_collect(0, -1, [])
|
||||
return _found
|
||||
|
||||
|
||||
func _collect(row: int, prev_col: int, current: Array) -> void:
|
||||
if _found.size() >= _cap:
|
||||
return
|
||||
|
||||
if row == _n:
|
||||
_found.append(current.duplicate())
|
||||
return
|
||||
|
||||
if _clue_cols.has(row):
|
||||
var fixed_col := int(_clue_cols[row])
|
||||
if _can_place(row, fixed_col, prev_col):
|
||||
_place(row, fixed_col)
|
||||
current.append(fixed_col)
|
||||
_collect(row + 1, fixed_col, current)
|
||||
current.pop_back()
|
||||
_unplace(row, fixed_col)
|
||||
return
|
||||
|
||||
for c in range(_n):
|
||||
if not _can_place(row, c, prev_col):
|
||||
continue
|
||||
_place(row, c)
|
||||
current.append(c)
|
||||
_collect(row + 1, c, current)
|
||||
current.pop_back()
|
||||
_unplace(row, c)
|
||||
|
||||
|
||||
func _can_place(row: int, c: int, prev_col: int) -> bool:
|
||||
if _used_cols.has(c):
|
||||
return false
|
||||
var region := int(_regions[row][c])
|
||||
if _used_regions.has(region):
|
||||
return false
|
||||
if row > 0 and abs(c - prev_col) < 2:
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _place(row: int, c: int) -> void:
|
||||
_used_cols[c] = true
|
||||
_used_regions[int(_regions[row][c])] = true
|
||||
|
||||
|
||||
func _unplace(row: int, c: int) -> void:
|
||||
_used_cols.erase(c)
|
||||
_used_regions.erase(int(_regions[row][c]))
|
||||
|
||||
|
||||
func _same_solution(a: Array, b: Array) -> bool:
|
||||
for i in N:
|
||||
if int(a[i]) != int(b[i]):
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _alternate(solutions: Array, intended: Array) -> Array:
|
||||
for candidate in solutions:
|
||||
var same := true
|
||||
for i in N:
|
||||
if int(candidate[i]) != int(intended[i]):
|
||||
same = false
|
||||
break
|
||||
if not same:
|
||||
return candidate
|
||||
return []
|
||||
|
||||
|
||||
func _shuffle(arr: Array, rng: RandomNumberGenerator) -> void:
|
||||
for i in range(arr.size() - 1, 0, -1):
|
||||
var j := rng.randi_range(0, i)
|
||||
var tmp = arr[i]
|
||||
arr[i] = arr[j]
|
||||
arr[j] = tmp
|
||||
@@ -0,0 +1 @@
|
||||
uid://oy3sanp8disa
|
||||
@@ -0,0 +1,122 @@
|
||||
param(
|
||||
[switch]$Build,
|
||||
[switch]$Screenshots
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$project = Split-Path $PSScriptRoot -Parent
|
||||
$godot = "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"
|
||||
if (-not (Test-Path $godot)) {
|
||||
throw "Godot executable not found."
|
||||
}
|
||||
|
||||
$tempRoot = "C:\Users\enter\AppData\Local\Temp\opencode"
|
||||
New-Item -ItemType Directory -Force -Path $tempRoot | Out-Null
|
||||
$logFile = Join-Path $tempRoot "ratdoku-qa.log"
|
||||
Remove-Item $logFile -Force -ErrorAction SilentlyContinue
|
||||
|
||||
$failures = @()
|
||||
$checks = @()
|
||||
|
||||
function Write-Section([string]$text) {
|
||||
Write-Host "`n=== $text ==="
|
||||
Add-Content -Path $logFile -Value "=== $text ==="
|
||||
}
|
||||
|
||||
function Quote-Args([string[]]$items) {
|
||||
return ($items | ForEach-Object {
|
||||
if ($_ -match '\s') { '"' + $_ + '"' } else { $_ }
|
||||
}) -join " "
|
||||
}
|
||||
|
||||
function Invoke-Godot([string[]]$arguments, [string]$name, [string]$marker) {
|
||||
$outFile = Join-Path $tempRoot "qa-$name.out"
|
||||
$errFile = Join-Path $tempRoot "qa-$name.err"
|
||||
Remove-Item $outFile, $errFile -Force -ErrorAction SilentlyContinue
|
||||
|
||||
$process = Start-Process -FilePath $godot -ArgumentList (Quote-Args $arguments) `
|
||||
-Wait -PassThru -RedirectStandardOutput $outFile -RedirectStandardError $errFile
|
||||
|
||||
$text = ""
|
||||
if (Test-Path $outFile) { $text += (Get-Content $outFile -Raw) }
|
||||
if (Test-Path $errFile) { $text += "`n" + (Get-Content $errFile -Raw) }
|
||||
Add-Content -Path $logFile -Value $text
|
||||
|
||||
$hasMarker = $text -match [regex]::Escape($marker)
|
||||
$hasError = $text -match 'ERROR:|SCRIPT ERROR:|Parse Error|FAIL:|Assertion failed'
|
||||
if ($process.ExitCode -ne 0 -or -not $hasMarker -or $hasError) {
|
||||
$script:failures += $name
|
||||
Write-Host "FAIL $name (exit=$($process.ExitCode) marker=$hasMarker error=$hasError)"
|
||||
if (-not $hasMarker) { Write-Host " missing marker: $marker" }
|
||||
}
|
||||
else {
|
||||
Write-Host "PASS $name"
|
||||
$script:checks += $name
|
||||
}
|
||||
}
|
||||
|
||||
Write-Section "Godot project scan"
|
||||
Invoke-Godot @("--headless", "--path", $project, "--editor", "--quit") "class-scan" "Godot Engine"
|
||||
|
||||
$tests = @(
|
||||
@{ File = "tools/smoke_test.gd"; Marker = "SMOKE TEST: PASS"; Name = "smoke" },
|
||||
@{ File = "tools/ui_test.gd"; Marker = "UI TEST: PASS"; Name = "ui" },
|
||||
@{ File = "tools/qa_core.gd"; Marker = "QA CORE: PASS"; Name = "qa-core" },
|
||||
@{ File = "tools/qa_ui.gd"; Marker = "QA UI: PASS"; Name = "qa-ui" },
|
||||
@{ File = "tools/qa_input.gd"; Marker = "QA INPUT: PASS"; Name = "qa-input" }
|
||||
)
|
||||
|
||||
foreach ($test in $tests) {
|
||||
$path = Join-Path $project $test.File
|
||||
if (-not (Test-Path $path)) {
|
||||
$script:failures += $test.Name
|
||||
Write-Host "FAIL $($test.Name) (script missing: $($test.File))"
|
||||
continue
|
||||
}
|
||||
Write-Section $test.Name
|
||||
Invoke-Godot @(
|
||||
"--headless", "--path", $project,
|
||||
"--script", "res://$($test.File)", "--quit-after", "12000"
|
||||
) $test.Name $test.Marker
|
||||
}
|
||||
|
||||
if ($Screenshots) {
|
||||
Write-Section "screenshots"
|
||||
Invoke-Godot @("--path", $project, "--script", "res://tools/screenshot.gd", "--quit-after", "12000") "screenshots" "Saved"
|
||||
}
|
||||
|
||||
if ($Build) {
|
||||
Write-Section "android build"
|
||||
$buildScript = Join-Path $PSScriptRoot "build_android.ps1"
|
||||
$buildOut = Join-Path $tempRoot "qa-build.out"
|
||||
$buildErr = Join-Path $tempRoot "qa-build.err"
|
||||
Remove-Item $buildOut, $buildErr -Force -ErrorAction SilentlyContinue
|
||||
$buildProc = Start-Process -FilePath "powershell.exe" `
|
||||
-ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$buildScript`"" `
|
||||
-Wait -PassThru -RedirectStandardOutput $buildOut -RedirectStandardError $buildErr
|
||||
$buildOutput = ""
|
||||
if (Test-Path $buildOut) { $buildOutput += (Get-Content $buildOut -Raw) }
|
||||
if (Test-Path $buildErr) { $buildOutput += "`n" + (Get-Content $buildErr -Raw) }
|
||||
Add-Content -Path $logFile -Value $buildOutput
|
||||
$apk = Join-Path $project "build/Ratdoku.apk"
|
||||
if ($buildProc.ExitCode -ne 0 -or $buildOutput -notmatch 'DONE' -or -not (Test-Path $apk)) {
|
||||
$script:failures += "android-build"
|
||||
Write-Host "FAIL android-build"
|
||||
}
|
||||
else {
|
||||
Write-Host "PASS android-build"
|
||||
$script:checks += "android-build"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Section "summary"
|
||||
Write-Host "Passed: $($checks.Count)"
|
||||
Write-Host "Failed: $($failures.Count)"
|
||||
if ($failures.Count -gt 0) {
|
||||
Write-Host ("Failed suites: " + ($failures -join ", "))
|
||||
}
|
||||
Write-Host "Full log: $logFile"
|
||||
|
||||
if ($failures.Count -gt 0) { exit 1 }
|
||||
exit 0
|
||||
@@ -0,0 +1,503 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless core QA: save migration, daily logic, frames, and game data.
|
||||
## <godot> --headless --path . --script res://tools/qa_core.gd --quit-after 1200
|
||||
##
|
||||
## This suite only ever replaces the game's own save file (SaveGame.PATH).
|
||||
## It leaves every other file alone and restores a clean save before it exits.
|
||||
|
||||
var failures := 0
|
||||
var frames = null
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures += 1
|
||||
print("FAIL: ", message)
|
||||
|
||||
|
||||
func _note(message: String) -> void:
|
||||
print("QA CORE: ", message)
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
_check(save != null, "SaveGame autoload missing")
|
||||
if save == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
# Resolve Frames at runtime: a static reference compiles it before the
|
||||
# SaveGame autoload is registered when launched with --script.
|
||||
frames = load("res://scripts/Frames.gd")
|
||||
_check(frames != null, "Frames script missing")
|
||||
if frames == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
_test_save_migrations(save)
|
||||
_test_daily(save)
|
||||
_test_frames(save)
|
||||
_test_game_data(save)
|
||||
|
||||
_reset_to_clean(save)
|
||||
_finish()
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if failures == 0:
|
||||
print("QA CORE: PASS")
|
||||
quit(0)
|
||||
else:
|
||||
print("QA CORE: FAIL (%d)" % failures)
|
||||
quit(1)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _write_save(save, dict: Dictionary) -> void:
|
||||
var file := FileAccess.open(save.PATH, FileAccess.WRITE)
|
||||
if file == null:
|
||||
_check(false, "could not open save path for writing: %s" % save.PATH)
|
||||
return
|
||||
file.store_string(JSON.stringify(dict, "\t"))
|
||||
file.close()
|
||||
|
||||
|
||||
func _remove_save(save) -> void:
|
||||
if FileAccess.file_exists(save.PATH):
|
||||
var err := DirAccess.remove_absolute(ProjectSettings.globalize_path(save.PATH))
|
||||
if err != OK:
|
||||
_check(false, "could not remove test save file")
|
||||
|
||||
|
||||
func _reset_to_clean(save) -> void:
|
||||
save.data = save._default_data()
|
||||
save.save_game()
|
||||
save.load_game()
|
||||
|
||||
|
||||
func _same_value(a, b) -> bool:
|
||||
if typeof(a) == TYPE_INT or typeof(a) == TYPE_FLOAT:
|
||||
if typeof(b) == TYPE_INT or typeof(b) == TYPE_FLOAT:
|
||||
return absf(float(a) - float(b)) < 0.0001
|
||||
return false
|
||||
if typeof(a) == TYPE_BOOL or typeof(b) == TYPE_BOOL:
|
||||
return typeof(a) == TYPE_BOOL and typeof(b) == TYPE_BOOL and bool(a) == bool(b)
|
||||
return str(a) == str(b)
|
||||
|
||||
|
||||
func _is_default_daily(save, daily: Dictionary) -> bool:
|
||||
var defaults: Dictionary = save._default_daily()
|
||||
return (
|
||||
str(daily.get("last_completed", "")) == str(defaults["last_completed"])
|
||||
and _same_value(daily.get("streak", -1), defaults["streak"])
|
||||
and _same_value(daily.get("best_streak", -1), defaults["best_streak"])
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Save migration matrix
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _test_save_migrations(save) -> void:
|
||||
_note("1. save migration matrix")
|
||||
|
||||
# (a) No save file at all -> fresh version-3 defaults.
|
||||
_remove_save(save)
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "fresh save should be version 3")
|
||||
_check(bool(save.get_setting("double_tap_place")), "fresh save should default to double-tap")
|
||||
_check(_is_default_daily(save, save.daily_data()), "fresh save should have default daily stats")
|
||||
_check(save.selected_frame() == "plain", "fresh save should select the plain frame")
|
||||
_check((save.data.get("completed_rooms") as Array).is_empty(), "fresh save should have no rooms")
|
||||
_check((save.data.get("unlocked_guests") as Array).is_empty(), "fresh save should have no guests")
|
||||
|
||||
# (b) Version 1 with hold-to-place and no daily/frame keys -> migrate to v3.
|
||||
var v1: Dictionary = save._default_data()
|
||||
v1["version"] = 1
|
||||
v1["settings"]["double_tap_place"] = false
|
||||
v1.erase("daily")
|
||||
v1.erase("profile_frame")
|
||||
_write_save(save, v1)
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "version 1 should migrate to version 3")
|
||||
_check(bool(save.get_setting("double_tap_place")), "version 1 should migrate to double-tap")
|
||||
_check(_is_default_daily(save, save.daily_data()), "version 1 missing daily should become defaults")
|
||||
_check(save.selected_frame() == "plain", "version 1 missing frame should become plain")
|
||||
|
||||
# (c) Version 2 with hold-to-place -> stay on hold, gain v3 daily/frame data.
|
||||
var v2: Dictionary = save._default_data()
|
||||
v2["version"] = 2
|
||||
v2["settings"]["double_tap_place"] = false
|
||||
v2.erase("daily")
|
||||
v2.erase("profile_frame")
|
||||
_write_save(save, v2)
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "version 2 should migrate to version 3")
|
||||
_check(not bool(save.get_setting("double_tap_place")), "version 2 double_tap=false should stay false")
|
||||
_check(_is_default_daily(save, save.daily_data()), "version 2 missing daily should become defaults")
|
||||
_check(save.selected_frame() == "plain", "version 2 missing frame should become plain")
|
||||
|
||||
# (d) Valid JSON with the wrong top-level shape -> no crash, defaults restored.
|
||||
var broken := FileAccess.open(save.PATH, FileAccess.WRITE)
|
||||
if broken != null:
|
||||
broken.store_string("[]")
|
||||
broken.close()
|
||||
else:
|
||||
_check(false, "could not write wrong-shape save")
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "wrong-shape save should restore version 3 defaults")
|
||||
_check(bool(save.get_setting("double_tap_place")), "wrong-shape save should restore double-tap default")
|
||||
_check(_is_default_daily(save, save.daily_data()), "wrong-shape save should restore daily defaults")
|
||||
_check(save.selected_frame() == "plain", "wrong-shape save should restore plain frame")
|
||||
_check((save.data.get("completed_rooms") as Array).is_empty(), "malformed JSON should have no rooms")
|
||||
|
||||
# (e) Missing individual setting keys are filled from DEFAULTS.
|
||||
var partial: Dictionary = save._default_data()
|
||||
partial["version"] = 3
|
||||
partial["settings"] = {}
|
||||
_write_save(save, partial)
|
||||
save.load_game()
|
||||
for key in save.DEFAULTS:
|
||||
_check(save.data["settings"].has(key), "missing setting '%s' should be filled" % key)
|
||||
_check(
|
||||
_same_value(save.get_setting(key), save.DEFAULTS[key]),
|
||||
"filled setting '%s' should match DEFAULTS" % key
|
||||
)
|
||||
|
||||
# A version-3 save's explicit false must not be overwritten by a default.
|
||||
var explicit_false: Dictionary = save._default_data()
|
||||
explicit_false["version"] = 3
|
||||
explicit_false["settings"]["double_tap_place"] = false
|
||||
_write_save(save, explicit_false)
|
||||
save.load_game()
|
||||
_check(not bool(save.get_setting("double_tap_place")), "an explicit false should not be overwritten")
|
||||
_check(bool(save.get_setting("patterns")), "unlisted settings should still be filled from DEFAULTS")
|
||||
|
||||
_reset_to_clean(save)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Daily logic
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _test_daily(save) -> void:
|
||||
_note("2. daily logic")
|
||||
|
||||
var today: String = Daily.today_key()
|
||||
_check(today.length() == 10, "today key should be YYYY-MM-DD (10 chars)")
|
||||
_check(today.substr(4, 1) == "-" and today.substr(7, 1) == "-", "today key separators should be dashes")
|
||||
_check(
|
||||
today.substr(0, 4).is_valid_int()
|
||||
and today.substr(5, 2).is_valid_int()
|
||||
and today.substr(8, 2).is_valid_int(),
|
||||
"today key date parts should be numeric"
|
||||
)
|
||||
var now: Dictionary = Time.get_date_dict_from_system()
|
||||
_check(
|
||||
today == "%04d-%02d-%02d" % [int(now["year"]), int(now["month"]), int(now["day"])],
|
||||
"today key should match the system's local date"
|
||||
)
|
||||
_check(Daily.day_number("") == 0, "an empty key should map to day 0")
|
||||
_check(Daily.day_number("bad-key") == 0, "a malformed key should map to day 0")
|
||||
|
||||
# Round trip between date keys and day numbers.
|
||||
var base: int = Daily.day_number(today)
|
||||
_note(
|
||||
"day_number(%s)=%d, key_from_day_number=%s"
|
||||
% [today, base, Daily.key_from_day_number(base)]
|
||||
)
|
||||
_check(Daily.key_from_day_number(base) == today, "key_from_day_number(day_number(today)) should be today")
|
||||
for delta in [1, 7, 30, 100, 400]:
|
||||
var key: String = Daily.key_from_day_number(base + delta)
|
||||
_check(
|
||||
Daily.day_number(key) == base + delta,
|
||||
"day_number(key_from_day_number(%d)) should round trip" % delta
|
||||
)
|
||||
|
||||
# Level selection: stable, in range, and valid on 30 consecutive dates.
|
||||
_check(Daily.level_index(0, today) == -1, "level_index should be -1 with no levels")
|
||||
_check(Daily.level_index(-5, today) == -1, "level_index should be -1 with a negative level count")
|
||||
var idx: int = Daily.level_index(30, today)
|
||||
_check(idx >= 0 and idx < 30, "level_index(30) should be in range")
|
||||
_check(idx == Daily.level_index(30, today), "level_index should be stable for the same date")
|
||||
var all_valid := true
|
||||
var distinct := {}
|
||||
for d in range(30):
|
||||
var key: String = Daily.key_from_day_number(base + d)
|
||||
var i: int = Daily.level_index(30, key)
|
||||
if i < 0 or i >= 30:
|
||||
all_valid = false
|
||||
distinct[i] = true
|
||||
_check(all_valid, "30 consecutive dates should all produce valid daily indices")
|
||||
_note("distinct daily levels across 30 consecutive days: %d" % distinct.size())
|
||||
|
||||
_reset_to_clean(save)
|
||||
|
||||
# Consecutive days extend the streak and mark today complete.
|
||||
var yesterday: String = Daily.key_from_day_number(Daily.day_number(today) - 1)
|
||||
var daily: Dictionary = save._default_daily()
|
||||
daily["last_completed"] = yesterday
|
||||
daily["streak"] = 2
|
||||
daily["best_streak"] = 2
|
||||
save.data["daily"] = daily
|
||||
var rooms_before: Array = (save.data["completed_rooms"] as Array).duplicate()
|
||||
var guests_before: Array = (save.data["unlocked_guests"] as Array).duplicate()
|
||||
_check(Daily.day_number(yesterday) == Daily.day_number(today) - 1, "yesterday key should be one day before today")
|
||||
_check(save.complete_daily(today), "completing today's daily should count")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 3, "consecutive daily should extend the streak to 3")
|
||||
_check(save.daily_streak() == 3, "daily_streak should report a live streak of 3")
|
||||
_check(save.best_streak() == 3, "best_streak should rise to 3")
|
||||
_check(save.daily_completed_today(), "daily_completed_today should be true")
|
||||
_check((save.data["completed_rooms"] as Array) == rooms_before, "daily must not change completed_rooms")
|
||||
_check((save.data["unlocked_guests"] as Array) == guests_before, "daily must not change unlocked_guests")
|
||||
|
||||
# Same-day replay and wrong dates do nothing.
|
||||
_check(not save.complete_daily(today), "same-day replay should return false")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 3, "same-day replay should not change the streak")
|
||||
_check(not save.complete_daily(yesterday), "an older date should not count")
|
||||
_check(not save.complete_daily(""), "an empty key should not count")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 3, "rejected dates should not change the streak")
|
||||
|
||||
# A gap resets the current streak but keeps the best.
|
||||
_reset_to_clean(save)
|
||||
var older: String = Daily.key_from_day_number(Daily.day_number(today) - 3)
|
||||
daily = save._default_daily()
|
||||
daily["last_completed"] = older
|
||||
daily["streak"] = 9
|
||||
daily["best_streak"] = 9
|
||||
save.data["daily"] = daily
|
||||
_check(save.complete_daily(today), "a daily after a gap should still count")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 1, "a gap should reset the streak to 1")
|
||||
_check(save.best_streak() == 9, "best_streak should survive a gap")
|
||||
|
||||
# Best streak persists; a stale streak is reported as dead.
|
||||
var best: int = save.best_streak()
|
||||
save.data["daily"]["streak"] = 0
|
||||
save.save_game()
|
||||
save.load_game()
|
||||
_check(save.best_streak() == best, "best_streak should persist through save/load")
|
||||
_check(save.daily_streak() == 0, "a zero streak should be reported as 0")
|
||||
save.data["daily"] = save._default_daily()
|
||||
_check(not save.daily_completed_today(), "a fresh daily state should not be complete today")
|
||||
_check(save.daily_streak() == 0, "a fresh daily state should have no live streak")
|
||||
|
||||
_reset_to_clean(save)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. Frames
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _test_frames(save) -> void:
|
||||
_note("3. frames")
|
||||
|
||||
_reset_to_clean(save)
|
||||
_check(frames.all().size() == 7, "there should be seven profile frames")
|
||||
_check(frames.is_unlocked("plain"), "plain frame should always be unlocked")
|
||||
_check(not frames.requirement_text("plain").is_empty(), "plain frame should have requirement text")
|
||||
|
||||
var locked_at_zero: Array = ["paper", "gold", "bell", "star", "regular", "night"]
|
||||
for id in locked_at_zero:
|
||||
_check(not frames.is_unlocked(str(id)), "%s should be locked with no progress" % id)
|
||||
_check(not frames.requirement_text(str(id)).is_empty(), "%s should show a requirement while locked" % id)
|
||||
_check(frames.by_id("does-not-exist").is_empty(), "unknown frame id should resolve to nothing")
|
||||
_check(not frames.is_unlocked("does-not-exist"), "unknown frame should never be unlocked")
|
||||
_check(frames.requirement_text("does-not-exist").is_empty(), "unknown frame should have empty requirement text")
|
||||
|
||||
var room_thresholds := {"paper": 5, "gold": 10, "bell": 20, "star": 30}
|
||||
for id in room_thresholds:
|
||||
var need: int = int(room_thresholds[id])
|
||||
save.data["completed_rooms"] = []
|
||||
for i in range(need - 1):
|
||||
save.data["completed_rooms"].append("room-probe-%d" % i)
|
||||
_check(not frames.is_unlocked(str(id)), "%s should be locked at %d rooms" % [id, need - 1])
|
||||
save.data["completed_rooms"].append("room-probe-last")
|
||||
_check(frames.is_unlocked(str(id)), "%s should unlock at %d rooms" % [id, need])
|
||||
|
||||
_reset_to_clean(save)
|
||||
var streak_thresholds := {"regular": 3, "night": 7}
|
||||
for id in streak_thresholds:
|
||||
var need: int = int(streak_thresholds[id])
|
||||
save.data["daily"]["best_streak"] = need - 1
|
||||
_check(not frames.is_unlocked(str(id)), "%s should be locked at a %d-day best streak" % [id, need - 1])
|
||||
save.data["daily"]["best_streak"] = need
|
||||
_check(frames.is_unlocked(str(id)), "%s should unlock at a %d-day best streak" % [id, need])
|
||||
|
||||
# Selecting a locked frame must not make it unlocked.
|
||||
_reset_to_clean(save)
|
||||
save.select_frame("star")
|
||||
save.save_game()
|
||||
save.load_game()
|
||||
_check(save.selected_frame() == "star", "selection itself should persist")
|
||||
_check(not frames.is_unlocked("star"), "selecting a locked frame must not unlock it")
|
||||
|
||||
# A legitimately unlocked selection survives save/load.
|
||||
_reset_to_clean(save)
|
||||
for i in range(5):
|
||||
save.data["completed_rooms"].append("room-%02d" % i)
|
||||
save.select_frame("paper")
|
||||
save.save_game()
|
||||
save.load_game()
|
||||
_check(frames.is_unlocked("paper"), "five-room unlock should survive save/load")
|
||||
_check(save.selected_frame() == "paper", "frame selection should persist through save/load")
|
||||
|
||||
# Document reset_progress()'s actual behaviour instead of guessing.
|
||||
_reset_to_clean(save)
|
||||
save.data["completed_rooms"] = ["room-a", "room-b", "room-c"]
|
||||
save.data["unlocked_guests"] = ["pepper", "miso"]
|
||||
save.data["last_room"] = 3
|
||||
save.data["daily"]["best_streak"] = 5
|
||||
save.data["daily"]["streak"] = 2
|
||||
save.data["daily"]["last_completed"] = Daily.today_key()
|
||||
save.select_frame("regular")
|
||||
save.reset_progress()
|
||||
_note(
|
||||
"reset_progress -> rooms=%d guests=%d last_room=%d best_streak=%d streak=%d last_completed=%s frame=%s"
|
||||
% [
|
||||
save.rooms_completed(),
|
||||
(save.data["unlocked_guests"] as Array).size(),
|
||||
int(save.data["last_room"]),
|
||||
save.best_streak(),
|
||||
int(save.daily_data().get("streak", -1)),
|
||||
str(save.daily_data().get("last_completed", "")),
|
||||
save.selected_frame()
|
||||
]
|
||||
)
|
||||
_check(save.rooms_completed() == 0, "reset_progress should clear completed_rooms")
|
||||
_check((save.data["unlocked_guests"] as Array).is_empty(), "reset_progress should clear unlocked_guests")
|
||||
_check(int(save.data["last_room"]) == 0, "reset_progress should clear last_room")
|
||||
_check(save.best_streak() == 5, "reset_progress should leave best_streak alone")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 2, "reset_progress should leave the daily streak alone")
|
||||
_check(
|
||||
str(save.daily_data().get("last_completed", "")) == Daily.today_key(),
|
||||
"reset_progress should leave last_completed alone"
|
||||
)
|
||||
_check(save.selected_frame() == "regular", "reset_progress should leave the selected frame alone")
|
||||
|
||||
_reset_to_clean(save)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 4. Level and guest data
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
func _test_game_data(save) -> void:
|
||||
_note("4. level/guest data")
|
||||
|
||||
var levels: Array = Levels.load_all()
|
||||
_check(levels.size() == 30, "there should be 30 levels")
|
||||
if levels.is_empty():
|
||||
return
|
||||
|
||||
var board := Board.new()
|
||||
root.add_child(board)
|
||||
|
||||
var bad_shape := 0
|
||||
var bad_solution := 0
|
||||
var bad_clues := 0
|
||||
var bad_regions := 0
|
||||
var bad_rats := 0
|
||||
var bad_region_rats := 0
|
||||
var valid_guests: Dictionary = {}
|
||||
for guest in Guests.all():
|
||||
valid_guests[str(guest.get("id", ""))] = true
|
||||
|
||||
for level_variant in levels:
|
||||
if typeof(level_variant) != TYPE_DICTIONARY:
|
||||
bad_shape += 1
|
||||
continue
|
||||
var level: Dictionary = level_variant
|
||||
var n: int = int(level.get("n", 0))
|
||||
var regions: Array = level.get("regions", [])
|
||||
var solution: Array = level.get("solution", [])
|
||||
var clues: Array = level.get("clues", [])
|
||||
var label: String = str(level.get("id", "?"))
|
||||
|
||||
if n != 8:
|
||||
bad_shape += 1
|
||||
if regions.size() != n:
|
||||
bad_regions += 1
|
||||
else:
|
||||
for row in regions:
|
||||
if (row as Array).size() != n:
|
||||
bad_regions += 1
|
||||
var region_ids := {}
|
||||
for row in regions:
|
||||
for value in row:
|
||||
region_ids[int(value)] = true
|
||||
if region_ids.size() != n:
|
||||
bad_regions += 1
|
||||
|
||||
if solution.size() != n:
|
||||
bad_solution += 1
|
||||
else:
|
||||
var cells := []
|
||||
for r in n:
|
||||
var row := []
|
||||
for c in n:
|
||||
row.append(Rules.EMPTY)
|
||||
cells.append(row)
|
||||
for r in n:
|
||||
var c: int = int(solution[r])
|
||||
if c >= 0 and c < n:
|
||||
cells[r][c] = Rules.RAT
|
||||
if not Rules.is_valid(cells, regions):
|
||||
bad_solution += 1
|
||||
if Rules.count_rats(cells) != n:
|
||||
bad_solution += 1
|
||||
|
||||
if clues.size() != 3:
|
||||
bad_clues += 1
|
||||
else:
|
||||
for clue in clues:
|
||||
var cr: int = int(clue[0])
|
||||
var cc: int = int(clue[1])
|
||||
if cr < 0 or cr >= n or cc < 0 or cc >= n or int(solution[cr]) != cc:
|
||||
bad_clues += 1
|
||||
|
||||
board.set_level(level)
|
||||
if board.region_rats.size() != 8:
|
||||
bad_region_rats += 1
|
||||
var seen := {}
|
||||
for id_variant in board.region_rats:
|
||||
var id: String = str(id_variant)
|
||||
if seen.has(id) or not valid_guests.has(id):
|
||||
bad_region_rats += 1
|
||||
seen[id] = true
|
||||
if seen.size() != 8:
|
||||
bad_region_rats += 1
|
||||
if board.fixed.size() != 3:
|
||||
bad_rats += 1
|
||||
|
||||
_check(bad_shape == 0, "every level should have n=8 (%d bad)" % bad_shape)
|
||||
_check(bad_regions == 0, "every level should have an 8x8 region grid with 8 regions (%d bad)" % bad_regions)
|
||||
_check(bad_solution == 0, "every solution should be a legal board under Rules (%d bad)" % bad_solution)
|
||||
_check(bad_clues == 0, "every level should have 3 clues matching its solution (%d bad)" % bad_clues)
|
||||
_check(bad_region_rats == 0, "every level should carry 8 unique guest ids in Board.region_rats (%d bad)" % bad_region_rats)
|
||||
_check(bad_rats == 0, "every level should fix 3 clue rats on its board (%d bad)" % bad_rats)
|
||||
|
||||
board.free()
|
||||
|
||||
var guests: Array = Guests.all()
|
||||
_check(guests.size() == 25, "guest manifest should contain 25 guests")
|
||||
var guest_ids := {}
|
||||
var duplicate_guests := 0
|
||||
for guest in guests:
|
||||
var id: String = str(guest.get("id", ""))
|
||||
if guest_ids.has(id) or id.is_empty():
|
||||
duplicate_guests += 1
|
||||
guest_ids[id] = true
|
||||
_check(FileAccess.file_exists(Guests.portrait(id, "thumbs")), "missing thumb portrait for '%s'" % id)
|
||||
_check(FileAccess.file_exists(Guests.portrait(id, "full")), "missing card portrait for '%s'" % id)
|
||||
_check(duplicate_guests == 0, "guest ids should be non-empty and unique (%d bad)" % duplicate_guests)
|
||||
|
||||
_check(FileAccess.file_exists("res://art/crumb_head.png"), "Crumb head art should exist")
|
||||
_check(FileAccess.file_exists("res://art/crumb.png"), "Crumb art should exist")
|
||||
@@ -0,0 +1 @@
|
||||
uid://dsjew0n3nwi1
|
||||
@@ -0,0 +1,428 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless input QA: board placement modes, Guest Book tap/scroll gestures,
|
||||
## and scroll pass-through on the scrolling screens.
|
||||
## <godot> --headless --path <project> --script res://tools/qa_input.gd --quit-after 1800
|
||||
|
||||
var failures := 0
|
||||
var finished := false
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures += 1
|
||||
print("FAIL: ", message)
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if finished:
|
||||
return
|
||||
finished = true
|
||||
print("QA INPUT: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
||||
quit(0 if failures == 0 else 1)
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
# Failsafe: never leave the command line hanging.
|
||||
var watchdog := Timer.new()
|
||||
watchdog.wait_time = 20.0
|
||||
watchdog.one_shot = true
|
||||
watchdog.timeout.connect(func() -> void:
|
||||
if not finished:
|
||||
_check(false, "QA timed out")
|
||||
_finish()
|
||||
)
|
||||
root.add_child(watchdog)
|
||||
watchdog.start()
|
||||
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
_check(save != null, "SaveGame autoload missing")
|
||||
if save == null:
|
||||
_finish()
|
||||
return
|
||||
|
||||
# Snapshot so the user's settings are exactly as we found them.
|
||||
var original_settings: Dictionary = save.data["settings"].duplicate(true)
|
||||
|
||||
_test_board_modes(save)
|
||||
|
||||
var err := change_scene_to_file("res://scenes/Main.tscn")
|
||||
if err != OK:
|
||||
_check(false, "could not load Main (%d)" % err)
|
||||
_restore_settings(save, original_settings)
|
||||
_finish()
|
||||
return
|
||||
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var main = current_scene
|
||||
_check(main != null, "Main scene missing")
|
||||
if main == null:
|
||||
_restore_settings(save, original_settings)
|
||||
_finish()
|
||||
return
|
||||
|
||||
await _test_scroll_pass_through(main)
|
||||
await _test_guest_book_input(main)
|
||||
|
||||
_restore_settings(save, original_settings)
|
||||
_finish()
|
||||
|
||||
|
||||
func _restore_settings(save, original: Dictionary) -> void:
|
||||
for key in original:
|
||||
save.set_setting(key, original[key])
|
||||
save.save_game()
|
||||
|
||||
|
||||
# --- Board -------------------------------------------------------------------
|
||||
|
||||
func _test_board_modes(save) -> void:
|
||||
var levels: Array = Levels.load_all()
|
||||
_check(levels.size() > 0, "no levels available")
|
||||
if levels.is_empty():
|
||||
return
|
||||
var level: Dictionary = levels[0]
|
||||
|
||||
var board := Board.new()
|
||||
root.add_child(board)
|
||||
board.size = Vector2(640, 640)
|
||||
board.set_level(level)
|
||||
board._update_layout()
|
||||
_reset_press(board)
|
||||
|
||||
# ---------------------------------------------------------------- hold mode
|
||||
save.set_setting("hold_seconds", 0.35)
|
||||
save.set_setting("double_tap_place", false)
|
||||
_check(not board.double_tap_place, "hold mode setting did not reach Board")
|
||||
|
||||
# Quick press + release marks an X.
|
||||
var tap_cell := _find_empty(board)
|
||||
_check(tap_cell.x >= 0, "no empty cell for hold-mode tap")
|
||||
if tap_cell.x >= 0:
|
||||
_mouse_button(board, tap_cell, true)
|
||||
_mouse_button(board, tap_cell, false)
|
||||
_check(int(board.cells[tap_cell.x][tap_cell.y]) == Board.X,
|
||||
"hold mode: press + release should mark X")
|
||||
|
||||
# A press held past the threshold checks a guest in, and releasing keeps it.
|
||||
var hold_cell := _find_empty(board)
|
||||
_check(hold_cell.x >= 0, "no empty cell for hold")
|
||||
if hold_cell.x >= 0:
|
||||
_mouse_button(board, hold_cell, true)
|
||||
board._process(board.hold_seconds + 0.05)
|
||||
_check(int(board.cells[hold_cell.x][hold_cell.y]) == Board.RAT,
|
||||
"hold past the threshold should place a rat")
|
||||
_check(board.hold_fired, "hold_fired should be set after the threshold")
|
||||
_mouse_button(board, hold_cell, false)
|
||||
_check(int(board.cells[hold_cell.x][hold_cell.y]) == Board.RAT,
|
||||
"releasing after a hold should keep the rat")
|
||||
_check(board.press_cell == Vector2i(-1, -1), "release should clear press_cell")
|
||||
_check(not board.hold_fired, "release should clear hold_fired")
|
||||
|
||||
# Right-click checks a guest in, then out.
|
||||
var right_cell := _find_empty(board)
|
||||
_check(right_cell.x >= 0, "no empty cell for right-click")
|
||||
if right_cell.x >= 0:
|
||||
_right_click(board, right_cell)
|
||||
_check(int(board.cells[right_cell.x][right_cell.y]) == Board.RAT,
|
||||
"right-click should check a guest in")
|
||||
_right_click(board, right_cell)
|
||||
_check(int(board.cells[right_cell.x][right_cell.y]) == Board.EMPTY,
|
||||
"right-click should check a guest out")
|
||||
|
||||
# Fixed clues cannot be changed by any input path.
|
||||
if board.fixed.is_empty():
|
||||
_check(false, "test level has no fixed clues")
|
||||
else:
|
||||
var fixed_cell: Vector2i = board.fixed.keys()[0]
|
||||
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
|
||||
"fixed clue should start as a rat")
|
||||
board._toggle_rat(fixed_cell)
|
||||
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
|
||||
"right-click must not remove a fixed clue")
|
||||
board._tap(fixed_cell)
|
||||
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
|
||||
"tap must not clear a fixed clue")
|
||||
_reset_press(board)
|
||||
_mouse_button(board, fixed_cell, true)
|
||||
_mouse_button(board, fixed_cell, false)
|
||||
_check(int(board.cells[fixed_cell.x][fixed_cell.y]) == Board.RAT,
|
||||
"press + release must not change a fixed clue")
|
||||
|
||||
# Undo and restart discard a tap waiting for its partner.
|
||||
var undo_cell := _find_empty(board)
|
||||
_check(undo_cell.x >= 0, "no empty cell for pending-undo test")
|
||||
_check(not board.history.is_empty(), "board history should be non-empty before undo")
|
||||
board.pending_tap_cell = undo_cell
|
||||
board.pending_tap_at = Time.get_ticks_msec()
|
||||
board.undo()
|
||||
_check(board.pending_tap_cell == Vector2i(-1, -1), "undo should clear a pending tap")
|
||||
|
||||
var restart_cell := _find_empty(board)
|
||||
_check(restart_cell.x >= 0, "no empty cell for pending-restart test")
|
||||
board.pending_tap_cell = restart_cell
|
||||
board.pending_tap_at = Time.get_ticks_msec()
|
||||
board.restart()
|
||||
_check(board.pending_tap_cell == Vector2i(-1, -1), "restart should clear a pending tap")
|
||||
|
||||
# --------------------------------------------------------- double-tap mode
|
||||
save.set_setting("double_tap_place", true)
|
||||
_check(board.double_tap_place, "double-tap setting did not reach Board")
|
||||
board.set_level(level)
|
||||
board._update_layout()
|
||||
_reset_press(board)
|
||||
|
||||
# One tap leaves the cell untouched until the window expires.
|
||||
var first := _find_empty(board)
|
||||
_check(first.x >= 0, "no empty cell for first tap")
|
||||
if first.x >= 0:
|
||||
board._handle_tap(first)
|
||||
_check(int(board.cells[first.x][first.y]) == Board.EMPTY,
|
||||
"first tap should leave the cell empty")
|
||||
_check(board.pending_tap_cell == first, "first tap should be pending")
|
||||
board.pending_tap_at -= Board.DOUBLE_TAP_MS + 1
|
||||
board._process(0.0)
|
||||
_check(int(board.cells[first.x][first.y]) == Board.X,
|
||||
"a lone tap should mark X after the double-tap window")
|
||||
|
||||
# Two quick taps check a guest in, then out again.
|
||||
var pair := _find_empty(board)
|
||||
_check(pair.x >= 0, "no empty cell for double tap")
|
||||
if pair.x >= 0:
|
||||
board._handle_tap(pair)
|
||||
board._handle_tap(pair)
|
||||
_check(int(board.cells[pair.x][pair.y]) == Board.RAT,
|
||||
"two quick taps should check a guest in")
|
||||
board._handle_tap(pair)
|
||||
board._handle_tap(pair)
|
||||
_check(int(board.cells[pair.x][pair.y]) == Board.EMPTY,
|
||||
"two quick taps on a rat should check them out")
|
||||
|
||||
# Holding does nothing while double-tap mode is on.
|
||||
var held := _find_empty(board)
|
||||
_check(held.x >= 0, "no empty cell for hold-in-double-tap test")
|
||||
if held.x >= 0:
|
||||
_reset_press(board)
|
||||
_mouse_button(board, held, true)
|
||||
board._process(board.hold_seconds + 1.0)
|
||||
_check(int(board.cells[held.x][held.y]) == Board.EMPTY,
|
||||
"hold should not place a rat in double-tap mode")
|
||||
_check(not board.hold_fired, "hold_fired must stay clear in double-tap mode")
|
||||
_mouse_button(board, held, false)
|
||||
board.pending_tap_cell = Vector2i(-1, -1)
|
||||
|
||||
# Right-click still works in double-tap mode.
|
||||
var right2 := _find_empty(board)
|
||||
_check(right2.x >= 0, "no empty cell for double-tap right-click")
|
||||
if right2.x >= 0:
|
||||
_right_click(board, right2)
|
||||
_check(int(board.cells[right2.x][right2.y]) == Board.RAT,
|
||||
"right-click should check in during double-tap mode")
|
||||
_right_click(board, right2)
|
||||
_check(int(board.cells[right2.x][right2.y]) == Board.EMPTY,
|
||||
"right-click should check out during double-tap mode")
|
||||
|
||||
# Switching modes flushes a pending tap (and a half-finished hold).
|
||||
var flush := _find_empty(board)
|
||||
_check(flush.x >= 0, "no empty cell for mode-switch test")
|
||||
if flush.x >= 0:
|
||||
board._handle_tap(flush)
|
||||
_check(board.pending_tap_cell == flush, "pending tap should be set up")
|
||||
save.set_setting("double_tap_place", false)
|
||||
_check(not board.double_tap_place, "switch to hold mode did not reach Board")
|
||||
_check(board.pending_tap_cell == Vector2i(-1, -1),
|
||||
"switching out of double-tap should flush the pending tap")
|
||||
_check(int(board.cells[flush.x][flush.y]) == Board.X,
|
||||
"flushed pending tap should mark X")
|
||||
|
||||
board.press_cell = flush
|
||||
board.hold_fired = true
|
||||
save.set_setting("double_tap_place", true)
|
||||
_check(board.double_tap_place, "switch back to double-tap did not reach Board")
|
||||
_check(board.press_cell == Vector2i(-1, -1),
|
||||
"switching to double-tap should clear a held press")
|
||||
_check(not board.hold_fired, "switching to double-tap should clear hold_fired")
|
||||
|
||||
board.free()
|
||||
|
||||
|
||||
func _find_empty(board: Board) -> Vector2i:
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
if (
|
||||
int(board.cells[r][c]) == Board.EMPTY
|
||||
and not board.fixed.has(Vector2i(r, c))
|
||||
and not board.auto_x[r][c]
|
||||
):
|
||||
return Vector2i(r, c)
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
|
||||
func _reset_press(board: Board) -> void:
|
||||
board.press_cell = Vector2i(-1, -1)
|
||||
board.press_elapsed = 0.0
|
||||
board.hold_fired = false
|
||||
board.pending_tap_cell = Vector2i(-1, -1)
|
||||
|
||||
|
||||
func _mouse_button(board: Board, cell: Vector2i, pressed: bool) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_LEFT
|
||||
event.pressed = pressed
|
||||
event.position = board._cell_rect(cell.x, cell.y).get_center()
|
||||
board._gui_input(event)
|
||||
|
||||
|
||||
func _right_click(board: Board, cell: Vector2i) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_RIGHT
|
||||
event.pressed = true
|
||||
event.position = board._cell_rect(cell.x, cell.y).get_center()
|
||||
board._gui_input(event)
|
||||
|
||||
|
||||
# --- Scroll pass-through ------------------------------------------------------
|
||||
|
||||
func _test_scroll_pass_through(main) -> void:
|
||||
main.open_settings("home")
|
||||
await process_frame
|
||||
var sheet = main.settings_sheet
|
||||
_check(sheet != null, "settings sheet missing")
|
||||
if sheet != null:
|
||||
for key in ["patterns", "show_timer", "reduce_motion", "double_tap_place"]:
|
||||
if sheet.toggles.has(key):
|
||||
_check(sheet.toggles[key].mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"settings row '%s' should pass swipes" % key)
|
||||
main.close_settings()
|
||||
|
||||
main.show_screen("guest_book")
|
||||
await process_frame
|
||||
var book = main.guest_book
|
||||
_check(book != null, "Guest Book missing")
|
||||
if book != null:
|
||||
_check(book.grid.mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"guest grid should pass swipes")
|
||||
for card in book.grid.get_children():
|
||||
_check(card.mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"guest cards should pass swipes")
|
||||
|
||||
main.show_screen("rules")
|
||||
await process_frame
|
||||
var rulebook = main.rulebook
|
||||
_check(rulebook != null, "Rulebook missing")
|
||||
if rulebook != null:
|
||||
var scrolls = rulebook.find_children("*", "ScrollContainer", true, false)
|
||||
_check(scrolls.size() > 0, "rules ScrollContainer missing")
|
||||
if scrolls.size() > 0:
|
||||
var content = scrolls[0].get_child(0)
|
||||
_check(content.mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"rules content should pass swipes")
|
||||
var tutorial = rulebook.tutorial_board
|
||||
_check(tutorial != null, "tutorial board missing")
|
||||
if tutorial != null:
|
||||
_check(tutorial.mouse_filter == Control.MOUSE_FILTER_STOP,
|
||||
"tutorial board should keep its own input")
|
||||
|
||||
|
||||
# --- Guest Book input ---------------------------------------------------------
|
||||
|
||||
func _test_guest_book_input(main) -> void:
|
||||
main.show_screen("guest_book")
|
||||
await process_frame
|
||||
var book = main.guest_book
|
||||
_check(book != null, "Guest Book missing")
|
||||
if book == null:
|
||||
return
|
||||
|
||||
var guests: Array = Guests.all()
|
||||
_check(guests.size() > 0, "no guests to test")
|
||||
if guests.is_empty():
|
||||
return
|
||||
var guest: Dictionary = guests[0]
|
||||
|
||||
book.scroll.scroll_vertical = 0
|
||||
book._press_scroll = 0
|
||||
book._suppress_until = 0
|
||||
book._dragged = false
|
||||
book.detail_layer.visible = false
|
||||
|
||||
# A short, stationary press + release opens the card.
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
_card_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(book.detail_layer.visible, "stationary press/release should open detail")
|
||||
|
||||
book.detail_layer.visible = false
|
||||
book._suppress_until = 0
|
||||
book._dragged = false
|
||||
book.scroll.scroll_vertical = 0
|
||||
|
||||
# Movement beyond 12dp makes it a scroll, not a tap.
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
var motion := InputEventMouseMotion.new()
|
||||
motion.global_position = Vector2(170, 300)
|
||||
book._on_card_input(motion, guest, false)
|
||||
_card_mouse(book, guest, Vector2(170, 300), false)
|
||||
_check(not book.detail_layer.visible, "a >12dp drag should not open detail")
|
||||
|
||||
book._suppress_until = 0
|
||||
book._dragged = false
|
||||
book.scroll.scroll_vertical = 0
|
||||
|
||||
# A press whose scroll offset changes is a scroll, not a tap.
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
book.scroll.scroll_vertical = 60
|
||||
if absi(book.scroll.scroll_vertical - book._press_scroll) <= 1:
|
||||
# The headless layout may clamp scrolling; emulate the changed offset.
|
||||
book._press_scroll = book.scroll.scroll_vertical - 60
|
||||
_card_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(not book.detail_layer.visible, "a scrolled press should not open detail")
|
||||
|
||||
book.scroll.scroll_vertical = 0
|
||||
book._press_scroll = 0
|
||||
book._suppress_until = 0
|
||||
book._dragged = false
|
||||
|
||||
# A tap right after a fling is suppressed.
|
||||
book._suppress_until = Time.get_ticks_msec() + 1000
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
_card_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(not book.detail_layer.visible, "post-drag suppression should block a tap")
|
||||
|
||||
book._suppress_until = 0
|
||||
book._dragged = false
|
||||
|
||||
# The opening tap must not immediately close the sheet.
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
_card_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(book.detail_layer.visible, "a clean tap should open detail")
|
||||
book._try_close_detail()
|
||||
_check(book.detail_layer.visible, "close should be guarded right after opening")
|
||||
book._detail_opened_at -= 300
|
||||
book._try_close_detail()
|
||||
_check(not book.detail_layer.visible, "close should work after the guard")
|
||||
|
||||
# A later release on the scrim closes the sheet.
|
||||
_card_mouse(book, guest, Vector2(100, 300), true)
|
||||
_card_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(book.detail_layer.visible, "a clean tap should reopen detail")
|
||||
book._detail_opened_at -= 300
|
||||
var up := InputEventMouseButton.new()
|
||||
up.button_index = MOUSE_BUTTON_LEFT
|
||||
up.pressed = false
|
||||
up.global_position = Vector2(20, 20)
|
||||
book.detail_layer.emit_signal("gui_input", up)
|
||||
_check(not book.detail_layer.visible, "a later scrim release should close detail")
|
||||
|
||||
|
||||
func _card_mouse(book, guest: Dictionary, pos: Vector2, pressed: bool) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_LEFT
|
||||
event.pressed = pressed
|
||||
event.global_position = pos
|
||||
book._on_card_input(event, guest, false)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b017p64qwfkhk
|
||||
@@ -0,0 +1,305 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless UI QA sweep: screens, settings, profile frames, daily/campaign
|
||||
## win flows and the Guest Book detail guard.
|
||||
## <godot> --headless --path . --script res://tools/qa_ui.gd --quit-after 1800
|
||||
|
||||
var failures := 0
|
||||
var frames
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures += 1
|
||||
print("FAIL: ", message)
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var err := change_scene_to_file("res://scenes/Main.tscn")
|
||||
if err != OK:
|
||||
print("FAIL: could not load Main")
|
||||
quit(1)
|
||||
return
|
||||
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var main = current_scene
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
_check(save != null, "SaveGame autoload missing")
|
||||
if save == null:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Resolve Frames at runtime: a static reference would compile it before
|
||||
# autoloads are registered when this script is launched with --script.
|
||||
frames = load("res://scripts/Frames.gd")
|
||||
_check(frames != null, "Frames script missing")
|
||||
|
||||
_test_screen_cycle(main)
|
||||
await _test_settings(main, save)
|
||||
await _test_profile(main, save)
|
||||
await _test_daily(main, save)
|
||||
await _test_campaign(main, save)
|
||||
await _test_guest_book(main)
|
||||
_restore_defaults(save)
|
||||
|
||||
print("QA UI: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
||||
quit(0 if failures == 0 else 1)
|
||||
|
||||
|
||||
func _test_screen_cycle(main) -> void:
|
||||
var expected: Array[String] = ["home", "game", "guest_book", "rules", "profile"]
|
||||
_check(main.screens.size() == expected.size(), "Main should expose all five screens")
|
||||
for name in expected:
|
||||
_check(main.screens.has(name) and main.screens[name] != null, "screen missing: %s" % name)
|
||||
_check(
|
||||
main.home != null and main.game != null and main.guest_book != null
|
||||
and main.rulebook != null and main.profile != null,
|
||||
"named screen references should all exist"
|
||||
)
|
||||
_check(main.settings_sheet != null, "settings sheet missing")
|
||||
|
||||
var keys: Array = main.screens.keys()
|
||||
for name in expected:
|
||||
main.show_screen(name, false)
|
||||
for key in keys:
|
||||
_check(
|
||||
bool(main.screens[key].visible) == (key == name),
|
||||
"only %s should be visible after show_screen(%s)" % [key, name]
|
||||
)
|
||||
main.show_screen("home", false)
|
||||
|
||||
|
||||
func _test_settings(main, save) -> void:
|
||||
main.show_screen("home", false)
|
||||
main.open_settings("home")
|
||||
await process_frame
|
||||
_check(main.settings_sheet.visible, "settings sheet should open from home")
|
||||
_check(main.settings_sheet.resume_button.text == "Close", "home settings should use Close")
|
||||
_check(not main.settings_sheet.game_actions.visible, "home settings should hide game actions")
|
||||
|
||||
var toggles: Dictionary = main.settings_sheet.toggles
|
||||
_check(toggles.has("patterns") and toggles.has("double_tap_place"), "settings toggles missing")
|
||||
_check(toggles["patterns"].mouse_filter == Control.MOUSE_FILTER_PASS, "settings rows should pass swipes")
|
||||
|
||||
# Changes made through SaveGame must be reflected after an explicit refresh.
|
||||
save.set_setting("patterns", false)
|
||||
save.set_setting("double_tap_place", false)
|
||||
main.settings_sheet.refresh()
|
||||
_check(not toggles["patterns"].button_pressed, "sheet should refresh patterns from SaveGame")
|
||||
_check(not toggles["double_tap_place"].button_pressed, "sheet should refresh double-tap from SaveGame")
|
||||
_check(main.settings_sheet.hold_slider.editable, "hold slider should be editable with double-tap off")
|
||||
|
||||
# The sheet's own toggles must write back to SaveGame.
|
||||
toggles["patterns"].button_pressed = true
|
||||
_check(bool(save.get_setting("patterns")), "patterns toggle should update SaveGame")
|
||||
toggles["double_tap_place"].button_pressed = true
|
||||
_check(bool(save.get_setting("double_tap_place")), "double-tap toggle should update SaveGame")
|
||||
_check(not main.settings_sheet.hold_slider.editable, "hold slider should be disabled with double-tap on")
|
||||
main.close_settings()
|
||||
await process_frame
|
||||
_check(not main.settings_sheet.visible, "settings sheet should close from home")
|
||||
|
||||
main.show_screen("game", false)
|
||||
main.open_settings("game")
|
||||
await process_frame
|
||||
_check(main.settings_sheet.visible, "settings sheet should open from game")
|
||||
_check(main.settings_sheet.resume_button.text == "Resume", "game settings should use Resume")
|
||||
_check(main.settings_sheet.game_actions.visible, "game settings should show Restart/Lobby")
|
||||
_check(main.game.ui_paused, "game should pause while settings are open")
|
||||
main.close_settings()
|
||||
await process_frame
|
||||
_check(not main.settings_sheet.visible, "settings sheet should close from game")
|
||||
_check(not main.game.ui_paused, "game should resume after closing settings")
|
||||
main.show_screen("home", false)
|
||||
|
||||
|
||||
func _test_profile(main, save) -> void:
|
||||
# Five campaign rooms and a three-day streak unlock Paper and Regular.
|
||||
save.reset_progress()
|
||||
var stats: Dictionary = save.daily_data().duplicate(true)
|
||||
stats["best_streak"] = 3
|
||||
save.data["daily"] = stats
|
||||
save.select_frame("plain")
|
||||
for i in range(5):
|
||||
save.data["completed_rooms"].append("qa-frame-%02d" % i)
|
||||
save.save_game()
|
||||
save.progress_changed.emit()
|
||||
|
||||
main.show_screen("profile", false)
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var profile = main.profile
|
||||
_check(profile != null, "Profile screen missing")
|
||||
if profile == null:
|
||||
return
|
||||
|
||||
var expected: int = frames.all().size()
|
||||
_check(profile.frame_grid.get_child_count() == expected, "Profile should show every frame")
|
||||
for i in range(profile.frame_grid.get_child_count()):
|
||||
_check(
|
||||
profile.frame_grid.get_child(i).mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"frame card %d should pass swipes" % i
|
||||
)
|
||||
_check(profile.rooms_label.text == "5 / 30", "profile room count should reflect save data")
|
||||
_check(profile.best_label.text == "3", "profile best streak should reflect save data")
|
||||
|
||||
var regular_index := -1
|
||||
var night_index := -1
|
||||
for i in range(frames.all().size()):
|
||||
var id := str(frames.all()[i].get("id", ""))
|
||||
if id == "regular":
|
||||
regular_index = i
|
||||
if id == "night":
|
||||
night_index = i
|
||||
_check(regular_index >= 0 and night_index >= 0, "Regular and Night owl frames should exist")
|
||||
_check(frames.is_unlocked("regular"), "a three-day best streak should unlock Regular")
|
||||
_check(not frames.is_unlocked("night"), "Night owl should still be locked")
|
||||
if regular_index < 0 or night_index < 0:
|
||||
return
|
||||
|
||||
# Regression: rebuilding the card grid while `pressed` is on the stack
|
||||
# frees the emitting node under Godot. Watch the card from inside the
|
||||
# signal, before the deferred frame change has a chance to run.
|
||||
var card = profile.frame_grid.get_child(regular_index)
|
||||
var probe := {"valid": false, "inside": false, "count": -1}
|
||||
var watcher := func() -> void:
|
||||
var valid := is_instance_valid(card)
|
||||
probe["valid"] = valid
|
||||
probe["inside"] = valid and card.is_inside_tree()
|
||||
probe["count"] = profile.frame_grid.get_child_count()
|
||||
|
||||
card.pressed.connect(watcher)
|
||||
var count_before: int = profile.frame_grid.get_child_count()
|
||||
card.pressed.emit()
|
||||
_check(bool(probe["valid"]) and bool(probe["inside"]), "frame card must stay alive while pressed emits")
|
||||
_check(int(probe["count"]) == count_before, "frame grid must stay stable while pressed emits")
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(save.selected_frame() == "regular", "pressing an unlocked frame should select it")
|
||||
_check(profile.frame_grid.get_child_count() == count_before, "frame grid should stay stable after selection")
|
||||
_check(profile.status_label.text.find("Now wearing") >= 0, "selection should be reported in profile status")
|
||||
|
||||
var locked_card = profile.frame_grid.get_child(night_index)
|
||||
locked_card.pressed.emit()
|
||||
await process_frame
|
||||
_check(
|
||||
profile.status_label.text.find(frames.requirement_text("night")) >= 0,
|
||||
"locked frame should show its requirement"
|
||||
)
|
||||
_check(save.selected_frame() == "regular", "locked frame must not change the selection")
|
||||
|
||||
|
||||
func _test_daily(main, save) -> void:
|
||||
main.show_screen("home", false)
|
||||
var today := Daily.today_key()
|
||||
var yesterday := Daily.key_from_day_number(Daily.day_number(today) - 1)
|
||||
var daily: Dictionary = save._default_daily()
|
||||
daily["last_completed"] = yesterday
|
||||
daily["streak"] = 2
|
||||
daily["best_streak"] = 3
|
||||
save.data["daily"] = daily
|
||||
save.save_game()
|
||||
var streak_before: int = save.daily_streak()
|
||||
var rooms_before: Array = (save.data["completed_rooms"] as Array).duplicate()
|
||||
|
||||
main._on_daily()
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(main.game.daily_mode, "daily button should start daily mode")
|
||||
_check(main.game.level_label.text == "Daily room", "daily mode should label the room")
|
||||
_check(main.game.daily_key == today, "daily mode should carry today's key")
|
||||
|
||||
await _solve_board(main.game, "daily room")
|
||||
_check(main.game.overlay.visible, "daily win overlay should appear after the timer")
|
||||
_check(main.game.win_title.text == "Daily room complete!", "daily win title should be correct")
|
||||
_check(main.game.win_next.text == "Back to lobby", "daily win button should say Back to lobby")
|
||||
_check(save.daily_streak() == streak_before + 1, "daily streak should increment exactly once")
|
||||
_check(save.daily_completed_today(), "today should be marked complete")
|
||||
_check((save.data["completed_rooms"] as Array) == rooms_before, "daily must not touch completed rooms")
|
||||
|
||||
main.game.win_next.pressed.emit()
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(main.current == "home", "Back to lobby should return to home")
|
||||
_check(main.home.visible, "home should be visible after the daily win")
|
||||
|
||||
|
||||
func _test_campaign(main, save) -> void:
|
||||
main.show_screen("game", false)
|
||||
main.game.start_level(0)
|
||||
await process_frame
|
||||
var room_id := str(main.game.current_level_id)
|
||||
var guest: Dictionary = Guests.for_room(1)
|
||||
var guest_id := str(guest.get("id", ""))
|
||||
|
||||
await _solve_board(main.game, "campaign room 1")
|
||||
_check(main.game.overlay.visible, "campaign win overlay should appear")
|
||||
_check(main.game.win_title.text == "Everyone checked in!", "campaign win title should be correct")
|
||||
_check(main.game.win_next.text == "Next room", "campaign win button should say Next room")
|
||||
_check((save.data["completed_rooms"] as Array).has(room_id), "campaign room should be recorded")
|
||||
_check(guest_id != "" and save.is_guest_unlocked(guest_id), "room 1 should unlock a guest")
|
||||
|
||||
main.game.win_next.pressed.emit()
|
||||
await process_frame
|
||||
_check(not main.game.daily_mode, "next room should not be daily mode")
|
||||
_check(main.game.level_index == 1, "next room should be room 2")
|
||||
_check(main.game.level_label.text == "Room 2", "room 2 should be labelled correctly")
|
||||
_check(not main.game.overlay.visible, "overlay should hide when room 2 starts")
|
||||
|
||||
|
||||
func _test_guest_book(main) -> void:
|
||||
main.show_screen("guest_book", false)
|
||||
await process_frame
|
||||
var book = main.guest_book
|
||||
_check(book != null, "Guest Book missing")
|
||||
if book == null:
|
||||
return
|
||||
var guest: Dictionary = Guests.all()[0]
|
||||
book._show_detail(guest)
|
||||
_check(book.detail_layer.visible, "guest detail should open")
|
||||
_check(book.detail_name.text == str(guest.get("name", "")), "guest detail should name the guest")
|
||||
book._try_close_detail()
|
||||
_check(book.detail_layer.visible, "close should be guarded right after opening")
|
||||
book._detail_opened_at -= 300
|
||||
book._try_close_detail()
|
||||
_check(not book.detail_layer.visible, "close should work after the guard")
|
||||
main.show_screen("home", false)
|
||||
|
||||
|
||||
func _solve_board(game, label: String) -> void:
|
||||
var board = game.board
|
||||
var solved := false
|
||||
for i in range(12):
|
||||
if Rules.is_valid(board.cells, board.regions) or game.win_shown:
|
||||
solved = true
|
||||
break
|
||||
board.hint()
|
||||
await process_frame
|
||||
if not solved:
|
||||
solved = Rules.is_valid(board.cells, board.regions) or game.win_shown
|
||||
_check(solved, "%s should solve within 12 hints" % label)
|
||||
await create_timer(0.6).timeout
|
||||
await process_frame
|
||||
|
||||
|
||||
func _restore_defaults(save) -> void:
|
||||
save.reset_progress()
|
||||
save.data["daily"] = save._default_daily()
|
||||
save.data["last_room"] = 0
|
||||
save.select_frame("plain")
|
||||
save.set_setting("patterns", true)
|
||||
save.set_setting("show_timer", true)
|
||||
save.set_setting("reduce_motion", false)
|
||||
save.set_setting("hold_seconds", 0.35)
|
||||
save.set_setting("double_tap_place", true)
|
||||
save.save_game()
|
||||
_check(save.rooms_completed() == 0, "save progress should be restored")
|
||||
_check(save.daily_data() == save._default_daily(), "save daily should be restored")
|
||||
_check(save.selected_frame() == "plain", "save frame should be restored")
|
||||
@@ -0,0 +1 @@
|
||||
uid://dm888jqtkwin7
|
||||
@@ -0,0 +1,117 @@
|
||||
extends SceneTree
|
||||
|
||||
## Development helper: boots the game, saves one screenshot per screen, quits.
|
||||
## Run without --headless:
|
||||
## <godot> --path . --script res://tools/screenshot.gd
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var err := change_scene_to_file("res://scenes/Main.tscn")
|
||||
if err != OK:
|
||||
print("Could not load Main.tscn: ", err)
|
||||
quit(1)
|
||||
return
|
||||
|
||||
await process_frame
|
||||
await process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
_save("res://screenshots/home.png")
|
||||
|
||||
var main = current_scene
|
||||
_reset_save()
|
||||
|
||||
main.show_screen("profile")
|
||||
await _settle()
|
||||
_save("res://screenshots/profile.png")
|
||||
main.show_screen("home", false)
|
||||
|
||||
main.open_settings("home")
|
||||
await _settle()
|
||||
_save("res://screenshots/settings.png")
|
||||
main.close_settings()
|
||||
|
||||
main.show_screen("guest_book")
|
||||
await _settle()
|
||||
_save("res://screenshots/guest_book.png")
|
||||
|
||||
main.guest_book._show_detail(Guests.by_id("miso"))
|
||||
await _settle()
|
||||
_save("res://screenshots/guest_detail.png")
|
||||
main.guest_book.detail_layer.visible = false
|
||||
|
||||
main.show_screen("rules")
|
||||
await _settle()
|
||||
_save("res://screenshots/rules.png")
|
||||
|
||||
var scrolls = main.rulebook.find_children("*", "ScrollContainer", true, false)
|
||||
if scrolls.size() > 0:
|
||||
scrolls[0].scroll_vertical = 1400
|
||||
await _settle()
|
||||
_save("res://screenshots/rules_tutorial.png")
|
||||
|
||||
main.show_screen("home")
|
||||
main._on_daily()
|
||||
await _settle()
|
||||
_save("res://screenshots/daily.png")
|
||||
for i in range(12):
|
||||
if main.game.win_shown:
|
||||
break
|
||||
main.game.board.hint()
|
||||
await process_frame
|
||||
await create_timer(0.8).timeout
|
||||
await RenderingServer.frame_post_draw
|
||||
_save("res://screenshots/daily_win.png")
|
||||
main.show_screen("home", false)
|
||||
|
||||
main.show_screen("game")
|
||||
main.game.start_level(0)
|
||||
await _settle()
|
||||
_save("res://screenshots/game.png")
|
||||
|
||||
main.open_settings("game")
|
||||
await _settle()
|
||||
_save("res://screenshots/settings_game.png")
|
||||
main.close_settings()
|
||||
|
||||
var game = main.game
|
||||
for i in range(12):
|
||||
if game.win_shown:
|
||||
break
|
||||
game.board.hint()
|
||||
await process_frame
|
||||
await create_timer(0.8).timeout
|
||||
await RenderingServer.frame_post_draw
|
||||
_save("res://screenshots/win.png")
|
||||
|
||||
_reset_save()
|
||||
quit()
|
||||
|
||||
|
||||
func _reset_save() -> void:
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
if save != null:
|
||||
save.reset_progress()
|
||||
save.data["daily"] = save._default_daily()
|
||||
save.data["profile_frame"] = "plain"
|
||||
save.save_game()
|
||||
|
||||
|
||||
func _settle() -> void:
|
||||
await process_frame
|
||||
await process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
|
||||
|
||||
func _save(path: String) -> void:
|
||||
var image := root.get_texture().get_image()
|
||||
if image == null:
|
||||
print("No viewport image yet.")
|
||||
return
|
||||
var absolute := ProjectSettings.globalize_path(path)
|
||||
DirAccess.make_dir_recursive_absolute(absolute.get_base_dir())
|
||||
image.save_png(absolute)
|
||||
print("Saved %s (%dx%d)" % [absolute, image.get_width(), image.get_height()])
|
||||
@@ -0,0 +1 @@
|
||||
uid://dew8388i54gfs
|
||||
@@ -0,0 +1,175 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless smoke test for the rules and the board's public-ish operations.
|
||||
## <godot> --headless --path . --script res://tools/smoke_test.gd
|
||||
|
||||
var solved_flag := false
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var levels: Array = Levels.load_all()
|
||||
if levels.is_empty():
|
||||
print("FAIL: no levels")
|
||||
quit(1)
|
||||
return
|
||||
|
||||
var board := Board.new()
|
||||
root.add_child(board)
|
||||
board.size = Vector2(640, 640)
|
||||
board.solved.connect(_on_solved)
|
||||
|
||||
var all_ok := true
|
||||
|
||||
for i in levels.size():
|
||||
var level: Dictionary = levels[i]
|
||||
board.set_level(level)
|
||||
solved_flag = false
|
||||
|
||||
var fixed_count: int = board.fixed.size()
|
||||
var seen := {}
|
||||
|
||||
for r in board.n:
|
||||
var c := int(level["solution"][r])
|
||||
var cell := Vector2i(r, c)
|
||||
if board.fixed.has(cell):
|
||||
continue
|
||||
# Check the guest in directly.
|
||||
board._toggle_rat(cell)
|
||||
seen[cell] = true
|
||||
|
||||
var valid: bool = Rules.is_valid(board.cells, board.regions)
|
||||
var rats: int = Rules.count_rats(board.cells)
|
||||
var conflicts: int = board.conflict_cells.size()
|
||||
|
||||
if not valid or rats != board.n or conflicts != 0 or not solved_flag:
|
||||
all_ok = false
|
||||
print("FAIL %s: valid=%s rats=%d/%d conflicts=%d solved=%s fixed=%d" % [
|
||||
level["id"], valid, rats, board.n, conflicts, solved_flag, fixed_count
|
||||
])
|
||||
|
||||
# Undo / restart / hint on the first level.
|
||||
var first: Dictionary = levels[0]
|
||||
board.set_level(first)
|
||||
var before: int = Rules.count_rats(board.cells)
|
||||
var target := _first_empty_solution(board, first)
|
||||
if target.x >= 0:
|
||||
board._toggle_rat(target)
|
||||
var placed: int = Rules.count_rats(board.cells)
|
||||
board.undo()
|
||||
var undone: int = Rules.count_rats(board.cells)
|
||||
if placed != before + 1 or undone != before:
|
||||
all_ok = false
|
||||
print("FAIL undo: before=%d placed=%d undone=%d" % [before, placed, undone])
|
||||
|
||||
board.set_level(first)
|
||||
if target.x >= 0:
|
||||
board._toggle_rat(target)
|
||||
board.restart()
|
||||
if Rules.count_rats(board.cells) != board.fixed.size():
|
||||
all_ok = false
|
||||
print("FAIL restart: rats=%d fixed=%d" % [Rules.count_rats(board.cells), board.fixed.size()])
|
||||
|
||||
board.set_level(first)
|
||||
solved_flag = false
|
||||
var guard := 0
|
||||
while guard < 12:
|
||||
guard += 1
|
||||
if not board.hint():
|
||||
break
|
||||
if not solved_flag:
|
||||
all_ok = false
|
||||
print("FAIL hint: board not solved after %d hints" % guard)
|
||||
|
||||
# Coordinate mapping: the centre of a cell must map back to that cell.
|
||||
board.size = Vector2(640, 640)
|
||||
board._update_layout()
|
||||
var mapped: Vector2i = board._pos_to_cell(board._cell_rect(3, 4).get_center())
|
||||
if mapped != Vector2i(3, 4):
|
||||
all_ok = false
|
||||
print("FAIL mapping: expected (3,4), got %s" % str(mapped))
|
||||
|
||||
# Tap marks X, right-click checks in, and hold checks in without a tap.
|
||||
# This section exercises hold mode explicitly; double-tap has its own
|
||||
# checks in ui_test.gd.
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
var previous_mode := true
|
||||
if save != null:
|
||||
previous_mode = bool(save.get_setting("double_tap_place"))
|
||||
save.set_setting("double_tap_place", false)
|
||||
board.set_level(first)
|
||||
board._update_layout()
|
||||
var tap_cell := _find_empty_cell(board)
|
||||
if tap_cell.x >= 0:
|
||||
_left_click(board, tap_cell, true)
|
||||
_left_click(board, tap_cell, false)
|
||||
if int(board.cells[tap_cell.x][tap_cell.y]) != Board.X:
|
||||
all_ok = false
|
||||
print("FAIL tap: expected X, got %d" % int(board.cells[tap_cell.x][tap_cell.y]))
|
||||
|
||||
_right_click(board, tap_cell)
|
||||
if int(board.cells[tap_cell.x][tap_cell.y]) != Board.RAT:
|
||||
all_ok = false
|
||||
print("FAIL right-click: expected RAT, got %d" % int(board.cells[tap_cell.x][tap_cell.y]))
|
||||
|
||||
board.set_level(first)
|
||||
board._update_layout()
|
||||
var hold_cell := _find_empty_cell(board)
|
||||
if hold_cell.x >= 0:
|
||||
_left_click(board, hold_cell, true)
|
||||
board._process(board.hold_seconds + 0.05)
|
||||
if int(board.cells[hold_cell.x][hold_cell.y]) != Board.RAT:
|
||||
all_ok = false
|
||||
print("FAIL hold: expected RAT, got %d" % int(board.cells[hold_cell.x][hold_cell.y]))
|
||||
_left_click(board, hold_cell, false)
|
||||
if int(board.cells[hold_cell.x][hold_cell.y]) != Board.RAT:
|
||||
all_ok = false
|
||||
print("FAIL hold release: guest was removed")
|
||||
|
||||
if save != null:
|
||||
save.set_setting("double_tap_place", previous_mode)
|
||||
|
||||
print("SMOKE TEST: %s" % ("PASS" if all_ok else "FAIL"))
|
||||
quit(0 if all_ok else 1)
|
||||
|
||||
|
||||
func _on_solved() -> void:
|
||||
solved_flag = true
|
||||
|
||||
|
||||
func _find_empty_cell(board: Board) -> Vector2i:
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
var cell := Vector2i(r, c)
|
||||
if board.fixed.has(cell):
|
||||
continue
|
||||
if int(board.cells[r][c]) == Board.EMPTY and not board.auto_x[r][c]:
|
||||
return cell
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
|
||||
func _left_click(board: Board, cell: Vector2i, pressed: bool) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_LEFT
|
||||
event.pressed = pressed
|
||||
event.position = board._cell_rect(cell.x, cell.y).get_center()
|
||||
board._gui_input(event)
|
||||
|
||||
|
||||
func _right_click(board: Board, cell: Vector2i) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_RIGHT
|
||||
event.pressed = true
|
||||
event.position = board._cell_rect(cell.x, cell.y).get_center()
|
||||
board._gui_input(event)
|
||||
|
||||
|
||||
func _first_empty_solution(board: Board, level: Dictionary) -> Vector2i:
|
||||
for r in board.n:
|
||||
var cell := Vector2i(r, int(level["solution"][r]))
|
||||
if not board.fixed.has(cell):
|
||||
return cell
|
||||
return Vector2i(-1, -1)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dfbmnhb4buk40
|
||||
@@ -0,0 +1,368 @@
|
||||
extends SceneTree
|
||||
|
||||
## Headless UI/save integration test.
|
||||
## <godot> --headless --path . --script res://tools/ui_test.gd
|
||||
|
||||
var failures := 0
|
||||
var frames = null
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures += 1
|
||||
print("FAIL: ", message)
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var err := change_scene_to_file("res://scenes/Main.tscn")
|
||||
if err != OK:
|
||||
print("FAIL: could not load Main")
|
||||
quit(1)
|
||||
return
|
||||
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var main = current_scene
|
||||
var save = root.get_node_or_null("SaveGame")
|
||||
_check(save != null, "SaveGame autoload missing")
|
||||
if save == null:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Resolve at runtime so Frames.gd does not compile before autoloads exist.
|
||||
frames = load("res://scripts/Frames.gd")
|
||||
_check(frames != null, "Frames script missing")
|
||||
if frames == null:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
_test_save_defaults(save)
|
||||
save.reset_progress()
|
||||
await _test_daily_and_frames(save, main)
|
||||
|
||||
main.game.start_level(0)
|
||||
await process_frame
|
||||
|
||||
save.set_setting("patterns", false)
|
||||
_check(not main.game.board.show_patterns, "patterns setting did not reach Board")
|
||||
save.set_setting("patterns", true)
|
||||
_check(main.game.board.show_patterns, "patterns setting did not restore")
|
||||
|
||||
save.set_setting("show_timer", false)
|
||||
main.show_screen("game")
|
||||
await process_frame
|
||||
_check(not main.game.timer_label.visible, "show_timer setting did not hide timer")
|
||||
save.set_setting("show_timer", true)
|
||||
|
||||
save.set_setting("hold_seconds", 0.50)
|
||||
_check(abs(main.game.board.hold_seconds - 0.50) < 0.001, "hold_seconds did not reach Board")
|
||||
save.set_setting("hold_seconds", 0.35)
|
||||
|
||||
_test_placement_modes(save, main.game.board)
|
||||
|
||||
main.open_settings("home")
|
||||
await process_frame
|
||||
_check(
|
||||
main.settings_sheet.toggles["double_tap_place"].mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"settings rows should pass swipes to the ScrollContainer"
|
||||
)
|
||||
main.close_settings()
|
||||
|
||||
var unlocked: String = save.complete_room("room-01", 1)
|
||||
_check(unlocked == "pepper", "room 1 should unlock Pepper")
|
||||
_check(save.is_guest_unlocked("pepper"), "Pepper should be unlocked")
|
||||
_check(save.is_guest_unlocked("miso"), "Miso should be unlocked as a resident")
|
||||
|
||||
main.show_screen("guest_book")
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(main.guest_book != null, "Guest Book missing")
|
||||
if main.guest_book != null and main.guest_book.progress_label != null:
|
||||
_check(main.guest_book.progress_label.text.find("6/25") >= 0, "Guest Book progress should be 6/25")
|
||||
_test_guest_book_input(main.guest_book)
|
||||
_check(main.guest_book.grid.mouse_filter == Control.MOUSE_FILTER_PASS, "guest grid should pass swipes")
|
||||
var first_card = main.guest_book.grid.get_child(0)
|
||||
_check(first_card.mouse_filter == Control.MOUSE_FILTER_PASS, "guest cards should pass swipes")
|
||||
|
||||
main.show_screen("rules")
|
||||
await process_frame
|
||||
var tutorial_board = main.rulebook.tutorial_board
|
||||
_check(tutorial_board != null, "Tutorial board missing")
|
||||
if tutorial_board != null:
|
||||
var rule_scrolls = main.rulebook.find_children("*", "ScrollContainer", true, false)
|
||||
_check(rule_scrolls.size() > 0, "Rules ScrollContainer missing")
|
||||
if rule_scrolls.size() > 0:
|
||||
var rules_content = rule_scrolls[0].get_child(0)
|
||||
_check(rules_content.mouse_filter == Control.MOUSE_FILTER_PASS, "rules content should pass swipes")
|
||||
_check(tutorial_board.mouse_filter == Control.MOUSE_FILTER_STOP, "tutorial board should keep its own input")
|
||||
for i in range(8):
|
||||
tutorial_board.hint()
|
||||
await process_frame
|
||||
_check(Rules.is_valid(tutorial_board.cells, tutorial_board.regions), "Tutorial puzzle did not solve")
|
||||
|
||||
save.reset_progress()
|
||||
save.set_setting("patterns", true)
|
||||
save.set_setting("show_timer", true)
|
||||
save.set_setting("reduce_motion", false)
|
||||
save.set_setting("hold_seconds", 0.35)
|
||||
save.set_setting("double_tap_place", true)
|
||||
|
||||
print("UI TEST: ", "PASS" if failures == 0 else "FAIL (%d)" % failures)
|
||||
quit(0 if failures == 0 else 1)
|
||||
|
||||
|
||||
func _test_daily_and_frames(save, main) -> void:
|
||||
var today := Daily.today_key()
|
||||
var yesterday := Daily.key_from_day_number(Daily.day_number(today) - 1)
|
||||
var daily: Dictionary = save._default_daily()
|
||||
daily["last_completed"] = yesterday
|
||||
daily["streak"] = 2
|
||||
daily["best_streak"] = 2
|
||||
save.data["daily"] = daily
|
||||
|
||||
_check(save.complete_daily(today), "today's daily should count")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 3, "consecutive daily should extend streak")
|
||||
_check(save.daily_streak() == 3, "daily streak should be alive")
|
||||
_check(save.best_streak() == 3, "best streak should update")
|
||||
_check(not save.complete_daily(today), "same day should not count twice")
|
||||
_check(int(save.daily_data().get("streak", 0)) == 3, "replay should not change streak")
|
||||
|
||||
var older := Daily.key_from_day_number(Daily.day_number(today) - 3)
|
||||
daily = save._default_daily()
|
||||
daily["last_completed"] = older
|
||||
daily["streak"] = 9
|
||||
daily["best_streak"] = 9
|
||||
save.data["daily"] = daily
|
||||
save.complete_daily(today)
|
||||
_check(int(save.daily_data().get("streak", 0)) == 1, "a gap should reset the streak")
|
||||
_check(save.best_streak() == 9, "best streak should survive a reset")
|
||||
|
||||
var index := Daily.level_index(30, today)
|
||||
_check(index >= 0 and index < 30, "daily level index should be in range")
|
||||
_check(index == Daily.level_index(30, today), "daily level index should be stable")
|
||||
save.data["daily"] = save._default_daily()
|
||||
save.save_game()
|
||||
|
||||
save.reset_progress()
|
||||
_check(frames.is_unlocked("plain"), "plain frame should always be available")
|
||||
_check(not frames.is_unlocked("paper"), "Paper should need rooms")
|
||||
for i in range(5):
|
||||
save.data["completed_rooms"].append("room-%02d" % i)
|
||||
save.save_game()
|
||||
_check(frames.is_unlocked("paper"), "five rooms should unlock Paper")
|
||||
_check(not frames.is_unlocked("bell"), "Bellhop should still be locked")
|
||||
var stats: Dictionary = save.daily_data()
|
||||
stats["best_streak"] = 3
|
||||
save.data["daily"] = stats
|
||||
save.save_game()
|
||||
_check(frames.is_unlocked("regular"), "a 3-day best streak should unlock Regular")
|
||||
save.select_frame("regular")
|
||||
save.load_game()
|
||||
_check(save.selected_frame() == "regular", "frame selection should persist")
|
||||
|
||||
main.show_screen("profile")
|
||||
await process_frame
|
||||
_check(main.profile != null, "Profile screen missing")
|
||||
if main.profile != null:
|
||||
_check(
|
||||
main.profile.frame_grid.get_child_count() == frames.all().size(),
|
||||
"Profile should show every frame"
|
||||
)
|
||||
_check(
|
||||
main.profile.frame_grid.get_child(0).mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"frame cards should pass swipes"
|
||||
)
|
||||
# Regression: pressing a card must not free that card while its
|
||||
# `pressed` signal is still on the stack.
|
||||
var regular_index := -1
|
||||
for i in frames.all().size():
|
||||
if str(frames.all()[i].get("id", "")) == "regular":
|
||||
regular_index = i
|
||||
if regular_index >= 0:
|
||||
main.profile.frame_grid.get_child(regular_index).pressed.emit()
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(save.selected_frame() == "regular", "frame press should select the frame")
|
||||
_check(
|
||||
main.profile.frame_grid.get_child_count() == frames.all().size(),
|
||||
"frame grid should stay stable after selection"
|
||||
)
|
||||
main.show_screen("home")
|
||||
main.home.daily_pressed.emit()
|
||||
await process_frame
|
||||
_check(main.game.daily_mode, "daily button should start daily mode")
|
||||
_check(main.game.level_label.text == "Daily room", "daily mode should label the room")
|
||||
main.show_screen("home", false)
|
||||
|
||||
save.data["completed_rooms"] = []
|
||||
save.data["daily"] = save._default_daily()
|
||||
save.select_frame("plain")
|
||||
|
||||
|
||||
func _test_save_defaults(save) -> void:
|
||||
# A fresh save starts in double-tap mode at version 2.
|
||||
var abs_path := ProjectSettings.globalize_path(save.PATH)
|
||||
if FileAccess.file_exists(save.PATH):
|
||||
DirAccess.remove_absolute(abs_path)
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "fresh saves should be version 3")
|
||||
_check(bool(save.get_setting("double_tap_place")), "fresh saves should default to double-tap")
|
||||
|
||||
# A version 1 save with hold selected migrates to double-tap once.
|
||||
var old: Dictionary = save._default_data()
|
||||
old["version"] = 1
|
||||
old["settings"]["double_tap_place"] = false
|
||||
var file := FileAccess.open(save.PATH, FileAccess.WRITE)
|
||||
file.store_string(JSON.stringify(old, "\t"))
|
||||
file.close()
|
||||
|
||||
save.load_game()
|
||||
_check(int(save.data.get("version", 0)) == 3, "version 1 saves should migrate to version 3")
|
||||
_check(bool(save.get_setting("double_tap_place")), "version 1 saves should migrate to double-tap")
|
||||
|
||||
|
||||
func _find_empty(board: Board) -> Vector2i:
|
||||
for r in board.n:
|
||||
for c in board.n:
|
||||
if (
|
||||
int(board.cells[r][c]) == Board.EMPTY
|
||||
and not board.fixed.has(Vector2i(r, c))
|
||||
and not board.auto_x[r][c]
|
||||
):
|
||||
return Vector2i(r, c)
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
|
||||
func _test_placement_modes(save, board: Board) -> void:
|
||||
board.restart()
|
||||
save.set_setting("double_tap_place", true)
|
||||
_check(board.double_tap_place, "double_tap_place did not reach Board")
|
||||
|
||||
# A first tap waits; a second tap on the same cell checks a guest in.
|
||||
var cell := _find_empty(board)
|
||||
board._handle_tap(cell)
|
||||
_check(int(board.cells[cell.x][cell.y]) == Board.EMPTY, "first tap should wait in double-tap mode")
|
||||
board._handle_tap(cell)
|
||||
_check(int(board.cells[cell.x][cell.y]) == Board.RAT, "double tap should check a guest in")
|
||||
board._handle_tap(cell)
|
||||
board._handle_tap(cell)
|
||||
_check(int(board.cells[cell.x][cell.y]) == Board.EMPTY, "double tap on a guest should check them out")
|
||||
|
||||
# A lone tap still marks an X once the double-tap window passes.
|
||||
var cell2 := _find_empty(board)
|
||||
board._handle_tap(cell2)
|
||||
board.pending_tap_at -= Board.DOUBLE_TAP_MS + 1
|
||||
board._process(0.0)
|
||||
_check(int(board.cells[cell2.x][cell2.y]) == Board.X, "single tap should mark X after the window")
|
||||
|
||||
# Holding must not place a guest while double-tap mode is on.
|
||||
board.press_cell = cell2
|
||||
board.press_elapsed = 0.0
|
||||
board.hold_fired = false
|
||||
board._process(1.0)
|
||||
_check(int(board.cells[cell2.x][cell2.y]) == Board.X, "hold should not place in double-tap mode")
|
||||
board.press_cell = Vector2i(-1, -1)
|
||||
board.hold_fired = false
|
||||
|
||||
# Right-click still checks a guest in and out in double-tap mode.
|
||||
board.size = Vector2(320, 320)
|
||||
board._update_layout()
|
||||
var cell3 := _find_empty(board)
|
||||
_right_click(board, cell3)
|
||||
_check(int(board.cells[cell3.x][cell3.y]) == Board.RAT, "right-click should check in during double-tap mode")
|
||||
_right_click(board, cell3)
|
||||
_check(int(board.cells[cell3.x][cell3.y]) == Board.EMPTY, "right-click should check out during double-tap mode")
|
||||
|
||||
# Hold mode still works when the setting is off.
|
||||
save.set_setting("double_tap_place", false)
|
||||
_check(not board.double_tap_place, "double_tap_place did not turn off")
|
||||
board.restart()
|
||||
var cell4 := _find_empty(board)
|
||||
board.press_cell = cell4
|
||||
board.press_elapsed = 0.0
|
||||
board.hold_fired = false
|
||||
board._process(0.60)
|
||||
_check(int(board.cells[cell4.x][cell4.y]) == Board.RAT, "hold should place in hold mode")
|
||||
board.press_cell = Vector2i(-1, -1)
|
||||
board.hold_fired = false
|
||||
|
||||
# Single tap marks X in hold mode.
|
||||
var cell5 := _find_empty(board)
|
||||
board.size = Vector2(320, 320)
|
||||
board._update_layout()
|
||||
_left_tap(board, cell5)
|
||||
_check(int(board.cells[cell5.x][cell5.y]) == Board.X, "single tap should mark X in hold mode")
|
||||
|
||||
# The setting survives a save/load round trip.
|
||||
save.set_setting("double_tap_place", true)
|
||||
save.load_game()
|
||||
_check(bool(save.get_setting("double_tap_place")), "double_tap_place should persist")
|
||||
save.set_setting("double_tap_place", true)
|
||||
board.restart()
|
||||
|
||||
|
||||
func _left_tap(board: Board, cell: Vector2i) -> void:
|
||||
var pos := board._cell_rect(cell.x, cell.y).get_center()
|
||||
var down := InputEventMouseButton.new()
|
||||
down.button_index = MOUSE_BUTTON_LEFT
|
||||
down.pressed = true
|
||||
down.position = pos
|
||||
board._gui_input(down)
|
||||
var up := InputEventMouseButton.new()
|
||||
up.button_index = MOUSE_BUTTON_LEFT
|
||||
up.pressed = false
|
||||
up.position = pos
|
||||
board._gui_input(up)
|
||||
|
||||
|
||||
func _right_click(board: Board, cell: Vector2i) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_RIGHT
|
||||
event.pressed = true
|
||||
event.position = board._cell_rect(cell.x, cell.y).get_center()
|
||||
board._gui_input(event)
|
||||
|
||||
|
||||
func _test_guest_book_input(book) -> void:
|
||||
var guest: Dictionary = Guests.all()[0]
|
||||
book.detail_layer.visible = false
|
||||
|
||||
# Dragging across a card is a scroll, not a tap.
|
||||
_mouse(book, guest, Vector2(100, 300), true)
|
||||
var motion := InputEventMouseMotion.new()
|
||||
motion.global_position = Vector2(170, 300)
|
||||
book._on_card_input(motion, guest, false)
|
||||
_mouse(book, guest, Vector2(170, 300), false)
|
||||
_check(not book.detail_layer.visible, "dragging should not open a guest card")
|
||||
|
||||
# A fling settling must not turn into a tap either.
|
||||
book._suppress_until = Time.get_ticks_msec() + 1000
|
||||
_mouse(book, guest, Vector2(100, 300), true)
|
||||
_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(not book.detail_layer.visible, "post-scroll tap should be ignored")
|
||||
|
||||
# A short, stationary tap opens the card.
|
||||
book._suppress_until = 0
|
||||
_mouse(book, guest, Vector2(100, 300), true)
|
||||
_mouse(book, guest, Vector2(100, 300), false)
|
||||
_check(book.detail_layer.visible, "a clean tap should open a guest card")
|
||||
|
||||
# The opening tap must not immediately close the sheet.
|
||||
book._try_close_detail()
|
||||
_check(book.detail_layer.visible, "close should be guarded right after opening")
|
||||
book._detail_opened_at -= 300
|
||||
book._try_close_detail()
|
||||
_check(not book.detail_layer.visible, "close should work after the guard")
|
||||
|
||||
|
||||
func _mouse(book, guest: Dictionary, pos: Vector2, pressed: bool) -> void:
|
||||
var event := InputEventMouseButton.new()
|
||||
event.button_index = MOUSE_BUTTON_LEFT
|
||||
event.pressed = pressed
|
||||
event.global_position = pos
|
||||
book._on_card_input(event, guest, false)
|
||||
@@ -0,0 +1 @@
|
||||
uid://ccl6uk1425kix
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"08988737-a544-4ab1-99fb-22d67b7c36e3","revision":0,"last_node_id":52,"last_link_id":85,"nodes":[{"id":29,"type":"SaveImage","pos":[521.2820256118092,-86.65135385501759],"size":[879.953125,1019.953125],"flags":{},"order":5,"mode":0,"inputs":[{"localized_name":"images","name":"images","type":"IMAGE","link":44},{"localized_name":"filename_prefix","name":"filename_prefix","type":"STRING","widget":{"name":"filename_prefix"},"link":null}],"outputs":[{"localized_name":"images","name":"images","type":"IMAGE","links":null}],"properties":{"Node name for S&R":"SaveImage","cnr_id":"comfy-core","ver":"0.25.0"},"widgets_values":["Krea2_turbo"],"widgets_values_named":{"filename_prefix":"Krea2_turbo"}},{"id":30,"type":"b0e5ca93-2731-42b9-8e0a-d28ea851ff81","pos":[-140,-110],"size":[559.953125,1009.953125],"flags":{},"order":4,"mode":0,"inputs":[{"label":"prompt","name":"value","type":"STRING","widget":{"name":"value"},"link":null},{"label":"prompt_enhance","name":"value_1","type":"BOOLEAN","widget":{"name":"value_1"},"link":null},{"label":"LLM_max_token","name":"max_length","type":"INT","widget":{"name":"max_length"},"link":null},{"label":"LLM_thinking_mode","name":"thinking","shape":7,"type":"BOOLEAN","widget":{"name":"thinking"},"link":null},{"label":"width","name":"width_1","type":"INT","widget":{"name":"width_1"},"link":84},{"label":"height","name":"height_1","type":"INT","widget":{"name":"height_1"},"link":85},{"label":"seed","name":"seed_1","type":"INT","widget":{"name":"seed_1"},"link":null},{"label":"enable_lora","name":"value_3","type":"BOOLEAN","widget":{"name":"value_3"},"link":null},{"label":"lora_name","name":"lora_name_1","type":"COMBO","widget":{"name":"lora_name_1"},"link":null},{"label":"lora_strength","name":"strength_model_1","type":"FLOAT","widget":{"name":"strength_model_1"},"link":null},{"label":"lora_trigger_word","name":"string_b_1","type":"STRING","widget":{"name":"string_b_1"},"link":null},{"label":"unet_name","name":"unet_name_1","type":"COMBO","widget":{"name":"unet_name_1"},"link":null},{"label":"clip_name","name":"clip_name_1","type":"COMBO","widget":{"name":"clip_name_1"},"link":null},{"label":"vae_name","name":"vae_name_1","type":"COMBO","widget":{"name":"vae_name_1"},"link":null}],"outputs":[{"localized_name":"IMAGE","name":"IMAGE","type":"IMAGE","links":[44]}],"properties":{"cnr_id":"comfy-core","ver":"0.25.0","previewExposures":[{"name":"$$canvas-image-preview","sourceNodeId":"3","sourcePreviewName":"$$canvas-image-preview"}]},"widgets_values":["A cozy children's-book character illustration of Crumb, a round dumbo-eared fancy rat innkeeper. Plump pear-shaped body, soft fawn-and-cream hooded fur, huge low-set round ears, tiny pink paws, long delicate whiskers, bright curious eyes, one small notch in her left ear. She wears a tiny flour-dusted linen apron with a cheese-wedge pocket and holds a little clipboard. Standing three-quarter view, full body, centered, friendly slightly flustered expression. Hand-painted gouache texture, visible soft brush strokes, warm cream, ochre and dusty rose palette, gentle rim light, soft contact shadow, plain warm cream background, clean sticker-like silhouette, no text, no logo, 1:1.\n\n",false,512,false,1024,1024,107158940777715,true,"krea2_refusal_compact.safetensors",0.8,"","krea2_turbo_int8_convrot.safetensors","qwen3vl_4b_fp8_scaled.safetensors","qwen_image_vae.safetensors"],"widgets_values_named":{"value":"A cozy children's-book character illustration of Crumb, a round dumbo-eared fancy rat innkeeper. Plump pear-shaped body, soft fawn-and-cream hooded fur, huge low-set round ears, tiny pink paws, long delicate whiskers, bright curious eyes, one small notch in her left ear. She wears a tiny flour-dusted linen apron with a cheese-wedge pocket and holds a little clipboard. Standing three-quarter view, full body, centered, friendly slightly flustered expression. Hand-painted gouache texture, visible soft brush strokes, warm cream, ochre and dusty rose palette, gentle rim light, soft contact shadow, plain warm cream background, clean sticker-like silhouette, no text, no logo, 1:1.\n\n","value_1":false,"max_length":512,"thinking":false,"width_1":1024,"height_1":1024,"seed_1":107158940777715,"value_3":true,"lora_name_1":"krea2_refusal_compact.safetensors","strength_model_1":0.8,"string_b_1":"","unet_name_1":"krea2_turbo_int8_convrot.safetensors","clip_name_1":"qwen3vl_4b_fp8_scaled.safetensors","vae_name_1":"qwen_image_vae.safetensors"}},{"id":47,"type":"MarkdownNote","pos":[-1200,970],"size":[689.953125,509.953125],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[],"title":"LoRA Trigger Words and Settings","properties":{},"widgets_values":["## Model Links\n\n- [Hugging Face:Comfy-Org/Krea-2](https://huggingface.co/Comfy-Org/Krea-2)\n- [ModelScope:Comfy-Org/Krea-2](https://modelscope.cn/models/Comfy-Org/Krea-2)\n\nDownload the style LoRAs used in this workflow from [Comfy-Org/Krea-2/loras](https://huggingface.co/Comfy-Org/Krea-2/tree/main/loras).Line truncated
|
||||