Merge #33: opening intro cutscene
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
c9898a97c8
19 changed files with 2112 additions and 21 deletions
26
README.md
26
README.md
|
|
@ -221,6 +221,21 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`).
|
|||
(`example_morning_day_2.tres`, the Scarecrow and a Little Green Alien) uses the HUD's painted
|
||||
icons as placeholder portraits (`DialogueSpeaker.icon`) until real pictures are set.
|
||||
|
||||
* **The opening intro** — every New vacation opens with a cutscene, about 70 s (`OpeningIntro`,
|
||||
`game/scripts/opening_intro.gd`): on a summer morning the farmers load up their station wagon
|
||||
and drive off to the Bon Jovi concert; that night a bickering UFO crew loses control over the
|
||||
farm, a glowing part falls off, and its blue flash brings the scarecrow to life (the faint blue
|
||||
glow in its chest from then on); then a loading screen (`LoadingScreen`) and the first
|
||||
morning's sign. Hold Space / Enter / A (or E, or the mouse button) for a second to skip it
|
||||
(straight to the sign); Escape pauses it, and Restart the night skips it. Continue never plays
|
||||
it, and hosting co-op skips it. Its lines are talking-head conversations in
|
||||
`game/resources/dialogue/intro/` (`departure.tres`, `flight.tres`, `uh_oh.tres`; edit the lines
|
||||
and speakers there: that folder never plays by itself), shown in the intro's own box, where
|
||||
they go on by themselves and a tap hurries them. It shares the car, the farmers, and the camera
|
||||
moves with the ending (`CutsceneKit`). Its staging points are in
|
||||
[`game/LAYOUT.md`](game/LAYOUT.md). To review it shot by shot, `game/tools/capture_intro.gd`
|
||||
saves a frame at every stage (its header has the command).
|
||||
|
||||
* **Menus and saving** — `Main` (`game/scripts/main.gd`, `game/scenes/main.tscn`) hosts the farm
|
||||
under the menus. `MainMenu` is the title screen (Continue, New vacation, Settings, Quit) over
|
||||
the paused farm, with a camera circling it. `PauseMenu` (Escape / Start) pauses the whole tree
|
||||
|
|
@ -316,6 +331,7 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`).
|
|||
| Pause / resume | Escape | Start |
|
||||
| Hide the tips | Backspace | Back |
|
||||
| Mute / unmute your microphone (co-op) | M | - |
|
||||
| Skip the opening intro (hold 1 s) | Space, Enter, E, or left mouse | A, X, or right trigger |
|
||||
| Skip the farmers' return | Space, Enter, E, or click | A or X |
|
||||
| Menus and end screens | Click, arrows + Enter, Escape to go back | D-pad + A, B to go back |
|
||||
|
||||
|
|
@ -610,8 +626,8 @@ damaged, rule-breaking, non-morning, newer, and too-old saves refused with a rea
|
|||
save upgraded, the autosave every morning, retry restoring the saved morning, the save deleted
|
||||
when the vacation is finished, settings saved, loaded, clamped, and applied (bus volumes, dead
|
||||
zones), and the final assessment's score, tiers, and renormalized weights. The flow suite plays
|
||||
the game through `main.tscn`: the title screen over the paused farm, New vacation and Continue
|
||||
(and their questions), pausing freezing the simulation tick, settings applying and saving from
|
||||
the game through `main.tscn`: the title screen over the paused farm, New vacation (its intro
|
||||
skipped) and Continue (and their questions), pausing freezing the simulation tick, settings applying and saving from
|
||||
the pause menu, Restart the night and Save & quit leaving the save untouched, a damaged save
|
||||
refused, the failure screens and Retry, the farmers' return to the final assessment (and
|
||||
skipping it), the first day's and night's tips, and the sounds hooked to the game. The co-op suite
|
||||
|
|
@ -619,6 +635,12 @@ runs a host and a partner in one process (the partner's farm in its own world, o
|
|||
link): the join, the partner's requests, moves, gathering, and shots, enemies, loot, and shots
|
||||
arriving, the fall rule and Retry, a crowd with dropped packets and message sizes, and either side
|
||||
leaving. `game/tools/coop_smoke.gd` plays the same over real GD-Sync between two processes.
|
||||
The intro suite plays the opening intro through `main.tscn`: New vacation starts it, and Continue
|
||||
and hosting don't; stepped through, it visits every stage in order with the farm held (no sign,
|
||||
no HUD, the scarecrow frozen on its post) and ends on the focused morning sign; and a skip from
|
||||
every stage, holding to skip, Restart the night, and Save & quit during it each leave the farm
|
||||
exactly as a new vacation's first morning (the scarecrow at its start with input and glow, the
|
||||
light and sounds given back, the game camera, nothing of the intro left).
|
||||
|
||||
Prototype: 107 checks, ~1.5 s. Covers pool acquire/release/exhaustion and swap identities, slot reuse
|
||||
hygiene and stale handles, U-shape routing, corner cutting, unreachable spawns, octile costs,
|
||||
|
|
|
|||
|
|
@ -264,6 +264,34 @@ Its largest slice stays about 3 ms.
|
|||
- **What to avoid:** the tractor parked east of the house (about (30, −25)) hides anything at the
|
||||
house's east side from the south-east.
|
||||
|
||||
## The opening intro (#33)
|
||||
|
||||
`OpeningIntro` (`game/scripts/opening_intro.gd`) stages its shots on the same map:
|
||||
- **The car** waits at the end of the ending's route, (32.8, −29.5), facing north (nose-out), and
|
||||
drives the route backwards: north along the yard road, east out of GapDriveway (the horn), then
|
||||
south down the road at x 52 to z 80, well past the map's south edge.
|
||||
- **The farmers** come out of the front door, (19.6, −29.8). The farmer walks along z ≈ −31 to the
|
||||
car's left door, (31.45, −29.95). The wife goes round the car's nose (z −33.7) to its right
|
||||
door, (34.15, −29.95).
|
||||
- **The departure shot** looks south over the yard from the north, (26.2, 13.5, −59), at
|
||||
(26.2, 1, −30.5). The porch and the car stand side by side in the middle of the frame, clear of
|
||||
the talking heads at its sides. The scrap heap's props between the camera and the yard are low
|
||||
enough to look over.
|
||||
- **The drive** follows behind the car until 6 m before the gap. Then the camera stops by
|
||||
GapDriveway, at (46.8, 3, −43.6), and watches the car go south down the road.
|
||||
- **The scarecrow's post** stands at the scarecrow's start, (3, −13). The scarecrow hangs 0.6 m up
|
||||
on it, facing east over the crop field. It drops off 0.6 m in front of the post, which tips over
|
||||
to its left. At the end it stands at its start again, facing north.
|
||||
- **The UFO** comes from (125, 62, −150), bends over (70, 40, −40), and stops over the scarecrow at
|
||||
(5, 19, −13). The part lands 0.8 m in front of the scarecrow. After the flash the UFO backs off to
|
||||
(26, 15, −16), then leaves up and away to the east-north-east.
|
||||
- **The night shots:** the flight and the wobble look up from the south-west, low, at
|
||||
(−9, 1.5, 19), far enough off to see the saucer from the side. The drop and the flash look at
|
||||
the scarecrow from the east (the barn behind it). The uh-oh and the escape look over the
|
||||
scarecrow's right shoulder from behind it.
|
||||
- **What to avoid:** the woodlot's trees block any view of the yard from the east, and the pen
|
||||
(x −10…4, z −11…−1) is right under low cameras south-west of the scarecrow.
|
||||
|
||||
## Outside the fence
|
||||
|
||||
The scarecrow can leave through the fence's gaps or across the open south and west sides. The invisible walls (`Zones/Perimeter/PlayerBounds`)
|
||||
|
|
|
|||
|
|
@ -396,3 +396,23 @@ so a whole vacation is about 3¼ hours, and losses still carry over. The nights,
|
|||
biggest step.
|
||||
- Rewrite the draft titles and hints of nights 6–29 (in the files, or in `make_nights.gd`'s lists
|
||||
followed by `--force`).
|
||||
|
||||
## The opening intro (2026-10-07)
|
||||
|
||||
New vacation now opens with a cutscene (#33, `OpeningIntro`); README has the story and LAYOUT.md
|
||||
the staging. When nothing is skipped and no line is hurried, it lasts 69 s. The stages, in
|
||||
seconds: leave 12.2, board 2.2, drive 12, card 3.6, flight 13, wobble 4, drop 2.6, flash 5.4,
|
||||
uh-oh 7.1, escape 2.6, loading 4.1. `test_intro` checks that every stage plays in order, and
|
||||
that a skip from any of them, Restart the night, or Save & quit leaves the farm exactly as a new
|
||||
vacation's first morning. `game/tools/capture_intro.gd` saves a frame at each stage for the
|
||||
timing review (#34).
|
||||
|
||||
**For the playtest:**
|
||||
- Watch it once from New vacation, all the way to the first morning's sign.
|
||||
- Start another and hold Space / Enter / A partway through. Does it skip cleanly to the sign? Is
|
||||
the hint ("Hold ... to skip", with its ring) easy to find?
|
||||
- Tap through a few lines: do they hurry as expected, and do the shots still keep up?
|
||||
- Press Escape mid-intro. Does the pause menu work over it, and does Restart the night take you
|
||||
to the sign?
|
||||
- Is anything important hidden behind the dialogue box? Is the UFO easy to read against the night
|
||||
sky?
|
||||
|
|
|
|||
|
|
@ -545,6 +545,12 @@ shed counts as raided when a thief takes the last of its stock, and storing anyt
|
|||
## Menus, pause, and settings
|
||||
|
||||
- **Title screen:** Continue, New vacation, Settings, Quit, over the farm standing still.
|
||||
- **The opening intro.** New vacation plays a cutscene (about 70 s) before the first morning's
|
||||
sign: the farmers leave, and that night a UFO's lost part brings the scarecrow to life. Holding
|
||||
Space / Enter / A (or E, or the mouse button) for a second skips it, straight to the sign.
|
||||
Continue never plays it, and hosting co-op skips it. It changes nothing in the farm: the new
|
||||
vacation is saved before it starts, so quitting during it continues at that morning without
|
||||
it, and Restart the night during it skips it. Escape pauses it like the game.
|
||||
- **Pause** (Escape / Start, any phase) freezes the whole simulation: timers, enemies, shots,
|
||||
and game sounds. The menus and the ambience keep running. Its options are Resume, Restart the
|
||||
night, Settings, Save & quit to menu, and Quit the game. Restarting and quitting ask first, with
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ extends Node
|
|||
## starts while a menu is up (the shops, or Main's: DialogueBox.blocked) or the vacation is over,
|
||||
## and a new morning (or a retry) takes down whatever was up. play() shows a conversation from
|
||||
## code at any time; replay() (debug: F5) plays this phase's again.
|
||||
## The opening intro (OpeningIntro) holds all of it: nothing starts while it's on screen (play()
|
||||
## waits) and the sign stays down while it has the farm; at its end (intro_over()) night 1's
|
||||
## morning conversations play, then the sign comes up.
|
||||
|
||||
const DIR := "res://game/resources/dialogue/"
|
||||
|
||||
|
|
@ -73,9 +76,9 @@ func due(n: int, phase: CampaignController.Phase) -> Array[Conversation]:
|
|||
return out
|
||||
|
||||
|
||||
## Shows conversation c now, or after the one that's up.
|
||||
## Shows conversation c now, or after the one that's up (or the opening intro).
|
||||
func play(c: Conversation) -> void:
|
||||
if is_playing():
|
||||
if is_playing() or _intro_busy():
|
||||
_asked.append(c)
|
||||
return
|
||||
_played[c] = true
|
||||
|
|
@ -98,6 +101,17 @@ func replay() -> void:
|
|||
play(c)
|
||||
|
||||
|
||||
## Whether a conversation would start now (the intro keeps the sign down for it).
|
||||
func has_due() -> bool:
|
||||
return not _asked.is_empty() or (not _queue.is_empty() and _elapsed() >= _queue[0].delay)
|
||||
|
||||
|
||||
## The opening intro is over: this morning's conversations now, then the sign.
|
||||
func intro_over() -> void:
|
||||
if not is_playing():
|
||||
_next()
|
||||
|
||||
|
||||
## Takes down whatever is up and forgets what was due.
|
||||
func stop() -> void:
|
||||
_queue.clear()
|
||||
|
|
@ -120,7 +134,7 @@ func _exit_tree() -> void:
|
|||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _queue.is_empty() or is_playing() or box.is_blocked() or sim.campaign.is_over() or sim._menu_open():
|
||||
if _queue.is_empty() or is_playing() or box.is_blocked() or sim.campaign.is_over() or sim._menu_open() or _intro_busy():
|
||||
return
|
||||
if _elapsed() >= _queue[0].delay:
|
||||
play(_queue.pop_front())
|
||||
|
|
@ -146,6 +160,11 @@ func _on_phase(phase: CampaignController.Phase, _previous: CampaignController.Ph
|
|||
|
||||
func _on_finished(_c: Conversation) -> void:
|
||||
_release()
|
||||
_next()
|
||||
|
||||
|
||||
## The next conversation (asked for, or due), or the sign.
|
||||
func _next() -> void:
|
||||
if not _asked.is_empty():
|
||||
play(_asked.pop_front())
|
||||
elif not _queue.is_empty() and _elapsed() >= _queue[0].delay:
|
||||
|
|
@ -155,10 +174,10 @@ func _on_finished(_c: Conversation) -> void:
|
|||
|
||||
|
||||
## The morning sign steps aside while a conversation is up, and comes back (with the focus on
|
||||
## Start the day) after it.
|
||||
## Start the day) after it (not while the opening intro has the farm).
|
||||
func _sign(show: bool) -> void:
|
||||
var review := sim.review_panel if sim != null else null
|
||||
if review == null:
|
||||
if review == null or (show and sim.intro != null and sim.intro.running):
|
||||
return
|
||||
if show:
|
||||
review.refresh()
|
||||
|
|
@ -167,6 +186,10 @@ func _sign(show: bool) -> void:
|
|||
review.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
|
||||
func _intro_busy() -> bool:
|
||||
return sim != null and sim.intro != null and sim.intro.busy()
|
||||
|
||||
|
||||
## Stops the farm for a conversation that pauses the game: the whole tree solo, this machine's
|
||||
## scarecrow in co-op.
|
||||
func _hold(pause: bool) -> void:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ enum Align { SIDE, LEFT, CENTER, RIGHT }
|
|||
## Optional mouth flaps: shown in turn with portrait while the words are being written.
|
||||
@export var talk_frames: Array[Texture2D] = []
|
||||
## Placeholder art while there's no portrait: one of Sketch.ICONS ("portrait" is the scarecrow,
|
||||
## "thief" an alien, "breaker" a robot, "crow", "ufo").
|
||||
## "thief" an alien, "breaker" a robot, "crow", "ufo", "farmer" the farmer in his straw hat,
|
||||
## "farmers_wife" the farmer's wife).
|
||||
@export var icon := ""
|
||||
@export var side: HeadSide = HeadSide.LEFT
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ extends Node3D
|
|||
## * UI: hover, click, back, open, close, error (ui(), also from the menus)
|
||||
## * the opening intro (OpeningIntro, solo only, so never sent): the farmhouse door's creak, the
|
||||
## car doors, the big UFO's hum (a loop), spin-up whine, and zoom away, the part's falling
|
||||
## whistle, and the flash that brings the scarecrow to life
|
||||
## whistle, and the flash that brings the scarecrow to life. While it plays it holds the
|
||||
## ambience and the music (set_scene: its morning, then its night) whatever the phase, and it
|
||||
## stops new_campaign()'s morning stinger (stop_cue) to play it with the sign instead
|
||||
## * Music (the Music bus), by phase: "On the Farm" on the title screen (the farm's morning
|
||||
## behind it), the morning, and by day, and when the farmers are back; "Purgatory" at night;
|
||||
## none at dusk, at dawn, or after a Game Over (only the ambience). Tracks crossfade.
|
||||
|
|
@ -168,6 +170,8 @@ var _bell_left: float = -1.0
|
|||
var music_track := ""
|
||||
var _music := {}
|
||||
var _music_level := {}
|
||||
## A cutscene holds the ambience and the music (set_scene); the phase gets them back at end_scene().
|
||||
var scene := false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -369,6 +373,36 @@ func wire_buttons(node: Node) -> void:
|
|||
button.pressed.connect(func() -> void: ui("ui_click"))
|
||||
|
||||
|
||||
## A cutscene's ambience (day, night levels, 0..1; they crossfade to it) and music track ("" for
|
||||
## none), whatever the phase, until end_scene().
|
||||
func set_scene(ambience: Vector2, track: String) -> void:
|
||||
scene = true
|
||||
_ambience_target = ambience
|
||||
music_track = track
|
||||
|
||||
|
||||
## Gives the ambience (at once) and the music back to the phase.
|
||||
func end_scene() -> void:
|
||||
if not scene:
|
||||
return
|
||||
scene = false
|
||||
var phase := sim.campaign.state.phase if sim != null else CampaignController.Phase.MORNING
|
||||
_ambience_target = AMBIENCE.get(phase, Vector2(1.0, 0.0))
|
||||
_ambience = _ambience_target
|
||||
music_track = MUSIC_FOR.get(phase, "")
|
||||
|
||||
|
||||
## Stops whatever a cue is playing now.
|
||||
func stop_cue(cue: String) -> void:
|
||||
for p in _voices_3d:
|
||||
if p.playing and p.get_meta(&"cue", "") == cue:
|
||||
p.stop()
|
||||
for pool: Array[AudioStreamPlayer] in [_voices_ui, _voices_game]:
|
||||
for p in pool:
|
||||
if p.playing and p.get_meta(&"cue", "") == cue:
|
||||
p.stop()
|
||||
|
||||
|
||||
## The first stream of a cue (for looping players the cutscene owns).
|
||||
func stream_of(cue: String) -> AudioStream:
|
||||
var list: Array = streams.get(cue, [])
|
||||
|
|
@ -432,6 +466,8 @@ func _process(delta: float) -> void:
|
|||
|
||||
|
||||
func _on_phase(phase: CampaignController.Phase, _previous: CampaignController.Phase) -> void:
|
||||
if scene:
|
||||
return # the cutscene's (it gives them back at its end)
|
||||
_ambience_target = AMBIENCE.get(phase, Vector2(1.0, 0.0))
|
||||
music_track = MUSIC_FOR.get(phase, "")
|
||||
match phase:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ extends Node
|
|||
## combat, and interactions are that machine's own scarecrow's (player 2's).
|
||||
## FarmAudio plays every sound, Tutorial shows the first
|
||||
## day's and night's tips, DialogueDirector the talking-head conversations (game/resources/
|
||||
## dialogue/), and FarmersReturn plays the ending. Debug: T / G / H send in a
|
||||
## dialogue/), OpeningIntro the cutscene before a new vacation's first morning (Main starts it),
|
||||
## and FarmersReturn plays the ending. Debug: T / G / H send in a
|
||||
## thief / a crow / a fence breaker at any time.
|
||||
|
||||
const SCARECROW_RADIUS := 0.4
|
||||
|
|
@ -86,6 +87,7 @@ var audio: FarmAudio
|
|||
var tutorial: Tutorial
|
||||
var dialogue: DialogueDirector
|
||||
var ending: FarmersReturn
|
||||
var intro: OpeningIntro
|
||||
## Flow-field rebuild after a structure change: running, and stats of the last one.
|
||||
var rebuilding := false
|
||||
var rebuilds: int = 0
|
||||
|
|
@ -313,6 +315,12 @@ func _ready() -> void:
|
|||
ending.name = "FarmersReturn"
|
||||
add_child(ending)
|
||||
ending.setup(self)
|
||||
intro = OpeningIntro.new()
|
||||
intro.name = "OpeningIntro"
|
||||
add_child(intro)
|
||||
intro.setup(self)
|
||||
if review_panel != null:
|
||||
review_panel.intro = intro
|
||||
if end_panel != null:
|
||||
end_panel.setup(campaign)
|
||||
end_panel.ending = ending
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ extends Node
|
|||
## circles the farm behind the menu; the HUD is hidden.
|
||||
## * New vacation (asks first when it would replace a save), Continue (the saved morning,
|
||||
## SaveGame; refused with the reason when the save can't be used), Settings, Quit.
|
||||
## * A new vacation opens with the intro (OpeningIntro; held down, it skips) before its first
|
||||
## morning's sign. Continue never plays it, nor does hosting co-op. Restart the night during
|
||||
## it skips it; Save & quit to menu takes it down (the save is that first morning already).
|
||||
## * During play, Escape / Start pauses (PauseMenu): the tree pauses, so the simulation tick,
|
||||
## timers, enemies, and game sounds all freeze. Resume, Restart the night (asks first),
|
||||
## Settings, Save & quit to menu, Quit the game (asks first).
|
||||
|
|
@ -65,6 +68,8 @@ func _ready() -> void:
|
|||
sim.tutorial.enabled = settings.show_tips
|
||||
if sim.dialogue != null:
|
||||
sim.dialogue.box.blocked = func() -> bool: return screen != Screen.PLAYING
|
||||
if sim.intro != null:
|
||||
sim.intro.blocked = func() -> bool: return screen != Screen.PLAYING
|
||||
main_menu.continue_requested.connect(continue_vacation)
|
||||
main_menu.new_requested.connect(_ask_new_vacation)
|
||||
main_menu.settings_requested.connect(_open_settings)
|
||||
|
|
@ -158,10 +163,13 @@ func continue_vacation() -> bool:
|
|||
return true
|
||||
|
||||
|
||||
## New vacation: a fresh farm, the morning of night 1 (saved at once, replacing any save).
|
||||
func new_vacation() -> void:
|
||||
## New vacation: a fresh farm, the morning of night 1 (saved at once, replacing any save), and
|
||||
## the opening intro before its sign (unless intro is false: hosting co-op).
|
||||
func new_vacation(intro := true) -> void:
|
||||
_play()
|
||||
sim.campaign.new_campaign()
|
||||
if intro and sim.intro != null:
|
||||
sim.intro.start()
|
||||
|
||||
|
||||
func pause() -> void:
|
||||
|
|
@ -188,7 +196,7 @@ func resume() -> void:
|
|||
pause_menu.close()
|
||||
screen = Screen.PLAYING
|
||||
get_tree().paused = false
|
||||
if sim.local_frozen:
|
||||
if sim.local_frozen and not (sim.intro != null and sim.intro.running): # (the intro's freeze is its own)
|
||||
sim.freeze_local(false)
|
||||
if sim.dialogue != null:
|
||||
sim.dialogue.hold() # a conversation that was up stops the farm again
|
||||
|
|
@ -196,6 +204,9 @@ func resume() -> void:
|
|||
|
||||
func restart_night() -> void:
|
||||
resume()
|
||||
if sim.intro != null and sim.intro.running:
|
||||
sim.intro.skip() # its night is the first morning already: straight to it
|
||||
return
|
||||
sim.campaign.retry_night()
|
||||
|
||||
|
||||
|
|
@ -204,6 +215,8 @@ func restart_night() -> void:
|
|||
func to_menu() -> void:
|
||||
confirm.close()
|
||||
settings_menu.close()
|
||||
if sim.intro != null:
|
||||
sim.intro.clear()
|
||||
if sim.coop.is_client():
|
||||
_leave_as_partner("")
|
||||
return
|
||||
|
|
@ -262,7 +275,7 @@ func _host_coop(mode: CoopLobby.Mode, player: String, resume: bool) -> void:
|
|||
if not continue_vacation():
|
||||
return
|
||||
else:
|
||||
new_vacation()
|
||||
new_vacation(false) # no intro: the friend can join any time
|
||||
lobby.host(mode, player)
|
||||
if not resume and SaveGame.read(save_path).status == SaveGame.Status.OK:
|
||||
confirm.ask("Start a new vacation? It replaces your saved one.", "New vacation", go)
|
||||
|
|
|
|||
1536
game/scripts/opening_intro.gd
Normal file
1536
game/scripts/opening_intro.gd
Normal file
File diff suppressed because it is too large
Load diff
1
game/scripts/opening_intro.gd.uid
Normal file
1
game/scripts/opening_intro.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cppgmcqeukqgy
|
||||
|
|
@ -7,7 +7,8 @@ extends CenterContainer
|
|||
## * the enemies defeated, by type;
|
||||
## * the materials gathered over the day and night.
|
||||
## 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.
|
||||
## 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).
|
||||
|
||||
const CATEGORIES := ["Crops", "Animals", "Supplies"]
|
||||
const ENEMY_TYPES := [EnemySystem.TYPE_CROW, EnemySystem.TYPE_THIEF, EnemySystem.TYPE_BREAKER, EnemySystem.TYPE_UFO]
|
||||
|
|
@ -19,8 +20,9 @@ const BOTTOM := 70.0
|
|||
const WIDTH := 880.0
|
||||
|
||||
var campaign: CampaignController
|
||||
## Set by FarmSim: the night plans (last night's title).
|
||||
## Set by FarmSim: the night plans (last night's title), and the opening intro.
|
||||
var waves: WaveDirector
|
||||
var intro: OpeningIntro
|
||||
|
||||
var _board: PanelContainer
|
||||
var _title: Label
|
||||
|
|
@ -151,7 +153,7 @@ static func backing() -> StyleBoxFlat:
|
|||
func refresh() -> void:
|
||||
if campaign == null:
|
||||
return
|
||||
visible = campaign.state.phase == CampaignController.Phase.MORNING
|
||||
visible = campaign.state.phase == CampaignController.Phase.MORNING and not (intro != null and intro.running)
|
||||
mouse_filter = Control.MOUSE_FILTER_STOP if visible else Control.MOUSE_FILTER_IGNORE
|
||||
if not visible:
|
||||
return
|
||||
|
|
@ -177,7 +179,14 @@ func refresh() -> void:
|
|||
_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)))
|
||||
_board.queue_redraw()
|
||||
_start.grab_focus.call_deferred()
|
||||
_focus_start.call_deferred()
|
||||
|
||||
|
||||
## Start the day takes the focus (unless the sign went down again meanwhile: a hidden button
|
||||
## would still take Enter).
|
||||
func _focus_start() -> void:
|
||||
if is_visible_in_tree():
|
||||
_start.grab_focus()
|
||||
|
||||
|
||||
## The results table as text, one row per category ("Crops 4 3 1"), for tests.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ extends Control
|
|||
## [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.
|
||||
|
||||
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.",
|
||||
|
|
@ -93,7 +94,7 @@ func _process(delta: float) -> void:
|
|||
return
|
||||
var s := sim.campaign.state
|
||||
if not enabled or dismissed or s.night != 1 or sim.campaign.is_over() or sim._menu_open() \
|
||||
or (sim.dialogue != null and sim.dialogue.is_playing()):
|
||||
or (sim.dialogue != null and sim.dialogue.is_playing()) or (sim.intro != null and sim.intro.busy()):
|
||||
_show("")
|
||||
return
|
||||
_check_done()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const SUITES := [
|
|||
"res://game/tests/test_look.gd",
|
||||
"res://game/tests/test_dialogue.gd",
|
||||
"res://game/tests/test_loading.gd",
|
||||
"res://game/tests/test_intro.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:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extends RefCounted
|
||||
## The whole game through its entry scene (main.tscn, with test save and settings paths): the
|
||||
## main menu over the paused farm; New vacation, Continue, and their questions; pausing freezes
|
||||
## main menu over the paused farm; New vacation (its opening intro, skipped here: test_intro
|
||||
## covers it), Continue, and their questions; pausing freezes
|
||||
## the simulation tick; settings apply and persist from the pause menu; Restart the night and
|
||||
## Save & quit to menu put the farm back at the saved morning without touching the save; a
|
||||
## damaged save can't be continued; quitting a hosted co-op game from the pause menu leaves the
|
||||
|
|
@ -62,6 +63,15 @@ func _press(action: String) -> void:
|
|||
await r.process_frame
|
||||
|
||||
|
||||
## New vacation's opening intro, skipped to its end (the first morning's sign).
|
||||
func _skip_intro() -> void:
|
||||
sim.intro.skip()
|
||||
var t := 0.0
|
||||
while sim.intro.busy() and t < 10.0:
|
||||
sim.intro.step(DT)
|
||||
t += DT
|
||||
|
||||
|
||||
func _hud_visible() -> bool:
|
||||
return (main.farm.get_node("Hud") as CanvasLayer).visible
|
||||
|
||||
|
|
@ -85,9 +95,12 @@ func _title_screen() -> void:
|
|||
"the UI theme is the project's default")
|
||||
main.main_menu.new_button.pressed.emit()
|
||||
var saved := SaveGame.read(SAVE)
|
||||
r.check(main.screen == Main.Screen.PLAYING and not r.paused and sim.intro.running and c.state.phase == P.MORNING,
|
||||
"New vacation (no save to replace) starts at once, with the opening intro")
|
||||
_skip_intro()
|
||||
r.check(main.screen == Main.Screen.PLAYING and not r.paused and _hud_visible() and c.state.phase == P.MORNING
|
||||
and sim.review_panel.visible and main.get_viewport().get_camera_3d() == sim.camera,
|
||||
"New vacation (no save to replace) starts at once: the morning screen, the HUD, the follow camera")
|
||||
"after it, the morning screen, the HUD, the follow camera")
|
||||
r.check(saved.status == SaveGame.Status.OK and saved.state.night == 1, "and saves the new vacation's first morning")
|
||||
|
||||
|
||||
|
|
@ -197,6 +210,7 @@ func _continue_and_new() -> void:
|
|||
main.main_menu.new_button.pressed.emit()
|
||||
r.check(main.screen == Main.Screen.PLAYING and SaveGame.read(SAVE).status == SaveGame.Status.OK,
|
||||
"New vacation doesn't ask about a damaged save and replaces it")
|
||||
_skip_intro()
|
||||
|
||||
|
||||
## Hosting co-op, the pause menu freezes only this scarecrow; quitting to the menu from it must
|
||||
|
|
@ -414,6 +428,7 @@ func _audio() -> void:
|
|||
r.check(audio._day.playing and audio._night.playing and (audio._day.stream as AudioStreamWAV).loop_mode == AudioStreamWAV.LOOP_FORWARD
|
||||
and audio._day.bus == &"Ambience", "the day and night ambience loop on the Ambience bus")
|
||||
main.new_vacation()
|
||||
_skip_intro()
|
||||
var before := audio.played.duplicate()
|
||||
var count := func(cue: String) -> int: return int(audio.played.get(cue, 0)) - int(before.get(cue, 0))
|
||||
sim.combat.fired.emit()
|
||||
|
|
|
|||
273
game/tests/test_intro.gd
Normal file
273
game/tests/test_intro.gd
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
extends RefCounted
|
||||
## The opening intro (OpeningIntro) through the game's entry scene (main.tscn, with test save and
|
||||
## settings paths): New vacation plays it, Continue and hosting co-op don't. Stepped through, it
|
||||
## visits every stage in order while it holds the farm (no morning sign, no HUD, the scarecrow
|
||||
## frozen on its post without its glow, the light forced), and it ends on the first morning's sign
|
||||
## (focused) with the farm exactly as new_campaign() leaves it. Skipping it from any stage
|
||||
## (pressing or holding), Restart the night, and Save & quit to menu leave it just as clean.
|
||||
|
||||
const SAVE := "user://test_intro_save.json"
|
||||
const SETTINGS := "user://test_intro_settings.cfg"
|
||||
const DT := 1.0 / 30.0
|
||||
const LIMIT := 120.0 # seconds of stepping before a run counts as stuck
|
||||
|
||||
var r: GameTestRunner
|
||||
var main: Main
|
||||
var sim: FarmSim
|
||||
var intro: OpeningIntro
|
||||
|
||||
|
||||
func run(p_r: GameTestRunner) -> void:
|
||||
r = p_r
|
||||
_clean()
|
||||
main = (load("res://game/scenes/main.tscn") as PackedScene).instantiate() as Main
|
||||
main.save_path = SAVE
|
||||
main.settings_path = SETTINGS
|
||||
r.root.add_child(main)
|
||||
await r.process_frame
|
||||
await r.physics_frame
|
||||
sim = main.sim
|
||||
intro = sim.intro
|
||||
intro.set_process(false) # stepped by hand
|
||||
await _new_and_continue()
|
||||
await _whole_intro()
|
||||
await _skips()
|
||||
await _hold_to_skip()
|
||||
await _restart_and_quit()
|
||||
await _hosting()
|
||||
main.queue_free()
|
||||
r.paused = false
|
||||
await r.process_frame
|
||||
_clean()
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
|
||||
|
||||
func _hud_visible() -> bool:
|
||||
return (main.farm.get_node("Hud") as CanvasLayer).visible
|
||||
|
||||
|
||||
## New vacation (from the menu; it asks over a save).
|
||||
func _new_vacation() -> void:
|
||||
main.main_menu.new_button.pressed.emit()
|
||||
if main.confirm.is_open:
|
||||
main.confirm.yes_button.pressed.emit()
|
||||
|
||||
|
||||
## Steps until the stage is `until` (or it's over); returns false if it never got there.
|
||||
func _step_to(until: String) -> bool:
|
||||
var t := 0.0
|
||||
while intro.stage != until and not intro.done and t < LIMIT:
|
||||
intro.step(DT)
|
||||
t += DT
|
||||
return intro.stage == until
|
||||
|
||||
|
||||
func _step_to_end() -> bool:
|
||||
var t := 0.0
|
||||
while intro.busy() and t < LIMIT:
|
||||
intro.step(DT)
|
||||
t += DT
|
||||
return intro.done
|
||||
|
||||
|
||||
## The farm held by the intro: no sign, no HUD, the intro's camera, the scarecrow frozen.
|
||||
func _held() -> bool:
|
||||
return intro.running and not sim.review_panel.visible and not _hud_visible() and sim.local_frozen \
|
||||
and not sim.player.input_enabled and not sim.player.is_physics_processing() \
|
||||
and main.get_viewport().get_camera_3d() != sim.camera
|
||||
|
||||
|
||||
## The farm as new_campaign() leaves it, and the first morning's sign up (focused).
|
||||
func _check_clean(what: String) -> void:
|
||||
var p := sim.player
|
||||
var dn := sim.day_night
|
||||
var morning := DayNight.morning()
|
||||
var light := dn.forced == "" and not dn.lanterns_dark and is_equal_approx(float(dn.current["elev"]), float(morning["elev"])) \
|
||||
and is_equal_approx(float(dn.current["energy"]), float(morning["energy"])) \
|
||||
and is_equal_approx(float(dn.target()["energy"]), float(morning["energy"]))
|
||||
var body := p.global_position.distance_to(OpeningIntro.START) < 0.01 and is_zero_approx(p.model.rotation.y) \
|
||||
and p.is_physics_processing() and p.input_enabled and not sim.local_frozen and p.core_glow.visible \
|
||||
and p.find_children("*", "LookAtModifier3D", true, false).is_empty() and sim.scarecrow.alive and sim.combat.show_marker
|
||||
var gone := intro.done and not intro.running and intro.stage == "end" and intro.get_child_count() == 0
|
||||
var screen := _hud_visible() and main.get_viewport().get_camera_3d() == sim.camera and sim.review_panel.visible \
|
||||
and sim.campaign.state.phase == CampaignController.Phase.MORNING and sim.campaign.state.night == 1
|
||||
var sound := sim.audio.focus == p and not sim.audio.scene and sim.audio.music_track == "farm"
|
||||
await r.process_frame
|
||||
await r.process_frame
|
||||
var focus := sim.review_panel._start.has_focus()
|
||||
r.check(gone and body and light and screen and sound and focus,
|
||||
"%s: the farm's as new_campaign() left it (intro gone %s, scarecrow at its start with input and glow %s, the morning light %s, HUD / game camera / sign %s, sounds %s, Start focused %s)"
|
||||
% [what, gone, body, light, screen, sound, focus])
|
||||
|
||||
|
||||
## New vacation plays it, holding the farm; Save & quit to menu takes it down; Continue doesn't
|
||||
## play it.
|
||||
func _new_and_continue() -> void:
|
||||
_new_vacation()
|
||||
r.check(main.screen == Main.Screen.PLAYING and intro.running and intro.stage == "leave" and _held(),
|
||||
"New vacation starts the intro: no sign, no HUD, its own camera, the scarecrow frozen")
|
||||
var p := sim.player
|
||||
var on_post := absf(p.global_position.y - OpeningIntro.POST_LIFT) < 0.2 and not p.core_glow.visible \
|
||||
and not p.animation_player.is_playing() and sim.day_night.forced == "morning" and sim.day_night.lanterns_dark \
|
||||
and not sim.scarecrow.alive and not sim.combat.show_marker
|
||||
r.check(on_post, "the scarecrow hangs on its post (raised, T-pose: no animation), not alive yet (no chest glow, fear ring, or aim marker), a forced morning, lantern dark")
|
||||
var at := p.global_position
|
||||
Input.action_press(&"move_forward")
|
||||
for i in 6:
|
||||
await r.physics_frame
|
||||
Input.action_release(&"move_forward")
|
||||
r.check(p.global_position == at and intro.running, "and the scarecrow can't move")
|
||||
r.check(not sim.tutorial._box.visible, "no tips meanwhile")
|
||||
main.to_menu()
|
||||
r.check(main.screen == Main.Screen.MENU and not intro.busy() and intro.get_child_count() == 0 and not sim.local_frozen
|
||||
and sim.player.is_physics_processing() and sim.day_night.forced == "" and sim.player.core_glow.visible,
|
||||
"Save & quit to menu mid-intro: nothing of it left, the scarecrow given back")
|
||||
main.main_menu.continue_button.pressed.emit()
|
||||
r.check(main.screen == Main.Screen.PLAYING and not intro.busy() and sim.review_panel.visible and _hud_visible(),
|
||||
"Continue plays no intro: straight to the saved morning's sign")
|
||||
main.to_menu()
|
||||
|
||||
|
||||
## The whole intro, stepped: every stage in order, the farm held until it's handed back.
|
||||
func _whole_intro() -> void:
|
||||
var audio := sim.audio
|
||||
var before := audio.played.duplicate()
|
||||
var count := func(cue: String) -> int: return int(audio.played.get(cue, 0)) - int(before.get(cue, 0))
|
||||
var fired: Array[int] = [0]
|
||||
var on_finished := func() -> void: fired[0] += 1
|
||||
intro.finished.connect(on_finished)
|
||||
_new_vacation()
|
||||
var stinger := false
|
||||
for v in audio._voices_ui:
|
||||
stinger = stinger or (v.playing and v.get_meta(&"cue", "") == "morning")
|
||||
r.check(count.call("morning") == 1 and not stinger, "new_campaign()'s morning stinger is stopped under the intro")
|
||||
var seen: Array[String] = [intro.stage]
|
||||
var length := {intro.stage: 0.0}
|
||||
var held := true
|
||||
var night_ok := false
|
||||
var part_ok := false
|
||||
var flash_ok := false
|
||||
var t := 0.0
|
||||
while intro.busy() and t < LIMIT:
|
||||
intro.step(DT)
|
||||
t += DT
|
||||
if intro.stage != seen[-1]:
|
||||
seen.append(intro.stage)
|
||||
length[intro.stage] = 0.0
|
||||
match intro.stage:
|
||||
"flight":
|
||||
night_ok = sim.day_night.forced == "night" and sim.day_night.lanterns_dark and intro._ufo.visible \
|
||||
and audio.music_track == "" and audio._ambience_target == Vector2(0.0, 1.0)
|
||||
"flash":
|
||||
part_ok = intro._part.visible and intro._part.global_position.distance_to(OpeningIntro.START + OpeningIntro.FACING * 0.8) < 0.3
|
||||
"uh_oh":
|
||||
flash_ok = sim.player.core_glow.visible and not sim.day_night.lanterns_dark \
|
||||
and absf(sim.player.global_position.y - intro._ground) < 0.01 and not intro._part.visible
|
||||
else:
|
||||
length[intro.stage] = float(length[intro.stage]) + DT
|
||||
if intro.running and not _held():
|
||||
held = false
|
||||
r.check(seen == OpeningIntro.STAGES, "it visits every stage in order (%s)" % [seen])
|
||||
r.check(held, "and holds the farm all along (no sign, no HUD, the scarecrow frozen) until it's handed back")
|
||||
r.check(night_ok, "the night falls under the card: forced night, the lantern dark, the UFO up, night ambience, no music")
|
||||
r.check(part_ok, "the part lands in front of the scarecrow")
|
||||
r.check(flash_ok, "after the flash the scarecrow is down off its post, glowing, its lantern lit, the part gone into it")
|
||||
r.check(fired[0] == 1 and t > 50.0 and t < 100.0, "finished once, %.1f s in all" % t)
|
||||
var parts := PackedStringArray()
|
||||
for s: String in seen:
|
||||
parts.append("%s %.1f" % [s, float(length[s])])
|
||||
r.info("intro stages (s): %s; %.1f s in all" % [", ".join(parts), t])
|
||||
var cues := ["door_creak", "car_door", "horn", "ufo_whine", "part_fall", "life_flash", "ufo_zoom", "morning"]
|
||||
var counts := []
|
||||
for c: String in cues:
|
||||
counts.append(count.call(c))
|
||||
r.check(counts == [1, 2, 1, 1, 1, 1, 1, 2], "its sounds: %s = %s (the morning stinger with the sign)" % [cues, counts])
|
||||
intro.finished.disconnect(on_finished)
|
||||
await _check_clean("at the end")
|
||||
main.to_menu()
|
||||
|
||||
|
||||
## A skip from any stage fades straight to the sign, the farm just as clean.
|
||||
func _skips() -> void:
|
||||
for stage in OpeningIntro.STAGES:
|
||||
if stage == "end":
|
||||
continue
|
||||
_new_vacation()
|
||||
var got := _step_to(stage)
|
||||
var t := 0.0
|
||||
while got and intro.stage == stage and t < 0.6:
|
||||
intro.step(DT)
|
||||
t += DT
|
||||
var at := intro.stage
|
||||
intro.skip()
|
||||
var ended := _step_to_end()
|
||||
r.check(got and ended and intro._loading == null, "a skip in %s ends it" % at)
|
||||
await _check_clean("skipped in " + at)
|
||||
main.to_menu()
|
||||
|
||||
|
||||
## Holding Space / Enter / A for a second skips it (a key already down at the start doesn't).
|
||||
func _hold_to_skip() -> void:
|
||||
Input.action_press(&"ui_accept")
|
||||
_new_vacation()
|
||||
for i in 45:
|
||||
intro.step(DT)
|
||||
var ignored := not intro._skipping
|
||||
Input.action_release(&"ui_accept")
|
||||
intro.step(DT)
|
||||
Input.action_press(&"ui_accept")
|
||||
for i in 20:
|
||||
intro.step(DT)
|
||||
var early := intro._skipping
|
||||
for i in 12:
|
||||
intro.step(DT)
|
||||
var skipping := intro._skipping
|
||||
Input.action_release(&"ui_accept")
|
||||
_step_to_end()
|
||||
r.check(ignored and not early and skipping, "holding [Space / Enter / A] a second skips (a key held from the menu doesn't count)")
|
||||
await _check_clean("held to skip")
|
||||
main.to_menu()
|
||||
|
||||
|
||||
## The pause menu over it: Restart the night skips it; Save & quit to menu takes it down.
|
||||
func _restart_and_quit() -> void:
|
||||
_new_vacation()
|
||||
var morning := SaveGame.read(SAVE).state.to_dict()
|
||||
_step_to("flight")
|
||||
main.pause()
|
||||
r.check(main.screen == Main.Screen.PAUSED and r.paused and intro._box.is_blocked(), "Escape pauses it (its box waits)")
|
||||
main.pause_menu.restart_button.pressed.emit()
|
||||
main.confirm.yes_button.pressed.emit()
|
||||
r.check(main.screen == Main.Screen.PLAYING and not r.paused and intro._skipping and sim.local_frozen,
|
||||
"Restart the night during it skips it (still held while it fades)")
|
||||
_step_to_end()
|
||||
await _check_clean("restarted")
|
||||
r.check(JSON.stringify(SaveGame.read(SAVE).state.to_dict()) == JSON.stringify(morning), "the save is still the first morning")
|
||||
main.to_menu()
|
||||
_new_vacation()
|
||||
_step_to("uh_oh")
|
||||
main.pause()
|
||||
main.pause_menu.menu_button.pressed.emit()
|
||||
var p := sim.player
|
||||
r.check(main.screen == Main.Screen.MENU and not intro.busy() and intro.get_child_count() == 0 and not sim.local_frozen
|
||||
and p.global_position.distance_to(OpeningIntro.START) < 0.01 and p.is_physics_processing() and p.core_glow.visible
|
||||
and p.find_children("*", "LookAtModifier3D", true, false).is_empty() and sim.day_night.forced == ""
|
||||
and not sim.day_night.lanterns_dark and not sim.audio.scene, "Save & quit to menu late in it leaves nothing behind")
|
||||
|
||||
|
||||
## Hosting co-op starts the vacation without the intro.
|
||||
func _hosting() -> void:
|
||||
var gd := main.lobby.gdsync
|
||||
main.lobby.gdsync = null # (no network in the test: the lobby just fails)
|
||||
main._host_coop(CoopLobby.Mode.LAN, "Ana", false)
|
||||
if main.confirm.is_open:
|
||||
main.confirm.yes_button.pressed.emit()
|
||||
r.check(main.screen == Main.Screen.PLAYING and not intro.busy() and sim.review_panel.visible and _hud_visible()
|
||||
and not sim.local_frozen, "hosting co-op starts a new vacation without the intro")
|
||||
main.lobby.gdsync = gd
|
||||
main.to_menu()
|
||||
1
game/tests/test_intro.gd.uid
Normal file
1
game/tests/test_intro.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cn413pm2x21au
|
||||
96
game/tools/capture_intro.gd
Normal file
96
game/tools/capture_intro.gd
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
extends SceneTree
|
||||
## Captures the opening intro (OpeningIntro) for review: runs the real game (main.tscn, so the
|
||||
## toon look and the pixel outlines are on, as ToonLook comes with Main) in a window, starts a New
|
||||
## vacation, and saves a PNG at the start of every stage and every --every seconds of it, then one
|
||||
## of the first morning's sign, and quits. It needs a window (not --headless) and must not run
|
||||
## fullscreen (the project's default), so pass --windowed and a resolution; a hidden window with
|
||||
## VSync on crawls on some desktops, so keep it visible and pass --disable-vsync. --fixed-fps
|
||||
## makes every frame the same game time, so the shots don't depend on the machine's speed:
|
||||
## godot --path . --windowed --resolution 1600x900 --disable-vsync --fixed-fps 30 \
|
||||
## --script res://game/tools/capture_intro.gd -- --out=/tmp/hs-intro --every=2
|
||||
## Options (after --): --out=dir (default /tmp/hs-intro/), --every=seconds (default 2; 0: stage
|
||||
## starts only), --prefix=text (default "intro"), --skip-at=stage (skips half a second into that
|
||||
## stage, to look at the skip). It saves to its own user://capture_intro_* files, so the player's
|
||||
## save and settings are never touched.
|
||||
|
||||
const SAVE := "user://capture_intro_save.json"
|
||||
const SETTINGS := "user://capture_intro_settings.cfg"
|
||||
const LIMIT := 240.0 # seconds of intro before giving up
|
||||
|
||||
var _out := "/tmp/hs-intro/"
|
||||
var _every := 2.0
|
||||
var _prefix := "intro"
|
||||
var _skip_at := ""
|
||||
var _count: int = 0
|
||||
|
||||
|
||||
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("--every="):
|
||||
_every = float(arg.trim_prefix("--every="))
|
||||
elif arg.begins_with("--prefix="):
|
||||
_prefix = arg.trim_prefix("--prefix=")
|
||||
elif arg.begins_with("--skip-at="):
|
||||
_skip_at = arg.trim_prefix("--skip-at=")
|
||||
if not _out.ends_with("/"):
|
||||
_out += "/"
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
DirAccess.make_dir_recursive_absolute(_out)
|
||||
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
|
||||
main.new_vacation()
|
||||
var intro := main.sim.intro if main.sim != null else null
|
||||
if intro == null or not intro.busy():
|
||||
printerr("capture_intro: the intro didn't start")
|
||||
quit(1)
|
||||
return
|
||||
var last := ""
|
||||
var next_shot := 0.0
|
||||
var skipped := false
|
||||
while intro.busy() and intro.elapsed < LIMIT:
|
||||
await process_frame
|
||||
if intro.stage != last:
|
||||
last = intro.stage
|
||||
await _shot(intro, "start")
|
||||
elif _every > 0.0 and intro.elapsed >= next_shot:
|
||||
next_shot = intro.elapsed + _every
|
||||
await _shot(intro, "")
|
||||
if _skip_at != "" and not skipped and intro.stage == _skip_at and intro.elapsed > 0.0:
|
||||
skipped = true
|
||||
for i in 15:
|
||||
await process_frame
|
||||
intro.skip()
|
||||
for i in 30: # the sign settles
|
||||
await process_frame
|
||||
await _shot(intro, "sign")
|
||||
print("capture_intro: %d shots in %s (%.1f s of intro)" % [_count, _out, intro.elapsed])
|
||||
main.queue_free()
|
||||
await process_frame
|
||||
await create_timer(0.3).timeout
|
||||
_clean()
|
||||
quit()
|
||||
|
||||
|
||||
func _shot(intro: OpeningIntro, tag: String) -> void:
|
||||
await RenderingServer.frame_post_draw
|
||||
var image := root.get_texture().get_image()
|
||||
var stage := intro.stage if intro.stage != "" else "none"
|
||||
var file := "%s%s_%03d_%05.1fs_%s%s.png" % [_out, _prefix, _count, intro.elapsed, stage, "_" + tag if tag != "" else ""]
|
||||
image.save_png(file)
|
||||
_count += 1
|
||||
|
||||
|
||||
func _clean() -> void:
|
||||
for p in [SAVE, SAVE + ".tmp", SETTINGS]:
|
||||
if FileAccess.file_exists(p):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(p))
|
||||
1
game/tools/capture_intro.gd.uid
Normal file
1
game/tools/capture_intro.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://tmmr78wn70ce
|
||||
Loading…
Add table
Add a link
Reference in a new issue