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

@ -1,10 +1,11 @@
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class ResourceDiceDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(name, actorName, resource, options = {}) {
constructor(name, recovery, actorName, resource, options = {}) {
super(options);
this.name = name;
this.recovery = recovery;
this.actorName = actorName;
this.resource = resource;
}
@ -39,7 +40,8 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
async _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;
}
@ -66,9 +68,9 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
this.close();
}
static async create(name, actorName, resource, options = {}) {
static async create(name, recovery, actorName, resource, options = {}) {
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.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(
item.name,
item.system.resource.recovery,
this.document.name,
item.system.resource
);