Fixed so enriched buttons are inline by default. Can be set to 'inline:true' to make them fit with the text better (#1068)

This commit is contained in:
WBHarry 2025-08-23 13:49:10 +02:00 committed by GitHub
parent f76515eac1
commit 936c96a1be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 7 deletions

View file

@ -2,7 +2,8 @@ export default function DhDamageEnricher(match, _options) {
const parts = match[1].split('|').map(x => x.trim()); const parts = match[1].split('|').map(x => x.trim());
let value = null, let value = null,
type = null; type = null,
inline = false;
parts.forEach(part => { parts.forEach(part => {
const split = part.split(':').map(x => x.toLowerCase().trim()); const split = part.split(':').map(x => x.toLowerCase().trim());
@ -14,16 +15,19 @@ export default function DhDamageEnricher(match, _options) {
case 'type': case 'type':
type = split[1]; type = split[1];
break; break;
case 'inline':
inline = true;
break;
} }
} }
}); });
if (!value || !value) return match[0]; if (!value || !value) return match[0];
return getDamageMessage(value, type, match[0]); return getDamageMessage(value, type, inline, match[0]);
} }
function getDamageMessage(damage, type, defaultElement) { function getDamageMessage(damage, type, inline, defaultElement) {
const typeIcons = type const typeIcons = type
.replace('[', '') .replace('[', '')
.replace(']', '') .replace(']', '')
@ -40,7 +44,7 @@ function getDamageMessage(damage, type, defaultElement) {
const dualityElement = document.createElement('span'); const dualityElement = document.createElement('span');
dualityElement.innerHTML = ` dualityElement.innerHTML = `
<button class="enriched-damage-button" <button class="enriched-damage-button${inline ? ' inline' : ''}"
data-value="${damage}" data-value="${damage}"
data-type="${type}" data-type="${type}"
data-tooltip="${game.i18n.localize('DAGGERHEART.GENERAL.damage')}" data-tooltip="${game.i18n.localize('DAGGERHEART.GENERAL.damage')}"

View file

@ -36,7 +36,7 @@ function getDualityMessage(roll, flavor) {
const dualityElement = document.createElement('span'); const dualityElement = document.createElement('span');
dualityElement.innerHTML = ` dualityElement.innerHTML = `
<button class="duality-roll-button" <button class="duality-roll-button${roll.inline ? ' inline' : ''}"
data-title="${label}" data-title="${label}"
data-label="${dataLabel}" data-label="${dataLabel}"
data-reaction="${roll.reaction ? 'true' : 'false'}" data-reaction="${roll.reaction ? 'true' : 'false'}"

View file

@ -2,7 +2,8 @@ export default function DhTemplateEnricher(match, _options) {
const parts = match[1].split('|').map(x => x.trim()); const parts = match[1].split('|').map(x => x.trim());
let type = null, let type = null,
range = null; range = null,
inline = false;
parts.forEach(part => { parts.forEach(part => {
const split = part.split(':').map(x => x.toLowerCase().trim()); const split = part.split(':').map(x => x.toLowerCase().trim());
@ -20,6 +21,9 @@ export default function DhTemplateEnricher(match, _options) {
); );
range = matchedRange?.id; range = matchedRange?.id;
break; break;
case 'inline':
inline = true;
break;
} }
} }
}); });
@ -30,7 +34,7 @@ export default function DhTemplateEnricher(match, _options) {
const templateElement = document.createElement('span'); const templateElement = document.createElement('span');
templateElement.innerHTML = ` templateElement.innerHTML = `
<button class="measured-template-button" data-type="${type}" data-range="${range}"> <button class="measured-template-button${inline ? ' inline' : ''}" data-type="${type}" data-range="${range}">
${label} - ${game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.name`)} ${label} - ${game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.name`)}
</button> </button>
`; `;

View file

@ -0,0 +1,14 @@
.measured-template-button,
.enriched-damage-button,
.duality-roll-button {
display: inline;
&.inline {
min-height: unset;
height: 18px;
}
i {
font-size: 12px;
}
}

View file

@ -2,6 +2,7 @@
@import './dialog.less'; @import './dialog.less';
@import './chat.less'; @import './chat.less';
@import './elements.less'; @import './elements.less';
@import './enrichment.less';
@import './tab-navigation.less'; @import './tab-navigation.less';
@import './tab-form-footer.less'; @import './tab-form-footer.less';
@import './tab-actions.less'; @import './tab-actions.less';