move various power dialogs to DialogV2

This commit is contained in:
Mike Bloy 2025-05-28 21:44:43 -05:00
parent a2fa9d3b05
commit f900cb7d53
3 changed files with 46 additions and 42 deletions

View File

@ -78,6 +78,8 @@ import { WishEffect } from './wish.js';
import { ZombieEffect } from './zombie.js';
import { InquisitorJudgementEffect } from './inquisitor.js';
const { DialogV2 } = foundry.applications.api;
const PowerClasses = {
'animal-companion': SummonCompanionEffect,
'arcane-protection': ArcaneProtectionEffect,
@ -313,7 +315,7 @@ export async function powerEffectsMenu(options = {}) {
const powerInst = new powerClass();
powers[powerInst.name] = powerClass;
}
let form = `<form>
let form = `
<p>Select a power.</p>
<div class="form-group">
<label>Power:</label>
@ -332,21 +334,22 @@ export async function powerEffectsMenu(options = {}) {
}
form += `<option>${powerName}</option>`;
}
form += `</optgroup></select></div></form>`;
const formResult = await Dialog.wait({
title: 'Select a power',
content: form,
buttons: {
submit: {
label: 'Choose Power',
callback: (html) => {
const formElement = html[0].querySelector('form');
const formData = new FormDataExtended(formElement);
return formData;
},
},
cancel: { label: 'Cancel' },
form += `</optgroup></select></div>`;
const formResult = await DialogV2.wait({
window: {
title: 'Select a power',
icon: 'fa-solid fa-wand-magic-sparkles',
},
content: form,
buttons: [
{
action: 'submit',
label: 'Choose Power',
default: true,
callback: (event, button, dialog) => new FormDataExtended(button.form),
},
{ action: 'cancel', label: 'Cancel' },
],
});
console.log(formResult);
const powerName = formResult.get('power');

View File

@ -141,7 +141,7 @@ class BaseAllyEffect extends BaseSummonEffect {
const skillList = Array.from(skillSet);
skillList.sort();
const attrList = ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'];
let html = `<form><h2>Increase Attributes</h2><p>(+1 pp each)</p>`;
let html = `<div><h2>Increase Attributes</h2><p>(+1 pp each)</p>`;
html += attrList
.map(
(name) => `<div class="form-group">
@ -157,20 +157,21 @@ class BaseAllyEffect extends BaseSummonEffect {
</div>`,
)
.join('');
const formData = await Dialog.wait({
title: 'Select Trait increases',
content: html,
buttons: {
submit: {
label: 'Submit',
callback: (html) => {
const formElement = html[0].querySelector('form');
const formData = new FormDataExtended(formElement);
return formData.object;
},
},
cancel: { label: 'Cancel' },
html += '</div>';
const formData = await foundry.applications.api.DialogV2.wait({
window: {
title: 'Select Trait increases',
icon: 'fa-solid fa-person-arrow-up-from-line',
},
content: html,
buttons: [
{
action: 'submit',
label: 'Submit',
callback: (event, button, dialog) => new FormDataExtended(button.form),
},
{ action: 'cancel', label: 'Cancel' },
],
});
const mode = CONST.ACTIVE_EFFECT_MODES.ADD;
const value = 2;

View File

@ -159,20 +159,20 @@ export class ZombieEffect extends BaseSummonEffect {
</div>
</form>
`;
const formData = await Dialog.wait({
title: 'Select trait for raise increase',
content: html,
buttons: {
submit: {
label: 'Submit',
callback: (html) => {
const formElement = html[0].querySelector('form');
const formData = new FormDataExtended(formElement);
return formData.object;
},
},
cancel: { label: 'cancel' },
const formData = await foundry.applications.api.DialogV2.wait({
window: {
title: 'Select trait for raise increase',
icon: 'fa-solid fa-biohazard',
},
content: html,
buttons: [
{
action: 'submit',
label: 'Submit',
callback: (event, button, dialog) => new FormDataExtended(button.form),
},
{ action: 'cancel', label: 'cancel' },
],
});
const key = formData.trait;
this.data.primaryEffectChanges.push({