daggerheart/module/dialogs/damageDialog.mjs
Dapoulp 19cc10a3c9
Feature/201 new roll type (#218)
* Action Roll DiceSet type

* Fix

* Remove console log

* Tmp fix for non consistent resource

* fix
2025-06-29 23:00:11 +02:00

60 lines
No EOL
1.6 KiB
JavaScript

const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
export default class DamageDialog extends HandlebarsApplicationMixin(ApplicationV2) {
constructor(roll, config={}, options={}) {
super(options);
this.roll = roll;
this.config = config;
}
static DEFAULT_OPTIONS = {
tag: 'form',
id: 'roll-selection',
classes: ['daggerheart', 'views', 'damage-selection'],
position: {
width: 400,
height: 'auto'
},
actions: {
submitRoll: this.submitRoll
},
form: {
handler: this.updateRollConfiguration,
submitOnChange: true,
submitOnClose: false
}
};
/** @override */
static PARTS = {
damageSelection: {
id: 'damageSelection',
template: 'systems/daggerheart/templates/views/damageSelection.hbs'
}
};
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.title = this.config.title;
context.formula = this.config.roll.formula;
return context;
}
static async submitRoll() {
await this.close({ submitted: true });
}
/** @override */
_onClose(options={}) {
if ( !options.submitted ) this.config = false;
}
static async configure(roll, config={}) {
return new Promise(resolve => {
const app = new this(roll, config);
app.addEventListener("close", () => resolve(app.config), { once: true });
app.render({ force: true });
});
}
}