Fixed resource dice positioning

This commit is contained in:
WBHarry 2025-07-13 13:18:49 +02:00
parent 58f96a36c9
commit 9fc1005caa
7 changed files with 80 additions and 76 deletions

View file

@ -390,7 +390,9 @@
}, },
"ResourceDice": { "ResourceDice": {
"title": "{name} Resource", "title": "{name} Resource",
"rerollDice": "Reroll Dice" "rerollDice": "Reroll Dice",
"rerollRecoveryInfo": "{name} refresh on {recovery}.",
"rerollConfirmation": "Are you sure you want to reroll your {name} dice?"
} }
}, },

View file

@ -1,10 +1,11 @@
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class ResourceDiceDialog extends HandlebarsApplicationMixin(ApplicationV2) { export default class ResourceDiceDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(name, actorName, resource, options = {}) { constructor(name, recovery, actorName, resource, options = {}) {
super(options); super(options);
this.name = name; this.name = name;
this.recovery = recovery;
this.actorName = actorName; this.actorName = actorName;
this.resource = resource; this.resource = resource;
} }
@ -39,7 +40,8 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
async _prepareContext(_options) { async _prepareContext(_options) {
const context = await super._prepareContext(_options); const context = await super._prepareContext(_options);
context.resource = this.resource; context.name = this.name;
context.recovery = game.i18n.localize(CONFIG.DH.GENERAL.refreshTypes[this.recovery].label);
return context; return context;
} }
@ -66,9 +68,9 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
this.close(); this.close();
} }
static async create(name, actorName, resource, options = {}) { static async create(name, recovery, actorName, resource, options = {}) {
return new Promise(resolve => { return new Promise(resolve => {
const app = new this(name, actorName, resource, options); const app = new this(name, recovery, actorName, resource, options);
app.addEventListener('close', () => resolve(app.rollValues), { once: true }); app.addEventListener('close', () => resolve(app.rollValues), { once: true });
app.render({ force: true }); app.render({ force: true });
}); });

View file

@ -700,6 +700,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create( const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create(
item.name, item.name,
item.system.resource.recovery,
this.document.name, this.document.name,
item.system.resource item.system.resource
); );

View file

@ -1,31 +1,6 @@
.daggerheart.dialog.dh-style.views.resource-dice { .daggerheart.dialog.dh-style.views.resource-dice {
.item-resources { .reroll-confirmation {
display: flex; margin-bottom: 8px;
align-items: center;
justify-content: center;
gap: 8px;
.item-resource {
width: 38px;
height: 38px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
label {
position: absolute;
color: light-dark(white, black);
filter: drop-shadow(0 0 1px @golden);
font-size: 24px;
z-index: 2;
}
img {
filter: brightness(0) saturate(100%) invert(97%) sepia(7%) saturate(580%) hue-rotate(332deg)
brightness(96%) contrast(95%);
}
}
} }
footer { footer {

View file

@ -1,13 +1,10 @@
<div> <div>
<div class="item-resources"> <div class="reroll-confirmation">
{{#each resource.diceStates as | state key |}} <div>{{localize 'DAGGERHEART.APPLICATIONS.ResourceDice.rerollRecoveryInfo' name=name recovery=recovery }}</div>
<div class="item-resource"> <div>{{localize 'DAGGERHEART.APPLICATIONS.ResourceDice.rerollConfirmation' name=name }}</div>
<label>{{ifThen state.value state.value '?'}}</label>
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/d" ../resource.dieFaces ".svg"}}" />
</div>
{{/each}}
</div> </div>
<footer> <footer>
<button data-action="close">{{localize 'No'}}</button>
<button data-action="rerollDice">{{localize "DAGGERHEART.APPLICATIONS.ResourceDice.rerollDice"}}</button> <button data-action="rerollDice">{{localize "DAGGERHEART.APPLICATIONS.ResourceDice.rerollDice"}}</button>
</footer> </footer>
</div> </div>

View file

@ -1,45 +1,70 @@
<li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}" draggable="true"> <li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}" draggable="true">
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} /> <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} />
<div class="item-label"> <div class="item-label-wrapper">
{{#if isCompanion}} <div class="item-label {{#unless (and (not isSidebar) (or (eq item.system.resource.type 'simple') item.system.quantity))}}fullWidth{{/unless}}">
<a class="item-name" data-action="attackRoll">{{item.name}}</a> {{#if isCompanion}}
{{else}} <a class="item-name" data-action="attackRoll">{{item.name}}</a>
<div class="item-name">{{item.name}}</div> {{else}}
{{/if}} <div class="item-name">{{item.name}}</div>
{{#if (eq type 'weapon')}} {{/if}}
<div class="item-tags"> {{#if (eq type 'weapon')}}
<div class="item-tags">
{{#if isSidebar}}
<div class="item-labels">
<div class="label">
{{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}}
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}}
<span> - </span>
{{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}}
{{!-- ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) --}}
{{#each item.system.attack.damage.parts.0.type as | type | }}
{{#with (lookup @root.config.GENERAL.damageTypes type)}}
<i class="fa-solid {{icon}}"></i>
{{/with}}
{{/each}}
</div>
</div>
{{else}}
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}}
</div>
<div class="tag">
{{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}}
(
{{#each item.system.attack.damage.parts.0.type}}
{{localize (concat 'DAGGERHEART.CONFIG.DamageType.' this '.abbreviation')}}
{{/each}}
)
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}}
</div>
{{/if}}
</div>
{{/if}}
{{#if (eq type 'armor')}}
{{#if isSidebar}} {{#if isSidebar}}
<div class="item-labels"> <div class="item-labels">
<div class="label"> <div class="label">
{{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}} {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}:
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}} {{item.system.baseScore}}
<span> - </span>
{{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}}
{{!-- ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) --}}
{{#each item.system.attack.damage.parts.0.type as | type | }}
{{#with (lookup @root.config.GENERAL.damageTypes type)}}
<i class="fa-solid {{icon}}"></i>
{{/with}}
{{/each}}
</div> </div>
</div> </div>
{{else}} {{else}}
<div class="tag"> <div class="item-tags">
{{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}} <div class="tag">
</div> {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}:
<div class="tag"> {{item.system.baseScore}}
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}} </div>
</div> <div class="tag">
<div class="tag"> {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}:
{{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}} {{item.system.baseThresholds.major}}
( <span>/</span>
{{#each item.system.attack.damage.parts.0.type}} {{item.system.baseThresholds.severe}}
{{localize (concat 'DAGGERHEART.CONFIG.DamageType.' this '.abbreviation')}} </div>
{{/each}}
)
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}}
</div> </div>
{{/if}} {{/if}}
{{/if}} {{/if}}
@ -102,7 +127,7 @@
</div> </div>
{{/if}} {{/if}}
</div> </div>
{{#if (and (not isSidebar) item.system.resource)}} {{#if (and (not isSidebar) (eq item.system.resource.type 'simple'))}}
{{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}} {{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}}
{{/if}} {{/if}}
{{#if (and (not isSidebar) item.system.quantity)}} {{#if (and (not isSidebar) item.system.quantity)}}
@ -160,7 +185,9 @@
<span></span> <span></span>
{{/unless}} {{/unless}}
<div class="item-description">{{#unless isSidebar}}{{{item.system.description}}}{{/unless}}</div> <div class="item-description">{{#unless isSidebar}}{{{item.system.description}}}{{/unless}}</div>
{{#if (and (not isSidebar) (eq item.system.resource.type 'diceValue'))}}
{{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}}
{{/if}}
{{#if featureType}} {{#if featureType}}
<div class="item-buttons"> <div class="item-buttons">
{{#each item.system.actions as | action |}} {{#each item.system.actions as | action |}}

View file

@ -14,6 +14,6 @@
</div> </div>
</a> </a>
{{/each}} {{/each}}
<a data-action="handleResourceDice"><i class="fa-solid fa-gears resource-edit"></i></a> <a data-action="handleResourceDice" data-tooltip="DAGGERHEART.APPLICATIONS.ResourceDice.rerollDice"><i class="fa-solid fa-dice resource-edit"></i></a>
</div> </div>
{{/if}} {{/if}}