Port achievements and player rankings to the Modern UI (by Codex)

This commit is contained in:
Codex committed 2026-10-25 13:51:36 +01:00
1 parent d419943e86
commit 96e88c9579
29 files changed
+1362 -17

No files matched your search

+33
View File
@@ -16,6 +16,23 @@ import shutil
import subprocess
def silver_highscore_svg(source):
"""Apply the Gold CSS brightness(.44)/saturate(1.2) to vector colours only."""
def colour(match):
raw = match[2][1:]
if len(raw) not in (3, 4, 6, 8):
raise ValueError('Unsupported SVG colour length')
if len(raw) in (3, 4):
raw = ''.join(c * 2 for c in raw)
rgb = [int(raw[i:i + 2], 16) * .44 for i in (0, 2, 4)]
luminance = sum(a * b for a, b in zip(rgb, (.213, .715, .072), strict=True))
result = ''.join(f'{max(0, min(255, round(luminance + 1.2 * (c - luminance)))):02x}'
for c in rgb)
return match[1] + '#' + result + raw[6:] + match[3]
return re.sub(r'''((?:fill|stroke|stop-color|color)\s*=\s*["'])(\#[0-9a-fA-F]{3,8})(["'])''',
colour, source)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--mockup', type=Path, required=True)
@@ -86,6 +103,22 @@ def main():
for path in sorted((source / folder).rglob('*')):
if path.is_file() and path.suffix.lower() in ('.png', '.svg', '.jpg', '.webp'):
add('art.' + path.relative_to(source / folder).as_posix(), path.relative_to(source).as_posix())
# The native compatibility renderer has no CSS image-filter implementation.
# Keep the approved original untouched; supply its exact colour-only variant.
logo_source = source / 'assets/vector/highscore-mark-v1.svg'
logo_relative = 'generated/highscore-mark-silver.svg'
logo_destination = output / logo_relative
if not logo_destination.resolve().is_relative_to(output):
raise ValueError('Derived GUI output escapes resource directory')
logo_destination.parent.mkdir(parents=True, exist_ok=True)
logo_bytes = silver_highscore_svg(logo_source.read_text()).encode()
if not logo_destination.exists() or logo_destination.read_bytes() != logo_bytes:
logo_destination.write_bytes(logo_bytes)
items['art.highscore-mark-silver.svg'] = {
'file': logo_relative, 'sha256': hashlib.sha256(logo_bytes).hexdigest(),
'derived_from': 'assets/vector/highscore-mark-v1.svg',
'transform': 'brightness(0.44) saturate(1.2); alpha unchanged',
}
map_source = (source / 'desktop/camp-map-data.js').read_text()
maps = json.loads(re.search(r'Object.freeze\((.*)\);', map_source).group(1))
regions = {'germany': 'de', 'europe': 'eu', 'gulf': 'me'}