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>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/camera_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureCameraAim" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
yaw_degrees = 20.0
|
||||
aiming = true
|
||||
reduce_motion = true
|
||||
@@ -6,6 +6,8 @@ extends "res://test/capture/smoke_scene.gd"
|
||||
@export var yaw_degrees: float = 0.0
|
||||
@export var pitch_degrees: float = -8.0
|
||||
@export var aiming: bool = false
|
||||
## A13: the calmer aim zoom of the reduce-motion setting.
|
||||
@export var reduce_motion: bool = false
|
||||
|
||||
|
||||
func _add_camera() -> void:
|
||||
@@ -19,6 +21,7 @@ func _add_camera() -> void:
|
||||
camera.yaw = deg_to_rad(yaw_degrees)
|
||||
camera.pitch = deg_to_rad(pitch_degrees)
|
||||
camera.aiming = aiming
|
||||
camera.rig.reduce_motion = reduce_motion
|
||||
if aiming:
|
||||
camera.rig.aim_blend = 1.0
|
||||
add_child(camera)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "build"
|
||||
vision = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "build_refused"
|
||||
vision = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "hud"
|
||||
captions = true
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/client_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureClient" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "hud"
|
||||
captions = true
|
||||
ui_scale = 1.3
|
||||
@@ -24,6 +24,11 @@ const LIMIT_ROUNDS: int = 200 * Tuning.TICK_RATE_HZ
|
||||
@export var stage: String = "barge"
|
||||
@export var match_seed: int = 2
|
||||
@export var bots: int = 23
|
||||
## A13: a colour-vision set (Palette.VISION_*), captions for the sounds of the last
|
||||
## second before the picture, and the interface size.
|
||||
@export var vision: int = 0
|
||||
@export var captions: bool = false
|
||||
@export var ui_scale: float = 1.0
|
||||
|
||||
var _loop: ServerLoop
|
||||
var _net: NetServer
|
||||
@@ -32,6 +37,8 @@ var _session: ClientSession
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Palette.vision = vision
|
||||
get_tree().root.content_scale_factor = ui_scale
|
||||
var rules: MatchRules = MatchRules.new()
|
||||
rules.max_players = bots + 1
|
||||
rules.lobby_ticks = 6
|
||||
@@ -104,6 +111,22 @@ func _ready() -> void:
|
||||
return
|
||||
basin_text += downed_text
|
||||
_session.hud.fade_feed = false
|
||||
if captions:
|
||||
# A second of play with its sound, which is what the captions hear.
|
||||
_session.settings.captions = true
|
||||
# Play on until something worth a caption is heard (bots' gunfire carries far),
|
||||
# for up to 20 seconds.
|
||||
for _frame: int in 20 * Tuning.TICK_RATE_HZ:
|
||||
if _session.captions.lines().size() >= 2:
|
||||
break
|
||||
_game.poll()
|
||||
_loop.run_tick()
|
||||
_game.after_tick()
|
||||
_session.pump(DT)
|
||||
_session.sound.update(_session.game, _session.mirror.own_id, _session.view.camera.global_position, DT)
|
||||
_session._hear_captions(DT)
|
||||
if _session.captions.lines().is_empty():
|
||||
push_error("client capture: nothing was captioned")
|
||||
_session.hud.show_state(_session.hud_state())
|
||||
_session.view.settle()
|
||||
var others: int = 0
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/menu_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureMenu" type="Control"]
|
||||
script = ExtResource("1")
|
||||
screen = "main"
|
||||
over_match = false
|
||||
ui_scale = 1.3
|
||||
@@ -8,9 +8,12 @@ extends Control
|
||||
@export var screen: String = "main"
|
||||
@export var over_match: bool = false
|
||||
@export var settings_tab: int = 0
|
||||
## A13: the interface size (GameSettings.UI_SCALES).
|
||||
@export var ui_scale: float = 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
get_tree().root.content_scale_factor = ui_scale
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
if over_match:
|
||||
var stand_in: MenuBackdrop = MenuBackdrop.new()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/menu_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureMenu" type="Control"]
|
||||
script = ExtResource("1")
|
||||
screen = "settings"
|
||||
over_match = false
|
||||
settings_tab = 6
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/menu_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureMenu" type="Control"]
|
||||
script = ExtResource("1")
|
||||
screen = "settings"
|
||||
over_match = false
|
||||
settings_tab = 2
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/menu_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureMenu" type="Control"]
|
||||
script = ExtResource("1")
|
||||
screen = "settings"
|
||||
over_match = false
|
||||
settings_tab = 6
|
||||
ui_scale = 1.3
|
||||
@@ -0,0 +1,93 @@
|
||||
extends TestCase
|
||||
|
||||
## A13: aim assist slows the stick across an opponent in sight and, while aiming,
|
||||
## eases towards them; never through cover, never for the mouse, and only when on.
|
||||
|
||||
const EYE: Vector3 = Vector3(100.0, 10.0, 100.0)
|
||||
|
||||
|
||||
## An opponent `metres` ahead (yaw 0 looks along +z), `degrees` to the left.
|
||||
static func ahead(metres: float, degrees: float) -> Vector3:
|
||||
var angle: float = deg_to_rad(degrees)
|
||||
return EYE + Vector3(sin(angle), 0.0, cos(angle)) * metres
|
||||
|
||||
|
||||
func test_only_opponents_near_the_look_and_in_range_count() -> void:
|
||||
var targets: Array[Vector3] = [ahead(30.0, 20.0), ahead(30.0, 3.0), ahead(200.0, 0.5)]
|
||||
var found: Dictionary = AimAssist.nearest(EYE, 0.0, 0.0, targets)
|
||||
assert_false(found.is_empty())
|
||||
assert_eq(found["point"], targets[1], "the one 3 degrees off, not the far or wide ones")
|
||||
var none: Array[Vector3] = [ahead(30.0, 20.0)]
|
||||
assert_true(AimAssist.nearest(EYE, 0.0, 0.0, none).is_empty())
|
||||
|
||||
|
||||
func test_cover_hides_an_opponent() -> void:
|
||||
var targets: Array[Vector3] = [ahead(30.0, 2.0)]
|
||||
var walled: Callable = func(_from: Vector3, _to: Vector3) -> bool: return false
|
||||
assert_true(AimAssist.nearest(EYE, 0.0, 0.0, targets, walled).is_empty())
|
||||
|
||||
|
||||
func test_friction_is_strongest_at_the_centre() -> void:
|
||||
assert_eq(AimAssist.friction({}), 1.0)
|
||||
var centre: float = AimAssist.friction(AimAssist.nearest(EYE, 0.0, 0.0, [ahead(30.0, 0.0)] as Array[Vector3]))
|
||||
var edge: float = AimAssist.friction(AimAssist.nearest(EYE, 0.0, 0.0, [ahead(30.0, 5.0)] as Array[Vector3]))
|
||||
assert_near(centre, AimAssist.FRICTION, 0.01)
|
||||
assert_true(edge > centre and edge < 1.0)
|
||||
|
||||
|
||||
func test_pull_turns_towards_and_never_past() -> void:
|
||||
var target: Vector3 = ahead(30.0, 2.0)
|
||||
var found: Dictionary = AimAssist.nearest(EYE, 0.0, 0.0, [target] as Array[Vector3])
|
||||
var step: Vector2 = AimAssist.pull(EYE, 0.0, 0.0, found, 0.1)
|
||||
assert_true(step.x > 0.0, "turns left, towards it")
|
||||
assert_true(step.x <= AimAssist.PULL_RADIANS_PER_SECOND * 0.1 + 0.0001, "no faster than the limit")
|
||||
var yaw: float = 0.0
|
||||
for _frame: int in 200:
|
||||
found = AimAssist.nearest(EYE, yaw, 0.0, [target] as Array[Vector3])
|
||||
yaw = AimAssist.pull(EYE, yaw, 0.0, found, 0.05).x
|
||||
assert_true(yaw <= deg_to_rad(2.0) + 0.0001, "never past the opponent: %f" % rad_to_deg(yaw))
|
||||
|
||||
|
||||
func test_through_client_input_only_for_the_pad_and_only_when_on() -> void:
|
||||
var targets: Array[Vector3] = [ahead(30.0, 3.0)]
|
||||
# The pad, aiming and moving the stick a little: the look is drawn left.
|
||||
var input: ClientInput = _aiming_pad(targets)
|
||||
input.handle(TestPad.axis(JOY_AXIS_RIGHT_Y, 0.4), false)
|
||||
for _frame: int in 30:
|
||||
input.poll(1.0 / 60.0)
|
||||
var assisted: float = angle_difference(0.0, input.yaw)
|
||||
assert_true(assisted > 0.002, "pulled towards the opponent: %f" % assisted)
|
||||
# The same with assist off: no sideways pull at all.
|
||||
input = _aiming_pad(targets)
|
||||
input.settings.aim_assist = false
|
||||
input.handle(TestPad.axis(JOY_AXIS_RIGHT_Y, 0.4), false)
|
||||
for _frame: int in 30:
|
||||
input.poll(1.0 / 60.0)
|
||||
assert_near(angle_difference(0.0, input.yaw), 0.0, 0.00001, "off means off")
|
||||
# The mouse with the pad set aside: no pull either.
|
||||
input = _aiming_pad(targets)
|
||||
var key: InputEventKey = InputEventKey.new()
|
||||
key.physical_keycode = KEY_W
|
||||
key.pressed = true
|
||||
input.handle(key, true)
|
||||
var motion: InputEventMouseMotion = InputEventMouseMotion.new()
|
||||
motion.relative = Vector2(0.0, -4.0)
|
||||
input.handle(motion, true)
|
||||
input.poll(1.0 / 60.0)
|
||||
assert_near(angle_difference(0.0, input.yaw), 0.0, 0.00001, "never for the mouse")
|
||||
|
||||
|
||||
func _aiming_pad(targets: Array[Vector3]) -> ClientInput:
|
||||
var input: ClientInput = ClientInput.new()
|
||||
input.eye = EYE
|
||||
input.targets = targets
|
||||
input.handle(TestPad.axis(JOY_AXIS_TRIGGER_LEFT, 1.0), false)
|
||||
return input
|
||||
|
||||
|
||||
class TestPad:
|
||||
static func axis(which: JoyAxis, value: float) -> InputEventJoypadMotion:
|
||||
var event: InputEventJoypadMotion = InputEventJoypadMotion.new()
|
||||
event.axis = which
|
||||
event.axis_value = value
|
||||
return event
|
||||
@@ -0,0 +1 @@
|
||||
uid://btsy5xwlv3q3e
|
||||
@@ -0,0 +1,77 @@
|
||||
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()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bakugnl3g23rk
|
||||
@@ -269,3 +269,50 @@ func test_browse_options() -> void:
|
||||
assert_eq(ClientConfig.parse(PackedStringArray(["--browse"])).lan_port, ServerConfig.DEFAULT_PORT)
|
||||
assert_false(ClientConfig.parse(PackedStringArray(["--browse", "--lan-target=somewhere"])).is_valid())
|
||||
assert_false(ClientConfig.parse(PackedStringArray(["--browse", "--connect=192.0.2.7"])).is_valid())
|
||||
|
||||
|
||||
static func _pad_button(index: JoyButton, pressed: bool) -> InputEventJoypadButton:
|
||||
var event: InputEventJoypadButton = InputEventJoypadButton.new()
|
||||
event.button_index = index
|
||||
event.pressed = pressed
|
||||
return event
|
||||
|
||||
|
||||
static func _pad_axis(which: JoyAxis, value: float) -> InputEventJoypadMotion:
|
||||
var event: InputEventJoypadMotion = InputEventJoypadMotion.new()
|
||||
event.axis = which
|
||||
event.axis_value = value
|
||||
return event
|
||||
|
||||
|
||||
func test_a_gamepad_plays_through_the_session() -> void:
|
||||
# A13: the script lands the player; then a simulated pad takes over.
|
||||
session.play_offline(4, 3)
|
||||
for frame: int in 60 * 150:
|
||||
session.pump(FRAME)
|
||||
if session.game.playing() and _own().drop_state == Drop.NONE and _own().on_ground:
|
||||
break
|
||||
assert_true(session.game.playing() and _own().drop_state == Drop.NONE, "landed")
|
||||
session.input.autoplay = false
|
||||
session.input.yaw = 0.0
|
||||
var start: Vector3 = _own().position
|
||||
session.input.handle(_pad_axis(JOY_AXIS_LEFT_Y, -1.0), false)
|
||||
for frame: int in 60 * 2:
|
||||
session.pump(FRAME)
|
||||
var walked: float = Vector2(_own().position.x - start.x, _own().position.z - start.z).length()
|
||||
assert_true(walked > 3.0, "the left stick walked the player %.1f m" % walked)
|
||||
assert_false(session.input.targets.is_empty(), "aim assist sees the bots as opponents")
|
||||
session.input.handle(_pad_axis(JOY_AXIS_LEFT_Y, 0.0), false)
|
||||
session.input.handle(_pad_button(JOY_BUTTON_RIGHT_SHOULDER, true), false)
|
||||
session.input.handle(_pad_button(JOY_BUTTON_RIGHT_SHOULDER, false), false)
|
||||
for frame: int in 10:
|
||||
session.pump(FRAME)
|
||||
assert_eq(_own().selected, 1, "the right bumper picked the first slot")
|
||||
# Start asks for the pause menu, as Escape does.
|
||||
var asked: Array[bool] = [false]
|
||||
session.pause_requested.connect(func() -> void: asked[0] = true)
|
||||
var tree: SceneTree = Engine.get_main_loop() as SceneTree
|
||||
tree.root.add_child(session)
|
||||
session._unhandled_input(_pad_button(JOY_BUTTON_START, true))
|
||||
assert_true(asked[0], "Start asked for the pause menu")
|
||||
tree.root.remove_child(session)
|
||||
|
||||
@@ -209,3 +209,70 @@ func test_renderer_fallback_notice() -> void:
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "gl_compatibility", PackedStringArray(["--rendering-method", "gl_compatibility"])), "", "the player chose OpenGL")
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "gl_compatibility", PackedStringArray(["--rendering-driver=opengl3"])), "", "the player chose OpenGL")
|
||||
assert_eq(RendererCheck.fallback_notice(), "", "nothing to say headless")
|
||||
|
||||
|
||||
func test_gamepad_and_accessibility_round_trip_and_fall_back() -> void:
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
assert_true(settings.mouse.aim_assist, "aim assist starts on")
|
||||
assert_false(settings.captions)
|
||||
assert_false(settings.reduce_motion)
|
||||
settings.mouse.pad_sensitivity = 1.75
|
||||
settings.mouse.aim_assist = false
|
||||
settings.vision = Palette.VISION_RED_GREEN
|
||||
settings.ui_scale = 1.15
|
||||
settings.captions = true
|
||||
settings.reduce_motion = true
|
||||
assert_eq(settings.save(PATH), OK)
|
||||
var loaded: GameSettings = GameSettings.load_from(PATH)
|
||||
assert_near(loaded.mouse.pad_sensitivity, 1.75, 0.0001)
|
||||
assert_false(loaded.mouse.aim_assist)
|
||||
assert_eq(loaded.vision, Palette.VISION_RED_GREEN)
|
||||
assert_eq(loaded.ui_scale, 1.15)
|
||||
assert_true(loaded.captions)
|
||||
assert_true(loaded.reduce_motion)
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
config.set_value("access", "vision", 42)
|
||||
config.set_value("access", "ui_scale", 7.0)
|
||||
config.set_value("access", "captions", "yes")
|
||||
config.set_value("input", "pad_sensitivity", 99.0)
|
||||
config.set_value("input", "aim_assist", 3)
|
||||
config.save(PATH)
|
||||
loaded = GameSettings.load_from(PATH)
|
||||
assert_eq(loaded.vision, Palette.VISION_NAMES.size() - 1, "clamped")
|
||||
assert_eq(loaded.ui_scale, 1.0, "a scale not offered is the default")
|
||||
assert_false(loaded.captions)
|
||||
assert_near(loaded.mouse.pad_sensitivity, InputSettings.MAX_PAD_SENSITIVITY, 0.0001)
|
||||
assert_true(loaded.mouse.aim_assist)
|
||||
|
||||
|
||||
func test_applying_sets_the_colour_vision_and_interface_size() -> void:
|
||||
var tree: SceneTree = Engine.get_main_loop() as SceneTree
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
settings.vision = Palette.VISION_BLUE_YELLOW
|
||||
settings.ui_scale = 1.3
|
||||
settings.apply_to_program(tree)
|
||||
assert_eq(Palette.vision, Palette.VISION_BLUE_YELLOW)
|
||||
assert_near(tree.root.content_scale_factor, 1.3, 0.0001)
|
||||
GameSettings.new().apply_to_program(tree)
|
||||
assert_eq(Palette.vision, Palette.VISION_STANDARD)
|
||||
assert_near(tree.root.content_scale_factor, 1.0, 0.0001)
|
||||
|
||||
|
||||
func test_reduce_motion_calms_the_aim_zoom() -> void:
|
||||
var rig: CameraRig = CameraRig.new()
|
||||
rig.update_aim(true, 0.1)
|
||||
var quick: float = rig.aim_blend
|
||||
rig.aim_blend = 1.0
|
||||
var full_zoom: float = rig.fov()
|
||||
var calm: CameraRig = CameraRig.new()
|
||||
calm.reduce_motion = true
|
||||
calm.update_aim(true, 0.1)
|
||||
assert_true(calm.aim_blend < quick, "eases in more slowly")
|
||||
calm.aim_blend = 1.0
|
||||
assert_true(calm.fov() > full_zoom + 10.0, "zooms in less: %.0f against %.0f" % [calm.fov(), full_zoom])
|
||||
var view: MatchView = MatchView.new()
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
settings.reduce_motion = true
|
||||
view.apply_settings(settings)
|
||||
assert_true(view.rig.reduce_motion)
|
||||
view.free()
|
||||
|
||||
@@ -214,3 +214,25 @@ func test_a_down_in_duos_travels_in_the_feed_and_reads_as_a_down() -> void:
|
||||
assert_eq(lines[0]["text"], "You knocked Thole down")
|
||||
assert_eq(lines[1]["text"], "Brine is down")
|
||||
assert_eq(HudState.feed_lines(told["entries"], -3)[0]["text"], "Ada knocked you down")
|
||||
|
||||
|
||||
func test_the_bottom_row_never_overlaps_at_any_interface_size() -> void:
|
||||
# A13: the interface size makes the canvas narrower; the hotbar must stay clear of
|
||||
# the vitals and the materials, and inside the screen.
|
||||
for scale: float in GameSettings.UI_SCALES:
|
||||
var hud: Hud = Hud.new()
|
||||
var canvas: Vector2 = Vector2(1280.0, 720.0) / scale
|
||||
hud.size = canvas
|
||||
var state: HudState = HudState.new()
|
||||
state.playing = true
|
||||
for index: int in 6:
|
||||
state.slots.append({"id": "", "name": "Slot", "count": 0, "rounds": 0, "reserve": 0, "magazine": 0, "tier": -1, "selected": index == 0, "empty": true})
|
||||
hud.show_state(state)
|
||||
var bar: Rect2 = hud.hotbar_rect()
|
||||
assert_true(bar.position.x >= hud.vitals_rect().end.x + 1.0, "at %d%% the hotbar starts after the vitals: %s" % [roundi(scale * 100.0), bar])
|
||||
var materials_left: float = canvas.x - Hud.MARGIN - hud.materials_rect().size.x
|
||||
assert_true(bar.end.x <= materials_left - 1.0, "at %d%% the hotbar ends before the materials (%.0f, %.0f)" % [roundi(scale * 100.0), bar.end.x, materials_left])
|
||||
assert_true(bar.size.x >= 6.0 * Hud.SLOT_MIN_WIDTH, "slots no narrower than the least")
|
||||
if is_equal_approx(scale, 1.0):
|
||||
assert_near(bar.get_center().x, canvas.x * 0.5, 1.0, "centred at 100%")
|
||||
hud.free()
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
extends TestCase
|
||||
|
||||
## A13: every in-game action works from a gamepad, driven here by simulated pad
|
||||
## events through ClientInput exactly as the session passes them on.
|
||||
|
||||
var input: ClientInput
|
||||
|
||||
|
||||
func before_each() -> void:
|
||||
super.before_each()
|
||||
input = ClientInput.new()
|
||||
|
||||
|
||||
static func button(index: JoyButton, pressed: bool = true) -> InputEventJoypadButton:
|
||||
var event: InputEventJoypadButton = InputEventJoypadButton.new()
|
||||
event.button_index = index
|
||||
event.pressed = pressed
|
||||
return event
|
||||
|
||||
|
||||
static func axis(which: JoyAxis, value: float) -> InputEventJoypadMotion:
|
||||
var event: InputEventJoypadMotion = InputEventJoypadMotion.new()
|
||||
event.axis = which
|
||||
event.axis_value = value
|
||||
return event
|
||||
|
||||
|
||||
func _tap(index: JoyButton) -> void:
|
||||
input.handle(button(index, true), false)
|
||||
input.handle(button(index, false), false)
|
||||
|
||||
|
||||
func _command() -> PlayerCommand:
|
||||
input.poll(1.0 / 60.0)
|
||||
return input.command(1)
|
||||
|
||||
|
||||
func test_the_left_stick_moves_with_a_dead_zone() -> void:
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, -0.1), false)
|
||||
input.poll(0.016)
|
||||
assert_eq(input.move, Vector2.ZERO, "inside the dead zone")
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, -1.0), false)
|
||||
input.poll(0.016)
|
||||
assert_near(input.move.y, 1.0, 0.001, "stick up walks forward")
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, 0.0), false)
|
||||
input.handle(axis(JOY_AXIS_LEFT_X, 0.6), false)
|
||||
input.poll(0.016)
|
||||
assert_true(input.move.x > 0.4 and input.move.x < 0.6, "part way right is part speed: %s" % input.move)
|
||||
assert_near(input.move.y, 0.0, 0.001)
|
||||
|
||||
|
||||
func test_every_held_action_has_a_button_or_trigger() -> void:
|
||||
var cases: Array[Array] = [
|
||||
[button(JOY_BUTTON_A), PlayerCommand.BUTTON_JUMP],
|
||||
[button(JOY_BUTTON_B), PlayerCommand.BUTTON_CROUCH],
|
||||
[button(JOY_BUTTON_X), PlayerCommand.BUTTON_RELOAD],
|
||||
[button(JOY_BUTTON_Y), PlayerCommand.BUTTON_INTERACT],
|
||||
[button(JOY_BUTTON_DPAD_DOWN), PlayerCommand.BUTTON_DROP],
|
||||
[axis(JOY_AXIS_TRIGGER_RIGHT, 1.0), PlayerCommand.BUTTON_FIRE],
|
||||
[axis(JOY_AXIS_TRIGGER_LEFT, 1.0), PlayerCommand.BUTTON_AIM],
|
||||
]
|
||||
for case: Array in cases:
|
||||
input = ClientInput.new()
|
||||
input.handle(case[0], false)
|
||||
input.poll(0.016)
|
||||
assert_eq(input.buttons, int(case[1]), "%s holds %d" % [(case[0] as InputEvent).as_text(), case[1]])
|
||||
# A trigger only lightly touched isn't held.
|
||||
input = ClientInput.new()
|
||||
input.handle(axis(JOY_AXIS_TRIGGER_RIGHT, 0.2), false)
|
||||
input.poll(0.016)
|
||||
assert_eq(input.buttons, 0)
|
||||
|
||||
|
||||
func test_clicking_the_left_stick_sprints_until_you_stop() -> void:
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, -1.0), false)
|
||||
_tap(JOY_BUTTON_LEFT_STICK)
|
||||
assert_true(_command().buttons & PlayerCommand.BUTTON_SPRINT != 0, "sprinting")
|
||||
assert_true(_command().buttons & PlayerCommand.BUTTON_SPRINT != 0, "still sprinting")
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, 0.0), false)
|
||||
assert_eq(_command().buttons & PlayerCommand.BUTTON_SPRINT, 0, "stopping ends the sprint")
|
||||
input.handle(axis(JOY_AXIS_LEFT_Y, -1.0), false)
|
||||
assert_eq(_command().buttons & PlayerCommand.BUTTON_SPRINT, 0, "walking again doesn't sprint")
|
||||
|
||||
|
||||
func test_bumpers_pick_slots_and_pieces_and_the_dpad_the_material() -> void:
|
||||
_tap(JOY_BUTTON_RIGHT_SHOULDER)
|
||||
assert_eq(input.slot, 1)
|
||||
_tap(JOY_BUTTON_LEFT_SHOULDER)
|
||||
_tap(JOY_BUTTON_LEFT_SHOULDER)
|
||||
assert_eq(input.slot, Inventory.slot_count(), "wraps round to the last slot")
|
||||
_tap(JOY_BUTTON_RIGHT_STICK)
|
||||
assert_true(input.build_mode, "clicking the right stick enters build mode")
|
||||
_tap(JOY_BUTTON_RIGHT_SHOULDER)
|
||||
assert_eq(input.build_kind, StructureSet.FLOOR)
|
||||
_tap(JOY_BUTTON_LEFT_SHOULDER)
|
||||
_tap(JOY_BUTTON_LEFT_SHOULDER)
|
||||
assert_eq(input.build_kind, StructureSet.KINDS.size() - 1)
|
||||
_tap(JOY_BUTTON_DPAD_RIGHT)
|
||||
assert_eq(input.material, Materials.STONE)
|
||||
_tap(JOY_BUTTON_DPAD_LEFT)
|
||||
_tap(JOY_BUTTON_DPAD_LEFT)
|
||||
assert_eq(input.material, Materials.NAMES.size() - 1)
|
||||
var command: PlayerCommand = _command()
|
||||
assert_true(command.buttons & PlayerCommand.BUTTON_BUILD != 0)
|
||||
_tap(JOY_BUTTON_RIGHT_STICK)
|
||||
assert_false(input.build_mode)
|
||||
_tap(JOY_BUTTON_DPAD_UP)
|
||||
assert_true(input.map_open, "D-pad up opens the chart")
|
||||
_tap(JOY_BUTTON_DPAD_UP)
|
||||
assert_false(input.map_open)
|
||||
|
||||
|
||||
func test_a_held_button_acts_once() -> void:
|
||||
input.handle(button(JOY_BUTTON_RIGHT_SHOULDER, true), false)
|
||||
input.handle(button(JOY_BUTTON_RIGHT_SHOULDER, true), false)
|
||||
assert_eq(input.slot, 1, "a repeat of a held button isn't a second press")
|
||||
|
||||
|
||||
func test_the_right_stick_turns_by_time_and_settings() -> void:
|
||||
input.handle(axis(JOY_AXIS_RIGHT_X, 1.0), false)
|
||||
input.poll(0.5)
|
||||
var turned: float = angle_difference(input.yaw, 0.0)
|
||||
assert_near(turned, PadInput.LOOK_RADIANS_PER_SECOND * 0.5, 0.001, "full right turns right at the full rate")
|
||||
input = ClientInput.new()
|
||||
input.settings.pad_sensitivity = 2.0
|
||||
input.handle(axis(JOY_AXIS_RIGHT_X, 1.0), false)
|
||||
input.poll(0.25)
|
||||
assert_near(angle_difference(input.yaw, 0.0), PadInput.LOOK_RADIANS_PER_SECOND * 0.5, 0.001, "twice the speed")
|
||||
input = ClientInput.new()
|
||||
input.handle(axis(JOY_AXIS_RIGHT_Y, -1.0), false)
|
||||
input.poll(0.1)
|
||||
assert_true(input.pitch > 0.0, "stick up looks up")
|
||||
input.settings.invert_y = true
|
||||
input.poll(0.1)
|
||||
assert_near(input.pitch, 0.0, 0.0001, "inverted, it looks back down")
|
||||
# A small push turns much less than in proportion (the response curve).
|
||||
input = ClientInput.new()
|
||||
input.handle(axis(JOY_AXIS_RIGHT_X, 0.5), false)
|
||||
input.poll(1.0)
|
||||
assert_true(angle_difference(input.yaw, 0.0) < PadInput.LOOK_RADIANS_PER_SECOND * 0.35)
|
||||
|
||||
|
||||
func test_the_pad_is_active_until_the_keyboard_is_used() -> void:
|
||||
assert_false(input.pad.active)
|
||||
_tap(JOY_BUTTON_A)
|
||||
assert_true(input.pad.active)
|
||||
var key: InputEventKey = InputEventKey.new()
|
||||
key.physical_keycode = KEY_W
|
||||
key.pressed = true
|
||||
input.handle(key, true)
|
||||
assert_false(input.pad.active)
|
||||
|
||||
|
||||
func test_release_forgets_what_was_held() -> void:
|
||||
input.handle(axis(JOY_AXIS_TRIGGER_RIGHT, 1.0), false)
|
||||
input.handle(button(JOY_BUTTON_A), false)
|
||||
input.pad.release()
|
||||
input.poll(0.016)
|
||||
assert_eq(input.buttons, 0)
|
||||
|
||||
|
||||
func test_every_layout_entry_names_a_real_input() -> void:
|
||||
for action: String in ["jump", "crouch", "reload", "interact", "fire", "aim", "sprint", "build", "map", "drop", "material", "slot_next", "pause", "forward"]:
|
||||
assert_ne(PadInput.describe(action), "?", action)
|
||||
var named: Array[String] = []
|
||||
for pair: Array in PadInput.LAYOUT:
|
||||
named.append(String(pair[1]))
|
||||
for which: String in PadInput.NAMES.values():
|
||||
assert_true(named.has(which) or which == "D-pad right" or which == "D-pad left", "%s is in the listed layout" % which)
|
||||
|
||||
|
||||
func test_menus_accept_and_go_back_on_the_pad() -> void:
|
||||
PadInput.install_menu_actions()
|
||||
PadInput.install_menu_actions()
|
||||
var accept: int = 0
|
||||
for event: InputEvent in InputMap.action_get_events("ui_accept"):
|
||||
if event is InputEventJoypadButton and (event as InputEventJoypadButton).button_index == JOY_BUTTON_A:
|
||||
accept += 1
|
||||
assert_eq(accept, 1, "South chooses, added once")
|
||||
assert_true(button(JOY_BUTTON_B).is_action_pressed("ui_cancel"), "East goes back")
|
||||
assert_true(button(JOY_BUTTON_START).is_action_pressed("ui_cancel"), "Start goes back")
|
||||
assert_true(button(JOY_BUTTON_DPAD_DOWN).is_action_pressed("ui_down"), "the D-pad moves the focus")
|
||||
assert_true(axis(JOY_AXIS_LEFT_Y, 1.0).is_action_pressed("ui_down"), "so does the left stick")
|
||||
@@ -0,0 +1 @@
|
||||
uid://bf3khtxcj4xe8
|
||||
@@ -60,3 +60,81 @@ func _scripts_under(dir_path: String) -> Array[String]:
|
||||
for name: String in DirAccess.get_directories_at(dir_path):
|
||||
found.append_array(_scripts_under(dir_path.path_join(name)))
|
||||
return found
|
||||
|
||||
|
||||
# --- A13: colour vision -------------------------------------------------------------
|
||||
|
||||
## Machado, Oliveira and Fernandes (2009), full severity, applied in linear RGB.
|
||||
const SIMULATE: Dictionary = {
|
||||
"protan": [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-0.003882, -0.048116, 1.051998]],
|
||||
"deutan": [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.011820, 0.042940, 0.968881]],
|
||||
"tritan": [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [0.004733, 0.691367, 0.303900]],
|
||||
}
|
||||
## Each set, and the colour visions it is for.
|
||||
const SETS_FOR: Dictionary = {
|
||||
Palette.VISION_RED_GREEN: ["protan", "deutan"],
|
||||
Palette.VISION_BLUE_YELLOW: ["tritan"],
|
||||
}
|
||||
## How far apart (in Oklab) the two colours of a signal must look.
|
||||
const APART: float = 0.25
|
||||
|
||||
|
||||
func after_each() -> void:
|
||||
super.after_each()
|
||||
Palette.vision = Palette.VISION_STANDARD
|
||||
|
||||
|
||||
static func _seen(colour: Color, vision: String) -> Vector3:
|
||||
var linear: Color = colour.srgb_to_linear()
|
||||
var rgb: Array[float] = [linear.r, linear.g, linear.b]
|
||||
var out: Array[float] = [0.0, 0.0, 0.0]
|
||||
var matrix: Array = SIMULATE[vision]
|
||||
for row: int in 3:
|
||||
for column: int in 3:
|
||||
out[row] += float(matrix[row][column]) * rgb[column]
|
||||
var r: float = clampf(out[0], 0.0, 1.0)
|
||||
var g: float = clampf(out[1], 0.0, 1.0)
|
||||
var b: float = clampf(out[2], 0.0, 1.0)
|
||||
var l: float = pow(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b, 1.0 / 3.0)
|
||||
var m: float = pow(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b, 1.0 / 3.0)
|
||||
var s: float = pow(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b, 1.0 / 3.0)
|
||||
return Vector3(0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s,
|
||||
1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s,
|
||||
0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s)
|
||||
|
||||
|
||||
static func _apart(a: Color, b: Color, vision: String) -> float:
|
||||
return _seen(a, vision).distance_to(_seen(b, vision))
|
||||
|
||||
|
||||
func test_each_colour_vision_set_keeps_its_signals_apart_for_those_eyes() -> void:
|
||||
for vision: int in SETS_FOR:
|
||||
Palette.vision = vision
|
||||
for eyes: String in SETS_FOR[vision]:
|
||||
var ghost: float = _apart(Palette.ghost_ok(), Palette.ghost_refused(), eyes)
|
||||
var danger: float = _apart(Palette.warning(), Palette.own(), eyes)
|
||||
assert_true(ghost >= APART, "%s set, %s: allowed and refused %.3f apart" % [Palette.VISION_NAMES[vision], eyes, ghost])
|
||||
assert_true(danger >= APART, "%s set, %s: danger and own marks %.3f apart" % [Palette.VISION_NAMES[vision], eyes, danger])
|
||||
|
||||
|
||||
func test_the_sets_do_better_than_the_standard_colours_where_they_are_weakest() -> void:
|
||||
# The standard ghost is hardest for deutan eyes, and danger against your own marks for
|
||||
# tritan ones; the sets made for them must be clearly better there.
|
||||
var standard_ghost: float = _apart(Palette.GHOST_OK, Palette.GHOST_REFUSED, "deutan")
|
||||
var standard_danger: float = _apart(Palette.WARNING, Palette.OILSKIN, "tritan")
|
||||
assert_true(standard_ghost < APART, "the standard ghost is a real problem for deutan eyes (%.3f)" % standard_ghost)
|
||||
Palette.vision = Palette.VISION_RED_GREEN
|
||||
assert_true(_apart(Palette.ghost_ok(), Palette.ghost_refused(), "deutan") > standard_ghost * 1.5)
|
||||
Palette.vision = Palette.VISION_BLUE_YELLOW
|
||||
assert_true(_apart(Palette.warning(), Palette.own(), "tritan") > standard_danger * 1.5)
|
||||
|
||||
|
||||
func test_the_standard_set_is_the_documented_colours() -> void:
|
||||
Palette.vision = Palette.VISION_STANDARD
|
||||
assert_eq(Palette.ghost_ok(), Palette.GHOST_OK)
|
||||
assert_eq(Palette.ghost_refused(), Palette.GHOST_REFUSED)
|
||||
assert_eq(Palette.warning(), Palette.WARNING)
|
||||
assert_eq(Palette.own(), Palette.OILSKIN)
|
||||
Palette.vision = 99
|
||||
assert_eq(Palette.vision, Palette.VISION_BLUE_YELLOW, "clamped")
|
||||
assert_eq(Palette.VISION_NAMES.size(), Palette.VISION_SIGNALS.size())
|
||||
|
||||
@@ -300,3 +300,99 @@ func test_main_menu_shows_the_version_and_commit() -> void:
|
||||
assert_not_null(build, "the main menu has a build line")
|
||||
if build != null:
|
||||
assert_eq(build.text, "Version " + BuildInfo.describe())
|
||||
|
||||
|
||||
static func _pad(index: JoyButton, pressed: bool = true) -> InputEventJoypadButton:
|
||||
var event: InputEventJoypadButton = InputEventJoypadButton.new()
|
||||
event.button_index = index
|
||||
event.pressed = pressed
|
||||
return event
|
||||
|
||||
|
||||
## A press and release through Input, the way a real pad's events arrive (some
|
||||
## controls, such as sliders and tab bars, follow the pad through Input's state).
|
||||
func _pad_tap(index: JoyButton) -> void:
|
||||
Input.parse_input_event(_pad(index, true))
|
||||
Input.flush_buffered_events()
|
||||
await tree.process_frame
|
||||
Input.parse_input_event(_pad(index, false))
|
||||
Input.flush_buffered_events()
|
||||
await tree.process_frame
|
||||
|
||||
|
||||
func test_the_menus_work_from_a_gamepad() -> void:
|
||||
menus.show_screen("main", false)
|
||||
await tree.process_frame
|
||||
await _pad_tap(JOY_BUTTON_DPAD_DOWN)
|
||||
var focused: Control = menus.get_viewport().gui_get_focus_owner()
|
||||
assert_true(focused is Button and (focused as Button).text == "Tutorial", "the D-pad moved the focus down: %s" % focused)
|
||||
var asked: Array[bool] = [false]
|
||||
menus.tutorial_requested.connect(func() -> void: asked[0] = true)
|
||||
await _pad_tap(JOY_BUTTON_A)
|
||||
assert_true(asked[0], "South chose the focused button")
|
||||
# Into settings and through its tabs, then back with East.
|
||||
menus.show_screen("main", false)
|
||||
await tree.process_frame
|
||||
for _step: int in 3:
|
||||
await _pad_tap(JOY_BUTTON_DPAD_DOWN)
|
||||
assert_eq((menus.get_viewport().gui_get_focus_owner() as Button).text, "Settings")
|
||||
await _pad_tap(JOY_BUTTON_A)
|
||||
assert_eq(menus.current, "settings")
|
||||
var tabs: TabContainer = menus._tabs
|
||||
var first: int = tabs.current_tab
|
||||
await _pad_tap(JOY_BUTTON_DPAD_RIGHT)
|
||||
assert_eq(tabs.current_tab, first + 1, "the D-pad changes tab")
|
||||
await _pad_tap(JOY_BUTTON_B)
|
||||
assert_eq(menus.current, "main", "East went back")
|
||||
|
||||
|
||||
func test_the_pause_menu_closes_with_start() -> void:
|
||||
menus.show_screen("pause", false)
|
||||
await tree.process_frame
|
||||
var resumed: Array[bool] = [false]
|
||||
menus.resume_requested.connect(func() -> void: resumed[0] = true)
|
||||
await _pad_tap(JOY_BUTTON_START)
|
||||
assert_true(resumed[0])
|
||||
|
||||
|
||||
func test_a_slider_and_a_switch_change_from_the_pad() -> void:
|
||||
menus.show_screen("settings", false)
|
||||
await tree.process_frame
|
||||
menus._tabs.current_tab = 2 # Gamepad
|
||||
await tree.process_frame
|
||||
menus._pad_speed.grab_focus()
|
||||
var before: float = settings_speed()
|
||||
await _pad_tap(JOY_BUTTON_DPAD_RIGHT)
|
||||
assert_true(settings_speed() > before, "D-pad right turned the slider up")
|
||||
menus._aim_assist.grab_focus()
|
||||
await _pad_tap(JOY_BUTTON_A)
|
||||
assert_false(menus.settings.mouse.aim_assist, "South switched aim assist off")
|
||||
|
||||
|
||||
func settings_speed() -> float:
|
||||
return menus.settings.mouse.pad_sensitivity
|
||||
|
||||
|
||||
func test_rebinding_can_be_left_from_the_pad() -> void:
|
||||
menus.show_screen("settings", false)
|
||||
await tree.process_frame
|
||||
menus.listen_for("jump")
|
||||
await _pad_tap(JOY_BUTTON_B)
|
||||
assert_eq(menus.listening_for, "", "East stopped listening")
|
||||
assert_eq(menus.current, "settings", "and stayed on settings")
|
||||
assert_eq(menus.settings.bindings.code_of("jump"), KEY_SPACE)
|
||||
|
||||
|
||||
func test_the_access_tab_changes_the_settings() -> void:
|
||||
menus.show_screen("settings", false)
|
||||
await tree.process_frame
|
||||
menus._vision.select(Palette.VISION_RED_GREEN)
|
||||
menus._vision.item_selected.emit(Palette.VISION_RED_GREEN)
|
||||
menus._ui_scale.item_selected.emit(2)
|
||||
menus._captions.toggled.emit(true)
|
||||
menus._reduce_motion.toggled.emit(true)
|
||||
assert_eq(menus.settings.vision, Palette.VISION_RED_GREEN)
|
||||
assert_eq(menus.settings.ui_scale, GameSettings.UI_SCALES[2])
|
||||
assert_true(menus.settings.captions)
|
||||
assert_true(menus.settings.reduce_motion)
|
||||
assert_eq(GameSettings.load_from(PATH).vision, Palette.VISION_RED_GREEN, "saved at once")
|
||||
|
||||
Reference in New Issue
Block a user