Merge #36: prompts in touch words

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-14 14:32:12 -04:00
commit fac806f0cc
14 changed files with 368 additions and 16 deletions

View file

@ -36,7 +36,7 @@ func _process(_delta: float) -> void:
## The controls line, as shown. ## The controls line, as shown.
func help_text() -> String: func help_text() -> String:
return "LMB / RT build · Z C / d-pad rotate · 1-4 / Tab pick · RMB / B dismantle or leave" return Prompts.build_help()
func _draw() -> void: 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) Sketch.box(self, rect, Sketch.SLOT, Sketch.INK, 2.5, 810.0 + i * 3.0)
if picked: if picked:
Sketch.box(self, rect.grow(2.0), Color(0, 0, 0, 0), Sketch.GOLD, 3.5, 830.0 + i) 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), "%d %s" % [i + 1, StructureSystem.NAMES[t]], 28, Sketch.TEXT, Sketch.text(self, rect.position + Vector2(12.0, 4.0), Prompts.build_slot(i + 1, StructureSystem.NAMES[t]), 28, Sketch.TEXT,
HORIZONTAL_ALIGNMENT_LEFT, 6) HORIZONTAL_ALIGNMENT_LEFT, 6)
Sketch.text(self, rect.position + Vector2(12.0, 42.0), ResourceStore.describe(cost), 22, 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) Sketch.TEXT if r.can_afford(cost, slot) else SHORT, HORIZONTAL_ALIGNMENT_LEFT, 6)

View file

@ -184,11 +184,13 @@ func _process(_delta: float) -> void:
for m in cost: for m in cost:
if floori(int(cost[m]) * config.dismantle_refund) > 0: if floori(int(cost[m]) * config.dismantle_refund) > 0:
refund[m] = floori(int(cost[m]) * config.dismantle_refund) refund[m] = floori(int(cost[m]) * config.dismantle_refund)
_label.text = "%s %d/%d\n[RMB / B] Dismantle%s" % [StructureSystem.NAMES.get(e.get("type", ""), ""), int(e.get("hp", 0)), _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")), (" (+%s)" % ResourceStore.describe(refund)) if not refund.is_empty() else ""] structures.max_hp(e.get("type", "fence")), Prompts.dismantle(),
(" (+%s)" % ResourceStore.describe(refund)) if not refund.is_empty() else ""]
_label.modulate = Color(0.85, 0.95, 1.0) _label.modulate = Color(0.85, 0.95, 1.0)
elif ok: elif ok:
_label.text = "%s %s\n[LMB / RT] Build" % [StructureSystem.NAMES[type()], ResourceStore.describe(config.costs.get(type(), {}))] _label.text = "%s %s\n%s" % [StructureSystem.NAMES[type()], ResourceStore.describe(config.costs.get(type(), {})),
Prompts.build_place()]
_label.modulate = Color(0.7, 1.0, 0.7) _label.modulate = Color(0.7, 1.0, 0.7)
else: else:
_label.text = "%s\n%s" % [StructureSystem.NAMES[type()], reason] _label.text = "%s\n%s" % [StructureSystem.NAMES[type()], reason]

View file

@ -101,7 +101,7 @@ func start() -> void:
CutsceneKit.follow_camera(_camera, _car, 1.0) CutsceneKit.follow_camera(_camera, _car, 1.0)
if sim.audio != null: if sim.audio != null:
sim.audio.focus = _car sim.audio.focus = _car
_overlay = CutsceneKit.make_letterbox(self, "The farmers are on their way home", "[Space / Enter / A] skip") _overlay = CutsceneKit.make_letterbox(self, "The farmers are on their way home", Prompts.return_skip())
_caption = _overlay.caption _caption = _overlay.caption
_set_hud(false) _set_hud(false)

View file

@ -330,7 +330,7 @@ func _upgrade_prompt(id: int) -> String:
return "Upgrading is for daytime" return "Upgrading is for daytime"
var why := structures.upgrade_blocker(id, kit.slot) var why := structures.upgrade_blocker(id, kit.slot)
if why == "": if why == "":
return "[E / X] Upgrade to L%d (%s)" % [structures.level_of(id) + 1, ResourceStore.describe(structures.upgrade_cost(id))] return Prompts.upgrade_to(structures.level_of(id) + 1, ResourceStore.describe(structures.upgrade_cost(id)))
return why return why
@ -415,7 +415,7 @@ func _process(delta: float) -> void:
prompt = "Gathering..." prompt = "Gathering..."
elif n == focus: elif n == focus:
var why := _blocker(n) var why := _blocker(n)
prompt = "[E / X] Gather" if why == "" else why prompt = Prompts.gather() if why == "" else why
n.show_state(charges(n), near and kit.alive, prompt) n.show_state(charges(n), near and kit.alive, prompt)
if workbench != null and show_labels: if workbench != null and show_labels:
var granted := structures != null and structures.has_workbench() var granted := structures != null and structures.has_workbench()
@ -432,7 +432,7 @@ func _process(delta: float) -> void:
_repair_label.global_position = Vector3(e["x"], 2.7, e["z"]) _repair_label.global_position = Vector3(e["x"], 2.7, e["z"])
var cost := structures.repair_cost(shown) 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"]), _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 "[E / X] Repair (%s)" % ResourceStore.describe(cost)] "Repairing..." if repairing >= 0 else Prompts.repair(ResourceStore.describe(cost))]
var ushown := (upgrading if upgrading >= 0 else upgrade_target) if show_labels else -1 var ushown := (upgrading if upgrading >= 0 else upgrade_target) if show_labels else -1
_upgrade_label.visible = ushown >= 0 _upgrade_label.visible = ushown >= 0
if ushown >= 0: if ushown >= 0:

View file

@ -13,7 +13,13 @@ extends RefCounted
## on, to see the phone build without a phone (add --rendering-method mobile for its renderer). ## 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: static func active() -> bool:
if forced >= 0:
return forced == 1
return OS.has_feature("mobile") or "--mobile" in OS.get_cmdline_user_args() return OS.has_feature("mobile") or "--mobile" in OS.get_cmdline_user_args()

View file

@ -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) ## The overlay (letterbox, the skip hint and its ring, the box, the flash, the black, the card)
## and the loading screen over it. ## and the loading screen over it.
func _build_screen() -> void: func _build_screen() -> void:
_overlay = CutsceneKit.make_letterbox(self, "", "Hold [Space / Enter / A] to skip", 5) _overlay = CutsceneKit.make_letterbox(self, "", Prompts.intro_skip(), 5)
_overlay.name = "Overlay" _overlay.name = "Overlay"
_overlay.caption.visible = false _overlay.caption.visible = false
_ring = SkipRing.new() _ring = SkipRing.new()

134
game/scripts/prompts.gd Normal file
View file

@ -0,0 +1,134 @@
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".
## #38 points this at TouchSticks' move_on_right variable (which #41's Swap setting flips).
static func move_side() -> String:
return "right" if TouchSticks.MOVE_ON_RIGHT 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."

View file

@ -0,0 +1 @@
uid://d5ghg35h8m5

View file

@ -167,8 +167,8 @@ func refresh() -> void:
_title.text = "The farmers are away" _title.text = "The farmers are away"
_intro.text = "\n".join([ _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, "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.", Prompts.sign_day(),
"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.", Prompts.sign_night(),
]) ])
else: else:
var e: Dictionary = s.night_log[s.night_log.size() - 1] var e: Dictionary = s.night_log[s.night_log.size() - 1]

View file

@ -38,5 +38,5 @@ func show_state(campaign: CampaignController, show: bool, focused: bool) -> void
total += 1 total += 1
if Upgrades.owned(campaign.state, id): if Upgrades.owned(campaign.state, id):
done += 1 done += 1
var hint := ("[E / X] Shop" if campaign.is_daytime() else "Shop by day") if focused else "Shop" var hint := (Prompts.shop() if campaign.is_daytime() else "Shop by day") if focused else "Shop"
_label.text = "%s\n%d of %d done" % [hint, done, total] _label.text = "%s\n%d of %d done" % [hint, done, total]

View file

@ -12,6 +12,8 @@ extends Control
## them. ## them.
## None show while a talking-head conversation or the opening intro is up. ## 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 := { 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.", "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.", "gather": "Hold [E / X] at a dead tree, the haystacks, or the scrap heap to gather wood, straw, and scrap.",
@ -81,7 +83,7 @@ func _ready() -> void:
_text.add_theme_font_size_override("font_size", 24) _text.add_theme_font_size_override("font_size", 24)
col.add_child(_text) col.add_child(_text)
_hint = Label.new() _hint = Label.new()
_hint.text = "Tip · [Backspace / Back] hide tips" _hint.text = Prompts.tip_footer()
_hint.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER _hint.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_hint.add_theme_font_size_override("font_size", 16) _hint.add_theme_font_size_override("font_size", 16)
_hint.add_theme_color_override("font_color", Color(0.7, 0.72, 0.65)) _hint.add_theme_color_override("font_color", Color(0.7, 0.72, 0.65))
@ -166,7 +168,7 @@ func _show(id: String) -> void:
_box.visible = id != "" _box.visible = id != ""
if id == "": if id == "":
return return
_text.text = TEXT[id] _text.text = Prompts.tip(id)
_text.remove_theme_color_override("font_color") _text.remove_theme_color_override("font_color")
_box.reset_size() _box.reset_size()
_box.position = Vector2((size.x - _box.size.x) * 0.5, size.y - 250.0 - _box.size.y) _box.position = Vector2((size.x - _box.size.x) * 0.5, size.y - 250.0 - _box.size.y)

View file

@ -42,6 +42,6 @@ func show_state(campaign: CampaignController, show: bool, focused: bool, broken:
_label.text = "Broken -- repair it" if focused else "Broken" _label.text = "Broken -- repair it" if focused else "Broken"
return return
_label.modulate = NORMAL_COLOR _label.modulate = NORMAL_COLOR
var hint := ("[E / X] Upgrades" if campaign.is_daytime() else "Upgrades by day") if focused else "Upgrades" var hint := (Prompts.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), _label.text = "%s\n%d of %d levels" % [hint, Upgrades.levels_bought(campaign.config, campaign.state),
Upgrades.levels_total(campaign.config)] Upgrades.levels_total(campaign.config)]

View file

@ -0,0 +1,206 @@
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

View file

@ -0,0 +1 @@
uid://bym4d52rn3d40