Implement the dice list form and tweak some design variables

This commit is contained in:
Oliver-Akins 2024-02-03 13:57:31 -07:00
parent 15462c98fb
commit 52aaa41d86
9 changed files with 160 additions and 50 deletions

View file

@ -1,6 +1,7 @@
import { GenericDialog } from "./GenericDialog.mjs";
export class DiceList extends GenericDialog {
constructor(mobActor) {
super({}, { title: `${mobActor.name}'s Dice List` });
this.actor = mobActor;
@ -14,22 +15,31 @@ export class DiceList extends GenericDialog {
const opts = mergeObject({
...super.defaultOptions,
template: `systems/dotdungeon/templates/dialogs/diceList.hbs`,
width: 400,
width: 275,
height: 400,
submitOnClose: true,
submitOnClose: false,
resizable: true,
});
opts.classes.push(`dotdungeon`);
opts.classes?.push(`dotdungeon`);
return opts;
};
async getData() {
const ctx = await super.getData();
ctx.dice = this.dice;
console.debug(`DiceList context`, ctx);
return ctx;
};
async _updateObject(event, formData) {
console.log(event, formData);
async _updateObject(_event, formData) {
const newDice = this.dice.map(d => {
return {
count: formData[`${d.id}.count`],
sides: formData[`${d.id}.sides`],
repeat: formData[`${d.id}.repeat`],
};
});
await this.actor.update({ "system.dice": newDice });
};
addDie() {
@ -41,4 +51,10 @@ export class DiceList extends GenericDialog {
});
this.render();
};
deleteDie($e) {
const data = $e.currentTarget.dataset;
this.dice = this.dice.filter(d => d.id !== data.id);
this.render();
};
};

View file

@ -42,4 +42,8 @@ export class GenericDialog extends FormApplication {
if (!this[data.action]) return;
this[data.action].bind(this)($e);
};
closeNoSave() {
this.close({ submit: false, });
};
};