start converting main power dialog to applicationv2
This commit is contained in:
@@ -40,52 +40,39 @@ function _hashCode(str) {
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
export class PowerFormApplicationV2 extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
export class PowerFormApplication extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(powerEffect) {
|
||||
super();
|
||||
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
|
||||
this.options.id = `${this.options.id}${name}`;
|
||||
const id = `${PowerFormApplication.DEFAULT_OPTIONS.id}${name}`;
|
||||
super({ id });
|
||||
this.powerEffect = powerEffect;
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: ['mbSwadePowerEffectsApplicationV2'],
|
||||
id: 'mbSwadePowerEffectsApplicationV2',
|
||||
form: {
|
||||
handler: PowerFormApplicationV2.#onSubmit,
|
||||
handler: PowerFormApplication.#onSubmit,
|
||||
closeOnSubmit: true,
|
||||
},
|
||||
tag: 'form',
|
||||
position: {
|
||||
width: 400,
|
||||
width: 600,
|
||||
height: 'auto',
|
||||
},
|
||||
classes: ['sheet', 'mbSwadeForm', 'mbSwadePowerEffectsForm'],
|
||||
window: {
|
||||
icon: 'fas fa-gear',
|
||||
icon: 'fa-solid fa-hand-sparkles',
|
||||
title: 'mbSwade.powerEffectsForm.title',
|
||||
},
|
||||
};
|
||||
|
||||
static #onSubmit(event, form, formData) {}
|
||||
}
|
||||
|
||||
export class PowerFormApplication extends FormApplication {
|
||||
constructor(powerEffect) {
|
||||
super();
|
||||
const name = powerEffect.name.replaceAll(/[^a-zA-Z]/g, '');
|
||||
this.options.id = `${this.options.id}${name}`;
|
||||
this.powerEffect = powerEffect;
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ['sheet', 'mbSwadeForm', 'mbSwadePowerEffectsForm'],
|
||||
popOut: true,
|
||||
template: templates['powerDialog.html'],
|
||||
id: ['mbSwadePowerEffectsApplication'],
|
||||
title: 'Power Effects',
|
||||
width: 400,
|
||||
});
|
||||
}
|
||||
static PARTS = {
|
||||
body: { template: templates['powerDialog.html'] },
|
||||
footer: {
|
||||
template: 'templates/generic/form-footer.hbs',
|
||||
classes: ['sheet-footer', 'flexrow'],
|
||||
},
|
||||
};
|
||||
|
||||
static sortMods(a, b) {
|
||||
if (a.isGlobal !== b.isGlobal) {
|
||||
@@ -100,7 +87,7 @@ export class PowerFormApplication extends FormApplication {
|
||||
return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
|
||||
}
|
||||
|
||||
getData() {
|
||||
_prepareContext() {
|
||||
let modifiers = foundry.utils.deepClone(this.powerEffect.modifiers);
|
||||
modifiers.sort(PowerFormApplication.sortMods);
|
||||
for (const modifier of modifiers) {
|
||||
@@ -153,8 +140,8 @@ export class PowerFormApplication extends FormApplication {
|
||||
return data;
|
||||
}
|
||||
|
||||
async _updateObject(ev, formData) {
|
||||
formData.submit = ev?.submitter?.value ?? 'cancel';
|
||||
static async #onSubmit(event, form, formData) {
|
||||
formData.submit = event?.submitter?.value ?? 'cancel';
|
||||
if (formData.submit !== 'cancel') {
|
||||
this.powerEffect.formData = formData;
|
||||
this.powerEffect.applyEffect();
|
||||
|
||||
Reference in New Issue
Block a user