Compare commits
No commits in common. "cad1ba7e24d6bd193bfdca92f8ede58c25f85970" and "8c81d815eb1092ef2f8b759b85b09a19d49f9f16" have entirely different histories.
cad1ba7e24
...
8c81d815eb
87 changed files with 3832 additions and 9741 deletions
625
docs/plan.md
625
docs/plan.md
|
|
@ -1,390 +1,317 @@
|
|||
# Harvest Season — playable on phones (2026-10-14)
|
||||
# Harvest Season — opening intro (2026-10-07)
|
||||
|
||||
Status: planned, not started. The iOS test port showed the game runs well on an iPhone: night 20
|
||||
with every enemy on the farm held 60 FPS (worst frame 19.7 ms, worst physics 0.8 ms). Floating
|
||||
thumbsticks are in (`TouchSticks`, 8c81d81): the right half moves and the left half attacks. This
|
||||
plan covers everything else a phone player needs to play a whole vacation with touch alone:
|
||||
controls for every action, an interface sized for a 6" screen that stays clear of the notch,
|
||||
prompts in touch words, and the platform details. Tasks continue at **#35–#46**. The opening-intro
|
||||
plan this file replaces is in git at 5dbad4c; its #34 (timing review) is still open.
|
||||
Status: planned, not started. The user asked for a cutscene at the start of every new vacation:
|
||||
the farmers leave for the Bon Jovi concert, and that night a bickering UFO crew drops a part that
|
||||
brings the scarecrow to life. Then a loading screen, then the first morning's instructions. Tasks
|
||||
continue the numbering at **#29–#34** (#1–#28 are merged; the thirty-nights plan this file
|
||||
replaced is in git at 6a9575d). Line numbers point at bbd8012 plus the uncommitted dialogue work,
|
||||
so re-check them before editing.
|
||||
|
||||
Ads and the remove-ads purchase come in the next plan, once the game plays well by touch.
|
||||
**Before any worker starts:** the talking-head dialogue system is still uncommitted in the user's
|
||||
tree. That covers `conversation.gd`, `dialogue_*.gd`, `game/resources/dialogue/`,
|
||||
`test_dialogue.gd`, and the edits to `campaign_controller.gd`, `farm_sim.gd`, `main.gd`,
|
||||
`tutorial.gd`, `campaign_debug.gd`, `run_tests.gd`, and `farm.tscn`. Worktrees branch from HEAD,
|
||||
so it must be committed first, or the workers won't have it.
|
||||
|
||||
## Ground rules for workers
|
||||
|
||||
- **Godot binary:** `godot` is not on PATH. Use `~/Downloads/Godot_v4.7.2-stable_linux.x86_64`
|
||||
wherever these docs say `godot`. Exit code 127 means the binary wasn't found, not a pass.
|
||||
- **Godot binary:** `godot` is not on PATH here. Use `~/Downloads/Godot_v4.7.2-stable_linux.x86_64`
|
||||
everywhere these docs say `godot`. Exit code 127 means the binary wasn't found, not a pass.
|
||||
- **Tests:** `godot --headless --path . --script res://game/tests/run_tests.gd`. The exit code is
|
||||
the failure count and is never 0 here, because tuning breaks a few dozen checks. Run the suites
|
||||
you touch before editing, diff the FAIL lines afterwards, and judge your task by new FAIL lines
|
||||
only. One suite: `-- --suite=test_x`.
|
||||
- **Mobile tests** go in `game/tests/mobile/`, one file per task (see #35). `test_mobile`
|
||||
(`-- --suite=test_mobile`) runs them all, so no task edits `run_tests.gd`'s list after #35.
|
||||
Force phone mode with `MobilePort.forced = 1` and send touches with
|
||||
`game/tests/mobile/touch.gd`, which goes through `Input.parse_input_event` so Godot's
|
||||
touch-to-click emulation runs as it does on a phone.
|
||||
- **Parallel worktrees:** give each headless run its own `XDG_DATA_HOME`.
|
||||
- **Phone-only behaviour stays behind `MobilePort.active()`.** The desktop build must not change:
|
||||
same strings, same layout, same input. Each task checks a sample of desktop strings or values
|
||||
unchanged.
|
||||
- **Seeing the phone build on desktop:**
|
||||
`godot --path . --rendering-method mobile --windowed --resolution 2340x1080 -- --mobile --safe-area=140,0,140,60`
|
||||
(from #35: `--safe-area=left,top,right,bottom` in window pixels simulates a notch and home
|
||||
indicator). Also try a 4:3 window (`--resolution 1600x1200`) for iPads. Headless runs draw
|
||||
nothing, so take screenshots from a windowed run and show them to the user.
|
||||
- **No new HUD text.** The user had the pop-up text removed. The touch buttons below are controls
|
||||
the user asked for: icons with at most one short word. Prompts change their wording on phones,
|
||||
not their number. Ask before adding any other text.
|
||||
- **`farm.tscn` and `.tres` files:** edit them as text. A headless `ResourceSaver.save()` drops the
|
||||
`uid=` lines.
|
||||
- **Co-op is off on phones.** Don't touch co-op code. Desktop co-op must keep working.
|
||||
the failure count and is never 0 here: about 25 checks fail because of tuning, and the
|
||||
test_roster "All three" check is flaky. Run the suite before editing, diff the FAIL lines
|
||||
afterwards, and judge your task by new FAIL lines only. One suite: `-- --suite=test_x`.
|
||||
- **Parallel worktrees:** give each headless run its own `XDG_DATA_HOME` so `user://` saves don't
|
||||
collide.
|
||||
- **`farm.tscn` and `.tres` files:** edit them as text. A headless `ResourceSaver.save()` drops
|
||||
the `uid=` lines; if you must save from a script, restore them the way
|
||||
`game/tools/build_prop_collision.gd` does.
|
||||
- **Co-op is untouched:** the intro is local, solo-only, and runs before any partner can join.
|
||||
Nothing here changes the save format, `state.to_dict()`, or the wire format.
|
||||
- **No new HUD text:** gameplay feedback still goes through menus, sound, and world visuals. The
|
||||
intro's own captions ("Later that night....", the skip hint) are cutscene chrome the user asked
|
||||
for, like the ending's caption, and appear only while it plays.
|
||||
- **Look:** the user named the luggage, the UFO's flight, the part, the blue flash, the chest
|
||||
glow, and the loading screen, so those are in scope. The farmers stay the tinted mannequins
|
||||
from the ending. Talking heads are sketch placeholders (real portraits go in the speaker
|
||||
`.tres` later). New lit `StandardMaterial3D`s get the toon look from `ToonLook` automatically;
|
||||
a custom `ShaderMaterial` must `#include "res://game/resources/toon_light.gdshaderinc"`.
|
||||
- **Graph:** after modifying code, run `graphify update .`.
|
||||
|
||||
## Decisions (the user's)
|
||||
## Decisions (the user's, 2026-10-07)
|
||||
|
||||
1. **Move on the right, attack on the left** (2026-10-14). This is the mirror of most twin-stick
|
||||
games. `TouchSticks.MOVE_ON_RIGHT` holds it, and a Swap setting flips it (#41).
|
||||
2. **Phones drop the toon and pixel look** (standard materials, Mobile renderer) **and co-op**.
|
||||
3. **Floating sticks:** a stick starts where the finger lands and is drawn only while held.
|
||||
4. **iOS first** through Codemagic and TestFlight. Android follows (#44).
|
||||
5. **Sprint becomes a speed upgrade, on every platform** (2026-10-14). Owning the Sprint upgrade
|
||||
raises the scarecrow's base speed for good. There's no more hold-to-sprint, time limit,
|
||||
cooldown, or stamina bar (#46), so phones need no sprint control.
|
||||
1. **Dialogue in the talking-head box** (`DialogueBox`, the morning sign's paper with portraits).
|
||||
Lines go on by themselves in time with the action; a tap hurries them.
|
||||
2. **The part is absorbed into the scarecrow.** A faint blue glow stays in its chest all game.
|
||||
It sets up the day-2 alien's "You have something of ours" (`morning_day_2.tres`).
|
||||
3. **Loading screen:** `assets/pictures/screens/splash-screen.png` with a slow pan, the title in
|
||||
the handwritten font, and a sketch UFO wobbling along a hand-drawn progress bar, about 3 s.
|
||||
4. **It plays on every New vacation, and can be skipped.** Continue never plays it. Hosting co-op
|
||||
skips it.
|
||||
|
||||
## Defaults (assumed; flip any of these on request)
|
||||
|
||||
**Controls**
|
||||
1. **Contextual buttons.** A button shows only when it can do something: Use near something
|
||||
usable, Patch when hurt and carrying straw, Bomb once owned, Build by day. This keeps the
|
||||
screen clear.
|
||||
2. **Placement.** The attack side has a column of Fear, Bomb, and Patch along its outer edge,
|
||||
above where the thumb rests. The move side has Use and Build. Pause sits at the top edge beside
|
||||
the day widget. Tap a hotbar slot to switch weapons and tap the backpack for the pouch. See the
|
||||
diagram below.
|
||||
3. **Sprint's boost: +25% base speed** (`sprint_speed_mult` 1.25). The old burst was +80% for
|
||||
4 s, too fast to keep on all the time. Tune it in `game_config.tres`.
|
||||
4. **Bomb.** A tap throws along the attack stick's direction, or the last one, 7 m out, the same
|
||||
as on a gamepad. The orange landing ring already shows where it will land.
|
||||
5. **Use.** It works like E. Hold it to gather, repair, or upgrade a structure. Tap it to open the
|
||||
workbench or the shed. Its word follows what's in reach: Gather, Repair, Upgrade, Workbench, or
|
||||
Shop.
|
||||
6. **Build mode.** The attack half becomes the placing finger: the ghost sits on the ground under
|
||||
the finger, within build range. Buttons are Place, Rotate left and right, Dismantle (over a
|
||||
structure), and Done. Tap a build-bar slot to pick what to build. The move stick still walks.
|
||||
7. **Dialogue and tips.** A tap advances a conversation, as now. A Skip button skips a
|
||||
conversation, and an × on the tip box hides tips.
|
||||
8. **Haptics.** A short buzz when the scarecrow is hit, on by default, with a setting.
|
||||
**Controls.**
|
||||
- A tap (Space / Enter / E / A / click) is the box's own input and goes to the next line.
|
||||
- Holding Space / Enter / A for 1 s skips the whole intro. The hint is "Hold [Space / Enter / A]
|
||||
to skip", bottom right, with a ring that fills while held.
|
||||
- The intro polls `Input` for the hold, because the box takes the press.
|
||||
|
||||
**Screen**
|
||||
9. **Interface scale.** It's set automatically from the screen's physical size: about 1.6× on
|
||||
phones, 1× on iPads and desktop, **capped at 1.7×** (the user's call, 2026-10-14). An Interface
|
||||
size setting (80–130%) adjusts it. At 1.6× on a 19.5:9 phone the canvas is about 1460×675; at
|
||||
the 1.7 cap (iPhone SE, 13 mini) it's about 635 tall (SE: about 1130×635). Every menu and panel
|
||||
must fit 635 px tall.
|
||||
10. **Safe area.** Every HUD widget and menu stays inside it, clear of the notch, the rounded
|
||||
corners, and the home indicator.
|
||||
11. **World labels** (Gather, Repair, a structure's name) draw as flat text on phones
|
||||
(`ScreenLabels`), so they're sharp and scale with the interface.
|
||||
12. **Camera.** 12 m on phones (16 on desktop), adjustable in settings. No pinch zoom yet.
|
||||
13. **Settings on phones.** No Fullscreen, VSync, mouse note, or bindings table. It adds Interface
|
||||
size, Swap sticks, Camera distance, and Haptics, plus a short touch-controls guide.
|
||||
14. **Minimum touch target.** 44 pt (Apple's guideline), worked out from the scale (#35).
|
||||
**Skipping, pausing, and quitting.**
|
||||
- A skip fades straight to the first morning sign, without the loading screen.
|
||||
- Escape opens the pause menu as usual: the tree pauses, so the intro freezes, and the box waits
|
||||
(`blocked`).
|
||||
- "Restart the night" during the intro acts as a skip.
|
||||
- "Save & quit to menu" clears the intro. The save is night 1's morning (`new_campaign` autosaves),
|
||||
so Continue from there plays no intro.
|
||||
|
||||
**Platform**
|
||||
15. **No Quit buttons on phones.** Android's back button pauses, closes the top menu, or quits
|
||||
from the main menu.
|
||||
16. **iPad supported.** Layouts must fit 4:3 too. If iPad isn't wanted for v1, switch
|
||||
`targeted_device_family` to iPhone only and drop the 4:3 checks.
|
||||
17. **Android** is in this plan (#44) but can wait until iOS plays well.
|
||||
**Names and lines.**
|
||||
- Speakers: **Farmer**, **Farmer's Wife**, **Little Green Alien** (the existing speaker, who comes
|
||||
back on day 2), and **Big Green Alien**. They're editable in `speakers/*.tres`.
|
||||
- The user wrote "etc." for the bickering. The extra lines below marked *(draft)* are
|
||||
placeholders to rewrite freely in the `.tres`.
|
||||
|
||||
## The touch layout (19.5:9 phone, defaults)
|
||||
**Staging.**
|
||||
- The car waits parked nose-out (facing north) for the departure, so it drives straight off.
|
||||
- The same luggage rides on the ending's car (one shared kit), so the farmers come home loaded.
|
||||
- If the house model's front door is a separate node, it swings open. Otherwise the farmers appear
|
||||
on the porch with a door creak.
|
||||
- The scarecrow stands on a wooden post at its start spot (3, −13) in its rest pose, arms out
|
||||
(check that the mannequin's rest pose is a T-pose; if it isn't, ask).
|
||||
- Its lantern stays dark until the flash. Only player 1's scarecrow exists during the intro.
|
||||
- The chest glow is on every scarecrow (the co-op partner's too) from then on. It's a fixed part
|
||||
of the look, so nothing is saved for it.
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────────────┐
|
||||
│ (portrait) HP ▬▬▬▬▬ [ ‖ ] ┌ Day 3 of 30 ┐ │
|
||||
│ │ 2:58 to Dusk│ │
|
||||
│ └─────────────┘ │
|
||||
│ [Fear] [Use] │
|
||||
│ [Bomb] attack half: a finger is the move half: a [Build] │
|
||||
│ [Patch] attack stick (aim + attack) finger is the │
|
||||
│ move stick │
|
||||
│ (backpack) [1][2][3][4] [bomb] hotbar │
|
||||
└──────────────────────────────────────────────────────────────────────────┘
|
||||
notch side ←→ safe-area inset home indicator ↓ inset
|
||||
```
|
||||
## The storyboard
|
||||
|
||||
Build mode swaps the button columns: the attack side gets Rotate ⟲ ⟳ and Dismantle, and the move
|
||||
side gets Place and Done. The build bar replaces the hotbar.
|
||||
About 75 s if nothing is skipped or hurried. Stage names are `OpeningIntro.stage` values.
|
||||
|
||||
| # | Stage | Light | Camera | What happens | Sound |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | `leave` | morning (forced) | Wide from the yard's north-east, looking south-west at the porch and the parked car | The farmers come out of the door (19.6, −29.8) and walk to the car's doors. The **departure** conversation starts as they step off the porch, and they wait at the doors until it ends. ~18 s | door creak, day ambience |
|
||||
| 2 | `board` | | same | The farmer gets in on the left and the wife on the right; each disappears with a door slam. The engine starts and the luggage jiggles. ~2 s | car door ×2, engine |
|
||||
| 3 | `drive` | | Follows behind the car (the ending's follow camera), then stops at GapDriveway and watches it shrink down the road | The car drives the ending's route backwards: north along the yard road, east out GapDriveway (a horn toot), then south down the road at x 52 and away. The luggage sways on the turns. ~12 s | engine, horn |
|
||||
| 4 | `card` | night (forced, snapped while black) | — | Fade to black. "Later that night...." is written letter by letter in the handwritten font, centered. ~3.5 s | night ambience fades in |
|
||||
| 5 | `flight` | night | Low on the farm, looking up at the night sky; it pans to track the UFO | A big UFO (`EnemySystem.build_ufo_mesh` at scale ~8, `ufo.gdshader`, lights pulsing) crosses from the far north-east toward the farm. Its path jerks and banks with each line of the **flight** conversation (a tug-of-war on the controls). ~18 s | UFO hum (loop) |
|
||||
| 6 | `wobble` | | Holds on the UFO above the farm | It stops over the scarecrow at about (3, 20, −13). It sways side to side (±3 m, ±20° tilt) faster and faster, then spins up hard. ~4 s | rising whine |
|
||||
| 7 | `drop` | | Cuts to the scarecrow on its post as the part comes into frame | A part flies off the rim and tumbles down with a blue trail. It lands about 0.8 m in front of the scarecrow with a thud and a puff of dust. ~2.5 s | falling whistle, thud |
|
||||
| 8 | `flash` | | Close on the scarecrow | The part pulses three times, then a **blue flash**: a light spike, a full-screen blue-white flash fading out, and a ring across the ground. The part streaks into the scarecrow's chest and the chest glow comes on. The scarecrow drops off its post (`Hit_A`), lands, its lantern lights, and it looks around (`Idle_B`), then up. ~5 s | shimmer zap |
|
||||
| 9 | `uh_oh` | | Low behind the scarecrow, looking up at the hovering UFO | The **uh-oh** conversation. The UFO shifts guiltily. ~7 s | hum |
|
||||
| 10 | `escape` | | Holds on the scarecrow looking up | The UFO tilts and zooms off up and away, its lights streaking. ~2.5 s | whoosh |
|
||||
| 11 | `loading` | morning (released, snapped) | — | Fade to black, then the loading screen, about 3 s. Under it the farm is put back: post and part gone, the scarecrow idle at its start, HUD and input back, the light snapped to the morning look. ~4.5 s | |
|
||||
| 12 | `end` | | the game camera | Fade into the first morning sign ("The farmers are away", `review_panel.gd:164-170`). `finished` is emitted. | |
|
||||
|
||||
## The lines
|
||||
|
||||
**`intro/departure.tres`**
|
||||
- Farmer: "Well, I sure hope the farm will be okay."
|
||||
- Farmer's Wife: "Well then, you should have paid someone to come watch it for you instead of
|
||||
buying those front row tickets to the Bon Jovi concert."
|
||||
- Farmer: "Ah, it'll be alright. What's the worst that could happen?"
|
||||
|
||||
**`intro/flight.tres`**
|
||||
- Little Green Alien: "I want to fly the ship!"
|
||||
- Big Green Alien: "You flew it all the way from the Andromeda galaxy! It's my turn!"
|
||||
- Little Green Alien: "Your tentacles don't even reach the pedals!" *(draft)*
|
||||
- Big Green Alien: "Mother said we take turns! Give me the stick!" *(draft)*
|
||||
- Little Green Alien: "Hands off! [shake]HANDS OFF![/shake]" *(draft; the wobble starts on this line)*
|
||||
|
||||
**`intro/uh_oh.tres`**
|
||||
- Big Green Alien: "Uh oh.... we should go tell mother."
|
||||
- Little Green Alien: "Are you crazy!!! Let's just get out of here, maybe no one will notice!"
|
||||
|
||||
## How it fits together
|
||||
|
||||
- **`MobilePort`** (exists) gains `ui_scale()`, `safe_rect(canvas_item)`, the `--safe-area`
|
||||
simulator, and a `forced` override for tests (#35). `GameSettings.apply` sets the window's
|
||||
`content_scale_factor` on phones. That scales every CanvasLayer (HUD, menus, sticks) and leaves
|
||||
the 3D view alone.
|
||||
- **`Prompts`** (new, #36) returns touch wording on phones and today's exact strings elsewhere.
|
||||
Every key-naming string goes through it. The touch words name the buttons of #38–#40.
|
||||
- **`TouchSticks`** (exists) gets `move_on_right` as a variable (#38). It stops pressing fire in
|
||||
build mode and hands the attack half to placing (#40).
|
||||
- **`TouchButtons`** (new, #38) is a HUD Control with the contextual buttons, drawn in the
|
||||
`Sketch` style. Its buttons press the existing actions with `Input.action_press` and
|
||||
`action_release` (hold while the finger is down, and held for at least one physics tick), so
|
||||
game code and `ActionEdges` don't change. Buttons are Controls with STOP, so they take their
|
||||
touches before the sticks. Everything else stays IGNORE so the sticks keep the screen.
|
||||
- **Settings contract** (#38 and #41): `TouchSticks` and `TouchButtons` join group
|
||||
`&"touch_controls"` and implement `apply_settings(s: GameSettings)`. `GameSettings.apply` calls
|
||||
`get_tree().call_group(&"touch_controls", &"apply_settings", self)` and sets the camera's
|
||||
distance. This way #41 doesn't need `main.gd`.
|
||||
- **HUD hit targets** (#39): the hotbar slots, the backpack, the tip ×, and the dialogue Skip
|
||||
button are small STOP Controls over today's drawn widgets.
|
||||
- **`BuildMode`** (#40) gets a screen-point cursor hook (the mouse ray path, fed by a finger),
|
||||
plus public `confirm()` and `dismantle()` that the buttons call. The key and gamepad paths stay
|
||||
the same.
|
||||
- **Layout passes** (#41–#43) fit every screen to the scaled canvas inside `safe_rect`. They use
|
||||
scroll lists where a panel is taller than about 640 px, wrapping, and anchors instead of
|
||||
1920×1080 absolutes.
|
||||
**`OpeningIntro`** (`game/scripts/opening_intro.gd`)
|
||||
- A `Node3D` under `FarmSim`, built and wired in `_ready` like `FarmersReturn` (`farm_sim.gd:312`).
|
||||
- Everything is built in `start()` and freed in `clear()`, so nothing exists during play.
|
||||
- `step(delta)` drives the stage machine, so tests can step it headless the way
|
||||
`test_flow.gd:_ending` steps the ending.
|
||||
- Its API is `start()`, `skip()`, `clear()`, `running`, `done`, `stage`, and `signal finished`.
|
||||
|
||||
**`CutsceneKit`** (`game/scripts/cutscene_kit.gd`): static helpers shared with `FarmersReturn`.
|
||||
- The car with its roof luggage.
|
||||
- The tinted farmer mannequins with straw hats, and their `AnimationPlayer`s.
|
||||
- Camera easing (`_move_camera`) and the follow-behind camera.
|
||||
- The letterbox overlay with its caption label and the skip hint.
|
||||
|
||||
**Its own `DialogueBox`** sits in the intro's overlay `CanvasLayer`, because the HUD layer is
|
||||
hidden.
|
||||
- Its conversations live in `game/resources/dialogue/intro/`. `DialogueDirector.load_all` skips
|
||||
subfolders, so they never play by themselves.
|
||||
- They use `pause_game = true` (the box takes input) with `auto_advance` ≈ 1.6 s, so lines go on
|
||||
by themselves and a tap hurries them. The intro plays them with `box.play()`, never through
|
||||
`DialogueDirector.play()`, so the tree isn't paused.
|
||||
- Main sets the box's `blocked` the same way as `sim.dialogue.box.blocked` (`main.gd:66`).
|
||||
- **Framing:** the paper is 1360×350, 118 px above the bottom, and the heads stand above it. Keep
|
||||
the action in the upper half of the frame while a line is up. If that isn't enough, give
|
||||
`DialogueBox` a size scale at the timing review (#34).
|
||||
|
||||
**Hooks it needs:**
|
||||
- **`DayNight.forced`** (empty = normal): `target()` returns the named look ("morning" = the
|
||||
MORNING mix, "night" = `NIGHT`). A way to keep a lantern dark.
|
||||
- **The morning sign:**
|
||||
- `ReviewPanel.refresh()` keeps the sign hidden while `sim.intro` is running.
|
||||
- `DialogueDirector` doesn't start morning conversations or call `_sign(true)` while the intro
|
||||
runs.
|
||||
- When the intro ends, it hands over: night 1's morning conversations (none today), then the
|
||||
sign.
|
||||
- **`Tutorial`** hides while the intro runs.
|
||||
- **Freezing and focus:** `sim.freeze_local(true)` stops the scarecrow's input (morning input
|
||||
isn't otherwise gated). Audio focus goes to the cutscene's subject (`sim.audio.focus`), and the
|
||||
HUD layer is hidden (`FarmersReturn._set_hud`).
|
||||
- **`Main.new_vacation()`** (`main.gd:162`): after `new_campaign()`, call `sim.intro.start()`
|
||||
unless hosting. `_host_coop` must not start it. `to_menu()` clears it.
|
||||
|
||||
**`LoadingScreen`** (`game/scripts/loading_screen.gd`) is a self-contained `Control` with
|
||||
`play(seconds)` and `signal finished`, so it can be reused later.
|
||||
|
||||
## File overlap and order
|
||||
|
||||
| File | Tasks |
|
||||
|---|---|
|
||||
| `mobile_port.gd`, `game_settings.gd` | #35, then #41 (`game_settings.gd`: new settings) |
|
||||
| `run_tests.gd`, `test_mobile.gd` (new), `game/tests/mobile/` | #35 creates them; later tasks add their own files only |
|
||||
| `prompts.gd` (new); key strings in `tutorial.gd`, `review_panel.gd`, `interactions.gd`, `workbench.gd`, `shed_counter.gd`, `build_mode.gd`, `build_hud.gd`, `opening_intro.gd`, `farmers_return.gd` | #36 |
|
||||
| `project.godot`, `main.gd`, `main_menu.gd`, `pause_menu.gd`, `toon_look.gd`, `screen_labels.gd`, `follow_camera.gd` | #37 (wave 1). `main.gd` again in #38; `main_menu.gd` and `pause_menu.gd` again in #41 |
|
||||
| `touch_buttons.gd` (new), `touch_sticks.gd`, `interactions.gd` (query only), `main.gd`, `sketch.gd` (icons) | #38, then #40 (`touch_sticks.gd`, `touch_buttons.gd`) |
|
||||
| `player_character.gd`, `game_config.gd`, `game_config.tres`, `upgrades.gd` (docs), `test_scarecrow.gd`, `test_economy.gd`, `test_nights.gd` | #46 |
|
||||
| `scarecrow_hud.gd` | #46 (stamina bar out, wave 1), then #39, then #43 |
|
||||
| `scarecrow_hud.gd`, `resource_hud.gd`, `tutorial.gd`, `dialogue_box.gd` | #39, then #43 (all but `resource_hud.gd`) |
|
||||
| `main_menu.gd`, `pause_menu.gd`, `confirm_box.gd`, `settings_menu.gd`, `game_settings.gd`, `scarecrow.gd` (haptics) | #41 |
|
||||
| `review_panel.gd`, `end_panel.gd`, `upgrade_panel.gd` | #42 |
|
||||
| `build_mode.gd`, `build_hud.gd` | #40 (after #36's string edits) |
|
||||
| `phase_hud.gd`, `radar_hud.gd`, `alert_manager.gd`, `cutscene_kit.gd`, `loading_screen.gd` | #43 |
|
||||
| `export_presets.cfg`, `codemagic.yaml`, adaptive icon layers | #44 |
|
||||
| `README.md`, `game/LAYOUT.md`, `game/PLAYTEST.md`, `docs/ios-test-port.md` | #45 |
|
||||
| `farmers_return.gd` | #29 (moves pieces into the kit) |
|
||||
| `cutscene_kit.gd` (new) | #29, used by #33 |
|
||||
| `day_night.gd` | #30 |
|
||||
| `farm_audio.gd`, `game/tools/synth_audio.gd`, `assets/audio/synth/` | #30 |
|
||||
| `player_character.gd` (or wherever the scarecrow's model is built) | #30 (chest glow) |
|
||||
| `sketch.gd` | #31 (two icons) |
|
||||
| `game/resources/dialogue/` | #31 |
|
||||
| `loading_screen.gd` (new) | #32 |
|
||||
| `opening_intro.gd` (new), `farm_sim.gd`, `main.gd`, `review_panel.gd`, `dialogue_director.gd`, `tutorial.gd` | #33 |
|
||||
| `test_flow.gd` | #29 (ending still passes), #33 (new-vacation flow) |
|
||||
| `README.md`, `game/LAYOUT.md`, `game/PLAYTEST.md`, `RULES.md` | #33 |
|
||||
|
||||
| Wave | Tasks (parallel within a wave) | Size |
|
||||
|---|---|---|
|
||||
| 1 | #35 scale and safe area · #36 prompts · #37 platform · #46 sprint as a speed upgrade | M · M · S · S |
|
||||
| 2 | #38 action buttons · #39 tappable HUD · #41 menus and settings · #42 panels | L · M · M · M |
|
||||
| 3 | #40 build mode · #43 HUD and cutscene layout | L · M |
|
||||
| any | #44 Android (independent; best once iOS plays well) | M |
|
||||
| last | #45 device playtest and docs (with the user) | — |
|
||||
- **Wave 1 (parallel):** #29, #30, #31, #32. They touch different files.
|
||||
- **Wave 2:** #33, after all of wave 1.
|
||||
- **Wave 3:** #34, the timing review with the user.
|
||||
|
||||
## Tasks
|
||||
|
||||
### #35 [mobile] Interface scale, safe area, and the mobile test kit
|
||||
### #29 [intro] Cutscene kit and the loaded-up car
|
||||
|
||||
(#46, the sprint change, is in wave 1 too. Its section is after #44.)
|
||||
- **Extract from `FarmersReturn`:** the car instancing (collision layers off, engine player), the
|
||||
farmer building (tinted mannequins, straw hats, `AnimationPlayer` with
|
||||
`player_animations.res`), `_move_camera` / `_follow_camera` / `_face`, and `_build_overlay`. Put
|
||||
them in `CutsceneKit` as static functions or small helper classes. `FarmersReturn` keeps its
|
||||
behavior exactly.
|
||||
- **Roof luggage** (`CutsceneKit.load_roof(car)`), National Lampoon's style:
|
||||
- A tall, slightly crooked stack on `car_002`'s roof rack, as children of the car so it rides
|
||||
along.
|
||||
- Use the farm pack's `bag_001..003` and `box_004/005` props, scaled, plus 3–4 primitive
|
||||
suitcases in different colors. Add 2–3 thin dark straps over the top, tied down, and one item
|
||||
hanging off the side (a rolled mattress or a bike, primitives are fine).
|
||||
- Find the roof height from the car mesh's AABB, not a hard-coded number.
|
||||
- A small sway, driven by the car's turning and braking (`CutsceneKit.sway_luggage(delta, turn,
|
||||
accel)`).
|
||||
- The ending's car gets the luggage too.
|
||||
- **Verify:** `test_flow.gd`'s `_ending` passes unchanged. A new check confirms the car has its
|
||||
luggage and the luggage sits above the roof's AABB top. No new FAIL lines. Take a screenshot of
|
||||
the parked car (headless can't render, so use the editor binary with a window, as in
|
||||
`render_overview.gd`) and show it to the user.
|
||||
|
||||
- `MobilePort.ui_scale()`: work out the physical screen height in inches from
|
||||
`DisplayServer.screen_get_size()` and `screen_get_dpi()`. Use `clampf(4.3 / inches, 1.0, 1.7)` (the cap was 1.8; the user lowered it after #35),
|
||||
which gives about 1.6 on phones and 1.0 on iPads, times `GameSettings.interface_size` (0.8–1.3,
|
||||
default 1.0). Desktop is always 1.0. **Check `screen_get_dpi()` on an iPhone through the
|
||||
PerfTest overlay before relying on it.** If it's wrong or 0, fall back to the screen's
|
||||
shorter-side size class (phone below 500 pt, else tablet).
|
||||
- Apply it in `GameSettings.apply` on phones as `get_window().content_scale_factor`.
|
||||
- `MobilePort.safe_rect(ci: CanvasItem) -> Rect2`: `DisplayServer.get_display_safe_area()`
|
||||
mapped into the canvas through the viewport's final transform, so it includes the scale. On
|
||||
desktop it's the full visible rect. A `--safe-area=l,t,r,b` user argument (window pixels)
|
||||
simulates an inset.
|
||||
- `static var forced := -1` (−1 = detect, 0 = desktop, 1 = phone) for tests. `active()` honours
|
||||
it.
|
||||
- `minimum_target()`: 44 pt in canvas pixels at the current scale.
|
||||
- Test kit: `game/tests/test_mobile.gd`, added once to `run_tests.gd`'s SUITES, which runs every
|
||||
`game/tests/mobile/*_test.gd` in name order with the runner's `check()`. `mobile/touch.gd` has
|
||||
static `touch(i, canvas_pos, pressed)` and `drag(i, from, to)`.
|
||||
- Port the sticks checks (the 24 from 8c81d81's driver) into `mobile/sticks_test.gd`.
|
||||
- **Verify:** `scale_test.gd` covers the scale for phone, tablet, and desktop sizes, the safe
|
||||
rect with a simulated inset, and desktop untouched (factor 1). `sticks_test.gd` passes. Take
|
||||
screenshots of the day HUD at 2340×1080 with an inset and at 4:3 (layouts will overflow; #41–#43
|
||||
fix that). No new FAIL lines.
|
||||
### #30 [intro] Hooks: forced lighting, sounds, the chest glow
|
||||
|
||||
### #36 [mobile] Prompts in touch words
|
||||
- **`DayNight.forced: String`** (`""`, `"morning"`, `"night"`): `target()` returns that look while
|
||||
it's set, and `snap()` still works. Add a lantern override (`lanterns_dark := false`) so the
|
||||
intro can keep the scarecrow's lantern off until the flash.
|
||||
- **Sounds** (`synth_audio.gd`, written to `assets/audio/synth/`, registered in `FarmAudio`):
|
||||
- `ufo_hum`: a loop, a low wobbling drone.
|
||||
- `ufo_whine`: a rising spin-up, ~2 s.
|
||||
- `part_fall`: a falling whistle, ~1.5 s.
|
||||
- `life_flash`: a bright shimmer-zap.
|
||||
- `ufo_zoom`: a doppler whoosh away.
|
||||
- `car_door`: a dull metal thunk.
|
||||
- `door_creak`: try `kenney/rpg/creak*` first (already used for `thief_arrive`).
|
||||
- Reuse `fall`, `horn`, `truck_engine`, and the ambiences.
|
||||
- **Chest glow:**
|
||||
- A small emissive blue core on each scarecrow's model at chest height, with a faint pulse and a
|
||||
weak `OmniLight3D`. Keep it subtle in daylight and visible at night.
|
||||
- It's on by default, and `set_core_glow(on)` lets the intro hide it until the flash.
|
||||
- It must not break the hit-flash material swap or the toon look.
|
||||
- **Verify:** unit checks that `forced` overrides `target()` and clears back, and that the new
|
||||
sound names resolve to streams. No new FAIL lines. Take a screenshot of the scarecrow at night
|
||||
showing the glow.
|
||||
|
||||
- `Prompts` (`prompts.gd`): `Prompts.touch()` returns `MobilePort.active()`, and one function or
|
||||
constant per prompt returns the touch wording or today's string.
|
||||
- Touch wordings (the button names come from #38–#40):
|
||||
- World labels: "[E / X] Gather" becomes "Gather". Repair, Upgrade, Upgrades, and Shop likewise
|
||||
lose the key.
|
||||
- Build ghost: "[LMB / RT] Build" becomes "Place", and "[RMB / B] Dismantle" becomes
|
||||
"Dismantle (+refund)".
|
||||
- Build bar help line: "Place · Rotate · Dismantle · Done" (or none, if the buttons make it
|
||||
redundant; show the user).
|
||||
- Cutscenes: "Hold to skip" (intro) and "Tap to skip" (farmers' return).
|
||||
- Tip footer: "Tip · × hides tips".
|
||||
- The tutorial tips and the first morning sign's lines, rewritten for touch. Examples: "Move
|
||||
with your right thumb…", "Hold Use at a dead tree…", "Tap the backpack…", "Build (by day):
|
||||
tap Build, pick a fence, put your finger where it goes, then Place…", "Your left thumb aims
|
||||
and attacks… tap the hotbar to switch… Bomb throws one…", "Crowded? Fear…", "Hurt? Hold
|
||||
Patch…". Show the user the full set.
|
||||
- **Verify:** `prompts_test.gd` checks the phone strings for each prompt and that a sample of
|
||||
desktop strings is byte for byte what it was. No new FAIL lines.
|
||||
### #31 [intro] Speakers and the three conversations
|
||||
|
||||
### #37 [mobile] Platform: back button, no Quit, flat labels, camera
|
||||
- **Speakers** in `game/resources/dialogue/speakers/`:
|
||||
- `farmer.tres` (left side, low voice pitch).
|
||||
- `farmers_wife.tres` (right side, higher pitch).
|
||||
- `big_green_alien.tres` (icon `"thief"`, right side, `portrait_height` ~380 so it's literally
|
||||
bigger than the Little Green Alien's 300, lower pitch).
|
||||
- The existing `little_green_alien.tres` stays as it is, on the left.
|
||||
- **Two new `Sketch.ICONS`:** `"farmer"` (a round face, a straw hat, a moustache) and
|
||||
`"farmers_wife"` (a straw hat with a flower, curls), drawn the way the existing icons are.
|
||||
- **Conversations** in `game/resources/dialogue/intro/` (`departure.tres`, `flight.tres`,
|
||||
`uh_oh.tres`), with the lines from "The lines" above:
|
||||
- `pause_game = true`, `auto_advance` 1.6, `enabled = false`.
|
||||
- Being in a subfolder already keeps them from playing by themselves; `enabled = false` is a
|
||||
second guard.
|
||||
- Write them as text, with uids.
|
||||
- **Verify:** `test_dialogue.gd` loads each one and checks the speakers and line counts.
|
||||
`DialogueDirector.load_all(DIR)` still returns only `morning_day_2`. No new FAIL lines. Take a
|
||||
screenshot of the box with each new speaker up.
|
||||
|
||||
- **Android back:** set `application/config/quit_on_go_back=false`. Main handles
|
||||
`NOTIFICATION_WM_GO_BACK_REQUEST` like the pause action: playing pauses; paused closes the
|
||||
confirm box, then settings, then resumes; at the main menu it quits (Android convention).
|
||||
- **Quit:** hide the main menu's Quit and the pause menu's "Quit the game" on phones.
|
||||
- **World labels on phones:** `ScreenLabels` without `ToonLook`. Main adds `ScreenLabels` on its
|
||||
own on phones, so the Label3D prompts draw flat and scale with the interface. `ToonLook` keeps
|
||||
creating it on desktop.
|
||||
- **Camera:** default distance 12 m on phones (`FollowCamera.distance`). The setting comes in #41.
|
||||
- **Verify:** `platform_test.gd` covers the back-request sequence (play, pause, settings, back,
|
||||
back, resume; main menu quits), no Quit on phones (Quit still there on desktop), ScreenLabels
|
||||
present on phones, and the camera distance. A screenshot of world labels at 1.6×. No new FAIL
|
||||
lines.
|
||||
### #32 [intro] The loading screen
|
||||
|
||||
### #38 [mobile] Touch action buttons
|
||||
- **`LoadingScreen extends Control`:** full-rect, on its own `CanvasLayer` (the caller adds it).
|
||||
- **Splash art:** `splash-screen.png`, scaled to cover (crop, never letterbox), with a slow
|
||||
Ken-Burns pan and zoom over the screen's time.
|
||||
- **Title:** "Harvest Season" in `Sketch.font()` with the outline style (there's no logo image
|
||||
yet; `assets/pictures/logo/` is empty).
|
||||
- **Progress:** a hand-drawn progress bar (`Sketch.box` / `Sketch.line`) fills over `seconds`. The
|
||||
sketch `"ufo"` icon bobs and wobbles along its leading edge. "Loading..." is written under it,
|
||||
with the dots cycling.
|
||||
- **API:** `play(seconds := 3.0)` fades in from black, runs, and emits `finished` at full
|
||||
progress. The caller fades it out.
|
||||
- It works while the tree is paused (`PROCESS_MODE_ALWAYS`).
|
||||
- **Verify:** a unit check that `finished` fires once after `seconds` of steps. Take a screenshot
|
||||
mid-way.
|
||||
|
||||
- `TouchButtons` (`touch_buttons.gd`) is a HUD Control (Main adds it beside TouchSticks). It
|
||||
lays out inside `MobilePort.safe_rect`, with each button at least `MobilePort.minimum_target()`.
|
||||
Buttons are round, in the `Sketch` style, with an icon and at most one word. The set:
|
||||
- **Pause:** opens the pause menu. Top edge, beside the phase widget. Always shown while
|
||||
playing.
|
||||
- **Fear:** a tap. Shows the cooldown as a ring, like the portrait's.
|
||||
- **Bomb:** shown once pumpkin bombs are owned. A tap throws (offhand: press, then release).
|
||||
Shows a ring while it recharges.
|
||||
- **Patch:** shown when hurt and carrying straw. Hold it, with a 2 s progress ring.
|
||||
- **Use:** shown when something is in reach. Its word comes from `Interactions` (a new
|
||||
read-only `focus()` that returns kind and label; no behaviour change). Hold or tap as E does.
|
||||
- **Build:** by day. Toggles build mode (#40 adds the build-mode set).
|
||||
- No sprint control: after #46, Sprint is a passive speed upgrade.
|
||||
- `TouchSticks.move_on_right` becomes a variable (default `MOVE_ON_RIGHT`). The button columns
|
||||
follow it. Both nodes join `&"touch_controls"` with `apply_settings()`, a stub until #41.
|
||||
- A button keeps its action pressed for at least one physics tick, so a quick tap still counts.
|
||||
Pause, freeze, and hiding let everything go, as the sticks do.
|
||||
- Icons go in `Sketch` as needed (pause, bomb, patch, use, build).
|
||||
- **Verify:** `buttons_test.gd` drives each button by touch:
|
||||
- Fear starts its cooldown.
|
||||
- Holding Patch heals after 2 s.
|
||||
- Holding Use gathers at a node; tapping Use by day opens the workbench.
|
||||
- Bomb throws.
|
||||
- Pause opens the menu.
|
||||
- A touch on a button starts no stick; hidden buttons don't block the sticks.
|
||||
### #33 [intro] The opening intro
|
||||
|
||||
Take a screenshot of the day HUD at 2340×1080 with an inset. No new FAIL lines.
|
||||
Blocked by #29–#32.
|
||||
|
||||
### #39 [mobile] Tappable HUD
|
||||
- Build `OpeningIntro` per "How it fits together" and the storyboard. That means stages 1–12, the
|
||||
hold-to-skip, its own `DialogueBox`, and the hooks into `ReviewPanel`, `DialogueDirector`,
|
||||
`Tutorial`, `freeze_local`, the HUD layer, audio focus, and `DayNight.forced`.
|
||||
- **The part:** a primitive-built gizmo, about 0.5 m: a dark metal cylinder and a torus, a glowing
|
||||
blue core (emission plus an `OmniLight3D`), and a blue trail while it falls (a `GPUParticles3D`
|
||||
or a few fading quads).
|
||||
- **The flash:** an `OmniLight3D` energy spike, a full-screen `ColorRect` in the overlay going
|
||||
blue-white and fading, and a ground ring (reuse `fear_burst.gdshader` if it fits).
|
||||
- **The UFO:** a `MeshInstance3D` with `build_ufo_mesh(8.0)` and a `ufo.gdshader` material, set up
|
||||
as `FarmSim` does for the enemy UFOs (`farm_sim.gd:201`) but its own instance. Spin it with the
|
||||
shader's spin plus node rotation for the fast spin. Give it night glow.
|
||||
- **Wiring:**
|
||||
- `FarmSim` builds `intro` next to `ending`.
|
||||
- `Main.new_vacation()` starts it, except from `_host_coop`. `to_menu()` clears it.
|
||||
- "Restart the night" skips it.
|
||||
- Main sets the intro box's `blocked`.
|
||||
- **Ends cleanly:** after `finished` (or a skip), the farm must be exactly what `new_campaign()`
|
||||
leaves:
|
||||
- the scarecrow at its start, input back, HUD back, the lighting un-forced and snapped;
|
||||
- the post, the part, the UFO, the car, and the farmers freed;
|
||||
- the morning sign up with focus on its Start button.
|
||||
- **Docs:** README (what happens on New vacation; the skip), `game/LAYOUT.md` (the intro's staging
|
||||
points, next to "The car's route"), `game/PLAYTEST.md` (a line to watch it once and try a skip),
|
||||
and RULES.md if it describes starting a vacation.
|
||||
- **Verify:**
|
||||
- A new `test_intro.gd` (registered in `run_tests.gd`) covers these:
|
||||
- New vacation starts it, and Continue doesn't.
|
||||
- Hosting doesn't start it.
|
||||
- Stepping to the end visits every stage in order, ends with `done`, and the sign is visible.
|
||||
- During the intro the sign is hidden, the HUD layer is hidden, and the scarecrow can't move.
|
||||
- A skip at each stage ends clean.
|
||||
- `to_menu` mid-intro leaves no intro nodes. Restart mid-intro ends clean.
|
||||
- The lighting is back to the MORNING target, and the chest glow is on after.
|
||||
- No new FAIL lines.
|
||||
- A windowed run with frames captured at every stage, to show the user.
|
||||
|
||||
- **Hotbar:** tap a slot to equip that weapon (only when combat allows switching, as with Tab).
|
||||
- **Backpack:** a tap toggles the pouch panel, and a tap outside closes it. The pouch panel
|
||||
fits the scaled canvas.
|
||||
- **Tips:** an × on the tip box hides tips (as `hide_tips`).
|
||||
- **Dialogue:** a Skip button on conversations that pause the game skips the conversation (as
|
||||
Backspace). A tap still advances.
|
||||
- Each hit target is a STOP Control over its drawn widget only. The rest of each widget stays
|
||||
IGNORE.
|
||||
- **Verify:** `hud_taps_test.gd` covers each tap and checks that a touch beside each widget still
|
||||
starts a stick. Screenshots. No new FAIL lines.
|
||||
### #34 [intro] Timing review with the user
|
||||
|
||||
### #40 [mobile] Build mode by touch (after #36 and #38)
|
||||
|
||||
- In build mode, TouchSticks never presses `fire`. This fixes placing on every tilt. A finger on
|
||||
the attack half sets `BuildMode`'s screen-point cursor, so the ghost goes under the finger,
|
||||
clamped to `build_range`, and stays put when the finger lifts.
|
||||
- The TouchButtons build set: Place (greyed when invalid; the ghost label still says why),
|
||||
Rotate ⟲ and ⟳, Dismantle (when the cursor is over a structure), and Done. Build-bar slots are
|
||||
tappable to pick. The build bar sits above the home indicator.
|
||||
- `BuildMode`: add `cursor_screen` (null means use the existing mouse or gamepad path), plus
|
||||
public `confirm()` and `dismantle()` taken from `step`. Keyboard and gamepad behave the same.
|
||||
- **Verify:** `build_test.gd`, all by touch: enter, pick a gate, put the ghost down, rotate,
|
||||
place (costs paid), dismantle (refund), and Done. At night Place refuses with "Building is for
|
||||
daytime". `test_structures` has no new FAIL lines. Screenshot.
|
||||
|
||||
### #41 [mobile] Menus and settings at phone scale
|
||||
|
||||
- **Main menu:** anchored and fitted to the scaled canvas and the safe rect.
|
||||
- **Pause and confirm:** buttons at least `minimum_target()` tall.
|
||||
- **Settings on phones:**
|
||||
- Audio, unchanged.
|
||||
- Touch: Interface size, Swap sticks, Camera distance (8–20 m), Haptics.
|
||||
- Gameplay: tips.
|
||||
- Display: 3D resolution scale only.
|
||||
- A short touch-controls guide in place of the bindings table.
|
||||
- Fullscreen, VSync, and the mouse note are hidden. Reset leaves hidden settings alone.
|
||||
- Drag-scrolling mustn't fight the sliders: tall rows, and a slider only grabs after a
|
||||
horizontal move. Check on a device.
|
||||
- **`GameSettings`:** `interface_size` (from #35), `swap_sticks`, `camera_distance`, and `haptics`,
|
||||
saved and loaded with fallbacks. They're applied live: the call to `&"touch_controls"` and the
|
||||
camera's `distance`.
|
||||
- **Haptics:** `Input.vibrate_handheld(30)` when the scarecrow takes a hit (`scarecrow.gd`), on
|
||||
phones with the setting on.
|
||||
- **Verify:** `menus_test.gd` checks every menu's buttons inside the safe rect at 19.5:9 and 4:3
|
||||
(1.6× and 1.0×) and at least the minimum target, the settings round trip, and the swap moving
|
||||
the sticks. Desktop settings are unchanged. Screenshots. No new FAIL lines.
|
||||
|
||||
### #42 [mobile] Panels at phone scale
|
||||
|
||||
- **Morning sign** (about 850 tall today): fits about 640 px by scrolling or splitting into two
|
||||
columns, and Start the day stays visible.
|
||||
- **End panel:** stats wrap.
|
||||
- **Workbench and shed panels:** a scroll list with rows at least the minimum target, and Close
|
||||
always visible.
|
||||
- **Verify:** `panels_test.gd` checks each panel's rect inside the safe rect at 19.5:9 and 4:3,
|
||||
and that rows and buttons are at least the minimum target. The desktop layout is the same at
|
||||
1920×1080. Screenshots. No new FAIL lines.
|
||||
|
||||
### #43 [mobile] HUD and cutscenes at phone scale (after #39)
|
||||
|
||||
- Every HUD widget sits inside `safe_rect`: the portrait and HP, the phase widget and radar, the
|
||||
hotbar above the home indicator, the backpack, the banner, the dusk hint, the tutorial box, and
|
||||
the dialogue box (paper and heads fit about 640 px).
|
||||
- Letterbox bars and skip hints, and the loading screen.
|
||||
- Alert edge arrows keep out of the real widget rects instead of today's constants.
|
||||
- **Verify:** `hud_layout_test.gd` checks every widget's rect inside the safe rect at 19.5:9 with
|
||||
an inset and at 4:3, and no two overlapping. The desktop layout is unchanged. Screenshots of a
|
||||
day, a night, a conversation, and the intro's skip hint. No new FAIL lines.
|
||||
|
||||
### #44 [mobile] Android build
|
||||
|
||||
- An Android preset:
|
||||
- Gradle build, arm64.
|
||||
- The target SDK Play currently requires.
|
||||
- Sensor landscape, ETC2/ASTC (already on).
|
||||
- An adaptive icon (foreground and background layers from `app_icon.png`).
|
||||
- The `perf_test` feature on the test build.
|
||||
- An `android-perf-test` workflow in `codemagic.yaml`: a Linux instance, the keystore from
|
||||
Codemagic's code-signing identities, AAB and APK artifacts, and optionally Play's internal
|
||||
track.
|
||||
- **Needs from the user:** a Google Play developer account, a keystore (Codemagic can generate
|
||||
one), and for a personal account, 12 testers in a closed test for 14 days before production.
|
||||
- **Verify:** the Codemagic build installs on an Android phone. Back behaves as in #37, the
|
||||
sticks and buttons work, and the safe area holds on a hole-punch camera.
|
||||
|
||||
### #46 [gameplay] Sprint becomes a speed upgrade (all platforms)
|
||||
|
||||
- When the Sprint upgrade is owned (`Upgrades.owned(state, "sprint")`), the scarecrow's base speed
|
||||
is multiplied by `config.sprint_speed_mult` (now 1.25) all the time, walking and running alike.
|
||||
Without it, the speed is unchanged.
|
||||
- Remove the burst: hold-to-sprint, `sprint_time`, `sprint_cooldown`, the stamina state in
|
||||
`PlayerCharacter` (`step_sprint` and friends), and the HUD's stamina bar (`scarecrow_hud.gd`).
|
||||
The `sprint` input action stays in `project.godot` (unused). Removing it is a follow-up, since
|
||||
#37 owns that file.
|
||||
- The upgrade's id stays `"sprint"` (saves and costs are unchanged). Its text becomes "Run 25%
|
||||
faster, always" in `game_config.gd`'s defaults and in `game_config.tres`, which overrides it.
|
||||
- Update the sprint checks in `test_scarecrow.gd`, `test_economy.gd`, and `test_nights.gd`
|
||||
rather than deleting them. Check that the speed is the same without the upgrade, ×1.25 with it,
|
||||
with no time limit, and that it survives save and retry.
|
||||
- **Verify:** no new FAIL lines beyond the sprint checks this task rewrites (list any that change
|
||||
and why). Desktop and phone both get the boost.
|
||||
|
||||
### #45 [mobile] Device playtest and docs (with the user)
|
||||
|
||||
- A TestFlight build on iPhone (and iPad, if supported). Play a whole new vacation by touch: the
|
||||
intro skip, the day-1 tutorial, gathering, building, a night fight, the workbench and shed, the
|
||||
pouch, a conversation, settings, sending the app to the background and back, game over, retry,
|
||||
and the farmers' return.
|
||||
- Docs: a mobile section in `README.md`, the new scripts in `game/LAYOUT.md`, a touch checklist
|
||||
in `game/PLAYTEST.md`, and `docs/ios-test-port.md` brought up to date.
|
||||
- The user's notes go to `docs/followups.md`.
|
||||
- **Done when:** the user signs off that a vacation plays by touch alone.
|
||||
|
||||
## Not in this plan
|
||||
|
||||
- **Ads and the remove-ads purchase:** the next plan. It will need a spot for "Remove ads" in the
|
||||
pause menu and an interstitial at dawn.
|
||||
- **Pinch zoom:** it needs gesture arbitration with the sticks.
|
||||
- **Co-op on phones, cloud saves, localization, and controller remapping.**
|
||||
- **Release cleanup:** removing the `perf_test` feature, a real icon, and the store listing.
|
||||
Run the intro in a window and capture each shot. Then go through the user's notes: line timing
|
||||
(`auto_advance`, letters/s), shot framing against the dialogue box (add a box size scale if
|
||||
needed), UFO sway and spin feel, flash strength, the luggage's look, the loading screen's length,
|
||||
and rewrites of the *(draft)* lines. No acceptance beyond the user's sign-off.
|
||||
|
|
|
|||
150
docs/tasks.md
150
docs/tasks.md
|
|
@ -362,153 +362,3 @@ dialogue system before starting: worktrees branch from HEAD.
|
|||
Captured shots, then the user's notes on timing, framing against the box, the UFO's feel, the
|
||||
flash, the luggage, the loading length, and the draft lines.
|
||||
*Acceptance:* the user signs off.
|
||||
|
||||
# Playable on phones — task list
|
||||
|
||||
Plan, decisions, defaults, the touch layout, and file overlap: `docs/plan.md` (2026-10-14). The
|
||||
desktop build must not change; phone behaviour stays behind `MobilePort.active()`. Mobile tests go
|
||||
in `game/tests/mobile/` (one file per task) and run with `-- --suite=test_mobile` after #35.
|
||||
|
||||
## Wave 1 (parallel)
|
||||
|
||||
- [x] **#35 Interface scale, safe area, and the mobile test kit.** Blocks #38–#43. *(merged
|
||||
aee60b0 — `MobilePort.ui_scale(interface_size)`, `scale_for(px, dpi, px_per_pt)` (size-class
|
||||
fallback for an implausible DPI), `safe_rect(ci)`, `minimum_target(ci)`, `forced`, preview
|
||||
`--safe-area=l,t,r,b` / `--dpi=N` (else a ≥1.7:1 window is a phone, ~1.59×); `interface_size`
|
||||
is saved (`[touch]`), #41 adds the slider; `GameSettings.apply_scale`; PerfTest shows
|
||||
`MobilePort.describe()` — read the DPI line on the next TestFlight build; test kit: each
|
||||
`mobile/*_test.gd` has `run(t)`, `test_mobile` resets `forced`/root size/factor between files,
|
||||
headless root is 64×64 (counts as an iPad: set `t.root.size = Vector2i(2340, 1080)` for a
|
||||
phone); `Touch` = `preload("res://game/tests/mobile/touch.gd")`; capture:
|
||||
`game/tools/capture_mobile.gd`; the 1.8 cap gives a 600 px canvas on SE / 13 mini (open for the
|
||||
user); the scale isn't re-applied on resize)*
|
||||
`MobilePort.ui_scale()` (physical screen height → about 1.6× on phones, 1× on tablets, times an
|
||||
Interface size setting) applied as the window's `content_scale_factor`; `safe_rect()`;
|
||||
`--safe-area` simulator; `forced` override; `minimum_target()` (44 pt). `test_mobile.gd` runner,
|
||||
`mobile/touch.gd` helper, and the sticks checks ported to `mobile/sticks_test.gd`.
|
||||
*Acceptance:* scale and safe-rect checks; desktop factor 1; screenshots at 2340×1080 with an
|
||||
inset and at 4:3; no new FAIL lines.
|
||||
|
||||
- [x] **#36 Prompts in touch words.** Blocks #40. *(merged 9f4a189 — `Prompts` (all static, one
|
||||
function per prompt; `Prompts.tip(id)` picks `TOUCH_TIPS` on phones, `Tutorial.TEXT` stays the
|
||||
desktop table; `move_side()`/`attack_side()` from `TouchSticks.MOVE_ON_RIGHT`, #38 points them at
|
||||
`move_on_right`); build-bar slots drop their number key on phones; open for the user: keep the
|
||||
build help line, "Hold Use" vs "Hold Gather"; left over: the hotbar's number keys
|
||||
(`scarecrow_hud.gd`, #39) and `[N] start the night early` (`phase_hud.gd`, off by default))*
|
||||
`Prompts` returns touch wording on phones and today's strings elsewhere: world labels, build
|
||||
ghost and bar, cutscene hints, tip footer, tutorial tips, first morning sign.
|
||||
*Acceptance:* phone strings checked; desktop strings byte for byte unchanged; the user sees the
|
||||
rewritten tips; no new FAIL lines.
|
||||
|
||||
- [x] **#37 Platform: back button, no Quit, flat labels, camera.** *(merged c47e678 —
|
||||
`Main.go_back()` (phones only) also closes the workbench/shed panel, the pouch, and build mode
|
||||
before pausing; `_back_in_pause()` shared with Esc; `ScreenLabels.ensure(host)` (one per game,
|
||||
group `&"screen_labels"`) and `watch(root)`; labels are sized × `content_scale_factor`;
|
||||
`FollowCamera.PHONE_DISTANCE` 12 — #41's camera setting should default to it)*
|
||||
Android back = pause / close the top menu / quit from the main menu; no Quit buttons on phones;
|
||||
`ScreenLabels` on phones without `ToonLook`; camera 12 m on phones.
|
||||
*Acceptance:* back-request sequence, Quit hidden only on phones, labels and camera checked; no
|
||||
new FAIL lines.
|
||||
|
||||
- [x] **#46 Sprint becomes a speed upgrade (all platforms).** The user's call (2026-10-14).
|
||||
*(merged 962c7b0 — `PlayerCharacter.speed_factor()` is `sprint_speed_mult` while
|
||||
`has_sprint()` (was `can_sprint()`); run 5.0 → 6.25 m/s with it; `sprint_time`/`sprint_cooldown`
|
||||
and the stamina bar gone; left over: README.md:129/149, game/RULES.md:315/395, and the `sprint`
|
||||
action in project.godot + `configure_input.gd`, which re-adds it)*
|
||||
Owning Sprint multiplies base speed by `sprint_speed_mult` (1.25, tunable) all the time; the
|
||||
hold-to-sprint burst, its time limit and cooldown, and the stamina bar go. Upgrade id `"sprint"`
|
||||
and costs unchanged; text "Run 25% faster, always".
|
||||
*Acceptance:* sprint checks in test_scarecrow, test_economy, and test_nights rewritten (speed
|
||||
×1 without, ×1.25 with, no limit, survives save and retry); no other new FAIL lines.
|
||||
|
||||
## Wave 2 (parallel, after wave 1)
|
||||
|
||||
- [x] **#38 Touch action buttons.** Blocked by #35. Blocks #40. *(merged e435b76 — `TouchButtons`
|
||||
(inner `Pad`: round STOP pads, press via `Input.action_press`, release held ≥ 1 physics tick;
|
||||
process ALWAYS, hidden and released while paused, under a menu/shop/pouch/sign/end panel);
|
||||
Pause → `pause_requested` (Main.pause); Fear always while playing, Bomb once the off-hand is
|
||||
bombs, Patch when hurt with straw, Use from `Interactions.focus_info()` (not `focus()`: name
|
||||
clash; dimmed when refused), Build by day ("Done" in build mode); layout keeps out of
|
||||
`TouchButtons.reserved()` (built from other widgets' constants: update with #43);
|
||||
`TouchSticks.move_on_right` + `apply_settings`, `TouchSticks.move_on_right_now()` behind
|
||||
`Prompts.move_side()`; a stick finger's drags/lifts read in `_input`; Main calls
|
||||
`apply_settings` after adding both; for #40: TouchSticks still fires in build mode, add the
|
||||
build set's ids to `ALL`/`ACTIONS`/`ICONS`; for #43: `ScarecrowHud._draw_health()` logs
|
||||
"triangulation failed" as a patch starts (heal_frac ≈ 0; skip the sliver under ~2 px))*
|
||||
`TouchButtons`: Pause, Fear, Bomb, Patch, Use (contextual word from a new `Interactions.focus()`),
|
||||
Build; `move_on_right` variable; `&"touch_controls"` group (no sprint control: see #46).
|
||||
*Acceptance:* each button driven by touch does what its key does; buttons take their touches,
|
||||
hidden ones don't block; screenshot; no new FAIL lines.
|
||||
|
||||
- [x] **#39 Tappable HUD.** Blocked by #35. Blocks #43. *(merged 49e9487 — `ScarecrowHud.HitTarget`
|
||||
(STOP, `cover(r)` grows to `minimum_target()`, `tapped`; ignores the emulated click) used by the
|
||||
hotbar slots (`slot_rects()`, `tap_slot(i)` → the `weapon_k` path), the backpack
|
||||
(`ResourceHud.icon_rect()`/`panel_rect()`, clamped into the safe rect; a finger elsewhere
|
||||
closes the pouch and goes on to the sticks), the tip box's × (`Tutorial.hide_tips()`), and
|
||||
Skip on pausing conversations (`DialogueBox.skip_rect()`); `Prompts.hotbar_key(n)` drops the
|
||||
slot numbers on phones; for #43: backpack, hotbar bottom and the dialogue paper still cross
|
||||
the safe rect; the tip box overlaps the open pouch)*
|
||||
Tap hotbar slots to switch weapons, the backpack for the pouch (panel fits the scaled canvas),
|
||||
× on the tip box, a Skip button on pausing conversations.
|
||||
*Acceptance:* each tap works and touches beside each widget still start a stick; no new FAIL
|
||||
lines.
|
||||
|
||||
- [x] **#41 Menus and settings at phone scale.** Blocked by #35, #37. *(merged 0c40117 — each menu
|
||||
has `fit()` (on open and on the root's `size_changed`); `UiTheme.touch_height/
|
||||
inset_to_safe_area/overlay_rect`; pause menu goes two-column on phones and tablets; phone
|
||||
settings: Audio, Touch (Interface size, Swap, Camera distance, Haptics, then the
|
||||
`SettingsMenu.touch_guide()`), Display (3D resolution only), Gameplay (tips) — dead zones and
|
||||
pixel size also hidden; `TouchSlider` grabs only after a sideways move, the list drag-scrolls
|
||||
(device check pending); `[touch]` keys `interface_size`, `swap_sticks`, `camera_distance`,
|
||||
`haptics`; `GameSettings.apply_touch(tree)` calls `&"touch_controls"`, sets the
|
||||
`FollowCamera.GROUP` distance on phones, and `Scarecrow.haptics` → `Scarecrow.buzz()` (30 ms)
|
||||
on an accepted local hit)*
|
||||
Main menu, pause, confirm, and settings fitted to the scaled canvas and safe rect; phone settings
|
||||
(Interface size, Swap sticks, Camera distance, Haptics, touch guide; no Fullscreen/VSync/
|
||||
bindings); haptic buzz on a hit.
|
||||
*Acceptance:* every menu inside the safe rect at 19.5:9 and 4:3 with targets ≥ 44 pt; settings
|
||||
round trip; swap moves the sticks; desktop settings unchanged; no new FAIL lines.
|
||||
|
||||
- [x] **#42 Panels at phone scale.** Blocked by #35. *(merged e8729b4 — `UiTheme.panel_room()`
|
||||
(safe rect − 8), `fit_margins()` (a MarginContainer between each panel and its full-screen
|
||||
container), `UiTheme.TouchScroll` (a 10 pt drag scrolls and cancels the press under the finger,
|
||||
so nothing is bought; a tap buys; Godot's own touch drag off; no fling — device check pending);
|
||||
the sign scrolls (two columns can't fit an SE: the results table is 724 px wide) with Start the
|
||||
day always below; end panel wraps to 1180 and scrolls; shop rows are a scroll list, wrap to
|
||||
1150, Close below; UpgradePanel's tree is now Safe/Panel/Margin/Box (setup adds rows to List);
|
||||
follow-ups: Interface size above ~110% on notch phones (130% on an SE) overflows the sign's
|
||||
width; #41's settings list has its own drag-scroll, a second implementation)*
|
||||
Morning sign (scroll or two columns, Start the day visible), end panel (wrap), workbench and shed
|
||||
(scroll list, Close visible).
|
||||
*Acceptance:* each panel inside the safe rect at both aspects with targets ≥ 44 pt; desktop
|
||||
layout unchanged; no new FAIL lines.
|
||||
|
||||
## Wave 3 (parallel, after wave 2)
|
||||
|
||||
- [ ] **#40 Build mode by touch.** Blocked by #36, #38.
|
||||
No fire from the attack stick in build mode; a finger on the attack half places the ghost;
|
||||
Place, Rotate ⟲ ⟳, Dismantle, Done; tappable build-bar slots; `BuildMode.confirm()`,
|
||||
`dismantle()`, `cursor_screen`.
|
||||
*Acceptance:* enter, pick, place, rotate, pay, dismantle, refund, leave, all by touch; night
|
||||
refusal; `test_structures` has no new FAIL lines.
|
||||
|
||||
- [ ] **#43 HUD and cutscenes at phone scale.** Blocked by #39.
|
||||
Every HUD widget inside the safe rect (hotbar above the home indicator), dialogue box and tips
|
||||
fit about 640 px, letterbox hints, loading screen, alert arrows avoid the real widget rects.
|
||||
*Acceptance:* every widget inside the safe rect at both aspects, none overlapping; desktop
|
||||
unchanged; screenshots; no new FAIL lines.
|
||||
|
||||
## Independent
|
||||
|
||||
- [ ] **#44 Android build.** Best once iOS plays well.
|
||||
Android preset (Gradle, arm64, current target SDK, adaptive icon, `perf_test` on the test
|
||||
build) and an `android-perf-test` Codemagic workflow. Needs the user's Play account and
|
||||
keystore.
|
||||
*Acceptance:* the build installs on an Android phone; back, sticks, buttons, and safe area work.
|
||||
|
||||
## Last
|
||||
|
||||
- [ ] **#45 Device playtest and docs (with the user).** Blocked by #35–#43, #46.
|
||||
A whole vacation by touch on iPhone (and iPad); README, LAYOUT, PLAYTEST, and the iOS doc
|
||||
updated; notes to `docs/followups.md`.
|
||||
*Acceptance:* the user signs off that a vacation plays by touch alone.
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ upgrades = {
|
|||
},
|
||||
"sprint": {
|
||||
"name": "Sprint",
|
||||
"text": "Run 25% faster, always",
|
||||
"text": "Sprint 80% faster for 4 s at a time, every 10 s",
|
||||
"track": "Scarecrow"
|
||||
},
|
||||
"sticky_tar": {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func _process(_delta: float) -> void:
|
|||
|
||||
## The controls line, as shown.
|
||||
func help_text() -> String:
|
||||
return Prompts.build_help()
|
||||
return "LMB / RT build · Z C / d-pad rotate · 1-4 / Tab pick · RMB / B dismantle or leave"
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
|
|
@ -64,7 +64,7 @@ func _draw() -> void:
|
|||
Sketch.box(self, rect, Sketch.SLOT, Sketch.INK, 2.5, 810.0 + i * 3.0)
|
||||
if picked:
|
||||
Sketch.box(self, rect.grow(2.0), Color(0, 0, 0, 0), Sketch.GOLD, 3.5, 830.0 + i)
|
||||
Sketch.text(self, rect.position + Vector2(12.0, 4.0), Prompts.build_slot(i + 1, StructureSystem.NAMES[t]), 28, Sketch.TEXT,
|
||||
Sketch.text(self, rect.position + Vector2(12.0, 4.0), "%d %s" % [i + 1, StructureSystem.NAMES[t]], 28, Sketch.TEXT,
|
||||
HORIZONTAL_ALIGNMENT_LEFT, 6)
|
||||
Sketch.text(self, rect.position + Vector2(12.0, 42.0), ResourceStore.describe(cost), 22,
|
||||
Sketch.TEXT if r.can_afford(cost, slot) else SHORT, HORIZONTAL_ALIGNMENT_LEFT, 6)
|
||||
|
|
|
|||
|
|
@ -184,13 +184,11 @@ func _process(_delta: float) -> void:
|
|||
for m in cost:
|
||||
if floori(int(cost[m]) * config.dismantle_refund) > 0:
|
||||
refund[m] = floori(int(cost[m]) * config.dismantle_refund)
|
||||
_label.text = "%s %d/%d\n%s%s" % [StructureSystem.NAMES.get(e.get("type", ""), ""), int(e.get("hp", 0)),
|
||||
structures.max_hp(e.get("type", "fence")), Prompts.dismantle(),
|
||||
(" (+%s)" % ResourceStore.describe(refund)) if not refund.is_empty() else ""]
|
||||
_label.text = "%s %d/%d\n[RMB / B] Dismantle%s" % [StructureSystem.NAMES.get(e.get("type", ""), ""), int(e.get("hp", 0)),
|
||||
structures.max_hp(e.get("type", "fence")), (" (+%s)" % ResourceStore.describe(refund)) if not refund.is_empty() else ""]
|
||||
_label.modulate = Color(0.85, 0.95, 1.0)
|
||||
elif ok:
|
||||
_label.text = "%s %s\n%s" % [StructureSystem.NAMES[type()], ResourceStore.describe(config.costs.get(type(), {})),
|
||||
Prompts.build_place()]
|
||||
_label.text = "%s %s\n[LMB / RT] Build" % [StructureSystem.NAMES[type()], ResourceStore.describe(config.costs.get(type(), {}))]
|
||||
_label.modulate = Color(0.7, 1.0, 0.7)
|
||||
else:
|
||||
_label.text = "%s\n%s" % [StructureSystem.NAMES[type()], reason]
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ class_name ConfirmBox
|
|||
extends CenterContainer
|
||||
## A yes / no question over the menus (Main): the message, the confirming button, and Cancel
|
||||
## (focused, so a stray Enter / A never throws progress away). Escape / B cancels. Hand-drawn like
|
||||
## the pause menu it mostly opens from (UiTheme.sketch). On a phone it sits in the middle of the
|
||||
## safe area with touch-sized buttons (fit).
|
||||
|
||||
const BUTTON_HEIGHT := 54.0
|
||||
## the pause menu it mostly opens from (UiTheme.sketch).
|
||||
|
||||
var message: Label
|
||||
var yes_button: Button
|
||||
|
|
@ -13,7 +10,6 @@ var no_button: Button
|
|||
var is_open := false
|
||||
|
||||
var _on_yes: Callable
|
||||
var _phone := false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -40,33 +36,18 @@ func _ready() -> void:
|
|||
row.add_theme_constant_override("separation", 24)
|
||||
box.add_child(row)
|
||||
yes_button = Button.new()
|
||||
yes_button.custom_minimum_size = Vector2(240.0, BUTTON_HEIGHT)
|
||||
yes_button.custom_minimum_size = Vector2(240.0, 54.0)
|
||||
yes_button.add_theme_font_size_override("font_size", 30)
|
||||
yes_button.pressed.connect(_yes)
|
||||
row.add_child(yes_button)
|
||||
no_button = Button.new()
|
||||
no_button.text = "Cancel"
|
||||
no_button.custom_minimum_size = Vector2(200.0, BUTTON_HEIGHT)
|
||||
no_button.custom_minimum_size = Vector2(200.0, 54.0)
|
||||
no_button.add_theme_font_size_override("font_size", 30)
|
||||
no_button.pressed.connect(close)
|
||||
row.add_child(no_button)
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_phone = MobilePort.active()
|
||||
if _phone:
|
||||
get_viewport().size_changed.connect(fit)
|
||||
fit()
|
||||
|
||||
|
||||
## A phone: inside the safe area, the buttons at least the minimum touch target tall. (Nothing on
|
||||
## desktop.)
|
||||
func fit() -> void:
|
||||
if not _phone or not is_inside_tree():
|
||||
return
|
||||
UiTheme.inset_to_safe_area(self)
|
||||
for b: Button in [yes_button, no_button]:
|
||||
b.custom_minimum_size.y = UiTheme.touch_height(self, BUTTON_HEIGHT)
|
||||
queue_redraw() # the dim covers the screen from wherever the inset put this
|
||||
|
||||
|
||||
func ask(text: String, confirm_text: String, on_yes: Callable) -> void:
|
||||
|
|
@ -76,7 +57,6 @@ func ask(text: String, confirm_text: String, on_yes: Callable) -> void:
|
|||
is_open = true
|
||||
visible = true
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
fit()
|
||||
no_button.grab_focus.call_deferred()
|
||||
|
||||
|
||||
|
|
@ -89,11 +69,7 @@ func close() -> void:
|
|||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(UiTheme.overlay_rect(self), Color(0.0, 0.0, 0.0, 0.45)) # dims what's behind
|
||||
|
||||
|
||||
func _has_point(point: Vector2) -> bool:
|
||||
return UiTheme.overlay_rect(self).has_point(point) # all of the screen, also outside the safe area
|
||||
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.45)) # dims what's behind
|
||||
|
||||
|
||||
func _yes() -> void:
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ extends Control
|
|||
## [Backspace / Back] skips the rest of the conversation. One that doesn't pause the game takes no
|
||||
## input and goes on by itself (Conversation.line_hold). Works while the game is paused
|
||||
## (DialogueDirector pauses it for a conversation); waits while blocked (a menu is up over it).
|
||||
## On a phone (MobilePort.active()) a tap is the click, and a conversation that pauses the game
|
||||
## has a Skip button on the paper (a ScarecrowHud.HitTarget) that skips it, as Backspace does.
|
||||
|
||||
signal finished(conversation: Conversation)
|
||||
|
||||
|
|
@ -33,19 +31,12 @@ const OPEN_TIME := 0.18
|
|||
const PAUSES := {".": 0.32, "!": 0.32, "?": 0.32, "…": 0.32, ",": 0.14, ";": 0.14, ":": 0.14}
|
||||
const TALK_FPS := 9.0
|
||||
const SEED := 701.0
|
||||
## Phones: the Skip button drawn on the paper (its hit target may be bigger), its right edge and
|
||||
## bottom this far in from the paper's bottom-right corner (left of the pen arrow).
|
||||
const SKIP_SIZE := Vector2(118.0, 50.0)
|
||||
const SKIP_INSET := Vector2(104.0, 26.0)
|
||||
const SKIP_FONT := 30
|
||||
|
||||
## Optional: whether a menu is up over the box (it waits: no input, no writing).
|
||||
var blocked: Callable
|
||||
## The conversation up (null when none), and its line on the paper.
|
||||
var conversation: Conversation
|
||||
var index: int = -1
|
||||
## Phones: the Skip button (null on desktop), shown while a conversation pauses the game.
|
||||
var skip_target: ScarecrowHud.HitTarget
|
||||
|
||||
static var _narrator := DialogueSpeaker.new()
|
||||
static var _variants := {} # "font id/slant/bold" -> FontVariation
|
||||
|
|
@ -108,13 +99,6 @@ func _ready() -> void:
|
|||
_more.size = Vector2(40.0, 40.0)
|
||||
_more.draw.connect(_draw_more)
|
||||
_sheet.add_child(_more)
|
||||
if MobilePort.active():
|
||||
skip_target = ScarecrowHud.HitTarget.new()
|
||||
skip_target.name = "Skip"
|
||||
skip_target.visible = false
|
||||
skip_target.tapped.connect(_on_skip_tapped)
|
||||
skip_target.draw.connect(_draw_skip)
|
||||
_sheet.add_child(skip_target)
|
||||
_voice = AudioStreamPlayer.new()
|
||||
_voice.bus = &"SFX"
|
||||
add_child(_voice)
|
||||
|
|
@ -384,25 +368,10 @@ func _place() -> void:
|
|||
_text.size = Vector2(inner, r.size.y - top - 36.0)
|
||||
_more.position = Vector2(r.size.x - 50.0 - _more.size.x, r.size.y - 30.0 - _more.size.y)
|
||||
_more.visible = conversation != null and conversation.pause_game and is_written()
|
||||
if skip_target != null:
|
||||
skip_target.visible = conversation != null and conversation.pause_game
|
||||
skip_target.cover(skip_rect())
|
||||
skip_target.queue_redraw()
|
||||
_stage.queue_redraw()
|
||||
_more.queue_redraw()
|
||||
|
||||
|
||||
## Phones: where the Skip button is drawn on the paper (the sheet's coordinates).
|
||||
func skip_rect() -> Rect2:
|
||||
var r := _sheet_rect()
|
||||
return Rect2(r.size - SKIP_INSET - SKIP_SIZE, SKIP_SIZE)
|
||||
|
||||
|
||||
func _on_skip_tapped() -> void:
|
||||
if conversation != null and conversation.pause_game and not is_blocked():
|
||||
skip()
|
||||
|
||||
|
||||
func _sheet_rect() -> Rect2:
|
||||
var w := minf(WIDTH, size.x - 2.0 * SIDE_GAP)
|
||||
return Rect2((size.x - w) * 0.5, size.y - BOTTOM - HEIGHT, w, HEIGHT)
|
||||
|
|
@ -481,25 +450,6 @@ func _frame(h: Head) -> Texture2D:
|
|||
return h.face if k == 0 else sp.talk_frames[k - 1]
|
||||
|
||||
|
||||
## Phones: the Skip button, a pen-drawn box on the paper with the word and a double arrow.
|
||||
func _draw_skip() -> void:
|
||||
var ink := Sketch.PAPER_INK
|
||||
var r := Rect2((skip_target.size - SKIP_SIZE) * 0.5, SKIP_SIZE)
|
||||
Sketch.box(skip_target, r, Color(Sketch.PAPER.darkened(0.1), 0.9), Color(ink, 0.85), 2.0, SEED + 21.0)
|
||||
var word := Sketch.text_width("Skip", SKIP_FONT)
|
||||
var arrows := 26.0
|
||||
var x := r.get_center().x - (word + 8.0 + arrows) * 0.5
|
||||
var f := Sketch.font()
|
||||
var top := r.get_center().y - (f.get_ascent(SKIP_FONT) + f.get_descent(SKIP_FONT)) * 0.5
|
||||
Sketch.text(skip_target, Vector2(x, top), "Skip", SKIP_FONT, ink, HORIZONTAL_ALIGNMENT_LEFT, 0)
|
||||
var c := Vector2(x + word + 8.0, r.get_center().y)
|
||||
for k in 2:
|
||||
var a := c + Vector2(k * 12.0, 0.0)
|
||||
var tip := PackedVector2Array([a + Vector2(0.0, -9.0), a + Vector2(13.0, 0.0), a + Vector2(0.0, 9.0)])
|
||||
skip_target.draw_colored_polygon(tip, Color(ink, 0.85))
|
||||
Sketch.outline(skip_target, tip, ink, 1.5, SEED + 30.0 + k, 0.6, 1)
|
||||
|
||||
|
||||
## The pen arrow in the corner when the line is written and the player goes on.
|
||||
func _draw_more() -> void:
|
||||
var ink: Color = _text.get_theme_color("default_color")
|
||||
|
|
|
|||
|
|
@ -10,19 +10,12 @@ extends CenterContainer
|
|||
## * The final assessment, once the farmers' return (FarmersReturn) has played or been
|
||||
## skipped: the rating and score (Assessment), the share kept per category with a bar, and
|
||||
## the vacation's totals, with Main menu (or New vacation).
|
||||
## On a phone (UiTheme's panels) it sits in the safe area: the text wraps to the room's width
|
||||
## (up to PHONE_WIDTH), scrolls (drag it) if it's still too tall, and the buttons stay below it,
|
||||
## in view and at least the touch target tall.
|
||||
|
||||
signal menu_requested
|
||||
|
||||
const DELAY := 1.4
|
||||
const GOLD := Color(0.95, 0.82, 0.45)
|
||||
const GREY := Color(0.75, 0.77, 0.72)
|
||||
const MARGIN := 34
|
||||
const BUTTON := Vector2(230.0, 56.0)
|
||||
## The text's widest on a phone (an iPad's room is wider): about the totals' longest line.
|
||||
const PHONE_WIDTH := 1180.0
|
||||
|
||||
var campaign: CampaignController
|
||||
## Set by Main: the Main menu button shows instead of New vacation.
|
||||
|
|
@ -44,11 +37,6 @@ var _menu: Button
|
|||
var _new: Button
|
||||
var _wait: float = -1.0
|
||||
var _pending_mode := ""
|
||||
var _safe: MarginContainer
|
||||
var _panel: PanelContainer
|
||||
var _scroll: UiTheme.TouchScroll
|
||||
var _box: VBoxContainer
|
||||
var _fit_queued := false
|
||||
|
||||
|
||||
func setup(p_campaign: CampaignController) -> void:
|
||||
|
|
@ -61,25 +49,16 @@ func setup(p_campaign: CampaignController) -> void:
|
|||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
_safe = MarginContainer.new() # the safe area's margins on a phone (none on desktop)
|
||||
add_child(_safe)
|
||||
_panel = PanelContainer.new()
|
||||
_panel.add_theme_stylebox_override("panel", ReviewPanel.backing())
|
||||
_safe.add_child(_panel)
|
||||
var panel := PanelContainer.new()
|
||||
panel.add_theme_stylebox_override("panel", ReviewPanel.backing())
|
||||
add_child(panel)
|
||||
var margin := MarginContainer.new()
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
margin.add_theme_constant_override("margin_" + side, MARGIN)
|
||||
_panel.add_child(margin)
|
||||
var page := VBoxContainer.new() # the text (scrolling on a phone), then the buttons
|
||||
page.add_theme_constant_override("separation", 16)
|
||||
margin.add_child(page)
|
||||
_scroll = UiTheme.TouchScroll.new(UiTheme.TEXT)
|
||||
page.add_child(_scroll)
|
||||
margin.add_theme_constant_override("margin_" + side, 34)
|
||||
panel.add_child(margin)
|
||||
var box := VBoxContainer.new()
|
||||
box.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
box.add_theme_constant_override("separation", 16)
|
||||
_scroll.add_child(box)
|
||||
_box = box
|
||||
margin.add_child(box)
|
||||
_title = _label(box, 46)
|
||||
_rating = _label(box, 30, GOLD)
|
||||
_detail = _label(box, 22)
|
||||
|
|
@ -113,7 +92,7 @@ func _ready() -> void:
|
|||
var buttons := HBoxContainer.new()
|
||||
buttons.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
buttons.add_theme_constant_override("separation", 24)
|
||||
page.add_child(buttons)
|
||||
box.add_child(buttons)
|
||||
_retry = _button(buttons, "Retry the night")
|
||||
_retry.pressed.connect(func() -> void: campaign.retry_night())
|
||||
_menu = _button(buttons, "Main menu")
|
||||
|
|
@ -121,8 +100,6 @@ func _ready() -> void:
|
|||
_new = _button(buttons, "New vacation")
|
||||
_new.pressed.connect(func() -> void: campaign.new_campaign())
|
||||
hide_panel()
|
||||
box.minimum_size_changed.connect(_queue_fit) # the text reflowed
|
||||
get_viewport().size_changed.connect(_queue_fit)
|
||||
|
||||
|
||||
func hide_panel() -> void:
|
||||
|
|
@ -253,46 +230,9 @@ func _show_buttons() -> void:
|
|||
func _open(focus: Button) -> void:
|
||||
visible = true
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
_fit()
|
||||
_scroll.scroll_vertical = 0
|
||||
focus.grab_focus()
|
||||
|
||||
|
||||
## Lays the screen out: on desktop as it always was; on a phone (UiTheme's panels) inside the
|
||||
## safe area, the text wrapped to the room's width and scrolling past what its height leaves.
|
||||
func _fit() -> void:
|
||||
var phone := MobilePort.active()
|
||||
_scroll.set_phone(phone)
|
||||
for l: Label in [_title, _rating, _detail, _stats]:
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART if phone else TextServer.AUTOWRAP_OFF
|
||||
for b: Button in [_retry, _menu, _new]:
|
||||
b.custom_minimum_size = Vector2(BUTTON.x, maxf(BUTTON.y, MobilePort.minimum_target(self))) if phone else BUTTON
|
||||
if not phone:
|
||||
UiTheme.fit_margins(_safe, Rect2())
|
||||
_box.custom_minimum_size.x = 0.0
|
||||
return
|
||||
var room := UiTheme.panel_room(self)
|
||||
UiTheme.fit_margins(_safe, room)
|
||||
var frame := 2.0 * MARGIN + _panel.get_theme_stylebox("panel").get_minimum_size().x + _scroll.frame_width()
|
||||
_box.custom_minimum_size.x = floorf(minf(PHONE_WIDTH, room.size.x - frame))
|
||||
var others := _panel.get_combined_minimum_size().y - _scroll.get_combined_minimum_size().y
|
||||
_scroll.fit(room.size.y - others)
|
||||
|
||||
|
||||
## Fits again once this frame's changes are in (the text reflowed, the screen changed size).
|
||||
func _queue_fit() -> void:
|
||||
if _fit_queued or not visible:
|
||||
return
|
||||
_fit_queued = true
|
||||
_refit.call_deferred()
|
||||
|
||||
|
||||
func _refit() -> void:
|
||||
_fit_queued = false
|
||||
if visible:
|
||||
_fit()
|
||||
|
||||
|
||||
func _label(parent: Node, font_size: int, color: Color = Color(0.92, 0.92, 0.88)) -> Label:
|
||||
var l := Label.new()
|
||||
l.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
|
|
@ -305,7 +245,7 @@ func _label(parent: Node, font_size: int, color: Color = Color(0.92, 0.92, 0.88)
|
|||
func _button(parent: Control, text: String) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.custom_minimum_size = BUTTON
|
||||
b.custom_minimum_size = Vector2(230.0, 56.0)
|
||||
b.add_theme_font_size_override("font_size", 24)
|
||||
parent.add_child(b)
|
||||
return b
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ func _ready() -> void:
|
|||
var t0 := Time.get_ticks_msec()
|
||||
config = campaign.config
|
||||
campaign.set_physics_process(false) # ticked from step(), after the simulation
|
||||
player.config = config # Sprint's speed boost
|
||||
player.config = config # the sprint
|
||||
player.campaign = campaign
|
||||
var shed_zone := zones.zone(FarmZone.Kind.SUPPLY_SHED)
|
||||
var pen_zone := zones.zone(FarmZone.Kind.ANIMAL_PEN)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ func start() -> void:
|
|||
CutsceneKit.follow_camera(_camera, _car, 1.0)
|
||||
if sim.audio != null:
|
||||
sim.audio.focus = _car
|
||||
_overlay = CutsceneKit.make_letterbox(self, "The farmers are on their way home", Prompts.return_skip())
|
||||
_overlay = CutsceneKit.make_letterbox(self, "The farmers are on their way home", "[Space / Enter / A] skip")
|
||||
_caption = _overlay.caption
|
||||
_set_hud(false)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,7 @@ class_name FollowCamera
|
|||
extends Camera3D
|
||||
## Angled top-down camera that trails a target. The framing comes entirely from pitch / yaw /
|
||||
## distance (the transform is overwritten every frame, also in the editor so the framing can be
|
||||
## previewed). PlayerCharacter moves relative to this camera's yaw. Mouse wheel zooms. On a phone
|
||||
## (MobilePort) it starts closer, at PHONE_DISTANCE, and then sits at the Camera distance setting
|
||||
## (GameSettings.apply_touch finds it through GROUP).
|
||||
|
||||
## The phones' distance (the small screen), in place of distance's default when the game starts.
|
||||
const PHONE_DISTANCE := 12.0
|
||||
## Every follow camera is in this group, for the settings.
|
||||
const GROUP := &"follow_camera"
|
||||
## previewed). PlayerCharacter moves relative to this camera's yaw. Mouse wheel zooms.
|
||||
|
||||
@export var target: Node3D
|
||||
@export_range(5.0, 89.0) var pitch_deg := 50.0
|
||||
|
|
@ -29,9 +22,6 @@ var _focus := Vector3.ZERO
|
|||
|
||||
func _ready() -> void:
|
||||
physics_interpolation_mode = Node.PHYSICS_INTERPOLATION_MODE_OFF
|
||||
add_to_group(GROUP)
|
||||
if not Engine.is_editor_hint() and MobilePort.active():
|
||||
distance = PHONE_DISTANCE
|
||||
snap_to_target()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,11 +45,12 @@ extends Resource
|
|||
## Patch up: hold for patch_time (rooted, no shooting) to restore patch_heal HP.
|
||||
@export var patch_time: float = 2.0
|
||||
@export_range(1, 100) var patch_heal: int = 3
|
||||
## Sprint (the workbench's Sprint upgrade): once it's bought, the scarecrow moves
|
||||
## sprint_speed_mult times as fast for good, walking and running alike (PlayerCharacter). No
|
||||
## button, time limit, or cooldown. Its "text" in upgrades below names the boost: keep the two
|
||||
## in step.
|
||||
@export var sprint_speed_mult: float = 1.25
|
||||
## Sprint (the workbench's Sprint upgrade): hold sprint while moving to run sprint_speed_mult
|
||||
## times as fast for up to sprint_time seconds; once it ends, sprint_cooldown seconds until the
|
||||
## next one.
|
||||
@export var sprint_speed_mult: float = 1.8
|
||||
@export var sprint_time: float = 4.0
|
||||
@export var sprint_cooldown: float = 10.0
|
||||
|
||||
@export_group("Farm assets")
|
||||
## Crop units and animals on the farm when the vacation starts; they must match the farm scene
|
||||
|
|
@ -147,8 +148,8 @@ extends Resource
|
|||
## "name", "track" (the menu's heading), "text": what it does.
|
||||
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
|
||||
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
|
||||
## does something else instead (sprint: PlayerCharacter's speed, by sprint_speed_mult; the
|
||||
## weapons: ScarecrowCombat; radar: RadarHud).
|
||||
## unlocks something instead (sprint: PlayerCharacter; the weapons: ScarecrowCombat; radar:
|
||||
## RadarHud).
|
||||
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
|
||||
## with one entry per level. Each owned level's entry applies in turn, so they stack.
|
||||
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
|
||||
|
|
@ -179,7 +180,7 @@ extends Resource
|
|||
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
|
||||
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
|
||||
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
|
||||
"sprint": {"name": "Sprint", "text": "Run 25% faster, always", "track": "Scarecrow"},
|
||||
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
|
||||
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
|
||||
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
|
||||
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ extends RefCounted
|
|||
## resolution scale, used when the pixel size is 1 (the HUD stays sharp either way).
|
||||
## * Gameplay: whether the tips show on the first day and night (Tutorial).
|
||||
## * Co-op: your player name, and whether your microphone is sent in voice chat.
|
||||
## * Touch (phones): the interface size, times the scale the screen's size calls for
|
||||
## (MobilePort.ui_scale; it doesn't change desktop), the sticks swapped, the camera's
|
||||
## distance, and a buzz when the scarecrow is hit. Saved on every platform; only phones
|
||||
## apply them (and show them: SettingsMenu).
|
||||
## Values missing from the file or out of range fall back to the defaults, so an old or
|
||||
## hand-edited file never breaks the game.
|
||||
|
||||
|
|
@ -24,11 +20,6 @@ const BUS_NAMES := {"Master": "Master volume", "Music": "Music and stingers", "S
|
|||
"Voice": "Voice chat (your friend)"}
|
||||
const DEFAULT_VOLUME := {"Master": 0.8, "Music": 0.7, "SFX": 0.8, "Ambience": 0.6, "Voice": 1.0}
|
||||
const MAX_PIXEL_SIZE := 8
|
||||
## Phones: the Interface size's range (MobilePort.ui_scale clamps to the same) and the camera's.
|
||||
const INTERFACE_SIZE_MIN := 0.8
|
||||
const INTERFACE_SIZE_MAX := 1.3
|
||||
const CAMERA_DISTANCE_MIN := 8.0
|
||||
const CAMERA_DISTANCE_MAX := 20.0
|
||||
|
||||
var volume := DEFAULT_VOLUME.duplicate()
|
||||
var move_dead_zone := 0.2
|
||||
|
|
@ -42,14 +33,6 @@ var show_tips := true
|
|||
## Co-op: your name for the lobby and the name tag, and whether your microphone is sent.
|
||||
var player_name := ""
|
||||
var microphone := true
|
||||
## Phones: the Interface size, 0.8-1.3 times the scale the screen calls for (MobilePort.ui_scale).
|
||||
var interface_size := 1.0
|
||||
## Phones: the sticks swapped (TouchSticks, TouchButtons: the move stick on the other half), the
|
||||
## follow camera's distance (8-20 m, in place of FollowCamera.PHONE_DISTANCE), and a short buzz
|
||||
## when the scarecrow is hit (Scarecrow.haptics).
|
||||
var swap_sticks := false
|
||||
var camera_distance := FollowCamera.PHONE_DISTANCE
|
||||
var haptics := true
|
||||
|
||||
|
||||
static func load_from(path: String = PATH) -> GameSettings:
|
||||
|
|
@ -69,12 +52,6 @@ static func load_from(path: String = PATH) -> GameSettings:
|
|||
var n: Variant = f.get_value("coop", "player_name", "")
|
||||
g.player_name = String(n).strip_edges().left(20) if n is String else ""
|
||||
g.microphone = _flag(f.get_value("coop", "microphone", g.microphone), g.microphone)
|
||||
g.interface_size = _number(f.get_value("touch", "interface_size", g.interface_size), INTERFACE_SIZE_MIN,
|
||||
INTERFACE_SIZE_MAX, g.interface_size)
|
||||
g.swap_sticks = _flag(f.get_value("touch", "swap_sticks", g.swap_sticks), g.swap_sticks)
|
||||
g.camera_distance = _number(f.get_value("touch", "camera_distance", g.camera_distance), CAMERA_DISTANCE_MIN,
|
||||
CAMERA_DISTANCE_MAX, g.camera_distance)
|
||||
g.haptics = _flag(f.get_value("touch", "haptics", g.haptics), g.haptics)
|
||||
return g
|
||||
|
||||
|
||||
|
|
@ -91,16 +68,11 @@ func save_to(path: String = PATH) -> Error:
|
|||
f.set_value("gameplay", "show_tips", show_tips)
|
||||
f.set_value("coop", "player_name", player_name)
|
||||
f.set_value("coop", "microphone", microphone)
|
||||
f.set_value("touch", "interface_size", interface_size)
|
||||
f.set_value("touch", "swap_sticks", swap_sticks)
|
||||
f.set_value("touch", "camera_distance", camera_distance)
|
||||
f.set_value("touch", "haptics", haptics)
|
||||
return f.save(path)
|
||||
|
||||
|
||||
## Applies everything: bus volumes, dead zones (into config too, when given), the interface
|
||||
## scale, the touch settings (apply_touch), and the display (skipped without a real display, e.g.
|
||||
## headless).
|
||||
## Applies everything: bus volumes, dead zones (into config too, when given), and the display
|
||||
## (skipped without a real display, e.g. headless).
|
||||
func apply(viewport: Viewport, config: GameConfig = null) -> void:
|
||||
for bus in BUSES:
|
||||
var i := AudioServer.get_bus_index(bus)
|
||||
|
|
@ -116,8 +88,6 @@ func apply(viewport: Viewport, config: GameConfig = null) -> void:
|
|||
config.aim_dead_zone = aim_dead_zone
|
||||
if viewport != null:
|
||||
apply_pixels(viewport)
|
||||
apply_scale(viewport)
|
||||
apply_touch(viewport.get_tree() if viewport != null else Engine.get_main_loop() as SceneTree)
|
||||
if DisplayServer.get_name() == "headless":
|
||||
return
|
||||
var mode := DisplayServer.window_get_mode()
|
||||
|
|
@ -142,31 +112,6 @@ func apply_pixels(viewport: Viewport) -> void:
|
|||
viewport.msaa_3d = ProjectSettings.get_setting("rendering/anti_aliasing/quality/msaa_3d", Viewport.MSAA_DISABLED)
|
||||
|
||||
|
||||
## The interface scale (MobilePort.ui_scale: on a phone, the screen's size times
|
||||
## interface_size; always 1 on desktop) as the window's content_scale_factor, which scales every
|
||||
## CanvasLayer (the HUD, the menus, the sticks) and leaves the 3D view alone.
|
||||
func apply_scale(viewport: Viewport) -> void:
|
||||
var window := viewport.get_window()
|
||||
if window != null:
|
||||
window.content_scale_factor = MobilePort.ui_scale(interface_size)
|
||||
|
||||
|
||||
## The touch settings, live: every node in group &"touch_controls" (TouchSticks, TouchButtons)
|
||||
## gets apply_settings(self) (the sticks' sides follow swap_sticks), and on a phone the follow
|
||||
## camera (group FollowCamera.GROUP) moves to camera_distance and a hit buzzes when haptics is on
|
||||
## (Scarecrow.haptics). Desktop's camera keeps its own distance (16, and the mouse wheel's zoom).
|
||||
## Main applies the settings after the farm is ready, so on a phone this is what sets the
|
||||
## camera's distance.
|
||||
func apply_touch(tree: SceneTree) -> void:
|
||||
Scarecrow.haptics = haptics and MobilePort.active()
|
||||
if tree == null:
|
||||
return
|
||||
tree.call_group(&"touch_controls", &"apply_settings", self)
|
||||
if MobilePort.active():
|
||||
for cam in tree.get_nodes_in_group(FollowCamera.GROUP):
|
||||
(cam as FollowCamera).distance = camera_distance
|
||||
|
||||
|
||||
static func _number(v: Variant, lo: float, hi: float, fallback: float) -> float:
|
||||
if not (v is float or v is int):
|
||||
return fallback
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ extends Node3D
|
|||
## Nothing here works in build mode.
|
||||
## * Focus: the nearest gather point, workbench, or shed counter within its reach, preferring
|
||||
## gather points with charges left over used-up ones; nearby points show their charges, the
|
||||
## focused one its prompt (or why it can't be used). focus_info() says what interact would
|
||||
## act on, read-only, for the phone's Use button (TouchButtons).
|
||||
## focused one its prompt (or why it can't be used).
|
||||
## * Gather: hold interact by day (D8) at a point with charges left and room in the pouch for
|
||||
## the whole yield (so a charge is never half wasted).
|
||||
## The scarecrow is rooted for gather_time looping the point's clip, then yield_amount goes
|
||||
|
|
@ -54,8 +53,6 @@ const POPUP_TIME := 1.1
|
|||
const POPUPS := 6
|
||||
## Seconds a partner's press of interact waits (on the host) for its copy to reach a counter.
|
||||
const PRESS_WINDOW := 0.3
|
||||
## The phone's Use button's word for each kind of focus_info().
|
||||
const FOCUS_LABELS := {"gather": "Gather", "repair": "Repair", "upgrade": "Upgrade", "workbench": "Workbench", "shed": "Shop"}
|
||||
|
||||
var config: GameConfig
|
||||
var campaign: CampaignController
|
||||
|
|
@ -165,47 +162,6 @@ func can_shoot() -> bool:
|
|||
and not (shed_panel != null and shed_panel.is_open) and not (remote != null and remote.ui_open)
|
||||
|
||||
|
||||
## What interact would act on now (the phone's Use button, TouchButtons; read-only, as of the
|
||||
## last step): {} with nothing in reach (or in build mode, or down), else
|
||||
## kind "gather", "repair", "upgrade", "workbench", or "shed": a channel under way or an
|
||||
## open shop's menu, else (in step's order) a damaged structure in reach, a levelable
|
||||
## one, the nearest point or counter
|
||||
## label the button's word: Gather, Repair, Upgrade, Workbench, or Shop
|
||||
## ready whether holding (or, at a counter, pressing) interact would do it now; false when
|
||||
## it would be refused (the world label says why: nightfall, a full pouch, short of
|
||||
## materials, max level, a broken workbench)
|
||||
## progress 0-1 through the gather, repair, or upgrade under way; -1 when none is.
|
||||
func focus_info() -> Dictionary:
|
||||
if kit == null or not kit.alive or (build != null and build.active):
|
||||
return {}
|
||||
var day := campaign.is_daytime()
|
||||
if gathering != null:
|
||||
return _focus("gather", true, gather_elapsed / maxf(config.gather_time, 0.001))
|
||||
if repairing >= 0:
|
||||
return _focus("repair", true, repair_elapsed / maxf(config.repair_time, 0.001))
|
||||
if upgrading >= 0:
|
||||
return _focus("upgrade", true, upgrade_elapsed / maxf(config.structure_upgrade_time, 0.001))
|
||||
if upgrade_panel != null and upgrade_panel.is_open:
|
||||
return _focus("workbench", true)
|
||||
if shed_panel != null and shed_panel.is_open:
|
||||
return _focus("shed", true)
|
||||
if structures != null and repair_target >= 0:
|
||||
return _focus("repair", campaign.state.resources.can_afford(structures.repair_cost(repair_target), kit.slot))
|
||||
if structures != null and upgrade_target >= 0:
|
||||
return _focus("upgrade", day and structures.upgrade_blocker(upgrade_target, kit.slot) == "")
|
||||
if focus is GatherNode:
|
||||
return _focus("gather", _blocker(focus) == "")
|
||||
if focus is Workbench:
|
||||
return _focus("workbench", day and not (structures != null and structures.is_broken(structures.workbench_id())))
|
||||
if focus is ShedCounter:
|
||||
return _focus("shed", day)
|
||||
return {}
|
||||
|
||||
|
||||
func _focus(kind: String, ready: bool, progress: float = -1.0) -> Dictionary:
|
||||
return {"kind": kind, "label": FOCUS_LABELS[kind], "ready": ready, "progress": clampf(progress, 0.0, 1.0) if progress >= 0.0 else -1.0}
|
||||
|
||||
|
||||
## One physics tick, after the scarecrow kit.
|
||||
func step(dt: float) -> void:
|
||||
var held := remote.held(&"interact") if remote != null else Input.is_action_pressed("interact")
|
||||
|
|
@ -374,7 +330,7 @@ func _upgrade_prompt(id: int) -> String:
|
|||
return "Upgrading is for daytime"
|
||||
var why := structures.upgrade_blocker(id, kit.slot)
|
||||
if why == "":
|
||||
return Prompts.upgrade_to(structures.level_of(id) + 1, ResourceStore.describe(structures.upgrade_cost(id)))
|
||||
return "[E / X] Upgrade to L%d (%s)" % [structures.level_of(id) + 1, ResourceStore.describe(structures.upgrade_cost(id))]
|
||||
return why
|
||||
|
||||
|
||||
|
|
@ -459,7 +415,7 @@ func _process(delta: float) -> void:
|
|||
prompt = "Gathering..."
|
||||
elif n == focus:
|
||||
var why := _blocker(n)
|
||||
prompt = Prompts.gather() if why == "" else why
|
||||
prompt = "[E / X] Gather" if why == "" else why
|
||||
n.show_state(charges(n), near and kit.alive, prompt)
|
||||
if workbench != null and show_labels:
|
||||
var granted := structures != null and structures.has_workbench()
|
||||
|
|
@ -476,7 +432,7 @@ func _process(delta: float) -> void:
|
|||
_repair_label.global_position = Vector3(e["x"], 2.7, e["z"])
|
||||
var cost := structures.repair_cost(shown)
|
||||
_repair_label.text = "%s %d/%d\n%s" % [StructureSystem.NAMES[e["type"]], int(e["hp"]), structures.max_hp(e["type"]),
|
||||
"Repairing..." if repairing >= 0 else Prompts.repair(ResourceStore.describe(cost))]
|
||||
"Repairing..." if repairing >= 0 else "[E / X] Repair (%s)" % ResourceStore.describe(cost)]
|
||||
var ushown := (upgrading if upgrading >= 0 else upgrade_target) if show_labels else -1
|
||||
_upgrade_label.visible = ushown >= 0
|
||||
if ushown >= 0:
|
||||
|
|
|
|||
|
|
@ -19,11 +19,8 @@ extends Node
|
|||
## over GD-Sync (GDSyncLink), with voice chat. In co-op the menus don't pause the farm; the
|
||||
## host's leaving ends the partner's game (back to this menu, which says why), the partner's
|
||||
## leaving leaves the host alone. [M] mutes the microphone.
|
||||
## * On a phone (MobilePort): no ToonLook (Main adds the ScreenLabels that draws the Label3Ds
|
||||
## flat), no co-op, no Quit buttons, two thumbsticks (TouchSticks) and the action buttons
|
||||
## (TouchButtons; their Pause pauses), both taking the settings (apply_settings), and leaving
|
||||
## the app pauses. Android's back button (go_back) closes what's on top or pauses, and quits
|
||||
## from the main menu. The iOS test build adds PerfTest (frame times and test buttons).
|
||||
## * On a phone (MobilePort): no ToonLook, no co-op, two thumbsticks (TouchSticks), and leaving
|
||||
## the app pauses. The iOS test build adds PerfTest (frame times and test buttons).
|
||||
## Main processes while paused; the farm doesn't. Tests set save_path and settings_path
|
||||
## before adding it to the tree.
|
||||
|
||||
|
|
@ -66,8 +63,6 @@ func _ready() -> void:
|
|||
var look := ToonLook.new() # toon shading and pixel outlines on the farm
|
||||
look.name = "ToonLook"
|
||||
add_child(look)
|
||||
else:
|
||||
ScreenLabels.ensure(self).watch(get_tree().root) # ToonLook's label drawing, without the look
|
||||
if MobilePort.perf_test():
|
||||
var perf := PerfTest.new()
|
||||
perf.name = "PerfTest"
|
||||
|
|
@ -137,19 +132,11 @@ func _ready() -> void:
|
|||
var hud_layer := farm.get_node_or_null("Hud")
|
||||
if hud_layer != null:
|
||||
hud_layer.add_child(coop_hud)
|
||||
if MobilePort.active(): # the phone's thumbsticks and buttons, over the HUD (hidden with it in the menus)
|
||||
if MobilePort.active(): # the phone's thumbsticks, over the HUD (hidden with it in the menus)
|
||||
var sticks := TouchSticks.new()
|
||||
sticks.name = "TouchSticks"
|
||||
sticks.setup(sim)
|
||||
hud_layer.add_child(sticks)
|
||||
var buttons := TouchButtons.new()
|
||||
buttons.name = "TouchButtons"
|
||||
buttons.setup(sim)
|
||||
buttons.blocked = func() -> bool: return screen != Screen.PLAYING
|
||||
buttons.pause_requested.connect(pause)
|
||||
hud_layer.add_child(buttons)
|
||||
sticks.apply_settings(settings) # (settings.apply, above, ran before they were here)
|
||||
buttons.apply_settings(settings)
|
||||
if sim.audio != null:
|
||||
sim.audio.wire_buttons($Menus)
|
||||
_menu_camera = Camera3D.new()
|
||||
|
|
@ -280,49 +267,6 @@ func _notification(what: int) -> void:
|
|||
quit_game()
|
||||
elif what == NOTIFICATION_APPLICATION_PAUSED: # a phone app sent to the background
|
||||
pause()
|
||||
elif what == NOTIFICATION_WM_GO_BACK_REQUEST and MobilePort.active(): # Android's back button
|
||||
go_back()
|
||||
|
||||
|
||||
## The phone's back button (application/config/quit_on_go_back is off, so it comes here): what's
|
||||
## on top closes. Playing: the workbench's or the shed's panel, the pouch panel, or build mode,
|
||||
## else it pauses (over a conversation, a sign, the intro, or the end panel too, as Escape does).
|
||||
## Paused: the question, then settings, then it resumes. The main menu: the question, then
|
||||
## settings, else it quits (as Quit: quit_requested).
|
||||
func go_back() -> void:
|
||||
if quitting:
|
||||
return
|
||||
match screen:
|
||||
Screen.PLAYING:
|
||||
if sim.upgrade_panel != null and sim.upgrade_panel.is_open:
|
||||
sim.upgrade_panel.close()
|
||||
elif sim.shed_panel != null and sim.shed_panel.is_open:
|
||||
sim.shed_panel.close()
|
||||
elif sim.resource_hud != null and sim.resource_hud.open:
|
||||
sim.resource_hud.toggle()
|
||||
elif sim.build != null and sim.build.active:
|
||||
sim.build.set_active(false)
|
||||
else:
|
||||
pause()
|
||||
Screen.PAUSED:
|
||||
_back_in_pause()
|
||||
Screen.MENU:
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
elif main_menu.visible: # (not the co-op menu's screens: no co-op on phones)
|
||||
main_menu.quit_requested.emit()
|
||||
|
||||
|
||||
## Paused, the pause action or back: the question closes first, then settings, then it resumes.
|
||||
func _back_in_pause() -> void:
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
else:
|
||||
resume()
|
||||
|
||||
|
||||
func _play() -> void:
|
||||
|
|
@ -463,5 +407,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
pause()
|
||||
get_viewport().set_input_as_handled()
|
||||
Screen.PAUSED:
|
||||
_back_in_pause()
|
||||
if confirm.is_open:
|
||||
confirm.close()
|
||||
elif settings_menu.is_open:
|
||||
settings_menu.close()
|
||||
else:
|
||||
resume()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
|
|
|||
|
|
@ -2,12 +2,8 @@ class_name MainMenu
|
|||
extends Control
|
||||
## The title screen over the farm (Main slowly circles a camera around it): the title, then
|
||||
## Continue (with which morning it resumes at, or why the save can't be continued), New
|
||||
## vacation, Play with a friend (co-op, CoopMenu; not on phones), Settings, and Quit (not on
|
||||
## phones either), and a notice line (e.g.
|
||||
## vacation, Play with a friend (co-op, CoopMenu; not on phones), Settings, and Quit, and a notice line (e.g.
|
||||
## why a co-op game ended). Mouse, keyboard, and gamepad work through focus.
|
||||
## On a phone the column and the credits sit inside the safe area (clear of the notch and the home
|
||||
## indicator), the buttons at least the minimum touch target tall, with smaller type and gaps
|
||||
## when the canvas is too short for the desktop's (fit).
|
||||
|
||||
signal continue_requested
|
||||
signal new_requested
|
||||
|
|
@ -15,18 +11,6 @@ signal settings_requested
|
|||
signal coop_requested
|
||||
signal quit_requested
|
||||
|
||||
const BUTTON_SIZE := Vector2(380.0, 62.0)
|
||||
## Phones: the layouts to try, roomiest first (the first is the desktop's): the title's,
|
||||
## subtitle's, and credits' font sizes, the gap above the buttons, the column's gaps, and its
|
||||
## distance from the safe area's top-left corner (the credits line up with it, BOTTOM_PAD above
|
||||
## the safe area's bottom).
|
||||
const LAYOUTS: Array[Dictionary] = [
|
||||
{"title": 92, "sub": 28, "credits": 16, "gap": 50.0, "separation": 16, "pad": Vector2(110.0, 150.0)},
|
||||
{"title": 72, "sub": 26, "credits": 16, "gap": 12.0, "separation": 10, "pad": Vector2(56.0, 28.0)},
|
||||
{"title": 60, "sub": 22, "credits": 14, "gap": 0.0, "separation": 6, "pad": Vector2(40.0, 10.0)},
|
||||
]
|
||||
const BOTTOM_PAD := 14.0
|
||||
|
||||
var continue_button: Button
|
||||
var new_button: Button
|
||||
var settings_button: Button
|
||||
|
|
@ -35,14 +19,6 @@ var notice: Label
|
|||
var quit_button: Button
|
||||
var save_note: Label
|
||||
|
||||
var _phone := false
|
||||
var _shade: ColorRect
|
||||
var _box: VBoxContainer
|
||||
var _title: Label
|
||||
var _sub: Label
|
||||
var _gap: Control
|
||||
var _credits: Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
|
|
@ -52,9 +28,7 @@ func _ready() -> void:
|
|||
add_child(shade)
|
||||
shade.set_anchors_and_offsets_preset(Control.PRESET_LEFT_WIDE)
|
||||
shade.offset_right = 700.0
|
||||
_shade = shade
|
||||
var box := VBoxContainer.new()
|
||||
_box = box
|
||||
box.position = Vector2(110.0, 150.0)
|
||||
box.add_theme_constant_override("separation", 16)
|
||||
add_child(box)
|
||||
|
|
@ -65,17 +39,14 @@ func _ready() -> void:
|
|||
title.add_theme_color_override("font_outline_color", Color(0.15, 0.1, 0.05))
|
||||
title.add_theme_constant_override("outline_size", 14)
|
||||
box.add_child(title)
|
||||
_title = title
|
||||
var sub := Label.new()
|
||||
sub.text = "The farmers are away. You're the scarecrow."
|
||||
sub.add_theme_font_size_override("font_size", 28)
|
||||
sub.add_theme_color_override("font_color", UiTheme.TEXT)
|
||||
box.add_child(sub)
|
||||
_sub = sub
|
||||
var gap := Control.new()
|
||||
gap.custom_minimum_size = Vector2(0.0, 50.0)
|
||||
box.add_child(gap)
|
||||
_gap = gap
|
||||
continue_button = _button(box, "Continue")
|
||||
continue_button.pressed.connect(func() -> void: continue_requested.emit())
|
||||
save_note = Label.new()
|
||||
|
|
@ -91,7 +62,6 @@ func _ready() -> void:
|
|||
settings_button.pressed.connect(func() -> void: settings_requested.emit())
|
||||
quit_button = _button(box, "Quit")
|
||||
quit_button.pressed.connect(func() -> void: quit_requested.emit())
|
||||
quit_button.visible = not MobilePort.active() # phones: the system closes apps (Android's back here, Main)
|
||||
notice = Label.new()
|
||||
notice.add_theme_font_size_override("font_size", 22)
|
||||
notice.add_theme_color_override("font_color", Color(1.0, 0.75, 0.5))
|
||||
|
|
@ -104,45 +74,7 @@ func _ready() -> void:
|
|||
credits.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_LEFT)
|
||||
credits.offset_top = -60.0
|
||||
credits.offset_left = 110.0
|
||||
_credits = credits
|
||||
visible = false
|
||||
_phone = MobilePort.active()
|
||||
if _phone:
|
||||
get_viewport().size_changed.connect(fit)
|
||||
fit()
|
||||
|
||||
|
||||
## A phone: the column and the credits (wrapped to the column's width, so they stay on the shade)
|
||||
## inside the safe area, the buttons at least the minimum touch target tall, in the roomiest of
|
||||
## LAYOUTS that fits. (Nothing on desktop.)
|
||||
func fit() -> void:
|
||||
if not _phone or not is_inside_tree():
|
||||
return
|
||||
var safe := MobilePort.safe_rect(self)
|
||||
var view := get_viewport_rect().size
|
||||
for b: Button in [continue_button, new_button, coop_button, settings_button, quit_button]:
|
||||
b.custom_minimum_size.y = UiTheme.touch_height(self, BUTTON_SIZE.y)
|
||||
for layout in LAYOUTS:
|
||||
var pad: Vector2 = layout["pad"]
|
||||
_title.add_theme_font_size_override("font_size", layout["title"])
|
||||
_sub.add_theme_font_size_override("font_size", layout["sub"])
|
||||
_gap.custom_minimum_size.y = layout["gap"]
|
||||
_box.add_theme_constant_override("separation", layout["separation"])
|
||||
var column := _box.get_combined_minimum_size()
|
||||
_credits.add_theme_font_size_override("font_size", layout["credits"])
|
||||
_credits.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART # under the column, on its shade
|
||||
_credits.custom_minimum_size.x = column.x
|
||||
_credits.size = Vector2(column.x, 0.0)
|
||||
var credits_h := _credits.get_combined_minimum_size().y
|
||||
_box.position = safe.position + pad
|
||||
_box.size = column
|
||||
_credits.offset_left = safe.position.x + pad.x
|
||||
_credits.offset_right = _credits.offset_left + _credits.custom_minimum_size.x
|
||||
_credits.offset_bottom = safe.end.y - view.y - BOTTOM_PAD
|
||||
_credits.offset_top = _credits.offset_bottom - credits_h
|
||||
_shade.offset_right = _box.position.x + column.x + pad.x
|
||||
if pad.y + column.y + BOTTOM_PAD + credits_h + BOTTOM_PAD <= safe.size.y and pad.x + column.x <= safe.size.x:
|
||||
break
|
||||
|
||||
|
||||
## Shows the menu for the save as read (SaveGame.read): Continue says where it resumes, or is
|
||||
|
|
@ -157,7 +89,6 @@ func open(saved: SaveGame.Loaded, nights: int) -> void:
|
|||
(" · saved " + saved.saved_at.replace("T", " ").left(16)) if saved.saved_at != "" else ""]
|
||||
else:
|
||||
save_note.text = saved.message if saved != null else "No saved vacation"
|
||||
fit()
|
||||
_focus_first.call_deferred()
|
||||
|
||||
|
||||
|
|
@ -176,7 +107,7 @@ func _button(parent: Control, text: String) -> Button:
|
|||
var b := Button.new()
|
||||
b.text = text
|
||||
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
b.custom_minimum_size = BUTTON_SIZE
|
||||
b.custom_minimum_size = Vector2(380.0, 62.0)
|
||||
b.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
b.add_theme_font_size_override("font_size", 28)
|
||||
parent.add_child(b)
|
||||
|
|
|
|||
|
|
@ -7,233 +7,15 @@ extends RefCounted
|
|||
## main menu's button and the settings' Co-op section), two thumbsticks move and attack
|
||||
## (TouchSticks), and leaving the app pauses the game.
|
||||
## The microphone is never opened (audio/driver/enable_input.mobile in project.godot).
|
||||
## The interface is scaled for the screen's physical size (ui_scale) and kept inside its safe
|
||||
## area (safe_rect), with touch targets of at least minimum_target(); see below.
|
||||
## * perf_test(): the iOS preset's "perf_test" feature. Main adds PerfTest (the frame-time
|
||||
## readout and test buttons), and CampaignDebug's jumps work in that release build.
|
||||
## On desktop, `-- --mobile` and `-- --perf-test` after the usual arguments turn the same switches
|
||||
## on, to see the phone build without a phone (add --rendering-method mobile for its renderer).
|
||||
|
||||
|
||||
## Tests: -1 detects the platform, 0 forces desktop, 1 forces a phone.
|
||||
static var forced := -1
|
||||
|
||||
|
||||
static func active() -> bool:
|
||||
if forced >= 0:
|
||||
return forced == 1
|
||||
return OS.has_feature("mobile") or "--mobile" in OS.get_cmdline_user_args()
|
||||
|
||||
|
||||
static func perf_test() -> bool:
|
||||
return OS.has_feature("perf_test") or "--perf-test" in OS.get_cmdline_user_args()
|
||||
|
||||
|
||||
## --- The interface on a phone: its scale, the safe area, and the touch target ---
|
||||
## ui_scale() is the root window's content_scale_factor on a phone (GameSettings.apply). It
|
||||
## scales every CanvasLayer (the HUD, the menus, the sticks) and leaves the 3D view alone. It's
|
||||
## worked out from the screen's physical size: clampf(4.3 / the shorter side in inches, 1, 1.7),
|
||||
## about 1.6 on a phone and 1 on an iPad, times the Interface size setting (0.8-1.3). At 1.6 a
|
||||
## 19.5:9 phone's canvas is about 1460x675 instead of 2340x1080. Desktop is always 1.
|
||||
## The density (screen_get_dpi) isn't trusted blindly: when it's 0 or impossible for a phone or a
|
||||
## tablet (DPI_RANGE, INCH_RANGE), the size class decides: a shorter side below 500 points is a
|
||||
## phone (1.6), anything bigger a tablet (1). PerfTest shows what a device reports (describe()).
|
||||
## The desktop preview (-- --mobile, or tests' forced = 1) plays the phone in the window:
|
||||
## * --dpi=N (or preview_dpi) gives the window that density. Without it, a window at least
|
||||
## 1.7:1 (16:9 and wider) is a phone whose shorter side is 2.7 in (about 1.6x), a squarer one
|
||||
## an iPad's 6 in (1x).
|
||||
## * --safe-area=left,top,right,bottom (or preview_insets) insets the safe area by that many
|
||||
## window pixels on each side, to stand in for a notch and the home indicator.
|
||||
|
||||
## Apple's minimum touch target, in points (an iPhone's pixels over its screen scale).
|
||||
const TARGET_PT := 44.0
|
||||
## The scale from the screen's size: this many inches across the shorter side is 1x.
|
||||
const REFERENCE_INCHES := 4.3
|
||||
const MIN_SCALE := 1.0
|
||||
const MAX_SCALE := 1.7 # the user's cap (2026-10-14): keeps the smallest iPhones' canvas about 635 tall
|
||||
## The size class, when the density can't be trusted: a phone's shorter side is below this many
|
||||
## points, and gets PHONE_SCALE; anything bigger is a tablet (TABLET_SCALE).
|
||||
const PHONE_POINTS := 500.0
|
||||
const PHONE_SCALE := 1.6
|
||||
const TABLET_SCALE := 1.0
|
||||
## The densities (dots per inch) and shorter sides (inches) a phone or a tablet can have. Outside
|
||||
## them the reported density is wrong.
|
||||
const DPI_RANGE := Vector2(120.0, 800.0)
|
||||
const INCH_RANGE := Vector2(1.5, 13.0)
|
||||
## An original iPhone's density: one point per pixel. Pixels per point are the density over it
|
||||
## where the screen doesn't say (the desktop preview).
|
||||
const POINT_DPI := 163.0
|
||||
## The desktop preview without --dpi: a window at least this wide for its height is a phone with
|
||||
## PREVIEW_PHONE_INCHES across its shorter side, a squarer one an iPad with PREVIEW_TABLET_INCHES.
|
||||
const PREVIEW_PHONE_ASPECT := 1.7
|
||||
const PREVIEW_PHONE_INCHES := 2.7
|
||||
const PREVIEW_TABLET_INCHES := 6.0
|
||||
|
||||
## The desktop preview's density (dots per inch). 0: the --dpi=N user argument, or by the
|
||||
## window's shape (see above).
|
||||
static var preview_dpi := 0.0
|
||||
## The desktop preview's safe-area insets in window pixels: [left, top, right, bottom]. Empty:
|
||||
## the --safe-area=l,t,r,b user argument, or none.
|
||||
static var preview_insets: Array = []
|
||||
|
||||
|
||||
## A phone in the desktop preview (active() without the "mobile" feature: -- --mobile, or a test).
|
||||
static func previewing() -> bool:
|
||||
return active() and not OS.has_feature("mobile")
|
||||
|
||||
|
||||
## The interface scale (the window's content_scale_factor): screen_scale() times interface_size
|
||||
## (the Interface size setting, 0.8-1.3) on a phone; 1 on desktop.
|
||||
static func ui_scale(interface_size: float = 1.0) -> float:
|
||||
if not active():
|
||||
return 1.0
|
||||
return screen_scale() * clampf(interface_size, 0.8, 1.3)
|
||||
|
||||
|
||||
## The scale this screen's physical size calls for (scale_for), before the Interface size.
|
||||
static func screen_scale() -> float:
|
||||
return scale_for(screen_pixels(), screen_dpi(), pixels_per_point())
|
||||
|
||||
|
||||
## The scale for a screen this many pixels across, at this density (dots per inch), with this
|
||||
## many pixels per point: clampf(4.3 / the shorter side in inches, 1, 1.7). When the density
|
||||
## can't be right (dpi_plausible), the size class: below PHONE_POINTS points across the shorter
|
||||
## side is a phone (1.6), else a tablet (1).
|
||||
static func scale_for(pixels: Vector2, dpi: float, per_point: float) -> float:
|
||||
var short := minf(pixels.x, pixels.y)
|
||||
if dpi_plausible(pixels, dpi):
|
||||
return clampf(REFERENCE_INCHES / (short / dpi), MIN_SCALE, MAX_SCALE)
|
||||
return PHONE_SCALE if short / maxf(per_point, 0.001) < PHONE_POINTS else TABLET_SCALE
|
||||
|
||||
|
||||
## Whether a screen this many pixels across could have this density: one inside DPI_RANGE, which
|
||||
## makes the shorter side a length inside INCH_RANGE.
|
||||
static func dpi_plausible(pixels: Vector2, dpi: float) -> bool:
|
||||
if dpi < DPI_RANGE.x or dpi > DPI_RANGE.y:
|
||||
return false
|
||||
var inches := minf(pixels.x, pixels.y) / dpi
|
||||
return inches >= INCH_RANGE.x and inches <= INCH_RANGE.y
|
||||
|
||||
|
||||
## The phone's screen in pixels: the screen on a phone, the window in the desktop preview.
|
||||
static func screen_pixels() -> Vector2:
|
||||
if previewing():
|
||||
var root := _root()
|
||||
return Vector2(root.size) if root != null else Vector2.ZERO
|
||||
return Vector2(DisplayServer.screen_get_size())
|
||||
|
||||
|
||||
## The screen's density (dots per inch): the screen's own on a phone; in the desktop preview
|
||||
## preview_dpi, --dpi=N, or the phone's or the iPad's by the window's shape.
|
||||
static func screen_dpi() -> float:
|
||||
if not previewing():
|
||||
return float(DisplayServer.screen_get_dpi())
|
||||
if preview_dpi > 0.0:
|
||||
return preview_dpi
|
||||
var arg := _arg("--dpi=")
|
||||
if arg.is_valid_float() and float(arg) > 0.0:
|
||||
return float(arg)
|
||||
var px := screen_pixels()
|
||||
var short := minf(px.x, px.y)
|
||||
var phone := maxf(px.x, px.y) >= PREVIEW_PHONE_ASPECT * short
|
||||
return short / (PREVIEW_PHONE_INCHES if phone else PREVIEW_TABLET_INCHES)
|
||||
|
||||
|
||||
## Pixels per point: the screen's scale on a phone (2 or 3 on an iPhone; Android's density
|
||||
## over 160), else the density over POINT_DPI (the desktop preview, or a phone that says 1 and
|
||||
## has a plausible density), else 1.
|
||||
static func pixels_per_point() -> float:
|
||||
var dpi := screen_dpi()
|
||||
if previewing():
|
||||
return maxf(dpi / POINT_DPI, 0.001)
|
||||
var s := DisplayServer.screen_get_scale()
|
||||
if s > 1.0:
|
||||
return s
|
||||
return dpi / POINT_DPI if dpi_plausible(screen_pixels(), dpi) else 1.0
|
||||
|
||||
|
||||
## The safe area in window pixels: the display's (DisplayServer.get_display_safe_area: clear of
|
||||
## the notch, the rounded corners and the home indicator) on a phone; the window less the
|
||||
## preview's insets in the desktop preview. The whole window when there's none.
|
||||
static func safe_area_pixels(window: Window) -> Rect2:
|
||||
var full := Rect2(Vector2.ZERO, Vector2(window.size))
|
||||
var safe := full
|
||||
if previewing():
|
||||
var inset := insets()
|
||||
safe = Rect2(full.position + Vector2(inset[0], inset[1]),
|
||||
(full.size - Vector2(inset[0] + inset[2], inset[1] + inset[3])).max(Vector2.ZERO))
|
||||
elif active():
|
||||
safe = Rect2(DisplayServer.get_display_safe_area()).abs()
|
||||
safe.position -= Vector2(DisplayServer.window_get_position()) # screen to window (0 when full screen)
|
||||
safe = safe.intersection(full)
|
||||
return safe if safe.has_area() else full
|
||||
|
||||
|
||||
## The preview's safe-area insets in window pixels, [left, top, right, bottom]: preview_insets,
|
||||
## or --safe-area=l,t,r,b, or none.
|
||||
static func insets() -> Array:
|
||||
var from: Array = preview_insets
|
||||
if from.size() != 4:
|
||||
from = Array(_arg("--safe-area=").split(","))
|
||||
var out: Array = []
|
||||
for v: Variant in from:
|
||||
var x := float(v) if v is float or v is int or (v is String and (v as String).is_valid_float()) else NAN
|
||||
if is_nan(x):
|
||||
return [0.0, 0.0, 0.0, 0.0]
|
||||
out.append(maxf(x, 0.0))
|
||||
return out if out.size() == 4 else [0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
|
||||
## The safe area in ci's canvas coordinates (the window's pixels through the viewport's final
|
||||
## transform and ci's canvas layer, so with the interface scale): where the HUD's widgets and
|
||||
## the menus go on a phone. On desktop, the whole visible rect.
|
||||
static func safe_rect(ci: CanvasItem) -> Rect2:
|
||||
if not active():
|
||||
return ci.get_viewport_rect()
|
||||
return _to_window(ci).affine_inverse() * safe_area_pixels(ci.get_window())
|
||||
|
||||
|
||||
## Apple's minimum touch target (44 points) in canvas pixels at the current scale, for ci's
|
||||
## canvas (the root window's without one): about 70 on a phone or an iPad. 44 on desktop.
|
||||
static func minimum_target(ci: CanvasItem = null) -> float:
|
||||
if not active():
|
||||
return TARGET_PT
|
||||
var s := absf(_to_window(ci).get_scale().y)
|
||||
return TARGET_PT * pixels_per_point() / s if s > 0.0 else TARGET_PT
|
||||
|
||||
|
||||
## Two lines for PerfTest's overlay, to check on a device what it reports: the screen (pixels,
|
||||
## density, pixels per point) and the display's safe area as reported (the simulated one in the
|
||||
## desktop preview); then the scale and how it was worked out, the window's factor, and the
|
||||
## canvas and the touch target that gives.
|
||||
static func describe() -> String:
|
||||
var px := screen_pixels()
|
||||
var dpi := screen_dpi()
|
||||
var root := _root()
|
||||
var safe := Rect2i(safe_area_pixels(root)) if previewing() and root != null else DisplayServer.get_display_safe_area()
|
||||
var canvas := root.get_visible_rect().size if root != null else Vector2.ZERO
|
||||
return "Screen %d×%d · %d dpi · %.2f px/pt · safe area %d,%d %d×%d\nScale ×%.2f (%s) · window ×%.2f · canvas %d×%d · 44 pt = %d px" % [
|
||||
roundi(px.x), roundi(px.y), roundi(dpi), pixels_per_point(), safe.position.x, safe.position.y, safe.size.x, safe.size.y,
|
||||
screen_scale(), "dpi" if dpi_plausible(px, dpi) else "size class", root.content_scale_factor if root != null else 1.0,
|
||||
roundi(canvas.x), roundi(canvas.y), roundi(minimum_target())]
|
||||
|
||||
|
||||
## ci's canvas coordinates to window pixels (the root window's canvas without ci).
|
||||
static func _to_window(ci: CanvasItem) -> Transform2D:
|
||||
if ci != null:
|
||||
return ci.get_viewport().get_final_transform() * ci.get_canvas_transform()
|
||||
var root := _root()
|
||||
return root.get_final_transform() if root != null else Transform2D.IDENTITY
|
||||
|
||||
|
||||
static func _root() -> Window:
|
||||
var tree := Engine.get_main_loop() as SceneTree
|
||||
return tree.root if tree != null else null
|
||||
|
||||
|
||||
## The value of a `--name=value` user argument ("" without one).
|
||||
static func _arg(prefix: String) -> String:
|
||||
for a: String in OS.get_cmdline_user_args():
|
||||
if a.begins_with(prefix):
|
||||
return a.trim_prefix(prefix)
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -1025,7 +1025,7 @@ func _build_night() -> void:
|
|||
## The overlay (letterbox, the skip hint and its ring, the box, the flash, the black, the card)
|
||||
## and the loading screen over it.
|
||||
func _build_screen() -> void:
|
||||
_overlay = CutsceneKit.make_letterbox(self, "", Prompts.intro_skip(), 5)
|
||||
_overlay = CutsceneKit.make_letterbox(self, "", "Hold [Space / Enter / A] to skip", 5)
|
||||
_overlay.name = "Overlay"
|
||||
_overlay.caption.visible = false
|
||||
_ring = SkipRing.new()
|
||||
|
|
|
|||
|
|
@ -3,11 +3,8 @@ extends CenterContainer
|
|||
## Escape / Start during play (Main pauses the tree), hand-drawn like the HUD's pouch panel
|
||||
## (UiTheme.sketch): where you are and what's left to protect
|
||||
## (crops, animals, supplies; asset_counts), then Resume, Restart the night, Settings, Save & quit
|
||||
## to the menu, and Quit the game (not on phones, MobilePort), with a reminder of what Continue
|
||||
## picks up (the vacation is saved every morning).
|
||||
## On a phone the buttons stand in a column beside the rest (the panel is wide and short enough
|
||||
## for a phone held sideways), the whole panel in the middle of the safe area with touch-sized
|
||||
## buttons, and on a short canvas (a phone's, not an iPad's) smaller type: fit.
|
||||
## to the menu, and Quit the game, with a reminder of what Continue picks up (the vacation is
|
||||
## saved every morning).
|
||||
|
||||
signal resume_requested
|
||||
signal restart_requested
|
||||
|
|
@ -15,15 +12,6 @@ signal settings_requested
|
|||
signal menu_requested
|
||||
signal quit_requested
|
||||
|
||||
const BUTTON_SIZE := Vector2(420.0, 56.0)
|
||||
## Phones: the sizes as built (REGULAR), and the smaller ones for when those don't fit (COMPACT):
|
||||
## the font sizes of the title, where you are, the assets, the note, and the buttons; the note's
|
||||
## width, the buttons' width, and the gaps.
|
||||
const REGULAR := {"title": 56, "where": 28, "assets": 30, "note": 22, "button": 30, "note_width": 520.0,
|
||||
"button_width": 420.0, "separation": 14}
|
||||
const COMPACT := {"title": 44, "where": 24, "assets": 26, "note": 20, "button": 28, "note_width": 380.0,
|
||||
"button_width": 340.0, "separation": 10}
|
||||
|
||||
var resume_button: Button
|
||||
var restart_button: Button
|
||||
var settings_button: Button
|
||||
|
|
@ -32,20 +20,12 @@ var quit_button: Button
|
|||
var _where: Label
|
||||
var _note: Label
|
||||
var _assets: Array[Label] = []
|
||||
var _phone := false
|
||||
var _panel: PanelContainer
|
||||
var _box: VBoxContainer
|
||||
var _title: Label
|
||||
var _buttons: Array[Button] = []
|
||||
var _side: VBoxContainer # phones: the buttons' column
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
theme = UiTheme.sketch()
|
||||
_phone = MobilePort.active()
|
||||
var panel := PanelContainer.new()
|
||||
_panel = panel
|
||||
add_child(panel)
|
||||
var margin := MarginContainer.new()
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
|
|
@ -54,9 +34,7 @@ func _ready() -> void:
|
|||
var box := VBoxContainer.new()
|
||||
box.add_theme_constant_override("separation", 14)
|
||||
margin.add_child(box)
|
||||
_box = box
|
||||
var title := Label.new()
|
||||
_title = title
|
||||
title.text = "Paused"
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
title.add_theme_font_size_override("font_size", 56)
|
||||
|
|
@ -67,17 +45,9 @@ func _ready() -> void:
|
|||
_where.add_theme_font_size_override("font_size", 28)
|
||||
_where.add_theme_color_override("font_color", Sketch.DIM)
|
||||
box.add_child(_where)
|
||||
var assets: Container
|
||||
if _phone: # a narrower column: the assets wrap
|
||||
var flow := HFlowContainer.new()
|
||||
flow.alignment = FlowContainer.ALIGNMENT_CENTER
|
||||
flow.add_theme_constant_override("h_separation", 30)
|
||||
assets = flow
|
||||
else:
|
||||
var row := HBoxContainer.new()
|
||||
row.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
row.add_theme_constant_override("separation", 30)
|
||||
assets = row
|
||||
var assets := HBoxContainer.new()
|
||||
assets.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
assets.add_theme_constant_override("separation", 30)
|
||||
box.add_child(assets)
|
||||
for c in 3:
|
||||
var l := Label.new()
|
||||
|
|
@ -95,7 +65,6 @@ func _ready() -> void:
|
|||
menu_button.pressed.connect(func() -> void: menu_requested.emit())
|
||||
quit_button = _button(box, "Quit the game")
|
||||
quit_button.pressed.connect(func() -> void: quit_requested.emit())
|
||||
quit_button.visible = not MobilePort.active() # phones: the system closes apps
|
||||
_note = Label.new()
|
||||
_note.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_note.custom_minimum_size = Vector2(520.0, 0.0)
|
||||
|
|
@ -103,58 +72,8 @@ func _ready() -> void:
|
|||
_note.add_theme_font_size_override("font_size", 22)
|
||||
_note.add_theme_color_override("font_color", Sketch.DIM)
|
||||
box.add_child(_note)
|
||||
_buttons = [resume_button, restart_button, settings_button, menu_button, quit_button]
|
||||
if _phone:
|
||||
_side_by_side(margin)
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
if _phone:
|
||||
get_viewport().size_changed.connect(fit)
|
||||
fit()
|
||||
|
||||
|
||||
## Phones: the buttons move to a column of their own beside the title, the assets, and the note.
|
||||
func _side_by_side(margin: MarginContainer) -> void:
|
||||
var columns := HBoxContainer.new()
|
||||
columns.add_theme_constant_override("separation", 24)
|
||||
margin.remove_child(_box)
|
||||
margin.add_child(columns)
|
||||
_box.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
columns.add_child(_box)
|
||||
_side = VBoxContainer.new()
|
||||
_side.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
columns.add_child(_side)
|
||||
for b in _buttons:
|
||||
b.reparent(_side, false)
|
||||
|
||||
|
||||
## A phone: the panel in the middle of the safe area, the buttons at least the minimum touch
|
||||
## target tall, and the compact sizes when the regular ones don't fit. (Nothing on desktop.)
|
||||
func fit() -> void:
|
||||
if not _phone or not is_inside_tree():
|
||||
return
|
||||
UiTheme.inset_to_safe_area(self)
|
||||
var safe := MobilePort.safe_rect(self)
|
||||
for sizes: Dictionary in [REGULAR, COMPACT]:
|
||||
_use(sizes)
|
||||
var need := _panel.get_combined_minimum_size()
|
||||
if need.x <= safe.size.x and need.y <= safe.size.y:
|
||||
break
|
||||
queue_redraw() # the dim covers the screen from wherever the inset put this
|
||||
|
||||
|
||||
func _use(sizes: Dictionary) -> void:
|
||||
_title.add_theme_font_size_override("font_size", sizes["title"])
|
||||
_where.add_theme_font_size_override("font_size", sizes["where"])
|
||||
for l in _assets:
|
||||
l.add_theme_font_size_override("font_size", sizes["assets"])
|
||||
_note.add_theme_font_size_override("font_size", sizes["note"])
|
||||
_note.custom_minimum_size.x = sizes["note_width"]
|
||||
for b in _buttons:
|
||||
b.add_theme_font_size_override("font_size", sizes["button"])
|
||||
b.custom_minimum_size = Vector2(sizes["button_width"], UiTheme.touch_height(self, BUTTON_SIZE.y))
|
||||
_box.add_theme_constant_override("separation", sizes["separation"])
|
||||
_side.add_theme_constant_override("separation", sizes["separation"])
|
||||
|
||||
|
||||
## coop: 0 solo, 1 hosting a co-op game, 2 a partner in one (the farm doesn't stop for menus).
|
||||
|
|
@ -177,7 +96,6 @@ func open(campaign: CampaignController, coop: int = 0) -> void:
|
|||
_note.text = "Co-op: the farm keeps going while you're in this menu. Only the host can restart the night; the host's game is saved."
|
||||
visible = true
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
fit()
|
||||
resume_button.grab_focus.call_deferred()
|
||||
|
||||
|
||||
|
|
@ -199,11 +117,7 @@ func describe_assets() -> String:
|
|||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(UiTheme.overlay_rect(self), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
|
||||
|
||||
|
||||
func _has_point(point: Vector2) -> bool:
|
||||
return UiTheme.overlay_rect(self).has_point(point) # all of the screen, also outside the safe area
|
||||
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
|
||||
|
||||
|
||||
func close() -> void:
|
||||
|
|
@ -214,7 +128,7 @@ func close() -> void:
|
|||
func _button(parent: Control, text: String) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.custom_minimum_size = BUTTON_SIZE
|
||||
b.custom_minimum_size = Vector2(420.0, 56.0)
|
||||
b.add_theme_font_size_override("font_size", 30)
|
||||
parent.add_child(b)
|
||||
return b
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ extends CanvasLayer
|
|||
## late night on a phone (docs/ios-test-port.md). Over everything, top centre:
|
||||
## * Now, over the last second: FPS, the frame time (average and worst), the CPU time in
|
||||
## physics (the farm's tick, FarmSim.step, runs there) and in rendering, the GPU time to draw
|
||||
## the view, the enemies alive, the 3D view's render size, and the renderer and device. And
|
||||
## the screen as the device reports it (size, density, safe area) with the interface scale
|
||||
## that gives (MobilePort.describe), to check the density on a phone.
|
||||
## the view, the enemies alive, the 3D view's render size, and the renderer and device.
|
||||
## * This night, from its start to its end (then held until the next night): the frame time's
|
||||
## average, 99th percentile, and worst, the share of frames slower than 30 FPS, the peak
|
||||
## enemies alive, and how long it ran. Frames while paused aren't counted. Printed as one
|
||||
|
|
@ -147,7 +145,6 @@ func _refresh(now: int) -> void:
|
|||
roundi(_second_frames * 1000.0 / span), span / n, _second_worst, _second_physics / n, _second_physics_worst,
|
||||
_second_render_cpu / n, "%.1f ms" % gpu if gpu > 0.0 else "n/a", enemies, roundi(size_3d.x), roundi(size_3d.y),
|
||||
RenderingServer.get_current_rendering_method(), RenderingServer.get_current_rendering_driver_name(), OS.get_model_name()]
|
||||
_now.text += "\n" + MobilePort.describe() # the screen as the phone reports it, and the interface scale it gives
|
||||
if _in_night:
|
||||
_night.text = _describe_night("so far")
|
||||
_second_usec = now
|
||||
|
|
|
|||
|
|
@ -7,16 +7,15 @@ extends CharacterBody3D
|
|||
## (start_channel: patching up, gathering) it is rooted and loops the channel's clip; once fallen
|
||||
## (die) it plays the death clip and takes no input until revived. set_flash() tints the model
|
||||
## for hit feedback.
|
||||
## Sprint (the workbench's Sprint upgrade): once it's bought, the scarecrow moves
|
||||
## GameConfig.sprint_speed_mult times as fast for good (speed_factor), walking and running alike,
|
||||
## on every platform, and the run clip plays that much faster to match. There's no button, time
|
||||
## limit, or cooldown. FarmSim sets config and campaign; without them, or without the upgrade, it
|
||||
## moves at run_speed.
|
||||
## Sprint (the workbench's Sprint upgrade): holding sprint (Shift / L3) while moving runs at
|
||||
## GameConfig.sprint_speed_mult times run_speed, the run clip sped up to match, for up to
|
||||
## sprint_time seconds; once it ends (time's up, let go, or stopped) it takes sprint_cooldown
|
||||
## seconds to come back. FarmSim sets config and campaign; without them, or without the upgrade,
|
||||
## there's no sprint.
|
||||
## Co-op: the other machine's scarecrow is remote_driven: it eases toward the position and facing
|
||||
## it was last sent (net_position, net_yaw) and animates by net_speed (like input strength: 1 at
|
||||
## run speed, more with the Sprint upgrade) instead of reading the input. Each scarecrow's speed
|
||||
## is worked out on the machine that plays it. set_tint() and set_tag() tell the two scarecrows
|
||||
## apart.
|
||||
## run speed, more while sprinting) instead of reading the input. Each scarecrow sprints on the
|
||||
## machine that plays it. set_tint() and set_tag() tell the two scarecrows apart.
|
||||
## The core glow: every scarecrow has a small blue core in its chest (the alien part it absorbed
|
||||
## in the opening intro): a glowing gem on the chest bone (so it follows the animation), a soft
|
||||
## halo, and a weak blue light, pulsing slowly. It's unshaded (the toon look and the hit flash
|
||||
|
|
@ -91,9 +90,13 @@ var net_position := Vector3.ZERO
|
|||
var net_yaw: float = 0.0
|
||||
var net_speed: float = 0.0
|
||||
|
||||
## Set by FarmSim: Sprint's speed boost, and the farm state that says whether it's bought.
|
||||
## Set by FarmSim: the sprint's tuning, and the farm state that says whether it's unlocked.
|
||||
var config: GameConfig
|
||||
var campaign: CampaignController
|
||||
## Sprinting now, seconds of it left, and seconds until the next one (0 = ready).
|
||||
var sprinting := false
|
||||
var sprint_left: float = 0.0
|
||||
var sprint_recharge: float = 0.0
|
||||
|
||||
var _aim := Vector2.ZERO
|
||||
var _aim_hold: float = 0.0
|
||||
|
|
@ -127,6 +130,7 @@ func _physics_process(delta: float) -> void:
|
|||
_follow_net(delta)
|
||||
return
|
||||
var move := _move_direction() if alive and not rooted else Vector3.ZERO
|
||||
step_sprint(delta, can_sprint() and input_enabled and Input.is_action_pressed("sprint"), move.length_squared() > 1e-4)
|
||||
var horizontal := Vector3(velocity.x, 0.0, velocity.z).move_toward(move * run_speed * speed_factor(), acceleration * delta)
|
||||
velocity.x = horizontal.x
|
||||
velocity.z = horizontal.z
|
||||
|
|
@ -165,20 +169,46 @@ func snap_to_net(at: Vector3, yaw: float) -> void:
|
|||
model.rotation.y = yaw
|
||||
|
||||
|
||||
## Movement strength for the network: 0 standing .. 1 at run speed (sprint_speed_mult at full
|
||||
## speed with the Sprint upgrade).
|
||||
## Movement strength for the network: 0 standing .. 1 at run speed (more while sprinting).
|
||||
func move_strength() -> float:
|
||||
return clampf(Vector2(velocity.x, velocity.z).length() / run_speed, 0.0, 2.0)
|
||||
|
||||
|
||||
## Whether the Sprint upgrade is owned.
|
||||
func has_sprint() -> bool:
|
||||
func can_sprint() -> bool:
|
||||
return config != null and campaign != null and Upgrades.owned(campaign.state, "sprint")
|
||||
|
||||
|
||||
## Speed relative to run_speed: sprint_speed_mult with the Sprint upgrade, else 1.
|
||||
## Speed relative to run_speed: sprint_speed_mult while sprinting.
|
||||
func speed_factor() -> float:
|
||||
return config.sprint_speed_mult if has_sprint() else 1.0
|
||||
return config.sprint_speed_mult if sprinting else 1.0
|
||||
|
||||
|
||||
## One tick of the sprint: starts one while held and moving (when unlocked and recharged); ends
|
||||
## it when its time is up, it's let go, or the scarecrow stops; then counts the recharge down.
|
||||
func step_sprint(dt: float, held: bool, moving: bool) -> void:
|
||||
if sprinting:
|
||||
sprint_left -= dt
|
||||
if sprint_left <= 0.0 or not held or not moving or not alive or not can_sprint():
|
||||
_end_sprint()
|
||||
return
|
||||
sprint_recharge = maxf(sprint_recharge - dt, 0.0)
|
||||
if held and moving and alive and sprint_recharge == 0.0 and can_sprint():
|
||||
sprinting = true
|
||||
sprint_left = config.sprint_time
|
||||
|
||||
|
||||
## Ready to sprint again at once (a new morning).
|
||||
func reset_sprint() -> void:
|
||||
sprinting = false
|
||||
sprint_left = 0.0
|
||||
sprint_recharge = 0.0
|
||||
|
||||
|
||||
func _end_sprint() -> void:
|
||||
sprinting = false
|
||||
sprint_left = 0.0
|
||||
sprint_recharge = config.sprint_cooldown if config != null else 0.0
|
||||
|
||||
|
||||
## Shows or hides the core glow in the chest (on from the start).
|
||||
|
|
@ -312,6 +342,7 @@ func stop_channel() -> void:
|
|||
func die() -> void:
|
||||
alive = false
|
||||
rooted = false
|
||||
reset_sprint()
|
||||
animation_player.speed_scale = 1.0
|
||||
animation_player.play(death_animation, 0.15)
|
||||
|
||||
|
|
@ -320,6 +351,7 @@ func revive() -> void:
|
|||
alive = true
|
||||
rooted = false
|
||||
_aim_hold = 0.0
|
||||
reset_sprint()
|
||||
animation_player.play(idle_animation, 0.1)
|
||||
|
||||
|
||||
|
|
@ -350,7 +382,7 @@ func _update_animation(strength: float) -> void:
|
|||
clip = run_animation
|
||||
elif strength > 0.0:
|
||||
clip = walk_animation
|
||||
# The Sprint upgrade's speed (strength above 1) plays the run clip faster.
|
||||
# A sprint (strength above 1) plays the run clip faster.
|
||||
animation_player.speed_scale = maxf(strength, 1.0) if clip == run_animation else 1.0
|
||||
if animation_player.current_animation != clip:
|
||||
animation_player.play(clip, blend_time)
|
||||
|
|
|
|||
|
|
@ -1,143 +0,0 @@
|
|||
class_name Prompts
|
||||
extends RefCounted
|
||||
## The game's prompts that name a key, a mouse button, or a gamepad button, in one place. On a
|
||||
## phone (MobilePort.active()) each says it in touch words instead: the controls there are the
|
||||
## two thumbsticks (TouchSticks) and the touch buttons (Use, Build, Fear, Bomb, Patch, Pause; in
|
||||
## build mode Place, Rotate, Dismantle, Done), the hotbar, the backpack, and the tip box's ×.
|
||||
## Everywhere else each returns exactly the string the game showed before. Phones change a
|
||||
## prompt's words, never how many there are.
|
||||
## * World labels: gather, repair, upgrade (Interactions), the workbench and the shed counter.
|
||||
## * Build mode: the ghost's label (BuildMode) and the build bar (BuildHud).
|
||||
## * Cutscenes: the skip hints (OpeningIntro, FarmersReturn).
|
||||
## * The tutorial: each tip (Tutorial.TEXT; on phones TOUCH_TIPS) and the tip box's footer.
|
||||
## * The first morning's sign (ReviewPanel): how the day and the night are played.
|
||||
|
||||
## The tutorial's tips that name a control, in touch words (the others read the same on phones:
|
||||
## Tutorial.TEXT). {move} and {attack} are the screen sides of the move and attack sticks.
|
||||
const TOUCH_TIPS := {
|
||||
"move": "Move with your {move} thumb: touch the {move} half of the screen and slide. You're the scarecrow: keep the farm safe until the farmers are back.",
|
||||
"gather": "Hold Use at a dead tree, the haystacks, or the scrap heap to gather wood, straw, and scrap.",
|
||||
"store": "Your pouch only holds so much (tap the backpack to see what's in it): walk onto the barn's apron (the Supply Shed) to store what you carry.",
|
||||
"build": "Build (by day): tap Build, pick a fence, put your {attack} thumb where it goes, then tap Place. Aliens have to break through fences.",
|
||||
"shoot": "Your {attack} thumb aims and attacks: slide it toward an alien to stab with your pitchfork. The supply shed sells a corn shooter (tap the hotbar to switch); more weapons arrive there over the days, like pumpkin bombs for your off-hand (Bomb throws one).",
|
||||
"fear": "Crowded? Tap Fear to scare off everything nearby, and they drop what they carry.",
|
||||
"patch": "Hurt? Hold Patch to patch up with straw. Health carries over to the next night.",
|
||||
}
|
||||
|
||||
|
||||
## Touch wording (a phone, or `-- --mobile`).
|
||||
static func touch() -> bool:
|
||||
return MobilePort.active()
|
||||
|
||||
|
||||
## The screen half the move stick is on: "right" or "left", as the sticks in play have it
|
||||
## (TouchSticks.move_on_right_now(): their move_on_right, which the Swap sticks setting flips;
|
||||
## TouchSticks.MOVE_ON_RIGHT without them).
|
||||
static func move_side() -> String:
|
||||
return "right" if TouchSticks.move_on_right_now() else "left"
|
||||
|
||||
|
||||
## The screen half the attack stick is on: the other one.
|
||||
static func attack_side() -> String:
|
||||
return "left" if move_side() == "right" else "right"
|
||||
|
||||
|
||||
# --- World labels (Label3D; ScreenLabels draws them flat on phones) ---
|
||||
|
||||
## A gather point in reach (Interactions).
|
||||
static func gather() -> String:
|
||||
return "Gather" if touch() else "[E / X] Gather"
|
||||
|
||||
|
||||
## A damaged structure in reach (Interactions); cost as ResourceStore.describe gives it.
|
||||
static func repair(cost: String) -> String:
|
||||
return ("Repair (%s)" if touch() else "[E / X] Repair (%s)") % cost
|
||||
|
||||
|
||||
## A levelable structure in reach (Interactions): the level it would go to and what that costs.
|
||||
static func upgrade_to(level: int, cost: String) -> String:
|
||||
return ("Upgrade to L%d (%s)" if touch() else "[E / X] Upgrade to L%d (%s)") % [level, cost]
|
||||
|
||||
|
||||
## The workbench, in reach by day (Workbench).
|
||||
static func upgrades() -> String:
|
||||
return "Upgrades" if touch() else "[E / X] Upgrades"
|
||||
|
||||
|
||||
## The shed counter, in reach by day (ShedCounter).
|
||||
static func shop() -> String:
|
||||
return "Shop" if touch() else "[E / X] Shop"
|
||||
|
||||
|
||||
# --- Build mode ---
|
||||
|
||||
## The ghost's label when it can go down here (BuildMode).
|
||||
static func build_place() -> String:
|
||||
return "Place" if touch() else "[LMB / RT] Build"
|
||||
|
||||
|
||||
## The ghost's label over a built structure (BuildMode); the refund follows it.
|
||||
static func dismantle() -> String:
|
||||
return "Dismantle" if touch() else "[RMB / B] Dismantle"
|
||||
|
||||
|
||||
## The build bar's controls line (BuildHud).
|
||||
static func build_help() -> String:
|
||||
return "Place · Rotate · Dismantle · Done" if touch() \
|
||||
else "LMB / RT build · Z C / d-pad rotate · 1-4 / Tab pick · RMB / B dismantle or leave"
|
||||
|
||||
|
||||
## A build bar slot's heading: its number key and the structure's name (BuildHud). Phones pick by
|
||||
## tapping the slot, so there it's the name alone.
|
||||
static func build_slot(number: int, structure: String) -> String:
|
||||
return structure if touch() else "%d %s" % [number, structure]
|
||||
|
||||
|
||||
# --- Cutscenes ---
|
||||
|
||||
## The opening intro's skip hint (OpeningIntro): a long press anywhere skips it on phones.
|
||||
static func intro_skip() -> String:
|
||||
return "Hold to skip" if touch() else "Hold [Space / Enter / A] to skip"
|
||||
|
||||
|
||||
## The farmers' return's skip hint (FarmersReturn): a tap skips it on phones.
|
||||
static func return_skip() -> String:
|
||||
return "Tap to skip" if touch() else "[Space / Enter / A] skip"
|
||||
|
||||
|
||||
# --- The tutorial ---
|
||||
|
||||
## A tip's text (Tutorial): on phones its TOUCH_TIPS wording, if it has one.
|
||||
static func tip(id: String) -> String:
|
||||
if touch() and TOUCH_TIPS.has(id):
|
||||
return (TOUCH_TIPS[id] as String).format({"move": move_side(), "attack": attack_side()})
|
||||
return Tutorial.TEXT[id]
|
||||
|
||||
|
||||
## The line under each tip (Tutorial): how to hide them.
|
||||
static func tip_footer() -> String:
|
||||
return "Tip · × hides tips" if touch() else "Tip · [Backspace / Back] hide tips"
|
||||
|
||||
|
||||
# --- The first morning's sign (ReviewPanel) ---
|
||||
|
||||
## The day's paragraph.
|
||||
static func sign_day() -> String:
|
||||
if touch():
|
||||
return "By day, gather wood, scrap, and straw (hold Use), store them at the barn, and build defenses (tap Build). There's more to gather off the farm, to the north, east, and south."
|
||||
return "By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south."
|
||||
|
||||
|
||||
## The night's paragraph.
|
||||
static func sign_night() -> String:
|
||||
if touch():
|
||||
return ("At night, stab aliens with your pitchfork (%s thumb), scare them off (Fear), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons on the hotbar), and more weapons arrive there over the days." % attack_side())
|
||||
return "At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days."
|
||||
|
||||
|
||||
# --- The hotbar ---
|
||||
|
||||
## A hotbar slot's number: the key that picks its weapon (ScarecrowHud; 0: none, the off-hand's).
|
||||
## Phones pick by tapping the slot, so there it's none.
|
||||
static func hotbar_key(number: int) -> String:
|
||||
return "" if touch() or number <= 0 else str(number)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://d5ghg35h8m5
|
||||
|
|
@ -4,10 +4,6 @@ extends Control
|
|||
## beside it, and a red dot once something new has gone into it since it was last opened (gone
|
||||
## again when the pouch is emptied). The pouch action (I / R3) opens the pouch panel over it, and
|
||||
## closes it again: each material carried, and how much of each the supply shed holds.
|
||||
## On a phone (MobilePort.active()) the backpack is a hit target (ScarecrowHud.HitTarget): a tap
|
||||
## opens or closes the panel, and a finger landing anywhere else but on the panel closes it (and
|
||||
## goes on to whatever is there: a thumbstick, a button). There the panel stays inside the safe
|
||||
## area (MobilePort.safe_rect).
|
||||
|
||||
## The backpack icon, from the screen's bottom-left corner.
|
||||
const ICON := Rect2(26.0, -136.0, 108.0, 108.0)
|
||||
|
|
@ -23,11 +19,8 @@ var slot: int = 0
|
|||
var open := false
|
||||
## Something went into the pouch since it was last opened.
|
||||
var new_items := false
|
||||
## Phones: the backpack's hit target (null on desktop).
|
||||
var backpack_target: ScarecrowHud.HitTarget
|
||||
|
||||
var _last := {}
|
||||
var _phone := false
|
||||
|
||||
|
||||
func setup(p_campaign: CampaignController) -> void:
|
||||
|
|
@ -38,24 +31,6 @@ func setup(p_campaign: CampaignController) -> void:
|
|||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_phone = MobilePort.active()
|
||||
set_process_input(_phone)
|
||||
if _phone:
|
||||
backpack_target = ScarecrowHud.HitTarget.new()
|
||||
backpack_target.name = "Backpack"
|
||||
backpack_target.visible = false
|
||||
backpack_target.tapped.connect(toggle)
|
||||
add_child(backpack_target)
|
||||
|
||||
|
||||
## Phones: a finger landing outside the backpack and the open panel closes the panel. It isn't
|
||||
## taken: it goes on to the HUD's buttons and the thumbsticks.
|
||||
func _input(event: InputEvent) -> void:
|
||||
var touch := event as InputEventScreenTouch
|
||||
if touch == null or not touch.pressed or not open or campaign == null or not is_visible_in_tree():
|
||||
return
|
||||
if not backpack_target.get_global_rect().has_point(touch.position) and not panel_rect().has_point(touch.position):
|
||||
toggle()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
|
|
@ -70,22 +45,6 @@ func toggle() -> void:
|
|||
new_items = false
|
||||
|
||||
|
||||
## The backpack icon, at the screen's bottom-left.
|
||||
func icon_rect() -> Rect2:
|
||||
return Rect2(Vector2(ICON.position.x, size.y + ICON.position.y), ICON.size)
|
||||
|
||||
|
||||
## The pouch panel, over the backpack; on a phone moved inside the safe area if it isn't.
|
||||
func panel_rect() -> Rect2:
|
||||
var icon := icon_rect()
|
||||
var height := 52.0 + ResourceStore.MATERIALS.size() * ROW + 12.0 # its heading, then a row per material (rows())
|
||||
var r := Rect2(Vector2(icon.position.x - 4.0, icon.position.y - 14.0 - height), Vector2(PANEL_WIDTH, height))
|
||||
if _phone:
|
||||
var safe := MobilePort.safe_rect(self)
|
||||
r.position = r.position.clamp(safe.position, (safe.end - r.size).max(safe.position))
|
||||
return r
|
||||
|
||||
|
||||
## "6/15": what the pouch holds, of what it can.
|
||||
func count_text() -> String:
|
||||
var r := campaign.state.resources
|
||||
|
|
@ -103,9 +62,6 @@ func rows() -> Array[Dictionary]:
|
|||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if backpack_target != null:
|
||||
backpack_target.visible = campaign != null
|
||||
backpack_target.cover(icon_rect())
|
||||
if campaign == null:
|
||||
return
|
||||
var r := campaign.state.resources
|
||||
|
|
@ -122,7 +78,7 @@ func _process(_delta: float) -> void:
|
|||
func _draw() -> void:
|
||||
if campaign == null:
|
||||
return
|
||||
var icon := icon_rect()
|
||||
var icon := Rect2(Vector2(ICON.position.x, size.y + ICON.position.y), ICON.size)
|
||||
Sketch.icon(self, "backpack", icon)
|
||||
if new_items:
|
||||
var at := icon.position + Vector2(icon.size.x - 16.0, 16.0)
|
||||
|
|
@ -130,12 +86,13 @@ func _draw() -> void:
|
|||
Sketch.circle(self, at, 11.5, Sketch.INK, 2.0, 402.0)
|
||||
Sketch.text(self, Vector2(icon.end.x + 4.0, icon.get_center().y - 18.0), count_text(), 42)
|
||||
if open:
|
||||
_draw_panel()
|
||||
_draw_panel(icon)
|
||||
|
||||
|
||||
func _draw_panel() -> void:
|
||||
func _draw_panel(icon: Rect2) -> void:
|
||||
var list := rows()
|
||||
var r := panel_rect()
|
||||
var height := 52.0 + list.size() * ROW + 12.0
|
||||
var r := Rect2(Vector2(icon.position.x - 4.0, icon.position.y - 14.0 - height), Vector2(PANEL_WIDTH, height))
|
||||
Sketch.panel(self, r, 411.0)
|
||||
var pouch_x := r.position.x + 290.0
|
||||
var shed_x := r.end.x - 26.0
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ extends CenterContainer
|
|||
## Each row has its icon; a type or material with none isn't listed. "Start the day" (focused,
|
||||
## so Enter / A work) ends it. The first morning explains the vacation instead of results. It
|
||||
## stays down while the opening intro has the farm (intro.running).
|
||||
## On a phone (UiTheme's panels) the sign stands in the safe area: the paper's text scrolls
|
||||
## (drag it) and Start the day stays below it, in view and at least the touch target tall; the
|
||||
## text is narrower if need be, and in a room shorter than TIGHT (a phone's, not an iPad's) the
|
||||
## paper's margins and the posts' tops are a little shorter.
|
||||
|
||||
const CATEGORIES := ["Crops", "Animals", "Supplies"]
|
||||
const ENEMY_TYPES := [EnemySystem.TYPE_CROW, EnemySystem.TYPE_THIEF, EnemySystem.TYPE_BREAKER, EnemySystem.TYPE_UFO]
|
||||
|
|
@ -22,38 +18,13 @@ const SIDE := 64.0
|
|||
const BEAM := 92.0
|
||||
const BOTTOM := 70.0
|
||||
const WIDTH := 880.0
|
||||
## The paper's margins around its text: either side, above, and below (PHONE_SHEET in a tight
|
||||
## room, below).
|
||||
const SHEET_SIDE := 48
|
||||
const SHEET := Vector2i(26, 32)
|
||||
const PHONE_SHEET := Vector2i(14, 16)
|
||||
const START := Vector2(300.0, 62.0)
|
||||
## How far the drawing reaches past the board: the top beam's ends either side (24, and their
|
||||
## end grain), the posts above the top beam (POST_TOP, PHONE_POST_TOP in a tight room; their end
|
||||
## grain END_GRAIN more), and the posts' feet below the board (into the ground: on a phone they
|
||||
## may run past the safe area).
|
||||
const BEAM_END := 40.0
|
||||
const POST_TOP := 36.0
|
||||
const PHONE_POST_TOP := 16.0
|
||||
const END_GRAIN := 10.0
|
||||
const FEET := 52.0
|
||||
## A phone's room is shorter than this (an iPad's isn't): the paper's margins and the posts' tops
|
||||
## shrink to give the text more of it.
|
||||
const TIGHT := 1000.0
|
||||
|
||||
var campaign: CampaignController
|
||||
## Set by FarmSim: the night plans (last night's title), and the opening intro.
|
||||
var waves: WaveDirector
|
||||
var intro: OpeningIntro
|
||||
|
||||
var _safe: MarginContainer
|
||||
var _board: PanelContainer
|
||||
var _sheet: MarginContainer
|
||||
var _scroll: UiTheme.TouchScroll
|
||||
var _box: VBoxContainer
|
||||
var _start_gap: Control
|
||||
var _post_top := POST_TOP
|
||||
var _fit_queued := false
|
||||
var _title: Label
|
||||
var _last_head: Label
|
||||
var _rule: HSeparator
|
||||
|
|
@ -77,8 +48,6 @@ func setup(p_campaign: CampaignController) -> void:
|
|||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
theme = UiTheme.sketch()
|
||||
_safe = MarginContainer.new() # the safe area's margins on a phone (none on desktop)
|
||||
add_child(_safe)
|
||||
_board = PanelContainer.new()
|
||||
var margins := StyleBoxEmpty.new()
|
||||
margins.content_margin_left = SIDE
|
||||
|
|
@ -86,7 +55,7 @@ func _ready() -> void:
|
|||
margins.content_margin_bottom = BOTTOM
|
||||
_board.add_theme_stylebox_override("panel", margins)
|
||||
_board.draw.connect(_draw_board)
|
||||
_safe.add_child(_board)
|
||||
add_child(_board)
|
||||
var column := VBoxContainer.new()
|
||||
column.add_theme_constant_override("separation", 0)
|
||||
_board.add_child(column)
|
||||
|
|
@ -96,23 +65,16 @@ func _ready() -> void:
|
|||
_title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_title.custom_minimum_size = Vector2(0.0, BEAM)
|
||||
column.add_child(_title)
|
||||
_sheet = MarginContainer.new()
|
||||
var sheet := MarginContainer.new()
|
||||
for side: String in ["left", "right"]:
|
||||
_sheet.add_theme_constant_override("margin_" + side, SHEET_SIDE)
|
||||
_sheet.add_theme_constant_override("margin_top", SHEET.x)
|
||||
_sheet.add_theme_constant_override("margin_bottom", SHEET.y)
|
||||
column.add_child(_sheet)
|
||||
var page := VBoxContainer.new() # the paper: its text (scrolling on a phone), then Start the day
|
||||
page.add_theme_constant_override("separation", 10)
|
||||
_sheet.add_child(page)
|
||||
_scroll = UiTheme.TouchScroll.new(Sketch.PAPER_INK)
|
||||
page.add_child(_scroll)
|
||||
sheet.add_theme_constant_override("margin_" + side, 48)
|
||||
sheet.add_theme_constant_override("margin_top", 26)
|
||||
sheet.add_theme_constant_override("margin_bottom", 32)
|
||||
column.add_child(sheet)
|
||||
var box := VBoxContainer.new()
|
||||
box.custom_minimum_size = Vector2(WIDTH, 0.0)
|
||||
box.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
box.add_theme_constant_override("separation", 10)
|
||||
_scroll.add_child(box)
|
||||
_box = box
|
||||
sheet.add_child(box)
|
||||
_last_head = _ink(box, 38)
|
||||
_last_head.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_rule = HSeparator.new()
|
||||
|
|
@ -162,7 +124,7 @@ func _ready() -> void:
|
|||
_intro.add_theme_constant_override("paragraph_spacing", 14)
|
||||
_start = Button.new()
|
||||
_start.text = "Start the day"
|
||||
_start.custom_minimum_size = START
|
||||
_start.custom_minimum_size = Vector2(300.0, 62.0)
|
||||
_start.add_theme_font_size_override("font_size", 32)
|
||||
_start.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
var wood := {
|
||||
|
|
@ -173,12 +135,9 @@ func _ready() -> void:
|
|||
for key: String in wood:
|
||||
_start.add_theme_stylebox_override(key, wood[key])
|
||||
_start.pressed.connect(func() -> void: campaign.begin_day())
|
||||
_start_gap = _spacer(6.0)
|
||||
page.add_child(_start_gap)
|
||||
page.add_child(_start)
|
||||
box.add_child(_spacer(6.0))
|
||||
box.add_child(_start)
|
||||
visible = false
|
||||
box.minimum_size_changed.connect(_queue_fit) # the text reflowed (a new width, new results)
|
||||
get_viewport().size_changed.connect(_queue_fit)
|
||||
|
||||
|
||||
## The dark, nearly opaque panel behind the menus and the end screens.
|
||||
|
|
@ -208,8 +167,8 @@ func refresh() -> void:
|
|||
_title.text = "The farmers are away"
|
||||
_intro.text = "\n".join([
|
||||
"Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights,
|
||||
Prompts.sign_day(),
|
||||
Prompts.sign_night(),
|
||||
"By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.",
|
||||
"At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.",
|
||||
])
|
||||
else:
|
||||
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
||||
|
|
@ -219,53 +178,10 @@ func refresh() -> void:
|
|||
_fill_grid(e)
|
||||
_fill_list(_enemies, _no_enemies, func(t: int) -> int: return int(e.get("killed_" + EnemySystem.TYPE_NAMES[t], 0)))
|
||||
_fill_list(_materials, _no_materials, func(m: String) -> int: return int(e.get("gathered_" + m, 0)))
|
||||
_fit()
|
||||
_scroll.scroll_vertical = 0 # each morning's sheet from its top
|
||||
_board.queue_redraw()
|
||||
_focus_start.call_deferred()
|
||||
|
||||
|
||||
## Lays the sign out for the screen: on desktop as it always was; on a phone (UiTheme's panels)
|
||||
## inside the safe area (its posts' tops and its top beam's ends too), as wide as that allows up
|
||||
## to WIDTH, with the paper's text scrolling past what the height leaves for it.
|
||||
func _fit() -> void:
|
||||
var phone := MobilePort.active()
|
||||
var room := UiTheme.panel_room(self) if phone else Rect2()
|
||||
var tight := phone and room.size.y < TIGHT
|
||||
_scroll.set_phone(phone)
|
||||
_post_top = PHONE_POST_TOP if tight else POST_TOP
|
||||
var sheet := PHONE_SHEET if tight else SHEET
|
||||
UiTheme.set_constant(_sheet, "margin_top", sheet.x)
|
||||
UiTheme.set_constant(_sheet, "margin_bottom", sheet.y)
|
||||
_start_gap.visible = not tight
|
||||
_start.custom_minimum_size = Vector2(START.x, maxf(START.y, MobilePort.minimum_target(self))) if phone else START
|
||||
if not phone:
|
||||
UiTheme.fit_margins(_safe, Rect2())
|
||||
_box.custom_minimum_size.x = WIDTH
|
||||
return
|
||||
var top := _post_top + END_GRAIN
|
||||
UiTheme.fit_margins(_safe, room, Vector4(BEAM_END, top, BEAM_END, 0.0))
|
||||
var frame := 2.0 * (BEAM_END + SIDE + SHEET_SIDE) + _scroll.frame_width()
|
||||
_box.custom_minimum_size.x = floorf(minf(WIDTH, room.size.x - frame))
|
||||
var others := _board.get_combined_minimum_size().y - _scroll.get_combined_minimum_size().y
|
||||
_scroll.fit(room.size.y - top - others)
|
||||
_board.queue_redraw()
|
||||
|
||||
|
||||
## Fits again once this frame's changes are in (the text reflowed, the screen changed size).
|
||||
func _queue_fit() -> void:
|
||||
if _fit_queued or not visible:
|
||||
return
|
||||
_fit_queued = true
|
||||
_refit.call_deferred()
|
||||
|
||||
|
||||
func _refit() -> void:
|
||||
_fit_queued = false
|
||||
if visible:
|
||||
_fit()
|
||||
|
||||
|
||||
## Start the day takes the focus (unless the sign went down again meanwhile: a hidden button
|
||||
## would still take Enter).
|
||||
func _focus_start() -> void:
|
||||
|
|
@ -373,10 +289,9 @@ func _draw_board() -> void:
|
|||
var h := b.size.y
|
||||
var paper := Rect2(SIDE - 14.0, BEAM - 26.0, w - 2.0 * SIDE + 28.0, h - BEAM - BOTTOM + 52.0)
|
||||
var posts: Array[float] = [SIDE + 34.0, w - SIDE - 34.0]
|
||||
var reach := _post_top + h + FEET # a post's length, from its top to its feet
|
||||
for k in 2:
|
||||
b.draw_set_transform(Vector2(posts[k], (h + FEET - _post_top) * 0.5), PI * 0.5)
|
||||
Sketch.plank(b, Rect2(-reach * 0.5, -27.0, reach, 54.0), Sketch.WOOD.darkened(0.08), 601.0 + k)
|
||||
b.draw_set_transform(Vector2(posts[k], h * 0.5 + 8.0), PI * 0.5)
|
||||
Sketch.plank(b, Rect2(-h * 0.5 - 44.0, -27.0, h + 88.0, 54.0), Sketch.WOOD.darkened(0.08), 601.0 + k)
|
||||
b.draw_set_transform_matrix(Transform2D.IDENTITY)
|
||||
Sketch.paper(b, paper, 611.0)
|
||||
Sketch.plank(b, Rect2(0.0, h - BOTTOM - 4.0, w, 62.0), Sketch.WOOD.darkened(0.04), 621.0)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ extends Node3D
|
|||
## * Health lives in FarmState and carries over between nights (D7). try_damage() is the only
|
||||
## way to hurt the scarecrow: after an accepted hit it is invulnerable for
|
||||
## invulnerability_time, so several hits on one tick cost one hit's damage. Hits blink the
|
||||
## model red, tint the screen (ScarecrowHud), and interrupt patching. On a phone with the
|
||||
## Haptics setting on (haptics, set by GameSettings), the local scarecrow's hits buzz.
|
||||
## model red, tint the screen (ScarecrowHud), and interrupt patching.
|
||||
## * Fear (fear action): every thief within fear_radius flees for fear_duration; carriers
|
||||
## drop their crop (D5) and thieves mid-steal lose their progress. Then fear_cooldown
|
||||
## seconds until the next one. A ring under the scarecrow shows that fear is ready.
|
||||
|
|
@ -28,14 +27,6 @@ signal patch_cancelled
|
|||
signal patch_denied(missing: Dictionary)
|
||||
|
||||
const BURST_TIME := 0.45
|
||||
## A hit's buzz on a phone, in milliseconds.
|
||||
const HIT_BUZZ_MS := 30
|
||||
|
||||
## Whether an accepted hit buzzes the phone: the Haptics setting on a phone (GameSettings.apply
|
||||
## sets it on every change). Read once per hit, never per frame.
|
||||
static var haptics := false
|
||||
## Buzzes so far (buzz()), for tests: the vibration itself can't be observed.
|
||||
static var buzzes := 0
|
||||
|
||||
var config: GameConfig
|
||||
var campaign: CampaignController
|
||||
|
|
@ -190,20 +181,12 @@ func try_damage(amount: int = 1) -> bool:
|
|||
s.record_event("scarecrow_damage", mini(amount, hp()))
|
||||
_set_hp(hp() - amount)
|
||||
cancel_patch()
|
||||
if haptics and remote == null: # (the host's kit for its partner doesn't buzz the host)
|
||||
buzz()
|
||||
damaged.emit(hp())
|
||||
if hp() <= 0:
|
||||
_die()
|
||||
return true
|
||||
|
||||
|
||||
## A short buzz (Input.vibrate_handheld; nothing on desktop), counted in buzzes.
|
||||
static func buzz() -> void:
|
||||
buzzes += 1
|
||||
Input.vibrate_handheld(HIT_BUZZ_MS)
|
||||
|
||||
|
||||
## Fear burst at the scarecrow. Returns how many thieves fled, or -1 if it isn't ready.
|
||||
func use_fear() -> int:
|
||||
if not alive or fear_left > 0.0:
|
||||
|
|
|
|||
|
|
@ -5,16 +5,14 @@ extends Control
|
|||
## arc sweeping round while fear recharges, glowing blue when it's ready (a flash as it
|
||||
## becomes ready); greyed out while the scarecrow is down. Beside it the health bar, one
|
||||
## segment per point of max health (red filled, grey empty; while patching, the segments the
|
||||
## patch will fill fill in).
|
||||
## patch will fill fill in), and under it, once the Sprint upgrade is bought, a thin green
|
||||
## bar: the sprint's stamina (draining while sprinting, filling back while it recharges).
|
||||
## * Bottom-center: the hotbar, one slot per main weapon owned (locked ones aren't shown),
|
||||
## numbered by the key that picks it (ScarecrowCombat.owned_main: weapon_k picks slot k), the
|
||||
## one in hand highlighted; then past a divider the off-hand weapons owned (pumpkin bombs), in a
|
||||
## bolder frame, darkened from the top while a bomb recharges. Hidden in build mode (BuildHud
|
||||
## has the bottom then).
|
||||
## * A red tint over the screen when the scarecrow is hit.
|
||||
## On a phone (MobilePort.active()) each main weapon's slot is a hit target (HitTarget, below): a
|
||||
## tap picks that weapon as its number key does (tap_slot), and the slots show no numbers
|
||||
## (Prompts.hotbar_key). The off-hand's slot isn't one (there's nothing to pick; Bomb throws).
|
||||
|
||||
const PORTRAIT_CENTER := Vector2(78.0, 76.0)
|
||||
const PORTRAIT_RADIUS := 50.0
|
||||
|
|
@ -26,8 +24,10 @@ const SEGMENT_SKEW := 7.0
|
|||
## The health bar grows a segment per point of max health up to this width, then its segments
|
||||
## get narrower.
|
||||
const BAR_MAX_WIDTH := 360.0
|
||||
const STAMINA_HEIGHT := 6.0
|
||||
const HEALTH := Color(0.88, 0.14, 0.12)
|
||||
const EMPTY := Color(0.62, 0.62, 0.6, 0.85)
|
||||
const STAMINA := Color(0.3, 0.9, 0.25)
|
||||
const SLOT := Vector2(78.0, 72.0)
|
||||
const SLOT_GAP := 16.0
|
||||
const DIVIDER_GAP := 30.0
|
||||
|
|
@ -39,11 +39,7 @@ var combat: ScarecrowCombat
|
|||
var campaign: CampaignController
|
||||
## Set by FarmSim: the hotbar hides in build mode.
|
||||
var build: BuildMode
|
||||
## Phones: the main weapons' slots' hit targets, left to right (the ones past the slots shown are
|
||||
## hidden). Empty on desktop.
|
||||
var slot_targets: Array[HitTarget] = []
|
||||
|
||||
var _phone := false
|
||||
var _tint: ColorRect
|
||||
var _hit: float = 0.0
|
||||
var _ready_flash: float = 0.0
|
||||
|
|
@ -82,7 +78,6 @@ func _ready() -> void:
|
|||
_tint.color = Color(0.85, 0.05, 0.0, 0.0)
|
||||
_tint.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(_tint)
|
||||
_phone = MobilePort.active()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
@ -90,87 +85,43 @@ func _process(delta: float) -> void:
|
|||
_hit = maxf(_hit - delta * 2.5, 0.0)
|
||||
_ready_flash = maxf(_ready_flash - delta * 2.0, 0.0)
|
||||
_tint.color.a = 0.22 * _hit
|
||||
if _phone:
|
||||
_place_targets()
|
||||
queue_redraw()
|
||||
|
||||
|
||||
## Whether the green stamina bar shows: only once the Sprint upgrade is bought.
|
||||
func stamina_shown() -> bool:
|
||||
var body := kit.player if kit != null else null
|
||||
return body != null and body.config != null and body.can_sprint()
|
||||
|
||||
|
||||
## The green bar's fill, 0..1: the sprint left while sprinting, its recharge after, else full.
|
||||
func stamina() -> float:
|
||||
if not stamina_shown():
|
||||
return 1.0
|
||||
var body := kit.player
|
||||
if body.sprinting:
|
||||
return clampf(body.sprint_left / maxf(body.config.sprint_time, 0.001), 0.0, 1.0)
|
||||
if body.sprint_recharge > 0.0:
|
||||
return clampf(1.0 - body.sprint_recharge / maxf(body.config.sprint_cooldown, 0.001), 0.0, 1.0)
|
||||
return 1.0
|
||||
|
||||
|
||||
## The hotbar's slots as shown, left to right: {weapon, key (the number that picks it; 0 for
|
||||
## the off-hand), label (the number drawn in the slot: Prompts.hotbar_key), offhand, selected}.
|
||||
## Empty while it's hidden (build mode, no weapons).
|
||||
## the off-hand), offhand, selected}. Empty while it's hidden (build mode, no weapons).
|
||||
func slots() -> Array[Dictionary]:
|
||||
var out: Array[Dictionary] = []
|
||||
if combat == null or (build != null and build.active):
|
||||
return out
|
||||
var owned := combat.owned_main()
|
||||
for k in owned.size():
|
||||
var key := k + 1 if k < ScarecrowCombat.SWITCH_ACTIONS.size() - 1 else 0
|
||||
out.append({"weapon": owned[k], "key": key, "label": Prompts.hotbar_key(key),
|
||||
out.append({"weapon": owned[k], "key": k + 1 if k < ScarecrowCombat.SWITCH_ACTIONS.size() - 1 else 0,
|
||||
"offhand": false, "selected": owned[k] == combat.weapon})
|
||||
for w in ScarecrowCombat.OFFHAND_WEAPONS:
|
||||
if combat.owns(w):
|
||||
out.append({"weapon": w, "key": 0, "label": Prompts.hotbar_key(0), "offhand": true, "selected": _offhand_lit(w)})
|
||||
out.append({"weapon": w, "key": 0, "offhand": true, "selected": _offhand_lit(w)})
|
||||
return out
|
||||
|
||||
|
||||
## Where the slots (slots()) are drawn, left to right, before the one in hand is raised: centered
|
||||
## at the screen's bottom, the off-hand's past a divider.
|
||||
func slot_rects(list: Array[Dictionary]) -> Array[Rect2]:
|
||||
var out: Array[Rect2] = []
|
||||
var mains := 0
|
||||
for s in list:
|
||||
if not s["offhand"]:
|
||||
mains += 1
|
||||
var width := list.size() * SLOT.x + (list.size() - 1) * SLOT_GAP + (DIVIDER_GAP * 2.0 - SLOT_GAP if mains < list.size() else 0.0)
|
||||
var x := (size.x - width) * 0.5
|
||||
var y := size.y - HOTBAR_BOTTOM - SLOT.y
|
||||
for i in list.size():
|
||||
if i == mains and i > 0:
|
||||
x += DIVIDER_GAP * 2.0 - SLOT_GAP
|
||||
out.append(Rect2(Vector2(x, y), SLOT))
|
||||
x += SLOT.x + SLOT_GAP
|
||||
return out
|
||||
|
||||
|
||||
## A tap on main slot i (phones): picks its weapon as its number key does, through the same path
|
||||
## (ScarecrowCombat notes weapon_k, and takes it up on its next tick only when it may switch: not
|
||||
## in build mode, frozen, or under a menu).
|
||||
func tap_slot(i: int) -> void:
|
||||
var list := slots()
|
||||
if i < 0 or i >= list.size() or list[i]["offhand"] or int(list[i]["key"]) <= 0:
|
||||
return
|
||||
_press_switch.call_deferred(ScarecrowCombat.SWITCH_ACTIONS[int(list[i]["key"])]) # outside the touch's dispatch
|
||||
|
||||
|
||||
func _press_switch(action: StringName) -> void:
|
||||
for pressed in [true, false]:
|
||||
var e := InputEventAction.new()
|
||||
e.action = action
|
||||
e.pressed = pressed
|
||||
Input.parse_input_event(e)
|
||||
|
||||
|
||||
## Phones: a hit target over each main weapon's slot.
|
||||
func _place_targets() -> void:
|
||||
var list := slots()
|
||||
var rects := slot_rects(list)
|
||||
var n := 0
|
||||
for i in list.size():
|
||||
if list[i]["offhand"]:
|
||||
continue
|
||||
if n == slot_targets.size():
|
||||
var target := HitTarget.new()
|
||||
target.name = "Slot%d" % (n + 1)
|
||||
target.tapped.connect(tap_slot.bind(n)) # (the main slots come first: slot n is list[n])
|
||||
add_child(target)
|
||||
slot_targets.append(target)
|
||||
slot_targets[n].cover(rects[i])
|
||||
slot_targets[n].visible = true
|
||||
n += 1
|
||||
for k in range(n, slot_targets.size()):
|
||||
slot_targets[k].visible = false
|
||||
|
||||
|
||||
## Whether the off-hand weapon is in the off-hand and ready (a pumpkin bomb not recharging).
|
||||
func _offhand_lit(w: int) -> bool:
|
||||
return w == combat.offhand and not (w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0)
|
||||
|
|
@ -212,6 +163,7 @@ func _draw_health() -> void:
|
|||
var hp := kit.hp()
|
||||
var step := minf(SEGMENT.x + SEGMENT_GAP, (BAR_MAX_WIDTH + SEGMENT_GAP) / top)
|
||||
var seg := Vector2(maxf(step - SEGMENT_GAP, 4.0), SEGMENT.y)
|
||||
var width := step * top - SEGMENT_GAP
|
||||
var healing := 0
|
||||
var heal_frac := 0.0
|
||||
if kit.patching:
|
||||
|
|
@ -227,6 +179,16 @@ func _draw_health() -> void:
|
|||
if i < hp: # a darker stroke along the bottom, like paint pooling
|
||||
Sketch.line(self, at + Vector2(3.0, seg.y - 4.0), at + Vector2(seg.x - 3.0, seg.y - 4.0), full.darkened(0.3), 3.0, 60.0 + i, 0.6)
|
||||
Sketch.outline(self, pts, Color(Sketch.INK, 0.55), 1.5, 80.0 + i, 0.8, 1)
|
||||
if not stamina_shown():
|
||||
return
|
||||
# The stamina bar, as wide as the health bar.
|
||||
var bar := Rect2(BAR_ORIGIN + Vector2(0.0, SEGMENT.y + 12.0), Vector2(maxf(width, 120.0), STAMINA_HEIGHT))
|
||||
var y := bar.get_center().y
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(Sketch.INK, 0.6), STAMINA_HEIGHT + 3.0, 101.0, 0.6)
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(0.16, 0.3, 0.14, 0.9), STAMINA_HEIGHT, 101.0, 0.6)
|
||||
var fill := stamina()
|
||||
if fill > 0.0:
|
||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.position.x + bar.size.x * fill, y), STAMINA, STAMINA_HEIGHT, 102.0, 0.6)
|
||||
|
||||
|
||||
## A health segment: a slanted brush stroke.
|
||||
|
|
@ -241,14 +203,21 @@ func _draw_hotbar() -> void:
|
|||
var list := slots()
|
||||
if list.is_empty():
|
||||
return
|
||||
var rects := slot_rects(list)
|
||||
var mains := 0
|
||||
for s in list:
|
||||
if not s["offhand"]:
|
||||
mains += 1
|
||||
var width := list.size() * SLOT.x + (list.size() - 1) * SLOT_GAP + (DIVIDER_GAP * 2.0 - SLOT_GAP if mains < list.size() else 0.0)
|
||||
var x := (size.x - width) * 0.5
|
||||
var y := size.y - HOTBAR_BOTTOM - SLOT.y
|
||||
for i in list.size():
|
||||
var s: Dictionary = list[i]
|
||||
var w: int = s["weapon"]
|
||||
var r := rects[i]
|
||||
if i > 0 and s["offhand"] and not list[i - 1]["offhand"]:
|
||||
var div := rects[i - 1].end.x + DIVIDER_GAP
|
||||
Sketch.line(self, Vector2(div, r.position.y - 10.0), Vector2(div, r.end.y + 12.0), Sketch.INK, 3.0, 200.0, 1.5)
|
||||
if i == mains and i > 0:
|
||||
var div := x - SLOT_GAP + DIVIDER_GAP
|
||||
Sketch.line(self, Vector2(div, y - 10.0), Vector2(div, y + SLOT.y + 12.0), Sketch.INK, 3.0, 200.0, 1.5)
|
||||
x += DIVIDER_GAP * 2.0 - SLOT_GAP
|
||||
var r := Rect2(Vector2(x, y), SLOT)
|
||||
var lit: bool = s["selected"] and not s["offhand"] # the off-hand's ready shows by not being darkened
|
||||
if lit:
|
||||
r = r.grow(3.0)
|
||||
|
|
@ -262,37 +231,6 @@ func _draw_hotbar() -> void:
|
|||
Color(0.04, 0.05, 0.04, 0.6))
|
||||
if lit:
|
||||
Sketch.box(self, r.grow(2.0), Color(0, 0, 0, 0), Sketch.GOLD, 3.5, 240.0 + i)
|
||||
if s["label"] != "":
|
||||
Sketch.text(self, r.position + Vector2(7.0, 1.0), s["label"], 20, Sketch.TEXT, HORIZONTAL_ALIGNMENT_LEFT, 6)
|
||||
|
||||
|
||||
## A phone's hit target (only on a phone: MobilePort.active()) over a widget the HUD draws: a STOP
|
||||
## Control over the widget only, at least MobilePort.minimum_target() across (so it may reach past
|
||||
## a small widget). A finger on it is the widget's and starts no thumbstick (TouchSticks takes
|
||||
## only the touches the HUD leaves); beside it the screen is the sticks'. tapped comes when a
|
||||
## finger lands on it (or, in the desktop preview, on a click); the tap's emulated click (Godot's
|
||||
## touch-to-mouse) is taken without counting twice. The HUD's slots, the backpack (ResourceHud),
|
||||
## the tip box's × (Tutorial), and the conversation's Skip (DialogueBox) are these.
|
||||
class HitTarget extends Control:
|
||||
signal tapped
|
||||
|
||||
func _init() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
focus_mode = Control.FOCUS_NONE
|
||||
|
||||
## Covers r (in the parent's coordinates), grown about its center to the minimum target.
|
||||
func cover(r: Rect2) -> void:
|
||||
var least := MobilePort.minimum_target(self)
|
||||
var s := r.size.max(Vector2(least, least))
|
||||
position = r.get_center() - s * 0.5
|
||||
size = s
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
var touch := event as InputEventScreenTouch
|
||||
var click := event as InputEventMouseButton
|
||||
if touch == null and click == null:
|
||||
return
|
||||
accept_event()
|
||||
if (touch != null and touch.pressed) or (click != null and click.pressed and click.button_index == MOUSE_BUTTON_LEFT
|
||||
and click.device != InputEvent.DEVICE_ID_EMULATION):
|
||||
tapped.emit()
|
||||
if int(s["key"]) > 0:
|
||||
Sketch.text(self, r.position + Vector2(7.0, 1.0), str(s["key"]), 20, Sketch.TEXT, HORIZONTAL_ALIGNMENT_LEFT, 6)
|
||||
x += SLOT.x + SLOT_GAP
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
class_name ScreenLabels
|
||||
extends Control
|
||||
## Draws the farm's Label3Ds as flat text over the 3D view, so they stay sharp and readable when
|
||||
## the 3D view is pixelated (GameSettings.pixel_size) and at a phone's interface scale. There's one
|
||||
## per game (ensure()): ToonLook's on desktop, which tracks every Label3D, and on phones (no
|
||||
## ToonLook, MobilePort) Main's, which watch()es the tree for them itself. A tracked
|
||||
## the 3D view is pixelated (GameSettings.pixel_size). ToonLook tracks every Label3D; a tracked
|
||||
## label stops rendering in 3D (layers 0) and is drawn here instead, centered on where it projects,
|
||||
## with its text, colors, and outline (in the HUD's handwritten font, Sketch, unless it has its own
|
||||
## font), at the size it would have on screen (times the interface scale, the window's
|
||||
## content_scale_factor: phones', MobilePort; 1 on desktop) but never smaller than
|
||||
## font), at the size it would have on screen but never smaller than
|
||||
## MIN_SIZE (far-off ones, under HIDE_BELOW, aren't drawn at all). Labels that would overlap are
|
||||
## nudged apart: the lowest on screen keeps its place and the ones over it move up clear of it.
|
||||
## The game's labels are all
|
||||
|
|
@ -18,30 +15,11 @@ extends Control
|
|||
const MIN_SIZE := 16.0 # canvas pixels (1080 high): smaller labels are drawn at this size...
|
||||
const HIDE_BELOW := 6.0 # ...unless they'd be this small on screen, when they're not drawn
|
||||
const GAP := 2.0 # canvas pixels between labels nudged apart
|
||||
const GROUP := &"screen_labels"
|
||||
|
||||
var _labels: Array = [] # Label3D; untyped, so freed ones can be dropped
|
||||
|
||||
|
||||
## The game's ScreenLabels: the one in the tree already, else a new one under host (which must
|
||||
## be in the tree) on its own CanvasLayer, "Labels", over the 3D view and under the HUD (1) and
|
||||
## the menus (10). ToonLook and Main (on phones) both get theirs here, so there's never two.
|
||||
static func ensure(host: Node) -> ScreenLabels:
|
||||
for n in host.get_tree().get_nodes_in_group(GROUP):
|
||||
if not n.is_queued_for_deletion():
|
||||
return n as ScreenLabels
|
||||
var layer := CanvasLayer.new()
|
||||
layer.name = "Labels"
|
||||
layer.layer = -1
|
||||
var labels := ScreenLabels.new()
|
||||
labels.name = "ScreenLabels"
|
||||
layer.add_child(labels)
|
||||
host.add_child(layer)
|
||||
return labels
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group(GROUP)
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
|
|
@ -53,20 +31,6 @@ func track(label: Label3D) -> void:
|
|||
_labels.append(label)
|
||||
|
||||
|
||||
## Without ToonLook to hand them over (phones): tracks every Label3D under root, and from now on
|
||||
## each one as it enters the tree.
|
||||
func watch(root: Node) -> void:
|
||||
for l in root.find_children("*", "Label3D", true, false):
|
||||
track(l as Label3D)
|
||||
if not get_tree().node_added.is_connected(_on_node_added):
|
||||
get_tree().node_added.connect(_on_node_added)
|
||||
|
||||
|
||||
func _on_node_added(node: Node) -> void:
|
||||
if node is Label3D:
|
||||
track(node as Label3D)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
queue_redraw()
|
||||
|
||||
|
|
@ -81,7 +45,6 @@ func entries() -> Array[Dictionary]:
|
|||
if cam == null:
|
||||
return out
|
||||
var up := cam.global_basis.y
|
||||
var ui := get_window().content_scale_factor # the interface scale (phones; 1 on desktop): labels grow with the HUD
|
||||
var fallback := Sketch.font()
|
||||
for l: Label3D in _labels:
|
||||
if l.text == "" or not l.is_visible_in_tree():
|
||||
|
|
@ -90,7 +53,7 @@ func entries() -> Array[Dictionary]:
|
|||
if cam.is_position_behind(world):
|
||||
continue
|
||||
var at := cam.unproject_position(world) # already in canvas units (the stretched 1080-high view)
|
||||
var tall := at.distance_to(cam.unproject_position(world + up * l.font_size * l.pixel_size)) * ui
|
||||
var tall := at.distance_to(cam.unproject_position(world + up * l.font_size * l.pixel_size))
|
||||
if tall < HIDE_BELOW:
|
||||
continue
|
||||
var scale := maxf(tall, MIN_SIZE) / l.font_size
|
||||
|
|
|
|||
|
|
@ -10,35 +10,10 @@ extends CenterContainer
|
|||
## Co-op your name (the lobby and your name tag), and your microphone for voice chat
|
||||
## (not on phones: MobilePort)
|
||||
## Every change is applied and saved at once (changed); Back or Escape / B closes it.
|
||||
## On a phone (MobilePort) the list is shorter and made for fingers:
|
||||
## Audio as on desktop
|
||||
## Touch Interface size, Swap sticks, Camera distance, Haptics, then how the touch
|
||||
## controls work (touch_guide, in place of the bindings)
|
||||
## Display 3D resolution scale
|
||||
## Gameplay tips on the first day and night
|
||||
## (no dead zones, Fullscreen, VSync, pixel size, mouse note, or co-op; Reset to defaults leaves
|
||||
## those alone). The panel fills the safe area (fit), its rows are at least the minimum touch
|
||||
## target tall, and the list scrolls by dragging anywhere on it. A slider only takes a finger that
|
||||
## moves mostly sideways (TouchSlider), so scrolling never nudges a value; the Interface size
|
||||
## applies when its finger lifts (the whole menu rescales with it).
|
||||
|
||||
signal changed
|
||||
signal closed
|
||||
|
||||
const PANEL_MARGIN := 28
|
||||
const BUTTON_HEIGHT := 54.0
|
||||
const SCROLL_SIZE := Vector2(980.0, 640.0)
|
||||
## Phones: a safe area shorter than this (a phone's; not an iPad's) gets the compact panel.
|
||||
const COMPACT_HEIGHT := 800.0
|
||||
## Phones: the panel keeps this far inside the safe area.
|
||||
const EDGE := 8.0
|
||||
## Phones: how far a finger moves (points) before it scrolls the list or takes a slider.
|
||||
const DRAG_SLOP_PT := 10.0
|
||||
## Phones: the setting that applies when its slider's finger lifts, not while it moves.
|
||||
const ON_RELEASE := "interface_size"
|
||||
## Shown here, but Reset to defaults leaves them alone (co-op's).
|
||||
const KEEP_ON_RESET: Array[String] = ["player_name", "microphone"]
|
||||
|
||||
## (label, actions) shown in the bindings list.
|
||||
const BINDINGS := [
|
||||
["Move", []],
|
||||
|
|
@ -68,54 +43,34 @@ const PAD_BUTTONS := {
|
|||
var settings: GameSettings
|
||||
var is_open := false
|
||||
var back_button: Button
|
||||
var reset_button: Button
|
||||
## Controls by setting, for tests: "volume/Master", "move_dead_zone", "aim_dead_zone",
|
||||
## "fullscreen", "vsync", "resolution_scale", "show_tips"; on phones "interface_size",
|
||||
## "swap_sticks", "camera_distance", "haptics" instead of the dead zones, Fullscreen, VSync, and
|
||||
## the pixel size.
|
||||
## "fullscreen", "vsync", "resolution_scale", "show_tips".
|
||||
var controls := {}
|
||||
|
||||
var _box: VBoxContainer
|
||||
var _scroll: ScrollContainer
|
||||
var _values := {} # setting -> value Label
|
||||
var _loading := false
|
||||
var _phone := false
|
||||
var _panel: PanelContainer
|
||||
var _margin: MarginContainer
|
||||
var _outer: VBoxContainer
|
||||
var _title: Label
|
||||
var _tall: Array[Control] = [] # phones: the rows, at least the minimum touch target tall
|
||||
var _guide: Array[Label] = []
|
||||
## Phones: the finger dragging the list (drag_begin), and whether it has started scrolling it.
|
||||
var _drag_on := false
|
||||
var _drag_scrolling := false
|
||||
var _drag_from := Vector2.ZERO
|
||||
var _drag_start := 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_phone = MobilePort.active()
|
||||
var panel := PanelContainer.new()
|
||||
add_child(panel)
|
||||
_panel = panel
|
||||
var margin := MarginContainer.new()
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
margin.add_theme_constant_override("margin_" + side, PANEL_MARGIN)
|
||||
margin.add_theme_constant_override("margin_" + side, 28)
|
||||
panel.add_child(margin)
|
||||
_margin = margin
|
||||
var outer := VBoxContainer.new()
|
||||
outer.add_theme_constant_override("separation", 14)
|
||||
margin.add_child(outer)
|
||||
_outer = outer
|
||||
var title := Label.new()
|
||||
_title = title
|
||||
title.text = "Settings"
|
||||
title.add_theme_font_size_override("font_size", 44)
|
||||
title.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
outer.add_child(title)
|
||||
_scroll = ScrollContainer.new()
|
||||
_scroll.custom_minimum_size = SCROLL_SIZE
|
||||
_scroll.custom_minimum_size = Vector2(980.0, 640.0)
|
||||
_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
_scroll.follow_focus = true
|
||||
outer.add_child(_scroll)
|
||||
|
|
@ -126,30 +81,20 @@ func _ready() -> void:
|
|||
_head("Audio")
|
||||
for bus in GameSettings.BUSES:
|
||||
_slider("volume/" + bus, GameSettings.BUS_NAMES[bus], 0.0, 1.0, 0.05)
|
||||
if _phone:
|
||||
_head("Touch")
|
||||
_slider("interface_size", "Interface size", GameSettings.INTERFACE_SIZE_MIN, GameSettings.INTERFACE_SIZE_MAX, 0.05)
|
||||
_check("swap_sticks", "Swap the sticks (move on the %s)" % ("left" if TouchSticks.MOVE_ON_RIGHT else "right"))
|
||||
_slider("camera_distance", "Camera distance", GameSettings.CAMERA_DISTANCE_MIN, GameSettings.CAMERA_DISTANCE_MAX, 1.0)
|
||||
_check("haptics", "Buzz when the scarecrow is hit")
|
||||
_touch_guide()
|
||||
_head("Display")
|
||||
_slider("resolution_scale", "3D resolution scale", 0.5, 1.0, 0.05)
|
||||
else:
|
||||
_head("Controls")
|
||||
_slider("move_dead_zone", "Move stick dead zone", 0.05, 0.9, 0.05)
|
||||
_slider("aim_dead_zone", "Aim stick dead zone", 0.05, 0.9, 0.05)
|
||||
_note("Mouse aim follows the cursor directly, so it has no sensitivity to set.")
|
||||
_bindings()
|
||||
_head("Display")
|
||||
_check("fullscreen", "Fullscreen")
|
||||
_check("vsync", "VSync")
|
||||
_slider("pixel_size", "Pixel size", 1.0, GameSettings.MAX_PIXEL_SIZE, 1.0)
|
||||
_slider("resolution_scale", "3D resolution scale", 0.5, 1.0, 0.05)
|
||||
_note("Pixel size 1 turns the pixel look off; the resolution scale is used only then.")
|
||||
_head("Controls")
|
||||
_slider("move_dead_zone", "Move stick dead zone", 0.05, 0.9, 0.05)
|
||||
_slider("aim_dead_zone", "Aim stick dead zone", 0.05, 0.9, 0.05)
|
||||
_note("Mouse aim follows the cursor directly, so it has no sensitivity to set.")
|
||||
_bindings()
|
||||
_head("Display")
|
||||
_check("fullscreen", "Fullscreen")
|
||||
_check("vsync", "VSync")
|
||||
_slider("pixel_size", "Pixel size", 1.0, GameSettings.MAX_PIXEL_SIZE, 1.0)
|
||||
_slider("resolution_scale", "3D resolution scale", 0.5, 1.0, 0.05)
|
||||
_note("Pixel size 1 turns the pixel look off; the resolution scale is used only then.")
|
||||
_head("Gameplay")
|
||||
_check("show_tips", "Tips on the first day and night")
|
||||
if not _phone: # no co-op on phones
|
||||
if not MobilePort.active(): # no co-op on phones
|
||||
_head("Co-op")
|
||||
_text("player_name", "Your name")
|
||||
_check("microphone", "Send my microphone in voice chat")
|
||||
|
|
@ -158,76 +103,21 @@ func _ready() -> void:
|
|||
outer.add_child(row)
|
||||
back_button = Button.new()
|
||||
back_button.text = "Back"
|
||||
back_button.custom_minimum_size = Vector2(220.0, BUTTON_HEIGHT)
|
||||
back_button.custom_minimum_size = Vector2(220.0, 54.0)
|
||||
back_button.pressed.connect(close)
|
||||
row.add_child(back_button)
|
||||
reset_button = Button.new()
|
||||
reset_button.text = "Reset to defaults"
|
||||
reset_button.custom_minimum_size = Vector2(280.0, BUTTON_HEIGHT)
|
||||
reset_button.pressed.connect(reset_to_defaults)
|
||||
row.add_child(reset_button)
|
||||
var reset := Button.new()
|
||||
reset.text = "Reset to defaults"
|
||||
reset.custom_minimum_size = Vector2(280.0, 54.0)
|
||||
reset.pressed.connect(func() -> void:
|
||||
var fresh := GameSettings.new()
|
||||
for key in ["volume", "move_dead_zone", "aim_dead_zone", "fullscreen", "vsync", "pixel_size", "resolution_scale", "show_tips"]:
|
||||
settings.set(key, fresh.get(key))
|
||||
_load()
|
||||
changed.emit())
|
||||
row.add_child(reset)
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
if _phone:
|
||||
_scroll.gui_input.connect(_on_list_input)
|
||||
get_viewport().size_changed.connect(fit)
|
||||
fit()
|
||||
|
||||
|
||||
## Reset to defaults: every setting shown here but co-op's. What isn't shown (on a phone the dead
|
||||
## zones, Fullscreen, VSync, and the pixel size; on desktop the touch settings) stays as it is.
|
||||
func reset_to_defaults() -> void:
|
||||
var fresh := GameSettings.new()
|
||||
for key: String in controls:
|
||||
if key in KEEP_ON_RESET:
|
||||
continue
|
||||
if key.begins_with("volume/"):
|
||||
var bus := key.trim_prefix("volume/")
|
||||
settings.volume[bus] = fresh.volume[bus]
|
||||
else:
|
||||
settings.set(key, fresh.get(key))
|
||||
_load()
|
||||
changed.emit()
|
||||
_refresh_guide()
|
||||
|
||||
|
||||
## A phone: the panel fills the safe area (up to the desktop's size), the rows and buttons at
|
||||
## least the minimum touch target tall, with a smaller title and margins on a phone's short
|
||||
## canvas. (Nothing on desktop.)
|
||||
func fit() -> void:
|
||||
if not _phone or not is_inside_tree():
|
||||
return
|
||||
UiTheme.inset_to_safe_area(self)
|
||||
var safe := MobilePort.safe_rect(self)
|
||||
var compact := safe.size.y < COMPACT_HEIGHT
|
||||
var m := 14 if compact else PANEL_MARGIN
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
_margin.add_theme_constant_override("margin_" + side, m)
|
||||
_title.add_theme_font_size_override("font_size", 32 if compact else 44)
|
||||
_outer.add_theme_constant_override("separation", 8 if compact else 14)
|
||||
var target := UiTheme.touch_height(self, 0.0)
|
||||
for c in _tall:
|
||||
c.custom_minimum_size.y = target
|
||||
for b: Button in [back_button, reset_button]:
|
||||
b.custom_minimum_size.y = UiTheme.touch_height(self, BUTTON_HEIGHT)
|
||||
_scroll.custom_minimum_size = Vector2.ZERO
|
||||
var chrome := Vector2(2.0 * m + _panel.get_theme_stylebox(&"panel").get_minimum_size().x,
|
||||
_panel.get_combined_minimum_size().y - _scroll.get_combined_minimum_size().y)
|
||||
_scroll.custom_minimum_size = Vector2(minf(SCROLL_SIZE.x, safe.size.x - chrome.x - 2.0 * EDGE),
|
||||
minf(SCROLL_SIZE.y, safe.size.y - chrome.y - 2.0 * EDGE)).max(Vector2(160.0, 120.0))
|
||||
queue_redraw() # the dim covers the screen from wherever the inset put this
|
||||
|
||||
|
||||
## How the touch controls work (the guide on a phone, in place of the bindings): the sticks'
|
||||
## sides as Prompts says (they follow Swap sticks), then the buttons, the hotbar, and the backpack.
|
||||
static func touch_guide() -> PackedStringArray:
|
||||
return PackedStringArray([
|
||||
"Move: touch the %s half of the screen and slide your thumb." % Prompts.move_side(),
|
||||
"Attack: touch the %s half and slide toward an alien to aim and attack." % Prompts.attack_side(),
|
||||
"Use: hold it to gather, repair, or upgrade; tap it for the workbench or the shed. Build (by day) starts building.",
|
||||
"Fear scares off everything nearby. Bomb throws a pumpkin bomb. Hold Patch to patch up with straw.",
|
||||
"Pause is at the top of the screen. Tap the hotbar to switch weapons, and the backpack to see your pouch.",
|
||||
])
|
||||
|
||||
|
||||
func open(p_settings: GameSettings) -> void:
|
||||
|
|
@ -236,23 +126,17 @@ func open(p_settings: GameSettings) -> void:
|
|||
is_open = true
|
||||
visible = true
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
fit()
|
||||
_scroll.scroll_vertical = 0
|
||||
(controls["volume/Master"] as Control).grab_focus.call_deferred()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_rect(UiTheme.overlay_rect(self), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
|
||||
|
||||
|
||||
func _has_point(point: Vector2) -> bool:
|
||||
return UiTheme.overlay_rect(self).has_point(point) # all of the screen, also outside the safe area
|
||||
draw_rect(Rect2(Vector2.ZERO, size), Color(0.0, 0.0, 0.0, 0.4)) # dims what's behind
|
||||
|
||||
|
||||
func close() -> void:
|
||||
if not is_open:
|
||||
return
|
||||
drag_end()
|
||||
is_open = false
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
|
@ -309,7 +193,6 @@ func _load() -> void:
|
|||
elif c is LineEdit:
|
||||
(c as LineEdit).text = String(v)
|
||||
_loading = false
|
||||
_refresh_guide()
|
||||
|
||||
|
||||
func _apply_value(key: String, v: Variant) -> void:
|
||||
|
|
@ -322,7 +205,6 @@ func _apply_value(key: String, v: Variant) -> void:
|
|||
if v is float:
|
||||
_show_value(key, v)
|
||||
changed.emit()
|
||||
_refresh_guide() # (after Main applied it: Swap sticks moves the sticks, and the guide's sides)
|
||||
|
||||
|
||||
func _show_value(key: String, v: float) -> void:
|
||||
|
|
@ -330,8 +212,6 @@ func _show_value(key: String, v: float) -> void:
|
|||
return
|
||||
if key == "pixel_size":
|
||||
(_values[key] as Label).text = "Off" if roundi(v) <= 1 else "%d×" % roundi(v)
|
||||
elif key == "camera_distance":
|
||||
(_values[key] as Label).text = "%d m" % roundi(v)
|
||||
else:
|
||||
(_values[key] as Label).text = "%d%%" % roundi(v * 100.0)
|
||||
|
||||
|
|
@ -360,36 +240,19 @@ func _slider(key: String, label: String, lo: float, hi: float, step: float) -> v
|
|||
l.text = label
|
||||
l.custom_minimum_size = Vector2(340.0, 0.0)
|
||||
row.add_child(l)
|
||||
var s: HSlider = TouchSlider.new(self) if _phone else HSlider.new()
|
||||
var s := HSlider.new()
|
||||
s.min_value = lo
|
||||
s.max_value = hi
|
||||
s.step = step
|
||||
s.custom_minimum_size = Vector2(440.0, 32.0)
|
||||
s.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
s.value_changed.connect(func(v: float) -> void:
|
||||
if key == ON_RELEASE and s is TouchSlider and (s as TouchSlider).sliding():
|
||||
_show_value(key, v) # applied when the finger lifts
|
||||
else:
|
||||
_apply_value(key, v))
|
||||
s.value_changed.connect(func(v: float) -> void: _apply_value(key, v))
|
||||
row.add_child(s)
|
||||
var value := Label.new()
|
||||
value.custom_minimum_size = Vector2(80.0, 0.0)
|
||||
row.add_child(value)
|
||||
controls[key] = s
|
||||
_values[key] = value
|
||||
if _phone: # the row shares its width, and all of its (touch-tall) height is the slider's
|
||||
l.custom_minimum_size.x = 0.0
|
||||
l.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
l.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
s.custom_minimum_size.x = 200.0
|
||||
s.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
s.size_flags_stretch_ratio = 1.4
|
||||
s.size_flags_vertical = Control.SIZE_FILL
|
||||
value.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
if key == ON_RELEASE:
|
||||
s.drag_ended.connect(func(_changed: bool) -> void: _apply_value(key, s.value))
|
||||
_tall.append(row)
|
||||
|
||||
|
||||
func _text(key: String, label: String) -> void:
|
||||
|
|
@ -415,28 +278,6 @@ func _check(key: String, label: String) -> void:
|
|||
c.toggled.connect(func(on: bool) -> void: _apply_value(key, on))
|
||||
_box.add_child(c)
|
||||
controls[key] = c
|
||||
if _phone:
|
||||
c.mouse_filter = Control.MOUSE_FILTER_PASS # a drag from it reaches the list, which scrolls
|
||||
_tall.append(c)
|
||||
|
||||
|
||||
## Phones: the touch guide's lines (touch_guide), under a caption.
|
||||
func _touch_guide() -> void:
|
||||
_note("Playing by touch")
|
||||
for i in touch_guide().size():
|
||||
var l := Label.new()
|
||||
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
l.add_theme_font_size_override("font_size", 19)
|
||||
_box.add_child(l)
|
||||
_guide.append(l)
|
||||
|
||||
|
||||
func _refresh_guide() -> void:
|
||||
if _guide.is_empty():
|
||||
return
|
||||
var lines := touch_guide()
|
||||
for i in _guide.size():
|
||||
_guide[i].text = lines[i]
|
||||
|
||||
|
||||
func _bindings() -> void:
|
||||
|
|
@ -472,129 +313,3 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
if is_open and event.is_action_pressed("ui_cancel"):
|
||||
close()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
# --- Phones: the list scrolls by dragging (see the class notes) ---
|
||||
|
||||
## How far a finger moves (canvas pixels) before it scrolls the list or takes a slider.
|
||||
func drag_slop() -> float:
|
||||
return MobilePort.minimum_target(self) * DRAG_SLOP_PT / MobilePort.TARGET_PT
|
||||
|
||||
|
||||
## Every touch the rows pass on (the check boxes pass theirs; a TouchSlider hands over its own):
|
||||
## a finger that goes up or down by more than drag_slop scrolls the list. Godot's own touch
|
||||
## scrolling never sees them (it would scroll too).
|
||||
func _on_list_input(e: InputEvent) -> void:
|
||||
var mb := e as InputEventMouseButton
|
||||
if mb != null and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
if mb.pressed:
|
||||
drag_begin(mb.global_position)
|
||||
else:
|
||||
drag_end()
|
||||
_scroll.accept_event()
|
||||
elif e is InputEventMouseMotion:
|
||||
if _drag_on:
|
||||
drag_move((e as InputEventMouseMotion).global_position)
|
||||
_scroll.accept_event()
|
||||
elif e is InputEventScreenTouch or e is InputEventScreenDrag:
|
||||
_scroll.accept_event()
|
||||
|
||||
|
||||
## A finger down on the list at this canvas point.
|
||||
func drag_begin(at: Vector2) -> void:
|
||||
_drag_on = true
|
||||
_drag_scrolling = false
|
||||
_drag_from = at
|
||||
|
||||
|
||||
## The finger at this point: once it's gone far enough up or down (or now, when forced: a slider
|
||||
## handing it over), the list follows it.
|
||||
func drag_move(at: Vector2, force := false) -> void:
|
||||
if not _drag_on:
|
||||
return
|
||||
if not _drag_scrolling:
|
||||
if not force and absf(at.y - _drag_from.y) <= drag_slop():
|
||||
return
|
||||
_drag_scrolling = true
|
||||
_drag_from = at
|
||||
_drag_start = _scroll.scroll_vertical
|
||||
_box.propagate_notification(NOTIFICATION_SCROLL_BEGIN) # a check box under the finger lets go
|
||||
return
|
||||
_scroll.scroll_vertical = roundi(_drag_start - (at.y - _drag_from.y))
|
||||
|
||||
|
||||
func drag_end() -> void:
|
||||
_drag_on = false
|
||||
_drag_scrolling = false
|
||||
|
||||
|
||||
## A slider in the phone's scrolling list. A finger on it waits to see which way it goes: past the
|
||||
## menu's drag_slop, mostly sideways takes the slider (the value follows the finger), and mostly up
|
||||
## or down hands the finger to the list, which scrolls. A tap sets the value where it lands, as a
|
||||
## click does. Keys and the gamepad work as on any slider.
|
||||
class TouchSlider extends HSlider:
|
||||
enum Finger { NONE, WAITING, SLIDING, SCROLLING }
|
||||
|
||||
var menu: SettingsMenu
|
||||
var finger := Finger.NONE
|
||||
var _from := Vector2.ZERO
|
||||
|
||||
func _init(p_menu: SettingsMenu) -> void:
|
||||
menu = p_menu
|
||||
|
||||
## A finger is moving the value now.
|
||||
func sliding() -> bool:
|
||||
return finger == Finger.SLIDING
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_VISIBILITY_CHANGED and not is_visible_in_tree():
|
||||
finger = Finger.NONE
|
||||
|
||||
func _gui_input(e: InputEvent) -> void:
|
||||
var mb := e as InputEventMouseButton
|
||||
if mb != null and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
var was := finger
|
||||
finger = Finger.NONE
|
||||
if mb.pressed:
|
||||
finger = Finger.WAITING
|
||||
_from = mb.global_position
|
||||
elif was == Finger.WAITING:
|
||||
_slide_to(mb.position) # a tap
|
||||
elif was == Finger.SLIDING:
|
||||
drag_ended.emit(true)
|
||||
elif was == Finger.SCROLLING:
|
||||
menu.drag_end()
|
||||
accept_event()
|
||||
return
|
||||
var mm := e as InputEventMouseMotion
|
||||
if mm == null or finger == Finger.NONE:
|
||||
return
|
||||
if not (mm.button_mask & MOUSE_BUTTON_MASK_LEFT): # its release went elsewhere
|
||||
if finger == Finger.SCROLLING:
|
||||
menu.drag_end()
|
||||
finger = Finger.NONE
|
||||
return
|
||||
match finger:
|
||||
Finger.WAITING:
|
||||
var d := mm.global_position - _from
|
||||
if d.length() > menu.drag_slop():
|
||||
if absf(d.x) > absf(d.y):
|
||||
finger = Finger.SLIDING
|
||||
drag_started.emit()
|
||||
_slide_to(mm.position)
|
||||
else:
|
||||
finger = Finger.SCROLLING
|
||||
menu.drag_begin(_from)
|
||||
menu.drag_move(mm.global_position, true)
|
||||
Finger.SLIDING:
|
||||
_slide_to(mm.position)
|
||||
Finger.SCROLLING:
|
||||
menu.drag_move(mm.global_position)
|
||||
accept_event()
|
||||
|
||||
## The value under this point (local), as a click on a slider sets it.
|
||||
func _slide_to(at: Vector2) -> void:
|
||||
var grab := float(get_theme_icon(&"grabber").get_width())
|
||||
var room := size.x - grab
|
||||
if room > 0.0:
|
||||
set_as_ratio(clampf((at.x - grab * 0.5) / room, 0.0, 1.0))
|
||||
|
|
|
|||
|
|
@ -38,5 +38,5 @@ func show_state(campaign: CampaignController, show: bool, focused: bool) -> void
|
|||
total += 1
|
||||
if Upgrades.owned(campaign.state, id):
|
||||
done += 1
|
||||
var hint := (Prompts.shop() if campaign.is_daytime() else "Shop by day") if focused else "Shop"
|
||||
var hint := ("[E / X] Shop" if campaign.is_daytime() else "Shop by day") if focused else "Shop"
|
||||
_label.text = "%s\n%d of %d done" % [hint, done, total]
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ extends RefCounted
|
|||
## sketched outlines (each edge drawn twice, slightly off, overshooting its corners), painted
|
||||
## fills (a flat color, a lighter dab, a darker rim), and painted icons for the weapons, the
|
||||
## materials, the backpack, the sun and moon, the scarecrow's portrait, what thieves take (crops,
|
||||
## animals, supplies), the enemies, the farmer and his wife (talking heads), and the phone's touch
|
||||
## buttons (TouchButtons: fear, patch, use, build, pause; Bomb is the pumpkin bomb); and the morning
|
||||
## animals, supplies), the enemies, and the farmer and his wife (talking heads); and the morning
|
||||
## screen's wooden sign (planks, a nailed sheet of paper, leaves). Every wobble comes from a hash of a seed, so a shape is drawn the
|
||||
## same way each frame (no flicker).
|
||||
## Icons are designed in a 100 x 100 box and scaled to the rect they're drawn in.
|
||||
|
|
@ -40,8 +39,7 @@ const LEAF := Color(0.42, 0.64, 0.22)
|
|||
## EnemySystem.TYPE_NAMES, and these.
|
||||
const ICONS: Array[String] = ["pitchfork", "corn_shooter", "pumpkin_bomb", "potato_cannon", "shurikens",
|
||||
"propane_torch", "alien_ray", "wood", "scrap", "straw", "alien_goop", "backpack", "sun", "moon", "portrait",
|
||||
"crops", "animals", "supplies", "crow", "thief", "breaker", "ufo", "farmer", "farmers_wife",
|
||||
"fear", "patch", "use", "build", "pause"]
|
||||
"crops", "animals", "supplies", "crow", "thief", "breaker", "ufo", "farmer", "farmers_wife"]
|
||||
|
||||
static var _font: Font
|
||||
|
||||
|
|
@ -588,54 +586,6 @@ static func _icon(ci: CanvasItem, id: String) -> void:
|
|||
for j in 5:
|
||||
paint(ci, blob(flower + Vector2.from_angle(TAU * j / 5.0 - 0.3) * 5.5, 4.6, 4.6, 392.0 + j), Color(0.96, 0.42, 0.56), 397.0 + j, 1.2)
|
||||
ci.draw_circle(flower, 3.4, Color(1.0, 0.84, 0.3))
|
||||
"fear": # a fright: a jagged burst in the fear ring's blue, with a "boo" face
|
||||
var blue := Color(0.36, 0.74, 1.0)
|
||||
var burst := PackedVector2Array()
|
||||
for i in 18:
|
||||
var a := TAU * i / 18.0 - PI * 0.5
|
||||
burst.append(Vector2(50, 50) + Vector2(cos(a), sin(a)) * (46.0 if i % 2 == 0 else 29.0) + jitter(403.0 + i, 1.8))
|
||||
paint(ci, burst, blue, 422.0)
|
||||
for k: float in [-1.0, 1.0]:
|
||||
paint(ci, blob(Vector2(50.0 + 11.0 * k, 42.0), 5.5, 7.5, 423.0 + k), INK, 425.0 + k, 0.0)
|
||||
paint(ci, blob(Vector2(50, 63), 8.5, 10.5, 427.0, 0.06), INK, 428.0, 0.0)
|
||||
"patch": # a heart patched with a square of straw, stitched on
|
||||
var heart := PackedVector2Array()
|
||||
for i in 36:
|
||||
var a := TAU * i / 36.0
|
||||
var y := 13.0 * cos(a) - 5.0 * cos(2.0 * a) - 2.0 * cos(3.0 * a) - cos(4.0 * a)
|
||||
heart.append(Vector2(50.0 + 40.0 * sin(a) * sin(a) * sin(a), 47.0 - 2.5 * y) + jitter(431.0 + i, 0.6))
|
||||
paint(ci, heart, Color(0.88, 0.14, 0.12), 468.0)
|
||||
var square := PackedVector2Array([Vector2(40, 37), Vector2(68, 33), Vector2(72, 61), Vector2(44, 65)])
|
||||
paint(ci, square, Color(0.96, 0.82, 0.36), 469.0, 2.0)
|
||||
for i in 4:
|
||||
var a := square[i]
|
||||
var b := square[(i + 1) % 4]
|
||||
var across := (b - a).orthogonal().normalized() * 4.5
|
||||
for k in 3:
|
||||
var m := a.lerp(b, (k + 0.5) / 3.0)
|
||||
ci.draw_line(m - across, m + across, INK, 2.5, true)
|
||||
"use": # an open hand in a work glove, reaching out
|
||||
var glove := Color(0.93, 0.79, 0.5)
|
||||
for k in 4:
|
||||
var x := 35.0 + k * 10.0
|
||||
stroke(ci, Vector2(x, 58.0), Vector2(x + (k - 1.5) * 2.5, 20.0 + absf(k - 1.4) * 6.0), glove, 8.0, 471.0 + k)
|
||||
stroke(ci, Vector2(34.0, 72.0), Vector2(16.0, 52.0), glove, 8.0, 475.0)
|
||||
paint(ci, PackedVector2Array([Vector2(29, 50), Vector2(71, 49), Vector2(70, 82), Vector2(31, 83)]), glove, 476.0)
|
||||
paint(ci, PackedVector2Array([Vector2(29, 80), Vector2(71, 79), Vector2(72, 95), Vector2(28, 96)]), glove.darkened(0.3), 477.0, 2.0)
|
||||
"build": # a claw hammer
|
||||
var grip := Vector2(28, 90)
|
||||
var top := Vector2(60, 38)
|
||||
stroke(ci, grip, top, WOOD, 10.0, 481.0)
|
||||
var d := (top - grip).normalized() # along the handle
|
||||
var p := d.orthogonal() # across it: the head, its striking face up and to the left
|
||||
var c := top + d * 4.0
|
||||
paint(ci, PackedVector2Array([c - p * 14.0 + d * 6.0, c - p * 30.0 + d * 1.0, c - p * 38.0 - d * 12.0, c - p * 28.0 - d * 6.0,
|
||||
c - p * 14.0 - d * 6.0]), Color(0.56, 0.58, 0.62), 482.0, 2.0) # the claw, curling back
|
||||
paint(ci, PackedVector2Array([c + p * 24.0 - d * 9.0, c + p * 24.0 + d * 9.0, c - p * 14.0 + d * 9.0, c - p * 14.0 - d * 9.0]),
|
||||
Color(0.66, 0.68, 0.72), 483.0)
|
||||
"pause": # two upright bars
|
||||
for x: float in [25.0, 57.0]:
|
||||
paint(ci, PackedVector2Array([Vector2(x, 17), Vector2(x + 18.0, 16), Vector2(x + 19.0, 84), Vector2(x + 1.0, 85)]), TEXT, 491.0 + x, 3.0)
|
||||
|
||||
|
||||
## An open outline (pts) closed with straight edges through corners, in steps about 5 long, so
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ extends Node
|
|||
## * A full-screen quad (pixel_outline.gdshader) darkens depth edges and lightens creases for
|
||||
## whatever camera is current. It needs the Forward+ renderer.
|
||||
## * Label3Ds aren't rendered in 3D (they'd be pixelated): ScreenLabels draws them as sharp text
|
||||
## over the 3D view, under the HUD. (Phones have no ToonLook; Main adds the ScreenLabels.)
|
||||
## over the 3D view, under the HUD.
|
||||
## The pixel size (rendering the 3D view small and scaling it up with sharp pixels) is a display
|
||||
## setting: GameSettings.pixel_size.
|
||||
|
||||
|
|
@ -32,7 +32,13 @@ var _pending: Array = [] # untyped: a node may be freed before the flush
|
|||
func _ready() -> void:
|
||||
outline = make_outline()
|
||||
add_child(outline)
|
||||
labels = ScreenLabels.ensure(self) # its own Labels layer, under the HUD (or the one already there)
|
||||
var layer := CanvasLayer.new()
|
||||
layer.name = "Labels"
|
||||
layer.layer = -1 # over the 3D view, under the HUD (1) and the menus (10)
|
||||
add_child(layer)
|
||||
labels = ScreenLabels.new()
|
||||
labels.name = "ScreenLabels"
|
||||
layer.add_child(labels)
|
||||
get_tree().node_added.connect(_on_node_added)
|
||||
apply_to(get_tree().root)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,429 +0,0 @@
|
|||
class_name TouchButtons
|
||||
extends Control
|
||||
## The phone's action buttons (MobilePort; Main adds them over the HUD, beside TouchSticks):
|
||||
## round, hand-drawn (Sketch), an icon and at most one word each. They press the input actions
|
||||
## the keys press (Input.action_press while the finger is down, held for at least one physics
|
||||
## tick so a quick tap still counts), so the game reads them as it reads a key. Each shows only
|
||||
## when it can do something:
|
||||
## * Pause (top edge, beside the day widget): opens the pause menu, as Escape does
|
||||
## (pause_requested; Main.pause). Shown while the game is being played (playing): not while
|
||||
## the tree is paused (a conversation, the pause menu) or a shop menu, the pouch panel, the
|
||||
## morning sign, or the end panel is up, which have their own buttons.
|
||||
## * Fear: fear (a tap). Its ring is fear's recharge, as the portrait's; lit when ready.
|
||||
## * Bomb: offhand (a tap throws a pumpkin bomb along the attack stick, or the way it last
|
||||
## pointed, as on a gamepad). Once pumpkin bombs are owned; its ring is the recharge.
|
||||
## * Patch: patch (hold), when hurt with the straw for it (the pouch or the shed); its ring is
|
||||
## the patch's progress (patch_time).
|
||||
## * Use: interact (hold to gather, repair, or upgrade; tap by day for the workbench or the
|
||||
## shed), with something in reach (Interactions.focus_info()), whose word it shows (Gather,
|
||||
## Repair, Upgrade, Workbench, Shop); dimmed when it would be refused now (the world label
|
||||
## says why); its ring is the gather's, repair's, or upgrade's progress.
|
||||
## * Build: build_mode (a tap) by day, and in build mode to leave it ("Done").
|
||||
## Fear, Bomb, and Patch make a column at the attack stick's outer edge, Use and Build one at the
|
||||
## move stick's (move_on_right; the Swap sticks setting flips it, apply_settings). Each column
|
||||
## sits inside the safe area (MobilePort.safe_rect), clear of the HUD's widgets (reserved()),
|
||||
## at the bottom of the room they leave, each button at least MobilePort.minimum_target()
|
||||
## across. The action buttons show only while Pause does and the scarecrow can act (can_act: not
|
||||
## frozen, the vacation not over, the scarecrow up).
|
||||
## Each button is a STOP Control with a round hit area, so it takes its touches before the
|
||||
## sticks (which read what the GUI leaves); this node is IGNORE, so the rest of the screen stays
|
||||
## the sticks'. Hidden, a button takes no touches, so whatever is up (the dialogue's paper and
|
||||
## Skip, a menu) gets them. A finger that lands on a button is that button's until it lifts. A
|
||||
## pause, a freeze, hiding (a button or all of them), or the app leaving the foreground lets go;
|
||||
## it processes while the tree is paused to hide them at once. In the desktop preview
|
||||
## (-- --mobile) the mouse presses them too.
|
||||
## Settings: in group &"touch_controls" (TouchSticks.GROUP) with apply_settings().
|
||||
|
||||
signal pause_requested
|
||||
|
||||
const PAUSE := &"pause"
|
||||
const FEAR := &"fear"
|
||||
const BOMB := &"bomb"
|
||||
const PATCH := &"patch"
|
||||
const USE := &"use"
|
||||
const BUILD := &"build"
|
||||
## Every button, in the order they're made.
|
||||
const ALL: Array[StringName] = [PAUSE, FEAR, BOMB, PATCH, USE, BUILD]
|
||||
## The input action each holds down while pressed (Pause has none: it asks, pause_requested).
|
||||
const ACTIONS := {FEAR: &"fear", BOMB: &"offhand", PATCH: &"patch", USE: &"interact", BUILD: &"build_mode"}
|
||||
const ICONS := {PAUSE: "pause", FEAR: "fear", BOMB: "pumpkin_bomb", PATCH: "patch", USE: "use", BUILD: "build"}
|
||||
## Each one's word (Use's follows what's in reach; Build's is DONE in build mode; Pause has none).
|
||||
const WORDS := {FEAR: "Fear", BOMB: "Bomb", PATCH: "Patch", USE: "Use", BUILD: "Build"}
|
||||
const DONE := "Done"
|
||||
## The columns, top to bottom: at the attack stick's outer edge, and at the move stick's.
|
||||
const ATTACK_COLUMN: Array[StringName] = [FEAR, BOMB, PATCH]
|
||||
const MOVE_COLUMN: Array[StringName] = [USE, BUILD]
|
||||
## In canvas pixels: an action button across and Pause across (each at least the minimum
|
||||
## target), between buttons, from the safe area's edge, and from a HUD widget above or below.
|
||||
const SIZE := 92.0
|
||||
const PAUSE_SIZE := 72.0
|
||||
const GAP := 14.0
|
||||
const EDGE := 16.0
|
||||
const CLEAR := 12.0
|
||||
## The backpack's count ("8/16") beside its icon (ResourceHud), kept clear with it.
|
||||
const COUNT_WIDTH := 100.0
|
||||
const FILL := Color(0.1, 0.24, 0.1, 0.7) # Sketch.SLOT, a little more solid
|
||||
## A ring's unfilled part (as the portrait's), and each button's ring.
|
||||
const TRACK := Color(0.32, 0.42, 0.5, 0.85)
|
||||
const RING_COLORS := {FEAR: Color(0.36, 0.74, 1.0), BOMB: Color(1.0, 0.58, 0.18), PATCH: Color(0.98, 0.84, 0.38),
|
||||
USE: Color(1.0, 0.86, 0.35)}
|
||||
## The finger a mouse click stands for (the desktop preview has no touches).
|
||||
const MOUSE := -2
|
||||
|
||||
var sim: FarmSim
|
||||
## The move stick's half of the screen (TouchSticks.move_on_right): the move column goes there.
|
||||
var move_on_right := TouchSticks.MOVE_ON_RIGHT
|
||||
## Main: true while the game isn't being played (a menu is up); every button hides then.
|
||||
var blocked: Callable
|
||||
## The buttons by id (ALL).
|
||||
var pads := {}
|
||||
|
||||
var _time := 0.0
|
||||
|
||||
|
||||
## One round button: a STOP Control whose hit area is its circle, driven and drawn by its
|
||||
## TouchButtons.
|
||||
class Pad extends Control:
|
||||
var id: StringName
|
||||
var buttons: TouchButtons
|
||||
## The finger holding it (-1: none; MOUSE: a click), the physics frame it went down in, and
|
||||
## whether it lifted before a physics tick had seen it held.
|
||||
var finger := -1
|
||||
var down_frame := 0
|
||||
var lifted := false
|
||||
## What it shows: its word, its ring (0-1; -1: none), lit (fear or a bomb ready), dimmed (Use
|
||||
## when it would be refused).
|
||||
var word := ""
|
||||
var ring := -1.0
|
||||
var lit := false
|
||||
var dim := false
|
||||
|
||||
func _init(p_id: StringName, p_buttons: TouchButtons) -> void:
|
||||
id = p_id
|
||||
buttons = p_buttons
|
||||
name = String(p_id).capitalize()
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
focus_mode = Control.FOCUS_NONE
|
||||
visible = false
|
||||
|
||||
func held() -> bool:
|
||||
return finger != -1
|
||||
|
||||
func _has_point(point: Vector2) -> bool:
|
||||
return point.distance_to(size * 0.5) <= size.x * 0.5
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
buttons._pad_input(self, event)
|
||||
accept_event()
|
||||
|
||||
func _draw() -> void:
|
||||
buttons._draw_pad(self)
|
||||
|
||||
|
||||
func setup(p_sim: FarmSim) -> void:
|
||||
sim = p_sim
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group(TouchSticks.GROUP)
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS # so a pause hides the buttons (and lets them go) at once
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE # only the buttons take touches
|
||||
for id in ALL:
|
||||
var p := Pad.new(id, self)
|
||||
pads[id] = p
|
||||
add_child(p)
|
||||
layout()
|
||||
|
||||
|
||||
## The settings contract (group &"touch_controls", GameSettings.apply): Swap sticks puts the move
|
||||
## stick on the left, and the button columns swap with it. A button held then lets go.
|
||||
func apply_settings(s: GameSettings) -> void:
|
||||
var right := TouchSticks.MOVE_ON_RIGHT != s.swap_sticks
|
||||
if right != move_on_right:
|
||||
let_go()
|
||||
move_on_right = right
|
||||
layout()
|
||||
|
||||
|
||||
func pad(id: StringName) -> Pad:
|
||||
return pads[id]
|
||||
|
||||
|
||||
## Whether Pause shows: the game is being played (shown, and Main's menus aren't up: blocked), the
|
||||
## tree isn't paused (a conversation, the pause menu), and no shop menu, pouch panel, sign, or end
|
||||
## panel is over the farm. Hidden, a button takes no touches: what's up then gets them.
|
||||
func playing() -> bool:
|
||||
if sim == null or not is_visible_in_tree() or (blocked.is_valid() and blocked.call()) or get_tree().paused:
|
||||
return false
|
||||
for panel: UpgradePanel in [sim.upgrade_panel, sim.shed_panel]:
|
||||
if panel != null and panel.is_open:
|
||||
return false
|
||||
return not ((sim.resource_hud != null and sim.resource_hud.open) or (sim.review_panel != null and sim.review_panel.visible)
|
||||
or (sim.end_panel != null and sim.end_panel.visible))
|
||||
|
||||
|
||||
## Whether the action buttons show (all but Pause): playing, and the scarecrow can act: not
|
||||
## frozen (the intro), the vacation not over, the scarecrow up.
|
||||
func can_act() -> bool:
|
||||
return playing() and not sim.local_frozen and not sim.campaign.is_over() and sim.scarecrow != null and sim.scarecrow.alive
|
||||
|
||||
|
||||
## Lets every button go (their actions released).
|
||||
func let_go() -> void:
|
||||
for id in ALL:
|
||||
_release(pads[id])
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
match what:
|
||||
NOTIFICATION_VISIBILITY_CHANGED:
|
||||
if not is_visible_in_tree():
|
||||
let_go()
|
||||
NOTIFICATION_APPLICATION_PAUSED, NOTIFICATION_APPLICATION_FOCUS_OUT:
|
||||
let_go()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_time += delta
|
||||
layout()
|
||||
var act := can_act()
|
||||
for id in ALL:
|
||||
var p: Pad = pads[id]
|
||||
var show := _shown(id, act)
|
||||
if p.visible != show:
|
||||
p.visible = show
|
||||
if not show:
|
||||
_release(p)
|
||||
if p.lifted and Engine.get_physics_frames() > p.down_frame:
|
||||
_release(p) # a tap, now that a physics tick has seen it
|
||||
if show:
|
||||
_refresh(p)
|
||||
p.queue_redraw()
|
||||
|
||||
|
||||
## Whether a button shows (act: can_act()).
|
||||
func _shown(id: StringName, act: bool) -> bool:
|
||||
if id == PAUSE:
|
||||
return playing()
|
||||
if not act:
|
||||
return false
|
||||
match id:
|
||||
BOMB:
|
||||
return sim.combat.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB
|
||||
PATCH:
|
||||
var kit := sim.scarecrow
|
||||
return kit.patching or (kit.hp() < kit.max_hp()
|
||||
and sim.campaign.state.resources.can_afford(sim.config.costs.get("patch", {}), kit.slot))
|
||||
USE:
|
||||
return not sim.interactions.focus_info().is_empty()
|
||||
BUILD:
|
||||
return sim.campaign.is_daytime() or sim.build.active
|
||||
return true
|
||||
|
||||
|
||||
## A shown button's word, ring, and state.
|
||||
func _refresh(p: Pad) -> void:
|
||||
p.word = WORDS.get(p.id, "")
|
||||
p.ring = -1.0
|
||||
p.lit = false
|
||||
p.dim = false
|
||||
var kit := sim.scarecrow
|
||||
match p.id:
|
||||
FEAR:
|
||||
p.lit = kit.fear_left <= 0.0
|
||||
if not p.lit:
|
||||
p.ring = kit.fear_charge()
|
||||
BOMB:
|
||||
var cooldown := sim.config.bomb_cooldown
|
||||
p.lit = sim.combat.bomb_left <= 0.0
|
||||
if not p.lit and cooldown > 0.0:
|
||||
p.ring = clampf(1.0 - sim.combat.bomb_left / cooldown, 0.0, 1.0)
|
||||
PATCH:
|
||||
if kit.patching:
|
||||
p.ring = clampf(kit.patch_elapsed / maxf(sim.config.patch_time, 0.001), 0.0, 1.0)
|
||||
USE:
|
||||
var info := sim.interactions.focus_info()
|
||||
if not info.is_empty():
|
||||
p.word = info["label"]
|
||||
p.dim = not info["ready"]
|
||||
p.ring = info["progress"]
|
||||
BUILD:
|
||||
if sim.build.active:
|
||||
p.word = DONE
|
||||
p.modulate.a = 0.55 if p.dim else 1.0
|
||||
|
||||
|
||||
# --- Touches ---
|
||||
|
||||
func _pad_input(p: Pad, event: InputEvent) -> void:
|
||||
var touch := event as InputEventScreenTouch
|
||||
if touch != null:
|
||||
if touch.pressed:
|
||||
_down(p, touch.index)
|
||||
elif touch.index == p.finger:
|
||||
_up(p)
|
||||
return
|
||||
var click := event as InputEventMouseButton # the desktop preview's mouse (a phone's taps are emulated clicks: not these)
|
||||
if click != null and click.button_index == MOUSE_BUTTON_LEFT and click.device != InputEvent.DEVICE_ID_EMULATION:
|
||||
if click.pressed:
|
||||
_down(p, MOUSE)
|
||||
elif p.finger == MOUSE:
|
||||
_up(p)
|
||||
|
||||
|
||||
func _down(p: Pad, index: int) -> void:
|
||||
if p.held() or not p.visible:
|
||||
return
|
||||
p.finger = index
|
||||
p.down_frame = Engine.get_physics_frames()
|
||||
p.lifted = false
|
||||
if p.id == PAUSE:
|
||||
pause_requested.emit()
|
||||
else:
|
||||
Input.action_press(ACTIONS[p.id])
|
||||
p.queue_redraw()
|
||||
|
||||
|
||||
## The finger lifts: the action lets go, once a physics tick has seen it held (else in _process).
|
||||
func _up(p: Pad) -> void:
|
||||
if Engine.get_physics_frames() > p.down_frame:
|
||||
_release(p)
|
||||
else:
|
||||
p.lifted = true
|
||||
|
||||
|
||||
func _release(p: Pad) -> void:
|
||||
if not p.held():
|
||||
return
|
||||
p.finger = -1
|
||||
p.lifted = false
|
||||
if ACTIONS.has(p.id):
|
||||
Input.action_release(ACTIONS[p.id])
|
||||
p.queue_redraw()
|
||||
|
||||
|
||||
# --- Layout ---
|
||||
|
||||
## Places the buttons (every frame, and at once on apply_settings): Pause beside the day widget,
|
||||
## the attack column at the attack side's outer edge, the move column at the move side's. A
|
||||
## column sits at the bottom of the room the HUD's widgets leave it (nearer the thumb), and is
|
||||
## squeezed (down to the minimum target) where that room is short.
|
||||
func layout() -> void:
|
||||
if pads.is_empty():
|
||||
return
|
||||
var safe := MobilePort.safe_rect(self)
|
||||
var target := MobilePort.minimum_target(self)
|
||||
var keep := reserved()
|
||||
_column(ATTACK_COLUMN, not move_on_right, safe, target, keep)
|
||||
_column(MOVE_COLUMN, move_on_right, safe, target, keep)
|
||||
var side := maxf(PAUSE_SIZE, target)
|
||||
var day := _day_rect()
|
||||
var at := Vector2(day.position.x - GAP - side, day.get_center().y - side * 0.5)
|
||||
at = at.clamp(safe.position + Vector2(EDGE, EDGE * 0.5), safe.end - Vector2(side + EDGE, side + EDGE))
|
||||
_place(pads[PAUSE], Rect2(at, Vector2(side, side)))
|
||||
|
||||
|
||||
func _column(ids: Array[StringName], right: bool, safe: Rect2, target: float, keep: Array[Rect2]) -> void:
|
||||
var d := maxf(SIZE, target)
|
||||
var x := safe.end.x - EDGE - d if right else safe.position.x + EDGE
|
||||
var room := _room(x, x + d, safe, keep)
|
||||
var n := ids.size()
|
||||
var side := d
|
||||
var gap := GAP
|
||||
if n * d + (n - 1) * GAP > room.y - room.x:
|
||||
gap = GAP * 0.5
|
||||
side = maxf(target, (room.y - room.x - (n - 1) * gap) / n)
|
||||
if right:
|
||||
x += d - side # still at the edge
|
||||
var y := maxf(room.y - n * side - (n - 1) * gap, room.x)
|
||||
for k in n:
|
||||
_place(pads[ids[k]], Rect2(Vector2(x, y + k * (side + gap)), Vector2(side, side)))
|
||||
|
||||
|
||||
## The room down the safe area for a column from x0 to x1 (top, bottom): below each widget it
|
||||
## passes in the screen's top half, above each one in the bottom half.
|
||||
func _room(x0: float, x1: float, safe: Rect2, keep: Array[Rect2]) -> Vector2:
|
||||
var top := safe.position.y + EDGE
|
||||
var bottom := safe.end.y - EDGE
|
||||
for r in keep:
|
||||
if r.position.x >= x1 or r.end.x <= x0:
|
||||
continue
|
||||
if r.get_center().y < size.y * 0.5:
|
||||
top = maxf(top, r.end.y + CLEAR)
|
||||
else:
|
||||
bottom = minf(bottom, r.position.y - CLEAR)
|
||||
return Vector2(top, bottom)
|
||||
|
||||
|
||||
func _place(p: Pad, r: Rect2) -> void:
|
||||
if p.position != r.position or p.size != r.size:
|
||||
p.position = r.position
|
||||
p.size = r.size
|
||||
p.queue_redraw()
|
||||
|
||||
|
||||
## The HUD's widgets the buttons keep clear of, in canvas pixels, from those widgets' own layouts:
|
||||
## the portrait and health bar (top left), the day widget and, once owned, the radar under it
|
||||
## (top right), the backpack and its count (bottom left), the hotbar at its widest (bottom
|
||||
## middle), and in build mode the build bar. (#43 fits the widgets into the safe area.)
|
||||
func reserved() -> Array[Rect2]:
|
||||
var w := size
|
||||
var out: Array[Rect2] = []
|
||||
out.append(Rect2(Vector2.ZERO, Vector2(ScarecrowHud.BAR_ORIGIN.x + ScarecrowHud.BAR_MAX_WIDTH,
|
||||
ScarecrowHud.PORTRAIT_CENTER.y + ScarecrowHud.PORTRAIT_RADIUS + 6.0)))
|
||||
out.append(_day_rect())
|
||||
if sim != null and sim.campaign != null and Upgrades.owned(sim.campaign.state, "radar"):
|
||||
var top := sim.phase_hud.bottom() + 8.0 if sim.phase_hud != null else RadarHud.MARGIN_TOP
|
||||
out.append(Rect2(Vector2(w.x - RadarHud.MARGIN_RIGHT - RadarHud.MAP_SIZE.x, top), RadarHud.MAP_SIZE))
|
||||
var bag := ResourceHud.ICON
|
||||
out.append(Rect2(Vector2(0.0, w.y + bag.position.y), Vector2(bag.end.x + COUNT_WIDTH, -bag.position.y)))
|
||||
var n := ScarecrowCombat.MAIN_WEAPONS.size() + ScarecrowCombat.OFFHAND_WEAPONS.size()
|
||||
var bar := n * ScarecrowHud.SLOT.x + (n - 1) * ScarecrowHud.SLOT_GAP + ScarecrowHud.DIVIDER_GAP * 2.0 - ScarecrowHud.SLOT_GAP
|
||||
var high := ScarecrowHud.HOTBAR_BOTTOM + ScarecrowHud.SLOT.y + 7.0 # (the slot in hand stands a little proud)
|
||||
out.append(Rect2(Vector2((w.x - bar) * 0.5, w.y - high), Vector2(bar, high)))
|
||||
if sim != null and sim.build != null and sim.build.active:
|
||||
var m := StructureSystem.ORDER.size()
|
||||
var bw := m * BuildHud.SLOT.x + (m - 1) * BuildHud.GAP + BuildHud.PAD * 2.0
|
||||
var bh := BuildHud.HEAD + BuildHud.SLOT.y + BuildHud.HELP + BuildHud.PAD + BuildHud.BOTTOM
|
||||
out.append(Rect2(Vector2((w.x - bw) * 0.5, w.y - bh), Vector2(bw, bh)))
|
||||
return out
|
||||
|
||||
|
||||
## The day widget (PhaseHud) in canvas pixels.
|
||||
func _day_rect() -> Rect2:
|
||||
if sim != null and sim.phase_hud != null:
|
||||
return sim.phase_hud.widget_rect()
|
||||
return Rect2(Vector2(size.x - PhaseHud.MARGIN.x - PhaseHud.WIDGET.x, PhaseHud.MARGIN.y), PhaseHud.WIDGET)
|
||||
|
||||
|
||||
# --- Drawing ---
|
||||
|
||||
## A round button: a dark wash, its ring (a recharge or a channel's progress) or a glow when it's
|
||||
## ready, an ink rim, its icon, and its word along the bottom; brighter while held.
|
||||
func _draw_pad(p: Pad) -> void:
|
||||
var c := p.size * 0.5
|
||||
var r := p.size.x * 0.5 - 3.0
|
||||
var seed := 600.0 + ALL.find(p.id) * 10.0
|
||||
var color: Color = RING_COLORS.get(p.id, Sketch.GOLD)
|
||||
p.draw_circle(c, r, FILL)
|
||||
if p.held():
|
||||
p.draw_circle(c, r, Color(Sketch.GOLD, 0.28))
|
||||
if p.ring >= 0.0:
|
||||
Sketch.circle(p, c, r - 2.0, TRACK, 5.0, seed)
|
||||
Sketch.circle(p, c, r - 2.0, color, 5.0, seed + 1.0, -PI * 0.5, -PI * 0.5 + TAU * p.ring)
|
||||
elif p.lit:
|
||||
var pulse := 0.75 + 0.25 * sin(_time * 3.2)
|
||||
for k in 3:
|
||||
Sketch.circle(p, c, r + 2.0 + k * 3.0, Color(color, (0.32 - k * 0.08) * pulse), 4.0, seed + 2.0 + k)
|
||||
Sketch.circle(p, c, r - 2.0, color.lightened(0.35), 5.0, seed + 5.0)
|
||||
Sketch.circle(p, c, r + 1.0, Color(Sketch.INK, 0.85), 2.5, seed + 6.0)
|
||||
var worded := p.word != ""
|
||||
var side := r * (1.3 if worded else 1.4)
|
||||
var at := c + Vector2(0.0, -r * 0.24 if worded else 0.0)
|
||||
Sketch.icon(p, ICONS[p.id], Rect2(at - Vector2(side, side) * 0.5, Vector2(side, side)))
|
||||
if worded:
|
||||
var font_size := roundi(20.0 * p.size.x / SIZE)
|
||||
while font_size > 12 and Sketch.text_width(p.word, font_size) > r * 2.0 - 6.0:
|
||||
font_size -= 1
|
||||
Sketch.text(p, Vector2(c.x, c.y + r * 0.36), p.word, font_size, Sketch.TEXT, HORIZONTAL_ALIGNMENT_CENTER, 6)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://um2exbsubbr5
|
||||
|
|
@ -3,27 +3,22 @@ extends Control
|
|||
## The phone's controls (MobilePort; Main adds it over the HUD): two floating thumbsticks. A
|
||||
## finger down on one half of the screen starts that half's stick where it lands; dragging tilts
|
||||
## it (past the rim, the base follows the finger), and lifting the finger lets it go.
|
||||
## * Move (right half; the left with the Swap sticks setting, move_on_right): the move_*
|
||||
## actions, as far as the stick is tilted. Screen up is forward, as with WASD.
|
||||
## * Attack (the other half): the aim_* actions, as a gamepad's right stick, and fire held
|
||||
## while the stick is tilted past the aim dead zone, so the main weapon attacks that way each
|
||||
## time it's ready.
|
||||
## The sticks only take touches the HUD and the menus don't (their buttons get them first, as do
|
||||
## TouchButtons'), and only while the scarecrow can act: not paused (menus, conversations), not
|
||||
## frozen (the intro), not once the vacation is over. A finger on a stick keeps it wherever it
|
||||
## slides, over a button too (its drags and its lift are read before the GUI's). A pause or freeze
|
||||
## lets both sticks go. Each stick is drawn only while a finger is on it.
|
||||
## Settings: in group &"touch_controls" with TouchButtons; apply_settings() takes the Swap sticks
|
||||
## setting (GameSettings.swap_sticks), and move_on_right_now() is the side in play (Prompts' tips).
|
||||
## * Move (right half): the move_* actions, as far as the stick is tilted. Screen up is
|
||||
## forward, as with WASD.
|
||||
## * Attack (left half): the aim_* actions, as a gamepad's right stick, and fire held while the
|
||||
## stick is tilted past the aim dead zone, so the main weapon attacks that way each time it's
|
||||
## ready.
|
||||
## The sticks only take touches the HUD and the menus don't (their buttons get them first), and
|
||||
## only while the scarecrow can act: not paused (menus, conversations), not frozen (the intro),
|
||||
## not once the vacation is over. A pause or freeze lets both sticks go. Each stick is drawn only
|
||||
## while a finger is on it.
|
||||
## On phones a tap is also a left click (Godot's mouse emulation, which the buttons need), and
|
||||
## the left click is fire: fire and offhand lose their mouse buttons here, so only the attack
|
||||
## stick (or a paired gamepad) attacks.
|
||||
|
||||
enum Stick { MOVE, ATTACK }
|
||||
|
||||
const MOVE_ON_RIGHT := true # the move stick's half of the screen by default (the user's call); the attack stick has the other
|
||||
## The touch controls' group: GameSettings.apply calls apply_settings on each (#41).
|
||||
const GROUP := &"touch_controls"
|
||||
const MOVE_ON_RIGHT := true # the move stick's half of the screen; the attack stick has the other
|
||||
const RADIUS := 150.0 # base to rim, in canvas pixels (the 1920-wide canvas)
|
||||
## Per stick: its left, right, up (forward), and down actions.
|
||||
const ACTIONS: Array = [[&"move_left", &"move_right", &"move_forward", &"move_back"],
|
||||
|
|
@ -31,8 +26,6 @@ const ACTIONS: Array = [[&"move_left", &"move_right", &"move_forward", &"move_ba
|
|||
const COLORS: Array[Color] = [UiTheme.TEXT, Color(1.0, 0.5, 0.38)]
|
||||
|
||||
var sim: FarmSim
|
||||
## The move stick's half: the right (MOVE_ON_RIGHT), or the left with Swap sticks (apply_settings).
|
||||
var move_on_right := MOVE_ON_RIGHT
|
||||
## Per stick (Stick): the finger on it (-1: none), its base, and its tilt (length 0-1).
|
||||
var finger: Array[int] = [-1, -1]
|
||||
var base: Array[Vector2] = [Vector2.ZERO, Vector2.ZERO]
|
||||
|
|
@ -43,28 +36,7 @@ func setup(p_sim: FarmSim) -> void:
|
|||
sim = p_sim
|
||||
|
||||
|
||||
## The move stick's side in play: the move_on_right of the TouchSticks in the tree, else
|
||||
## MOVE_ON_RIGHT (desktop, or before Main has added them).
|
||||
static func move_on_right_now() -> bool:
|
||||
var tree := Engine.get_main_loop() as SceneTree
|
||||
if tree != null:
|
||||
for n in tree.get_nodes_in_group(GROUP):
|
||||
if n is TouchSticks:
|
||||
return (n as TouchSticks).move_on_right
|
||||
return MOVE_ON_RIGHT
|
||||
|
||||
|
||||
## The settings contract (group &"touch_controls"): Swap sticks puts the move stick on the left.
|
||||
## A stick held while it changes lets go.
|
||||
func apply_settings(s: GameSettings) -> void:
|
||||
var right := MOVE_ON_RIGHT != s.swap_sticks
|
||||
if right != move_on_right:
|
||||
let_go()
|
||||
move_on_right = right
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group(GROUP)
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE # never in the way of the HUD's own buttons
|
||||
for action: StringName in [&"fire", &"offhand"]:
|
||||
|
|
@ -85,46 +57,37 @@ func _process(_delta: float) -> void:
|
|||
let_go()
|
||||
|
||||
|
||||
## A finger already on a stick: its drags and its lift, before the GUI sees them (so a button it
|
||||
## slides over neither takes them nor stops the stick).
|
||||
func _input(event: InputEvent) -> void:
|
||||
var drag := event as InputEventScreenDrag
|
||||
if drag != null:
|
||||
for s in 2:
|
||||
if finger[s] == drag.index:
|
||||
_drag(s, drag.position)
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
var touch := event as InputEventScreenTouch
|
||||
if touch != null and not touch.pressed:
|
||||
for s in 2:
|
||||
if finger[s] == touch.index:
|
||||
_release(s)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
## A finger landing where nothing else took it starts its half's stick.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
var touch := event as InputEventScreenTouch
|
||||
if touch == null or not touch.pressed:
|
||||
if touch != null:
|
||||
if touch.pressed:
|
||||
var s := side_of(touch.position)
|
||||
if not can_act() or finger[s] != -1:
|
||||
return
|
||||
finger[s] = touch.index
|
||||
base[s] = touch.position
|
||||
tilt[s] = Vector2.ZERO
|
||||
_apply(s)
|
||||
get_viewport().set_input_as_handled()
|
||||
else:
|
||||
for s in 2:
|
||||
if finger[s] == touch.index:
|
||||
_release(s)
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
var s := side_of(touch.position)
|
||||
if not can_act() or finger[s] != -1:
|
||||
var drag := event as InputEventScreenDrag
|
||||
if drag == null:
|
||||
return
|
||||
finger[s] = touch.index
|
||||
base[s] = touch.position
|
||||
tilt[s] = Vector2.ZERO
|
||||
_apply(s)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _drag(s: int, at: Vector2) -> void:
|
||||
var d := at - base[s]
|
||||
if d.length() > RADIUS:
|
||||
base[s] += d.normalized() * (d.length() - RADIUS)
|
||||
d = at - base[s]
|
||||
tilt[s] = d / RADIUS
|
||||
_apply(s)
|
||||
for s in 2:
|
||||
if finger[s] != drag.index:
|
||||
continue
|
||||
var d := drag.position - base[s]
|
||||
if d.length() > RADIUS:
|
||||
base[s] += d.normalized() * (d.length() - RADIUS)
|
||||
d = drag.position - base[s]
|
||||
tilt[s] = d / RADIUS
|
||||
_apply(s)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
## Whether the scarecrow can take orders now (see the class notes).
|
||||
|
|
@ -135,7 +98,7 @@ func can_act() -> bool:
|
|||
## Which stick a finger landing at this point (canvas coordinates) starts.
|
||||
func side_of(at: Vector2) -> Stick:
|
||||
var right := at.x >= size.x * 0.5
|
||||
return Stick.MOVE if right == move_on_right else Stick.ATTACK
|
||||
return Stick.MOVE if right == MOVE_ON_RIGHT else Stick.ATTACK
|
||||
|
||||
|
||||
## Lets both sticks go: their actions and fire released.
|
||||
|
|
|
|||
|
|
@ -7,14 +7,11 @@ extends Control
|
|||
## Night: fight (once enemies are in), fear (when crowded), recover (when something is
|
||||
## dropped), patch up (when hurt)
|
||||
## The most urgent one wins (recover, fear, patch, shoot, dusk, then the day's in order).
|
||||
## [Backspace / Back] hides them until the game is restarted (hide_tips); on a phone so does the ×
|
||||
## on the tip box's corner (a ScarecrowHud.HitTarget). Settings turns them off.
|
||||
## [Backspace / Back] hides them until the game is restarted; Settings turns them off.
|
||||
## Finished tips stay finished for the session, so a retry or a second vacation doesn't repeat
|
||||
## them.
|
||||
## None show while a talking-head conversation or the opening intro is up.
|
||||
|
||||
## The tips as the desktop shows them. Phones say the ones that name a control in touch words
|
||||
## (Prompts.TOUCH_TIPS); Prompts.tip() picks.
|
||||
const TEXT := {
|
||||
"move": "Move with [W A S D] or the left stick. You're the scarecrow: keep the farm safe until the farmers are back.",
|
||||
"gather": "Hold [E / X] at a dead tree, the haystacks, or the scrap heap to gather wood, straw, and scrap.",
|
||||
|
|
@ -29,11 +26,6 @@ const TEXT := {
|
|||
const PRIORITY: Array[String] = ["recover", "fear", "patch", "shoot", "dusk", "move", "gather", "store", "build"]
|
||||
const DONE_TIME := 0.9
|
||||
const CROWD_RADIUS := 7.0
|
||||
## Phones: the ×'s disc, centered this far in from the tip box's top-right corner.
|
||||
const HIDE_RADIUS := 20.0
|
||||
const HIDE_INSET := 6.0
|
||||
const BOX_FILL := Color(0.08, 0.1, 0.08, 0.86)
|
||||
const BOX_EDGE := Color(0.95, 0.82, 0.45)
|
||||
|
||||
var sim: FarmSim
|
||||
## Off when the player turned tips off in Settings.
|
||||
|
|
@ -42,8 +34,6 @@ var enabled := true
|
|||
var dismissed := false
|
||||
var done := {}
|
||||
var current := ""
|
||||
## Phones: the tip box's × (null on desktop).
|
||||
var hide_target: ScarecrowHud.HitTarget
|
||||
|
||||
var _box: PanelContainer
|
||||
var _text: Label
|
||||
|
|
@ -71,8 +61,8 @@ func _ready() -> void:
|
|||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_box = PanelContainer.new()
|
||||
var bg := StyleBoxFlat.new()
|
||||
bg.bg_color = BOX_FILL
|
||||
bg.border_color = BOX_EDGE
|
||||
bg.bg_color = Color(0.08, 0.1, 0.08, 0.86)
|
||||
bg.border_color = Color(0.95, 0.82, 0.45)
|
||||
bg.set_border_width_all(2)
|
||||
bg.set_corner_radius_all(6)
|
||||
bg.content_margin_left = 18.0
|
||||
|
|
@ -91,20 +81,12 @@ func _ready() -> void:
|
|||
_text.add_theme_font_size_override("font_size", 24)
|
||||
col.add_child(_text)
|
||||
_hint = Label.new()
|
||||
_hint.text = Prompts.tip_footer()
|
||||
_hint.text = "Tip · [Backspace / Back] hide tips"
|
||||
_hint.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_hint.add_theme_font_size_override("font_size", 16)
|
||||
_hint.add_theme_color_override("font_color", Color(0.7, 0.72, 0.65))
|
||||
col.add_child(_hint)
|
||||
_box.visible = false
|
||||
if MobilePort.active():
|
||||
hide_target = ScarecrowHud.HitTarget.new()
|
||||
hide_target.name = "HideTips"
|
||||
hide_target.visible = false
|
||||
hide_target.tapped.connect(hide_tips)
|
||||
hide_target.draw.connect(_draw_hide)
|
||||
add_child(hide_target)
|
||||
_box.item_rect_changed.connect(_place_hide)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
@ -179,25 +161,15 @@ func _finish(id: String) -> void:
|
|||
_done_left = DONE_TIME
|
||||
|
||||
|
||||
## Hides the tips until the game is restarted: [Backspace / Back], or the × on a phone.
|
||||
func hide_tips() -> void:
|
||||
dismissed = true
|
||||
_show("")
|
||||
|
||||
|
||||
func _show(id: String) -> void:
|
||||
current = id
|
||||
_box.visible = id != ""
|
||||
if hide_target != null:
|
||||
hide_target.visible = _box.visible
|
||||
if id == "":
|
||||
return
|
||||
_text.text = Prompts.tip(id)
|
||||
_text.text = TEXT[id]
|
||||
_text.remove_theme_color_override("font_color")
|
||||
_box.reset_size()
|
||||
_box.position = Vector2((size.x - _box.size.x) * 0.5, size.y - 250.0 - _box.size.y)
|
||||
if hide_target != null:
|
||||
_place_hide()
|
||||
|
||||
|
||||
func _enemies_near() -> int:
|
||||
|
|
@ -221,23 +193,6 @@ func _on_phase(phase: CampaignController.Phase, _previous: CampaignController.Ph
|
|||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if _box.visible and event.is_action_pressed("hide_tips"):
|
||||
hide_tips()
|
||||
dismissed = true
|
||||
_show("")
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
## Phones: the × at the tip box's top-right corner, over it.
|
||||
func _place_hide() -> void:
|
||||
var r := _box.get_rect()
|
||||
var at := Vector2(r.end.x - HIDE_INSET, r.position.y + HIDE_INSET)
|
||||
hide_target.cover(Rect2(at - Vector2(HIDE_RADIUS, HIDE_RADIUS), Vector2(HIDE_RADIUS, HIDE_RADIUS) * 2.0))
|
||||
hide_target.queue_redraw()
|
||||
|
||||
|
||||
## The ×: a disc of the tip box's own fill and edge, on its corner.
|
||||
func _draw_hide() -> void:
|
||||
var c := hide_target.size * 0.5
|
||||
hide_target.draw_circle(c, HIDE_RADIUS, Color(BOX_FILL, 0.97))
|
||||
Sketch.circle(hide_target, c, HIDE_RADIUS, BOX_EDGE, 2.5, 3.0)
|
||||
var k := HIDE_RADIUS * 0.42
|
||||
Sketch.line(hide_target, c + Vector2(-k, -k), c + Vector2(k, k), Sketch.TEXT, 3.5, 11.0, 0.5)
|
||||
Sketch.line(hide_target, c + Vector2(k, -k), c + Vector2(-k, k), Sketch.TEXT, 3.5, 12.0, 0.5)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ extends RefCounted
|
|||
## boxes, and tabs to match. Labels keep the default look; the HUD sets its own sizes.
|
||||
## sketch() is the hand-drawn theme the in-game panels use instead (the pause menu and its
|
||||
## questions, the workbench and shed shops), to match the HUD's pouch panel (Sketch).
|
||||
## touch_height, inset_to_safe_area, and overlay_rect fit the menus on a phone; the panels' phone
|
||||
## layout (panel_room, fit_margins, TouchScroll) is at the end.
|
||||
|
||||
const TEXT := Color(0.95, 0.93, 0.85)
|
||||
const GOLD := Color(0.95, 0.82, 0.45)
|
||||
|
|
@ -69,35 +67,6 @@ static func sketch() -> Theme:
|
|||
return t
|
||||
|
||||
|
||||
## --- Menus on a phone (MobilePort): touch-sized buttons, inside the safe area ---
|
||||
## The menus (MainMenu, PauseMenu, ConfirmBox, SettingsMenu) fit themselves on a phone when they
|
||||
## open and whenever the canvas changes (the window, or the Interface size); desktop keeps the
|
||||
## layout they're built with.
|
||||
|
||||
## A canvas item's height on a phone: at least the minimum touch target (44 pt,
|
||||
## MobilePort.minimum_target). On desktop, h.
|
||||
static func touch_height(ci: CanvasItem, h: float) -> float:
|
||||
return maxf(h, ceilf(MobilePort.minimum_target(ci))) if MobilePort.active() else h
|
||||
|
||||
|
||||
## A full-screen overlay (a CenterContainer menu, a child of a CanvasLayer) inset to the safe area,
|
||||
## so what it centers sits clear of the notch, the rounded corners, and the home indicator. Its
|
||||
## dim and its input still cover the whole screen (overlay_rect).
|
||||
static func inset_to_safe_area(c: Control) -> void:
|
||||
var safe := MobilePort.safe_rect(c)
|
||||
var view := c.get_viewport_rect().size
|
||||
c.offset_left = safe.position.x
|
||||
c.offset_top = safe.position.y
|
||||
c.offset_right = safe.end.x - view.x
|
||||
c.offset_bottom = safe.end.y - view.y
|
||||
|
||||
|
||||
## The whole screen in an overlay's coordinates (its own rect unless inset_to_safe_area moved it):
|
||||
## what it dims, and where it takes the pointer so nothing behind it does.
|
||||
static func overlay_rect(c: Control) -> Rect2:
|
||||
return Rect2(-c.position, c.get_viewport_rect().size)
|
||||
|
||||
|
||||
static func _margins(s: StyleBox, x: float, y: float) -> void:
|
||||
s.content_margin_left = x
|
||||
s.content_margin_right = x
|
||||
|
|
@ -205,177 +174,3 @@ static func _box(bg: Color, border: Color, width: int) -> StyleBoxFlat:
|
|||
s.content_margin_top = 8.0
|
||||
s.content_margin_bottom = 8.0
|
||||
return s
|
||||
|
||||
|
||||
## --- Panels on a phone (#42) ---
|
||||
## The morning sign (ReviewPanel), the end screens (EndPanel), and the workbench's and the shed's
|
||||
## shops (UpgradePanel) on a phone (MobilePort.active(); at any interface scale, iPads too):
|
||||
## * each sits in panel_room(), the safe area (MobilePort.safe_rect) less PANEL_GAP, through
|
||||
## fit_margins() on a MarginContainer between the panel and its full-screen CenterContainer
|
||||
## (which still dims and blocks the whole screen);
|
||||
## * its long part is a TouchScroll at most as tall as the room leaves, with its buttons below
|
||||
## it, always in view; long lines wrap to the room's width;
|
||||
## * its buttons and rows are at least MobilePort.minimum_target() tall.
|
||||
## On desktop the margins are 0 and a TouchScroll is a plain box, so each is laid out as before.
|
||||
|
||||
const PANEL_GAP := 8.0
|
||||
|
||||
|
||||
## Where a panel goes on a phone: the safe rect less PANEL_GAP on every side, in ci's canvas.
|
||||
static func panel_room(ci: CanvasItem) -> Rect2:
|
||||
return MobilePort.safe_rect(ci).grow(-PANEL_GAP)
|
||||
|
||||
|
||||
## Puts the panel inside `wrap` (a MarginContainer, the only child of a full-screen
|
||||
## CenterContainer) in `room` (canvas coordinates): margins out to the room's edges, plus
|
||||
## `extra` (left, top, right, bottom) kept clear for drawing past the panel's rect. An empty
|
||||
## room (desktop) is no margins at all.
|
||||
static func fit_margins(wrap: MarginContainer, room: Rect2, extra: Vector4 = Vector4.ZERO) -> void:
|
||||
var m := Vector4.ZERO
|
||||
if room.has_area():
|
||||
var full := (wrap.get_parent() as Control).get_global_rect()
|
||||
m = Vector4(room.position.x - full.position.x, room.position.y - full.position.y,
|
||||
full.end.x - room.end.x, full.end.y - room.end.y) + extra
|
||||
var sides: Array[String] = ["left", "top", "right", "bottom"]
|
||||
for i in 4:
|
||||
set_constant(wrap, "margin_" + sides[i], maxi(ceili(m[i] - 0.001), 0))
|
||||
|
||||
|
||||
## A theme constant override, set only when it changes (each set lays the control out again).
|
||||
static func set_constant(c: Control, constant: String, value: int) -> void:
|
||||
if c.get_theme_constant(constant) != value:
|
||||
c.add_theme_constant_override(constant, value)
|
||||
|
||||
|
||||
## A panel's long part (its only child is the content). On desktop (set_phone(false), the
|
||||
## default) it's a plain box as tall as its content: no scrolling, no clipping, no bar. On a
|
||||
## phone (set_phone(true)) fit() makes it at most as tall as the panel's room leaves; past that
|
||||
## it scrolls, with a thin bar, and a finger drags it: a press inside it that moves DRAG_PT
|
||||
## points (about Apple's touch slop) scrolls with the finger, and the button it started on lets
|
||||
## go (NOTIFICATION_SCROLL_BEGIN), so lifting the finger presses (buys) nothing; a press that
|
||||
## doesn't move that far is a tap for whatever's under it. Godot's own touch dragging (only on a
|
||||
## real touchscreen, and only from between the buttons) is off, so a phone, the desktop
|
||||
## preview, and the tests all take this one path. To check on a device: the slop feels right;
|
||||
## there's no fling (the list stops when the finger lifts).
|
||||
class TouchScroll extends ScrollContainer:
|
||||
const DRAG_PT := 10.0
|
||||
|
||||
## The press under way has turned into a scroll.
|
||||
var dragging := false
|
||||
var _bar: Color
|
||||
var _pad: float
|
||||
var _finger := -1
|
||||
var _moved := Vector2.ZERO
|
||||
|
||||
## bar: the scroll bar's colour; pad: room kept clear around the content on a phone (where
|
||||
## it clips), for its buttons' focus frames.
|
||||
func _init(bar: Color, pad: float = 0.0) -> void:
|
||||
_bar = bar
|
||||
_pad = pad
|
||||
horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
scroll_deadzone = 1 << 30 # Godot's own touch dragging never starts: _input does it
|
||||
set_phone(false)
|
||||
|
||||
func _ready() -> void:
|
||||
get_viewport().gui_focus_changed.connect(_on_focus)
|
||||
|
||||
func set_phone(on: bool) -> void:
|
||||
vertical_scroll_mode = ScrollContainer.SCROLL_MODE_AUTO if on else ScrollContainer.SCROLL_MODE_DISABLED
|
||||
clip_contents = on
|
||||
if not on:
|
||||
custom_minimum_size = Vector2.ZERO
|
||||
remove_theme_stylebox_override("panel")
|
||||
_finger = -1
|
||||
dragging = false
|
||||
return
|
||||
if has_theme_stylebox_override("panel"):
|
||||
return
|
||||
var pad := StyleBoxEmpty.new()
|
||||
pad.set_content_margin_all(_pad)
|
||||
add_theme_stylebox_override("panel", pad)
|
||||
var track := StyleBoxFlat.new()
|
||||
track.bg_color = Color(_bar, 0.12)
|
||||
track.set_corner_radius_all(4)
|
||||
track.content_margin_left = 4.0
|
||||
track.content_margin_right = 4.0
|
||||
var grab := StyleBoxFlat.new()
|
||||
grab.bg_color = Color(_bar, 0.5)
|
||||
grab.set_corner_radius_all(4)
|
||||
var lit := grab.duplicate() as StyleBoxFlat
|
||||
lit.bg_color = Color(_bar, 0.75)
|
||||
var v := get_v_scroll_bar()
|
||||
for key: String in ["scroll", "scroll_focus"]:
|
||||
v.add_theme_stylebox_override(key, track)
|
||||
v.add_theme_stylebox_override("grabber", grab)
|
||||
for key: String in ["grabber_highlight", "grabber_pressed"]:
|
||||
v.add_theme_stylebox_override(key, lit)
|
||||
|
||||
## The width it adds around its content on a phone: the pad and the bar.
|
||||
func frame_width() -> float:
|
||||
return get_theme_stylebox("panel").get_minimum_size().x + get_v_scroll_bar().get_combined_minimum_size().x
|
||||
|
||||
## On a phone: as wide as its content and the bar, and as tall as its content up to `most`,
|
||||
## past which it scrolls.
|
||||
func fit(most: float) -> void:
|
||||
if get_child_count() == 0:
|
||||
return
|
||||
var content := (get_child(0) as Control).get_combined_minimum_size()
|
||||
var h := content.y + get_theme_stylebox("panel").get_minimum_size().y
|
||||
custom_minimum_size = Vector2(content.x + frame_width(), h if h <= most else floorf(maxf(most, 0.0)))
|
||||
|
||||
## Whether there's more than it shows.
|
||||
func scrolls() -> bool:
|
||||
var v := get_v_scroll_bar()
|
||||
return vertical_scroll_mode != ScrollContainer.SCROLL_MODE_DISABLED and v.max_value - v.page > 0.5
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
var touch := event as InputEventScreenTouch
|
||||
if touch != null:
|
||||
if touch.pressed:
|
||||
if _finger == -1 and is_visible_in_tree() and scrolls() and _grabs(touch.position):
|
||||
_finger = touch.index
|
||||
_moved = Vector2.ZERO
|
||||
dragging = false
|
||||
elif touch.index == _finger:
|
||||
_finger = -1
|
||||
if dragging:
|
||||
dragging = false
|
||||
scroll_ended.emit()
|
||||
return
|
||||
var drag := event as InputEventScreenDrag
|
||||
if drag == null or drag.index != _finger:
|
||||
return
|
||||
if not is_visible_in_tree():
|
||||
_finger = -1
|
||||
dragging = false
|
||||
return
|
||||
var v := get_v_scroll_bar()
|
||||
if not dragging:
|
||||
_moved += drag.relative
|
||||
if _moved.length() < DRAG_PT * MobilePort.minimum_target(self) / MobilePort.TARGET_PT:
|
||||
return
|
||||
dragging = true
|
||||
propagate_notification(Control.NOTIFICATION_SCROLL_BEGIN) # the button under the finger lets go
|
||||
scroll_started.emit()
|
||||
v.value -= _moved.y
|
||||
else:
|
||||
v.value -= drag.relative.y
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
## On a phone, keys and a gamepad scroll the button they focus into view (once the layout's
|
||||
## in); a finger's press doesn't (follow_focus would: the list would jump under it).
|
||||
func _on_focus(c: Control) -> void:
|
||||
if vertical_scroll_mode == ScrollContainer.SCROLL_MODE_DISABLED or Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or not is_ancestor_of(c):
|
||||
return
|
||||
_follow.call_deferred(c.get_instance_id())
|
||||
|
||||
func _follow(id: int) -> void:
|
||||
var c := instance_from_id(id) as Control
|
||||
if c != null and c.has_focus() and is_ancestor_of(c):
|
||||
ensure_control_visible(c)
|
||||
|
||||
## Whether a finger landing here (the viewport's canvas) drags it: inside it, off its bar.
|
||||
func _grabs(at: Vector2) -> bool:
|
||||
var local := get_global_transform_with_canvas().affine_inverse() * at
|
||||
var v := get_v_scroll_bar()
|
||||
return Rect2(Vector2.ZERO, size).has_point(local) and not (v.visible and v.get_rect().has_point(local))
|
||||
|
|
|
|||
|
|
@ -11,22 +11,12 @@ extends CenterContainer
|
|||
## Escape / B, interact again, by walking off, or at nightfall. The scarecrow stands still and
|
||||
## can't shoot while either is open. Hand-drawn like the HUD's pouch panel (UiTheme.sketch): the
|
||||
## title over a pen rule, the tracks' names dim like the pouch's column headings, a slot per row.
|
||||
## On a phone (UiTheme's panels) it sits in the safe area: the rows are a list that scrolls
|
||||
## (UiTheme.TouchScroll: a finger that drags the list scrolls it and buys nothing, a tap on a row
|
||||
## buys), each row at least the touch target tall with its text wrapped to the room's width (up
|
||||
## to PHONE_ROW), and Close stays below the list, always in view.
|
||||
|
||||
## A purchase's result text. Nothing shows it on screen since #23 (the rows say what's missing);
|
||||
## tests listen to it.
|
||||
signal message(text: String, color: Color)
|
||||
signal bought(id: String)
|
||||
|
||||
const ROW := Vector2(860.0, 46.0)
|
||||
const CLOSE := Vector2(200.0, 48.0)
|
||||
const MARGIN := 8
|
||||
## A row's widest on a phone (an iPad's room is wider): about the workbench's longest.
|
||||
const PHONE_ROW := 1150.0
|
||||
|
||||
var campaign: CampaignController
|
||||
var structures: StructureSystem
|
||||
var player: PlayerCharacter
|
||||
|
|
@ -43,11 +33,6 @@ var slot: int = 0
|
|||
var _rows := {} # upgrade id -> Button
|
||||
var _title: Label
|
||||
var _close: Button
|
||||
var _safe: MarginContainer
|
||||
var _panel: PanelContainer
|
||||
var _scroll: UiTheme.TouchScroll
|
||||
var _list: VBoxContainer
|
||||
var _fit_queued := false
|
||||
|
||||
|
||||
func setup(p_campaign: CampaignController, p_structures: StructureSystem, p_player: PlayerCharacter, p_shop: String = "workbench") -> void:
|
||||
|
|
@ -55,7 +40,7 @@ func setup(p_campaign: CampaignController, p_structures: StructureSystem, p_play
|
|||
structures = p_structures
|
||||
player = p_player
|
||||
shop = p_shop
|
||||
var box := _list
|
||||
var box := get_node("Panel/Margin/Box") as VBoxContainer
|
||||
var track := ""
|
||||
for id in Upgrades.ORDER:
|
||||
var u: Dictionary = campaign.config.upgrades.get(id, {})
|
||||
|
|
@ -70,27 +55,31 @@ func setup(p_campaign: CampaignController, p_structures: StructureSystem, p_play
|
|||
box.add_child(head)
|
||||
var b := Button.new()
|
||||
b.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
b.custom_minimum_size = ROW
|
||||
b.custom_minimum_size = Vector2(860.0, 46.0)
|
||||
b.add_theme_font_size_override("font_size", 25)
|
||||
b.pressed.connect(func() -> void: _buy(id))
|
||||
box.add_child(b)
|
||||
_rows[id] = b
|
||||
_close = Button.new()
|
||||
_close.text = "Close"
|
||||
_close.custom_minimum_size = Vector2(200.0, 48.0)
|
||||
_close.add_theme_font_size_override("font_size", 28)
|
||||
_close.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
_close.pressed.connect(close)
|
||||
box.add_child(_close)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
theme = UiTheme.sketch()
|
||||
_safe = MarginContainer.new() # the safe area's margins on a phone (none on desktop)
|
||||
_safe.name = "Safe"
|
||||
add_child(_safe)
|
||||
_panel = PanelContainer.new()
|
||||
_panel.name = "Panel"
|
||||
_safe.add_child(_panel)
|
||||
var panel := PanelContainer.new()
|
||||
panel.name = "Panel"
|
||||
add_child(panel)
|
||||
var margin := MarginContainer.new()
|
||||
margin.name = "Margin"
|
||||
for side in ["left", "right", "top", "bottom"]:
|
||||
margin.add_theme_constant_override("margin_" + side, MARGIN)
|
||||
_panel.add_child(margin)
|
||||
margin.add_theme_constant_override("margin_" + side, 8)
|
||||
panel.add_child(margin)
|
||||
var box := VBoxContainer.new()
|
||||
box.name = "Box"
|
||||
box.add_theme_constant_override("separation", 6)
|
||||
|
|
@ -99,24 +88,8 @@ func _ready() -> void:
|
|||
_title.add_theme_font_size_override("font_size", 36)
|
||||
box.add_child(_title)
|
||||
box.add_child(HSeparator.new())
|
||||
_scroll = UiTheme.TouchScroll.new(Sketch.TEXT, 4.0) # the rows (setup), scrolling on a phone
|
||||
box.add_child(_scroll)
|
||||
_list = VBoxContainer.new()
|
||||
_list.name = "List"
|
||||
_list.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_list.add_theme_constant_override("separation", 6)
|
||||
_scroll.add_child(_list)
|
||||
_close = Button.new()
|
||||
_close.text = "Close"
|
||||
_close.custom_minimum_size = CLOSE
|
||||
_close.add_theme_font_size_override("font_size", 28)
|
||||
_close.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
_close.pressed.connect(close)
|
||||
box.add_child(_close)
|
||||
visible = false
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_list.minimum_size_changed.connect(_queue_fit) # rows rewritten or reflowed
|
||||
get_viewport().size_changed.connect(_queue_fit)
|
||||
|
||||
|
||||
func open() -> void:
|
||||
|
|
@ -127,8 +100,6 @@ func open() -> void:
|
|||
mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
player.start_channel(&"Idle_A")
|
||||
refresh()
|
||||
_fit()
|
||||
_scroll.scroll_vertical = 0
|
||||
var first: Button = _close
|
||||
for id in Upgrades.ORDER:
|
||||
if _rows.has(id) and not (_rows[id] as Button).disabled:
|
||||
|
|
@ -146,42 +117,6 @@ func close() -> void:
|
|||
player.stop_channel()
|
||||
|
||||
|
||||
## Lays the menu out: on desktop as it always was; on a phone (UiTheme's panels) inside the safe
|
||||
## area, the rows wrapped to the room's width and at least the touch target tall, and the list
|
||||
## scrolling past what the height leaves for it.
|
||||
func _fit() -> void:
|
||||
var phone := MobilePort.active()
|
||||
_scroll.set_phone(phone)
|
||||
var target := MobilePort.minimum_target(self) if phone else 0.0
|
||||
_close.custom_minimum_size = Vector2(CLOSE.x, maxf(CLOSE.y, target))
|
||||
var room := UiTheme.panel_room(self) if phone else Rect2()
|
||||
UiTheme.fit_margins(_safe, room)
|
||||
var width := ROW.x
|
||||
if phone:
|
||||
var frame := _panel.get_theme_stylebox("panel").get_minimum_size().x + 2.0 * MARGIN + _scroll.frame_width()
|
||||
width = floorf(minf(PHONE_ROW, room.size.x - frame))
|
||||
for id: String in _rows:
|
||||
var b := _rows[id] as Button
|
||||
b.custom_minimum_size = Vector2(width, maxf(ROW.y, target))
|
||||
b.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART if phone else TextServer.AUTOWRAP_OFF
|
||||
if phone:
|
||||
_scroll.fit(room.size.y - (_panel.get_combined_minimum_size().y - _scroll.get_combined_minimum_size().y))
|
||||
|
||||
|
||||
## Fits again once this frame's changes are in (rows rewritten, the screen changed size).
|
||||
func _queue_fit() -> void:
|
||||
if _fit_queued or not is_open:
|
||||
return
|
||||
_fit_queued = true
|
||||
_refit.call_deferred()
|
||||
|
||||
|
||||
func _refit() -> void:
|
||||
_fit_queued = false
|
||||
if is_open:
|
||||
_fit()
|
||||
|
||||
|
||||
## Rewrites every row for what's owned and affordable now.
|
||||
func refresh() -> void:
|
||||
var cfg := campaign.config
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@ extends RefCounted
|
|||
## the scarecrow's max health (FarmState) when a level is bought, and the Bigger pouch upgrade
|
||||
## raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch grows) the same way. The
|
||||
## buyer pays from their own pouch and the shed (slot). Sprint, the weapons, and radar change no
|
||||
## stat here; owning one (owned(): level 1 or more) is what counts: Sprint makes the scarecrow
|
||||
## faster for good (PlayerCharacter.speed_factor, by GameConfig.sprint_speed_mult), the weapons
|
||||
## unlock in ScarecrowCombat, and radar's minimap in RadarHud. Rapid fire and heavy seeds (bought at the
|
||||
## stat: owning them (owned(): level 1 or more) unlocks sprinting (PlayerCharacter), the weapons
|
||||
## (ScarecrowCombat), and the minimap (RadarHud). Rapid fire and heavy seeds (bought at the
|
||||
## workbench) need the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
||||
|
||||
## Menu order, grouped by track.
|
||||
|
|
@ -32,8 +31,8 @@ static func level(state: FarmState, id: String) -> int:
|
|||
return int(state.upgrades.get(id, 0)) if state != null else 0
|
||||
|
||||
|
||||
## Owned at any level (level 1 or more): what "requires" and the stat-less ones (sprint's speed,
|
||||
## the weapons, radar) ask.
|
||||
## Owned at any level (level 1 or more): what "requires" and the unlocks (sprint, the weapons,
|
||||
## radar) ask.
|
||||
static func owned(state: FarmState, id: String) -> bool:
|
||||
return level(state, id) > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,6 @@ func show_state(campaign: CampaignController, show: bool, focused: bool, broken:
|
|||
_label.text = "Broken -- repair it" if focused else "Broken"
|
||||
return
|
||||
_label.modulate = NORMAL_COLOR
|
||||
var hint := (Prompts.upgrades() if campaign.is_daytime() else "Upgrades by day") if focused else "Upgrades"
|
||||
var hint := ("[E / X] Upgrades" if campaign.is_daytime() else "Upgrades by day") if focused else "Upgrades"
|
||||
_label.text = "%s\n%d of %d levels" % [hint, Upgrades.levels_bought(campaign.config, campaign.state),
|
||||
Upgrades.levels_total(campaign.config)]
|
||||
|
|
|
|||
|
|
@ -1,495 +0,0 @@
|
|||
extends RefCounted
|
||||
## #38, the touch buttons (TouchButtons) by touch, through the game's entry scene (main.tscn, with
|
||||
## test save and settings paths) on a 19.5:9 phone (2340x1080) with a simulated notch and home
|
||||
## indicator (MobilePort.preview_insets):
|
||||
## * On a phone Main adds them beside the sticks. Each is inside the safe area, at least the
|
||||
## minimum target, clear of the HUD's widgets (the radar's too, once owned; the build bar in
|
||||
## build mode), of #39's hit targets, and of each other; Fear, Bomb, and Patch on the attack
|
||||
## side, Use and Build on the move side, Pause beside the day widget.
|
||||
## * They show only when they can do something: none at the main menu, in the morning sign, in a
|
||||
## conversation that pauses the farm, in the pause menu, or with a shop's menu up; by day Pause,
|
||||
## Fear, and Build; Use only with something in reach (its word from Interactions.focus_info);
|
||||
## Bomb once owned; Patch when hurt with straw; Build not at night.
|
||||
## * Each does what its key does, by touch: Fear starts its cooldown (its ring); holding Patch
|
||||
## heals after patch_time (its ring fills); holding Use gathers at a point (its ring fills);
|
||||
## tapping Use by day opens the shed's shop, and the workbench's once it's granted; Build enters
|
||||
## build mode ("Done") and leaves it; Bomb throws along the attack stick's last aim; Pause
|
||||
## opens the pause menu and lets a held button go. A quick tap (down and up at once) counts.
|
||||
## * A touch on a shown button starts no stick; one where a hidden button would be does; a stick
|
||||
## finger sliding over a shown button keeps steering, and doesn't press it.
|
||||
## * apply_settings with Swap sticks (as GameSettings.apply will call it, group touch_controls):
|
||||
## the move stick, the button columns, and the tips' side (Prompts.move_side) swap, and back.
|
||||
## * Desktop (forced 0): no TouchButtons (nor sticks), and fire keeps its mouse button.
|
||||
## The InputMap's mouse buttons for fire and offhand (TouchSticks erases them) are put back.
|
||||
|
||||
const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
const SAVE := "user://test_buttons_save.json"
|
||||
const SETTINGS := "user://test_buttons_settings.cfg"
|
||||
const PHONE := Vector2i(2340, 1080)
|
||||
const INSETS := [140.0, 0.0, 140.0, 60.0]
|
||||
const AWAY := Vector3(-11.0, 0.0, 13.0) # nothing in reach there (as in the other suites)
|
||||
const PAUSE := TouchButtons.PAUSE
|
||||
const FEAR := TouchButtons.FEAR
|
||||
const BOMB := TouchButtons.BOMB
|
||||
const PATCH := TouchButtons.PATCH
|
||||
const USE := TouchButtons.USE
|
||||
const BUILD := TouchButtons.BUILD
|
||||
## #39's hit targets at this phone's scale (its notes): the hotbar's slots, the backpack, and the
|
||||
## tip box's ×; and the dialogue's Skip (only up while a conversation pauses the farm).
|
||||
const HUD_TARGETS: Array[Rect2] = [Rect2(533.0, 584.0, 267.0, 72.0), Rect2(26.0, 542.0, 108.0, 108.0),
|
||||
Rect2(1063.0, 215.0, 60.0, 60.0)]
|
||||
const SKIP := Rect2(1193.0, 496.0, 118.0, 68.0)
|
||||
const TALK := "res://game/resources/dialogue/morning_day_2.tres"
|
||||
const ACTIONS: Array[StringName] = [&"fear", &"offhand", &"patch", &"interact", &"build_mode", &"fire", &"move_left",
|
||||
&"move_right", &"move_forward", &"move_back", &"aim_left", &"aim_right", &"aim_up", &"aim_down"]
|
||||
|
||||
var t: GameTestRunner
|
||||
var main: Main
|
||||
var sim: FarmSim
|
||||
var buttons: TouchButtons
|
||||
var sticks: TouchSticks
|
||||
|
||||
|
||||
func run(p_t: GameTestRunner) -> void:
|
||||
t = p_t
|
||||
_clean()
|
||||
var bindings := {}
|
||||
for action: StringName in [&"fire", &"offhand"]:
|
||||
bindings[action] = InputMap.action_get_events(action)
|
||||
var size := t.root.size
|
||||
var factor := t.root.content_scale_factor
|
||||
MobilePort.forced = 1
|
||||
MobilePort.preview_insets = INSETS
|
||||
t.root.size = PHONE
|
||||
main = await _start()
|
||||
sim = main.sim
|
||||
buttons = main.farm.get_node_or_null("Hud/TouchButtons") as TouchButtons
|
||||
sticks = main.farm.get_node_or_null("Hud/TouchSticks") as TouchSticks
|
||||
t.check(buttons != null and sticks != null, "a phone: Main adds TouchButtons beside TouchSticks")
|
||||
if buttons != null and sticks != null:
|
||||
await _buttons()
|
||||
await _stop()
|
||||
for action: StringName in bindings:
|
||||
InputMap.action_erase_events(action)
|
||||
for e: InputEvent in bindings[action]:
|
||||
InputMap.action_add_event(action, e)
|
||||
for action in ACTIONS:
|
||||
Input.action_release(action)
|
||||
_clean()
|
||||
MobilePort.forced = 0
|
||||
MobilePort.preview_insets = []
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
main = await _start()
|
||||
t.check(main.farm.get_node_or_null("Hud/TouchButtons") == null and main.farm.get_node_or_null("Hud/TouchSticks") == null,
|
||||
"desktop: no touch buttons or sticks")
|
||||
var mouse_fire := InputMap.action_get_events("fire").filter(func(e: InputEvent) -> bool: return e is InputEventMouseButton)
|
||||
t.check(not mouse_fire.is_empty(), "desktop: fire keeps its mouse button")
|
||||
await _stop()
|
||||
MobilePort.forced = -1
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _start() -> Main:
|
||||
var m := (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
m.save_path = SAVE
|
||||
m.settings_path = SETTINGS
|
||||
t.root.add_child(m)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
return m
|
||||
|
||||
|
||||
func _stop() -> void:
|
||||
main.queue_free()
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _physics(n: int) -> void:
|
||||
for k in n:
|
||||
await t.physics_frame
|
||||
|
||||
|
||||
## A few physics ticks, then two frames (the buttons update in _process).
|
||||
func _settle(ticks: int = 3) -> void:
|
||||
await _physics(ticks)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _pad(id: StringName) -> TouchButtons.Pad:
|
||||
return buttons.pad(id)
|
||||
|
||||
|
||||
func _at(id: StringName) -> Vector2:
|
||||
return _pad(id).get_global_rect().get_center()
|
||||
|
||||
|
||||
## The buttons shown, in TouchButtons.ALL's order.
|
||||
func _shown() -> Array:
|
||||
var out := []
|
||||
for id in TouchButtons.ALL:
|
||||
if _pad(id).visible:
|
||||
out.append(id)
|
||||
return out
|
||||
|
||||
|
||||
## A quick tap on a button: down and up in the same instant.
|
||||
func _tap(id: StringName, finger := 7) -> void:
|
||||
Touch.tap(finger, _at(id))
|
||||
|
||||
|
||||
func _held() -> Array:
|
||||
return ACTIONS.filter(func(a: StringName) -> bool: return Input.is_action_pressed(a))
|
||||
|
||||
|
||||
## Puts the scarecrow beside a node (inside reach), trying four sides, until its hands focus it as
|
||||
## kind. Returns whether they do.
|
||||
func _go_to(n: Node3D, reach: float, kind: String) -> bool:
|
||||
for dir: Vector3 in [Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(-1, 0, 0), Vector3(0, 0, -1)]:
|
||||
sim.player.global_position = Vector3(n.global_position.x, 0.0, n.global_position.z) + dir * reach * 0.6
|
||||
await _settle(4)
|
||||
if sim.interactions.focus == n and sim.interactions.focus_info().get("kind", "") == kind:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _away() -> void:
|
||||
sim.player.global_position = AWAY
|
||||
await _settle(4)
|
||||
|
||||
|
||||
func _buttons() -> void:
|
||||
t.check(buttons.mouse_filter == Control.MOUSE_FILTER_IGNORE and _pad(FEAR).mouse_filter == Control.MOUSE_FILTER_STOP,
|
||||
"the buttons are STOP Controls in an IGNORE one")
|
||||
await t.process_frame
|
||||
t.check(_shown().is_empty(), "at the main menu no button shows (%s)" % [_shown()])
|
||||
main.new_vacation(false)
|
||||
await _settle()
|
||||
t.check(_shown().is_empty(), "the morning sign: no buttons (%s)" % [_shown()])
|
||||
sim.campaign.advance_phase() # morning -> day
|
||||
await _talk_if_any()
|
||||
await _away()
|
||||
t.check(_shown() == [PAUSE, FEAR, BUILD], "by day with nothing in reach: Pause, Fear, Build (%s)" % [_shown()])
|
||||
await _talk()
|
||||
_layout("by day")
|
||||
sim.campaign.state.upgrades["radar"] = 1
|
||||
await _settle(1)
|
||||
_layout("with the radar")
|
||||
sim.campaign.state.upgrades.erase("radar")
|
||||
await _fear()
|
||||
await _build()
|
||||
await _gather()
|
||||
await _shops()
|
||||
await _patch()
|
||||
await _bomb()
|
||||
await _blocking()
|
||||
await _swap()
|
||||
await _pause()
|
||||
await _night()
|
||||
t.check(_held().is_empty(), "nothing left held (%s)" % [_held()])
|
||||
|
||||
|
||||
## A conversation that pauses the farm (day 2's morning one, played now): no buttons while it's
|
||||
## up, so its paper and Skip get the touches; then skipped.
|
||||
func _talk() -> void:
|
||||
sim.dialogue.play(load(TALK) as Conversation)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
t.check(t.paused and sim.dialogue.box.conversation != null and sim.dialogue.box.conversation.pause_game,
|
||||
"a conversation that pauses the farm is up")
|
||||
t.check(_shown().is_empty() and not _pad(PAUSE).get_rect().intersects(SKIP),
|
||||
"while it's up no button shows, so its paper and Skip get the touches (%s)" % [_shown()])
|
||||
sim.dialogue.box.skip()
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
t.check(not t.paused and _shown().has(PAUSE), "skipped: the buttons are back")
|
||||
|
||||
|
||||
## The layout: inside the safe area, at least the minimum target, round, clear of the HUD's
|
||||
## widgets, #39's targets, and each other; each column on its side; Pause beside the day widget.
|
||||
func _layout(what: String) -> void:
|
||||
buttons.layout()
|
||||
var safe := MobilePort.safe_rect(buttons)
|
||||
var target := MobilePort.minimum_target(buttons)
|
||||
var keep := buttons.reserved()
|
||||
keep.append_array(HUD_TARGETS)
|
||||
var inside := true
|
||||
var big := true
|
||||
var clear := true
|
||||
var apart := true
|
||||
var why := ""
|
||||
var rects := {}
|
||||
for id in TouchButtons.ALL:
|
||||
var r := _pad(id).get_rect()
|
||||
rects[id] = r
|
||||
inside = inside and safe.grow(0.01).encloses(r)
|
||||
big = big and r.size.x >= target - 0.01 and is_equal_approx(r.size.x, r.size.y)
|
||||
for k in keep:
|
||||
if r.intersects(k):
|
||||
clear = false
|
||||
why += " %s over %s;" % [id, k]
|
||||
for i in TouchButtons.ALL.size():
|
||||
for j in range(i + 1, TouchButtons.ALL.size()):
|
||||
if (rects[TouchButtons.ALL[i]] as Rect2).intersects(rects[TouchButtons.ALL[j]]):
|
||||
apart = false
|
||||
why += " %s over %s;" % [TouchButtons.ALL[i], TouchButtons.ALL[j]]
|
||||
t.info("%s: canvas %s, safe %s, buttons %s" % [what, buttons.size, safe, rects])
|
||||
t.check(t.root.content_scale_factor > 1.5, "%s: at the phone's scale (%.2f)" % [what, t.root.content_scale_factor])
|
||||
t.check(inside, "%s: every button inside the safe area %s" % [what, safe])
|
||||
t.check(big, "%s: each round and at least the minimum target (%.0f px; Fear %s)" % [what, target, rects[FEAR]])
|
||||
t.check(clear, "%s: clear of the HUD's widgets and #39's targets%s" % [what, why])
|
||||
t.check(apart, "%s: clear of each other%s" % [what, why])
|
||||
var mid := buttons.size.x * 0.5
|
||||
var sides := true
|
||||
for id in TouchButtons.ATTACK_COLUMN:
|
||||
sides = sides and ((rects[id] as Rect2).get_center().x > mid) != buttons.move_on_right
|
||||
for id in TouchButtons.MOVE_COLUMN:
|
||||
sides = sides and ((rects[id] as Rect2).get_center().x > mid) == buttons.move_on_right
|
||||
var order: bool = (rects[FEAR] as Rect2).end.y <= (rects[BOMB] as Rect2).position.y \
|
||||
and (rects[BOMB] as Rect2).end.y <= (rects[PATCH] as Rect2).position.y and (rects[USE] as Rect2).end.y <= (rects[BUILD] as Rect2).position.y
|
||||
t.check(sides and order, "%s: Fear, Bomb, Patch down the %s edge; Use, Build down the %s edge" % [what,
|
||||
"left" if buttons.move_on_right else "right", "right" if buttons.move_on_right else "left"])
|
||||
var day := sim.phase_hud.widget_rect()
|
||||
var p: Rect2 = rects[PAUSE]
|
||||
t.check(p.end.x <= day.position.x and p.end.y > day.position.y and p.position.y < day.end.y and p.position.y < buttons.size.y * 0.2,
|
||||
"%s: Pause at the top edge, beside the day widget (%s; the widget %s)" % [what, p, day])
|
||||
|
||||
|
||||
func _fear() -> void:
|
||||
var kit := sim.scarecrow
|
||||
var used: Array[int] = []
|
||||
kit.fear_used.connect(func(_p: Vector3, _n: int) -> void: used.append(0))
|
||||
t.check(_pad(FEAR).lit and _pad(FEAR).word == "Fear", "Fear is lit while it's ready")
|
||||
_tap(FEAR)
|
||||
await _settle()
|
||||
t.check(used.size() == 1 and kit.fear_left > 0.0, "a quick tap on Fear scares, once, and starts its cooldown (%.1f s left)" % kit.fear_left)
|
||||
t.check(not Input.is_action_pressed("fear") and not _pad(FEAR).held(), "and lets fear go")
|
||||
var ring := _pad(FEAR).ring
|
||||
t.check(not _pad(FEAR).lit and ring >= 0.0 and ring < 0.25, "Fear's ring shows the recharge (%.2f)" % ring)
|
||||
kit.fear_left = 0.0
|
||||
|
||||
|
||||
func _build() -> void:
|
||||
t.check(_pad(BUILD).visible and _pad(BUILD).word == "Build", "Build by day")
|
||||
_tap(BUILD)
|
||||
await _settle()
|
||||
t.check(sim.build.active and _pad(BUILD).word == TouchButtons.DONE, "a tap on Build enters build mode; it says Done")
|
||||
t.check(not _pad(USE).visible, "no Use in build mode")
|
||||
_layout("in build mode")
|
||||
_tap(BUILD)
|
||||
await _settle()
|
||||
t.check(not sim.build.active and _pad(BUILD).word == "Build", "a tap on Done leaves it")
|
||||
t.check(not Input.is_action_pressed("build_mode"), "build_mode let go")
|
||||
|
||||
|
||||
func _gather() -> void:
|
||||
var it := sim.interactions
|
||||
var node: GatherNode = null
|
||||
for n in it.nodes:
|
||||
if it.charges(n) > 0 and not sim.zones.zone_at(n.global_position).outside:
|
||||
node = n
|
||||
break
|
||||
var ok := false
|
||||
if node != null:
|
||||
ok = await _go_to(node, node.reach, "gather")
|
||||
t.check(ok,"the scarecrow stands at a gather point (%s)" % (node.name if node != null else "none"))
|
||||
if not ok:
|
||||
return
|
||||
t.check(_pad(USE).visible and _pad(USE).word == "Gather" and not _pad(USE).dim, "at a gather point by day: Use, 'Gather'")
|
||||
var got: Array[int] = []
|
||||
it.gathered.connect(func(_m: String, amount: int, _n: GatherNode) -> void: got.append(amount))
|
||||
var at := _at(USE)
|
||||
var half := roundi(sim.config.gather_time * Engine.physics_ticks_per_second * 0.5)
|
||||
Touch.touch(3, at, true)
|
||||
await _settle(half)
|
||||
t.check(it.gathering == node and _pad(USE).ring > 0.25 and _pad(USE).ring < 0.75,
|
||||
"holding Use gathers; its ring fills (%.2f)" % _pad(USE).ring)
|
||||
await _settle(half + 10)
|
||||
t.check(got.size() >= 1, "holding Use gathers at a point (+%s %s)" % [got, node.material])
|
||||
Touch.touch(3, at, false)
|
||||
await _settle()
|
||||
t.check(not Input.is_action_pressed("interact") and it.gathering == null, "lifting the finger stops gathering")
|
||||
|
||||
|
||||
func _shops() -> void:
|
||||
var it := sim.interactions
|
||||
var counter := it.shed_counter
|
||||
var ok := await _go_to(counter, counter.reach, "shed")
|
||||
t.check(ok and _pad(USE).visible and _pad(USE).word == "Shop", "at the shed counter by day: Use, 'Shop' (workbench not granted yet: %s)"
|
||||
% (not sim.structures.has_workbench()))
|
||||
_tap(USE)
|
||||
await _settle()
|
||||
t.check(sim.shed_panel.is_open, "a tap on Use there opens the shed's shop")
|
||||
t.check(_shown().is_empty() and not Input.is_action_pressed("interact"), "with a shop's menu up no button shows (%s), interact let go" % [_shown()])
|
||||
sim.shed_panel.close()
|
||||
sim.structures.grant_workbench()
|
||||
ok = await _go_to(it.workbench, it.workbench.reach, "workbench")
|
||||
t.check(ok and _pad(USE).visible and _pad(USE).word == "Workbench", "at the granted workbench: Use, 'Workbench'")
|
||||
_tap(USE)
|
||||
await _settle()
|
||||
t.check(sim.upgrade_panel.is_open and _shown().is_empty(), "a tap on Use there opens the workbench's menu")
|
||||
sim.upgrade_panel.close()
|
||||
await _away()
|
||||
|
||||
|
||||
func _patch() -> void:
|
||||
var s := sim.campaign.state
|
||||
var kit := sim.scarecrow
|
||||
s.resources.shed["straw"] = 0
|
||||
s.resources.pouch_of(kit.slot)["straw"] = 0
|
||||
s.scarecrow_hp = s.scarecrow_max_hp - 1
|
||||
await _settle(1)
|
||||
t.check(not _pad(PATCH).visible, "no Patch when hurt without straw")
|
||||
s.resources.shed["straw"] = 10
|
||||
s.scarecrow_hp = s.scarecrow_max_hp
|
||||
await _settle(1)
|
||||
t.check(not _pad(PATCH).visible, "nor at full health")
|
||||
s.scarecrow_hp = s.scarecrow_max_hp - 1
|
||||
await _settle(1)
|
||||
t.check(_pad(PATCH).visible and _pad(PATCH).ring < 0.0, "hurt with straw: Patch")
|
||||
var patched: Array[int] = []
|
||||
kit.patched.connect(func(hp: int) -> void: patched.append(hp))
|
||||
var at := _at(PATCH)
|
||||
var half := roundi(sim.config.patch_time * Engine.physics_ticks_per_second * 0.5)
|
||||
Touch.touch(2, at, true)
|
||||
await _settle(half)
|
||||
t.check(kit.patching and patched.is_empty() and _pad(PATCH).ring > 0.3 and _pad(PATCH).ring < 0.7,
|
||||
"holding Patch patches up; its ring fills (%.2f)" % _pad(PATCH).ring)
|
||||
await _settle(half + 10)
|
||||
t.check(patched.size() == 1 and s.scarecrow_hp == s.scarecrow_max_hp, "holding Patch heals after %.1f s (HP %d/%d)"
|
||||
% [sim.config.patch_time, s.scarecrow_hp, s.scarecrow_max_hp])
|
||||
t.check(not _pad(PATCH).visible and not Input.is_action_pressed("patch"), "at full health Patch hides and lets go, finger still down")
|
||||
Touch.touch(2, at, false)
|
||||
await _settle()
|
||||
|
||||
|
||||
func _bomb() -> void:
|
||||
t.check(not _pad(BOMB).visible, "no Bomb before pumpkin bombs are owned")
|
||||
sim.campaign.state.upgrades["pumpkin_bomb"] = 1
|
||||
await _settle()
|
||||
t.check(_pad(BOMB).visible and _pad(BOMB).lit, "Bomb once they're owned, lit (one in hand)")
|
||||
# Aim with the attack stick (screen right), then let it go: the aim stays.
|
||||
var w := sticks.size
|
||||
var left := Vector2(w.x * 0.3, w.y * 0.45)
|
||||
Touch.touch(1, left, true)
|
||||
Touch.drag(1, left, left + Vector2(TouchSticks.RADIUS, 0.0))
|
||||
await _physics(12)
|
||||
Touch.touch(1, left + Vector2(TouchSticks.RADIUS, 0.0), false)
|
||||
await _settle()
|
||||
var aim := sim.combat.aim
|
||||
var throws: Array[Vector3] = []
|
||||
sim.combat.threw.connect(func(to: Vector3) -> void: throws.append(to))
|
||||
_tap(BOMB)
|
||||
await _settle(4)
|
||||
var p := sim.player.global_position
|
||||
t.check(throws.size() == 1, "a quick tap on Bomb throws one (%d)" % throws.size())
|
||||
if throws.size() == 1:
|
||||
var to := Vector2(throws[0].x - p.x, throws[0].z - p.z)
|
||||
var want := clampf(ScarecrowCombat.GAMEPAD_THROW, sim.config.bomb_min_range, sim.config.bomb_range)
|
||||
t.check(to.normalized().dot(aim) > 0.95 and absf(to.length() - want) < 0.75,
|
||||
"along the attack stick's last aim, %.1f m out (dot %.2f)" % [to.length(), to.normalized().dot(aim)])
|
||||
var ring := _pad(BOMB).ring
|
||||
t.check(not Input.is_action_pressed("offhand") and not _pad(BOMB).lit and ring >= 0.0 and ring < 0.3,
|
||||
"offhand let go; Bomb's ring shows the recharge (%.2f)" % ring)
|
||||
|
||||
|
||||
func _blocking() -> void:
|
||||
# A touch on a shown button is the button's: no stick.
|
||||
var at := _at(BUILD)
|
||||
Touch.touch(4, at, true)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == -1 and sticks.finger[TouchSticks.Stick.ATTACK] == -1 and _pad(BUILD).held(),
|
||||
"a touch on a shown button (Build) is the button's: no stick starts")
|
||||
Touch.touch(4, at, false)
|
||||
await _settle()
|
||||
_tap(BUILD) # (back out of build mode)
|
||||
await _settle()
|
||||
t.check(not sim.build.active, "(out of build mode again)")
|
||||
# Where a hidden button would be, the stick's.
|
||||
t.check(not _pad(USE).visible, "Use hidden (nothing in reach)")
|
||||
var use_at := _at(USE)
|
||||
Touch.touch(4, use_at, true)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == 4, "a touch where a hidden button (Use) would be starts the move stick")
|
||||
# That finger slides over a shown button (Build): it still steers, and Build isn't pressed.
|
||||
Touch.drag(4, use_at, at)
|
||||
await t.process_frame
|
||||
var tilt := sticks.tilt[TouchSticks.Stick.MOVE]
|
||||
t.check(tilt.length() > 0.3 and tilt.normalized().dot((at - use_at).normalized()) > 0.99 and not _pad(BUILD).held(),
|
||||
"sliding the stick's finger over Build keeps steering (tilt %s); Build stays up" % tilt)
|
||||
Touch.touch(4, at, false)
|
||||
await _settle()
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == -1 and not sim.build.active, "lifting it there lets the stick go, and Build wasn't pressed")
|
||||
|
||||
|
||||
func _swap() -> void:
|
||||
var s := GameSettings.new()
|
||||
s.swap_sticks = true
|
||||
t.call_group(TouchSticks.GROUP, &"apply_settings", s)
|
||||
await _settle(1)
|
||||
t.check(not sticks.move_on_right and not buttons.move_on_right, "Swap sticks: the sticks and the buttons have the move stick on the left")
|
||||
t.check(Prompts.move_side() == "left" and Prompts.attack_side() == "right", "and the tips say so (Prompts.move_side)")
|
||||
var w := sticks.size
|
||||
var left := Vector2(w.x * 0.3, w.y * 0.45)
|
||||
Touch.touch(0, left, true)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == 0, "a finger on the left half is the move stick now")
|
||||
Touch.touch(0, left, false)
|
||||
await _settle()
|
||||
_layout("swapped")
|
||||
sim.campaign.state.upgrades["radar"] = 1
|
||||
await _settle(1)
|
||||
_layout("swapped, with the radar")
|
||||
sim.campaign.state.upgrades.erase("radar")
|
||||
s.swap_sticks = false
|
||||
t.call_group(TouchSticks.GROUP, &"apply_settings", s)
|
||||
await _settle(1)
|
||||
t.check(sticks.move_on_right and buttons.move_on_right and Prompts.move_side() == "right"
|
||||
and sticks.side_of(Vector2(w.x * 0.75, w.y * 0.5)) == TouchSticks.Stick.MOVE, "and back")
|
||||
_layout("swapped back")
|
||||
|
||||
|
||||
func _pause() -> void:
|
||||
# Hold Fear, then tap Pause with another finger.
|
||||
var at := _at(FEAR)
|
||||
Touch.touch(5, at, true)
|
||||
await _settle(2)
|
||||
t.check(Input.is_action_pressed("fear") and _pad(FEAR).held(), "holding Fear holds fear")
|
||||
_tap(PAUSE, 6)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
t.check(main.screen == Main.Screen.PAUSED and main.pause_menu.visible and t.paused, "a tap on Pause opens the pause menu")
|
||||
t.check(not Input.is_action_pressed("fear") and not _pad(FEAR).held(), "the pause lets the held button go")
|
||||
t.check(_shown().is_empty(), "paused: no buttons (%s)" % [_shown()])
|
||||
Touch.touch(5, at, false)
|
||||
main.resume()
|
||||
await _settle()
|
||||
t.check(_shown().has(PAUSE) and not Input.is_action_pressed("fear"), "resumed: the buttons are back, nothing held")
|
||||
sim.scarecrow.fear_left = 0.0
|
||||
|
||||
|
||||
func _night() -> void:
|
||||
sim.campaign.advance_phase() # day -> dusk
|
||||
sim.campaign.advance_phase() # dusk -> night
|
||||
await _talk_if_any()
|
||||
await _settle()
|
||||
t.check(not sim.campaign.is_daytime() and not _pad(BUILD).visible and _pad(FEAR).visible and _pad(PAUSE).visible,
|
||||
"at night: no Build; Fear and Pause (%s)" % [_shown()])
|
||||
|
||||
|
||||
func _talk_if_any() -> void:
|
||||
for k in 10:
|
||||
await t.process_frame
|
||||
if t.paused and main.screen == Main.Screen.PLAYING and sim.dialogue != null and sim.dialogue.box.conversation != null:
|
||||
sim.dialogue.box.skip()
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://blsebwt2y2slm
|
||||
|
|
@ -1,376 +0,0 @@
|
|||
extends RefCounted
|
||||
## #39, the tappable HUD, by touch through the game's entry scene (main.tscn, with test save and
|
||||
## settings paths) on a 19.5:9 phone (2340x1080 at its interface scale), with a simulated notch
|
||||
## and home indicator (MobilePort.preview_insets):
|
||||
## * Every hit target (ScarecrowHud.HitTarget) covers its drawn widget, at least
|
||||
## MobilePort.minimum_target() across, and a finger just beside one starts a thumbstick.
|
||||
## * Dialogue: a conversation that pauses the game has Skip; a tap elsewhere writes the line,
|
||||
## then goes on; Skip skips the rest (and the game goes on). One that doesn't pause has none.
|
||||
## * Tips: the tip box's × hides the tips as Backspace (hide_tips) does: dismissed for the
|
||||
## session, tips still on in Settings.
|
||||
## * Hotbar: a tap on each main weapon's slot picks that weapon, in any order; frozen (no
|
||||
## switching) a tap picks nothing, then or later; in build mode there are no slot targets. The
|
||||
## slots show no number keys.
|
||||
## * Backpack: a tap opens the pouch panel and another closes it; a finger anywhere else closes
|
||||
## it (and still starts a stick), one on the panel doesn't. The panel lies inside the safe rect
|
||||
## at 2340x1080 with the inset, and on a 1334x750 window (at the preview's scale and at an
|
||||
## iPhone SE's 1.7 cap), with and without it.
|
||||
## * Desktop (forced 0): no hit targets, and the hotbar's number keys as before.
|
||||
## The InputMap's mouse buttons for fire and offhand (TouchSticks erases them) are put back.
|
||||
|
||||
const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
const SAVE := "user://test_hud_taps_save.json"
|
||||
const SETTINGS := "user://test_hud_taps_settings.cfg"
|
||||
const PHONE := Vector2i(2340, 1080)
|
||||
const SMALL := Vector2i(1334, 750)
|
||||
const INSETS := [140, 0, 140, 60]
|
||||
const SE_DPI := 326.0 # an iPhone SE's density: past the 1.7 cap
|
||||
const W := ScarecrowCombat.Weapon
|
||||
const TALK := "res://game/resources/dialogue/morning_day_2.tres"
|
||||
|
||||
var t: GameTestRunner
|
||||
var main: Main
|
||||
var sticks: TouchSticks
|
||||
|
||||
|
||||
func run(p_t) -> void:
|
||||
t = p_t
|
||||
_clean()
|
||||
var bindings := {}
|
||||
for action: StringName in [&"fire", &"offhand"]:
|
||||
bindings[action] = InputMap.action_get_events(action)
|
||||
var size := t.root.size
|
||||
var factor := t.root.content_scale_factor
|
||||
MobilePort.forced = 1
|
||||
MobilePort.preview_insets = INSETS.duplicate()
|
||||
t.root.size = PHONE
|
||||
await _start()
|
||||
sticks = main.farm.get_node_or_null("Hud/TouchSticks") as TouchSticks
|
||||
t.check(sticks != null and t.root.content_scale_factor > 1.5, "a phone at its interface scale (%.2f), with the sticks" % t.root.content_scale_factor)
|
||||
if sticks != null:
|
||||
await _day()
|
||||
await _dialogue()
|
||||
await _tips()
|
||||
await _hotbar()
|
||||
await _backpack()
|
||||
await _fit()
|
||||
await _stop()
|
||||
MobilePort.preview_insets = []
|
||||
MobilePort.preview_dpi = 0.0
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
MobilePort.forced = 0
|
||||
await _start()
|
||||
await _desktop()
|
||||
await _stop()
|
||||
for action: StringName in bindings:
|
||||
InputMap.action_erase_events(action)
|
||||
for e: InputEvent in bindings[action]:
|
||||
InputMap.action_add_event(action, e)
|
||||
for action in [&"fire", &"offhand", &"move_left", &"move_right", &"move_forward", &"move_back",
|
||||
&"aim_left", &"aim_right", &"aim_up", &"aim_down"]:
|
||||
Input.action_release(action)
|
||||
MobilePort.forced = -1
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _start() -> void:
|
||||
main = (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
main.save_path = SAVE
|
||||
main.settings_path = SETTINGS
|
||||
t.root.add_child(main)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _stop() -> void:
|
||||
main.queue_free()
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
main = null
|
||||
|
||||
|
||||
func _frames(n: int) -> void:
|
||||
for k in n:
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _physics(n: int) -> void:
|
||||
for k in n:
|
||||
await t.physics_frame
|
||||
|
||||
|
||||
## Every hit target under Main (visible or not).
|
||||
func _targets() -> Array:
|
||||
return main.find_children("*", "", true, false).filter(func(n: Node) -> bool: return n is ScarecrowHud.HitTarget)
|
||||
|
||||
|
||||
## A new vacation's first day (no intro), its conversations over, with three main weapons and
|
||||
## pumpkin bombs owned.
|
||||
func _day() -> void:
|
||||
main.new_vacation(false)
|
||||
await t.process_frame
|
||||
main.sim.campaign.advance_phase() # the first morning's sign -> day 1
|
||||
for k in 20:
|
||||
await t.process_frame
|
||||
if t.paused and main.sim.dialogue != null and main.sim.dialogue.is_playing():
|
||||
main.sim.dialogue.box.skip()
|
||||
var s := main.sim.campaign.state
|
||||
for id in ["corn_shooter", "potato_cannon", "pumpkin_bomb"]:
|
||||
s.upgrades[id] = 1
|
||||
await _physics(2)
|
||||
await _frames(2)
|
||||
t.check(main.screen == Main.Screen.PLAYING and not t.paused and sticks.can_act(), "day 1 under way, the sticks can act")
|
||||
|
||||
|
||||
## The target covers the drawn rect r (canvas coordinates), at least the minimum target across.
|
||||
func _covers(target: Control, r: Rect2, what: String) -> void:
|
||||
var g := target.get_global_rect()
|
||||
var least := MobilePort.minimum_target(target)
|
||||
t.check(target.is_visible_in_tree() and g.grow(0.01).encloses(r) and g.size.x >= least - 0.01 and g.size.y >= least - 0.01,
|
||||
"%s: its target %s covers it (%s), at least %.0f across" % [what, g, r, least])
|
||||
|
||||
|
||||
## A finger landing just beside the target (the canvas point at) starts a stick, and lifting it
|
||||
## lets the stick go.
|
||||
func _beside(at: Vector2, what: String) -> void:
|
||||
var s := sticks.side_of(at)
|
||||
Touch.touch(0, at, true)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[s] == 0, "a finger just beside %s (%s) starts the %s stick" % [what, at, "move" if s == TouchSticks.Stick.MOVE else "attack"])
|
||||
Touch.touch(0, at, false)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[s] == -1, "(and lifting it lets it go)")
|
||||
|
||||
|
||||
func _dialogue() -> void:
|
||||
var box := main.sim.dialogue.box
|
||||
var skip := box.skip_target
|
||||
t.check(skip != null and not skip.is_visible_in_tree(), "the dialogue box has a Skip target, hidden with no conversation up")
|
||||
if skip == null:
|
||||
return
|
||||
var c := load(TALK) as Conversation
|
||||
t.check(c != null and c.pause_game and c.lines.size() >= 3, "(a conversation that pauses the game: %s)" % TALK)
|
||||
main.sim.dialogue.play(c)
|
||||
await _frames(3)
|
||||
t.check(t.paused and box.is_playing() and skip.is_visible_in_tree(), "a conversation that pauses the game shows Skip")
|
||||
var drawn := Rect2(box._sheet.global_position + box.skip_rect().position, box.skip_rect().size)
|
||||
_covers(skip, drawn, "Skip")
|
||||
t.check(MobilePort.safe_rect(box).encloses(skip.get_global_rect()), "Skip is inside the safe rect")
|
||||
# A tap elsewhere on the paper: the rest of the line, then the next one.
|
||||
var paper := Rect2(box._sheet.global_position, box._sheet.size)
|
||||
var elsewhere := paper.get_center()
|
||||
t.check(not skip.get_global_rect().has_point(elsewhere) and not box.is_written(), "(the line is being written)")
|
||||
Touch.tap(0, elsewhere)
|
||||
await t.process_frame
|
||||
t.check(box.is_playing() and box.index == 0 and box.is_written(), "a tap elsewhere writes the rest of the line")
|
||||
Touch.tap(0, elsewhere)
|
||||
await t.process_frame
|
||||
t.check(box.is_playing() and box.index == 1, "another goes on to the next line (%d)" % box.index)
|
||||
# A tap just beside Skip goes on too (a stick can't start: the game is paused).
|
||||
var g := skip.get_global_rect()
|
||||
Touch.tap(0, Vector2(g.position.x - 8.0, g.get_center().y))
|
||||
await t.process_frame
|
||||
t.check(box.is_playing() and box.index == 1 and box.is_written() and sticks.finger == [-1, -1],
|
||||
"a tap just beside Skip writes the line, as anywhere else")
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
t.check(not box.is_playing(), "a tap on Skip skips the rest of the conversation")
|
||||
await _frames(3)
|
||||
t.check(not t.paused and not skip.is_visible_in_tree(), "the game goes on, and Skip is gone")
|
||||
# One that doesn't pause the game has no Skip.
|
||||
var quiet := Conversation.new()
|
||||
quiet.pause_game = false
|
||||
quiet.lines = c.lines
|
||||
main.sim.dialogue.play(quiet)
|
||||
await _frames(3)
|
||||
t.check(box.is_playing() and not t.paused and not skip.is_visible_in_tree(), "one that doesn't pause the game has no Skip")
|
||||
box.stop()
|
||||
await _frames(2)
|
||||
|
||||
|
||||
func _tips() -> void:
|
||||
var tut := main.sim.tutorial
|
||||
var x := tut.hide_target
|
||||
t.check(x != null, "the tip box has a × target")
|
||||
if x == null:
|
||||
return
|
||||
await _frames(3)
|
||||
t.check(tut.current != "" and tut._box.visible and x.is_visible_in_tree(), "a tip is up (%s), with its ×" % tut.current)
|
||||
var box := tut._box.get_global_rect()
|
||||
var drawn := Rect2(Vector2(box.end.x - Tutorial.HIDE_INSET, box.position.y + Tutorial.HIDE_INSET) - Vector2.ONE * Tutorial.HIDE_RADIUS,
|
||||
Vector2.ONE * Tutorial.HIDE_RADIUS * 2.0)
|
||||
_covers(x, drawn, "the ×")
|
||||
var g := x.get_global_rect()
|
||||
await _beside(Vector2(g.end.x + 8.0, g.get_center().y), "the ×")
|
||||
await _beside(Vector2(box.position.x + 40.0, box.get_center().y), "the tip box (only the × is a target)")
|
||||
t.check(tut.current != "" and not tut.dismissed, "(the tip is still up)")
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
var by_x := [tut.dismissed, tut.enabled, tut.current, tut._box.visible, main.settings.show_tips]
|
||||
t.check(by_x == [true, true, "", false, true], "a tap on the × hides the tips for the session; Settings still has them on: %s" % [by_x])
|
||||
await _frames(3)
|
||||
t.check(not tut._box.visible and not x.is_visible_in_tree(), "they stay hidden, the × with them")
|
||||
# Backspace does the same.
|
||||
tut.dismissed = false
|
||||
await _frames(3)
|
||||
t.check(tut.current != "" and x.is_visible_in_tree(), "(tips back for the comparison: %s)" % tut.current)
|
||||
for pressed in [true, false]:
|
||||
var e := InputEventAction.new()
|
||||
e.action = &"hide_tips"
|
||||
e.pressed = pressed
|
||||
Input.parse_input_event(e)
|
||||
Input.flush_buffered_events()
|
||||
await t.process_frame
|
||||
var by_key := [tut.dismissed, tut.enabled, tut.current, tut._box.visible, main.settings.show_tips]
|
||||
t.check(by_key == by_x, "Backspace (hide_tips) leaves the same: %s" % [by_key])
|
||||
|
||||
|
||||
func _hotbar() -> void:
|
||||
var hud := main.sim.hud
|
||||
var combat := main.sim.combat
|
||||
var list := hud.slots()
|
||||
var mains := combat.owned_main()
|
||||
t.check(mains == [W.PITCHFORK, W.CORN_SHOOTER, W.POTATO_CANNON] and list.size() == 4, "(three main weapons and the bombs: %s)" % [mains])
|
||||
t.check(list.all(func(s: Dictionary) -> bool: return s["label"] == ""), "no number keys in the slots on a phone")
|
||||
var shown := hud.slot_targets.filter(func(c: Control) -> bool: return c.is_visible_in_tree())
|
||||
t.check(shown.size() == 3, "a target on each main weapon's slot, none on the off-hand's (%d)" % shown.size())
|
||||
if shown.size() != 3:
|
||||
return
|
||||
var rects := hud.slot_rects(list)
|
||||
for i in 3:
|
||||
_covers(hud.slot_targets[i], rects[i], "slot %d" % (i + 1))
|
||||
t.check(not hud.slot_targets[0].get_global_rect().intersects(hud.slot_targets[1].get_global_rect())
|
||||
and not hud.slot_targets[1].get_global_rect().intersects(hud.slot_targets[2].get_global_rect()), "the slots' targets don't overlap")
|
||||
t.check(not shown.any(func(c: Control) -> bool: return c.get_global_rect().intersects(rects[3])), "the bombs' slot has no target")
|
||||
for i in [1, 2, 0, 2]:
|
||||
Touch.tap(0, hud.slot_targets[i].get_global_rect().get_center())
|
||||
await _physics(3)
|
||||
t.check(combat.weapon == mains[i] and sticks.finger == [-1, -1], "a tap on slot %d picks %s (in hand: %s), no stick" % [i + 1,
|
||||
ScarecrowCombat.WEAPON_NAMES[mains[i]], ScarecrowCombat.WEAPON_NAMES[combat.weapon]])
|
||||
var g: Rect2 = hud.slot_targets[1].get_global_rect()
|
||||
await _beside(Vector2(g.get_center().x, g.position.y - 8.0), "a slot")
|
||||
await _beside(Vector2(rects[3].get_center().x, rects[3].get_center().y), "the slots (on the bombs' slot)")
|
||||
# No switching while frozen (as under a co-op menu): the tap is dropped, not kept for later.
|
||||
main.sim.local_frozen = true
|
||||
Touch.tap(1, hud.slot_targets[0].get_global_rect().get_center())
|
||||
await _physics(3)
|
||||
t.check(combat.weapon == W.POTATO_CANNON, "frozen, a tap on a slot picks nothing")
|
||||
main.sim.local_frozen = false
|
||||
await _physics(3)
|
||||
t.check(combat.weapon == W.POTATO_CANNON, "nor once it can switch again")
|
||||
main.sim.build.set_active(true)
|
||||
await _frames(2)
|
||||
t.check(hud.slots().is_empty() and not hud.slot_targets.any(func(c: Control) -> bool: return c.is_visible_in_tree()),
|
||||
"in build mode the hotbar and its targets are gone")
|
||||
main.sim.build.set_active(false)
|
||||
await _frames(2)
|
||||
Touch.tap(0, hud.slot_targets[0].get_global_rect().get_center())
|
||||
await _physics(3)
|
||||
t.check(combat.weapon == W.PITCHFORK, "back from build mode, a tap picks again")
|
||||
|
||||
|
||||
func _backpack() -> void:
|
||||
var rh := main.sim.resource_hud
|
||||
var bag := rh.backpack_target
|
||||
t.check(bag != null, "the backpack has a target")
|
||||
if bag == null:
|
||||
return
|
||||
main.sim.campaign.state.resources.add_to_pouch("wood", 3)
|
||||
await _frames(2)
|
||||
t.check(not rh.open, "(the pouch panel is closed)")
|
||||
_covers(bag, rh.icon_rect(), "the backpack")
|
||||
var g := bag.get_global_rect()
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
t.check(rh.open and sticks.finger == [-1, -1], "a tap on the backpack opens the pouch panel, no stick")
|
||||
t.check(MobilePort.safe_rect(rh).encloses(rh.panel_rect()), "the panel %s is inside the safe rect %s" % [rh.panel_rect(), MobilePort.safe_rect(rh)])
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
t.check(not rh.open, "another closes it")
|
||||
# A finger elsewhere closes it, and still starts its stick.
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
var away := Vector2(rh.size.x * 0.75, rh.size.y * 0.4)
|
||||
Touch.touch(0, away, true)
|
||||
await t.process_frame
|
||||
t.check(not rh.open and sticks.finger[TouchSticks.Stick.MOVE] == 0, "a finger elsewhere closes it, and starts the move stick")
|
||||
Touch.touch(0, away, false)
|
||||
await t.process_frame
|
||||
# One on the panel leaves it open.
|
||||
Touch.tap(0, g.get_center())
|
||||
await t.process_frame
|
||||
Touch.tap(0, rh.panel_rect().get_center())
|
||||
await t.process_frame
|
||||
t.check(rh.open, "a finger on the panel leaves it open")
|
||||
Touch.tap(1, main.sim.hud.slot_targets[1].get_global_rect().get_center())
|
||||
await _physics(3)
|
||||
t.check(not rh.open and main.sim.combat.weapon == W.CORN_SHOOTER, "a tap on a hotbar slot closes it and picks the slot")
|
||||
await _beside(Vector2(g.get_center().x, g.position.y - 8.0), "the backpack")
|
||||
t.check(not rh.open, "(still closed)")
|
||||
|
||||
|
||||
## The pouch panel and the targets (the tip's × up too) at other windows: 1334x750 at the
|
||||
## preview's scale and at an iPhone SE's (the 1.7 cap), with the inset and without.
|
||||
func _fit() -> void:
|
||||
var rh := main.sim.resource_hud
|
||||
if not rh.open:
|
||||
rh.toggle()
|
||||
main.sim.tutorial.dismissed = false
|
||||
for dpi: float in [0.0, SE_DPI]:
|
||||
for inset in [INSETS, []]:
|
||||
MobilePort.preview_dpi = dpi
|
||||
MobilePort.preview_insets = inset.duplicate()
|
||||
t.root.size = SMALL
|
||||
main.settings.apply_scale(t.root)
|
||||
await _frames(3)
|
||||
var canvas := t.root.get_visible_rect().size
|
||||
var safe := MobilePort.safe_rect(rh)
|
||||
var what := "%s at x%.2f (canvas %dx%d)%s" % [SMALL, t.root.content_scale_factor, roundi(canvas.x), roundi(canvas.y),
|
||||
" with the inset" if not inset.is_empty() else ""]
|
||||
t.check(safe.encloses(rh.panel_rect()), "%s: the pouch panel %s is inside the safe rect %s" % [what, rh.panel_rect(), safe])
|
||||
var least := MobilePort.minimum_target(rh)
|
||||
var small := _targets().filter(func(c: Control) -> bool:
|
||||
return c.is_visible_in_tree() and (c.size.x < least - 0.01 or c.size.y < least - 0.01))
|
||||
t.check(small.is_empty(), "%s: every target is at least %.0f across (%s)" % [what, least, small.map(func(c: Control) -> String: return c.name)])
|
||||
var shown := _targets().filter(func(c: Control) -> bool: return c.is_visible_in_tree())
|
||||
var off := shown.filter(func(c: Control) -> bool: return not Rect2(Vector2.ZERO, canvas).encloses(c.get_global_rect()))
|
||||
t.check(shown.size() == 5 and off.is_empty(), "%s: the 5 targets up (3 slots, the backpack, the ×) are on the canvas (off it: %s)" % [
|
||||
what, off.map(func(c: Control) -> String: return c.name)])
|
||||
t.check(is_equal_approx(t.root.content_scale_factor, MobilePort.MAX_SCALE) and t.root.get_visible_rect().size.y < 640.0,
|
||||
"(the SE's density came to the 1.7 cap: %.2f)" % t.root.content_scale_factor)
|
||||
rh.toggle()
|
||||
main.sim.tutorial.hide_tips()
|
||||
|
||||
|
||||
func _desktop() -> void:
|
||||
main.new_vacation(false)
|
||||
await t.process_frame
|
||||
main.sim.campaign.advance_phase()
|
||||
for k in 20:
|
||||
await t.process_frame
|
||||
if t.paused and main.sim.dialogue != null and main.sim.dialogue.is_playing():
|
||||
main.sim.dialogue.box.skip()
|
||||
var s := main.sim.campaign.state
|
||||
for id in ["corn_shooter", "potato_cannon", "pumpkin_bomb"]:
|
||||
s.upgrades[id] = 1
|
||||
await _physics(2)
|
||||
await _frames(2)
|
||||
t.check(main.farm.get_node_or_null("Hud/TouchSticks") == null, "desktop: no sticks")
|
||||
t.check(_targets().is_empty() and main.sim.hud.slot_targets.is_empty() and main.sim.resource_hud.backpack_target == null
|
||||
and main.sim.tutorial.hide_target == null and main.sim.dialogue.box.skip_target == null, "desktop: no hit targets")
|
||||
var labels := main.sim.hud.slots().map(func(d: Dictionary) -> String: return d["label"])
|
||||
t.check(labels == ["1", "2", "3", ""], "desktop: the slots' numbers as before (%s)" % [labels])
|
||||
t.check(Prompts.hotbar_key(1) == "1" and Prompts.hotbar_key(6) == "6" and Prompts.hotbar_key(0) == "", "desktop: Prompts.hotbar_key is the number")
|
||||
var rh := main.sim.resource_hud
|
||||
var icon := rh.icon_rect()
|
||||
t.check(rh.panel_rect() == Rect2(Vector2(icon.position.x - 4.0, icon.position.y - 14.0 - 248.0), Vector2(ResourceHud.PANEL_WIDTH, 248.0)),
|
||||
"desktop: the pouch panel where it was (%s)" % rh.panel_rect())
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://b4y1im78s3fj3
|
||||
|
|
@ -1,546 +0,0 @@
|
|||
extends RefCounted
|
||||
## #41, the menus and settings at phone scale, through the entry scene (main.tscn, test save and
|
||||
## settings paths) with MobilePort.forced:
|
||||
## * Fitting: the main menu, the pause menu, the question (ConfirmBox), and settings keep every
|
||||
## button inside the safe area, at least the minimum touch target tall, on a 19.5:9 phone
|
||||
## (about 1.6x, notch and home indicator insets), an iPhone SE (the 1.7 cap, the same insets),
|
||||
## and a 4:3 iPad (1x, status bar and home indicator insets); the main menu's column stays
|
||||
## clear of its credits, and the pause menu's buttons keep their focus order.
|
||||
## * Phone settings: Audio, Touch (Interface size, Swap sticks, Camera distance, Haptics, the touch
|
||||
## guide), Display (3D resolution scale), Gameplay; none of the desktop-only rows. The list
|
||||
## scrolls by dragging (from a slider too, which then keeps its value); a sideways drag moves a
|
||||
## slider and doesn't scroll; a drag from a check box doesn't toggle it, a tap does. The
|
||||
## Interface size applies when its finger lifts.
|
||||
## * GameSettings: the touch settings round-trip through the file, with fallbacks and clamping;
|
||||
## Swap sticks reaches every node in &"touch_controls" (a stub here: TouchSticks and
|
||||
## TouchButtons join with #38); Camera distance sets the follow camera on a phone (at start and
|
||||
## live), never on desktop; Reset to defaults leaves what isn't shown alone (both platforms).
|
||||
## * Haptics: a hit buzzes (Scarecrow.buzz) on a phone with it on, not with it off, never on
|
||||
## desktop.
|
||||
## * Desktop (forced 0): the settings list has the same sections and rows as before, at the same
|
||||
## sizes.
|
||||
|
||||
const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
const SAVE := "user://test_menus_save.json"
|
||||
const SETTINGS := "user://test_menus_settings.cfg"
|
||||
const ROUND_TRIP := "user://test_menus_round_trip.cfg"
|
||||
const DT := 1.0 / 60.0
|
||||
## name, window pixels, density (0: the preview's guess from the shape), insets in window pixels
|
||||
## (left, top, right, bottom), and the canvas that gives (about).
|
||||
const DEVICES := [
|
||||
["19.5:9 phone", Vector2i(2340, 1080), 0.0, [140, 0, 140, 60], Vector2(1469, 678)],
|
||||
["iPhone SE", Vector2i(1334, 750), 326.0, [140, 0, 140, 60], Vector2(1130, 635)],
|
||||
["4:3 iPad", Vector2i(1600, 1200), 0.0, [0, 40, 0, 40], Vector2(1920, 1440)],
|
||||
]
|
||||
## The desktop settings list, as before #41: a head, a row (its label), a check box, a note, or
|
||||
## the bindings grid (its cell count).
|
||||
const DESKTOP_ROWS := [
|
||||
"head:Audio", "row:Master volume", "row:Music and stingers", "row:Sound effects", "row:Ambience",
|
||||
"row:Voice chat (your friend)",
|
||||
"head:Controls", "row:Move stick dead zone", "row:Aim stick dead zone",
|
||||
"note:Mouse aim follows the cursor directly, so it has no sensitivity to set.", "grid:51",
|
||||
"head:Display", "check:Fullscreen", "check:VSync", "row:Pixel size", "row:3D resolution scale",
|
||||
"note:Pixel size 1 turns the pixel look off; the resolution scale is used only then.",
|
||||
"head:Gameplay", "check:Tips on the first day and night",
|
||||
"head:Co-op", "row:Your name", "check:Send my microphone in voice chat",
|
||||
]
|
||||
const PHONE_ROWS := [
|
||||
"head:Audio", "row:Master volume", "row:Music and stingers", "row:Sound effects", "row:Ambience",
|
||||
"row:Voice chat (your friend)",
|
||||
"head:Touch", "row:Interface size", "check:Swap the sticks (move on the left)", "row:Camera distance",
|
||||
"check:Buzz when the scarecrow is hit", "note:Playing by touch", "guide", "guide", "guide", "guide", "guide",
|
||||
"head:Display", "row:3D resolution scale",
|
||||
"head:Gameplay", "check:Tips on the first day and night",
|
||||
]
|
||||
|
||||
|
||||
## A node in &"touch_controls" standing in for TouchSticks and TouchButtons (#38).
|
||||
class Stub extends Node:
|
||||
var calls: Array = [] # swap_sticks at each apply_settings
|
||||
|
||||
func apply_settings(s: GameSettings) -> void:
|
||||
calls.append(s.swap_sticks)
|
||||
|
||||
|
||||
var t: GameTestRunner
|
||||
var main: Main
|
||||
|
||||
|
||||
func run(p_t) -> void:
|
||||
t = p_t
|
||||
var root := t.root
|
||||
var pixels := [root.scaling_3d_mode, root.scaling_3d_scale, root.msaa_3d]
|
||||
_clean()
|
||||
_round_trip()
|
||||
MobilePort.forced = 1
|
||||
var seed := GameSettings.new() # a phone's defaults, but the camera at 15 m
|
||||
seed.camera_distance = 15.0
|
||||
seed.save_to(SETTINGS)
|
||||
_set_device(DEVICES[0])
|
||||
main = await _start()
|
||||
_camera(15.0, "phones: the Camera distance setting (15) decides the camera's distance at start")
|
||||
for d: Array in DEVICES:
|
||||
await _device(d)
|
||||
await _main_menu(d[0])
|
||||
await _confirm_over(main.main_menu, d[0] + " (main menu)")
|
||||
await _settings_layout(d[0])
|
||||
await _device(DEVICES[0])
|
||||
main.main_menu.new_button.pressed.emit()
|
||||
t.check(main.screen == Main.Screen.PLAYING, "(a new vacation)")
|
||||
main.pause()
|
||||
for d: Array in DEVICES:
|
||||
await _device(d)
|
||||
await _pause_menu(d[0])
|
||||
main.pause_menu.restart_button.pressed.emit()
|
||||
await _confirm_over(main.pause_menu, d[0] + " (pause menu)")
|
||||
await _device(DEVICES[0])
|
||||
main.pause_menu.settings_button.pressed.emit()
|
||||
await _frames()
|
||||
_phone_rows()
|
||||
await _drags()
|
||||
await _swap()
|
||||
await _camera_live()
|
||||
await _interface_size()
|
||||
await _reset_phone()
|
||||
main.settings_menu.back_button.pressed.emit()
|
||||
main.resume()
|
||||
await _haptics_phone()
|
||||
await _stop()
|
||||
|
||||
MobilePort.forced = 0
|
||||
MobilePort.preview_insets = []
|
||||
MobilePort.preview_dpi = 0.0
|
||||
root.size = Vector2i(1920, 1080)
|
||||
seed.haptics = true
|
||||
seed.save_to(SETTINGS)
|
||||
main = await _start()
|
||||
_camera(16.0, "desktop: the camera starts 16 m away whatever the Camera distance setting (15)")
|
||||
await _desktop()
|
||||
await _stop()
|
||||
|
||||
MobilePort.forced = -1
|
||||
MobilePort.preview_insets = []
|
||||
MobilePort.preview_dpi = 0.0
|
||||
Scarecrow.haptics = false
|
||||
GameSettings.new().apply(null) # the defaults for the audio and dead zones, as test_save does
|
||||
root.scaling_3d_mode = pixels[0]
|
||||
root.scaling_3d_scale = pixels[1]
|
||||
root.msaa_3d = pixels[2]
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS, ROUND_TRIP]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _start() -> Main:
|
||||
var m := (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
m.save_path = SAVE
|
||||
m.settings_path = SETTINGS
|
||||
t.root.add_child(m)
|
||||
await _frames()
|
||||
await t.physics_frame
|
||||
return m
|
||||
|
||||
|
||||
func _stop() -> void:
|
||||
main.queue_free()
|
||||
main = null
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _frames() -> void:
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _set_device(d: Array) -> void:
|
||||
MobilePort.preview_dpi = d[2]
|
||||
MobilePort.preview_insets = d[3]
|
||||
t.root.size = d[1]
|
||||
|
||||
|
||||
## The window turns into this device: its size, density, and insets, and the scale for it.
|
||||
func _device(d: Array) -> void:
|
||||
_set_device(d)
|
||||
main.settings.apply_scale(t.root)
|
||||
await _frames()
|
||||
var canvas := t.root.get_visible_rect().size
|
||||
var want: Vector2 = d[4]
|
||||
t.check(absf(canvas.x - want.x) < 3.0 and absf(canvas.y - want.y) < 3.0,
|
||||
"%s: the canvas is about %s (%s, ×%.2f)" % [d[0], want, canvas, t.root.content_scale_factor])
|
||||
|
||||
|
||||
## Each control visible in the safe area, at least the minimum target tall when it's a target.
|
||||
func _fit(where: String, what: String, controls: Array, safe: Rect2, target: float, tall := true) -> void:
|
||||
var bad := PackedStringArray()
|
||||
for c: Control in controls:
|
||||
var r := c.get_global_rect()
|
||||
var name := (c as Button).text if c is Button else String(c.name)
|
||||
if not c.is_visible_in_tree():
|
||||
bad.append("%s hidden" % name)
|
||||
elif not safe.grow(0.5).encloses(r):
|
||||
bad.append("%s at %s" % [name, r])
|
||||
elif tall and r.size.y < target - 0.5:
|
||||
bad.append("%s %.0f tall" % [name, r.size.y])
|
||||
t.check(bad.is_empty(), "%s: %s inside the safe area %s%s (%s)" % [where, what, Rect2i(safe),
|
||||
", at least %.0f tall" % target if tall else "", ", ".join(bad) if not bad.is_empty() else "all %d" % controls.size()])
|
||||
|
||||
|
||||
func _main_menu(device: String) -> void:
|
||||
var mm := main.main_menu
|
||||
t.check(mm.visible and main.screen == Main.Screen.MENU, "(%s: the main menu)" % device)
|
||||
var safe := MobilePort.safe_rect(mm)
|
||||
var target := MobilePort.minimum_target(mm)
|
||||
_fit(device + " main menu", "Continue, New vacation, and Settings", [mm.continue_button, mm.new_button, mm.settings_button], safe, target)
|
||||
_fit(device + " main menu", "the title, the save note, and the credits", [mm._title, mm._sub, mm.save_note, mm._credits], safe, target, false)
|
||||
var column := mm._box.get_global_rect()
|
||||
var credits := mm._credits.get_global_rect()
|
||||
t.check(column.end.y <= credits.position.y, "%s main menu: the column (to %.0f) stays above the credits (from %.0f)" % [device, column.end.y, credits.position.y])
|
||||
t.check(not mm.coop_button.visible and not mm.quit_button.visible, "%s main menu: no co-op, no Quit" % device)
|
||||
|
||||
|
||||
func _pause_menu(device: String) -> void:
|
||||
var pm := main.pause_menu
|
||||
t.check(pm.visible and main.screen == Main.Screen.PAUSED, "(%s: the pause menu)" % device)
|
||||
var safe := MobilePort.safe_rect(pm)
|
||||
var target := MobilePort.minimum_target(pm)
|
||||
_fit(device + " pause menu", "Resume, Restart the night, Settings, and Save & quit", [pm.resume_button, pm.restart_button,
|
||||
pm.settings_button, pm.menu_button], safe, target)
|
||||
_fit(device + " pause menu", "the panel", [pm._panel], safe, target, false)
|
||||
t.check(pm.resume_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.restart_button
|
||||
and pm.restart_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.settings_button
|
||||
and pm.settings_button.find_valid_focus_neighbor(SIDE_BOTTOM) == pm.menu_button
|
||||
and pm.menu_button.find_valid_focus_neighbor(SIDE_TOP) == pm.settings_button,
|
||||
"%s pause menu: up and down go through the buttons in order" % device)
|
||||
|
||||
|
||||
## A question over this menu (the longest the game asks).
|
||||
func _confirm_over(menu: Control, where: String) -> void:
|
||||
var box := main.confirm
|
||||
if not box.is_open:
|
||||
box.ask("Start a new vacation? It replaces your saved one (the morning of day 12 of 30).", "New vacation", func() -> void: pass)
|
||||
await _frames()
|
||||
var safe := MobilePort.safe_rect(box)
|
||||
var target := MobilePort.minimum_target(box)
|
||||
_fit(where + " question", "its two buttons", [box.yes_button, box.no_button], safe, target)
|
||||
_fit(where + " question", "the message", [box.message], safe, target, false)
|
||||
t.check(box.no_button.has_focus(), "%s question: Cancel is focused" % where)
|
||||
box.close()
|
||||
t.check(menu.visible, "(%s: closed, the menu still there)" % where)
|
||||
|
||||
|
||||
func _settings_layout(device: String) -> void:
|
||||
main.main_menu.settings_button.pressed.emit()
|
||||
var sm := main.settings_menu
|
||||
await _frames()
|
||||
t.check(sm.is_open, "(%s: settings)" % device)
|
||||
var safe := MobilePort.safe_rect(sm)
|
||||
var target := MobilePort.minimum_target(sm)
|
||||
_fit(device + " settings", "Back and Reset to defaults", [sm.back_button, sm.reset_button], safe, target)
|
||||
_fit(device + " settings", "the panel and its list", [sm._panel, sm._scroll], safe, target, false)
|
||||
var short := PackedStringArray()
|
||||
for c in sm._tall:
|
||||
if c.size.y < target - 0.5:
|
||||
short.append("%s %.0f" % [c.name, c.size.y])
|
||||
t.check(sm._tall.size() == 11 and short.is_empty(), "%s settings: every row (%d) at least %.0f tall (%s)" % [device,
|
||||
sm._tall.size(), target, ", ".join(short)])
|
||||
t.check(sm._scroll.size.y >= 240.0, "%s settings: the list shows a good part (%.0f tall)" % [device, sm._scroll.size.y])
|
||||
sm.back_button.pressed.emit()
|
||||
await _frames()
|
||||
t.check(not sm.is_open and main.main_menu.settings_button.has_focus(), "(%s: back to the main menu)" % device)
|
||||
|
||||
|
||||
func _row_name(c: Node) -> String:
|
||||
if c is CheckBox:
|
||||
return "check:" + (c as CheckBox).text
|
||||
if c is GridContainer:
|
||||
return "grid:%d" % c.get_child_count()
|
||||
if c is HBoxContainer:
|
||||
return "row:" + (c.get_child(0) as Label).text
|
||||
var l := c as Label
|
||||
if l == null:
|
||||
return c.get_class()
|
||||
if l.autowrap_mode != TextServer.AUTOWRAP_OFF:
|
||||
return "guide"
|
||||
return ("head:" if l.get_theme_font_size(&"font_size") == 28 else "note:") + l.text
|
||||
|
||||
|
||||
func _rows(sm: SettingsMenu) -> Array:
|
||||
return sm._box.get_children().map(_row_name)
|
||||
|
||||
|
||||
func _phone_rows() -> void:
|
||||
var sm := main.settings_menu
|
||||
var rows := _rows(sm)
|
||||
t.check(rows == PHONE_ROWS, "phone settings: Audio, Touch with the guide, Display, Gameplay (%s)" % ", ".join(rows))
|
||||
for key in ["move_dead_zone", "aim_dead_zone", "fullscreen", "vsync", "pixel_size", "player_name", "microphone"]:
|
||||
t.check(not sm.controls.has(key), "phone settings: no %s" % key)
|
||||
var guide := SettingsMenu.touch_guide()
|
||||
t.check(guide[0] == "Move: touch the right half of the screen and slide your thumb."
|
||||
and guide[1] == "Attack: touch the left half and slide toward an alien to aim and attack.",
|
||||
"the guide's sticks follow Prompts (move on the %s): '%s'" % [Prompts.move_side(), guide[0]])
|
||||
var all := " ".join(guide)
|
||||
t.check(["Use", "Build", "Fear", "Bomb", "Patch", "Pause", "hotbar", "backpack"].all(func(w: String) -> bool: return all.contains(w)),
|
||||
"and it names Use, Build, Fear, Bomb, Patch, Pause, the hotbar, and the backpack")
|
||||
var shown := sm._guide.map(func(l: Label) -> String: return l.text)
|
||||
t.check(shown == Array(guide), "the guide shows those lines")
|
||||
t.check((sm._values["camera_distance"] as Label).text == "15 m" and (sm._values["interface_size"] as Label).text == "100%",
|
||||
"Camera distance reads 15 m and Interface size 100%")
|
||||
|
||||
|
||||
## Fingers on the list: scrolling from a slider leaves its value; sideways moves it.
|
||||
func _drags() -> void:
|
||||
var sm := main.settings_menu
|
||||
var scroll := sm._scroll
|
||||
var music := sm.controls["volume/Music"] as HSlider
|
||||
scroll.scroll_vertical = 0
|
||||
await _frames()
|
||||
var before := music.value
|
||||
var at := music.get_global_rect().get_center()
|
||||
_swipe(at, at + Vector2(6.0, -180.0))
|
||||
await _frames()
|
||||
t.check(is_equal_approx(music.value, before) and scroll.scroll_vertical > 100,
|
||||
"a drag up starting on a slider scrolls the list (%d px) and leaves the value (%.2f)" % [scroll.scroll_vertical, music.value])
|
||||
scroll.scroll_vertical = 0
|
||||
await _frames()
|
||||
at = music.get_global_rect().get_center()
|
||||
_swipe(at, at + Vector2(-160.0, 10.0))
|
||||
await _frames()
|
||||
t.check(music.value < before - 0.1 and scroll.scroll_vertical == 0,
|
||||
"a sideways drag moves the slider (%.2f, was %.2f) and doesn't scroll" % [music.value, before])
|
||||
var r := music.get_global_rect()
|
||||
Touch.tap(0, Vector2(r.end.x - 2.0, r.get_center().y))
|
||||
t.check(is_equal_approx(music.value, 1.0) and is_equal_approx(main.settings.volume["Music"], 1.0),
|
||||
"a tap at a slider's end sets it there (%.2f)" % music.value)
|
||||
var tips := sm.controls["show_tips"] as CheckBox
|
||||
scroll.ensure_control_visible(tips)
|
||||
await _frames()
|
||||
var top := scroll.scroll_vertical
|
||||
var on := tips.button_pressed
|
||||
at = tips.get_global_rect().get_center()
|
||||
_swipe(at, at + Vector2(0.0, 150.0))
|
||||
await _frames()
|
||||
t.check(tips.button_pressed == on and scroll.scroll_vertical < top - 80,
|
||||
"a drag down from a check box scrolls (%d to %d) and doesn't toggle it" % [top, scroll.scroll_vertical])
|
||||
scroll.ensure_control_visible(tips)
|
||||
await _frames()
|
||||
Touch.tap(0, tips.get_global_rect().get_center())
|
||||
t.check(tips.button_pressed != on and main.settings.show_tips != on, "a tap on it toggles it")
|
||||
tips.button_pressed = on
|
||||
|
||||
|
||||
## A finger down at one point, moved to another in steps, and lifted.
|
||||
func _swipe(from: Vector2, to: Vector2, steps := 8) -> void:
|
||||
Touch.touch(0, from, true)
|
||||
var last := from
|
||||
for i in steps:
|
||||
var p := from.lerp(to, float(i + 1) / steps)
|
||||
Touch.drag(0, last, p)
|
||||
last = p
|
||||
Touch.touch(0, to, false)
|
||||
|
||||
|
||||
func _swap() -> void:
|
||||
var sm := main.settings_menu
|
||||
var stub := Stub.new()
|
||||
t.root.add_child(stub)
|
||||
stub.add_to_group(&"touch_controls")
|
||||
var swap := sm.controls["swap_sticks"] as CheckBox
|
||||
sm._scroll.ensure_control_visible(swap)
|
||||
await _frames()
|
||||
t.check(not swap.button_pressed and not main.settings.swap_sticks, "(Swap sticks off)")
|
||||
Touch.tap(0, swap.get_global_rect().get_center())
|
||||
t.check(swap.button_pressed and main.settings.swap_sticks and stub.calls == [true]
|
||||
and GameSettings.load_from(SETTINGS).swap_sticks,
|
||||
"tapping Swap sticks saves it and hands the settings to the touch controls (%s)" % [stub.calls])
|
||||
swap.button_pressed = false
|
||||
t.check(stub.calls == [true, false] and not GameSettings.load_from(SETTINGS).swap_sticks, "and off again")
|
||||
stub.free()
|
||||
|
||||
|
||||
func _camera(want: float, what: String) -> void:
|
||||
var cam := main.sim.camera as FollowCamera
|
||||
t.check(cam != null and is_equal_approx(cam.distance, want) and cam.is_in_group(FollowCamera.GROUP), "%s (%.1f)" % [what, cam.distance])
|
||||
|
||||
|
||||
func _camera_live() -> void:
|
||||
var slider := main.settings_menu.controls["camera_distance"] as HSlider
|
||||
t.check(slider.min_value == 8.0 and slider.max_value == 20.0, "Camera distance goes from 8 to 20 m")
|
||||
slider.value = 19.0
|
||||
_camera(19.0, "moving Camera distance moves the camera at once")
|
||||
t.check(is_equal_approx(GameSettings.load_from(SETTINGS).camera_distance, 19.0) and (main.settings_menu._values["camera_distance"] as Label).text == "19 m",
|
||||
"and it's saved and reads 19 m")
|
||||
slider.value = 15.0
|
||||
|
||||
|
||||
## Interface size: the menu rescales only when the finger lifts.
|
||||
func _interface_size() -> void:
|
||||
var sm := main.settings_menu
|
||||
var slider := sm.controls["interface_size"] as HSlider
|
||||
t.check(is_equal_approx(slider.min_value, 0.8) and is_equal_approx(slider.max_value, 1.3), "Interface size goes from 80% to 130%")
|
||||
sm._scroll.ensure_control_visible(slider)
|
||||
await _frames()
|
||||
var factor := t.root.content_scale_factor
|
||||
var r := slider.get_global_rect()
|
||||
var from := r.get_center()
|
||||
var to := Vector2(r.end.x - 4.0, from.y)
|
||||
Touch.touch(0, from, true)
|
||||
Touch.drag(0, from, from + Vector2(40.0, 0.0))
|
||||
Touch.drag(0, from + Vector2(40.0, 0.0), to)
|
||||
t.check(slider.value > 1.2 and is_equal_approx(t.root.content_scale_factor, factor) and main.settings.interface_size == 1.0,
|
||||
"dragging Interface size (to %d%%) doesn't rescale yet" % roundi(slider.value * 100.0))
|
||||
Touch.touch(0, to, false)
|
||||
t.check(is_equal_approx(main.settings.interface_size, slider.value) and is_equal_approx(t.root.content_scale_factor, MobilePort.ui_scale(slider.value))
|
||||
and t.root.content_scale_factor > factor * 1.15, "lifting the finger applies it: ×%.2f, was ×%.2f" % [t.root.content_scale_factor, factor])
|
||||
await _frames()
|
||||
var safe := MobilePort.safe_rect(sm)
|
||||
_fit("at %d%%" % roundi(slider.value * 100.0), "settings' panel and buttons", [sm._panel, sm.back_button, sm.reset_button], safe,
|
||||
MobilePort.minimum_target(sm))
|
||||
slider.value = 1.0
|
||||
t.check(is_equal_approx(t.root.content_scale_factor, factor) and main.settings.interface_size == 1.0, "a key or a set value applies at once (back to 100%)")
|
||||
await _frames()
|
||||
|
||||
|
||||
func _reset_phone() -> void:
|
||||
var sm := main.settings_menu
|
||||
var s := main.settings
|
||||
s.move_dead_zone = 0.5
|
||||
s.aim_dead_zone = 0.6
|
||||
s.fullscreen = true
|
||||
s.vsync = false
|
||||
s.pixel_size = 3
|
||||
s.volume["Music"] = 0.2
|
||||
s.interface_size = 1.0 # (the canvas stays; the reset of the size itself is checked on desktop's side)
|
||||
s.swap_sticks = true
|
||||
s.camera_distance = 18.0
|
||||
s.haptics = false
|
||||
s.resolution_scale = 0.6
|
||||
s.show_tips = false
|
||||
sm.reset_to_defaults()
|
||||
var fresh := GameSettings.new()
|
||||
t.check(s.volume["Music"] == fresh.volume["Music"] and not s.swap_sticks and s.camera_distance == FollowCamera.PHONE_DISTANCE
|
||||
and s.haptics and s.resolution_scale == fresh.resolution_scale and s.show_tips,
|
||||
"phone Reset to defaults resets what's shown (volumes, the touch settings, resolution, tips)")
|
||||
t.check(s.move_dead_zone == 0.5 and s.aim_dead_zone == 0.6 and s.fullscreen and not s.vsync and s.pixel_size == 3,
|
||||
"and leaves the hidden ones alone (dead zones, Fullscreen, VSync, pixel size)")
|
||||
_camera(FollowCamera.PHONE_DISTANCE, "and the camera goes back to 12 m")
|
||||
s.move_dead_zone = fresh.move_dead_zone
|
||||
s.aim_dead_zone = fresh.aim_dead_zone
|
||||
s.fullscreen = false
|
||||
s.vsync = true
|
||||
s.pixel_size = fresh.pixel_size
|
||||
s.camera_distance = 15.0
|
||||
sm._load()
|
||||
main._on_settings_changed()
|
||||
|
||||
|
||||
func _haptics_phone() -> void:
|
||||
var sim := main.sim
|
||||
sim.intro.skip() # (the scarecrow can't be hit during the intro)
|
||||
var waited := 0.0
|
||||
while sim.intro.busy() and waited < 10.0:
|
||||
sim.intro.step(DT)
|
||||
waited += DT
|
||||
var kit := sim.scarecrow
|
||||
t.check(kit.alive and not sim.intro.busy(), "(the intro skipped: the first morning)")
|
||||
var hp := kit.hp()
|
||||
t.check(main.settings.haptics and Scarecrow.haptics, "phones: Haptics on (the default) arms the buzz")
|
||||
var n := Scarecrow.buzzes
|
||||
kit.invulnerable_left = 0.0
|
||||
t.check(kit.try_damage(1) and Scarecrow.buzzes == n + 1, "phones: a hit buzzes with Haptics on")
|
||||
t.check(not kit.try_damage(1) and Scarecrow.buzzes == n + 1, "a hit refused (invulnerable) doesn't")
|
||||
main.settings.haptics = false
|
||||
main._on_settings_changed()
|
||||
kit.invulnerable_left = 0.0
|
||||
t.check(not Scarecrow.haptics and kit.try_damage(1) and Scarecrow.buzzes == n + 1, "with Haptics off a hit doesn't buzz")
|
||||
main.settings.haptics = true
|
||||
main._on_settings_changed()
|
||||
kit.invulnerable_left = 0.0
|
||||
main.sim.campaign.state.scarecrow_hp = hp
|
||||
|
||||
|
||||
## The settings file's touch section: saved, loaded, clamped, and a default when it's wrong.
|
||||
func _round_trip() -> void:
|
||||
var g := GameSettings.new()
|
||||
t.check(not g.swap_sticks and g.camera_distance == FollowCamera.PHONE_DISTANCE and g.haptics and g.interface_size == 1.0,
|
||||
"touch defaults: sticks as they are, the camera 12 m, Haptics on, Interface size 100%")
|
||||
g.swap_sticks = true
|
||||
g.camera_distance = 17.0
|
||||
g.haptics = false
|
||||
g.interface_size = 1.15
|
||||
g.save_to(ROUND_TRIP)
|
||||
var f := ConfigFile.new()
|
||||
f.load(ROUND_TRIP)
|
||||
t.check(f.get_value("touch", "swap_sticks") == true and f.get_value("touch", "camera_distance") == 17.0
|
||||
and f.get_value("touch", "haptics") == false and is_equal_approx(f.get_value("touch", "interface_size"), 1.15),
|
||||
"they're saved under [touch]: %s" % [f.get_section_keys("touch")])
|
||||
var back := GameSettings.load_from(ROUND_TRIP)
|
||||
t.check(back.swap_sticks and back.camera_distance == 17.0 and not back.haptics and is_equal_approx(back.interface_size, 1.15),
|
||||
"and load back")
|
||||
for bad: Array in [[30.0, 20.0, "too far: 20"], [2, 8.0, "too close: 8"], ["far", 12.0, "not a number: 12"], [NAN, 12.0, "NaN: 12"]]:
|
||||
f.set_value("touch", "camera_distance", bad[0])
|
||||
f.save(ROUND_TRIP)
|
||||
t.check(GameSettings.load_from(ROUND_TRIP).camera_distance == bad[1], "a camera distance %s" % bad[2])
|
||||
f.set_value("touch", "swap_sticks", "yes")
|
||||
f.set_value("touch", "haptics", 0)
|
||||
f.save(ROUND_TRIP)
|
||||
var odd := GameSettings.load_from(ROUND_TRIP)
|
||||
t.check(not odd.swap_sticks and odd.haptics, "Swap sticks and Haptics that aren't true/false load as the defaults (off, on)")
|
||||
f.erase_section("touch")
|
||||
f.save(ROUND_TRIP)
|
||||
var none := GameSettings.load_from(ROUND_TRIP)
|
||||
t.check(not none.swap_sticks and none.camera_distance == 12.0 and none.haptics and none.interface_size == 1.0,
|
||||
"a file without [touch] (from before) loads the defaults")
|
||||
|
||||
|
||||
func _desktop() -> void:
|
||||
t.check(t.root.content_scale_factor == 1.0 and not Scarecrow.haptics, "desktop: factor 1, and no buzz armed though Haptics is on")
|
||||
var kit := main.sim.scarecrow
|
||||
var n := Scarecrow.buzzes
|
||||
kit.invulnerable_left = 0.0
|
||||
t.check(kit.try_damage(1) and Scarecrow.buzzes == n, "desktop: a hit doesn't buzz")
|
||||
kit.invulnerable_left = 0.0
|
||||
var mm := main.main_menu
|
||||
t.check(mm._box.position == Vector2(110.0, 150.0) and mm._shade.offset_right == 700.0 and mm.new_button.custom_minimum_size == Vector2(380.0, 62.0)
|
||||
and mm._credits.autowrap_mode == TextServer.AUTOWRAP_OFF and mm._credits.offset_top == -60.0,
|
||||
"desktop main menu: the column at (110, 150), the shade 700 wide, 380x62 buttons, the credits as before")
|
||||
main.main_menu.settings_button.pressed.emit()
|
||||
await _frames()
|
||||
var sm := main.settings_menu
|
||||
var rows := _rows(sm)
|
||||
t.check(rows == DESKTOP_ROWS, "desktop settings: the same sections and rows as before (%s)" % ", ".join(rows))
|
||||
var music := sm.controls["volume/Music"] as HSlider
|
||||
t.check(not (music is SettingsMenu.TouchSlider) and music.custom_minimum_size == Vector2(440.0, 32.0)
|
||||
and (music.get_parent().get_child(0) as Label).custom_minimum_size == Vector2(340.0, 0.0)
|
||||
and sm._scroll.custom_minimum_size == Vector2(980.0, 640.0) and sm.back_button.custom_minimum_size == Vector2(220.0, 54.0)
|
||||
and sm.reset_button.custom_minimum_size == Vector2(280.0, 54.0) and sm._title.get_theme_font_size(&"font_size") == 44
|
||||
and sm.offset_left == 0.0 and sm.offset_bottom == 0.0 and sm._tall.is_empty(),
|
||||
"desktop settings: the same sizes (sliders 440x32, labels 340, the list 980x640, buttons 220 and 280 by 54)")
|
||||
var panel := sm._panel.get_global_rect()
|
||||
t.check(panel.get_center().distance_to(Vector2(960.0, 540.0)) <= 1.0, "desktop settings: centered (%s)" % panel)
|
||||
for key in ["interface_size", "swap_sticks", "camera_distance", "haptics"]:
|
||||
t.check(not sm.controls.has(key), "desktop settings: no %s" % key)
|
||||
var s := main.settings
|
||||
s.interface_size = 1.2
|
||||
s.swap_sticks = true
|
||||
s.camera_distance = 18.0
|
||||
s.haptics = false
|
||||
s.move_dead_zone = 0.5
|
||||
sm.reset_to_defaults()
|
||||
t.check(is_equal_approx(s.interface_size, 1.2) and s.swap_sticks and s.camera_distance == 18.0 and not s.haptics,
|
||||
"desktop Reset to defaults leaves the touch settings alone")
|
||||
t.check(s.move_dead_zone == GameSettings.new().move_dead_zone, "and resets what's shown (the dead zone)")
|
||||
_camera(16.0, "desktop: the Camera distance setting never moves the camera")
|
||||
sm.back_button.pressed.emit()
|
||||
await _frames()
|
||||
var pm := main.pause_menu
|
||||
t.check(pm._side == null and pm.resume_button.get_parent() == pm._box and pm.resume_button.custom_minimum_size == Vector2(420.0, 56.0)
|
||||
and pm._assets[0].get_parent() is HBoxContainer and pm.offset_top == 0.0,
|
||||
"desktop pause menu: one column, 420x56 buttons, as before")
|
||||
var box := main.confirm
|
||||
t.check(box.yes_button.custom_minimum_size == Vector2(240.0, 54.0) and box.no_button.custom_minimum_size == Vector2(200.0, 54.0)
|
||||
and box.offset_left == 0.0 and box.offset_bottom == 0.0, "desktop question: 240x54 and 200x54 buttons, full screen")
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://diluix7elstq8
|
||||
|
|
@ -1,415 +0,0 @@
|
|||
extends RefCounted
|
||||
## #42: the panels at phone scale (UiTheme's panels), on the farm's HUD (farm.tscn) with
|
||||
## MobilePort.forced:
|
||||
## * Phones (PHONES): a 19.5:9 phone at about 1.6x with a notch and the home indicator inset; an
|
||||
## iPhone SE at the 1.7 cap (1130x635); a 13 mini at the cap with its insets (the shortest
|
||||
## room, about 600 tall); and a 4:3 iPad at 1x with an inset. On each, the morning sign (the
|
||||
## first morning's, in touch words, and the longest later morning's review), the end screens
|
||||
## (the failure and the final assessment, with the longest totals), and the workbench's and
|
||||
## the shed's menus sit inside the safe rect (the sign's drawing too: its beam's ends and its
|
||||
## posts' tops); Start the day, the end screens' buttons, and Close are in view below the
|
||||
## scrolling part (no scrolling needed to reach them) and at least the touch target tall, as
|
||||
## is every shop row; the end screens' text wraps to the panel; whatever doesn't fit scrolls,
|
||||
## and scrolled to its end it's all there. The iPad's room needs no scrolling.
|
||||
## * Fingers (the 19.5:9 phone): a drag on a shop's list scrolls it and buys nothing, even one
|
||||
## that comes back to the row it started on; a tap on a row buys it, a little wobble still a
|
||||
## tap; a drag on the sign scrolls it; Close closes.
|
||||
## * Desktop (forced 0) at 1920x1080: every rect as it was before #42 (DESKTOP, recorded from the
|
||||
## code before it), nothing scrolls or wraps, no safe-area margins.
|
||||
|
||||
const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
|
||||
## name, window pixels, density (0: by the window's shape), insets in window pixels (l, t, r, b).
|
||||
const PHONES := [
|
||||
["19.5:9 phone (1.6x), notch and home indicator", Vector2i(2340, 1080), 0.0, [140, 0, 140, 60]],
|
||||
["iPhone SE (1.7x cap)", Vector2i(1334, 750), 326.0, []],
|
||||
["iPhone 13 mini (1.7x cap), notch and home indicator", Vector2i(2340, 1080), 476.0, [140, 0, 140, 60]],
|
||||
["4:3 iPad (1x), status bar and home indicator", Vector2i(1600, 1200), 0.0, [0, 40, 0, 40]],
|
||||
]
|
||||
## The desktop layout at 1920x1080 before #42 (position, size), with the content _later(),
|
||||
## _failure(), _assessment(), and _fixed() give.
|
||||
const DESKTOP := {
|
||||
"sign, first morning": Rect2(408, 179, 1104, 721),
|
||||
"sign, first morning: Start the day": Rect2(810, 736, 300, 62),
|
||||
"sign, later morning": Rect2(408, 119, 1104, 841),
|
||||
"sign, later morning: Start the day": Rect2(810, 796, 300, 62),
|
||||
"sign, later morning: the results": Rect2(598, 315, 724, 202),
|
||||
"sign, later morning: the lists": Rect2(520, 545, 880, 225),
|
||||
"workbench": Rect2(373, 124, 1174, 831),
|
||||
"workbench: first row": Rect2(407, 254, 1106, 46),
|
||||
"workbench: last row": Rect2(407, 827, 1106, 46),
|
||||
"workbench: Close": Rect2(860, 879, 200, 48),
|
||||
"shed": Rect2(373, 237, 1174, 605),
|
||||
"shed: first row": Rect2(407, 367, 1106, 46),
|
||||
"shed: last row": Rect2(407, 714, 1106, 46),
|
||||
"shed: Close": Rect2(860, 766, 200, 48),
|
||||
"failure": Rect2(333, 265, 1254, 549),
|
||||
"failure: Retry the night": Rect2(561, 722, 544, 56),
|
||||
"failure: New vacation": Rect2(1129, 722, 230, 56),
|
||||
"failure: totals": Rect2(369, 554, 1182, 152),
|
||||
"assessment": Rect2(333, 235, 1254, 609),
|
||||
"assessment: New vacation": Rect2(845, 752, 230, 56),
|
||||
"assessment: totals": Rect2(369, 615, 1182, 121),
|
||||
"assessment: shares kept": Rect2(511, 490, 898, 109),
|
||||
}
|
||||
## Every shop row's text for the desktop check (the real ones follow the tuning).
|
||||
const FIXED_ROW := "Long-range defenses II — Turrets reach 15% farther (18 wood, 26 scrap) Need 16 wood, 24 scrap more"
|
||||
const FIXED_TITLE := "Upgrades at the work area (0 of 10 done)"
|
||||
|
||||
var t
|
||||
var farm: Node3D
|
||||
var sim: FarmSim
|
||||
|
||||
|
||||
func run(p_t) -> void:
|
||||
t = p_t
|
||||
var root: Window = t.root
|
||||
MobilePort.forced = 0
|
||||
root.size = Vector2i(1920, 1080)
|
||||
GameSettings.new().apply_scale(root)
|
||||
farm = (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
||||
root.add_child(farm)
|
||||
await t.process_frame
|
||||
await t.physics_frame
|
||||
sim = farm.get_node("FarmSim") as FarmSim
|
||||
sim.set_physics_process(false)
|
||||
sim.waves.enabled = false
|
||||
if sim.dialogue != null:
|
||||
sim.dialogue.set_process(false) # no conversation over the panels
|
||||
await _desktop()
|
||||
MobilePort.forced = 1
|
||||
for phone: Array in PHONES:
|
||||
await _phone(phone)
|
||||
await _fingers()
|
||||
MobilePort.forced = -1
|
||||
MobilePort.preview_dpi = 0.0
|
||||
MobilePort.preview_insets = []
|
||||
farm.queue_free()
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _settle() -> void:
|
||||
for i in 3:
|
||||
await t.process_frame
|
||||
|
||||
|
||||
## Desktop: each panel exactly where and as big as before #42.
|
||||
func _desktop() -> void:
|
||||
var got := {}
|
||||
var c := sim.campaign
|
||||
var sign := sim.review_panel
|
||||
c.new_campaign()
|
||||
sign.refresh()
|
||||
await _settle()
|
||||
got["sign, first morning"] = sign._board.get_global_rect()
|
||||
got["sign, first morning: Start the day"] = sign._start.get_global_rect()
|
||||
_later(c)
|
||||
sign.refresh()
|
||||
await _settle()
|
||||
got["sign, later morning"] = sign._board.get_global_rect()
|
||||
got["sign, later morning: Start the day"] = sign._start.get_global_rect()
|
||||
got["sign, later morning: the results"] = sign._grid.get_global_rect()
|
||||
got["sign, later morning: the lists"] = sign._lists.get_global_rect()
|
||||
t.check(sign._scroll.vertical_scroll_mode == ScrollContainer.SCROLL_MODE_DISABLED and not sign._scroll.clip_contents
|
||||
and _margins(sign._safe) == Vector4.ZERO and sign._start_gap.visible, "desktop: the sign doesn't scroll and has no safe-area margins")
|
||||
c.begin_day()
|
||||
for p: Array in [[sim.upgrade_panel, "workbench"], [sim.shed_panel, "shed"]]:
|
||||
var panel := p[0] as UpgradePanel
|
||||
panel.open()
|
||||
_fixed(panel)
|
||||
await _settle()
|
||||
var rows := panel._rows.values()
|
||||
got[p[1]] = panel._panel.get_global_rect()
|
||||
got[p[1] + ": first row"] = (rows[0] as Control).get_global_rect()
|
||||
got[p[1] + ": last row"] = (rows[-1] as Control).get_global_rect()
|
||||
got[p[1] + ": Close"] = panel._close.get_global_rect()
|
||||
t.check(panel._scroll.vertical_scroll_mode == ScrollContainer.SCROLL_MODE_DISABLED and not panel._scroll.clip_contents
|
||||
and _margins(panel._safe) == Vector4.ZERO and rows.all(func(b: Button) -> bool: return b.autowrap_mode == TextServer.AUTOWRAP_OFF),
|
||||
"desktop: the %s's rows don't scroll or wrap" % p[1])
|
||||
panel.close()
|
||||
var end := sim.end_panel
|
||||
_failure(c)
|
||||
end.show_failure()
|
||||
await _settle()
|
||||
got["failure"] = end._panel.get_global_rect()
|
||||
got["failure: Retry the night"] = end._retry.get_global_rect()
|
||||
got["failure: New vacation"] = end._new.get_global_rect()
|
||||
got["failure: totals"] = end._stats.get_global_rect()
|
||||
t.check(end._stats.autowrap_mode == TextServer.AUTOWRAP_OFF and end._scroll.vertical_scroll_mode == ScrollContainer.SCROLL_MODE_DISABLED
|
||||
and _margins(end._safe) == Vector4.ZERO, "desktop: the end screen's text doesn't wrap or scroll")
|
||||
_assessment(c)
|
||||
end.show_assessment()
|
||||
await _settle()
|
||||
got["assessment"] = end._panel.get_global_rect()
|
||||
got["assessment: New vacation"] = end._new.get_global_rect()
|
||||
got["assessment: totals"] = end._stats.get_global_rect()
|
||||
got["assessment: shares kept"] = end._bars.get_global_rect()
|
||||
end.hide_panel()
|
||||
var moved: Array[String] = []
|
||||
for k: String in DESKTOP:
|
||||
var want: Rect2 = DESKTOP[k]
|
||||
var r: Rect2 = got.get(k, Rect2())
|
||||
if not (r.position.distance_to(want.position) < 0.5 and r.size.distance_to(want.size) < 0.5):
|
||||
moved.append("%s: %s (was %s)" % [k, r, want])
|
||||
t.check(moved.is_empty(), "desktop 1920x1080: all %d panel rects are as before %s" % [DESKTOP.size(), moved])
|
||||
|
||||
|
||||
## One phone: every panel in its safe rect, the buttons in view and big enough, the rest scrolling.
|
||||
func _phone(phone: Array) -> void:
|
||||
var name: String = phone[0]
|
||||
var root: Window = t.root
|
||||
MobilePort.preview_dpi = phone[2]
|
||||
MobilePort.preview_insets = phone[3]
|
||||
root.size = phone[1]
|
||||
GameSettings.new().apply_scale(root)
|
||||
await _settle()
|
||||
var safe := MobilePort.safe_rect(sim.review_panel)
|
||||
var target := MobilePort.minimum_target(sim.review_panel)
|
||||
var ipad := is_equal_approx(root.content_scale_factor, 1.0)
|
||||
t.info("%s: canvas %s, safe rect %s, touch target %.0f" % [name, root.get_visible_rect().size, safe, target])
|
||||
var c := sim.campaign
|
||||
var sign := sim.review_panel
|
||||
c.new_campaign()
|
||||
sign.refresh()
|
||||
await _settle()
|
||||
t.check(sign._intro.visible and sign._intro.text.contains("(hold Use)"), "%s: (the first morning's sign, in touch words)" % name)
|
||||
_check_sign(name + ", the first morning's sign", sign, safe, target, sign._intro, ipad)
|
||||
await _reach_end(name + ", the first morning's sign", sign._scroll, sign._intro)
|
||||
_later(c)
|
||||
sign.refresh()
|
||||
await _settle()
|
||||
t.check(sign._lists.visible and sign.enemies_text().count(",") == 3 and sign.materials_text().count(",") == 3,
|
||||
"%s: (the later morning's review, every enemy and material listed)" % name)
|
||||
_check_sign(name + ", the later morning's review", sign, safe, target, sign._lists, ipad)
|
||||
await _reach_end(name + ", the later morning's review", sign._scroll, sign._lists)
|
||||
c.begin_day()
|
||||
await t.process_frame
|
||||
for p: Array in [[sim.upgrade_panel, "workbench"], [sim.shed_panel, "shed"]]:
|
||||
var panel := p[0] as UpgradePanel
|
||||
panel.open()
|
||||
await _settle()
|
||||
_check_shop("%s, the %s's menu" % [name, p[1]], panel, safe, target, ipad)
|
||||
await _reach_end("%s, the %s's menu" % [name, p[1]], panel._scroll, panel._rows.values()[-1])
|
||||
panel.close()
|
||||
var end := sim.end_panel
|
||||
_failure(c)
|
||||
end.show_failure()
|
||||
await _settle()
|
||||
_check_end(name + ", the failure screen", end, safe, target, [end._retry, end._new])
|
||||
await _reach_end(name + ", the failure screen", end._scroll, end._stats)
|
||||
_assessment(c)
|
||||
end.show_assessment()
|
||||
await _settle()
|
||||
_check_end(name + ", the final assessment", end, safe, target, [end._new])
|
||||
await _reach_end(name + ", the final assessment", end._scroll, end._stats)
|
||||
end.hide_panel()
|
||||
|
||||
|
||||
func _check_sign(what: String, sign: ReviewPanel, safe: Rect2, target: float, last: Control, ipad: bool) -> void:
|
||||
var board := sign._board.get_global_rect()
|
||||
var top := sign._post_top + ReviewPanel.END_GRAIN
|
||||
var drawn := Rect2(board.position - Vector2(ReviewPanel.BEAM_END, top), board.size + Vector2(2.0 * ReviewPanel.BEAM_END, top))
|
||||
t.check(_inside(safe, drawn), "%s: inside the safe rect, its beam's ends and posts' tops too (%s in %s)" % [what, drawn, safe])
|
||||
var start := sign._start.get_global_rect()
|
||||
var paper := sign._scroll.get_global_rect()
|
||||
t.check(start.size.y >= target - 0.01 and _inside(board, start) and start.position.y >= paper.end.y,
|
||||
"%s: Start the day is in view below the text, %.0f tall (target %.0f)" % [what, start.size.y, target])
|
||||
t.check(_inside(board, paper), "%s: the text's view is on the paper" % what)
|
||||
if ipad:
|
||||
t.check(not sign._scroll.scrolls() and _inside(paper, last.get_global_rect()), "%s: it all fits, no scrolling" % what)
|
||||
|
||||
|
||||
func _check_shop(what: String, panel: UpgradePanel, safe: Rect2, target: float, ipad: bool) -> void:
|
||||
var rect := panel._panel.get_global_rect()
|
||||
t.check(_inside(safe, rect), "%s: inside the safe rect (%s in %s)" % [what, rect, safe])
|
||||
var close := panel._close.get_global_rect()
|
||||
var list := panel._scroll.get_global_rect()
|
||||
t.check(close.size.y >= target - 0.01 and _inside(rect, close) and close.position.y >= list.end.y,
|
||||
"%s: Close is in view below the list, %.0f tall" % [what, close.size.y])
|
||||
var short: Array[String] = []
|
||||
var wide := 0
|
||||
for id: String in panel._rows:
|
||||
var r := (panel._rows[id] as Control).get_global_rect()
|
||||
if r.size.y < target - 0.01:
|
||||
short.append("%s %.0f" % [id, r.size.y])
|
||||
if r.position.x < list.position.x - 0.5 or r.end.x > list.end.x + 0.5:
|
||||
wide += 1
|
||||
t.check(short.is_empty() and wide == 0, "%s: every row (%d) is at least %.0f tall and fits across, its text wrapped %s" % [what, panel._rows.size(), target, short])
|
||||
if ipad:
|
||||
t.check(not panel._scroll.scrolls(), "%s: all its rows fit, no scrolling" % what)
|
||||
|
||||
|
||||
func _check_end(what: String, end: EndPanel, safe: Rect2, target: float, buttons: Array) -> void:
|
||||
var rect := end._panel.get_global_rect()
|
||||
t.check(_inside(safe, rect), "%s: inside the safe rect (%s in %s)" % [what, rect, safe])
|
||||
var view := end._scroll.get_global_rect()
|
||||
var ok := true
|
||||
for b: Button in buttons:
|
||||
var r := b.get_global_rect()
|
||||
ok = ok and b.visible and r.size.y >= target - 0.01 and _inside(rect, r) and r.position.y >= view.end.y
|
||||
t.check(ok, "%s: its buttons are in view below the text, at least %.0f tall" % [what, target])
|
||||
var stats := end._stats.get_global_rect()
|
||||
t.check(end._stats.autowrap_mode != TextServer.AUTOWRAP_OFF and stats.position.x >= view.position.x - 0.5 and stats.end.x <= view.end.x + 0.5,
|
||||
"%s: the totals wrap to the panel (%d lines in %.0f px)" % [what, end._stats.get_line_count(), stats.size.x])
|
||||
|
||||
|
||||
## Scrolled to its end, the last of a panel's scrolling part is in its view.
|
||||
func _reach_end(what: String, scroll: UiTheme.TouchScroll, last: Control) -> void:
|
||||
scroll.scroll_vertical = 1000000
|
||||
await _settle()
|
||||
var view := scroll.get_global_rect()
|
||||
var r := last.get_global_rect()
|
||||
t.check(r.end.y <= view.end.y + 0.5 and r.end.y >= view.position.y + minf(r.size.y, view.size.y) - 0.5,
|
||||
"%s: scrolled to the end, all of it is there (%s scrolls: %s)" % [what, "it" if scroll.scrolls() else "nothing", scroll.scrolls()])
|
||||
scroll.scroll_vertical = 0
|
||||
await _settle()
|
||||
|
||||
|
||||
## Fingers on the 19.5:9 phone: drags scroll and never buy; taps buy; Close closes.
|
||||
func _fingers() -> void:
|
||||
var root: Window = t.root
|
||||
MobilePort.preview_dpi = 0.0
|
||||
MobilePort.preview_insets = [140, 0, 140, 60]
|
||||
root.size = Vector2i(2340, 1080)
|
||||
GameSettings.new().apply_scale(root)
|
||||
await _settle()
|
||||
var c := sim.campaign
|
||||
var slop := UiTheme.TouchScroll.DRAG_PT * MobilePort.minimum_target(sim.review_panel) / MobilePort.TARGET_PT
|
||||
# The sign: a drag scrolls its paper.
|
||||
c.new_campaign()
|
||||
var s := c.state
|
||||
_later(c)
|
||||
sim.review_panel.refresh()
|
||||
await _settle()
|
||||
var paper := sim.review_panel._scroll
|
||||
var at := paper.get_global_rect().get_center()
|
||||
t.check(paper.scrolls(), "(the later morning's review scrolls on this phone)")
|
||||
await _drag(at, at + Vector2(0.0, -120.0))
|
||||
t.check(paper.scroll_vertical >= 110 and s.phase == CampaignController.Phase.MORNING,
|
||||
"a finger dragging the sign's paper up scrolls it (%d px), and the day doesn't start" % paper.scroll_vertical)
|
||||
c.begin_day()
|
||||
await _settle()
|
||||
t.check(not sim.review_panel.visible, "(day: the sign is down)")
|
||||
for p: Array in [[sim.upgrade_panel, "workbench"], [sim.shed_panel, "shed"]]:
|
||||
var panel := p[0] as UpgradePanel
|
||||
var shop: String = p[1]
|
||||
s.resources.shed = {"wood": 9999, "scrap": 9999, "straw": 9999, "alien_goop": 9999}
|
||||
s.night = 20 # everything in stock
|
||||
s.upgrades.clear()
|
||||
s.upgrades["corn_shooter"] = 1 # (the corn shooter's upgrades open)
|
||||
var bought: Array[String] = []
|
||||
var count := func(id: String) -> void: bought.append(id)
|
||||
panel.bought.connect(count)
|
||||
panel.open()
|
||||
await _settle()
|
||||
var list := panel._scroll
|
||||
t.check(list.scrolls(), "(the %s's list scrolls on this phone)" % shop)
|
||||
# Press on a row and drag up: the list scrolls, nothing's bought.
|
||||
var row := _row_in_view(panel)
|
||||
var from := (panel._rows[row] as Control).get_global_rect().get_center()
|
||||
var levels := s.upgrades.duplicate()
|
||||
await _drag(from, from + Vector2(0.0, -150.0))
|
||||
t.check(list.scroll_vertical >= 140 and bought.is_empty() and s.upgrades == levels,
|
||||
"%s: a finger that presses a row and drags up scrolls the list (%d px) and buys nothing" % [shop, list.scroll_vertical])
|
||||
# Press, drag down, and back up to the same row: still a drag, not a buy.
|
||||
row = _row_in_view(panel)
|
||||
from = (panel._rows[row] as Control).get_global_rect().get_center()
|
||||
var was := list.scroll_vertical
|
||||
Touch.touch(0, from, true)
|
||||
Touch.drag(0, from, from + Vector2(0.0, 80.0))
|
||||
Touch.drag(0, from + Vector2(0.0, 80.0), from)
|
||||
await t.process_frame
|
||||
Touch.touch(0, from, false)
|
||||
await _settle()
|
||||
t.check(bought.is_empty() and s.upgrades == levels and list.scroll_vertical == was and panel.is_open,
|
||||
"%s: one that drags away and comes back to the row it pressed buys nothing either" % shop)
|
||||
# A tap (with a little wobble, under the slop) buys.
|
||||
row = _row_in_view(panel)
|
||||
from = (panel._rows[row] as Control).get_global_rect().get_center()
|
||||
Touch.touch(0, from, true)
|
||||
Touch.drag(0, from, from + Vector2(0.0, slop * 0.4))
|
||||
Touch.touch(0, from + Vector2(0.0, slop * 0.4), false)
|
||||
await _settle()
|
||||
t.check(bought == [row] and Upgrades.level(s, row) == int(levels.get(row, 0)) + 1,
|
||||
"%s: a tap on a row buys it, even with a little wobble (%s)" % [shop, bought])
|
||||
row = _row_in_view(panel)
|
||||
Touch.tap(0, (panel._rows[row] as Control).get_global_rect().get_center())
|
||||
await _settle()
|
||||
t.check(bought.size() == 2 and bought[1] == row, "%s: and a plain tap on another buys that (%s)" % [shop, bought])
|
||||
Touch.tap(0, panel._close.get_global_rect().get_center())
|
||||
await _settle()
|
||||
t.check(not panel.is_open and not panel.visible, "%s: a tap on Close closes the menu" % shop)
|
||||
panel.bought.disconnect(count)
|
||||
|
||||
|
||||
## A row all in the list's view that can be bought.
|
||||
func _row_in_view(panel: UpgradePanel) -> String:
|
||||
var view := panel._scroll.get_global_rect()
|
||||
for id: String in panel._rows:
|
||||
var b := panel._rows[id] as Button
|
||||
if not b.disabled and view.encloses(b.get_global_rect()):
|
||||
return id
|
||||
return ""
|
||||
|
||||
|
||||
## Finger 0 presses at `from`, drags to `to` in one move, and lifts there.
|
||||
func _drag(from: Vector2, to: Vector2) -> void:
|
||||
Touch.touch(0, from, true)
|
||||
Touch.drag(0, from, to)
|
||||
await t.process_frame
|
||||
Touch.touch(0, to, false)
|
||||
await _settle()
|
||||
|
||||
|
||||
static func _inside(outer: Rect2, inner: Rect2) -> bool:
|
||||
return outer.grow(0.5).encloses(inner)
|
||||
|
||||
|
||||
static func _margins(m: MarginContainer) -> Vector4:
|
||||
return Vector4(m.get_theme_constant("margin_left"), m.get_theme_constant("margin_top"),
|
||||
m.get_theme_constant("margin_right"), m.get_theme_constant("margin_bottom"))
|
||||
|
||||
|
||||
## The longest later morning: 28 nights logged, the last with night 3's title (the longest), every
|
||||
## loss, every enemy type and material, and three-digit counts.
|
||||
static func _later(c: CampaignController) -> void:
|
||||
var s := c.state
|
||||
s.night_log.clear()
|
||||
for n in range(1, 29):
|
||||
var e := {}
|
||||
for key in FarmState.LOG_KEYS:
|
||||
e[key] = 0
|
||||
e["night"] = n
|
||||
for key in ["crops_stolen", "crops_recovered", "crops_lost", "animals_stolen", "animals_strayed", "animals_recovered",
|
||||
"animals_lost", "supplies_stolen", "supplies_recovered", "supplies_lost"]:
|
||||
e[key] = 12 + n
|
||||
for key in ["killed_crow", "killed_thief", "killed_breaker", "killed_ufo"]:
|
||||
e[key] = 100 + n * 3
|
||||
for key in ["gathered_wood", "gathered_scrap", "gathered_straw", "gathered_alien_goop",
|
||||
"spent_wood", "spent_scrap", "spent_straw", "spent_alien_goop"]:
|
||||
e[key] = 140 + n
|
||||
for key in ["escaped", "scarecrow_damage", "patches", "structures_built", "structures_damaged",
|
||||
"structures_destroyed", "repairs", "upgrades_bought"]:
|
||||
e[key] = 9 + n
|
||||
s.night_log.append(e)
|
||||
s.night_log[s.night_log.size() - 1]["night"] = 3
|
||||
s.night = 29
|
||||
|
||||
|
||||
## The failure screen's longest: the scarecrow fallen on night 29 of a vacation like _later's.
|
||||
static func _failure(c: CampaignController) -> void:
|
||||
_later(c)
|
||||
c.outcome = CampaignController.Outcome.GAME_OVER_SCARECROW
|
||||
c.state.night = 29
|
||||
|
||||
|
||||
static func _assessment(c: CampaignController) -> void:
|
||||
_later(c)
|
||||
c.outcome = CampaignController.Outcome.VACATION_COMPLETE
|
||||
|
||||
|
||||
## Fixed row and title texts, so the desktop check doesn't follow the costs' tuning.
|
||||
static func _fixed(p: UpgradePanel) -> void:
|
||||
p._title.text = FIXED_TITLE
|
||||
for id: String in p._rows:
|
||||
(p._rows[id] as Button).text = FIXED_ROW
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://c3b8nvghm8hx3
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
extends RefCounted
|
||||
## #37, the phone's platform details, through the entry scene (main.tscn, test save and settings
|
||||
## paths) with MobilePort.forced:
|
||||
## * Android's back button (NOTIFICATION_WM_GO_BACK_REQUEST; quit_on_go_back is off, so the app
|
||||
## doesn't just close): playing, it pauses (over the intro and the morning sign too); paused,
|
||||
## it closes the question, then settings, then resumes; it closes the workbench's and the
|
||||
## shed's panels, the pouch panel, and build mode before pausing; at the main menu it closes the
|
||||
## question and settings, then quits (intercepted here, so the runner lives).
|
||||
## * No Quit buttons on phones (focus moves past where they were); ScreenLabels, only one (a
|
||||
## ToonLook added anyway shares it), draws the Label3Ds flat without ToonLook, growing with
|
||||
## the interface scale; the camera starts at 12 m.
|
||||
## * Desktop (forced 0) as before: both Quit buttons, back ignored, Escape / Start pauses and
|
||||
## resumes, ToonLook's ScreenLabels, the camera at 16 m.
|
||||
|
||||
const SAVE := "user://test_platform_save.json"
|
||||
const SETTINGS := "user://test_platform_settings.cfg"
|
||||
const DT := 1.0 / 60.0
|
||||
|
||||
var t: GameTestRunner
|
||||
|
||||
|
||||
func run(p_t) -> void:
|
||||
t = p_t
|
||||
_clean()
|
||||
t.check(ProjectSettings.get_setting("application/config/quit_on_go_back") == false and not t.quit_on_go_back,
|
||||
"back doesn't close the app by itself (quit_on_go_back off): Main handles it")
|
||||
MobilePort.forced = 1
|
||||
var main := await _start()
|
||||
_phone_quit(main)
|
||||
await _phone_back(main)
|
||||
_camera(main, FollowCamera.PHONE_DISTANCE, "phones")
|
||||
await _phone_labels(main)
|
||||
await _phone_back_at_menu(main)
|
||||
await _stop(main)
|
||||
_clean()
|
||||
MobilePort.forced = 0
|
||||
main = await _start()
|
||||
await _desktop(main)
|
||||
_camera(main, 16.0, "desktop")
|
||||
await _stop(main)
|
||||
MobilePort.forced = -1
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _start() -> Main:
|
||||
var main := (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
main.save_path = SAVE
|
||||
main.settings_path = SETTINGS
|
||||
t.root.add_child(main)
|
||||
await t.process_frame
|
||||
await t.physics_frame
|
||||
return main
|
||||
|
||||
|
||||
func _stop(main: Main) -> void:
|
||||
main.queue_free()
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
|
||||
|
||||
## The back button as the platform sends it: to every node from the root.
|
||||
func _back() -> void:
|
||||
t.root.propagate_notification(Node.NOTIFICATION_WM_GO_BACK_REQUEST)
|
||||
|
||||
|
||||
## The pause action as Escape / Start sends it.
|
||||
func _press(action: String) -> void:
|
||||
for pressed in [true, false]:
|
||||
var e := InputEventAction.new()
|
||||
e.action = StringName(action)
|
||||
e.pressed = pressed
|
||||
Input.parse_input_event(e)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _skip_intro(sim: FarmSim) -> void:
|
||||
sim.intro.skip()
|
||||
var s := 0.0
|
||||
while sim.intro.busy() and s < 10.0:
|
||||
sim.intro.step(DT)
|
||||
s += DT
|
||||
|
||||
|
||||
func _screen_labels() -> Array:
|
||||
return t.root.find_children("*", "ScreenLabels", true, false).filter(
|
||||
func(n: Node) -> bool: return not n.is_queued_for_deletion())
|
||||
|
||||
|
||||
func _paused_menu(main: Main) -> bool:
|
||||
return main.screen == Main.Screen.PAUSED and t.paused and main.pause_menu.visible
|
||||
|
||||
|
||||
func _playing(main: Main) -> bool:
|
||||
return main.screen == Main.Screen.PLAYING and not t.paused and not main.pause_menu.visible
|
||||
|
||||
|
||||
func _phone_quit(main: Main) -> void:
|
||||
var mm := main.main_menu
|
||||
var pm := main.pause_menu
|
||||
t.check(not mm.quit_button.visible and not pm.quit_button.visible and mm.settings_button.visible and pm.menu_button.visible,
|
||||
"phones: no Quit on the main menu or the pause menu (the rest are there)")
|
||||
t.check(mm.settings_button.find_valid_focus_neighbor(SIDE_BOTTOM) != mm.quit_button
|
||||
and mm.settings_button.find_next_valid_focus() != mm.quit_button
|
||||
and pm.menu_button.find_valid_focus_neighbor(SIDE_BOTTOM) != pm.quit_button
|
||||
and pm.menu_button.find_next_valid_focus() != pm.quit_button,
|
||||
"and focus (arrows, Tab) never lands on the hidden ones")
|
||||
|
||||
|
||||
func _phone_back(main: Main) -> void:
|
||||
var sim := main.sim
|
||||
var c := sim.campaign
|
||||
main.main_menu.settings_button.pressed.emit()
|
||||
t.check(main.settings_menu.is_open, "(settings open from the main menu)")
|
||||
_back()
|
||||
t.check(not main.settings_menu.is_open and main.screen == Main.Screen.MENU and main.main_menu.visible,
|
||||
"back at the main menu's settings closes them, back to the menu")
|
||||
main.main_menu.new_button.pressed.emit()
|
||||
t.check(main.screen == Main.Screen.PLAYING and sim.intro.running, "(a new vacation, its intro playing)")
|
||||
_back()
|
||||
t.check(_paused_menu(main) and sim.intro.running, "back during the intro pauses (Restart the night skips it from there)")
|
||||
_back()
|
||||
t.check(_playing(main) and sim.intro.running, "and back again resumes it")
|
||||
_skip_intro(sim)
|
||||
t.check(c.state.phase == CampaignController.Phase.MORNING and sim.review_panel.visible, "(the first morning's sign)")
|
||||
_back()
|
||||
t.check(_paused_menu(main) and sim.review_panel.visible, "back over the morning sign pauses (the sign stays)")
|
||||
main.pause_menu.settings_button.pressed.emit()
|
||||
t.check(main.settings_menu.is_open and not main.pause_menu.visible, "(settings open from the pause menu)")
|
||||
_back()
|
||||
t.check(not main.settings_menu.is_open and _paused_menu(main), "back closes settings, back to the pause menu")
|
||||
main.pause_menu.restart_button.pressed.emit()
|
||||
t.check(main.confirm.is_open, "(Restart the night asks first)")
|
||||
_back()
|
||||
t.check(not main.confirm.is_open and _paused_menu(main) and c.state.phase == CampaignController.Phase.MORNING,
|
||||
"back closes the question (nothing restarted), back to the pause menu")
|
||||
_back()
|
||||
t.check(_playing(main), "and back resumes")
|
||||
|
||||
c.begin_day()
|
||||
await t.physics_frame
|
||||
sim.upgrade_panel.open()
|
||||
t.check(sim.upgrade_panel.is_open, "(the workbench's panel open)")
|
||||
_back()
|
||||
t.check(not sim.upgrade_panel.is_open and _playing(main), "back closes the workbench's panel and doesn't pause")
|
||||
sim.shed_panel.open()
|
||||
_back()
|
||||
t.check(not sim.shed_panel.is_open and _playing(main), "and the shed's")
|
||||
sim.resource_hud.toggle()
|
||||
t.check(sim.resource_hud.open, "(the pouch panel open)")
|
||||
_back()
|
||||
t.check(not sim.resource_hud.open and _playing(main), "back closes the pouch panel")
|
||||
sim.build.set_active(true)
|
||||
_back()
|
||||
t.check(not sim.build.active and _playing(main), "back leaves build mode")
|
||||
_back()
|
||||
t.check(_paused_menu(main), "and with nothing open, back pauses")
|
||||
_back()
|
||||
|
||||
|
||||
func _camera(main: Main, want: float, platform: String) -> void:
|
||||
var cam := main.sim.camera as FollowCamera
|
||||
t.check(cam != null and is_equal_approx(cam.distance, want), "%s: the camera starts %.0f m away (%.1f)" % [platform, want, cam.distance])
|
||||
|
||||
|
||||
func _phone_labels(main: Main) -> void:
|
||||
var sim := main.sim
|
||||
var labels := _screen_labels()
|
||||
t.check(main.get_node_or_null("ToonLook") == null and labels.size() == 1 and (labels[0] as Node).get_parent() is CanvasLayer
|
||||
and ((labels[0] as Node).get_parent() as CanvasLayer).layer == -1,
|
||||
"phones: no ToonLook, and one ScreenLabels on its layer under the HUD (%d)" % labels.size())
|
||||
var drawer := labels[0] as ScreenLabels
|
||||
var label3ds := main.farm.find_children("*", "Label3D", true, false)
|
||||
t.check(label3ds.size() >= 5 and label3ds.all(func(l: Node) -> bool: return (l as Label3D).layers == 0),
|
||||
"which draws the farm's %d Label3Ds flat (none render in 3D)" % label3ds.size())
|
||||
var cam := t.root.get_camera_3d()
|
||||
t.check(cam == sim.camera, "(playing: the follow camera)")
|
||||
var sign := Label3D.new()
|
||||
sign.text = "Gather"
|
||||
sign.font_size = 40
|
||||
sign.pixel_size = 0.0075
|
||||
sign.outline_size = 10
|
||||
main.farm.add_child(sign)
|
||||
sign.global_position = cam.global_position - cam.global_basis.z * 10.0
|
||||
sign.reset_physics_interpolation()
|
||||
await t.process_frame
|
||||
var drawn := drawer.entries().filter(func(e: Dictionary) -> bool: return e["label"] == sign)
|
||||
t.check(sign.layers == 0 and drawn.size() == 1 and drawn[0]["text"] == "Gather"
|
||||
and drawn[0]["font_size"] >= ScreenLabels.MIN_SIZE and t.root.get_visible_rect().encloses(drawn[0]["rect"]),
|
||||
"and a label added later is drawn flat too, at a readable size (%s)" % [drawn[0]["font_size"] if drawn.size() == 1 else "not drawn"])
|
||||
var was := t.root.content_scale_factor
|
||||
t.root.content_scale_factor = 1.0
|
||||
drawn = drawer.entries().filter(func(e: Dictionary) -> bool: return e["label"] == sign)
|
||||
var at_1x: int = drawn[0]["font_size"] if drawn.size() == 1 else 0
|
||||
t.root.content_scale_factor = 1.6 # the phone's interface scale (MobilePort.ui_scale, #35)
|
||||
drawn = drawer.entries().filter(func(e: Dictionary) -> bool: return e["label"] == sign)
|
||||
var at_16x: int = drawn[0]["font_size"] if drawn.size() == 1 else 0
|
||||
t.root.content_scale_factor = was
|
||||
t.check(at_1x > 0 and absi(at_16x - at_1x) <= 1,
|
||||
"labels scale with the interface: at 1.6x the same canvas size (%d, was %d), so 1.6x as big on screen as in 3D" % [at_16x, at_1x])
|
||||
sign.queue_free()
|
||||
t.check(ScreenLabels.ensure(main) == drawer, "asking for ScreenLabels again gets the same one")
|
||||
var look := ToonLook.new() # if both ever applied
|
||||
main.add_child(look)
|
||||
t.check(look.labels == drawer and _screen_labels().size() == 1, "a ToonLook added on a phone shares it: still one")
|
||||
look.queue_free()
|
||||
await t.process_frame
|
||||
|
||||
|
||||
func _phone_back_at_menu(main: Main) -> void:
|
||||
main.to_menu()
|
||||
t.check(main.screen == Main.Screen.MENU and main.main_menu.visible, "(back at the main menu)")
|
||||
main.main_menu.new_button.pressed.emit()
|
||||
t.check(main.confirm.is_open, "(New vacation asks first: it would replace the save)")
|
||||
_back()
|
||||
t.check(not main.confirm.is_open and main.screen == Main.Screen.MENU and main.main_menu.visible,
|
||||
"back at the main menu closes the question")
|
||||
var quits := [0]
|
||||
main.main_menu.quit_requested.disconnect(main.quit_game) # the runner must live
|
||||
main.main_menu.quit_requested.connect(func() -> void: quits[0] += 1)
|
||||
_back()
|
||||
t.check(quits[0] == 1, "and back at the main menu itself quits (Android's way), as Quit would")
|
||||
|
||||
|
||||
func _desktop(main: Main) -> void:
|
||||
var mm := main.main_menu
|
||||
var pm := main.pause_menu
|
||||
t.check(mm.quit_button.visible and mm.quit_button.text == "Quit" and pm.quit_button.visible and pm.quit_button.text == "Quit the game",
|
||||
"desktop: Quit on the main menu and Quit the game on the pause menu")
|
||||
var look := main.get_node_or_null("ToonLook") as ToonLook
|
||||
var labels := _screen_labels()
|
||||
t.check(look != null and labels.size() == 1 and labels[0] == look.labels and look.labels.get_parent().get_parent() == look,
|
||||
"desktop: ToonLook makes the one ScreenLabels, under itself (%d)" % labels.size())
|
||||
var quits := [0]
|
||||
mm.quit_requested.disconnect(main.quit_game)
|
||||
mm.quit_requested.connect(func() -> void: quits[0] += 1)
|
||||
_back()
|
||||
t.check(quits[0] == 0 and main.screen == Main.Screen.MENU and mm.visible, "desktop: a back request does nothing at the main menu")
|
||||
mm.new_button.pressed.emit()
|
||||
_skip_intro(main.sim)
|
||||
_back()
|
||||
t.check(_playing(main), "or while playing")
|
||||
await _press("pause")
|
||||
t.check(_paused_menu(main), "desktop: Escape / Start still pauses")
|
||||
pm.settings_button.pressed.emit()
|
||||
await _press("pause")
|
||||
t.check(not main.settings_menu.is_open and _paused_menu(main), "closes settings")
|
||||
await _press("pause")
|
||||
t.check(_playing(main), "and resumes")
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bhmtct5ivpte6
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
extends RefCounted
|
||||
## #36: the prompts in touch words (Prompts). On a phone (MobilePort.forced = 1) every prompt
|
||||
## that names a key says it in touch words: the world labels, the build ghost and the build bar,
|
||||
## the cutscenes' skip hints, the tutorial's tips and their footer, and the first morning's sign,
|
||||
## with no key, mouse, or gamepad name left and the sticks' sides filled in. The tutorial, the
|
||||
## build bar, the workbench, the shed counter, and the morning sign show them. On desktop
|
||||
## (forced = 0) each is byte for byte the string the game showed before #36 (copied here as
|
||||
## literals from the code as it was).
|
||||
|
||||
## Words a touch prompt must not have: keys, mouse and gamepad buttons (a lone capital letter,
|
||||
## but A and I, which are words too), sticks (touch says thumbs), sprinting (#46), and a
|
||||
## {placeholder} left unfilled.
|
||||
const KEY_WORDS := "\\[|\\]|\\bLMB\\b|\\bRMB\\b|\\bRT\\b|\\bLT\\b|\\bLB\\b|\\bRB\\b|\\bSpace\\b|\\bEnter\\b|Backspace|[Mm]ouse" \
|
||||
+ "|\\bTab\\b|\\bkeys?\\b|d-pad|\\b[B-HJ-Z]\\b|[Ss]print|\\bShift\\b|\\bstick\\b|[Pp]ress|[Cc]lick|\\{|\\}"
|
||||
|
||||
var t
|
||||
var tree: SceneTree
|
||||
var campaign: CampaignController
|
||||
|
||||
|
||||
func run(p_t) -> void:
|
||||
t = p_t
|
||||
tree = Engine.get_main_loop() as SceneTree
|
||||
campaign = CampaignController.new()
|
||||
tree.root.add_child(campaign)
|
||||
campaign.set_physics_process(false)
|
||||
MobilePort.forced = 1
|
||||
_phone()
|
||||
await _phone_screens()
|
||||
MobilePort.forced = 0
|
||||
_desktop()
|
||||
await _desktop_screens()
|
||||
MobilePort.forced = -1
|
||||
campaign.free()
|
||||
|
||||
|
||||
func _phone() -> void:
|
||||
t.check(Prompts.touch() and MobilePort.active(), "forced to a phone, the prompts are in touch words")
|
||||
var move := Prompts.move_side()
|
||||
var attack := Prompts.attack_side()
|
||||
t.check(move == ("right" if TouchSticks.MOVE_ON_RIGHT else "left") and attack != move and attack in ["left", "right"],
|
||||
"the move stick is on the %s, the attack stick on the %s (TouchSticks)" % [move, attack])
|
||||
var want := {
|
||||
"gather": [Prompts.gather(), "Gather"],
|
||||
"repair": [Prompts.repair("6 wood"), "Repair (6 wood)"],
|
||||
"upgrade": [Prompts.upgrade_to(2, "4 scrap, 2 straw"), "Upgrade to L2 (4 scrap, 2 straw)"],
|
||||
"workbench": [Prompts.upgrades(), "Upgrades"],
|
||||
"shed counter": [Prompts.shop(), "Shop"],
|
||||
"build ghost": [Prompts.build_place(), "Place"],
|
||||
"dismantle": [Prompts.dismantle(), "Dismantle"],
|
||||
"build bar": [Prompts.build_help(), "Place · Rotate · Dismantle · Done"],
|
||||
"build slot": [Prompts.build_slot(1, "Fence"), "Fence"],
|
||||
"intro skip": [Prompts.intro_skip(), "Hold to skip"],
|
||||
"return skip": [Prompts.return_skip(), "Tap to skip"],
|
||||
"tip footer": [Prompts.tip_footer(), "Tip · × hides tips"],
|
||||
"tip move": [Prompts.tip("move"),
|
||||
"Move with your %s thumb: touch the %s half of the screen and slide. You're the scarecrow: keep the farm safe until the farmers are back." % [move, move]],
|
||||
"tip gather": [Prompts.tip("gather"), "Hold Use at a dead tree, the haystacks, or the scrap heap to gather wood, straw, and scrap."],
|
||||
"tip store": [Prompts.tip("store"),
|
||||
"Your pouch only holds so much (tap the backpack to see what's in it): walk onto the barn's apron (the Supply Shed) to store what you carry."],
|
||||
"tip build": [Prompts.tip("build"),
|
||||
"Build (by day): tap Build, pick a fence, put your %s thumb where it goes, then tap Place. Aliens have to break through fences." % attack],
|
||||
"tip dusk": [Prompts.tip("dusk"), "Dusk: aliens come at nightfall, from every side of the farm."],
|
||||
"tip shoot": [Prompts.tip("shoot"),
|
||||
"Your %s thumb aims and attacks: slide it toward an alien to stab with your pitchfork. The supply shed sells a corn shooter (tap the hotbar to switch); more weapons arrive there over the days, like pumpkin bombs for your off-hand (Bomb throws one)." % attack],
|
||||
"tip fear": [Prompts.tip("fear"), "Crowded? Tap Fear to scare off everything nearby, and they drop what they carry."],
|
||||
"tip recover": [Prompts.tip("recover"), "Something was dropped! Walk over it to bring it home. A dropped animal follows you back to the pen."],
|
||||
"tip patch": [Prompts.tip("patch"), "Hurt? Hold Patch to patch up with straw. Health carries over to the next night."],
|
||||
"sign day": [Prompts.sign_day(),
|
||||
"By day, gather wood, scrap, and straw (hold Use), store them at the barn, and build defenses (tap Build). There's more to gather off the farm, to the north, east, and south."],
|
||||
"sign night": [Prompts.sign_night(),
|
||||
"At night, stab aliens with your pitchfork (%s thumb), scare them off (Fear), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons on the hotbar), and more weapons arrive there over the days." % attack],
|
||||
}
|
||||
for k: String in want:
|
||||
t.check(want[k][0] == want[k][1], "phone, %s: '%s'" % [k, want[k][0]])
|
||||
var keys := RegEx.create_from_string(KEY_WORDS)
|
||||
var named: Array[String] = []
|
||||
for k: String in want:
|
||||
var m := keys.search(want[k][0])
|
||||
if m != null:
|
||||
named.append("%s ('%s')" % [k, m.get_string()])
|
||||
t.check(named.is_empty(), "no touch prompt names a key, a mouse or gamepad button, or sprinting %s" % [named])
|
||||
var tips := 0
|
||||
for id: String in Tutorial.TEXT:
|
||||
tips += 1 if Prompts.tip(id) != "" else 0
|
||||
t.check(tips == Tutorial.TEXT.size() and Prompts.TOUCH_TIPS.keys().all(func(id: String) -> bool: return Tutorial.TEXT.has(id)),
|
||||
"every tip has its wording on phones (%d of %d), and every touch tip is a tutorial tip" % [tips, Tutorial.TEXT.size()])
|
||||
var font := Sketch.font()
|
||||
var fallback := font is FontFile and (font as FontFile).allow_system_fallback
|
||||
t.check(font.has_char(0xD7) or fallback, "the HUD font draws the tip footer's × (has it: %s; system fallback: %s)" % [font.has_char(0xD7), fallback])
|
||||
|
||||
|
||||
## On a phone, what the tutorial, the build bar, the workbench, the shed counter, and the first
|
||||
## morning's sign show.
|
||||
func _phone_screens() -> void:
|
||||
var tut := Tutorial.new()
|
||||
tree.root.add_child(tut)
|
||||
tut._show("gather")
|
||||
t.check(tut._hint.text == "Tip · × hides tips" and tut._text.text == Prompts.tip("gather") and tut._text.text.begins_with("Hold Use"),
|
||||
"the tip box (phone): '%s' over '%s'" % [tut._text.text, tut._hint.text])
|
||||
tut.free()
|
||||
var bar := BuildHud.new()
|
||||
t.check(bar.help_text() == "Place · Rotate · Dismantle · Done", "the build bar's line (phone): '%s'" % bar.help_text())
|
||||
bar.free()
|
||||
var labels := await _labels()
|
||||
t.check(labels[0].begins_with("Upgrades\n") and labels[1].begins_with("Shop\n"),
|
||||
"the workbench and the shed counter by day (phone): '%s', '%s'" % [labels[0].get_slice("\n", 0), labels[1].get_slice("\n", 0)])
|
||||
var sign := await _sign()
|
||||
t.check(sign.size() == 3 and sign[1] == Prompts.sign_day() and sign[2] == Prompts.sign_night() and sign[1].contains("(hold Use)"),
|
||||
"the first morning's sign (phone) tells the day and the night in touch words")
|
||||
|
||||
|
||||
func _desktop() -> void:
|
||||
t.check(not Prompts.touch() and not MobilePort.active(), "forced to desktop, the prompts are as before")
|
||||
var want := {
|
||||
# interactions.gd
|
||||
"gather": [Prompts.gather(), "[E / X] Gather"],
|
||||
"repair": [Prompts.repair("6 wood"), "[E / X] Repair (%s)" % "6 wood"],
|
||||
"upgrade": [Prompts.upgrade_to(2, "4 scrap, 2 straw"), "[E / X] Upgrade to L%d (%s)" % [2, "4 scrap, 2 straw"]],
|
||||
# workbench.gd, shed_counter.gd
|
||||
"workbench": [Prompts.upgrades(), "[E / X] Upgrades"],
|
||||
"shed counter": [Prompts.shop(), "[E / X] Shop"],
|
||||
# build_mode.gd
|
||||
"build ghost": [Prompts.build_place(), "[LMB / RT] Build"],
|
||||
"dismantle": [Prompts.dismantle(), "[RMB / B] Dismantle"],
|
||||
# build_hud.gd
|
||||
"build bar": [Prompts.build_help(), "LMB / RT build · Z C / d-pad rotate · 1-4 / Tab pick · RMB / B dismantle or leave"],
|
||||
"build slot": [Prompts.build_slot(3, "Turret"), "%d %s" % [3, "Turret"]],
|
||||
# opening_intro.gd, farmers_return.gd
|
||||
"intro skip": [Prompts.intro_skip(), "Hold [Space / Enter / A] to skip"],
|
||||
"return skip": [Prompts.return_skip(), "[Space / Enter / A] skip"],
|
||||
# tutorial.gd
|
||||
"tip footer": [Prompts.tip_footer(), "Tip · [Backspace / Back] hide tips"],
|
||||
"tip move": [Prompts.tip("move"), "Move with [W A S D] or the left stick. You're the scarecrow: keep the farm safe until the farmers are back."],
|
||||
"tip gather": [Prompts.tip("gather"), "Hold [E / X] at a dead tree, the haystacks, or the scrap heap to gather wood, straw, and scrap."],
|
||||
"tip store": [Prompts.tip("store"), "Your pouch only holds so much ([I] shows what's in it): walk onto the barn's apron (the Supply Shed) to store what you carry."],
|
||||
"tip build": [Prompts.tip("build"), "Press [B / d-pad up] to build. Pick a fence [1], place it with left mouse / RT. Aliens have to break through fences."],
|
||||
"tip dusk": [Prompts.tip("dusk"), "Dusk: aliens come at nightfall, from every side of the farm."],
|
||||
"tip shoot": [Prompts.tip("shoot"), "Aim with the mouse or the right stick and hold left mouse / RT to stab with your pitchfork. The supply shed sells a corn shooter (switch with [Tab / the number keys]); more weapons arrive there over the days, like pumpkin bombs for your off-hand (throw them with [right mouse / LT])."],
|
||||
"tip fear": [Prompts.tip("fear"), "Crowded? [Q / LB] Fear scares off everything nearby, and they drop what they carry."],
|
||||
"tip recover": [Prompts.tip("recover"), "Something was dropped! Walk over it to bring it home. A dropped animal follows you back to the pen."],
|
||||
"tip patch": [Prompts.tip("patch"), "Hurt? Hold [F / Y] to patch up with straw. Health carries over to the next night."],
|
||||
# review_panel.gd
|
||||
"sign day": [Prompts.sign_day(), "By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south."],
|
||||
"sign night": [Prompts.sign_night(), "At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days."],
|
||||
}
|
||||
var changed: Array[String] = []
|
||||
for k: String in want:
|
||||
if want[k][0] != want[k][1]:
|
||||
changed.append("%s: '%s'" % [k, want[k][0]])
|
||||
t.check(changed.is_empty(), "desktop: all %d prompts are byte for byte as before %s" % [want.size(), changed])
|
||||
|
||||
|
||||
## On desktop, what the same screens show.
|
||||
func _desktop_screens() -> void:
|
||||
var tut := Tutorial.new()
|
||||
tree.root.add_child(tut)
|
||||
tut._show("move")
|
||||
t.check(tut._hint.text == "Tip · [Backspace / Back] hide tips"
|
||||
and tut._text.text == "Move with [W A S D] or the left stick. You're the scarecrow: keep the farm safe until the farmers are back.",
|
||||
"the tip box (desktop) is as before")
|
||||
tut.free()
|
||||
var bar := BuildHud.new()
|
||||
t.check(bar.help_text() == "LMB / RT build · Z C / d-pad rotate · 1-4 / Tab pick · RMB / B dismantle or leave",
|
||||
"the build bar's line (desktop) is as before")
|
||||
bar.free()
|
||||
var labels := await _labels()
|
||||
t.check(labels[0].begins_with("[E / X] Upgrades\n") and labels[1].begins_with("[E / X] Shop\n"),
|
||||
"the workbench and the shed counter by day (desktop) are as before")
|
||||
var sign := await _sign()
|
||||
var nights := campaign.config.campaign_nights
|
||||
t.check("\n".join(sign) == "\n".join([
|
||||
"Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights,
|
||||
"By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.",
|
||||
"At night, stab aliens with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. Animals roam loose until you lead them into the pen: walk up to one and it follows you. The supply shed sells a corn shooter (switch weapons with Tab or the number keys), and more weapons arrive there over the days.",
|
||||
]), "the first morning's sign (desktop) is as before")
|
||||
|
||||
|
||||
## The workbench's and the shed counter's labels, focused by day.
|
||||
func _labels() -> Array[String]:
|
||||
campaign.new_campaign()
|
||||
campaign.begin_day()
|
||||
var bench := Workbench.new()
|
||||
var counter := ShedCounter.new()
|
||||
tree.root.add_child(bench)
|
||||
tree.root.add_child(counter)
|
||||
await tree.process_frame
|
||||
bench.show_state(campaign, true, true)
|
||||
counter.show_state(campaign, true, true)
|
||||
var out: Array[String] = [bench._label.text, counter._label.text]
|
||||
bench.free()
|
||||
counter.free()
|
||||
return out
|
||||
|
||||
|
||||
## The first morning's sign: its introduction's lines.
|
||||
func _sign() -> PackedStringArray:
|
||||
campaign.new_campaign()
|
||||
var panel := ReviewPanel.new()
|
||||
tree.root.add_child(panel)
|
||||
panel.campaign = campaign
|
||||
panel.refresh()
|
||||
var lines := panel._intro.text.split("\n") if panel.visible and panel._intro.visible else PackedStringArray()
|
||||
await tree.process_frame # its deferred focus
|
||||
panel.free()
|
||||
return lines
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bym4d52rn3d40
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
extends RefCounted
|
||||
## The interface scale and the safe area (MobilePort, GameSettings, #35):
|
||||
## * scale_for: phones about 1.6 (clamped to 1.7 for the smallest), iPads and desktop 1, the
|
||||
## same in portrait; a missing or impossible density falls back to the size class.
|
||||
## * ui_scale: 1 on desktop whatever the Interface size; on a phone, the screen's scale times
|
||||
## the Interface size (clamped to 0.8-1.3). The desktop preview plays a phone or an iPad by
|
||||
## the window's shape, or at preview_dpi.
|
||||
## * GameSettings: interface_size saves, loads, and falls back; apply() sets the window's
|
||||
## content_scale_factor on a phone (the canvas shrinks by it) and leaves desktop at 1 with the
|
||||
## same canvas.
|
||||
## * safe_rect: the whole visible rect on desktop (insets ignored), the window less the
|
||||
## simulated insets on a phone, mapped into the canvas with the scale; the insets parse.
|
||||
## * minimum_target: 44 on desktop; on a phone 44 points (about 70 canvas pixels), whatever the
|
||||
## window's size, and smaller in canvas pixels as the Interface size grows.
|
||||
|
||||
const SETTINGS := "user://test_mobile_scale_settings.cfg"
|
||||
const PHONE := Vector2i(2340, 1080) # 19.5:9
|
||||
const IPAD := Vector2i(1600, 1200) # 4:3
|
||||
|
||||
var t: GameTestRunner
|
||||
var _layer: CanvasLayer
|
||||
var _probe: Control
|
||||
|
||||
|
||||
func run(p_t: GameTestRunner) -> void:
|
||||
t = p_t
|
||||
var root := t.root
|
||||
var size := root.size
|
||||
var factor := root.content_scale_factor
|
||||
var pixels := [root.scaling_3d_mode, root.scaling_3d_scale, root.msaa_3d]
|
||||
_layer = CanvasLayer.new()
|
||||
_probe = Control.new()
|
||||
_layer.add_child(_probe)
|
||||
root.add_child(_layer)
|
||||
_probe.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_devices()
|
||||
_settings_file()
|
||||
await _desktop()
|
||||
await _phone()
|
||||
await _ipad()
|
||||
await _min_target()
|
||||
_insets()
|
||||
MobilePort.forced = -1
|
||||
MobilePort.preview_dpi = 0.0
|
||||
MobilePort.preview_insets = []
|
||||
GameSettings.new().apply(null) # the defaults for the audio and dead zones, as test_save does
|
||||
root.size = size
|
||||
root.content_scale_factor = factor
|
||||
root.scaling_3d_mode = pixels[0]
|
||||
root.scaling_3d_scale = pixels[1]
|
||||
root.msaa_3d = pixels[2]
|
||||
_layer.queue_free()
|
||||
await t.process_frame
|
||||
if FileAccess.file_exists(SETTINGS):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(SETTINGS))
|
||||
|
||||
|
||||
## scale_for: real screens (pixels, density, pixels per point).
|
||||
func _devices() -> void:
|
||||
var cases := [
|
||||
# name, pixels, dpi, px/pt, low, high
|
||||
["iPhone 15", Vector2(2556, 1179), 460.0, 3.0, 1.6, 1.75],
|
||||
["iPhone 15 Pro Max", Vector2(2796, 1290), 460.0, 3.0, 1.5, 1.6],
|
||||
["iPhone 13 mini", Vector2(2340, 1080), 476.0, 3.0, 1.7, 1.7],
|
||||
["iPhone SE", Vector2(1334, 750), 326.0, 2.0, 1.7, 1.7],
|
||||
["iPad (10th)", Vector2(2360, 1640), 264.0, 2.0, 1.0, 1.0],
|
||||
["iPad mini", Vector2(2266, 1488), 326.0, 2.0, 1.0, 1.0],
|
||||
["iPad Pro 13\"", Vector2(2752, 2064), 264.0, 2.0, 1.0, 1.0],
|
||||
["a 1080p desktop monitor", Vector2(1920, 1080), 96.0, 1.0, 1.0, 1.0],
|
||||
]
|
||||
for c: Array in cases:
|
||||
var s := MobilePort.scale_for(c[1], c[2], c[3])
|
||||
t.check(s >= c[4] - 0.005 and s <= c[5] + 0.005, "%s: scale %.2f (want %.2f-%.2f)" % [c[0], s, c[4], c[5]])
|
||||
var portrait := MobilePort.scale_for(Vector2(c[1].y, c[1].x), c[2], c[3])
|
||||
t.check(is_equal_approx(portrait, s), "%s: the same in portrait (%.2f)" % [c[0], portrait])
|
||||
t.check(is_equal_approx(MobilePort.scale_for(Vector2(2556, 1179), 460.0, 3.0), 4.3 / (1179.0 / 460.0)),
|
||||
"the scale is 4.3 inches over the shorter side's")
|
||||
# The size class, for a density of 0 or one that can't be right.
|
||||
t.check(MobilePort.scale_for(Vector2(2556, 1179), 0.0, 3.0) == MobilePort.PHONE_SCALE, "no density: a phone (393 pt) gets 1.6")
|
||||
t.check(MobilePort.scale_for(Vector2(2556, 1179), 72.0, 3.0) == MobilePort.PHONE_SCALE, "72 dpi on a phone's pixels: the size class (1.6)")
|
||||
t.check(MobilePort.scale_for(Vector2(2556, 1179), 2000.0, 3.0) == MobilePort.PHONE_SCALE, "2000 dpi: the size class (1.6)")
|
||||
t.check(MobilePort.scale_for(Vector2(2360, 1640), 0.0, 2.0) == MobilePort.TABLET_SCALE, "no density: an iPad (820 pt) gets 1")
|
||||
t.check(MobilePort.scale_for(Vector2(1334, 750), 0.0, 2.0) == MobilePort.PHONE_SCALE, "no density: an iPhone SE (375 pt) gets 1.6")
|
||||
t.check(not MobilePort.dpi_plausible(Vector2(1179, 2556), 0.0) and MobilePort.dpi_plausible(Vector2(1179, 2556), 460.0),
|
||||
"0 dpi is never trusted; an iPhone's 460 is")
|
||||
|
||||
|
||||
## interface_size in the settings file: saved, loaded, clamped, and a default when it's wrong.
|
||||
func _settings_file() -> void:
|
||||
var g := GameSettings.new()
|
||||
t.check(g.interface_size == 1.0, "Interface size defaults to 100%")
|
||||
g.interface_size = 1.25
|
||||
g.save_to(SETTINGS)
|
||||
t.check(is_equal_approx(GameSettings.load_from(SETTINGS).interface_size, 1.25), "Interface size saves and loads")
|
||||
var f := ConfigFile.new()
|
||||
f.load(SETTINGS)
|
||||
f.set_value("touch", "interface_size", 5.0)
|
||||
f.save(SETTINGS)
|
||||
t.check(GameSettings.load_from(SETTINGS).interface_size == 1.3, "a size above 130% loads as 130%")
|
||||
f.set_value("touch", "interface_size", "big")
|
||||
f.save(SETTINGS)
|
||||
t.check(GameSettings.load_from(SETTINGS).interface_size == 1.0, "a size that isn't a number loads as 100%")
|
||||
|
||||
|
||||
## Desktop: factor 1, the same canvas, whatever the Interface size, and insets don't apply.
|
||||
func _desktop() -> void:
|
||||
MobilePort.forced = 0
|
||||
MobilePort.preview_insets = [140, 0, 140, 60]
|
||||
var root := t.root
|
||||
for size: Vector2i in [Vector2i(1920, 1080), PHONE]:
|
||||
root.size = size
|
||||
var g := GameSettings.new()
|
||||
g.interface_size = 1.3
|
||||
g.apply(root)
|
||||
await t.process_frame
|
||||
t.check(root.content_scale_factor == 1.0 and MobilePort.ui_scale(1.3) == 1.0 and MobilePort.ui_scale(0.8) == 1.0,
|
||||
"desktop %s: the factor stays 1 (%.2f)" % [size, root.content_scale_factor])
|
||||
var want := Vector2(size) * (1080.0 / size.y) # the 1080-tall canvas, as before
|
||||
t.check(root.get_visible_rect().size.is_equal_approx(want), "desktop %s: the canvas is %s (%s)" % [size, want, root.get_visible_rect().size])
|
||||
t.check(MobilePort.safe_rect(_probe) == _probe.get_viewport_rect(), "desktop %s: the safe rect is the visible rect" % size)
|
||||
t.check(MobilePort.minimum_target() == 44.0 and MobilePort.minimum_target(_probe) == 44.0, "desktop: the minimum target is 44")
|
||||
t.check(Vector2(root.get_final_transform().get_scale()).is_equal_approx(Vector2.ONE), "desktop 2340x1080: no extra scale")
|
||||
MobilePort.preview_insets = []
|
||||
|
||||
|
||||
## A 19.5:9 phone in the preview: about 1.6, applied as the window's factor, and the safe rect
|
||||
## inside the notch and home indicator insets.
|
||||
func _phone() -> void:
|
||||
MobilePort.forced = 1
|
||||
var root := t.root
|
||||
root.size = PHONE
|
||||
t.check(MobilePort.previewing(), "forced to a phone on desktop: the preview")
|
||||
var s := MobilePort.screen_scale()
|
||||
t.check(s > 1.55 and s < 1.65, "a 19.5:9 window plays a phone: scale %.2f (about 1.6)" % s)
|
||||
t.check(is_equal_approx(MobilePort.ui_scale(), s) and is_equal_approx(MobilePort.ui_scale(1.25), s * 1.25)
|
||||
and is_equal_approx(MobilePort.ui_scale(5.0), s * 1.3) and is_equal_approx(MobilePort.ui_scale(0.1), s * 0.8),
|
||||
"ui_scale is that times the Interface size, clamped to 0.8-1.3")
|
||||
MobilePort.preview_dpi = 460.0
|
||||
root.size = Vector2i(2556, 1179)
|
||||
t.check(is_equal_approx(MobilePort.screen_scale(), 4.3 / (1179.0 / 460.0)), "preview_dpi 460 at 2556x1179: an iPhone 15's %.2f" % MobilePort.screen_scale())
|
||||
MobilePort.preview_dpi = 0.0
|
||||
root.size = PHONE
|
||||
var g := GameSettings.new()
|
||||
g.apply(root)
|
||||
await t.process_frame
|
||||
t.check(is_equal_approx(root.content_scale_factor, s), "GameSettings.apply sets the factor to the scale (%.2f)" % root.content_scale_factor)
|
||||
var canvas := root.get_visible_rect().size
|
||||
t.check(canvas.is_equal_approx(Vector2(PHONE) / s), "the canvas shrinks by it: %s" % canvas)
|
||||
t.check(canvas.x > 1400.0 and canvas.x < 1520.0 and canvas.y > 650.0 and canvas.y < 700.0, "about 1460x675 (%s)" % canvas)
|
||||
t.check(_probe.size.is_equal_approx(canvas), "a full-rect HUD Control gets that canvas (%s)" % _probe.size)
|
||||
g.interface_size = 1.25
|
||||
g.apply_scale(root)
|
||||
await t.process_frame
|
||||
t.check(is_equal_approx(root.content_scale_factor, s * 1.25), "Interface size 125%%: factor %.2f" % root.content_scale_factor)
|
||||
g.interface_size = 1.0
|
||||
g.apply_scale(root)
|
||||
await t.process_frame
|
||||
# The safe rect, no inset: the whole canvas.
|
||||
var full := MobilePort.safe_rect(_probe)
|
||||
t.check(full.position.is_zero_approx() and full.size.is_equal_approx(canvas), "no inset: the safe rect is the canvas (%s)" % full)
|
||||
# A notch on both sides (the phone may turn either way) and the home indicator.
|
||||
MobilePort.preview_insets = [140, 0, 140, 60]
|
||||
var safe := MobilePort.safe_rect(_probe)
|
||||
var want := Rect2(Vector2(140.0, 0.0) / s, Vector2(PHONE.x - 280.0, PHONE.y - 60.0) / s)
|
||||
t.check(safe.position.is_equal_approx(want.position) and safe.size.is_equal_approx(want.size),
|
||||
"inset 140,0,140,60 px: the safe rect %s (want %s)" % [safe, want])
|
||||
t.check(Rect2(Vector2.ZERO, canvas).encloses(safe), "it's inside the canvas")
|
||||
var corner := Vector2(root.get_final_transform() * safe.end)
|
||||
t.check(corner.is_equal_approx(Vector2(PHONE.x - 140.0, PHONE.y - 60.0)), "its far corner is %s window pixels (2200, 1020)" % corner)
|
||||
var line := MobilePort.describe() # PerfTest's readout
|
||||
t.check(line.contains("Screen 2340×1080 · 400 dpi") and line.contains("safe area 140,0 2060×1020") and line.contains("(dpi)")
|
||||
and line.contains("canvas 1469×678"), "describe(): %s" % line.replace("\n", " / "))
|
||||
# A layer that's moved and scaled gets the same area in its own coordinates.
|
||||
var moved := CanvasLayer.new()
|
||||
moved.offset = Vector2(100.0, 50.0)
|
||||
moved.scale = Vector2(2.0, 2.0)
|
||||
var c := Control.new()
|
||||
moved.add_child(c)
|
||||
root.add_child(moved)
|
||||
var there := MobilePort.safe_rect(c)
|
||||
t.check(there.position.is_equal_approx((want.position - moved.offset) / 2.0) and there.size.is_equal_approx(want.size / 2.0),
|
||||
"in a moved, scaled layer: %s" % there)
|
||||
moved.free()
|
||||
# Too much inset: the whole window rather than nothing.
|
||||
MobilePort.preview_insets = [2000, 0, 2000, 0]
|
||||
t.check(MobilePort.safe_rect(_probe).size.is_equal_approx(canvas), "insets wider than the window: the whole canvas")
|
||||
MobilePort.preview_insets = []
|
||||
|
||||
|
||||
## A 4:3 window plays an iPad: 1x, the canvas 1920x1440 as before.
|
||||
func _ipad() -> void:
|
||||
MobilePort.forced = 1
|
||||
var root := t.root
|
||||
root.size = IPAD
|
||||
var s := MobilePort.screen_scale()
|
||||
t.check(s == 1.0, "a 4:3 window plays an iPad: scale %.2f" % s)
|
||||
GameSettings.new().apply_scale(root)
|
||||
await t.process_frame
|
||||
t.check(root.content_scale_factor == 1.0 and root.get_visible_rect().size.is_equal_approx(Vector2(1920.0, 1440.0)),
|
||||
"4:3 at 1x: the canvas is 1920x1440 (%s)" % root.get_visible_rect().size)
|
||||
MobilePort.preview_insets = [0, 40, 0, 40]
|
||||
var safe := MobilePort.safe_rect(_probe)
|
||||
var k := 1920.0 / IPAD.x # canvas pixels per window pixel
|
||||
t.check(safe.position.is_equal_approx(Vector2(0.0, 40.0 * k)) and safe.size.is_equal_approx(Vector2(1920.0, (IPAD.y - 80.0) * k)),
|
||||
"4:3 inset 0,40,0,40: %s" % safe)
|
||||
MobilePort.preview_insets = []
|
||||
|
||||
|
||||
## The minimum touch target: 44 points, about 70 canvas pixels on a phone and on an iPad, the
|
||||
## same at any window size, and smaller in canvas pixels as the Interface size grows.
|
||||
func _min_target() -> void:
|
||||
MobilePort.forced = 1
|
||||
var root := t.root
|
||||
var targets := {}
|
||||
for size: Vector2i in [PHONE, Vector2i(1170, 540), IPAD]:
|
||||
root.size = size
|
||||
GameSettings.new().apply_scale(root)
|
||||
await t.process_frame
|
||||
var m := MobilePort.minimum_target(_probe)
|
||||
targets[size] = m
|
||||
t.check(m > 60.0 and m < 80.0, "%s: the minimum target is %.1f canvas px (about 70)" % [size, m])
|
||||
t.check(is_equal_approx(m, MobilePort.minimum_target()), "%s: the same without a canvas item" % size)
|
||||
var points := m * root.get_final_transform().get_scale().y / MobilePort.pixels_per_point()
|
||||
t.check(is_equal_approx(points, 44.0), "%s: that's 44 points (%.2f)" % [size, points])
|
||||
t.check(is_equal_approx(targets[PHONE], targets[Vector2i(1170, 540)]), "the phone's target doesn't depend on the window's pixels")
|
||||
root.size = PHONE
|
||||
var g := GameSettings.new()
|
||||
g.interface_size = 1.3
|
||||
g.apply_scale(root)
|
||||
await t.process_frame
|
||||
t.check(is_equal_approx(MobilePort.minimum_target(_probe), targets[PHONE] / 1.3), "at 130%% it's 1.3 times fewer canvas pixels (%.1f)" % MobilePort.minimum_target(_probe))
|
||||
|
||||
|
||||
## The insets parse from numbers or text (as --safe-area=l,t,r,b), and anything else is none.
|
||||
func _insets() -> void:
|
||||
MobilePort.forced = 1
|
||||
MobilePort.preview_insets = ["140", "0", "140.5", "60"]
|
||||
t.check(MobilePort.insets() == [140.0, 0.0, 140.5, 60.0], "text insets parse: %s" % [MobilePort.insets()])
|
||||
MobilePort.preview_insets = [10, -5, 0, 0]
|
||||
t.check(MobilePort.insets() == [10.0, 0.0, 0.0, 0.0], "a negative inset is none")
|
||||
MobilePort.preview_insets = ["a", "0", "0", "0"]
|
||||
t.check(MobilePort.insets() == [0.0, 0.0, 0.0, 0.0], "a bad inset: none at all")
|
||||
MobilePort.preview_insets = []
|
||||
t.check(MobilePort.insets() == [0.0, 0.0, 0.0, 0.0], "no --safe-area: no inset")
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://cmrhytpkiqesd
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
extends RefCounted
|
||||
## The thumbsticks (TouchSticks) by touch, through the game's entry scene (main.tscn, with test
|
||||
## save and settings paths) on a 19.5:9 phone at its interface scale: the 24 checks of the
|
||||
## driver that came with them (8c81d81).
|
||||
## * On a phone Main adds them, fire loses its mouse button, and combat aims by stick.
|
||||
## * A finger on the right half is the move stick (it walks; its emulated click doesn't fire),
|
||||
## one on the left half the attack stick (it aims screen-up and attacks while held, without
|
||||
## switching combat to mouse aim); both work at once, and lifting a finger stops it. A tilt
|
||||
## inside the aim dead zone doesn't fire.
|
||||
## * A pause lets go of the sticks, and nothing walks on after it.
|
||||
## * A button gets its touch first: no stick starts.
|
||||
## * In the intro the sticks are off, and a held finger skips it.
|
||||
## The InputMap's mouse buttons for fire and offhand (TouchSticks erases them) are put back.
|
||||
|
||||
const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
const SAVE := "user://test_sticks_save.json"
|
||||
const SETTINGS := "user://test_sticks_settings.cfg"
|
||||
const PHONE := Vector2i(2340, 1080)
|
||||
|
||||
var t: GameTestRunner
|
||||
var main: Main
|
||||
var attacks: Array[int] = []
|
||||
|
||||
|
||||
func run(p_t: GameTestRunner) -> void:
|
||||
t = p_t
|
||||
_clean()
|
||||
var bindings := {}
|
||||
for action: StringName in [&"fire", &"offhand"]:
|
||||
bindings[action] = InputMap.action_get_events(action)
|
||||
var size := t.root.size
|
||||
var factor := t.root.content_scale_factor
|
||||
MobilePort.forced = 1
|
||||
t.root.size = PHONE
|
||||
main = (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
main.save_path = SAVE
|
||||
main.settings_path = SETTINGS
|
||||
t.root.add_child(main)
|
||||
await t.process_frame
|
||||
await t.process_frame
|
||||
await _sticks()
|
||||
main.queue_free()
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
for action: StringName in bindings:
|
||||
InputMap.action_erase_events(action)
|
||||
for e: InputEvent in bindings[action]:
|
||||
InputMap.action_add_event(action, e)
|
||||
for action in [&"fire", &"offhand", &"move_left", &"move_right", &"move_forward", &"move_back",
|
||||
&"aim_left", &"aim_right", &"aim_up", &"aim_down"]:
|
||||
Input.action_release(action)
|
||||
MobilePort.forced = -1
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _physics(n: int) -> void:
|
||||
for k in n:
|
||||
await t.physics_frame
|
||||
|
||||
|
||||
## Skips the first day's conversation, which pauses the farm.
|
||||
func _skip_talk() -> void:
|
||||
for k in 20:
|
||||
await t.process_frame
|
||||
if t.paused and main.screen == Main.Screen.PLAYING and main.sim.dialogue != null:
|
||||
main.sim.dialogue.box.skip()
|
||||
|
||||
|
||||
func _move() -> Vector2:
|
||||
return Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
||||
|
||||
|
||||
func _sticks() -> void:
|
||||
var sticks := main.farm.get_node_or_null("Hud/TouchSticks") as TouchSticks
|
||||
t.check(sticks != null, "TouchSticks added on a phone")
|
||||
if sticks == null:
|
||||
return
|
||||
t.check(t.root.content_scale_factor > 1.5, "at the phone's interface scale (%.2f)" % t.root.content_scale_factor)
|
||||
var mouse_fire := InputMap.action_get_events("fire").filter(func(e: InputEvent) -> bool: return e is InputEventMouseButton)
|
||||
t.check(mouse_fire.is_empty(), "fire has no mouse button")
|
||||
t.check(main.sim.combat.device == ScarecrowCombat.Device.GAMEPAD, "combat aims by stick")
|
||||
main.sim.combat.attacked.connect(func(_w: int) -> void: attacks.append(0))
|
||||
main.new_vacation(false)
|
||||
await t.process_frame
|
||||
main.sim.campaign.advance_phase() # morning -> day
|
||||
await _skip_talk()
|
||||
t.check(sticks.can_act(), "sticks can act in the day (phase %d)" % main.sim.campaign.state.phase)
|
||||
var w := sticks.size
|
||||
var right := Vector2(w.x * 0.75, w.y * 0.6)
|
||||
var left := Vector2(w.x * 0.25, w.y * 0.6)
|
||||
var player := main.sim.scarecrow.player
|
||||
# Move: finger 0 on the right half, dragged to the rim, rightward.
|
||||
var p0 := player.global_position
|
||||
Touch.touch(0, right, true)
|
||||
Touch.drag(0, right, right + Vector2(TouchSticks.RADIUS, 0.0))
|
||||
await _physics(40)
|
||||
t.check(_move().x > 0.9 and absf(_move().y) < 0.1, "move stick tilted right reads (1, 0): %s" % _move())
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == 0, "right half started the move stick")
|
||||
t.check(player.global_position.distance_to(p0) > 1.0, "the scarecrow walked %.1f m" % player.global_position.distance_to(p0))
|
||||
t.check(not Input.is_action_pressed("fire"), "moving doesn't fire (the tap's emulated click)")
|
||||
# Attack: finger 1 on the left half, dragged up (forward on screen).
|
||||
var a0 := attacks.size()
|
||||
Touch.touch(1, left, true)
|
||||
Touch.drag(1, left, left + Vector2(0.0, -TouchSticks.RADIUS))
|
||||
await _physics(60)
|
||||
t.check(Input.is_action_pressed("fire"), "attack stick holds fire")
|
||||
t.check(attacks.size() - a0 >= 2, "attacks repeat while held (%d)" % (attacks.size() - a0))
|
||||
var cam := t.root.get_camera_3d()
|
||||
var fwd := Vector2(-cam.global_basis.z.x, -cam.global_basis.z.z).normalized()
|
||||
t.check(main.sim.combat.aim.dot(fwd) > 0.9, "aim is screen-up (dot %.2f)" % main.sim.combat.aim.dot(fwd))
|
||||
t.check(main.sim.combat.device == ScarecrowCombat.Device.GAMEPAD, "taps didn't switch combat to mouse aim")
|
||||
t.check(_move().x > 0.9, "move holds while attacking")
|
||||
# Let go of the attack stick.
|
||||
Touch.touch(1, left + Vector2(0.0, -TouchSticks.RADIUS), false)
|
||||
await _physics(5)
|
||||
var a1 := attacks.size()
|
||||
await _physics(40)
|
||||
t.check(not Input.is_action_pressed("fire") and attacks.size() == a1, "releasing stops the attacks")
|
||||
# Let go of the move stick.
|
||||
Touch.touch(0, right + Vector2(TouchSticks.RADIUS, 0.0), false)
|
||||
await _physics(5)
|
||||
var p1 := player.global_position
|
||||
await _physics(30)
|
||||
t.check(_move() == Vector2.ZERO and player.global_position.distance_to(p1) < 0.2, "releasing stops the walk")
|
||||
# A small tilt (inside the aim dead zone) aims nowhere and doesn't fire.
|
||||
Touch.touch(1, left, true)
|
||||
Touch.drag(1, left, left + Vector2(TouchSticks.RADIUS * 0.15, 0.0))
|
||||
await _physics(10)
|
||||
t.check(not Input.is_action_pressed("fire"), "a tilt inside the dead zone doesn't fire")
|
||||
Touch.touch(1, left, false)
|
||||
await _physics(3)
|
||||
# A pause mid-walk lets go.
|
||||
Touch.touch(0, right, true)
|
||||
Touch.drag(0, right, right + Vector2(0.0, -TouchSticks.RADIUS))
|
||||
await _physics(10)
|
||||
t.check(_move().y < -0.9, "walking forward")
|
||||
main.pause()
|
||||
await t.process_frame
|
||||
t.check(_move() == Vector2.ZERO and sticks.finger[TouchSticks.Stick.MOVE] == -1, "pause lets the sticks go")
|
||||
main.resume()
|
||||
await _physics(5)
|
||||
var p2 := player.global_position
|
||||
await _physics(30)
|
||||
t.check(player.global_position.distance_to(p2) < 0.2, "no walking on after the pause")
|
||||
Touch.touch(0, right, false) # the finger lifted after the pause: ignored
|
||||
await t.process_frame
|
||||
await _button(sticks, right)
|
||||
# The intro: a held finger skips it; the sticks stay out of it.
|
||||
main.new_vacation()
|
||||
await t.process_frame
|
||||
t.check(main.sim.intro.running and not sticks.can_act(), "intro running, sticks off")
|
||||
Touch.touch(0, right, true)
|
||||
await t.create_timer(OpeningIntro.SKIP_HOLD + 0.6).timeout
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == -1, "no stick during the intro")
|
||||
t.check(main.sim.intro._skipping or not main.sim.intro.running, "holding a finger skips the intro")
|
||||
Touch.touch(0, right, false)
|
||||
await t.process_frame
|
||||
|
||||
|
||||
## A button over the move half (as PerfTest's were, in the driver) takes its tap: no stick starts.
|
||||
func _button(sticks: TouchSticks, at: Vector2) -> void:
|
||||
var layer := CanvasLayer.new()
|
||||
layer.layer = 20
|
||||
var b := Button.new()
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.size = Vector2(200.0, 100.0)
|
||||
b.position = at - b.size * 0.5
|
||||
layer.add_child(b)
|
||||
main.add_child(layer)
|
||||
await t.process_frame
|
||||
var pressed: Array[int] = []
|
||||
b.pressed.connect(func() -> void: pressed.append(0))
|
||||
Touch.touch(0, at, true)
|
||||
await t.process_frame
|
||||
t.check(sticks.finger[TouchSticks.Stick.MOVE] == -1 and sticks.finger[TouchSticks.Stick.ATTACK] == -1, "a touch on a button starts no stick")
|
||||
Touch.touch(0, at, false)
|
||||
await t.process_frame
|
||||
t.check(pressed.size() == 1, "the button got the tap")
|
||||
layer.free()
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://ccpmbww2ehqxx
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
extends RefCounted
|
||||
## Fingers for the phone tests (game/tests/mobile/), sent the way a phone sends them: through
|
||||
## Input.parse_input_event, so Godot's touch-to-click emulation runs too (finger 0 is also the
|
||||
## left mouse button), and delivered at once (Input.flush_buffered_events), so a check right
|
||||
## after a call sees its effect on the GUI and on _unhandled_input.
|
||||
## Points are canvas coordinates of the root viewport (what a full-rect HUD Control sees, at any
|
||||
## interface scale); they're turned into window pixels through the root's final transform, as
|
||||
## a phone's touches arrive.
|
||||
## const Touch := preload("res://game/tests/mobile/touch.gd")
|
||||
## Touch.touch(0, at, true) # finger 0 down at `at`
|
||||
## Touch.drag(0, at, at + Vector2(150, 0)) # it moves (one drag event; the finger stays down)
|
||||
## Touch.touch(0, at + Vector2(150, 0), false) # and lifts
|
||||
## Touch.tap(1, at) # finger 1 down and up at once
|
||||
|
||||
|
||||
## Finger i goes down (pressed) or lifts at this canvas point.
|
||||
static func touch(i: int, canvas_pos: Vector2, pressed: bool) -> void:
|
||||
var e := InputEventScreenTouch.new()
|
||||
e.index = i
|
||||
e.pressed = pressed
|
||||
e.position = window_pos(canvas_pos)
|
||||
_send(e)
|
||||
|
||||
|
||||
## Finger i, already down, moves from one canvas point to another (one drag event).
|
||||
static func drag(i: int, from: Vector2, to: Vector2) -> void:
|
||||
var e := InputEventScreenDrag.new()
|
||||
e.index = i
|
||||
e.position = window_pos(to)
|
||||
e.relative = window_pos(to) - window_pos(from)
|
||||
e.screen_relative = e.relative
|
||||
_send(e)
|
||||
|
||||
|
||||
## Finger i taps this canvas point: down, then up.
|
||||
static func tap(i: int, canvas_pos: Vector2) -> void:
|
||||
touch(i, canvas_pos, true)
|
||||
touch(i, canvas_pos, false)
|
||||
|
||||
|
||||
## A canvas point of the root viewport in window pixels (where a phone reports a touch there).
|
||||
static func window_pos(canvas_pos: Vector2) -> Vector2:
|
||||
var tree := Engine.get_main_loop() as SceneTree
|
||||
return tree.root.get_final_transform() * canvas_pos
|
||||
|
||||
|
||||
static func _send(e: InputEvent) -> void:
|
||||
Input.parse_input_event(e)
|
||||
Input.flush_buffered_events()
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://33srlb8fgmxj
|
||||
|
|
@ -27,7 +27,6 @@ const SUITES := [
|
|||
"res://game/tests/test_dialogue.gd",
|
||||
"res://game/tests/test_loading.gd",
|
||||
"res://game/tests/test_intro.gd",
|
||||
"res://game/tests/test_mobile.gd",
|
||||
]
|
||||
const TICK := 1.0 / 60.0
|
||||
## Points on the farm's edge (FarmZones.edge) for tests that send an enemy in from a known side:
|
||||
|
|
|
|||
|
|
@ -263,8 +263,7 @@ func _hidden_items(r: GameTestRunner) -> void:
|
|||
## multipliers multiply). upgrades_bought counts every level. The menu names the next level
|
||||
## ("Heavy seeds II") with its text and cost, says when it opens, and shows "Max" at the end.
|
||||
## Levels survive a save, the next morning, and a retry, and an old save's {"rapid_fire": 1}
|
||||
## loads as level 1. Sprint (#46) is a speed upgrade now: its text names sprint_speed_mult, the
|
||||
## menu offers it as that, and an old save's {"sprint": 1} still owns it (the id is unchanged).
|
||||
## loads as level 1.
|
||||
func _tiers(r: GameTestRunner) -> void:
|
||||
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
|
||||
var cfg := c.config
|
||||
|
|
@ -276,11 +275,6 @@ func _tiers(r: GameTestRunner) -> void:
|
|||
r.check(tiered == 9 and Upgrades.max_level(cfg, "sprint") == 1 and Upgrades.max_level(cfg, "corn_shooter") == 1
|
||||
and Upgrades.max_level(cfg, "alien_ray") == 1 and Upgrades.max_level(cfg, "radar") == 1,
|
||||
"the nine stat upgrades have 3 levels; Sprint, the weapons, and Radar one (%d with 3)" % tiered)
|
||||
var defaults := GameConfig.new()
|
||||
var says := "Run %d%% faster, always"
|
||||
r.check(Upgrades.text_at(cfg, "sprint", 1) == says % roundi((cfg.sprint_speed_mult - 1.0) * 100.0)
|
||||
and Upgrades.text_at(defaults, "sprint", 1) == says % roundi((defaults.sprint_speed_mult - 1.0) * 100.0),
|
||||
"Sprint says what it does: '%s' (x%.2f; game_config.gd's defaults agree)" % [Upgrades.text_at(cfg, "sprint", 1), cfg.sprint_speed_mult])
|
||||
# Costs grow.
|
||||
var grows := true
|
||||
for id: String in cfg.upgrades:
|
||||
|
|
@ -310,9 +304,6 @@ func _tiers(r: GameTestRunner) -> void:
|
|||
var row := panel._rows["heavy_seeds"] as Button
|
||||
r.check(row.text == "Heavy seeds I — Each kernel does 2 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 1)) and not row.disabled,
|
||||
"the menu offers level I: '%s'" % row.text)
|
||||
var sprint_row := panel._rows["sprint"] as Button
|
||||
r.check(sprint_row.text == "Sprint — %s (%s)" % [Upgrades.text_at(cfg, "sprint", 1), ResourceStore.describe(Upgrades.cost(cfg, "sprint", 1))]
|
||||
and not sprint_row.disabled, "the menu offers Sprint as the speed upgrade: '%s'" % sprint_row.text)
|
||||
var damage := cfg.shot_damage
|
||||
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 1
|
||||
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 1, "level 1 on day 1: kernels do %d damage" % (damage + 1))
|
||||
|
|
@ -382,15 +373,13 @@ func _tiers(r: GameTestRunner) -> void:
|
|||
"and a retry from that morning keeps them")
|
||||
# A save from before levels: {"rapid_fire": 1} is level 1.
|
||||
var old := c.state.to_dict()
|
||||
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1, "sprint": 1}
|
||||
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1}
|
||||
var was := SaveGame.read(TIERS_SAVE).state if SaveGame.write(old, TIERS_SAVE) == OK else null
|
||||
SaveGame.delete(TIERS_SAVE)
|
||||
r.check(was != null and Upgrades.level(was, "rapid_fire") == 1 and Upgrades.owned(was, "rapid_fire")
|
||||
and is_equal_approx(Upgrades.value(cfg, was, "fire_rate"), cfg.fire_rate * Upgrades.per_level(mult, 1))
|
||||
and Upgrades.next_cost(cfg, was, "rapid_fire") == Upgrades.cost(cfg, "rapid_fire", 2),
|
||||
"an old save's {\"rapid_fire\": 1} loads as level 1, with level 2 next")
|
||||
r.check(was != null and Upgrades.owned(was, "sprint") and Upgrades.level(was, "sprint") == 1,
|
||||
"and its {\"sprint\": 1} still owns Sprint, now the speed upgrade (same id)")
|
||||
c.queue_free()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
extends RefCounted
|
||||
## The phone tests: every game/tests/mobile/*_test.gd (one file per task), in name order, each
|
||||
## with the runner's check(). A test file extends RefCounted and has `func run(t) -> void` (it
|
||||
## may await); it forces a phone or desktop with MobilePort.forced = 1 or 0, sends fingers with
|
||||
## mobile/touch.gd, and before it returns sets MobilePort.forced back to -1 and frees what it
|
||||
## added (checked here). Between files this puts the root window back as it was (its size and
|
||||
## content_scale_factor, which a phone's GameSettings.apply changes), along with the desktop
|
||||
## preview's density and insets (MobilePort.preview_dpi, preview_insets) and the pause.
|
||||
## Run just these: -- --suite=test_mobile
|
||||
|
||||
const DIR := "res://game/tests/mobile/"
|
||||
|
||||
|
||||
func run(t: GameTestRunner) -> void:
|
||||
var files: Array[String] = []
|
||||
for f in DirAccess.get_files_at(DIR):
|
||||
if f.ends_with("_test.gd"):
|
||||
files.append(f)
|
||||
files.sort()
|
||||
t.check(not files.is_empty(), "%s has tests" % DIR)
|
||||
var suite := t.current
|
||||
var size := t.root.size
|
||||
var factor := t.root.content_scale_factor
|
||||
for f in files:
|
||||
var name := f.get_basename()
|
||||
print("-- ", name)
|
||||
t.current = "%s/%s" % [suite, name]
|
||||
var test: Object = (load(DIR + f) as GDScript).new()
|
||||
await test.call("run", t)
|
||||
t.check(MobilePort.forced == -1, "it set MobilePort.forced back to -1")
|
||||
MobilePort.forced = -1
|
||||
MobilePort.preview_dpi = 0.0
|
||||
MobilePort.preview_insets = []
|
||||
t.root.size = size
|
||||
t.root.content_scale_factor = factor
|
||||
t.paused = false
|
||||
await t.process_frame
|
||||
t.current = suite
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dwd5iel01flrd
|
||||
|
|
@ -193,7 +193,7 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
var morning := s.to_dict()
|
||||
var shed := s.resources.shed_total()
|
||||
var spent := 0
|
||||
r.check(not player.has_sprint() and player.speed_factor() == 1.0, "(no Sprint before the upgrade: 1x speed)")
|
||||
r.check(not player.can_sprint(), "(no sprint before the Sprint upgrade)")
|
||||
var day := s.night
|
||||
s.night = 14 # every shed item is in stock by day 14 (#26's from_day)
|
||||
for id in Upgrades.ORDER:
|
||||
|
|
@ -202,8 +202,7 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
r.check(Upgrades.level(s, id) == 1 and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
||||
s.night = day
|
||||
r.check(s.resources.shed_total() == shed - spent, "all %d cost %d materials together (level 1 each)" % [Upgrades.ORDER.size(), spent])
|
||||
r.check(player.has_sprint() and is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult),
|
||||
"sprint: the scarecrow is faster for good (x%.2f)" % player.speed_factor())
|
||||
r.check(player.can_sprint(), "sprint: the scarecrow can sprint")
|
||||
r.check(Upgrades.buy(c, "sprint", st).contains("already done") and Upgrades.buy(c, "rapid_fire", st).contains("level 2 opens on day 8")
|
||||
and Upgrades.level(s, "rapid_fire") == 1, "a one-off can't be bought twice, and an upgrade's level 2 waits for day 8")
|
||||
r.check(sim.combat.interval_ticks() < int(before["interval"]) and sim.combat.shot_damage() == int(before["damage"]) + 1,
|
||||
|
|
@ -262,20 +261,12 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
|||
_step(sim, 1)
|
||||
c.retry_night()
|
||||
r.check(s != c.state and c.state.upgrades == bought, "a retry from that morning keeps them")
|
||||
r.check(is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult), "Sprint's speed too, after the retry (x%.2f)" % player.speed_factor())
|
||||
var old := FarmState.from_dict(morning)
|
||||
r.check(old.upgrades.is_empty() and old.resources.shed_total() == shed, "(the morning before they were bought had none, and the materials)")
|
||||
c.new_campaign()
|
||||
_step(sim, 1)
|
||||
r.check(c.state.upgrades.is_empty() and sim.combat.shot_damage() == 1 and st.max_hp("fence") == cfg.fence_hp and not player.has_sprint()
|
||||
and player.speed_factor() == 1.0,
|
||||
r.check(c.state.upgrades.is_empty() and sim.combat.shot_damage() == 1 and st.max_hp("fence") == cfg.fence_hp and not player.can_sprint(),
|
||||
"a new vacation starts without them")
|
||||
c.load_state(back)
|
||||
_step(sim, 1)
|
||||
r.check(player.has_sprint() and is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult),
|
||||
"continuing the save brings Sprint's speed back (x%.2f)" % player.speed_factor())
|
||||
c.new_campaign()
|
||||
_step(sim, 1)
|
||||
player.global_position = AWAY
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,16 @@ extends RefCounted
|
|||
## not through cover, not while fleeing), fear (only thieves in range flee, carriers drop their
|
||||
## crop, thieves mid-steal lose their progress, the cooldown, thieves come back afterwards),
|
||||
## patching up (heals after the full channel while rooted; release, a hit, or fear cancel it;
|
||||
## not at full health), Sprint (#46: the upgrade makes it sprint_speed_mult times as fast for
|
||||
## good, walking and running, with nothing to hold, no time limit, no cooldown, and no stamina
|
||||
## bar), defeat (Game Over ahead of a stripped farm, the fall, the end panel and its Retry), the
|
||||
## morning revive, and the new input actions.
|
||||
## not at full health), sprint (only with the Sprint upgrade: faster while held and moving, 3 s at
|
||||
## most, then a 10 s recharge; letting go or stopping ends it early; the HUD line), defeat (Game
|
||||
## Over ahead of a stripped farm, the fall, the end panel and its Retry), the morning revive, and
|
||||
## the new input actions.
|
||||
|
||||
const S := LootSystem.Status
|
||||
const T := ThiefBehavior.State
|
||||
const DT := 1.0 / 60.0
|
||||
const AWAY := Vector3(-11.0, 0.0, 13.0)
|
||||
const SPOT := Vector2(8.0, -10.0) # open ground between the pen, the shed, and the field
|
||||
## A light stick: it walks (under run_threshold even with the Sprint upgrade).
|
||||
const WALK_STICK := 0.4
|
||||
|
||||
|
||||
func run(r: GameTestRunner) -> void:
|
||||
|
|
@ -42,7 +40,7 @@ func run(r: GameTestRunner) -> void:
|
|||
|
||||
|
||||
func _input_actions(r: GameTestRunner) -> void:
|
||||
for action in ["fear", "patch", "interact", "build_mode", "rotate_left", "rotate_right", "cancel", "pause"]:
|
||||
for action in ["fear", "patch", "interact", "build_mode", "rotate_left", "rotate_right", "cancel", "pause", "sprint"]:
|
||||
var keyboard := false
|
||||
var pad := false
|
||||
if InputMap.has_action(action):
|
||||
|
|
@ -186,90 +184,59 @@ func _patch(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
|||
_heal(sim)
|
||||
|
||||
|
||||
## Sprint (#46): owning the upgrade makes the scarecrow sprint_speed_mult times as fast for good,
|
||||
## walking and running alike, on desktop and phones. Nothing is held (the old sprint key does
|
||||
## nothing), and there's no time limit, no cooldown, and no stamina bar.
|
||||
func _sprint(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter, hud: ScarecrowHud) -> void:
|
||||
var cfg := sim.config
|
||||
var mult := cfg.sprint_speed_mult
|
||||
var s := sim.campaign.state
|
||||
var start := Vector3(0.0, 0.0, 6.0) # the open ground south-west of the pen
|
||||
s.upgrades.erase("sprint")
|
||||
r.check(not player.has_sprint() and player.speed_factor() == 1.0 and not hud.has_method(&"stamina"),
|
||||
"no Sprint before the upgrade: 1x speed (and the HUD has no stamina bar)")
|
||||
# On the real body, over physics frames: a full stick runs, a light one walks.
|
||||
var old_key := InputMap.has_action("sprint")
|
||||
if old_key:
|
||||
Input.action_press("sprint") # the old hold-to-sprint key
|
||||
var run0: float = await _speed_after(r, player, start, 1.0)
|
||||
var walk0: float = await _speed_after(r, player, start, WALK_STICK)
|
||||
if old_key:
|
||||
Input.action_release("sprint")
|
||||
r.check(absf(run0 - player.run_speed) < 0.05, "without it, it runs at %.2f m/s, even holding the old sprint key" % run0)
|
||||
hud._process(0.0)
|
||||
r.check(not player.can_sprint() and not hud.stamina_shown(), "no sprint before the upgrade (and no stamina bar on the HUD)")
|
||||
# On the real body, over physics frames: the open ground south-west of the pen.
|
||||
player.global_position = Vector3(0.0, 0.0, 6.0)
|
||||
player.velocity = Vector3.ZERO
|
||||
Input.action_press("move_right")
|
||||
Input.action_press("sprint")
|
||||
await _frames(r, 30)
|
||||
var speed := Vector2(player.velocity.x, player.velocity.z).length()
|
||||
r.check(not player.sprinting and speed <= player.run_speed + 0.05, "without it, holding sprint just runs (%.1f m/s)" % speed)
|
||||
s.upgrades["sprint"] = 1
|
||||
var run1: float = await _speed_after(r, player, start, 1.0)
|
||||
r.check(absf(run1 - player.run_speed * mult) < 0.05,
|
||||
"with the Sprint upgrade it runs x%.2f with nothing held: %.2f m/s (%.2f without)" % [mult, run1, run0])
|
||||
r.check(player.animation_player.current_animation == player.run_animation and absf(player.animation_player.speed_scale - mult) < 0.02,
|
||||
"the run clip plays x%.2f to match" % player.animation_player.speed_scale)
|
||||
r.check(absf(player.move_strength() - mult) < 0.02, "the partner's machine is told it's faster (strength %.2f)" % player.move_strength())
|
||||
var walk1: float = await _speed_after(r, player, start, WALK_STICK)
|
||||
r.check(walk0 > 0.5 and absf(walk1 - walk0 * mult) < 0.05 and player.animation_player.current_animation == player.walk_animation,
|
||||
"walking (a light stick) is x%.2f too: %.2f m/s (%.2f without), on the walk clip" % [walk1 / maxf(walk0, 0.001), walk1, walk0])
|
||||
# No time limit: 30 s of moving without a stop, the body stepped tick by tick inside one physics
|
||||
# frame and put back on the open ground each second.
|
||||
Input.action_press("move_right")
|
||||
await r.physics_frame
|
||||
var span := _hand_step(player, start, 30.0)
|
||||
var last := Vector2(player.velocity.x, player.velocity.z).length()
|
||||
r.check(absf(span.x - run1) < 0.05 and absf(span.y - run1) < 0.05 and absf(last - run1) < 0.05,
|
||||
"no time limit: after 30 s of moving it still runs %.2f m/s (%.2f..%.2f m/s throughout)" % [last, span.x, span.y])
|
||||
# No cooldown: stop, then go again.
|
||||
await _frames(r, 30)
|
||||
speed = Vector2(player.velocity.x, player.velocity.z).length()
|
||||
r.check(player.sprinting and absf(speed - player.run_speed * cfg.sprint_speed_mult) < 0.1,
|
||||
"with the Sprint upgrade, holding sprint while moving sprints: %.1f m/s (runs at %.1f)" % [speed, player.run_speed])
|
||||
r.check(player.animation_player.current_animation == player.run_animation and player.animation_player.speed_scale > 1.5,
|
||||
"the run clip plays faster (x%.2f)" % player.animation_player.speed_scale)
|
||||
r.check(player.move_strength() > 1.5, "the partner's machine is told it's sprinting (strength %.2f)" % player.move_strength())
|
||||
r.check(hud.stamina_shown() and hud.stamina() < 1.0 and is_equal_approx(hud.stamina(), player.sprint_left / cfg.sprint_time),
|
||||
"the HUD's stamina bar appears, and drains while sprinting (%.2f)" % hud.stamina())
|
||||
Input.action_release("move_right")
|
||||
var stopped := _hand_step(player, start, 1.0)
|
||||
Input.action_press("move_right")
|
||||
var again := _hand_step(player, start, 0.5)
|
||||
r.check(stopped.y < 0.05 and absf(again.x - run1) < 0.05 and absf(again.y - run1) < 0.05,
|
||||
"no cooldown: stopped, then off again at once at %.2f m/s" % again.y)
|
||||
Input.action_release("move_right")
|
||||
sim.scarecrow.reset_for_morning()
|
||||
r.check(is_equal_approx(player.speed_factor(), mult), "a new morning keeps it (x%.2f)" % player.speed_factor())
|
||||
# Phones: the speed path never asks the platform, so MobilePort.active() makes no difference.
|
||||
var asks := false
|
||||
for script: GDScript in [player.get_script(), load("res://game/scripts/upgrades.gd")]:
|
||||
asks = asks or script.source_code.contains("MobilePort")
|
||||
r.check(not asks, "the speed doesn't depend on the platform (PlayerCharacter and Upgrades never ask MobilePort; phone mode here: %s)" % MobilePort.active())
|
||||
s.upgrades.erase("sprint")
|
||||
await _frames(r, 2)
|
||||
r.check(not player.sprinting and player.sprint_recharge > cfg.sprint_cooldown - 0.1, "stopping ends it, and the recharge starts")
|
||||
r.check(hud.stamina() < 0.1, "and starts filling back as it recharges (%.2f)" % hud.stamina())
|
||||
Input.action_release("sprint")
|
||||
await _frames(r, 30)
|
||||
player.velocity = Vector3.ZERO
|
||||
player.global_position = Vector3(SPOT.x, 0.0, SPOT.y)
|
||||
|
||||
|
||||
## Puts the scarecrow at a spot at rest, holds move_right at a stick strength for 30 physics
|
||||
## frames, and returns its speed (m/s). move_right stays held.
|
||||
func _speed_after(r: GameTestRunner, player: PlayerCharacter, at: Vector3, strength: float) -> float:
|
||||
player.global_position = at
|
||||
player.velocity = Vector3.ZERO
|
||||
Input.action_press("move_right", strength)
|
||||
await _frames(r, 30)
|
||||
return Vector2(player.velocity.x, player.velocity.z).length()
|
||||
|
||||
|
||||
## Steps the body by hand for that many seconds of 60 Hz ticks (call it right after awaiting
|
||||
## physics_frame, so move_and_slide moves by DT), putting it back at the spot every second so it
|
||||
## stays on open ground. Returns the lowest and highest speed (m/s) over the ticks after the
|
||||
## first quarter second (the speed-up).
|
||||
func _hand_step(player: PlayerCharacter, at: Vector3, seconds: float) -> Vector2:
|
||||
var span := Vector2(INF, 0.0)
|
||||
var ticks := roundi(seconds / DT)
|
||||
for i in ticks:
|
||||
if i % 60 == 0:
|
||||
player.global_position = at
|
||||
player._physics_process(DT)
|
||||
if i >= 15:
|
||||
var v := Vector2(player.velocity.x, player.velocity.z).length()
|
||||
span = Vector2(minf(span.x, v), maxf(span.y, v))
|
||||
return span
|
||||
# The timing, tick by tick.
|
||||
player.reset_sprint()
|
||||
var ticks := 0
|
||||
player.step_sprint(DT, true, true)
|
||||
while player.sprinting and ticks < 1200:
|
||||
player.step_sprint(DT, true, true)
|
||||
ticks += 1
|
||||
r.check(absf(ticks * DT - cfg.sprint_time) < DT * 2.0, "held, a sprint lasts %.1f s" % (ticks * DT))
|
||||
ticks = 0
|
||||
while not player.sprinting and ticks < 1200:
|
||||
player.step_sprint(DT, true, true)
|
||||
ticks += 1
|
||||
r.check(absf(ticks * DT - cfg.sprint_cooldown) < DT * 2.0, "then %.1f s to recharge, and still held it starts again" % (ticks * DT))
|
||||
player.step_sprint(1.0, true, true)
|
||||
player.step_sprint(DT, false, true)
|
||||
r.check(not player.sprinting and is_equal_approx(player.sprint_recharge, cfg.sprint_cooldown), "letting go early ends it, and the full recharge starts")
|
||||
player.step_sprint(DT, true, false)
|
||||
r.check(not player.sprinting, "and it doesn't start standing still")
|
||||
sim.scarecrow.reset_for_morning()
|
||||
r.check(player.sprint_recharge == 0.0 and hud.stamina() == 1.0, "a new morning has it ready (a full bar)")
|
||||
s.upgrades.erase("sprint")
|
||||
|
||||
|
||||
func _frames(r: GameTestRunner, n: int) -> void:
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
extends SceneTree
|
||||
## Captures the phone build's day HUD for review: runs the real game (main.tscn) in a window as a
|
||||
## phone (MobilePort's preview: pass -- --mobile, so Main sets the farm up as on a phone and
|
||||
## GameSettings.apply scales the interface), starts a New vacation without its intro, begins day
|
||||
## 1, skips the day's conversation, and saves the screen; then the same with the safe area
|
||||
## marked (MobilePort.safe_rect outlined, outside it shaded), and quits. It prints what the scale
|
||||
## came to (MobilePort.describe). It needs a window (not --headless) that isn't fullscreen (the
|
||||
## project's default), so pass --windowed and a resolution; keep it visible and pass
|
||||
## --disable-vsync (a hidden window with VSync on crawls on some desktops). The desktop may
|
||||
## resize a big window (one desktop here maximized a 2340x1080 one), so --size=WxH makes it
|
||||
## borderless at exactly that size once it's up, and applies the scale for it again:
|
||||
## godot --path . --rendering-method mobile --windowed --resolution 2340x1080 --screen 2 \
|
||||
## --disable-vsync --script res://game/tools/capture_mobile.gd -- --mobile \
|
||||
## --size=2340x1080 --safe-area=140,0,140,60 --out=/tmp/hs-mobile --prefix=phone
|
||||
## Options (after --): --out=dir (default /tmp/hs-mobile/), --prefix=text (default "day"),
|
||||
## --size=WxH, and MobilePort's own --safe-area=l,t,r,b and --dpi=N. It saves to its own
|
||||
## user://capture_mobile_* files, so the player's save and settings are never touched.
|
||||
|
||||
const SAVE := "user://capture_mobile_save.json"
|
||||
const SETTINGS := "user://capture_mobile_settings.cfg"
|
||||
const SHADE := Color(1.0, 0.0, 0.6, 0.3)
|
||||
const EDGE := Color(1.0, 0.0, 0.6, 0.9)
|
||||
|
||||
var _out := "/tmp/hs-mobile/"
|
||||
var _prefix := "day"
|
||||
var _size := Vector2i.ZERO
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
for a in OS.get_cmdline_user_args():
|
||||
var arg := String(a)
|
||||
if arg.begins_with("--out="):
|
||||
_out = arg.trim_prefix("--out=")
|
||||
elif arg.begins_with("--prefix="):
|
||||
_prefix = arg.trim_prefix("--prefix=")
|
||||
elif arg.begins_with("--size="):
|
||||
var wh := arg.trim_prefix("--size=").split("x")
|
||||
if wh.size() == 2:
|
||||
_size = Vector2i(int(wh[0]), int(wh[1]))
|
||||
if not _out.ends_with("/"):
|
||||
_out += "/"
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
_clean()
|
||||
DirAccess.make_dir_recursive_absolute(_out)
|
||||
if not MobilePort.active():
|
||||
push_warning("capture_mobile: not a phone; pass -- --mobile to see the phone build")
|
||||
var main := (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
main.save_path = SAVE
|
||||
main.settings_path = SETTINGS
|
||||
root.add_child(main)
|
||||
for i in 5:
|
||||
await process_frame
|
||||
if _size != Vector2i.ZERO and root.size != _size:
|
||||
root.borderless = true # the desktop won't shrink or tile it then
|
||||
root.size = _size
|
||||
root.position = DisplayServer.screen_get_position(root.current_screen)
|
||||
for i in 20:
|
||||
await process_frame
|
||||
main.settings.apply_scale(root) # the scale for the window's new shape
|
||||
main.new_vacation(false)
|
||||
await process_frame
|
||||
main.sim.campaign.advance_phase() # the first morning's sign -> day 1
|
||||
for i in 30:
|
||||
await process_frame
|
||||
if paused and main.screen == Main.Screen.PLAYING and main.sim.dialogue != null:
|
||||
main.sim.dialogue.box.skip() # the day's conversation pauses the farm
|
||||
await create_timer(1.5).timeout # the HUD settles (tips fade in, the camera arrives)
|
||||
print("capture_mobile: window %s, canvas %s" % [root.size, root.get_visible_rect().size])
|
||||
print("capture_mobile: ", MobilePort.describe())
|
||||
await _shot("")
|
||||
var marks := CanvasLayer.new()
|
||||
marks.layer = 100
|
||||
var c := Control.new()
|
||||
c.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
marks.add_child(c)
|
||||
root.add_child(marks)
|
||||
c.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
c.draw.connect(func() -> void:
|
||||
var all := c.get_viewport_rect()
|
||||
var safe := MobilePort.safe_rect(c)
|
||||
c.draw_rect(Rect2(all.position, Vector2(all.size.x, safe.position.y - all.position.y)), SHADE)
|
||||
c.draw_rect(Rect2(Vector2(all.position.x, safe.end.y), Vector2(all.size.x, all.end.y - safe.end.y)), SHADE)
|
||||
c.draw_rect(Rect2(Vector2(all.position.x, safe.position.y), Vector2(safe.position.x - all.position.x, safe.size.y)), SHADE)
|
||||
c.draw_rect(Rect2(Vector2(safe.end.x, safe.position.y), Vector2(all.end.x - safe.end.x, safe.size.y)), SHADE)
|
||||
c.draw_rect(safe, EDGE, false, 3.0)
|
||||
var t := MobilePort.minimum_target(c)
|
||||
c.draw_rect(Rect2(safe.get_center() - Vector2(t, t) * 0.5, Vector2(t, t)), EDGE, false, 2.0)) # the minimum touch target
|
||||
await _shot("_safe")
|
||||
main.queue_free()
|
||||
await process_frame
|
||||
await create_timer(0.3).timeout
|
||||
_clean()
|
||||
quit()
|
||||
|
||||
|
||||
func _shot(suffix: String) -> void:
|
||||
await process_frame
|
||||
await process_frame
|
||||
var path := "%s%s%s.png" % [_out, _prefix, suffix]
|
||||
var err := root.get_texture().get_image().save_png(path)
|
||||
print("capture_mobile: %s (%s)" % [path, error_string(err)])
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://c82qfl7ugukef
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
"43": "Enemy Characters & Hits",
|
||||
"44": "PumpkinBombs",
|
||||
"45": "WeaponModels",
|
||||
"46": "test_weapons.gd",
|
||||
"47": "Prop Collision Builder",
|
||||
"48": "Horde Performance Report",
|
||||
"49": "KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)",
|
||||
|
|
@ -55,6 +56,8 @@
|
|||
"54": "GD-Sync Sync Icons",
|
||||
"55": "Pine & Foliage Textures",
|
||||
"56": "Campaign Experience (Step 11)",
|
||||
"57": "equip",
|
||||
"58": "render_overview.gd",
|
||||
"59": "Grid Design & Scope Limits",
|
||||
"60": "GD-Sync Physics/Voice Icons",
|
||||
"61": "AGENTS.md graphify Rules",
|
||||
|
|
|
|||
|
|
@ -43,16 +43,9 @@
|
|||
"41": "Harvest Season — co-op",
|
||||
"42": "Snapshot Decoding",
|
||||
"43": "Enemy Characters & Hits",
|
||||
"44": "PumpkinBombs",
|
||||
"45": "WeaponModels",
|
||||
"46": "test_weapons.gd",
|
||||
"47": "Prop Collision Builder",
|
||||
"48": "Horde Performance Report",
|
||||
"49": "KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)",
|
||||
"50": "GameConfig",
|
||||
"51": "Upgrades",
|
||||
"52": "Harvest Season — alien overhaul: review, decisions, and task plan",
|
||||
"53": "Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)",
|
||||
"54": "GD-Sync Sync Icons",
|
||||
"55": "Pine & Foliage Textures",
|
||||
"56": "Campaign Experience (Step 11)",
|
||||
|
|
@ -68,7 +61,6 @@
|
|||
"68": "Mannequin Textures",
|
||||
"69": "Bark Normal Maps",
|
||||
"70": "Nature MegaKit License",
|
||||
"71": "summarize.py",
|
||||
"72": "GD-Sync Logo",
|
||||
"73": "GD-Sync Load Icon",
|
||||
"74": "GD-Sync Instantiator Icon",
|
||||
|
|
@ -78,5 +70,7 @@
|
|||
"78": "Mushrooms Texture",
|
||||
"79": "Project Icon",
|
||||
"80": "Alien overhaul — task list",
|
||||
"81": "test_theft.gd"
|
||||
"81": "test_theft.gd",
|
||||
"85": "stop",
|
||||
"86": "MainMenu"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
# Graph Report - harvest-season (2026-10-14)
|
||||
# Graph Report - ios-test-port (2026-10-14)
|
||||
|
||||
## Corpus Check
|
||||
- 40 files · ~1,676,085 words
|
||||
- 40 files · ~1,667,729 words
|
||||
- Verdict: corpus is large enough that graph structure adds value.
|
||||
|
||||
## Summary
|
||||
- 1386 nodes · 4099 edges · 80 communities (65 shown, 15 thin omitted)
|
||||
- 1374 nodes · 4087 edges · 74 communities (58 shown, 16 thin omitted)
|
||||
- Extraction: 87% EXTRACTED · 13% INFERRED · 0% AMBIGUOUS · INFERRED: 542 edges (avg confidence: 0.91)
|
||||
- Token cost: 0 input · 0 output
|
||||
|
||||
## Graph Freshness
|
||||
- Built from commit: `c439925c`
|
||||
- Built from commit: `2e68223b`
|
||||
- Run `git rev-parse HEAD` and compare to check if the graph is stale.
|
||||
- Run `graphify update .` after code changes (no API cost).
|
||||
|
||||
|
|
@ -52,23 +52,13 @@
|
|||
- Shed Stock & Supply Targets
|
||||
- ResourceStore
|
||||
- Farm Projectiles
|
||||
- Alert Manager
|
||||
- Net Budget Tool
|
||||
- Enemy Roster Tests
|
||||
- Co-op Menu UI
|
||||
- Harvest Season — co-op
|
||||
- Snapshot Decoding
|
||||
- Enemy Characters & Hits
|
||||
- PumpkinBombs
|
||||
- WeaponModels
|
||||
- test_weapons.gd
|
||||
- Prop Collision Builder
|
||||
- Horde Performance Report
|
||||
- KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)
|
||||
- GameConfig
|
||||
- Upgrades
|
||||
- Harvest Season — alien overhaul: review, decisions, and task plan
|
||||
- Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)
|
||||
- GD-Sync Sync Icons
|
||||
- Pine & Foliage Textures
|
||||
- Campaign Experience (Step 11)
|
||||
|
|
@ -92,6 +82,10 @@
|
|||
- Grass Texture
|
||||
- Mushrooms Texture
|
||||
- Project Icon
|
||||
- Alien overhaul — task list
|
||||
- test_theft.gd
|
||||
- stop
|
||||
- MainMenu
|
||||
|
||||
## God Nodes (most connected - your core abstractions)
|
||||
1. `CampaignController` - 119 edges
|
||||
|
|
@ -119,13 +113,13 @@
|
|||
|
||||
## Import Cycles
|
||||
- 3-file cycle: `game/scripts/enemy_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 4-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/enemy_system.gd`
|
||||
- 4-file cycle: `game/scripts/enemy_system.gd -> game/scripts/loot_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/pumpkin_bombs.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 4-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_characters.gd -> game/scripts/loot_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd -> game/scripts/enemy_characters.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_characters.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd -> game/scripts/enemy_characters.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/pumpkin_bombs.gd -> game/scripts/enemy_system.gd`
|
||||
|
||||
## Hyperedges (group relationships)
|
||||
- **Prototype classes forked or generalized into game/ systems** — readme_hordesystem, game_scripts_enemy_system, readme_chasebehavior, game_scripts_thief_behavior, readme_arenanavigation, game_scripts_farm_navigation, readme_roundcontroller, game_scripts_campaign_controller, readme_prototypeconfig, game_scripts_game_config [EXTRACTED 1.00]
|
||||
|
|
@ -163,223 +157,175 @@
|
|||
- **Retry restores the failed night's morning snapshot (verified across suites)** — game_tests_test_campaign_retry, game_tests_test_economy_deposit_and_night, game_tests_test_coop_fall_rule, game_tests_test_flow_failure, game_tests_test_nights_upgrades [INFERRED 0.85]
|
||||
- **Suites that instantiate farm.tscn and step FarmSim by hand at 60 Hz** — game_tests_test_coop, game_tests_test_economy, game_tests_test_farm_layout, game_tests_test_nights, game_tests_test_roster [EXTRACTED 1.00]
|
||||
|
||||
## Communities (80 total, 15 thin omitted)
|
||||
## Communities (74 total, 16 thin omitted)
|
||||
|
||||
### Community 0 - "Campaign Controller & Farm State"
|
||||
Cohesion: 0.13
|
||||
Nodes (19): Dawn retreat and grace (D4), Dusk warning (banner, hint, phase HUD list), Phase cycle (Morning → Day → Dusk → Night → Dawn), FarmState, asset_counts(), create(), from_dict(), is_valid() (+11 more)
|
||||
Cohesion: 0.05
|
||||
Nodes (80): Assessment, CampaignController, advance_phase(), begin_day(), campaign_ended (signal), can_start_night_early(), check_outcome(), _enter() (+72 more)
|
||||
|
||||
### Community 1 - "Structures & Build Mode"
|
||||
Cohesion: 0.24
|
||||
Nodes (12): _process(), pay(), structure(), pay(), built (signal), dismantle(), max_hp(), place() (+4 more)
|
||||
Cohesion: 0.05
|
||||
Nodes (83): Automated defense (buildable), Crow (enemy), Fence (buildable), Fence breaker (enemy), Flying rule (fences, gates, traps ignore flyers), Gameplay is 2-D on the XZ plane, Gate (buildable), Pen gate breach (gate as start structure) (+75 more)
|
||||
|
||||
### Community 2 - "Audio & Farmers Return Ending"
|
||||
Cohesion: 0.05
|
||||
Nodes (70): Day/night lighting and lantern, Night record (FarmState.night_log) and morning review, enemies_line(), materials_line(), of(), new_campaign(), phase_changed (signal), DayNight (+62 more)
|
||||
Cohesion: 0.06
|
||||
Nodes (64): Harvest Season — audio credits, Kenney Digital Audio pack, Kenney Impact Sounds pack, Kenney Interface Sounds pack, Kenney Music Jingles pack (pizzicato set), Kenney RPG Audio pack, Kenney UI Audio (UI SFX Set) pack, "On the Farm" (music track) (+56 more)
|
||||
|
||||
### Community 3 - "Scarecrow Weapons & Bombs"
|
||||
Cohesion: 0.07
|
||||
Nodes (60): Prototype Kit texture (8x8 RGB color palette swatch atlas for flat-shaded prototype pieces), PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb), note(), PumpkinBombs, _burst(), burst (signal), _flash(), _new_mesh() (+52 more)
|
||||
Nodes (61): Prototype Kit texture (8x8 RGB color palette swatch atlas for flat-shaded prototype pieces), PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb), note(), PumpkinBombs, _burst(), burst (signal), _flash(), _new_mesh() (+53 more)
|
||||
|
||||
### Community 4 - "Waves, Night Plans & Review"
|
||||
Cohesion: 0.12
|
||||
Nodes (26): Harvest Season — audio credits, Kenney Digital Audio pack, Kenney Impact Sounds pack, Kenney Interface Sounds pack, Kenney Music Jingles pack (pizzicato set), Kenney RPG Audio pack, Kenney UI Audio (UI SFX Set) pack, Synthesized game sounds (synth/) (+18 more)
|
||||
|
||||
### Community 5 - "First Game Plan & Milestones"
|
||||
Cohesion: 0.07
|
||||
Nodes (48): First complete version — five-night vacation build steps, Farmers' return ending, Five-night farm vacation (core loop), Harvest Season — first game development plan, Alert priorities, grouping, and cap, D10: Ground enemies before Step 9, D1: Starting the night early (allow_early_night, off by default), D2: Early campaign end (scarecrow death or farm stripped) (+40 more)
|
||||
|
||||
### Community 6 - "Horde Prototype (README)"
|
||||
Cohesion: 0.12
|
||||
Nodes (36): Crows on MultiMesh, ground enemies from a KayKit pool, One fixed-order simulation tick, Game code in game/, prototype/ frozen (fork rule), One GameConfig resource, Horde survival prototype — coding-agent implementation plan, Centralized simulation with reusable storage, Prototype implementation milestones and gates, Pool reuse rules (no hot-path allocation) (+28 more)
|
||||
|
||||
### Community 7 - "Co-op Lobby & Smoke Test"
|
||||
Cohesion: 0.14
|
||||
Nodes (35): GDSync (GD-Sync plugin autoload), CoopLobby, _begin(), failed (signal), has_online_keys(), host(), host_addresses(), join() (+27 more)
|
||||
|
||||
### Community 8 - "Scarecrow Defender & Fear"
|
||||
Cohesion: 0.07
|
||||
Nodes (52): The scarecrow (player defender), pressed(), add_partner(), set_local(), FollowCamera, _apply(), _process(), snap_to_target() (+44 more)
|
||||
|
||||
### Community 9 - "Loot & Theft Events"
|
||||
Cohesion: 0.13
|
||||
Nodes (29): position(), start_following(), record_event(), LootSystem, animal_home(), animal_strays(), claim(), _claim_home() (+21 more)
|
||||
|
||||
### Community 10 - "Settings, Input & UI Theme"
|
||||
Cohesion: 0.19
|
||||
Nodes (17): can_start_night_early(), start_night_early(), CampaignDebug, cycle_scenario(), _describe(), _unhandled_input(), PhaseHud, join_words() (+9 more)
|
||||
|
||||
### Community 11 - "Main Scene & Title Menu"
|
||||
Cohesion: 0.11
|
||||
Nodes (35): AnimalSystem, _apply_visuals(), find_animals(), _follow(), _move(), pen_changed (signal), place(), _record_trail() (+27 more)
|
||||
|
||||
### Community 12 - "Farm Zones & Layout Tests"
|
||||
Cohesion: 0.09
|
||||
Nodes (43): Harvest Season — farm layout, The farm's edge (random enemy arrivals and carrier escapes), Farmers' return route and staging points, Fence gaps (GapNorth, GapDriveway, GapEast), Playable area (60 × 60 m, FarmZones.playable), Scarecrow bounds (PlayerBounds, physics layer 3, FarmZones.roam), CropUnit, FarmMarker (+35 more)
|
||||
|
||||
### Community 13 - "Enemy System & Theft Tests"
|
||||
Cohesion: 0.09
|
||||
Nodes (38): Fence breaker (enemy), Ground thief (enemy), Thief (enemy type), EnemyCharacters, acquire(), _animate(), clear(), hit() (+30 more)
|
||||
|
||||
### Community 14 - "Co-op Session Host/Client"
|
||||
Cohesion: 0.13
|
||||
Nodes (34): received (signal), send(), CoopSession, _apply_event(), _apply_foes(), _apply_state(), _client_message(), _close_menu_if_needed() (+26 more)
|
||||
|
||||
### Community 15 - "Rules of the Vacation"
|
||||
Cohesion: 0.05
|
||||
Nodes (64): "On the Farm" (music track), "Purgatory" (DavidKBD, Purgatory Pack music track), KayKit Character Animations license (CC0), KayKit: Character Animations 1.1 (Kay Lousberg), Prototype Kit license (CC0, Rgsdev), Prototype Kit (Raphael Gonçalves / Rgsdev), MultiMesh batching for birds and bullets, Simulation tick profile at 2,000 birds (steering, motion+collision, flow-field slice, grid) (+56 more)
|
||||
|
||||
### Community 16 - "Game Flow, Save & Pause"
|
||||
Cohesion: 0.17
|
||||
Nodes (26): Autosave and Continue (user://savegame.json), ConfirmBox, close(), _yes(), Main, _leave_as_partner(), _on_session_ended(), pause() (+18 more)
|
||||
|
||||
### Community 17 - "Farm Navigation Flow Fields"
|
||||
Cohesion: 0.09
|
||||
Nodes (46): _escalation(), handle_of(), queue_removal(), step(), FarmNavigation, barrier_ahead(), build(), cell_center() (+38 more)
|
||||
|
||||
### Community 18 - "Resource Economy & Upgrades"
|
||||
Cohesion: 0.10
|
||||
Nodes (20): Alien overhaul — task list, Dependent, Independent, Independent, Last, Opening intro — task list (2026-10-07), Playable on phones — task list, Post-overhaul fix batch (2026-10-06) (+12 more)
|
||||
|
||||
### Community 19 - "Animal System"
|
||||
Cohesion: 0.09
|
||||
Nodes (27): Harvest Season — co-op, GD-Sync API keys (keys.cfg), GD-Sync data allowance budget (22 MB per vacation, ~12 KB/s), Unreliable message size limit (under 1,100 bytes; GD-Sync splits at 1,200), Dead reckoning for enemies (25 cm error threshold), Harvest Season patches to GD-Sync (4), Host-authoritative simulation with partner replica (FarmSim.replica), LAN join by address (+19 more)
|
||||
|
||||
### Community 20 - "Test Runner & Farm Targets"
|
||||
Cohesion: 0.10
|
||||
Nodes (19): 1. With losses permanent, the density decides when the farm is empty, 2. Match the breakers to their pool, 3. Straw and Alien Goop pile up; wood runs out, Appendix: every night, per seed, Arrivals, the peak on the farm, and the tick, Character pools, Method, Not measured (+11 more)
|
||||
|
||||
### Community 5 - "First Game Plan & Milestones"
|
||||
Cohesion: 0.09
|
||||
Nodes (40): First complete version — five-night vacation build steps, Farmers' return ending, Five-night farm vacation (core loop), Harvest Season — first game development plan, D10: Ground enemies before Step 9, D1: Starting the night early (allow_early_night, off by default), D2: Early campaign end (scarecrow death or farm stripped), D3: Phase lengths (+32 more)
|
||||
|
||||
### Community 6 - "Horde Prototype (README)"
|
||||
Cohesion: 0.15
|
||||
Nodes (30): Game code in game/, prototype/ frozen (fork rule), Horde survival prototype — coding-agent implementation plan, Centralized simulation with reusable storage, Prototype implementation milestones and gates, Performance measurement goals (p95 <= 16.67 ms), Pool reuse rules (no hot-path allocation), Stress presets (25/50 to 1,000/2,000 birds), Harvest Season — horde survival prototype (+22 more)
|
||||
|
||||
### Community 7 - "Co-op Lobby & Smoke Test"
|
||||
Cohesion: 0.15
|
||||
Nodes (31): CoopLobby, _begin(), failed (signal), has_online_keys(), host(), host_addresses(), join_address(), _join_timed_out() (+23 more)
|
||||
|
||||
### Community 8 - "Scarecrow Defender & Fear"
|
||||
Cohesion: 0.05
|
||||
Nodes (64): MultiMesh batching for birds and bullets, GDScript simulation is the bottleneck, not rendering, Farm draw-call reduction (1,270 → 304 at start), User feedback: "extraordinarily easy" → 30-day scale pass, 5x enemies scale pass (up to 160 enemies; FarmSim.step 0.45 ms avg), pressed(), FarmSim, add_partner() (+56 more)
|
||||
|
||||
### Community 9 - "Loot & Theft Events"
|
||||
Cohesion: 0.06
|
||||
Nodes (78): Step 8: All three farm targets, Supply bundles (sacks from the most-stocked material), Step 8: Expand to all three farm targets, Three farm targets: crops, animals, supplies, AnimalSystem, _apply_visuals(), find_animals(), _follow() (+70 more)
|
||||
|
||||
### Community 10 - "Settings, Input & UI Theme"
|
||||
Cohesion: 0.23
|
||||
Nodes (14): _open_settings(), SettingsMenu, _apply_value(), _bindings(), changed (signal), close(), closed (signal), describe_keys() (+6 more)
|
||||
|
||||
### Community 11 - "Main Scene & Title Menu"
|
||||
Cohesion: 0.12
|
||||
Nodes (15): #29 [intro] Cutscene kit and the loaded-up car, #30 [intro] Hooks: forced lighting, sounds, the chest glow, #31 [intro] Speakers and the three conversations, #32 [intro] The loading screen, #33 [intro] The opening intro, #34 [intro] Timing review with the user, Decisions (the user's, 2026-10-07), Defaults (assumed; flip any of these on request) (+7 more)
|
||||
|
||||
### Community 12 - "Farm Zones & Layout Tests"
|
||||
Cohesion: 0.07
|
||||
Nodes (77): Gather points (4 per material, overnight regrowth), Harvest Season — farm layout, Crop Field zone, Crop units (30 row segments in 6 plots), The farm's edge (random enemy arrivals and carrier escapes), Farm zones (FarmZone rectangles under Zones/), Farmers' return route and staging points, Fence gaps (GapNorth, GapDriveway, GapEast) (+69 more)
|
||||
|
||||
### Community 13 - "Enemy System & Theft Tests"
|
||||
Cohesion: 0.11
|
||||
Nodes (30): EnemyCharacters, acquire(), _animate(), clear(), hit(), _process(), release(), EnemySystem (+22 more)
|
||||
|
||||
### Community 14 - "Co-op Session Host/Client"
|
||||
Cohesion: 0.15
|
||||
Nodes (32): send(), CoopSession, _apply_event(), _apply_foes(), _apply_state(), _client_message(), _close_menu_if_needed(), _do_request() (+24 more)
|
||||
|
||||
### Community 15 - "Rules of the Vacation"
|
||||
Cohesion: 0.05
|
||||
Nodes (64): KayKit Character Animations license (CC0), KayKit: Character Animations 1.1 (Kay Lousberg), Prototype Kit license (CC0, Rgsdev), Prototype Kit (Raphael Gonçalves / Rgsdev), Simulation tick profile at 2,000 birds (steering, motion+collision, flow-field slice, grid), Human playtest exit gates (still open), Scripted soak runs (soak_night.gd), Co-op fall rule (out until morning; Game Over only when both are down) (+56 more)
|
||||
|
||||
### Community 16 - "Game Flow, Save & Pause"
|
||||
Cohesion: 0.15
|
||||
Nodes (29): Autosave and Continue (user://savegame.json), ConfirmBox, close(), _yes(), EndPanel, Main, _ask_new_vacation(), continue_vacation() (+21 more)
|
||||
|
||||
### Community 17 - "Farm Navigation Flow Fields"
|
||||
Cohesion: 0.15
|
||||
Nodes (30): evaluate_attacks(), handle_of(), queue_removal(), barrier_ahead(), cell_of(), _downhill(), flow_direction(), line_clear() (+22 more)
|
||||
|
||||
### Community 18 - "Resource Economy & Upgrades"
|
||||
Cohesion: 0.38
|
||||
Nodes (9): Day/night lighting and lantern, DayNight, add_lantern(), _apply(), _mix(), _process(), setup(), snap() (+1 more)
|
||||
|
||||
### Community 19 - "Animal System"
|
||||
Cohesion: 0.15
|
||||
Nodes (9): GD-Sync data allowance budget (22 MB per vacation, ~12 KB/s), Unreliable message size limit (under 1,100 bytes; GD-Sync splits at 1,200), Dead reckoning for enemies (25 cm error threshold), Packed snapshots (15 Hz, 16-byte enemy records), Partner input record (39 bytes, press counts), Co-op voice chat (gated, 4-bit ADPCM), zstd compression of messages over 256 bytes, RemoteControls (+1 more)
|
||||
|
||||
### Community 20 - "Test Runner & Farm Targets"
|
||||
Cohesion: 0.26
|
||||
Nodes (13): Alerts (labeled edge arrows, priority, grouping), AlertManager, _alert(), _arrow(), cap(), collect(), _draw(), _escalation() (+5 more)
|
||||
|
||||
### Community 21 - "Co-op Docs & GD-Sync Link"
|
||||
Cohesion: 0.21
|
||||
Nodes (20): Menus, pause, and settings (user://settings.cfg), setup(), apply(), MainMenu, continue_requested (signal), coop_requested (signal), new_requested (signal), quit_requested (signal) (+12 more)
|
||||
Cohesion: 0.16
|
||||
Nodes (20): GDSync (GD-Sync plugin autoload), Harvest Season — co-op, GD-Sync API keys (keys.cfg), Harvest Season patches to GD-Sync (4), Host-authoritative simulation with partner replica (FarmSim.replica), LAN join by address, Same-network LAN play (GD-Sync local mode, peer to peer), Online lobbies via GD-Sync servers (+12 more)
|
||||
|
||||
### Community 22 - "Enemy Roster & Construction Plan"
|
||||
Cohesion: 0.14
|
||||
Nodes (30): setup(), StructureSystem, _add_view(), _build_view(), damage(), destroyed (signal), _ground_y(), hurt (signal) (+22 more)
|
||||
Cohesion: 0.26
|
||||
Nodes (14): Farm occupancy grid with one flow field per goal set, Structures are expensive-to-cross cells, not walls, FarmNavigation, build(), cell_center(), free_cells_in(), free_cells_near(), free_cells_on_outline() (+6 more)
|
||||
|
||||
### Community 23 - "Playtest Notes & Scaling"
|
||||
Cohesion: 0.16
|
||||
Nodes (19): _open_settings(), SettingsMenu, _apply_value(), _bindings(), changed (signal), close(), closed (signal), describe_keys() (+11 more)
|
||||
Cohesion: 0.15
|
||||
Nodes (12): Alien overhaul — follow-ups (outside docs/tasks.md scope), Crop fields (#13), Docs sweep after renames/rebalances, Housekeeping, Loose animals (#12), Playtest after #11 (player-built pen), Post-overhaul fix batch (#16–#22, 2026-10-06), Spec items from the review with no task (+4 more)
|
||||
|
||||
### Community 24 - "Farm Sim Setup Wiring"
|
||||
Cohesion: 0.13
|
||||
Nodes (31): Wave count and spacing scaling, Night plans (NightPlan groups: time, count, spacing, type, target), NightPlan, count_scale_in(), problems(), scaled_count(), scaled_every(), spacing_scale_in() (+23 more)
|
||||
Cohesion: 0.05
|
||||
Nodes (75): enemies_line(), materials_line(), of(), _process(), show_assessment(), show_failure(), _totals_text(), NightPlan (+67 more)
|
||||
|
||||
### Community 25 - "Co-op Link Transport"
|
||||
Cohesion: 0.14
|
||||
Nodes (26): CoopLink, close(), get_angle(), get_cm(), get_text(), get_time(), get_v3(), Loopback (+18 more)
|
||||
Nodes (27): CoopLink, close(), get_angle(), get_cm(), get_text(), get_time(), get_v3(), Loopback (+19 more)
|
||||
|
||||
### Community 26 - "Thief Behavior AI"
|
||||
Cohesion: 0.14
|
||||
Nodes (25): Shed stock piles (ShedStock), Supply Shed zone, Supply theft and shed stock rules, FarmSim, arrival_message(), _count_removal(), _finish_field_rebuild(), _ground_takes_crops() (+17 more)
|
||||
Cohesion: 0.33
|
||||
Nodes (9): step(), distance_field(), FieldJob, _init(), _push(), start(), step(), is_walkable() (+1 more)
|
||||
|
||||
### Community 27 - "Soak Night & Benchmarks"
|
||||
Cohesion: 0.30
|
||||
Nodes (14): Labeled stress benchmark presets (25–2,000 birds, compact/enlarged layouts), Scripted scarecrow bot (soak_night, perfect aim), _attack(), _build_tick(), _cycles(), _gather_day(), _gather_tick(), _guard() (+6 more)
|
||||
|
||||
### Community 28 - "Co-op Tests"
|
||||
Cohesion: 0.32
|
||||
Nodes (13): Assessment, GameConfig, enemy(), GameSettings, _assessment(), _autosave(), _bad_saves(), busy_state() (+5 more)
|
||||
Cohesion: 0.29
|
||||
Nodes (6): Decisions (resolved), Harvest Season — alien overhaul: review, decisions, and task plan, Headline finding from the review, Open assumptions (flagged, not yet confirmed), Suggested starting order, Task breakdown (mirrors Task tool `#1`–`#15`)
|
||||
|
||||
### Community 29 - "Player Character Movement"
|
||||
Cohesion: 0.33
|
||||
Nodes (5): Build and install, iOS test port, One-time setup, The test, What the phone build changes
|
||||
|
||||
### Community 30 - "Farm Layout Doc"
|
||||
Cohesion: 0.18
|
||||
Nodes (18): CampaignController, advance_phase(), begin_day(), campaign_ended (signal), check_outcome(), _enter(), is_over(), is_timed() (+10 more)
|
||||
Cohesion: 0.83
|
||||
Nodes (4): One fixed-order simulation tick, Round lifecycle and idempotent restart, Loss-before-victory tie policy, RoundController (prototype)
|
||||
|
||||
### Community 31 - "Co-op Voice Chat"
|
||||
Cohesion: 0.38
|
||||
Nodes (9): CoopVoice, decode(), encode(), _encode_next(), feed(), _gate(), loud_parts(), _process() (+1 more)
|
||||
Cohesion: 0.19
|
||||
Nodes (16): net_receive(), set_microphone(), start_voice(), CoopVoice, decode(), encode(), _encode_next(), feed() (+8 more)
|
||||
|
||||
### Community 32 - "FarmSim Tick & Camera"
|
||||
Cohesion: 0.22
|
||||
Nodes (17): show_state(), Interactions, _blocker(), cancel(), charges(), deposited (signal), _finish_gather(), gathered (signal) (+9 more)
|
||||
|
||||
### Community 33 - "Interactions & Gathering"
|
||||
Cohesion: 0.09
|
||||
Nodes (21): #35 [mobile] Interface scale, safe area, and the mobile test kit, #36 [mobile] Prompts in touch words, #37 [mobile] Platform: back button, no Quit, flat labels, camera, #38 [mobile] Touch action buttons, #39 [mobile] Tappable HUD, #40 [mobile] Build mode by touch (after #36 and #38), #41 [mobile] Menus and settings at phone scale, #42 [mobile] Panels at phone scale (+13 more)
|
||||
Cohesion: 0.67
|
||||
Nodes (3): Sliced flow-field rebuilds with Dial's algorithm, Risk: navigation cost on the farm grid, Flow-field slicing (1,200 cells per tick)
|
||||
|
||||
### Community 34 - "Shed Stock & Supply Targets"
|
||||
Cohesion: 0.37
|
||||
Nodes (16): check(), _crowd(), _enemies_match(), _fall_rule(), _join(), _leaving(), _night(), _partner_moves_and_gathers() (+8 more)
|
||||
|
||||
### Community 35 - "ResourceStore"
|
||||
Cohesion: 0.20
|
||||
Nodes (19): Farm zones (FarmZone rectangles under Zones/), Gather points (GatherNode), Gathering zones (Woodlot, Scrap Heap, Haystacks), Outside gathering areas (North Grove, Old Hangar, East Road, South Fields), Work Area zone (tool table / workbench), Gathering (1.5 s, yield 2 per charge, daytime only), to_dict(), GatherNode (+11 more)
|
||||
Cohesion: 0.31
|
||||
Nodes (15): SKY, _crowd(), _enemies_match(), _fall_rule(), _join(), _leaving(), _night(), _partner_shoots() (+7 more)
|
||||
|
||||
### Community 36 - "Farm Projectiles"
|
||||
Cohesion: 0.17
|
||||
Nodes (9): _release_slot(), sweep_hit(), FarmProjectiles, fire(), hit (signal), _release(), _resolve_segment(), step() (+1 more)
|
||||
|
||||
### Community 37 - "Alert Manager"
|
||||
Cohesion: 0.22
|
||||
Nodes (16): _breaker_goals(), can_afford(), describe(), missing(), blocks(), corners(), _distance_to_outline(), footprint() (+8 more)
|
||||
|
||||
### Community 38 - "Net Budget Tool"
|
||||
Cohesion: 0.27
|
||||
Nodes (13): Loopback._deliver(), _kill_one(), MeterLink, _deliver(), _pump(), _report(), _run(), _setup() (+5 more)
|
||||
|
||||
### Community 39 - "Enemy Roster Tests"
|
||||
Cohesion: 0.20
|
||||
Nodes (14): _ensure_coop(), load_from(), save_to(), _ask_new_vacation(), continue_vacation(), _host_coop(), open(), new_vacation() (+6 more)
|
||||
Cohesion: 0.23
|
||||
Nodes (15): _deliver(), Loopback._deliver(), _deliver(), _kill_one(), MeterLink, _deliver(), _pump(), _report() (+7 more)
|
||||
|
||||
### Community 40 - "Co-op Menu UI"
|
||||
Cohesion: 0.21
|
||||
Nodes (13): ActionEdges, BuildHud, _process(), BuildMode, dismantled (signal), message (signal), refused (signal), set_active() (+5 more)
|
||||
Cohesion: 0.19
|
||||
Nodes (16): Menus, pause, and settings (user://settings.cfg), GameSettings, apply(), load_from(), save_to(), _on_settings_changed(), pause(), _unhandled_input() (+8 more)
|
||||
|
||||
### Community 41 - "Harvest Season — co-op"
|
||||
Cohesion: 0.17
|
||||
Nodes (15): Automated defense (buildable), Crow (enemy), Fence (buildable), Farm occupancy grid with one flow field per goal set, Flying rule (fences, gates, traps ignore flyers), Gameplay is 2-D on the XZ plane, Gate (buildable), Pen gate breach (gate as start structure) (+7 more)
|
||||
|
||||
### Community 42 - "Snapshot Decoding"
|
||||
Cohesion: 0.15
|
||||
Nodes (12): Alien overhaul — follow-ups (outside docs/tasks.md scope), Crop fields (#13), Docs sweep after renames/rebalances, Housekeeping, Loose animals (#12), Playtest after #11 (player-built pen), Post-overhaul fix batch (#16–#22, 2026-10-06), Spec items from the review with no task (+4 more)
|
||||
Cohesion: 0.22
|
||||
Nodes (9): Alert priorities, grouping, and cap, Crows on MultiMesh, ground enemies from a KayKit pool, Enemy type table (GameConfig.enemy_types), Ground thief (enemy), Step 9: The first enemy roster, Step 9: Build the first enemy roster, Debug keys and enemy-introduction scenarios, KayKit characters (Rig_Medium / Rig_Large clips) (+1 more)
|
||||
|
||||
### Community 43 - "Enemy Characters & Hits"
|
||||
Cohesion: 0.25
|
||||
Nodes (8): M3 First loop (first major milestone), Step 7: Connect one complete day and night (milestone M3), Step 8: All three farm targets, Supply bundles (sacks from the most-stocked material), Step 7: Connect one complete day and night, Step 8: Expand to all three farm targets, Three farm targets: crops, animals, supplies, Day/night lighting and scarecrow lantern
|
||||
|
||||
### Community 44 - "PumpkinBombs"
|
||||
Cohesion: 0.38
|
||||
Nodes (11): CoopMenu, back_requested (signal), host_requested (signal), join_address_requested (signal), join_requested (signal), open(), _ready(), search_requested (signal) (+3 more)
|
||||
|
||||
### Community 45 - "WeaponModels"
|
||||
Cohesion: 0.42
|
||||
Nodes (10): _combat_input(), _consistent(), _escape(), _night_arrivals(), _retry(), run(), _shots(), _stale_handles() (+2 more)
|
||||
|
||||
### Community 46 - "test_weapons.gd"
|
||||
Cohesion: 0.24
|
||||
Nodes (10): _deliver(), net_receive(), set_microphone(), start_voice(), make(), mute_microphone(), GDSyncLink, _deliver() (+2 more)
|
||||
Cohesion: 0.33
|
||||
Nodes (6): Step 10: The five-night progression, Planned 30-night campaign, Wave count and spacing scaling, Step 10: Build the five-night progression, Night plans (NightPlan night_1..5), Workbench upgrades (eleven, bought once)
|
||||
|
||||
### Community 47 - "Prop Collision Builder"
|
||||
Cohesion: 0.38
|
||||
Nodes (9): GameTestRunner, _initialize(), _main(), run_phase(), _failure_in_every_phase(), _final_dawn_tie(), run(), _terminal() (+1 more)
|
||||
Cohesion: 0.31
|
||||
Nodes (10): _band_points(), _build(), _faces(), _fit(), _initialize(), _kind(), _process_prefab(), _restore_uids() (+2 more)
|
||||
|
||||
### Community 48 - "Horde Performance Report"
|
||||
Cohesion: 0.18
|
||||
Nodes (12): Performance report (prototype horde benchmarks), First shot / first hit stutter check (no first-use stutter), Largest tested passing population: 2,000 birds, 10-minute headless 1,000-bird recycle soak (flat memory), Start-up hitches (10–36 ms frames in the first second), VSync-on ~1 s stalls (compositor throttling of hidden windows), Headless tooling constraints (editor closed, restore UIDs), Performance measurement goals (p95 <= 16.67 ms) (+4 more)
|
||||
|
||||
### Community 49 - "KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)"
|
||||
Cohesion: 0.49
|
||||
Nodes (9): lose_crops(), make_campaign(), run_until(), _early_night(), _five_nights(), _night_log(), _order_and_timers(), _retry() (+1 more)
|
||||
Cohesion: 0.25
|
||||
Nodes (8): Performance report (prototype horde benchmarks), First shot / first hit stutter check (no first-use stutter), Largest tested passing population: 2,000 birds, 10-minute headless 1,000-bird recycle soak (flat memory), Start-up hitches (10–36 ms frames in the first second), VSync-on ~1 s stalls (compositor throttling of hidden windows), Headless tooling constraints (editor closed, restore UIDs), Editor-binary measurements, not a release build
|
||||
|
||||
### Community 50 - "GameConfig"
|
||||
Cohesion: 0.42
|
||||
Nodes (9): AlertManager, _alert(), _arrow(), cap(), collect(), _draw(), group_alerts(), label_for() (+1 more)
|
||||
|
||||
### Community 51 - "Upgrades"
|
||||
Cohesion: 0.21
|
||||
Nodes (18): start_channel(), trap_slow_time(), UpgradePanel, bought (signal), _buy(), message (signal), open(), refresh() (+10 more)
|
||||
|
||||
### Community 52 - "Harvest Season — alien overhaul: review, decisions, and task plan"
|
||||
Cohesion: 0.29
|
||||
Nodes (6): Decisions (resolved), Harvest Season — alien overhaul: review, decisions, and task plan, Headline finding from the review, Open assumptions (flagged, not yet confirmed), Suggested starting order, Task breakdown (mirrors Task tool `#1`–`#15`)
|
||||
|
||||
### Community 53 - "Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)"
|
||||
Cohesion: 0.44
|
||||
Nodes (9): Tutorial, _check_done(), _enemies_near(), _finish(), _on_phase(), _process(), setup(), _show() (+1 more)
|
||||
Cohesion: 0.38
|
||||
Nodes (11): CoopMenu, back_requested (signal), host_requested (signal), join_address_requested (signal), join_requested (signal), open(), _ready(), search_requested (signal) (+3 more)
|
||||
|
||||
### Community 54 - "GD-Sync Sync Icons"
|
||||
Cohesion: 0.50
|
||||
|
|
@ -390,8 +336,12 @@ Cohesion: 0.40
|
|||
Nodes (5): Leaf_Pine_C solid dark-green pine foliage silhouette, Leaf_Pine white alpha silhouette of a pine foliage cluster, Leaves_GiantPine_C solid green rounded foliage blob shapes, Leaves sprite sheet with colorful painted leaf shapes, ferns, clovers, Leaves_NormalTree white alpha silhouettes of normal tree leaf clusters
|
||||
|
||||
### Community 56 - "Campaign Experience (Step 11)"
|
||||
Cohesion: 0.22
|
||||
Nodes (9): D9: Retry from the failed night's morning, One authoritative FarmState, Step 11: The complete campaign experience, Step 11: Add the complete campaign experience, Farm audio cues and buses (FarmAudio), Kenney CC0 audio packs, Morning autosave and save migration (SaveGame), Morning review and nightly results (+1 more)
|
||||
Cohesion: 0.29
|
||||
Nodes (7): D9: Retry from the failed night's morning, One authoritative FarmState, Step 11: The complete campaign experience, Step 11: Add the complete campaign experience, Morning autosave and save migration (SaveGame), Morning review and nightly results, Contextual first-day tips (Tutorial)
|
||||
|
||||
### Community 59 - "Grid Design & Scope Limits"
|
||||
Cohesion: 0.30
|
||||
Nodes (15): GameTestRunner, _initialize(), _main(), _supplies(), _combat_input(), _consistent(), _escape(), _night_arrivals() (+7 more)
|
||||
|
||||
### Community 60 - "GD-Sync Physics/Voice Icons"
|
||||
Cohesion: 0.67
|
||||
|
|
@ -413,26 +363,42 @@ Nodes (3): Leaves_NormalTree_C (green leaf-cluster alpha card texture, CommonTre
|
|||
Cohesion: 0.67
|
||||
Nodes (3): PathRocks_Diffuse (mossy grey stepping-stone UV atlas diffuse, Pebble_* / RockPath_* models), Rocks_Desert_Diffuse (sandstone/ochre recolor of rock UV atlas, 2048px, unreferenced by any gltf), Rocks_Diffuse (mossy grey-green rock UV atlas diffuse, 2048px, Rock_Medium_1-3)
|
||||
|
||||
### Community 80 - "Alien overhaul — task list"
|
||||
Cohesion: 0.13
|
||||
Nodes (14): Alien overhaul — task list, Dependent, Independent, Opening intro — task list (2026-10-07), Post-overhaul fix batch (2026-10-06), Thirty nights — task list (2026-10-06), Wave 1, Wave 1 (+6 more)
|
||||
|
||||
### Community 81 - "test_theft.gd"
|
||||
Cohesion: 0.53
|
||||
Nodes (5): UiTheme, build(), check_icon(), _initialize(), Settings (settings.cfg) and UI theme
|
||||
|
||||
### Community 85 - "stop"
|
||||
Cohesion: 0.26
|
||||
Nodes (13): join(), leave(), status_changed (signal), _leave_as_partner(), _on_other_left(), _on_session_ended(), _on_welcomed(), quit_game() (+5 more)
|
||||
|
||||
### Community 86 - "MainMenu"
|
||||
Cohesion: 0.52
|
||||
Nodes (7): MainMenu, continue_requested (signal), coop_requested (signal), new_requested (signal), quit_requested (signal), _ready(), settings_requested (signal)
|
||||
|
||||
## Ambiguous Edges - Review These
|
||||
- `KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)` → `Final assessment (weighted share kept, 0–100 points, ratings)` [AMBIGUOUS]
|
||||
game/RULES.md · relation: conceptually_related_to
|
||||
|
||||
## Knowledge Gaps
|
||||
- **123 isolated node(s):** `Headline finding from the review`, `Decisions (resolved)`, `Open assumptions (flagged, not yet confirmed)`, `Task breakdown (mirrors Task tool `#1`–`#15`)`, `Suggested starting order` (+118 more)
|
||||
- **112 isolated node(s):** `Headline finding from the review`, `Decisions (resolved)`, `Open assumptions (flagged, not yet confirmed)`, `Task breakdown (mirrors Task tool `#1`–`#15`)`, `Suggested starting order` (+107 more)
|
||||
These have ≤1 connection - possible missing edges or undocumented components.
|
||||
- **15 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
|
||||
- **16 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
|
||||
|
||||
## Suggested Questions
|
||||
_Questions this graph is uniquely positioned to answer:_
|
||||
|
||||
- **What is the exact relationship between `KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)` and `Final assessment (weighted share kept, 0–100 points, ratings)`?**
|
||||
_Edge tagged AMBIGUOUS (relation: conceptually_related_to) - confidence is low._
|
||||
- **Why does `FarmSim` connect `Thief Behavior AI` to `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `Horde Prototype (README)`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Farm Navigation Flow Fields`, `Animal System`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Co-op Tests`, `Farm Layout Doc`, `FarmSim Tick & Camera`, `Shed Stock & Supply Targets`, `ResourceStore`, `Farm Projectiles`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `WeaponModels`, `GameConfig`, `Upgrades`, `Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)`?**
|
||||
_High betweenness centrality (0.113) - this node is a cross-community bridge._
|
||||
- **Why does `CoopSession` connect `Co-op Session Host/Client` to `Campaign Controller & Farm State`, `Shed Stock & Supply Targets`, `ResourceStore`, `Scarecrow Weapons & Bombs`, `Net Budget Tool`, `Enemy Roster Tests`, `Co-op Lobby & Smoke Test`, `Enemy System & Theft Tests`, `test_weapons.gd`, `Game Flow, Save & Pause`, `Animal System`, `Upgrades`, `Enemy Roster & Construction Plan`, `Co-op Link Transport`, `Thief Behavior AI`, `Farm Layout Doc`, `Co-op Voice Chat`?**
|
||||
- **Why does `CoopSession` connect `Co-op Session Host/Client` to `Campaign Controller & Farm State`, `Structures & Build Mode`, `Shed Stock & Supply Targets`, `Scarecrow Weapons & Bombs`, `Net Budget Tool`, `Co-op Lobby & Smoke Test`, `Scarecrow Defender & Fear`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Game Flow, Save & Pause`, `Animal System`, `Co-op Docs & GD-Sync Link`, `Farm Sim Setup Wiring`, `Co-op Link Transport`, `Co-op Voice Chat`?**
|
||||
_High betweenness centrality (0.119) - this node is a cross-community bridge._
|
||||
- **Why does `CampaignController` connect `Campaign Controller & Farm State` to `Structures & Build Mode`, `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `First Game Plan & Milestones`, `Horde Prototype (README)`, `Co-op Lobby & Smoke Test`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Resource Economy & Upgrades`, `Test Runner & Farm Targets`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Farm Layout Doc`, `Shed Stock & Supply Targets`, `Net Budget Tool`, `Co-op Menu UI`, `Grid Design & Scope Limits`?**
|
||||
_High betweenness centrality (0.115) - this node is a cross-community bridge._
|
||||
- **Why does `FarmSim` connect `Scarecrow Defender & Fear` to `Campaign Controller & Farm State`, `Structures & Build Mode`, `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `Horde Prototype (README)`, `Loot & Theft Events`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Farm Navigation Flow Fields`, `Resource Economy & Upgrades`, `Animal System`, `Test Runner & Farm Targets`, `Co-op Docs & GD-Sync Link`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Farm Layout Doc`, `Shed Stock & Supply Targets`, `Farm Projectiles`, `Net Budget Tool`, `Grid Design & Scope Limits`?**
|
||||
_High betweenness centrality (0.106) - this node is a cross-community bridge._
|
||||
- **Why does `CampaignController` connect `Farm Layout Doc` to `Campaign Controller & Farm State`, `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `First Game Plan & Milestones`, `Horde Prototype (README)`, `Co-op Lobby & Smoke Test`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Co-op Docs & GD-Sync Link`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Thief Behavior AI`, `Soak Night & Benchmarks`, `Co-op Tests`, `FarmSim Tick & Camera`, `Shed Stock & Supply Targets`, `ResourceStore`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `WeaponModels`, `Prop Collision Builder`, `KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)`, `GameConfig`, `Upgrades`, `Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)`?**
|
||||
_High betweenness centrality (0.102) - this node is a cross-community bridge._
|
||||
- **Are the 12 inferred relationships involving `CampaignController` (e.g. with `Outcome evaluator check_outcome` and `_night_log()`) actually correct?**
|
||||
_`CampaignController` has 12 INFERRED edges - model-reasoned connections that need verification._
|
||||
- **Are the 13 inferred relationships involving `EnemySystem` (e.g. with `AlertManager` and `_describe()`) actually correct?**
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,16 +1,16 @@
|
|||
# Graph Report - harvest-season (2026-10-14)
|
||||
|
||||
## Corpus Check
|
||||
- 40 files · ~1,676,209 words
|
||||
- 40 files · ~1,674,190 words
|
||||
- Verdict: corpus is large enough that graph structure adds value.
|
||||
|
||||
## Summary
|
||||
- 1386 nodes · 4099 edges · 79 communities (64 shown, 15 thin omitted)
|
||||
- 1374 nodes · 4087 edges · 82 communities (67 shown, 15 thin omitted)
|
||||
- Extraction: 87% EXTRACTED · 13% INFERRED · 0% AMBIGUOUS · INFERRED: 542 edges (avg confidence: 0.91)
|
||||
- Token cost: 0 input · 0 output
|
||||
|
||||
## Graph Freshness
|
||||
- Built from commit: `5d14fed3`
|
||||
- Built from commit: `59aa97c7`
|
||||
- Run `git rev-parse HEAD` and compare to check if the graph is stale.
|
||||
- Run `graphify update .` after code changes (no API cost).
|
||||
|
||||
|
|
@ -61,6 +61,7 @@
|
|||
- Enemy Characters & Hits
|
||||
- PumpkinBombs
|
||||
- WeaponModels
|
||||
- test_weapons.gd
|
||||
- Prop Collision Builder
|
||||
- Horde Performance Report
|
||||
- KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)
|
||||
|
|
@ -71,6 +72,8 @@
|
|||
- GD-Sync Sync Icons
|
||||
- Pine & Foliage Textures
|
||||
- Campaign Experience (Step 11)
|
||||
- equip
|
||||
- render_overview.gd
|
||||
- Grid Design & Scope Limits
|
||||
- GD-Sync Physics/Voice Icons
|
||||
- AGENTS.md graphify Rules
|
||||
|
|
@ -107,12 +110,12 @@
|
|||
## Surprising Connections (you probably didn't know these)
|
||||
- `Scripted soak runs (soak_night.gd)` --semantically_similar_to--> `Stress presets (25/50 to 1,000/2,000 birds)` [INFERRED] [semantically similar]
|
||||
first-game-plan.md → plan.md
|
||||
- `PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb)` --references--> `PumpkinBombs` [INFERRED]
|
||||
assets/weapons/PumpkinBomb_texture.png → game/scripts/pumpkin_bombs.gd
|
||||
- `Ground-bound birds (no flying navigation)` --semantically_similar_to--> `Gameplay is 2-D on the XZ plane` [INFERRED] [semantically similar]
|
||||
plan.md → first-game-plan.md
|
||||
- `Prototype scope boundaries` --semantically_similar_to--> `Deferred from version 1 (farming sim, multiplayer, tech trees)` [INFERRED] [semantically similar]
|
||||
plan.md → first-game.md
|
||||
- `PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb)` --references--> `PumpkinBombs` [INFERRED]
|
||||
assets/weapons/PumpkinBomb_texture.png → game/scripts/pumpkin_bombs.gd
|
||||
- `PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb)` --references--> `WeaponModels` [INFERRED]
|
||||
assets/weapons/PumpkinBomb_texture.png → game/scripts/weapon_models.gd
|
||||
|
||||
|
|
@ -120,11 +123,11 @@
|
|||
- 3-file cycle: `game/scripts/enemy_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 4-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/enemy_system.gd`
|
||||
- 4-file cycle: `game/scripts/enemy_system.gd -> game/scripts/loot_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_characters.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd -> game/scripts/enemy_characters.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/pumpkin_bombs.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_characters.gd -> game/scripts/loot_system.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd -> game/scripts/enemy_characters.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_characters.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd -> game/scripts/enemy_characters.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/pumpkin_bombs.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/remote_controls.gd -> game/scripts/scarecrow_combat.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
- 5-file cycle: `game/scripts/enemy_system.gd -> game/scripts/scarecrow.gd -> game/scripts/thief_behavior.gd -> game/scripts/structure_system.gd -> game/scripts/farm_projectiles.gd -> game/scripts/enemy_system.gd`
|
||||
|
||||
## Hyperedges (group relationships)
|
||||
- **Prototype classes forked or generalized into game/ systems** — readme_hordesystem, game_scripts_enemy_system, readme_chasebehavior, game_scripts_thief_behavior, readme_arenanavigation, game_scripts_farm_navigation, readme_roundcontroller, game_scripts_campaign_controller, readme_prototypeconfig, game_scripts_game_config [EXTRACTED 1.00]
|
||||
|
|
@ -162,219 +165,223 @@
|
|||
- **Retry restores the failed night's morning snapshot (verified across suites)** — game_tests_test_campaign_retry, game_tests_test_economy_deposit_and_night, game_tests_test_coop_fall_rule, game_tests_test_flow_failure, game_tests_test_nights_upgrades [INFERRED 0.85]
|
||||
- **Suites that instantiate farm.tscn and step FarmSim by hand at 60 Hz** — game_tests_test_coop, game_tests_test_economy, game_tests_test_farm_layout, game_tests_test_nights, game_tests_test_roster [EXTRACTED 1.00]
|
||||
|
||||
## Communities (79 total, 15 thin omitted)
|
||||
## Communities (82 total, 15 thin omitted)
|
||||
|
||||
### Community 0 - "Campaign Controller & Farm State"
|
||||
Cohesion: 0.13
|
||||
Nodes (19): Dawn retreat and grace (D4), Dusk warning (banner, hint, phase HUD list), Phase cycle (Morning → Day → Dusk → Night → Dawn), FarmState, asset_counts(), create(), from_dict(), is_valid() (+11 more)
|
||||
Cohesion: 0.06
|
||||
Nodes (78): D2: Early campaign end (scarecrow death or farm stripped), Outcome evaluator check_outcome, CampaignController, advance_phase(), begin_day(), campaign_ended (signal), can_start_night_early(), check_outcome() (+70 more)
|
||||
|
||||
### Community 1 - "Structures & Build Mode"
|
||||
Cohesion: 0.22
|
||||
Nodes (14): _process(), pay(), structure(), show_state(), _process(), pay(), built (signal), dismantle() (+6 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (21): _process(), pay(), structure(), pay(), _add_view(), _build_view(), built (signal), damage() (+13 more)
|
||||
|
||||
### Community 2 - "Audio & Farmers Return Ending"
|
||||
Cohesion: 0.05
|
||||
Nodes (70): Day/night lighting and lantern, Night record (FarmState.night_log) and morning review, enemies_line(), materials_line(), of(), new_campaign(), phase_changed (signal), DayNight (+62 more)
|
||||
Cohesion: 0.10
|
||||
Nodes (39): FarmAudio, _free_voice(), _on_loot(), _on_phase(), _on_removed(), _physics_process(), play(), play_remote() (+31 more)
|
||||
|
||||
### Community 3 - "Scarecrow Weapons & Bombs"
|
||||
Cohesion: 0.07
|
||||
Nodes (60): Prototype Kit texture (8x8 RGB color palette swatch atlas for flat-shaded prototype pieces), PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb), note(), PumpkinBombs, _burst(), burst (signal), _flash(), _new_mesh() (+52 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (27): note(), ScarecrowCombat, _aim_at(), attack(), attack_toward(), attacked (signal), _clear_line(), fired (signal) (+19 more)
|
||||
|
||||
### Community 4 - "Waves, Night Plans & Review"
|
||||
Cohesion: 0.12
|
||||
Nodes (26): Harvest Season — audio credits, Kenney Digital Audio pack, Kenney Impact Sounds pack, Kenney Interface Sounds pack, Kenney Music Jingles pack (pizzicato set), Kenney RPG Audio pack, Kenney UI Audio (UI SFX Set) pack, Synthesized game sounds (synth/) (+18 more)
|
||||
|
||||
### Community 5 - "First Game Plan & Milestones"
|
||||
Cohesion: 0.09
|
||||
Nodes (37): Harvest Season — first game development plan, Alert priorities, grouping, and cap, D10: Ground enemies before Step 9, D2: Early campaign end (scarecrow death or farm stripped), D3: Phase lengths, D4: Sunrise retreat and dawn grace, D5: Killing or fearing a carrier drops its loot, D6: Recovery rules (touch to recover; animals follow, max 3) (+29 more)
|
||||
Cohesion: 0.10
|
||||
Nodes (31): Harvest Season — first game development plan, D10: Ground enemies before Step 9, D4: Sunrise retreat and dawn grace, D5: Killing or fearing a carrier drops its loot, D6: Recovery rules (touch to recover; animals follow, max 3), D7: Scarecrow HP carries over between nights, D8: What's allowed at night, D9: Retry from the failed night's morning (+23 more)
|
||||
|
||||
### Community 6 - "Horde Prototype (README)"
|
||||
Cohesion: 0.12
|
||||
Nodes (36): Crows on MultiMesh, ground enemies from a KayKit pool, One fixed-order simulation tick, Game code in game/, prototype/ frozen (fork rule), One GameConfig resource, Horde survival prototype — coding-agent implementation plan, Centralized simulation with reusable storage, Prototype implementation milestones and gates, Pool reuse rules (no hot-path allocation) (+28 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (30): Crows on MultiMesh, ground enemies from a KayKit pool, Game code in game/, prototype/ frozen (fork rule), One GameConfig resource, Horde survival prototype — coding-agent implementation plan, Centralized simulation with reusable storage, Prototype implementation milestones and gates, Pool reuse rules (no hot-path allocation), Harvest Season — horde survival prototype (+22 more)
|
||||
|
||||
### Community 7 - "Co-op Lobby & Smoke Test"
|
||||
Cohesion: 0.14
|
||||
Nodes (35): GDSync (GD-Sync plugin autoload), CoopLobby, _begin(), failed (signal), has_online_keys(), host(), host_addresses(), join() (+27 more)
|
||||
Cohesion: 0.15
|
||||
Nodes (34): CoopLobby, _begin(), failed (signal), has_online_keys(), host(), host_addresses(), join(), join_address() (+26 more)
|
||||
|
||||
### Community 8 - "Scarecrow Defender & Fear"
|
||||
Cohesion: 0.07
|
||||
Nodes (52): The scarecrow (player defender), pressed(), add_partner(), set_local(), FollowCamera, _apply(), _process(), snap_to_target() (+44 more)
|
||||
Cohesion: 0.08
|
||||
Nodes (44): pressed(), add_partner(), setup(), PlayerCharacter, can_sprint(), die(), _follow_net(), _move_direction() (+36 more)
|
||||
|
||||
### Community 9 - "Loot & Theft Events"
|
||||
Cohesion: 0.13
|
||||
Nodes (29): position(), start_following(), record_event(), LootSystem, animal_home(), animal_strays(), claim(), _claim_home() (+21 more)
|
||||
Cohesion: 0.05
|
||||
Nodes (89): Pen gate breach (gate as start structure), Supply bundles (sacks from the most-stocked material), Step 8: Expand to all three farm targets, Three farm targets: crops, animals, supplies, AnimalSystem, _apply_visuals(), _follow(), _move() (+81 more)
|
||||
|
||||
### Community 10 - "Settings, Input & UI Theme"
|
||||
Cohesion: 0.19
|
||||
Nodes (17): can_start_night_early(), start_night_early(), CampaignDebug, cycle_scenario(), _describe(), _unhandled_input(), PhaseHud, join_words() (+9 more)
|
||||
Cohesion: 0.16
|
||||
Nodes (21): PhaseHud, _on_phase_changed(), on_the_farm(), _process(), setup(), ReviewPanel, backing(), category_counts() (+13 more)
|
||||
|
||||
### Community 11 - "Main Scene & Title Menu"
|
||||
Cohesion: 0.11
|
||||
Nodes (35): AnimalSystem, _apply_visuals(), find_animals(), _follow(), _move(), pen_changed (signal), place(), _record_trail() (+27 more)
|
||||
Nodes (23): find_animals(), pen_changed (signal), setup(), update_pen_open(), setup(), arrival_message(), _count_removal(), _ground_takes_crops() (+15 more)
|
||||
|
||||
### Community 12 - "Farm Zones & Layout Tests"
|
||||
Cohesion: 0.09
|
||||
Nodes (43): Harvest Season — farm layout, The farm's edge (random enemy arrivals and carrier escapes), Farmers' return route and staging points, Fence gaps (GapNorth, GapDriveway, GapEast), Playable area (60 × 60 m, FarmZones.playable), Scarecrow bounds (PlayerBounds, physics layer 3, FarmZones.roam), CropUnit, FarmMarker (+35 more)
|
||||
Cohesion: 0.25
|
||||
Nodes (19): CropUnit, FarmMarker, FarmZone, FarmZones, edge(), edge_point(), is_inside_fence(), info() (+11 more)
|
||||
|
||||
### Community 13 - "Enemy System & Theft Tests"
|
||||
Cohesion: 0.09
|
||||
Nodes (38): Fence breaker (enemy), Ground thief (enemy), Thief (enemy type), EnemyCharacters, acquire(), _animate(), clear(), hit() (+30 more)
|
||||
Cohesion: 0.13
|
||||
Nodes (19): clear(), release(), EnemySystem, apply_hit_handle(), clear(), commit_removals(), enemy_removed (signal), _load_types() (+11 more)
|
||||
|
||||
### Community 14 - "Co-op Session Host/Client"
|
||||
Cohesion: 0.13
|
||||
Nodes (34): received (signal), send(), CoopSession, _apply_event(), _apply_foes(), _apply_state(), _client_message(), _close_menu_if_needed() (+26 more)
|
||||
Cohesion: 0.12
|
||||
Nodes (40): get_angle(), poll(), put_angle(), reader(), send(), CoopSession, _apply_avatar(), _apply_event() (+32 more)
|
||||
|
||||
### Community 15 - "Rules of the Vacation"
|
||||
Cohesion: 0.05
|
||||
Nodes (64): "On the Farm" (music track), "Purgatory" (DavidKBD, Purgatory Pack music track), KayKit Character Animations license (CC0), KayKit: Character Animations 1.1 (Kay Lousberg), Prototype Kit license (CC0, Rgsdev), Prototype Kit (Raphael Gonçalves / Rgsdev), MultiMesh batching for birds and bullets, Simulation tick profile at 2,000 birds (steering, motion+collision, flow-field slice, grid) (+56 more)
|
||||
Cohesion: 0.13
|
||||
Nodes (24): Co-op fall rule (out until morning; Game Over only when both are down), Animal Pen zone, Finding: automated defense may be too strong for 6 scrap, Finding: a broken pen gate is the costliest event, Finding: the fence breaker can end a run by itself, Hallway test (the exit gate), Harvest Season — rules of the vacation, Animals and the pen (open pen, loose animals, leading home) (+16 more)
|
||||
|
||||
### Community 16 - "Game Flow, Save & Pause"
|
||||
Cohesion: 0.17
|
||||
Nodes (26): Autosave and Continue (user://savegame.json), ConfirmBox, close(), _yes(), Main, _leave_as_partner(), _on_session_ended(), pause() (+18 more)
|
||||
Cohesion: 0.06
|
||||
Nodes (91): Menus, pause, and settings (user://settings.cfg), Autosave and Continue (user://savegame.json), ConfirmBox, close(), _yes(), CoopMenu, back_requested (signal), host_requested (signal) (+83 more)
|
||||
|
||||
### Community 17 - "Farm Navigation Flow Fields"
|
||||
Cohesion: 0.09
|
||||
Nodes (46): _escalation(), handle_of(), queue_removal(), step(), FarmNavigation, barrier_ahead(), build(), cell_center() (+38 more)
|
||||
Cohesion: 0.07
|
||||
Nodes (64): Alerts (labeled edge arrows, priority, grouping), AlertManager, _alert(), _arrow(), cap(), collect(), _draw(), _escalation() (+56 more)
|
||||
|
||||
### Community 18 - "Resource Economy & Upgrades"
|
||||
Cohesion: 0.10
|
||||
Nodes (20): Alien overhaul — task list, Dependent, Independent, Independent, Last, Opening intro — task list (2026-10-07), Playable on phones — task list, Post-overhaul fix batch (2026-10-06) (+12 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (19): Day/night lighting and lantern, DayNight, add_lantern(), _apply(), _mix(), _process(), setup(), snap() (+11 more)
|
||||
|
||||
### Community 19 - "Animal System"
|
||||
Cohesion: 0.09
|
||||
Nodes (27): Harvest Season — co-op, GD-Sync API keys (keys.cfg), GD-Sync data allowance budget (22 MB per vacation, ~12 KB/s), Unreliable message size limit (under 1,100 bytes; GD-Sync splits at 1,200), Dead reckoning for enemies (25 cm error threshold), Harvest Season patches to GD-Sync (4), Host-authoritative simulation with partner replica (FarmSim.replica), LAN join by address (+19 more)
|
||||
Cohesion: 0.12
|
||||
Nodes (16): Harvest Season — co-op, GD-Sync API keys (keys.cfg), GD-Sync data allowance budget (22 MB per vacation, ~12 KB/s), Unreliable message size limit (under 1,100 bytes; GD-Sync splits at 1,200), Dead reckoning for enemies (25 cm error threshold), Harvest Season patches to GD-Sync (4), LAN join by address, Same-network LAN play (GD-Sync local mode, peer to peer) (+8 more)
|
||||
|
||||
### Community 20 - "Test Runner & Farm Targets"
|
||||
Cohesion: 0.10
|
||||
Nodes (19): 1. With losses permanent, the density decides when the farm is empty, 2. Match the breakers to their pool, 3. Straw and Alien Goop pile up; wood runs out, Appendix: every night, per seed, Arrivals, the peak on the farm, and the tick, Character pools, Method, Not measured (+11 more)
|
||||
|
||||
### Community 21 - "Co-op Docs & GD-Sync Link"
|
||||
Cohesion: 0.21
|
||||
Nodes (20): Menus, pause, and settings (user://settings.cfg), setup(), apply(), MainMenu, continue_requested (signal), coop_requested (signal), new_requested (signal), quit_requested (signal) (+12 more)
|
||||
Cohesion: 0.32
|
||||
Nodes (8): Partner panel, name tags, and edge arrow, CoopHud, _draw(), _measure_ping(), _process(), setup(), partner_speaking(), speaking()
|
||||
|
||||
### Community 22 - "Enemy Roster & Construction Plan"
|
||||
Cohesion: 0.14
|
||||
Nodes (30): setup(), StructureSystem, _add_view(), _build_view(), damage(), destroyed (signal), _ground_y(), hurt (signal) (+22 more)
|
||||
Cohesion: 0.25
|
||||
Nodes (18): StructureSystem, step(), trap_sprung (signal), try_trap(), turret_fired (signal), turret_range(), _ab_night(), _breakout() (+10 more)
|
||||
|
||||
### Community 23 - "Playtest Notes & Scaling"
|
||||
Cohesion: 0.16
|
||||
Nodes (19): _open_settings(), SettingsMenu, _apply_value(), _bindings(), changed (signal), close(), closed (signal), describe_keys() (+11 more)
|
||||
Cohesion: 0.15
|
||||
Nodes (18): "On the Farm" (music track), "Purgatory" (DavidKBD, Purgatory Pack music track), Harvest Season — playtest notes, Finding: the day may be long once everything is gathered (106 of 180 s), User feedback: "extraordinarily easy" → 30-day scale pass, 5x enemies scale pass (up to 160 enemies; FarmSim.step 0.45 ms avg), Finding: materials pile up (straw has almost no use), Night 2 is the cliff (112 enemies, ~10x night 1) (+10 more)
|
||||
|
||||
### Community 24 - "Farm Sim Setup Wiring"
|
||||
Cohesion: 0.13
|
||||
Nodes (31): Wave count and spacing scaling, Night plans (NightPlan groups: time, count, spacing, type, target), NightPlan, count_scale_in(), problems(), scaled_count(), scaled_every(), spacing_scale_in() (+23 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (29): NightPlan, count_scale_in(), problems(), scaled_count(), scaled_every(), spacing_scale_in(), total(), type_counts() (+21 more)
|
||||
|
||||
### Community 25 - "Co-op Link Transport"
|
||||
Cohesion: 0.14
|
||||
Nodes (26): CoopLink, close(), get_angle(), get_cm(), get_text(), get_time(), get_v3(), Loopback (+18 more)
|
||||
Cohesion: 0.15
|
||||
Nodes (22): CoopLink, close(), _deliver(), get_cm(), get_text(), get_time(), get_v3(), Loopback (+14 more)
|
||||
|
||||
### Community 26 - "Thief Behavior AI"
|
||||
Cohesion: 0.14
|
||||
Nodes (25): Shed stock piles (ShedStock), Supply Shed zone, Supply theft and shed stock rules, FarmSim, arrival_message(), _count_removal(), _finish_field_rebuild(), _ground_takes_crops() (+17 more)
|
||||
Cohesion: 0.16
|
||||
Nodes (18): Harvest Season — farm layout, Crop Field zone, Crop units (30 row segments in 6 plots), Farm zones (FarmZone rectangles under Zones/), Farmers' return route and staging points, Fence gaps (GapNorth, GapDriveway, GapEast), Gather points (GatherNode), Gathering zones (Woodlot, Scrap Heap, Haystacks) (+10 more)
|
||||
|
||||
### Community 27 - "Soak Night & Benchmarks"
|
||||
Cohesion: 0.30
|
||||
Nodes (14): Labeled stress benchmark presets (25–2,000 birds, compact/enlarged layouts), Scripted scarecrow bot (soak_night, perfect aim), _attack(), _build_tick(), _cycles(), _gather_day(), _gather_tick(), _guard() (+6 more)
|
||||
|
||||
### Community 28 - "Co-op Tests"
|
||||
Cohesion: 0.32
|
||||
Nodes (13): Assessment, GameConfig, enemy(), GameSettings, _assessment(), _autosave(), _bad_saves(), busy_state() (+5 more)
|
||||
Cohesion: 0.21
|
||||
Nodes (16): Assessment, enemies_line(), materials_line(), of(), EndPanel, hide_panel(), menu_requested (signal), _on_ended() (+8 more)
|
||||
|
||||
### Community 29 - "Player Character Movement"
|
||||
Cohesion: 0.33
|
||||
Nodes (5): Build and install, iOS test port, One-time setup, The test, What the phone build changes
|
||||
|
||||
### Community 30 - "Farm Layout Doc"
|
||||
Cohesion: 0.18
|
||||
Nodes (18): CampaignController, advance_phase(), begin_day(), campaign_ended (signal), check_outcome(), _enter(), is_over(), is_timed() (+10 more)
|
||||
Cohesion: 0.83
|
||||
Nodes (4): One fixed-order simulation tick, Round lifecycle and idempotent restart, Loss-before-victory tie policy, RoundController (prototype)
|
||||
|
||||
### Community 31 - "Co-op Voice Chat"
|
||||
Cohesion: 0.18
|
||||
Nodes (17): net_receive(), set_microphone(), start_voice(), CoopVoice, decode(), encode(), _encode_next(), feed() (+9 more)
|
||||
Nodes (19): GDSync (GD-Sync plugin autoload), net_receive(), set_microphone(), start_voice(), CoopVoice, decode(), encode(), _encode_next() (+11 more)
|
||||
|
||||
### Community 32 - "FarmSim Tick & Camera"
|
||||
Cohesion: 0.25
|
||||
Nodes (15): Interactions, _blocker(), cancel(), charges(), deposited (signal), _finish_gather(), gathered (signal), message (signal) (+7 more)
|
||||
Cohesion: 0.23
|
||||
Nodes (17): show_state(), Interactions, _blocker(), cancel(), charges(), deposited (signal), _finish_gather(), gathered (signal) (+9 more)
|
||||
|
||||
### Community 33 - "Interactions & Gathering"
|
||||
Cohesion: 0.09
|
||||
Nodes (21): #35 [mobile] Interface scale, safe area, and the mobile test kit, #36 [mobile] Prompts in touch words, #37 [mobile] Platform: back button, no Quit, flat labels, camera, #38 [mobile] Touch action buttons, #39 [mobile] Tappable HUD, #40 [mobile] Build mode by touch (after #36 and #38), #41 [mobile] Menus and settings at phone scale, #42 [mobile] Panels at phone scale (+13 more)
|
||||
Cohesion: 0.12
|
||||
Nodes (15): #29 [intro] Cutscene kit and the loaded-up car, #30 [intro] Hooks: forced lighting, sounds, the chest glow, #31 [intro] Speakers and the three conversations, #32 [intro] The loading screen, #33 [intro] The opening intro, #34 [intro] Timing review with the user, Decisions (the user's, 2026-10-07), Defaults (assumed; flip any of these on request) (+7 more)
|
||||
|
||||
### Community 34 - "Shed Stock & Supply Targets"
|
||||
Cohesion: 0.37
|
||||
Nodes (16): check(), _crowd(), _enemies_match(), _fall_rule(), _join(), _leaving(), _night(), _partner_moves_and_gathers() (+8 more)
|
||||
Cohesion: 0.17
|
||||
Nodes (25): Host-authoritative simulation with partner replica (FarmSim.replica), Avatar, FarmSim, set_local(), spawn_enemy(), spawn_thief(), _unhandled_input(), FollowCamera (+17 more)
|
||||
|
||||
### Community 35 - "ResourceStore"
|
||||
Cohesion: 0.19
|
||||
Nodes (21): Farm zones (FarmZone rectangles under Zones/), Gather points (GatherNode), Gathering zones (Woodlot, Scrap Heap, Haystacks), Outside gathering areas (North Grove, Old Hangar, East Road, South Fields), Work Area zone (tool table / workbench), Gathering (1.5 s, yield 2 per charge, daytime only), to_dict(), GatherNode (+13 more)
|
||||
Cohesion: 0.31
|
||||
Nodes (14): Pouch and shed storage, GatherNode, ResourceHud, _process(), ResourceStore, Workbench, _deposit_and_night(), _gathering() (+6 more)
|
||||
|
||||
### Community 36 - "Farm Projectiles"
|
||||
Cohesion: 0.17
|
||||
Nodes (9): _release_slot(), sweep_hit(), FarmProjectiles, fire(), hit (signal), _release(), _resolve_segment(), step() (+1 more)
|
||||
Cohesion: 0.16
|
||||
Nodes (10): _release_slot(), sweep_hit(), FarmProjectiles, fire(), hit (signal), _release(), _resolve_segment(), step() (+2 more)
|
||||
|
||||
### Community 37 - "Alert Manager"
|
||||
Cohesion: 0.22
|
||||
Nodes (16): _breaker_goals(), can_afford(), describe(), missing(), blocks(), corners(), _distance_to_outline(), footprint() (+8 more)
|
||||
Cohesion: 0.21
|
||||
Nodes (15): _breaker_goals(), _start_field_rebuild(), can_afford(), missing(), blocks(), corners(), _distance_to_outline(), footprint() (+7 more)
|
||||
|
||||
### Community 38 - "Net Budget Tool"
|
||||
Cohesion: 0.23
|
||||
Nodes (15): _deliver(), Loopback._deliver(), _deliver(), _kill_one(), MeterLink, _deliver(), _pump(), _report() (+7 more)
|
||||
Cohesion: 0.27
|
||||
Nodes (13): _kill_one(), MeterLink, _deliver(), send(), _pump(), _report(), _run(), _setup() (+5 more)
|
||||
|
||||
### Community 39 - "Enemy Roster Tests"
|
||||
Cohesion: 0.20
|
||||
Nodes (14): _ensure_coop(), load_from(), save_to(), _ask_new_vacation(), continue_vacation(), _host_coop(), open(), new_vacation() (+6 more)
|
||||
Cohesion: 0.13
|
||||
Nodes (14): Alien overhaul — task list, Dependent, Independent, Opening intro — task list (2026-10-07), Post-overhaul fix batch (2026-10-06), Thirty nights — task list (2026-10-06), Wave 1, Wave 1 (+6 more)
|
||||
|
||||
### Community 40 - "Co-op Menu UI"
|
||||
Cohesion: 0.21
|
||||
Nodes (13): ActionEdges, BuildHud, _process(), BuildMode, dismantled (signal), message (signal), refused (signal), set_active() (+5 more)
|
||||
Cohesion: 0.23
|
||||
Nodes (12): ActionEdges, BuildHud, _process(), BuildMode, dismantled (signal), message (signal), refused (signal), set_active() (+4 more)
|
||||
|
||||
### Community 41 - "Harvest Season — co-op"
|
||||
Cohesion: 0.17
|
||||
Nodes (15): Automated defense (buildable), Crow (enemy), Fence (buildable), Farm occupancy grid with one flow field per goal set, Flying rule (fences, gates, traps ignore flyers), Gameplay is 2-D on the XZ plane, Gate (buildable), Pen gate breach (gate as start structure) (+7 more)
|
||||
Cohesion: 0.13
|
||||
Nodes (20): Alert priorities, grouping, and cap, Automated defense (buildable), Crow (enemy), Enemy type table (GameConfig.enemy_types), Fence (buildable), Fence breaker (enemy), Flying rule (fences, gates, traps ignore flyers), Gameplay is 2-D on the XZ plane (+12 more)
|
||||
|
||||
### Community 42 - "Snapshot Decoding"
|
||||
Cohesion: 0.15
|
||||
Nodes (12): Alien overhaul — follow-ups (outside docs/tasks.md scope), Crop fields (#13), Docs sweep after renames/rebalances, Housekeeping, Loose animals (#12), Playtest after #11 (player-built pen), Post-overhaul fix batch (#16–#22, 2026-10-06), Spec items from the review with no task (+4 more)
|
||||
|
||||
### Community 43 - "Enemy Characters & Hits"
|
||||
Cohesion: 0.12
|
||||
Nodes (19): First complete version — five-night vacation build steps, Farmers' return ending, Five-night farm vacation (core loop), D1: Starting the night early (allow_early_night, off by default), M3 First loop (first major milestone), Step 10: The five-night progression, Step 1: Rules of the vacation, Step 2: Organize the map into a playable farm (+11 more)
|
||||
Cohesion: 0.14
|
||||
Nodes (16): First complete version — five-night vacation build steps, Five-night farm vacation (core loop), D1: Starting the night early (allow_early_night, off by default), Farm occupancy grid with one flow field per goal set, Step 10: The five-night progression, Step 1: Rules of the vacation, Step 2: Organize the map into a playable farm, Step 4: The scarecrow's defensive tools (+8 more)
|
||||
|
||||
### Community 44 - "PumpkinBombs"
|
||||
Cohesion: 0.38
|
||||
Nodes (11): CoopMenu, back_requested (signal), host_requested (signal), join_address_requested (signal), join_requested (signal), open(), _ready(), search_requested (signal) (+3 more)
|
||||
Cohesion: 0.27
|
||||
Nodes (9): PumpkinBombs, _burst(), burst (signal), _flash(), _new_mesh(), step(), throw(), thrown (signal) (+1 more)
|
||||
|
||||
### Community 45 - "WeaponModels"
|
||||
Cohesion: 0.42
|
||||
Nodes (10): _combat_input(), _consistent(), _escape(), _night_arrivals(), _retry(), run(), _shots(), _stale_handles() (+2 more)
|
||||
Cohesion: 0.29
|
||||
Nodes (9): Prototype Kit texture (8x8 RGB color palette swatch atlas for flat-shaded prototype pieces), PumpkinBomb_texture (11x11 Material-style color palette swatch grid for PumpkinBomb.glb), setup(), WeaponModels, _add(), mesh_of(), setup(), show_offhand() (+1 more)
|
||||
|
||||
### Community 46 - "test_weapons.gd"
|
||||
Cohesion: 0.38
|
||||
Nodes (9): _bombs(), _hud(), _offhand(), _pitchfork(), run(), _start(), _switching(), _unlocks() (+1 more)
|
||||
|
||||
### Community 47 - "Prop Collision Builder"
|
||||
Cohesion: 0.38
|
||||
Nodes (9): GameTestRunner, _initialize(), _main(), run_phase(), _failure_in_every_phase(), _final_dawn_tie(), run(), _terminal() (+1 more)
|
||||
Cohesion: 0.42
|
||||
Nodes (8): _band_points(), _build(), _faces(), _fit(), _initialize(), _kind(), _process_prefab(), _restore_uids()
|
||||
|
||||
### Community 48 - "Horde Performance Report"
|
||||
Cohesion: 0.18
|
||||
Nodes (12): Performance report (prototype horde benchmarks), First shot / first hit stutter check (no first-use stutter), Largest tested passing population: 2,000 birds, 10-minute headless 1,000-bird recycle soak (flat memory), Start-up hitches (10–36 ms frames in the first second), VSync-on ~1 s stalls (compositor throttling of hidden windows), Headless tooling constraints (editor closed, restore UIDs), Performance measurement goals (p95 <= 16.67 ms) (+4 more)
|
||||
|
||||
### Community 49 - "KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)"
|
||||
Cohesion: 0.49
|
||||
Nodes (9): lose_crops(), make_campaign(), run_until(), _early_night(), _five_nights(), _night_log(), _order_and_timers(), _retry() (+1 more)
|
||||
Cohesion: 0.28
|
||||
Nodes (9): KayKit Character Animations license (CC0), KayKit: Character Animations 1.1 (Kay Lousberg), Prototype Kit license (CC0, Rgsdev), Prototype Kit (Raphael Gonçalves / Rgsdev), Prototype asset inventory (Godot 4.7.2 dump), Bird_01.obj bird mesh (1 surface, 386 tris), KayKit Mannequin_Medium character (21-bone Rig_Medium skeleton), Prototype Kit FBX pieces (walls, fences, doors, stairs, primitives) (+1 more)
|
||||
|
||||
### Community 50 - "GameConfig"
|
||||
Cohesion: 0.42
|
||||
Nodes (9): AlertManager, _alert(), _arrow(), cap(), collect(), _draw(), group_alerts(), label_for() (+1 more)
|
||||
Cohesion: 0.22
|
||||
Nodes (9): The farm's edge (random enemy arrivals and carrier escapes), Travel times and the 12 s rule, Finding: night 1 alone is not a threat once anything is defended, Two-front pressure (main playtest question), Dawn retreat and grace (D4), Dusk warning (banner, hint, phase HUD list), The five nights progression, Night plans (NightPlan groups: time, count, spacing, type, target) (+1 more)
|
||||
|
||||
### Community 51 - "Upgrades"
|
||||
Cohesion: 0.22
|
||||
Nodes (16): start_channel(), trap_slow_time(), UpgradePanel, bought (signal), _buy(), message (signal), open(), refresh() (+8 more)
|
||||
Cohesion: 0.46
|
||||
Nodes (8): trap_slow_time(), Upgrades, blocker(), buy(), cost(), owned(), value(), show_state()
|
||||
|
||||
### Community 52 - "Harvest Season — alien overhaul: review, decisions, and task plan"
|
||||
Cohesion: 0.29
|
||||
Nodes (6): Decisions (resolved), Harvest Season — alien overhaul: review, decisions, and task plan, Headline finding from the review, Open assumptions (flagged, not yet confirmed), Suggested starting order, Task breakdown (mirrors Task tool `#1`–`#15`)
|
||||
|
||||
### Community 53 - "Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)"
|
||||
Cohesion: 0.44
|
||||
Nodes (9): Tutorial, _check_done(), _enemies_near(), _finish(), _on_phase(), _process(), setup(), _show() (+1 more)
|
||||
Cohesion: 0.29
|
||||
Nodes (7): MultiMesh batching for birds and bullets, Simulation tick profile at 2,000 birds (steering, motion+collision, flow-field slice, grid), GDScript simulation is the bottleneck, not rendering, Farm draw-call reduction (1,270 → 304 at start), Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields), Blocked routes (barrier cells as 18 m detours), RoundController (prototype)
|
||||
|
||||
### Community 54 - "GD-Sync Sync Icons"
|
||||
Cohesion: 0.50
|
||||
|
|
@ -385,8 +392,16 @@ Cohesion: 0.40
|
|||
Nodes (5): Leaf_Pine_C solid dark-green pine foliage silhouette, Leaf_Pine white alpha silhouette of a pine foliage cluster, Leaves_GiantPine_C solid green rounded foliage blob shapes, Leaves sprite sheet with colorful painted leaf shapes, ferns, clovers, Leaves_NormalTree white alpha silhouettes of normal tree leaf clusters
|
||||
|
||||
### Community 56 - "Campaign Experience (Step 11)"
|
||||
Cohesion: 0.22
|
||||
Nodes (9): D9: Retry from the failed night's morning, One authoritative FarmState, Step 11: The complete campaign experience, Step 11: Add the complete campaign experience, Farm audio cues and buses (FarmAudio), Kenney CC0 audio packs, Morning autosave and save migration (SaveGame), Morning review and nightly results (+1 more)
|
||||
Cohesion: 0.15
|
||||
Nodes (14): Farmers' return ending, D3: Phase lengths, M3 First loop (first major milestone), Campaign phase state machine (MORNING -> DAY -> DUSK -> NIGHT -> DAWN), Step 11: The complete campaign experience, Step 7: Connect one complete day and night (milestone M3), Step 11: Add the complete campaign experience, Step 7: Connect one complete day and night (+6 more)
|
||||
|
||||
### Community 57 - "equip"
|
||||
Cohesion: 0.43
|
||||
Nodes (7): cycle(), equip(), owns(), _set_offhand(), show_weapon(), switched (signal), tick()
|
||||
|
||||
### Community 58 - "render_overview.gd"
|
||||
Cohesion: 0.70
|
||||
Nodes (4): _draw_grid(), _draw_zones(), _initialize(), _render()
|
||||
|
||||
### Community 60 - "GD-Sync Physics/Voice Icons"
|
||||
Cohesion: 0.67
|
||||
|
|
@ -413,7 +428,7 @@ Nodes (3): PathRocks_Diffuse (mossy grey stepping-stone UV atlas diffuse, Pebble
|
|||
game/RULES.md · relation: conceptually_related_to
|
||||
|
||||
## Knowledge Gaps
|
||||
- **123 isolated node(s):** `Headline finding from the review`, `Decisions (resolved)`, `Open assumptions (flagged, not yet confirmed)`, `Task breakdown (mirrors Task tool `#1`–`#15`)`, `Suggested starting order` (+118 more)
|
||||
- **112 isolated node(s):** `Headline finding from the review`, `Decisions (resolved)`, `Open assumptions (flagged, not yet confirmed)`, `Task breakdown (mirrors Task tool `#1`–`#15`)`, `Suggested starting order` (+107 more)
|
||||
These have ≤1 connection - possible missing edges or undocumented components.
|
||||
- **15 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
|
||||
|
||||
|
|
@ -422,12 +437,12 @@ _Questions this graph is uniquely positioned to answer:_
|
|||
|
||||
- **What is the exact relationship between `KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)` and `Final assessment (weighted share kept, 0–100 points, ratings)`?**
|
||||
_Edge tagged AMBIGUOUS (relation: conceptually_related_to) - confidence is low._
|
||||
- **Why does `FarmSim` connect `Thief Behavior AI` to `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `Horde Prototype (README)`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Farm Navigation Flow Fields`, `Animal System`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Co-op Tests`, `Farm Layout Doc`, `FarmSim Tick & Camera`, `Shed Stock & Supply Targets`, `ResourceStore`, `Farm Projectiles`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `WeaponModels`, `GameConfig`, `Upgrades`, `Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)`?**
|
||||
_High betweenness centrality (0.113) - this node is a cross-community bridge._
|
||||
- **Why does `CoopSession` connect `Co-op Session Host/Client` to `Campaign Controller & Farm State`, `Shed Stock & Supply Targets`, `ResourceStore`, `Scarecrow Weapons & Bombs`, `Net Budget Tool`, `Enemy Roster Tests`, `Co-op Lobby & Smoke Test`, `Enemy System & Theft Tests`, `Game Flow, Save & Pause`, `Animal System`, `Upgrades`, `Enemy Roster & Construction Plan`, `Co-op Link Transport`, `Thief Behavior AI`, `Farm Layout Doc`, `Co-op Voice Chat`?**
|
||||
- **Why does `CoopSession` connect `Co-op Session Host/Client` to `Campaign Controller & Farm State`, `Shed Stock & Supply Targets`, `ResourceStore`, `Scarecrow Weapons & Bombs`, `Net Budget Tool`, `Co-op Lobby & Smoke Test`, `Enemy System & Theft Tests`, `Game Flow, Save & Pause`, `Animal System`, `Upgrades`, `Co-op Docs & GD-Sync Link`, `Enemy Roster & Construction Plan`, `Co-op Link Transport`, `Co-op Voice Chat`?**
|
||||
_High betweenness centrality (0.119) - this node is a cross-community bridge._
|
||||
- **Why does `CampaignController` connect `Campaign Controller & Farm State` to `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `Horde Prototype (README)`, `Co-op Lobby & Smoke Test`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Farm Navigation Flow Fields`, `Resource Economy & Upgrades`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Co-op Tests`, `Farm Layout Doc`, `FarmSim Tick & Camera`, `Shed Stock & Supply Targets`, `ResourceStore`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `GameConfig`, `Upgrades`, `Campaign Experience (Step 11)`?**
|
||||
_High betweenness centrality (0.115) - this node is a cross-community bridge._
|
||||
- **Why does `FarmSim` connect `Shed Stock & Supply Targets` to `Campaign Controller & Farm State`, `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `Horde Prototype (README)`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Farm Zones & Layout Tests`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Farm Navigation Flow Fields`, `Resource Economy & Upgrades`, `Animal System`, `Co-op Docs & GD-Sync Link`, `Enemy Roster & Construction Plan`, `Playtest Notes & Scaling`, `Farm Sim Setup Wiring`, `Soak Night & Benchmarks`, `Co-op Tests`, `Farm Layout Doc`, `FarmSim Tick & Camera`, `ResourceStore`, `Farm Projectiles`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `PumpkinBombs`, `test_weapons.gd`?**
|
||||
_High betweenness centrality (0.106) - this node is a cross-community bridge._
|
||||
- **Why does `CampaignController` connect `Farm Layout Doc` to `Campaign Controller & Farm State`, `Audio & Farmers Return Ending`, `Scarecrow Weapons & Bombs`, `First Game Plan & Milestones`, `Horde Prototype (README)`, `Co-op Lobby & Smoke Test`, `Scarecrow Defender & Fear`, `Loot & Theft Events`, `Settings, Input & UI Theme`, `Main Scene & Title Menu`, `Enemy System & Theft Tests`, `Co-op Session Host/Client`, `Rules of the Vacation`, `Game Flow, Save & Pause`, `Co-op Docs & GD-Sync Link`, `Enemy Roster & Construction Plan`, `Farm Sim Setup Wiring`, `Thief Behavior AI`, `Soak Night & Benchmarks`, `Co-op Tests`, `FarmSim Tick & Camera`, `Shed Stock & Supply Targets`, `ResourceStore`, `Alert Manager`, `Net Budget Tool`, `Co-op Menu UI`, `WeaponModels`, `Prop Collision Builder`, `KayKit Rig_Medium animation libraries (CombatMelee, CombatRanged, General, Movement, Simulation, Special, Tools)`, `GameConfig`, `Upgrades`, `Navigation occupancy grid (0.5 m cells, octile Dijkstra distance fields)`?**
|
||||
_High betweenness centrality (0.102) - this node is a cross-community bridge._
|
||||
- **Are the 12 inferred relationships involving `CampaignController` (e.g. with `Outcome evaluator check_outcome` and `_night_log()`) actually correct?**
|
||||
_`CampaignController` has 12 INFERRED edges - model-reasoned connections that need verification._
|
||||
- **Are the 13 inferred relationships involving `EnemySystem` (e.g. with `AlertManager` and `_describe()`) actually correct?**
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
graphify-out/cache/stat-index.json
vendored
2
graphify-out/cache/stat-index.json
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -985,13 +985,13 @@
|
|||
"semantic_hash": ""
|
||||
},
|
||||
"docs/tasks.md": {
|
||||
"mtime": 1792006512.8705802,
|
||||
"ast_hash": "c8f24a6735402df94b058f74942576ad",
|
||||
"mtime": 1791428141.5586648,
|
||||
"ast_hash": "93c0905bde5bd614da8963a2d1079faf",
|
||||
"semantic_hash": ""
|
||||
},
|
||||
"docs/plan.md": {
|
||||
"mtime": 1792003690.8921824,
|
||||
"ast_hash": "27002f2ec10b888758c1c6dba3a34e3e",
|
||||
"mtime": 1791423014.9100025,
|
||||
"ast_hash": "6c5a4e9916b50908cf01fb2ff2f562dd",
|
||||
"semantic_hash": ""
|
||||
},
|
||||
"assets/audio/synth/alien_beam.wav": {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ run/main_scene="res://game/scenes/main.tscn"
|
|||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
boot_splash/image="uid://dpociv7go51qj"
|
||||
config/icon="res://assets/pictures/icons/app_icon.png"
|
||||
config/quit_on_go_back=false
|
||||
|
||||
[audio]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue