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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user