Add selectable cyberpunk corporation palettes
This commit is contained in:
parent
bf5e2c7afe
commit
b9cdf09ff0
11
README.md
11
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,
|
||||
|
|
|
|||
1
TASKS.md
1
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
|
||||
|
||||
|
|
|
|||
126
data/themes.yaml
126
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'
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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'<option value="{key}" selected>', files['sheet.html'])
|
||||
self.assertIn(f'.sheet-theme-state[value="{key}"] ~ .sheet-d10', files['sheet.css'])
|
||||
self.assertIn(f'--d10-background: {palette["background"]}', files['sheet.css'])
|
||||
self.assertIn(f'--d10-figure-filter: {build.figure_filter(palette["background"])}', files['sheet.css'])
|
||||
build.build('cyberpunk', key, Path(tmp), check=True)
|
||||
|
||||
def test_hosted_image_urls(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
files = build.build('cyberpunk', 'parchment', Path(tmp),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ for (const variant of ['base', 'cyberpunk']) {
|
|||
},
|
||||
setAttrs: changes => Object.assign(attributes, changes),
|
||||
});
|
||||
assert.equal(handlers.size, tabs.length + skillTabs.length + categoryTabs.length);
|
||||
assert.equal(handlers.size, tabs.length + skillTabs.length + categoryTabs.length + (variant === 'cyberpunk' ? 1 : 0));
|
||||
assert.ok(!handlers.has('clicked:tab_core'));
|
||||
for (const tab of tabs) {
|
||||
assert.match(html, new RegExp(`name="act_tab_${tab}"`));
|
||||
|
|
@ -41,4 +41,10 @@ for (const variant of ['base', 'cyberpunk']) {
|
|||
if (variant === 'base') assert.match(html, /name="attr_d10_skill_tab" value="fight"/);
|
||||
if (variant === 'cyberpunk') assert.ok(!handlers.has('clicked:skill_tab_fight'));
|
||||
if (variant === 'cyberpunk') assert.match(html, /name="attr_d10_category_tab" value="physique"/);
|
||||
if (variant === 'cyberpunk') {
|
||||
assert.match(html, /name="attr_d10_theme_choice"/);
|
||||
assert.match(html, /name="attr_d10_theme" value="parchment"/);
|
||||
handlers.get('change:d10_theme_choice')({ newValue: 'bluecore' });
|
||||
assert.equal(attributes.d10_theme, 'bluecore');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,15 @@ def esc(value):
|
|||
return html.escape(str(value), quote=True)
|
||||
|
||||
|
||||
def figure_filter(background):
|
||||
channels = [int(background[index:index + 2], 16) for index in (1, 3, 5)]
|
||||
return 'invert(1)' if sum(channels) / 3 < 130 else 'none'
|
||||
|
||||
|
||||
def validate(model, skills, theme):
|
||||
if model.get('version') != 1:
|
||||
raise ValueError('unsupported model version')
|
||||
for color in theme.values():
|
||||
for color in (theme[key] for key in ('background', 'panel', 'ink', 'accent', 'border') if key in theme):
|
||||
if not isinstance(color, str) or not COLOR.fullmatch(color):
|
||||
raise ValueError(f'invalid theme color: {color!r}')
|
||||
for required in ('background', 'panel', 'ink', 'accent', 'border'):
|
||||
|
|
@ -207,18 +212,29 @@ def render_repeating_block(block, attributes, expanded=False):
|
|||
return ''.join(parts)
|
||||
|
||||
|
||||
def render(model, skills, variant, theme_name, theme, asset_base_url=''):
|
||||
def render(model, skills, variant, theme_name, theme, themes, asset_base_url=''):
|
||||
tabs = TABS[:-1] if model.get('skill_tabs') else TABS
|
||||
parts = [f'<div class="sheet-d10 sheet-variant-{variant} sheet-theme-{esc(theme_name)}">',
|
||||
switchable = variant == 'cyberpunk'
|
||||
parts = []
|
||||
if switchable:
|
||||
parts.extend(['<div class="sheet-theme-shell">',
|
||||
f'<input type="hidden" class="sheet-theme-state" name="attr_d10_theme" value="{esc(theme_name)}">'])
|
||||
parts.extend([f'<div class="sheet-d10 sheet-variant-{variant} sheet-theme-{esc(theme_name)}">',
|
||||
'<header class="sheet-hero"><div class="sheet-hero-mark">D10</div>',
|
||||
f'<div class="sheet-hero-main"><span class="sheet-eyebrow">Feuille de personnage</span><h1>{esc(model["title"])}</h1>',
|
||||
'<div class="sheet-identity"><label>Nom <input type="text" name="attr_character_name"></label>',
|
||||
'<label>Origine <input type="text" name="attr_character_race"></label></div></div>',
|
||||
'<label class="sheet-die-choice">Dé de jeu <select name="attr_dice">' + ''.join(
|
||||
f'<option value="{n}"{" selected" if n == 10 else ""}>d{n}</option>'
|
||||
for n in (4, 6, 8, 10, 12, 20)) + '</select></label></header>',
|
||||
for n in (4, 6, 8, 10, 12, 20)) + '</select></label>',
|
||||
])
|
||||
if switchable:
|
||||
parts.append('<label class="sheet-theme-choice">Thème <select name="attr_d10_theme_choice">' + ''.join(
|
||||
f'<option value="{esc(key)}"{" selected" if key == theme_name else ""}>{esc(palette.get("name", key))}</option>'
|
||||
for key, palette in themes.items()) + '</select></label>')
|
||||
parts.extend(['</header>',
|
||||
'<section class="sheet-panel"><div class="sheet-section-title"><span>01</span><h2>Caractéristiques</h2></div>',
|
||||
'<div class="sheet-stat-grid">']
|
||||
'<div class="sheet-stat-grid">'])
|
||||
for item in model['attributes']:
|
||||
key = item['id']
|
||||
threshold = f'(@{{base-{key}}}+@{{exal-{key}}})*2'
|
||||
|
|
@ -296,10 +312,19 @@ def render(model, skills, variant, theme_name, theme, asset_base_url=''):
|
|||
parts.append(render_repeating_block(block, model['attributes']))
|
||||
parts.append('</section></div>')
|
||||
parts.append('</div>')
|
||||
if switchable:
|
||||
parts.append('</div>')
|
||||
html_text = '\n'.join(parts) + '\n'
|
||||
css = '.sheet-d10, .sheet-rolltemplate-d10skillcheck {\n' + '\n'.join(
|
||||
f' --d10-{key}: {value};' for key, value in theme.items()) + '\n}\n'
|
||||
css = ('.sheet-d10, .sheet-rolltemplate-d10skillcheck {\n' + '\n'.join(
|
||||
f' --d10-{key}: {theme[key]};' for key in ('background', 'panel', 'ink', 'accent', 'border')) +
|
||||
f'\n --d10-figure-filter: {figure_filter(theme["background"])};\n}}\n')
|
||||
css += (ROOT / 'templates' / 'sheet.css').read_text(encoding='utf-8')
|
||||
if switchable:
|
||||
for key, palette in themes.items():
|
||||
css += f'\n.sheet-theme-state[value="{key}"] ~ .sheet-d10 {{\n'
|
||||
css += '\n'.join(f' --d10-{color}: {palette[color]};' for color in
|
||||
('background', 'panel', 'ink', 'accent', 'border'))
|
||||
css += f'\n --d10-figure-filter: {figure_filter(palette["background"])};\n}}\n'
|
||||
if model.get('skill_tabs'):
|
||||
css += '\n'.join(
|
||||
f'.sheet-d10 .sheet-skill-tab-state[value="{tab["id"]}"] ~ .sheet-skill-pane-{tab["id"]} {{ display: block; }}\n'
|
||||
|
|
@ -326,6 +351,8 @@ def render(model, skills, variant, theme_name, theme, asset_base_url=''):
|
|||
html_text += ''.join(
|
||||
f'on("clicked:category_tab_{section["id"]}", function () {{ setAttrs({{d10_category_tab: "{section["id"]}"}}); }});\n'
|
||||
for section in skills['sections'] if any(group.get('skills') for group in section['groups']))
|
||||
if switchable:
|
||||
html_text += 'on("change:d10_theme_choice", function (event) { setAttrs({d10_theme: event.newValue}); });\n'
|
||||
html_text += '</script>\n'
|
||||
return html_text, css
|
||||
|
||||
|
|
@ -343,7 +370,7 @@ def build(variant, theme_name, output, check=False, asset_base_url=''):
|
|||
skills = read_yaml(DATA / model['skills'])
|
||||
theme = themes[theme_name]
|
||||
validate({**model, 'version': source['version']}, skills, theme)
|
||||
html_text, css = render(model, skills, variant, theme_name, theme, asset_base_url)
|
||||
html_text, css = render(model, skills, variant, theme_name, theme, themes, asset_base_url)
|
||||
manifest = {'html': 'sheet.html', 'css': 'sheet.css', 'authors': 'Dandaedre',
|
||||
'roll20userid': '1067910', 'instructions': f'{model["title"]} generated from D10 YAML'}
|
||||
translation = {}
|
||||
|
|
@ -377,7 +404,7 @@ def build(variant, theme_name, output, check=False, asset_base_url=''):
|
|||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--variant', choices=('base', 'cyberpunk'), default='base')
|
||||
parser.add_argument('--theme', choices=('parchment', 'night'), default='parchment')
|
||||
parser.add_argument('--theme', choices=tuple(read_yaml(DATA / 'themes.yaml')['themes']), default='parchment')
|
||||
parser.add_argument('--output-dir', type=Path)
|
||||
parser.add_argument('--list-themes', action='store_true')
|
||||
parser.add_argument('--check', action='store_true', help='verify existing output without writing')
|
||||
|
|
|
|||
Loading…
Reference in New Issue