The game now opens on a main menu when it has a window: practice against bots (count and skill), join a server (by address, or from a LAN search list), settings, and quit. In a match, Escape brings up a pause menu (the match goes on) with settings and leave; when a match the player was in ends, a results screen shows their place, eliminations and the last of the feed. - KeyBindings: every action rebindable to a key or mouse button. bind() refuses an input another action uses and names it; Escape is reserved. ClientInput reads keys through the bindings. - GameSettings: bindings, mouse, graphics (quality preset and the print pass), audio (master, music and effects buses), display (window mode, vsync, frame cap), name, last server and practice choices, saved in user://settings.cfg. Missing, unreadable or corrupt files and bad values fall back to defaults, value by value; hand-edited key clashes are repaired on load. - Menus (src/ui): paper-and-ink panels, brass focus edge, keyboard navigable; a drawn sea-and-tide-post backdrop, or an ink wash over a match. AppShell runs menus and the session. - LocalServer takes a bot difficulty. - make menu-captures renders every screen. Closes #50 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.8 KiB
GDScript
63 lines
2.8 KiB
GDScript
extends TestCase
|
|
|
|
## A1: every colour the client draws with comes from Palette (docs/STYLE.md).
|
|
|
|
## Scripts allowed literal Color() values, and why.
|
|
const ALLOWED: Dictionary = {
|
|
"res://src/client/style/palette.gd": "the palette itself",
|
|
"res://src/client/terrain/terrain_chunk_builder.gd": "splat weights carried in vertex colours, not colours",
|
|
}
|
|
## A Color() made only of number literals, or a named engine colour other than the
|
|
## neutral ones used as multipliers.
|
|
const LITERAL: String = "Color\\(\\s*-?[0-9.]+\\s*,\\s*-?[0-9.]+\\s*,\\s*-?[0-9.]+\\s*(,\\s*-?[0-9.]+\\s*)?\\)"
|
|
const NAMED: String = "Color\\.(?!WHITE\\b|BLACK\\b|TRANSPARENT\\b)[A-Z_]+\\b|Color8\\(|Color\\.html\\("
|
|
|
|
|
|
func test_client_colours_come_from_the_palette() -> void:
|
|
var literal: RegEx = RegEx.create_from_string(LITERAL)
|
|
var named: RegEx = RegEx.create_from_string(NAMED)
|
|
var paths: Array[String] = _scripts_under("res://src/client")
|
|
paths.append_array(_scripts_under("res://src/app"))
|
|
paths.append_array(_scripts_under("res://src/ui"))
|
|
assert_true(paths.size() > 10, "expected client scripts")
|
|
for path: String in paths:
|
|
if ALLOWED.has(path):
|
|
continue
|
|
for line: String in FileAccess.get_file_as_string(path).split("\n"):
|
|
var code: String = line.get_slice("#", 0)
|
|
if literal.search(code) != null or named.search(code) != null:
|
|
fail("%s has a colour outside Palette: %s" % [path, code.strip_edges()])
|
|
|
|
|
|
func test_scanner_catches_literals_and_named_colours() -> void:
|
|
var literal: RegEx = RegEx.create_from_string(LITERAL)
|
|
var named: RegEx = RegEx.create_from_string(NAMED)
|
|
assert_not_null(literal.search("var c: Color = Color(0.5, 0.2, 0.1)"))
|
|
assert_not_null(literal.search("Color(1, 0, 0, 0.5)"))
|
|
assert_null(literal.search("Color(base.r + shift, 0.0, 1.0)"))
|
|
assert_not_null(named.search("x = Color.RED"))
|
|
assert_not_null(named.search("Color.html(\"#fff\")"))
|
|
assert_null(named.search("tint = Color.WHITE"))
|
|
|
|
|
|
func test_palette_matches_the_style_guide() -> void:
|
|
# Each named colour is listed in docs/STYLE.md, so the guide can't fall behind.
|
|
var guide: String = FileAccess.get_file_as_string("res://docs/STYLE.md")
|
|
assert_true(not guide.is_empty(), "docs/STYLE.md should exist")
|
|
var names: PackedStringArray = PackedStringArray()
|
|
for constant: String in (Palette as Script).get_script_constant_map():
|
|
names.append(constant)
|
|
assert_true(names.size() > 20, "expected the palette's colours")
|
|
for constant: String in names:
|
|
assert_true(guide.contains("`%s`" % constant), "docs/STYLE.md should list `%s`" % constant)
|
|
|
|
|
|
func _scripts_under(dir_path: String) -> Array[String]:
|
|
var found: Array[String] = []
|
|
for name: String in DirAccess.get_files_at(dir_path):
|
|
if name.ends_with(".gd"):
|
|
found.append(dir_path.path_join(name))
|
|
for name: String in DirAccess.get_directories_at(dir_path):
|
|
found.append_array(_scripts_under(dir_path.path_join(name)))
|
|
return found
|