From 6176c3265d4e7b30ac0101001ce657cc83297b59 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 14 Feb 2026 01:39:13 +0100 Subject: [PATCH] Fixed ArmorManagement pip syle --- .../applications/sheets/actors/character.mjs | 46 +++++++++++++++++-- .../less/sheets/actors/character/sidebar.less | 17 +++++++ styles/less/ux/tooltip/armorManagement.less | 23 ++++++++++ templates/sheets/actors/character/sidebar.hbs | 13 ++++-- templates/ui/tooltip/armorManagement.hbs | 43 +++++++++++------ 5 files changed, 121 insertions(+), 21 deletions(-) diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index c9a6047b..b9b6a123 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -966,11 +966,16 @@ export default class CharacterSheet extends DHBaseActorSheet { if (armorSources.length <= 1) return; + const useResourcePips = game.settings.get( + CONFIG.DH.id, + CONFIG.DH.SETTINGS.gameSettings.appearance + ).useResourcePips; const html = document.createElement('div'); html.innerHTML = await foundry.applications.handlebars.renderTemplate( `systems/daggerheart/templates/ui/tooltip/armorManagement.hbs`, { - sources: armorSources + sources: armorSources, + useResourcePips } ); @@ -986,6 +991,10 @@ export default class CharacterSheet extends DHBaseActorSheet { element.addEventListener('blur', CharacterSheet.armorSourceUpdate); element.addEventListener('input', CharacterSheet.armorSourceInput); }); + + html.querySelectorAll('.armor-slot').forEach(element => { + element.addEventListener('click', CharacterSheet.armorSourcePipUpdate); + }); } static async armorSourceInput(event) { @@ -1000,12 +1009,11 @@ export default class CharacterSheet extends DHBaseActorSheet { static async armorSourceUpdate(event) { const effect = await foundry.utils.fromUuid(event.target.dataset.uuid); if (effect.system.changes.length !== 1) return; - const armorEffect = effect.system.changes[0]; const value = Math.max(Math.min(Number.parseInt(event.target.value), effect.system.armorData.max), 0); const newChanges = [ { - ...armorEffect, + ...effect.system.changes[0], value } ]; @@ -1017,6 +1025,38 @@ export default class CharacterSheet extends DHBaseActorSheet { await effect.update({ 'system.changes': newChanges }); } + static async armorSourcePipUpdate(event) { + const target = event.target.closest('.armor-slot'); + const effect = await foundry.utils.fromUuid(target.dataset.uuid); + if (effect.system.changes.length !== 1) return; + const { value, max } = effect.system.armorData; + + const inputValue = Number.parseInt(target.dataset.value); + const decreasing = value >= inputValue; + const newValue = decreasing ? inputValue - 1 : inputValue; + + const newChanges = [ + { + ...effect.system.changes[0], + value: newValue + } + ]; + + const container = target.closest('.slot-bar'); + for (const armorSlot of container.querySelectorAll('.armor-slot i')) { + const index = Number.parseInt(armorSlot.dataset.index); + if (decreasing && index >= newValue) { + armorSlot.classList.remove('fa-shield'); + armorSlot.classList.add('fa-shield-halved'); + } else if (!decreasing && index < newValue) { + armorSlot.classList.add('fa-shield'); + armorSlot.classList.remove('fa-shield-halved'); + } + } + + await effect.update({ 'system.changes': newChanges }); + } + /** * Open the downtime application. * @type {ApplicationClickAction} diff --git a/styles/less/sheets/actors/character/sidebar.less b/styles/less/sheets/actors/character/sidebar.less index 42e40386..ddd3a348 100644 --- a/styles/less/sheets/actors/character/sidebar.less +++ b/styles/less/sheets/actors/character/sidebar.less @@ -276,6 +276,23 @@ } } + .slot-label { + .slot-value-container { + position: relative; + display: flex; + align-items: center; + justify-content: center; + width: 100%; + + i { + position: absolute; + right: 0; + font-size: 12px; + color: light-dark(@beige, @dark-blue); + } + } + } + .status-value { padding: 0 5px; } diff --git a/styles/less/ux/tooltip/armorManagement.less b/styles/less/ux/tooltip/armorManagement.less index bc716fa0..390c0a00 100644 --- a/styles/less/ux/tooltip/armorManagement.less +++ b/styles/less/ux/tooltip/armorManagement.less @@ -97,4 +97,27 @@ } } } + + .slot-bar { + display: flex; + flex-wrap: wrap; + gap: 4px; + padding: 5px; + border: 1px solid light-dark(@dark-blue, @golden); + border-radius: 6px; + z-index: 1; + background: @dark-blue; + justify-content: center; + color: light-dark(@dark-blue, @golden); + + .armor-slot { + cursor: pointer; + transition: all 0.3s ease; + font-size: var(--font-size-12); + + .fa-shield-halved { + color: light-dark(@dark-blue-40, @golden-40); + } + } + } } diff --git a/templates/sheets/actors/character/sidebar.hbs b/templates/sheets/actors/character/sidebar.hbs index 10017343..d3be4983 100644 --- a/templates/sheets/actors/character/sidebar.hbs +++ b/templates/sheets/actors/character/sidebar.hbs @@ -45,10 +45,13 @@ {{/times}} -
+ {{localize "DAGGERHEART.GENERAL.armorSlots"}} - {{document.system.armorScore.value}} / {{document.system.armorScore.max}} -
+
+ {{document.system.armorScore.value}} / {{document.system.armorScore.max}} + +
+
{{else}}
@@ -61,10 +64,10 @@ value='{{document.system.armorScore.value}}' max='{{document.system.armorScore.max}}' > - + {{/if}}
{{else}} diff --git a/templates/ui/tooltip/armorManagement.hbs b/templates/ui/tooltip/armorManagement.hbs index aa8c9878..f5cf0d32 100644 --- a/templates/ui/tooltip/armorManagement.hbs +++ b/templates/ui/tooltip/armorManagement.hbs @@ -1,19 +1,36 @@
{{#each sources as |source|}} -
- -
-
- - / - {{source.max}} + {{#if ../useResourcePips}} +
+ + -
-
+ {{else}} +
+ +
+
+ + / + {{source.max}} +
+ +
+
+ {{/if}} {{/each}}
\ No newline at end of file