Fallback for default dark dice

This commit is contained in:
WBHarry 2026-01-24 12:11:04 +01:00
parent 1f63a39a36
commit 3c2189c017
3 changed files with 78 additions and 2 deletions

View file

@ -11,7 +11,7 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
};
static buildParts() {
const { footer, header, sheet, ...parts } = super.PARTS;
const { footer, header, sheet, results, ...parts } = super.PARTS;
return {
sheet: {
...sheet,
@ -19,6 +19,11 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
},
header: { template: 'systems/daggerheart/templates/sheets/rollTable/header.hbs' },
...parts,
results: {
template: 'systems/daggerheart/templates/sheets/rollTable/results.hbs',
templates: ['templates/sheets/roll-table/result-details.hbs'],
scrollable: ['table[data-results] tbody']
},
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
footer
};
@ -54,6 +59,7 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
};
context.activeAltFormula = this.daggerheartFlag.activeAltFormula;
context.selectedFormula = this.daggerheartFlag.getActiveFormula(this.document.formula);
context.results = this.getExtendedResults(context.results);
break;
case 'header':
context.altFormula = this.daggerheartFlag.altFormula;
@ -69,11 +75,26 @@ export default class DhRollTableSheet extends foundry.applications.sheets.RollTa
context.altFormula = this.daggerheartFlag.altFormula;
context.formulaName = this.daggerheartFlag.formulaName;
break;
case 'results':
context.results = this.getExtendedResults(context.results);
break;
}
return context;
}
getExtendedResults(results) {
const bodyDarkMode = document.body.classList.contains('theme-dark');
const elementLightMode = this.element.classList.contains('theme-light');
const elementDarkMode = this.element.classList.contains('theme-dark');
const isDarkMode = elementDarkMode || (!elementLightMode && bodyDarkMode);
return results.map(x => ({
...x,
displayImg: isDarkMode && x.img === 'icons/svg/d20-black.svg' ? 'icons/svg/d20.svg' : x.img
}));
}
/* -------------------------------------------- */
/* Flag SystemData update methods */
/* -------------------------------------------- */

View file

@ -0,0 +1,55 @@
<section class="tab{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
<table class="flexcol" data-results>
<thead>
<tr class="flexrow">
<th class="image flexrow">
<button class="inline-control icon fa-solid fa-plus" data-action="createResult"
data-tooltip aria-label="{{localize "TABLE.ACTIONS.CreateResult"}}"></button>
</th>
<th class="details flexrow">{{localize "TABLE_RESULT.Details"}}</th>
<th class="weight flexrow">{{localize "TABLE_RESULT.FIELDS.weight.label"}}</th>
<th class="range flexrow">{{localize "TABLE_RESULT.FIELDS.range.label"}}</th>
<th class="controls flexrow">
<button class="inline-control icon fa-solid fa-scale-balanced" data-action="normalizeResults"
data-tooltip aria-label="{{localize "TABLE.ACTIONS.NormalizeResults"}}"></button>
</th>
</tr>
</thead>
<tbody class="scrollable">
{{#each results as |result i|}}
<tr class="flexrow{{#if result.drawn}} drawn{{/if}}" data-result-id="{{result.id}}">
<td class="image flexrow">
<img src="{{result.displayImg}}" data-action="editImage" data-edit="results.{{i}}.img"
alt="{{localize "TABLE_RESULT.FIELDS.img.label"}}" loading="lazy">
</td>
<td class="details">
{{> "templates/sheets/roll-table/result-details.hbs" result=result}}
</td>
<td class="weight flexrow">
<input type="number" name="results.{{i}}.weight" value="{{result.weight}}" placeholder="1">
</td>
<td class="range flexrow">
<input type="number" name="results.{{i}}.range.0" value="{{result.range.[0]}}" placeholder="L">
<span class="dash"></span>
<input type="number" name="results.{{i}}.range.1" value="{{result.range.[1]}}" placeholder="H">
</td>
<td class="controls flexrow">
<button class="inline-control icon fa-solid fa-file-pen" data-action="openResultSheet"
data-tooltip aria-label="{{localize "TABLE.ACTIONS.OpenResultConfig"}}"></button>
<button class="inline-control icon fa-solid fa-lock{{#unless result.drawn}}-open{{/unless}}"
data-action="lockResult"
data-tooltip aria-label="{{localize "TABLE.ACTIONS.ToggleDrawn"}}"></button>
<button class="inline-control icon fa-solid fa-trash" data-action="deleteResult"
data-tooltip aria-label="{{localize "TABLE.ACTIONS.DeleteResult"}}"></button>
</td>
<input type="hidden" name="results.{{i}}._id" value="{{result.id}}">
</tr>
{{/each}}
</tbody>
</table>
</section>

View file

@ -30,7 +30,7 @@
{{#each results as |result i|}}
<tr class="flexrow{{#if result.drawn}} drawn{{/if}}" data-result-id="{{result.id}}">
<td class="image">
<img src="{{result.img}}" alt="{{localize "TABLE_RESULT.FIELDS.img.label"}}" loading="lazy">
<img src="{{result.displayImg}}" alt="{{localize "TABLE_RESULT.FIELDS.img.label"}}" loading="lazy">
</td>
<td class="range">{{result.range}}</td>
<td class="details">