#38: touch action buttons

TouchButtons (phones only, Main adds it beside TouchSticks): Pause, Fear, Bomb,
Patch, Use (word from the new read-only Interactions.focus_info()) and Build,
round Sketch buttons that press the existing actions for at least one physics
tick, shown only when they can do something and hidden whenever the tree is
paused or a menu, panel or sign is up. Columns follow TouchSticks.move_on_right
(now a variable); both join "touch_controls" with apply_settings (Swap sticks),
which Main calls at startup; Prompts.move_side() reads the live sticks. Stick
fingers keep their drags over buttons. New Sketch icons: fear, patch, use,
build, pause. Test: game/tests/mobile/buttons_test.gd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-14 15:25:57 -04:00
parent 5392ae09af
commit e435b76aa2
9 changed files with 1115 additions and 48 deletions

View file

@ -5,7 +5,8 @@ extends Node3D
## Nothing here works in build mode.
## * Focus: the nearest gather point, workbench, or shed counter within its reach, preferring
## gather points with charges left over used-up ones; nearby points show their charges, the
## focused one its prompt (or why it can't be used).
## focused one its prompt (or why it can't be used). focus_info() says what interact would
## act on, read-only, for the phone's Use button (TouchButtons).
## * Gather: hold interact by day (D8) at a point with charges left and room in the pouch for
## the whole yield (so a charge is never half wasted).
## The scarecrow is rooted for gather_time looping the point's clip, then yield_amount goes
@ -53,6 +54,8 @@ const POPUP_TIME := 1.1
const POPUPS := 6
## Seconds a partner's press of interact waits (on the host) for its copy to reach a counter.
const PRESS_WINDOW := 0.3
## The phone's Use button's word for each kind of focus_info().
const FOCUS_LABELS := {"gather": "Gather", "repair": "Repair", "upgrade": "Upgrade", "workbench": "Workbench", "shed": "Shop"}
var config: GameConfig
var campaign: CampaignController
@ -162,6 +165,47 @@ func can_shoot() -> bool:
and not (shed_panel != null and shed_panel.is_open) and not (remote != null and remote.ui_open)
## What interact would act on now (the phone's Use button, TouchButtons; read-only, as of the
## last step): {} with nothing in reach (or in build mode, or down), else
## kind "gather", "repair", "upgrade", "workbench", or "shed": a channel under way or an
## open shop's menu, else (in step's order) a damaged structure in reach, a levelable
## one, the nearest point or counter
## label the button's word: Gather, Repair, Upgrade, Workbench, or Shop
## ready whether holding (or, at a counter, pressing) interact would do it now; false when
## it would be refused (the world label says why: nightfall, a full pouch, short of
## materials, max level, a broken workbench)
## progress 0-1 through the gather, repair, or upgrade under way; -1 when none is.
func focus_info() -> Dictionary:
if kit == null or not kit.alive or (build != null and build.active):
return {}
var day := campaign.is_daytime()
if gathering != null:
return _focus("gather", true, gather_elapsed / maxf(config.gather_time, 0.001))
if repairing >= 0:
return _focus("repair", true, repair_elapsed / maxf(config.repair_time, 0.001))
if upgrading >= 0:
return _focus("upgrade", true, upgrade_elapsed / maxf(config.structure_upgrade_time, 0.001))
if upgrade_panel != null and upgrade_panel.is_open:
return _focus("workbench", true)
if shed_panel != null and shed_panel.is_open:
return _focus("shed", true)
if structures != null and repair_target >= 0:
return _focus("repair", campaign.state.resources.can_afford(structures.repair_cost(repair_target), kit.slot))
if structures != null and upgrade_target >= 0:
return _focus("upgrade", day and structures.upgrade_blocker(upgrade_target, kit.slot) == "")
if focus is GatherNode:
return _focus("gather", _blocker(focus) == "")
if focus is Workbench:
return _focus("workbench", day and not (structures != null and structures.is_broken(structures.workbench_id())))
if focus is ShedCounter:
return _focus("shed", day)
return {}
func _focus(kind: String, ready: bool, progress: float = -1.0) -> Dictionary:
return {"kind": kind, "label": FOCUS_LABELS[kind], "ready": ready, "progress": clampf(progress, 0.0, 1.0) if progress >= 0.0 else -1.0}
## One physics tick, after the scarecrow kit.
func step(dt: float) -> void:
var held := remote.held(&"interact") if remote != null else Input.is_action_pressed("interact")