Begin making the BookGeistSheet have the final design
This commit is contained in:
parent
798e7441b4
commit
28345bdef0
8 changed files with 360 additions and 64 deletions
|
|
@ -2,21 +2,27 @@ import { filePath } from "../../consts.mjs";
|
|||
import { GenericAppMixin } from "../mixins/GenericApp.mjs";
|
||||
import { LaidOutAppMixin } from "../mixins/LaidOutAppMixin.mjs";
|
||||
import { localizer } from "../../utils/Localizer.mjs";
|
||||
import { editItemFromElement, deleteItemFromElement } from "../utils.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
|
||||
export class BookGeistSheet extends LaidOutAppMixin(GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2))) {
|
||||
export class BookGeistSheet extends
|
||||
LaidOutAppMixin(
|
||||
GenericAppMixin(
|
||||
HandlebarsApplicationMixin(
|
||||
ActorSheetV2,
|
||||
))) {
|
||||
// #region Options
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: [
|
||||
`ripcrypt--actor`,
|
||||
`BookGeistSheet`,
|
||||
],
|
||||
// position: {
|
||||
// width: ``,
|
||||
// height: ``,
|
||||
// },
|
||||
position: {
|
||||
width: `auto`,
|
||||
height: `auto`,
|
||||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
},
|
||||
|
|
@ -31,52 +37,71 @@ export class BookGeistSheet extends LaidOutAppMixin(GenericAppMixin(HandlebarsAp
|
|||
root: true,
|
||||
template: filePath(`templates/Apps/BookGeistSheet/layout.hbs`),
|
||||
},
|
||||
image: {
|
||||
template: filePath(`templates/Apps/BookGeistSheet/image.hbs`),
|
||||
},
|
||||
header: {
|
||||
template: filePath(`templates/Apps/BookGeistSheet/header.hbs`),
|
||||
},
|
||||
stats: {
|
||||
template: filePath(`templates/Apps/BookGeistSheet/stats.hbs`),
|
||||
},
|
||||
items: {
|
||||
template: filePath(`templates/Apps/BookGeistSheet/items.hbs`),
|
||||
},
|
||||
image: { template: filePath(`templates/Apps/BookGeistSheet/image.hbs`) },
|
||||
header: { template: filePath(`templates/Apps/BookGeistSheet/header.hbs`) },
|
||||
stats: { template: filePath(`templates/Apps/BookGeistSheet/stats.hbs`) },
|
||||
items: { template: filePath(`templates/Apps/BookGeistSheet/items.hbs`) },
|
||||
};
|
||||
// #endregion Options
|
||||
|
||||
// #region Lifecycle
|
||||
async _onRender() {
|
||||
await super._onRender();
|
||||
|
||||
new ContextMenu(
|
||||
this.element,
|
||||
`[data-ctx-menu="item"]`,
|
||||
[
|
||||
{
|
||||
name: localizer(`RipCrypt.common.edit`),
|
||||
condition: (el) => {
|
||||
const itemId = el.dataset.itemId;
|
||||
return itemId !== ``;
|
||||
},
|
||||
callback: editItemFromElement,
|
||||
},
|
||||
{
|
||||
name: localizer(`RipCrypt.common.delete`),
|
||||
condition: (el) => {
|
||||
const itemId = el.dataset.itemId;
|
||||
return itemId !== ``;
|
||||
},
|
||||
callback: deleteItemFromElement,
|
||||
},
|
||||
],
|
||||
{ jQuery: false, fixed: true },
|
||||
);
|
||||
};
|
||||
// #endregion Lifecycle
|
||||
|
||||
// #region Data Prep
|
||||
_preparePartContext(partID, ctx) {
|
||||
async _preparePartContext(partID, ctx) {
|
||||
|
||||
switch (partID) {
|
||||
case `layout`: this._prepareLayoutContext(ctx); break;
|
||||
case `image`: this._prepareImageContext(ctx); break;
|
||||
case `header`: this._prepareHeaderContext(ctx); break;
|
||||
case `stats`: this._prepareStatsContext(ctx); break;
|
||||
case `items`: this._prepareItemsContext(ctx); break;
|
||||
case `layout`: await this._prepareLayoutContext(ctx); break;
|
||||
case `image`: await this._prepareImageContext(ctx); break;
|
||||
case `header`: await this._prepareHeaderContext(ctx); break;
|
||||
case `stats`: await this._prepareStatsContext(ctx); break;
|
||||
case `items`: await this._prepareItemsContext(ctx); break;
|
||||
};
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
_prepareLayoutContext(ctx) {
|
||||
async _prepareLayoutContext(ctx) {
|
||||
ctx.imageVisible = true;
|
||||
};
|
||||
|
||||
_prepareImageContext(ctx) {
|
||||
async _prepareImageContext(ctx) {
|
||||
ctx.url = this.actor.img;
|
||||
};
|
||||
|
||||
_prepareHeaderContext(ctx) {
|
||||
async _prepareHeaderContext(ctx) {
|
||||
ctx.name = this.actor.name;
|
||||
ctx.description = null; // this.actor.system.description;
|
||||
};
|
||||
|
||||
_prepareStatsContext(ctx) {
|
||||
async _prepareStatsContext(ctx) {
|
||||
const system = this.actor.system;
|
||||
|
||||
const fate = system.fate;
|
||||
|
|
@ -98,14 +123,45 @@ export class BookGeistSheet extends LaidOutAppMixin(GenericAppMixin(HandlebarsAp
|
|||
ctx.speed = system.speed;
|
||||
};
|
||||
|
||||
_prepareItemsContext(ctx) {
|
||||
async _prepareItemsContext(ctx) {
|
||||
ctx.attacks = [];
|
||||
ctx.defense = {
|
||||
locations: `None`,
|
||||
protection: 0,
|
||||
shield: false,
|
||||
};
|
||||
ctx.traits = [];
|
||||
ctx.traits = []; // Array<{name: string}>
|
||||
|
||||
for (const item of this.actor.items) {
|
||||
switch (item.type) {
|
||||
case `weapon`: {
|
||||
if (!item.system.equipped) { continue };
|
||||
ctx.attacks.push(this._prepareWeapon(item));
|
||||
break;
|
||||
};
|
||||
case `trait`: {
|
||||
ctx.traits.push(this._prepareTrait(item));
|
||||
break;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_prepareWeapon(weapon) {
|
||||
return {
|
||||
uuid: weapon.uuid,
|
||||
name: weapon.name,
|
||||
damage: weapon.system.damage,
|
||||
range: weapon.system.range,
|
||||
};
|
||||
};
|
||||
|
||||
_prepareTrait(trait) {
|
||||
return {
|
||||
uuid: trait.uuid,
|
||||
name: trait.name,
|
||||
description: trait.system.description,
|
||||
};
|
||||
};
|
||||
// #endregion Data Prep
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue