mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 06:26:13 +01:00
Added ArmorManagement menu
This commit is contained in:
parent
934659910f
commit
3b011e2580
4 changed files with 85 additions and 2 deletions
|
|
@ -34,7 +34,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||
useDowntime: this.useDowntime,
|
||||
viewParty: CharacterSheet.#viewParty
|
||||
viewParty: CharacterSheet.#viewParty,
|
||||
toggleArmorMangement: CharacterSheet.#toggleArmorManagement
|
||||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
|
|
@ -945,6 +946,77 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
static async #toggleArmorManagement(_event, target) {
|
||||
const existingTooltip = document.body.querySelector('.locked-tooltip .armor-management-container');
|
||||
if (existingTooltip) {
|
||||
game.tooltip.dismissLockedTooltips();
|
||||
return;
|
||||
}
|
||||
|
||||
const armorSources = [];
|
||||
for (var effect of Array.from(this.document.allApplicableEffects())) {
|
||||
const origin = effect.origin ? await foundry.utils.fromUuid(effect.origin) : effect.parent;
|
||||
if (effect.type !== 'armor' || effect.disabled || effect.isSuppressed) continue;
|
||||
armorSources.push({
|
||||
uuid: effect.uuid,
|
||||
name: origin.name,
|
||||
...effect.system.armorData
|
||||
});
|
||||
}
|
||||
|
||||
if (armorSources.length <= 1) return;
|
||||
|
||||
const html = document.createElement('div');
|
||||
html.innerHTML = await foundry.applications.handlebars.renderTemplate(
|
||||
`systems/daggerheart/templates/ui/tooltip/armorManagement.hbs`,
|
||||
{
|
||||
sources: armorSources
|
||||
}
|
||||
);
|
||||
|
||||
game.tooltip.dismissLockedTooltips();
|
||||
game.tooltip.activate(target, {
|
||||
html,
|
||||
locked: true,
|
||||
cssClass: 'bordered-tooltip',
|
||||
direction: 'DOWN'
|
||||
});
|
||||
|
||||
html.querySelectorAll('.armor-marks-input').forEach(element => {
|
||||
element.addEventListener('blur', CharacterSheet.armorSourceUpdate);
|
||||
element.addEventListener('input', CharacterSheet.armorSourceInput);
|
||||
});
|
||||
}
|
||||
|
||||
static async armorSourceInput(event) {
|
||||
const effect = await foundry.utils.fromUuid(event.target.dataset.uuid);
|
||||
const value = Math.max(Math.min(Number.parseInt(event.target.value), effect.system.armorData.max), 0);
|
||||
event.target.value = value;
|
||||
const progressBar = event.target.closest('.status-bar.armor-slots').querySelector('progress');
|
||||
progressBar.value = value;
|
||||
}
|
||||
|
||||
/** Update specific armor source */
|
||||
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,
|
||||
value
|
||||
}
|
||||
];
|
||||
|
||||
event.target.value = value;
|
||||
const progressBar = event.target.closest('.status-bar.armor-slots').querySelector('progress');
|
||||
progressBar.value = value;
|
||||
|
||||
await effect.update({ 'system.changes': newChanges });
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the downtime application.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,10 @@
|
|||
border-radius: 3px;
|
||||
background: light-dark(@dark-blue, @golden);
|
||||
clip-path: none;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
h4 {
|
||||
font-weight: bold;
|
||||
|
|
@ -306,6 +310,11 @@
|
|||
color: light-dark(@beige, @dark-blue);
|
||||
font-size: var(--font-size-12);
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 12px;
|
||||
color: light-dark(@beige, @dark-blue);
|
||||
}
|
||||
}
|
||||
.slot-value {
|
||||
position: absolute;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@import './tooltip/tooltip.less';
|
||||
@import './tooltip/armorManagement.less';
|
||||
@import './tooltip/battlepoints.less';
|
||||
@import './tooltip/bordered-tooltip.less';
|
||||
@import './tooltip/domain-cards.less';
|
||||
|
|
|
|||
|
|
@ -61,8 +61,9 @@
|
|||
value='{{document.system.armorScore.value}}'
|
||||
max='{{document.system.armorScore.max}}'
|
||||
></progress>
|
||||
<div class="status-label">
|
||||
<div class="status-label" data-action="toggleArmorMangement">
|
||||
<h4>{{localize "DAGGERHEART.GENERAL.armorSlots"}}</h4>
|
||||
<i class="fa-solid fa-gear"></i>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue