Files
tidewall/test/client/test_captions.gd
T
claudeandClaude Opus 5.5 8142e39ab3 A13: Gamepad and accessibility
Gamepad: PadInput reads pad events in one fixed layout (sticks move and
look, triggers aim and fire, bumpers step slots and build pieces, Start
pauses), fed through ClientInput alongside the keys and mouse. Menus take
South to choose and East or Start to go back. The tutorial names pad
buttons once the pad is used.

Aim assist (option, on by default, pad only): friction across an
opponent in plain sight near the look, and a pull of at most 9 deg/s
while aiming. Client look only; never through cover.

Accessibility (new Access tab): colour-vision sets for the signal colours
(red-green, blue-yellow), checked by simulated colour vision in
test_palette; interface size 90-130%, with the HUD hotbar refitting at the
larger sizes; captions for key sounds with direction; reduce motion
(calmer aim zoom and hurt flash).

Tests for the pad, aim assist, captions, palettes, settings, the menus
driven from a pad, and a pad playing through a real offline session.
make access-captures renders the new screens and options.

Closes #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 08:53:30 -05:00

78 lines
3.5 KiB
GDScript

extends TestCase
## A13: captions name the sounds that matter, say which way they came from, don't
## stack repeats, leave out the player's own sounds, and fade.
const EYE: Vector3 = Vector3(50.0, 5.0, 50.0)
static func cue(sound: String, at: Variant = null) -> Dictionary:
return {"sound": sound, "category": "x", "spatial": at != null, "at": at if at != null else Vector3.ZERO, "volume_db": 0.0, "pitch": 1.0}
func test_sides_follow_the_look() -> void:
# Yaw 0 looks along +z; growing yaw turns left, towards +x.
assert_eq(Captions.side_of(EYE, 0.0, EYE + Vector3(0.0, 0.0, 10.0)), "ahead")
assert_eq(Captions.side_of(EYE, 0.0, EYE + Vector3(0.0, 0.0, -10.0)), "behind")
assert_eq(Captions.side_of(EYE, 0.0, EYE + Vector3(10.0, 0.0, 0.0)), "left")
assert_eq(Captions.side_of(EYE, 0.0, EYE + Vector3(-10.0, 0.0, 0.0)), "right")
assert_eq(Captions.side_of(EYE, PI * 0.5, EYE + Vector3(10.0, 0.0, 0.0)), "ahead", "turned to face +x")
func test_key_sounds_have_words_and_the_rest_none() -> void:
for sound: String in ["foghorn", "bell", "surge", "lighthouse", "hurt", "keg_blast", "step_sand_1", "shot_dock_carbine", "break_stone", "build_driftwood"]:
assert_ne(Captions.words_for(sound), "", sound)
for sound: String in ["amb_surf", "ui_click", "music_drone", "land"]:
assert_eq(Captions.words_for(sound), "", sound)
func test_a_frame_of_cues_becomes_lines() -> void:
var captions: Captions = Captions.new()
var cues: Array[Dictionary] = [cue("foghorn"), cue("shot_harpoon_gun", EYE + Vector3(-30.0, 0.0, 0.0)), cue("amb_wind")]
captions.hear(cues, EYE, 0.0, EYE, 0.016)
assert_eq(captions.lines(), ["Foghorn: the sea is rising", "Gunfire, right"] as Array[String])
func test_repeats_refresh_and_the_newest_is_last() -> void:
var captions: Captions = Captions.new()
var behind: Vector3 = EYE + Vector3(0.0, 0.0, -8.0)
captions.hear([cue("step_grass_1", behind)] as Array[Dictionary], EYE, 0.0, EYE, 0.016)
captions.hear([cue("bell")] as Array[Dictionary], EYE, 0.0, EYE, 0.016)
captions.hear([cue("step_grass_2", behind)] as Array[Dictionary], EYE, 0.0, EYE, 0.016)
assert_eq(captions.lines(), ["Ship's bell", "Footsteps, behind"] as Array[String])
func test_the_players_own_and_far_steps_are_left_out() -> void:
var captions: Captions = Captions.new()
var cues: Array[Dictionary] = [
cue("step_rock_1", EYE + Vector3(0.5, 0.0, 0.0)),
cue("shot_dock_carbine", EYE + Vector3(0.0, 1.2, 0.3)),
cue("step_rock_2", EYE + Vector3(0.0, 0.0, 40.0)),
]
captions.hear(cues, EYE, 0.0, EYE, 0.016)
assert_eq(captions.lines().size(), 0, "%s" % [captions.lines()])
func test_lines_fade_and_never_pile_up() -> void:
var captions: Captions = Captions.new()
var cues: Array[Dictionary] = [cue("foghorn"), cue("bell"), cue("surge"), cue("hurt"), cue("keg_blast", EYE + Vector3(0.0, 0.0, 20.0))]
captions.hear(cues, EYE, 0.0, Vector3.INF, 0.016)
assert_eq(captions.lines().size(), Captions.MAX_LINES)
assert_eq(captions.lines()[Captions.MAX_LINES - 1], "Powder keg blast, ahead")
var none: Array[Dictionary] = []
captions.hear(none, EYE, 0.0, Vector3.INF, Captions.SECONDS + 0.1)
assert_eq(captions.lines().size(), 0)
func test_the_hud_shows_them() -> void:
var hud: Hud = Hud.new()
var state: HudState = HudState.new()
state.captions = ["Gunfire, left"] as Array[String]
hud.show_state(state)
var found: bool = false
for label: Node in hud.find_children("*", "Label", true, false):
if (label as Label).text == "[ Gunfire, left ]":
found = true
assert_true(found, "a caption line on the HUD")
hud.free()