diff --git a/README.md b/README.md index 4ec1919..7013728 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,14 @@ trois sous-onglets issus des sections du catalogue YAML : **Physique**, Le choix principal est stocké dans `d10_tab`, celui des sous-onglets base dans `d10_skill_tab` et celui des catégories cyberpunk dans `d10_category_tab`. Les personnages qui avaient enregistré `core` ou, pour la variante base, -`other` affichent **Compétences** jusqu'au prochain clic. L'en-tête reste visible. Les -thèmes `parchment` et `night` changent les couleurs sans modifier les champs -ni les jets. +`other` affichent **Compétences** jusqu'au prochain clic. L'en-tête reste visible. +La variante cyberpunk propose un sélecteur de thème dans l'en-tête. Il conserve +le choix dans `d10_theme_choice` et applique immédiatement la palette via +`d10_theme`. Les 18 palettes du dossier local `styles/themes/` ont été +adaptées aux cinq couleurs de la feuille et copiées dans `data/themes.yaml`; +le build ne dépend pas de ce dossier. `parchment` et `night` restent disponibles. +`--theme` choisit le thème initial; tous les thèmes modifient seulement les +couleurs et la visibilité de la silhouette, sans modifier les champs ni les jets. Dans la variante cyberpunk, 02 affiche aussi deux cartes côte à côte : **Santé** (PV de la tête, du torse et des membres) et **Armure** (protection, diff --git a/TASKS.md b/TASKS.md index 7c75912..18d5d75 100644 --- a/TASKS.md +++ b/TASKS.md @@ -15,6 +15,7 @@ - [x] Restore original cyberpunk health and armor figures, add integrity maximum per location, and hide number spinners. - [x] Restore readable labels in night-theme repeating rows after Roll20 restructures their fieldsets. - [x] Add cyberpunk skill category subtabs for the full catalogue, preserving fixed skills and repeating fields. +- [x] Map all supplied corporation palettes into the D10 theme model and add a saved cyberpunk theme selector. ## Live Roll20 checks after local verification diff --git a/data/themes.yaml b/data/themes.yaml index 0b1190f..3bcfb57 100644 --- a/data/themes.yaml +++ b/data/themes.yaml @@ -11,3 +11,129 @@ themes: ink: '#f3f4f6' accent: '#48d4bf' border: '#567489' + bluecore: + name: Bluetech + background: '#1a222d' + panel: '#232f3a' + ink: '#d0e4ff' + accent: '#3399ff' + border: '#4488cc' + corporate: + name: Corporate + background: '#f4f5f7' + panel: '#ffffff' + ink: '#222222' + accent: '#2e3440' + border: '#bbbbbb' + dupont-monsanto: + name: Dupont-Monsanto + background: '#1f2c1a' + panel: '#2f3d26' + ink: '#eaffcc' + accent: '#d5e6aa' + border: '#bbdd44' + eden-green: + name: Eridani + background: '#1c2b1a' + panel: '#263f25' + ink: '#cceebb' + accent: '#99cc66' + border: '#66aa55' + foxified-dark: + name: Foxified sombre + background: '#2e1f16' + panel: '#3b261b' + ink: '#ffcc99' + accent: '#ff9b4d' + border: '#aa6033' + foxified-light: + name: Foxified clair + background: '#fff8f2' + panel: '#fff0e6' + ink: '#5a2e0c' + accent: '#8a3c00' + border: '#cc7744' + hci: + name: Habea Corpus + background: '#f2f9f6' + panel: '#e3f0eb' + ink: '#144d40' + accent: '#144d40' + border: '#66ccb3' + iron-docks: + name: Saturn Heavy Foundries + background: '#1e1e1e' + panel: '#2b2b2b' + ink: '#e0e0e0' + accent: '#ff9b35' + border: '#aaaaaa' + peaceframe: + name: ISF Peaceframe + background: '#e8f3fb' + panel: '#d4e8f5' + ink: '#1c3f55' + accent: '#1c3f55' + border: '#77aac6' + rebel: + name: Rebel + background: '#1a1a1a' + panel: '#2a2a2a' + ink: '#f5f5f5' + accent: '#dddddd' + border: '#666666' + sirius-mind: + name: Sirius + background: '#0e1a2b' + panel: '#162538' + ink: '#d0e6ff' + accent: '#86bfff' + border: '#4477aa' + solarized: + name: Sol + background: '#fdf6e3' + panel: '#fefcea' + ink: '#586e75' + accent: '#516a73' + border: '#cccccc' + sons-of-banard: + name: Banard + background: '#1e1c18' + panel: '#2c2a26' + ink: '#f0d9b5' + accent: '#e4b05a' + border: '#cc9966' + storm-pilot: + name: Centauri + background: '#101022' + panel: '#1b1b33' + ink: '#ccddff' + accent: '#aabbee' + border: '#5577aa' + tessier-ashpol: + name: Tessier-Ashpol + background: '#12171b' + panel: '#1a2025' + ink: '#ccf2ff' + accent: '#77cce0' + border: '#77cce0' + ustf: + name: USTF + background: '#0f1b2b' + panel: '#162536' + ink: '#e0e8f0' + accent: '#ff7777' + border: '#446688' + verdant-rebel: + name: Green Pastures + background: '#1b2a1b' + panel: '#273a27' + ink: '#ccffd9' + accent: '#77efaa' + border: '#66dd99' + weicat-industrial: + name: Weycat Industrial + background: '#1c1a14' + panel: '#2a261d' + ink: '#fff5cc' + accent: '#ffda55' + border: '#e6b800' diff --git a/templates/sheet.css b/templates/sheet.css index d783a57..d29ee61 100644 --- a/templates/sheet.css +++ b/templates/sheet.css @@ -11,11 +11,13 @@ } .sheet-d10 *, .sheet-d10 *::before, .sheet-d10 *::after { box-sizing: border-box; } .sheet-d10 .sheet-hero { display: grid; grid-template-columns: 60px minmax(0,1fr) 112px; gap: 16px; align-items: center; padding: 16px; background: var(--d10-panel); border: 1px solid var(--d10-border); border-left: 5px solid var(--d10-accent); } +.sheet-d10.sheet-variant-cyberpunk .sheet-hero { grid-template-columns: 60px minmax(0,1fr) 112px 170px; } .sheet-d10 .sheet-hero-mark { display: grid; place-items: center; width: 54px; height: 54px; color: var(--d10-panel); background: var(--d10-accent); font: bold 18px Georgia,serif; letter-spacing: -.08em; } .sheet-d10 .sheet-eyebrow { display: block; color: var(--d10-accent); font: bold 10px Arial,sans-serif; letter-spacing: .14em; text-transform: uppercase; } .sheet-d10 h1 { margin: 2px 0 11px; color: var(--d10-ink); font: bold 26px Georgia,serif; } .sheet-d10 .sheet-identity { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .sheet-d10 .sheet-identity label, .sheet-d10 .sheet-die-choice { display: grid; gap: 3px; margin: 0 !important; color: var(--d10-accent); font: bold 10px Arial,sans-serif; letter-spacing: .07em; text-transform: uppercase; } +.sheet-d10 .sheet-theme-choice { display: grid; gap: 3px; margin: 0 !important; color: var(--d10-accent); font: bold 10px Arial,sans-serif; letter-spacing: .07em; text-transform: uppercase; } .sheet-d10 .sheet-die-choice { align-self: end; } .sheet-d10 .sheet-tab-nav { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; margin: 14px 0 0; border-bottom: 2px solid var(--d10-accent); } .sheet-d10.sheet-variant-base .sheet-tab-nav { grid-template-columns: repeat(2,minmax(0,1fr)); } @@ -62,8 +64,7 @@ .sheet-d10 .sheet-map-card { min-width: 0; overflow-x: auto; padding: 10px; background: var(--d10-background); border: 1px solid var(--d10-border); } .sheet-d10 .sheet-map-card h3 { margin: 0; padding: 2px 4px 8px; color: var(--d10-accent); font: bold 16px Georgia,serif; text-align: center; border-bottom: 1px solid var(--d10-border); } .sheet-d10 .sheet-body-figure { position: relative; width: 330px; height: 365px; margin: 8px auto 0; } -.sheet-d10 .sheet-body-image { position: absolute; top: 32px; left: 92px; display: block; width: 146px; height: 300px; pointer-events: none; } -.sheet-d10.sheet-theme-night .sheet-body-image { filter: invert(1); } +.sheet-d10 .sheet-body-image { position: absolute; top: 32px; left: 92px; display: block; width: 146px; height: 300px; filter: var(--d10-figure-filter); pointer-events: none; } .sheet-d10 .sheet-zone { position: absolute; z-index: 1; display: grid; justify-items: center; gap: 2px; min-width: 56px; padding: 3px; background: var(--d10-panel); border: 1px solid var(--d10-border); border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,.12); } .sheet-d10 .sheet-zone-label { color: var(--d10-accent); font: bold 9px Arial,sans-serif; white-space: nowrap; } .sheet-d10 .sheet-zone input[type=number] { width: 46px; height: 28px; padding: 2px; font-size: 12px; } @@ -118,8 +119,10 @@ .sheet-d10 { padding: 9px; } .sheet-d10 .sheet-stat-grid, .sheet-d10 .sheet-resource-grid, .sheet-d10 .sheet-weapon-grid { grid-template-columns: 1fr; } .sheet-d10 .sheet-hero { grid-template-columns: 45px minmax(0,1fr); gap: 9px; } + .sheet-d10.sheet-variant-cyberpunk .sheet-hero { grid-template-columns: 45px minmax(0,1fr); } .sheet-d10 .sheet-hero-mark { width: 42px; height: 42px; font-size: 14px; } .sheet-d10 .sheet-die-choice { grid-column: 2; } + .sheet-d10 .sheet-theme-choice { grid-column: 2; } .sheet-d10 .sheet-tab-nav button[type=action] { min-height: 36px; padding: 5px 2px; font-size: 10px; } .sheet-d10 .sheet-skill-tab-nav { grid-template-columns: repeat(2,minmax(0,1fr)); } .sheet-d10 .sheet-skill-head, .sheet-d10 .sheet-skill-row { grid-template-columns: minmax(110px,1fr) 72px 48px 48px 36px; gap: 4px; padding: 4px; } diff --git a/tests/test_build.py b/tests/test_build.py index 2e1e70f..708ed43 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -96,9 +96,32 @@ class BuildTests(unittest.TestCase): with tempfile.TemporaryDirectory() as tmp: one = build.build('cyberpunk', 'parchment', Path(tmp)) two = build.build('cyberpunk', 'night', Path(tmp)) - self.assertEqual(one['sheet.html'].replace('theme-parchment', 'theme-night'), two['sheet.html']) + def normalize(markup, theme): + markup = markup.replace(f'theme-{theme}', 'theme-compiled').replace(' selected', '') + return re.sub(r'(class="sheet-theme-state" name="attr_d10_theme" value=")[^"]+', + r'\1compiled', markup) + self.assertEqual(normalize(one['sheet.html'], 'parchment'), normalize(two['sheet.html'], 'night')) self.assertNotEqual(one['sheet.css'], two['sheet.css']) + def test_corporate_theme_selector(self): + themes = build.read_yaml(build.DATA / 'themes.yaml')['themes'] + self.assertEqual(len(themes), 20) + def luminance(color): + channels = [int(color[index:index + 2], 16) / 255 for index in (1, 3, 5)] + linear = [value / 12.92 if value <= 0.04045 else ((value + 0.055) / 1.055) ** 2.4 + for value in channels] + return sum(value * weight for value, weight in zip(linear, (0.2126, 0.7152, 0.0722))) + for key, palette in themes.items(): + with self.subTest(theme=key), tempfile.TemporaryDirectory() as tmp: + accent, panel = luminance(palette['accent']), luminance(palette['panel']) + self.assertGreaterEqual((max(accent, panel) + 0.05) / (min(accent, panel) + 0.05), 4.5) + files = build.build('cyberpunk', key, Path(tmp)) + self.assertIn(f'