Merge #31: intro speakers and conversations
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fe08f6602c
8 changed files with 286 additions and 6 deletions
|
|
@ -6,10 +6,20 @@ extends RefCounted
|
|||
## night's phase and delay, pauses the farm for it and lets it go after, puts the morning sign
|
||||
## aside meanwhile, doesn't replay it on a retry but does on a new vacation,
|
||||
## takes it down on a new morning, plays several in order, waits under a menu, and lets one that
|
||||
## doesn't pause the game go on by itself.
|
||||
## doesn't pause the game go on by itself. The opening intro's conversations (dialogue/intro/)
|
||||
## have their lines and speakers and never play by themselves; the farmer's and his wife's heads
|
||||
## (Sketch icons) draw.
|
||||
|
||||
const P := CampaignController.Phase
|
||||
const DT := 1.0 / 60.0
|
||||
const INTRO := "res://game/resources/dialogue/intro/"
|
||||
const SPEAKERS := "res://game/resources/dialogue/speakers/"
|
||||
## The intro's conversations: who says each line, in order.
|
||||
const INTRO_LINES := {
|
||||
"departure": ["Farmer", "Farmer's Wife", "Farmer"],
|
||||
"flight": ["Little Green Alien", "Big Green Alien", "Little Green Alien", "Big Green Alien", "Little Green Alien"],
|
||||
"uh_oh": ["Big Green Alien", "Little Green Alien"],
|
||||
}
|
||||
|
||||
var r: GameTestRunner
|
||||
var sim: FarmSim
|
||||
|
|
@ -23,6 +33,8 @@ var scarecrow: DialogueSpeaker
|
|||
func run(p_r: GameTestRunner) -> void:
|
||||
r = p_r
|
||||
_saved()
|
||||
_intro()
|
||||
await _heads_draw()
|
||||
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
|
||||
r.root.add_child(farm)
|
||||
await r.process_frame
|
||||
|
|
@ -64,8 +76,67 @@ func _saved() -> void:
|
|||
if line == null or line.text.strip_edges() == "":
|
||||
bad.append(conv.resource_path)
|
||||
r.check(bad.is_empty(), "every saved conversation has lines with words and plays within the vacation (bad: %s)" % [bad])
|
||||
r.check(DialogueDirector.load_all("res://game/resources/dialogue/speakers/").is_empty(),
|
||||
"a speaker's file isn't taken for a conversation")
|
||||
r.check(DialogueDirector.load_all(SPEAKERS).is_empty(), "a speaker's file isn't taken for a conversation")
|
||||
|
||||
|
||||
## The intro's conversations load with their lines and speakers, wait for the intro to play them
|
||||
## (off, in a subfolder), and their speakers stand where they should.
|
||||
func _intro() -> void:
|
||||
for n: String in INTRO_LINES:
|
||||
var conv := load(INTRO.path_join(n + ".tres")) as Conversation
|
||||
if conv == null:
|
||||
r.check(false, "intro/%s.tres loads as a Conversation" % n)
|
||||
continue
|
||||
var who: Array[String] = []
|
||||
for line in conv.lines:
|
||||
who.append(line.speaker.display_name if line != null and line.speaker != null and line.text.strip_edges() != "" else "?")
|
||||
r.check(who == INTRO_LINES[n], "intro/%s: its lines by %s (got %s)" % [n, INTRO_LINES[n], who])
|
||||
r.check(not conv.enabled and conv.pause_game and is_equal_approx(conv.auto_advance, 1.6),
|
||||
"intro/%s is off (only the intro plays it), pauses (takes the taps), and goes on after 1.6 s" % n)
|
||||
var paths: Array[String] = []
|
||||
for conv in DialogueDirector.load_all(DialogueDirector.DIR):
|
||||
paths.append(conv.resource_path.get_file())
|
||||
r.check(paths == ["morning_day_2.tres"], "the director still plays only morning_day_2 by itself, not the intro's (got %s)" % [paths])
|
||||
r.check(DialogueDirector.load_all(INTRO).is_empty(), "and even loaded from intro/ they're off")
|
||||
var big := load(SPEAKERS + "big_green_alien.tres") as DialogueSpeaker
|
||||
var little := load(SPEAKERS + "little_green_alien.tres") as DialogueSpeaker
|
||||
var farmer := load(SPEAKERS + "farmer.tres") as DialogueSpeaker
|
||||
var wife := load(SPEAKERS + "farmers_wife.tres") as DialogueSpeaker
|
||||
r.check(big != null and little != null and farmer != null and wife != null, "the intro's speakers load")
|
||||
if big == null or little == null or farmer == null or wife == null:
|
||||
return
|
||||
r.check(big.icon == little.icon and big.portrait_height > little.portrait_height and big.voice_pitch < little.voice_pitch,
|
||||
"the Big Green Alien is the little one's head, bigger (%d px), with a lower voice" % big.portrait_height)
|
||||
r.check(farmer.icon == "farmer" and wife.icon == "farmers_wife" and farmer.voice_pitch < wife.voice_pitch,
|
||||
"the farmer and his wife have their own heads; his voice is the lower")
|
||||
r.check(farmer.side == DialogueSpeaker.HeadSide.LEFT and wife.side == DialogueSpeaker.HeadSide.RIGHT
|
||||
and big.side == DialogueSpeaker.HeadSide.RIGHT and little.side == DialogueSpeaker.HeadSide.LEFT,
|
||||
"the farmer and the little alien on the left, his wife and the big alien on the right")
|
||||
var no_head: Array[String] = []
|
||||
for f in ResourceLoader.list_directory(SPEAKERS):
|
||||
var sp := load(SPEAKERS + f) as DialogueSpeaker
|
||||
if sp != null and sp.portrait == null and not Sketch.ICONS.has(sp.icon):
|
||||
no_head.append(f)
|
||||
r.check(no_head.is_empty(), "every speaker has a head: a portrait or a Sketch icon (none: %s)" % [no_head])
|
||||
|
||||
|
||||
## The farmer's and his wife's heads are Sketch icons and draw (big, and HUD-small) without error.
|
||||
func _heads_draw() -> void:
|
||||
var ids: Array[String] = ["farmer", "farmers_wife"]
|
||||
r.check(Sketch.ICONS.has("farmer") and Sketch.ICONS.has("farmers_wife"), "the farmer and his wife are Sketch icons")
|
||||
var drawn: Array[String] = []
|
||||
var canvas := Control.new()
|
||||
canvas.size = Vector2(400.0, 400.0)
|
||||
canvas.draw.connect(func() -> void:
|
||||
for id in ids:
|
||||
Sketch.icon(canvas, id, Rect2(Vector2.ZERO, Vector2(380.0, 380.0)))
|
||||
Sketch.icon(canvas, id, Rect2(Vector2(10.0, 10.0), Vector2(40.0, 40.0)))
|
||||
drawn.append(id))
|
||||
r.root.add_child(canvas)
|
||||
await r.process_frame
|
||||
await r.process_frame
|
||||
r.check(drawn == ids, "their heads draw without an error (drew %s)" % [drawn])
|
||||
canvas.queue_free()
|
||||
|
||||
|
||||
func _writing() -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue