#36: prompts in touch words

Prompts (game/scripts/prompts.gd) holds every key-naming prompt: on a phone
(MobilePort.active()) it says each in touch words, elsewhere exactly the old
string. World labels drop the key (Gather, Repair, Upgrade to, Upgrades, Shop),
the build ghost says Place / Dismantle, the build bar's line is
"Place · Rotate · Dismantle · Done" and its slots drop the number keys, the
cutscenes say "Hold to skip" / "Tap to skip", the tip footer says
"× hides tips", and the tutorial's tips and the first morning's sign name the
thumbs (sides from TouchSticks), Use, Build, Place, Fear, Bomb, Patch, the
hotbar, and the backpack. MobilePort gains the `forced` test override.
game/tests/mobile/prompts_test.gd checks every phone string and that the
desktop strings are byte for byte as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-14 14:30:26 -04:00
parent f0291133fd
commit 9f4a1895bd
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.
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:
@ -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), "%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)
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)

View file

@ -184,11 +184,13 @@ 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[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.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.modulate = Color(0.85, 0.95, 1.0)
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)
else:
_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)
if sim.audio != null:
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
_set_hud(false)

View file

@ -330,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 "[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
@ -415,7 +415,7 @@ func _process(delta: float) -> void:
prompt = "Gathering..."
elif n == focus:
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)
if workbench != null and show_labels:
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"])
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 "[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
_upgrade_label.visible = 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).
## 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()

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)
## and the loading screen over it.
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.caption.visible = false
_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"
_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,
"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.",
Prompts.sign_day(),
Prompts.sign_night(),
])
else:
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
if Upgrades.owned(campaign.state, id):
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]

View file

@ -12,6 +12,8 @@ extends Control
## 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.",
@ -81,7 +83,7 @@ func _ready() -> void:
_text.add_theme_font_size_override("font_size", 24)
col.add_child(_text)
_hint = Label.new()
_hint.text = "Tip · [Backspace / Back] hide tips"
_hint.text = Prompts.tip_footer()
_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))
@ -166,7 +168,7 @@ func _show(id: String) -> void:
_box.visible = id != ""
if id == "":
return
_text.text = TEXT[id]
_text.text = Prompts.tip(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)

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"
return
_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),
Upgrades.levels_total(campaign.config)]