docs/STYLE.md sets Tidewall's look: a drowned coast printed by hand. It has the palette, shape language, character proportions, shading, UI motifs, audio palette and a do-not-do list. - Palette (src/client/style/palette.gd) is the one table of client colours. Every colour that was scattered over the views now names its entry, with values unchanged. test_palette fails on a colour literal anywhere else in src/client or src/app, and on a palette colour the guide doesn't list. - Look sets up the sky, the salt-faded grading (saturation 0.86, contrast 1.05), the sun and the print pass, for the match view and the capture scenes. - folk_print.gdshader is one full-screen quad multiplied over the frame. It draws ink lines at depth jumps and creases (fading with distance, scaled with screen height), diagonal hatching cut into real shadow, and faint paper grain. Ground under the sea gets none. - make style-captures renders a hamlet and a dock with and without the pass. Closes #41 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.8 KiB
GDScript
62 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"))
|
|
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
|