Working on the spells panel, which resulted in a lot of weird structural changes that aren't *really* functional yet

This commit is contained in:
Oliver-Akins 2024-01-07 22:27:26 -07:00
parent 227029ffcd
commit dfc51a5899
31 changed files with 499 additions and 84 deletions

View file

@ -20,7 +20,7 @@ export class AspectSheet extends ItemSheet {
console.debug(`.dungeon | Adding event listeners for Item: ${this.id}`);
};
getData() {
async getData() {
const ctx = {};
const item = this.item.toObject(false);
@ -29,10 +29,6 @@ export class AspectSheet extends ItemSheet {
ctx.system = item.system;
ctx.flags = item.flags;
console.groupCollapsed(`AspectSheet.getData`);
console.log(`ctx`, ctx);
console.log(`item`, item);
console.groupEnd();
return ctx;
};
};

View file

@ -1,3 +1,6 @@
import DOTDUNGEON from "../config.mjs";
import { preloadIcons } from "../handlebars.mjs";
export class GenericActorSheet extends ActorSheet {
_expanded = new Set();
@ -8,8 +11,8 @@ export class GenericActorSheet extends ActorSheet {
`resourcesOrSupplies`,
];
getData() {
const ctx = super.getData();
async getData() {
const ctx = {};
// Send all of the settings that sheets need into their context
ctx.settings = {};
@ -24,6 +27,10 @@ export class GenericActorSheet extends ActorSheet {
idp: this.actor.uuid,
};
ctx.actor = this.actor;
ctx.config = DOTDUNGEON;
ctx.icons = await preloadIcons();
return ctx;
};

View file

@ -0,0 +1,42 @@
import { preloadIcons } from "../handlebars.mjs";
export class GenericItemSheet extends ItemSheet {
_expanded = new Set();
#propogatedSettings = [
`devMode`,
`showAvatarOnSheet`,
`playersCanChangeGroup`,
`resourcesOrSupplies`,
];
activateListeners(html) {
super.activateListeners(html);
if (this.document.isEmbedded) return;
if (!this.isEditable) return;
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
};
async getData() {
const ctx = {};
const item = this.item.toObject(false);
// Send all of the settings that sheets need into their context
ctx.settings = {};
for (const setting of this.#propogatedSettings) {
ctx.settings[setting] = game.settings.get(`dotdungeon`, setting);
};
ctx.isGM = game.users.current.hasRole(CONST.USER_ROLES.ASSISTANT);
ctx.meta = {
expanded: this._expanded,
idp: this.actor.uuid,
};
ctx.icons = await preloadIcons();
return ctx;
};
};

View file

@ -20,23 +20,23 @@ export class PlayerSheet extends GenericActorSheet {
console.debug(`.dungeon | Adding event listeners for Actor: ${this.id}`);
html.find(`.add-spell`).on(`click`, this.actor.createCustomSpell.bind(this.actor));
html.find(`[data-embedded-update]`)
.on(`change`, this.actor.updateEmbeddedDocument.bind(this.actor));
};
getData() {
const ctx = super.getData();
async getData() {
const ctx = await super.getData();
const actor = this.actor.toObject(false);
ctx.system = actor.system;
ctx.flags = actor.flags;
ctx.items = this.actor.itemTypes;
ctx.computed = {
canChangeGroup: ctx.settings.playersCanChangeGroup || ctx.isGM,
};
console.groupCollapsed(`PlayerSheet.getData`);
console.log(`ctx`, ctx);
console.log(`actor`, actor);
console.groupEnd();
console.log(ctx)
return ctx;
};
};

View file

@ -0,0 +1,36 @@
import { GenericItemSheet } from "./GenericItemSheet.mjs";
export class SpellSheet extends GenericItemSheet {
static get defaultOptions() {
let opts = mergeObject(
super.defaultOptions,
{
template: `systems/dotdungeon/templates/items/spell.hbs`,
width: 280,
height: 340,
}
);
opts.classes.push(`dotdungeon`);
return opts;
};
activateListeners(html) {
super.activateListeners(html);
if (this.document.isEmbedded) return;
if (!this.isEditable) return;
console.debug(`.dungeon | Adding event listeners for Generic Item: ${this.id}`);
};
async getData() {
const ctx = {};
const item = this.item.toObject(false);
ctx.name = super.name;
ctx.item = item;
ctx.system = item.system;
ctx.flags = item.flags;
return ctx;
};
};

View file

@ -16,8 +16,8 @@ export class AbstractSyncSheet extends GenericActorSheet {
return opts;
};
getData() {
const ctx = super.getData();
async getData() {
const ctx = await super.getData();
const actor = this.actor.toObject(false);
ctx.system = actor.system;