Throw some initial version of code at the wall for the tabbed character sheet
This commit is contained in:
parent
eb6d7fee94
commit
b72f22380f
10 changed files with 213 additions and 2 deletions
137
module/Apps/ActorSheets/TabbedHeroSheet.mjs
Normal file
137
module/Apps/ActorSheets/TabbedHeroSheet.mjs
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
import { filePath } from "../../consts.mjs";
|
||||
import { GenericAppMixin } from "../GenericApp.mjs";
|
||||
import { HeroCraftCardV1 } from "./HeroCraftCardV1.mjs";
|
||||
import { HeroSkillsCardV1 } from "./HeroSkillsCardV1.mjs";
|
||||
import { HeroSummaryCardV1 } from "./HeroSummaryCardV1.mjs";
|
||||
import { Logger } from "../../utils/Logger.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
|
||||
export class TabbedHeroSheet extends GenericAppMixin(HandlebarsApplicationMixin(ActorSheetV2)) {
|
||||
|
||||
// #region Options
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: [
|
||||
`ripcrypt--actor`,
|
||||
`ripcrypt--TabbedHeroSheet`,
|
||||
],
|
||||
position: {
|
||||
width: `auto`,
|
||||
height: `auto`,
|
||||
},
|
||||
window: {
|
||||
resizable: false,
|
||||
},
|
||||
actions: {},
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false,
|
||||
},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
nav: {
|
||||
template: filePath(`templates/Apps/TabbedHeroSheet/tabs.hbs`),
|
||||
},
|
||||
summary: {
|
||||
template: filePath(`templates/Apps/HeroSummaryCardV1/content.hbs`),
|
||||
},
|
||||
skills: {
|
||||
template: filePath(`templates/Apps/HeroSkillsCardV1/content.hbs`),
|
||||
},
|
||||
};
|
||||
// #endregion
|
||||
|
||||
// #region Instance Data
|
||||
#tabs = {
|
||||
root: `HeroSummaryCardV1`,
|
||||
};
|
||||
// #endregion
|
||||
|
||||
// #region Lifecycle
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
||||
const summaryElement = this.element.querySelector(`.HeroSummaryCardV1`);
|
||||
HeroSummaryCardV1._onRender(
|
||||
context,
|
||||
{
|
||||
...options,
|
||||
element: summaryElement,
|
||||
isEditable: this.isEditable,
|
||||
},
|
||||
);
|
||||
|
||||
const skillsElement = this.element.querySelector(`.HeroSkillsCardV1`);
|
||||
HeroSkillsCardV1._onRender.bind(this)(
|
||||
context,
|
||||
{
|
||||
...options,
|
||||
element: skillsElement,
|
||||
isEditable: this.isEditable,
|
||||
},
|
||||
);
|
||||
|
||||
const craftsElement = this.element.querySelector(`.crafts-summary`);
|
||||
HeroCraftCardV1._onRender.bind(this)(
|
||||
context,
|
||||
{
|
||||
...options,
|
||||
element: craftsElement,
|
||||
isEditable: this.isEditable,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
async _preparePartContext(partId, ctx, opts) {
|
||||
ctx = await super._preparePartContext(partId, ctx, opts);
|
||||
ctx.actor = this.document;
|
||||
|
||||
ctx.classes = {
|
||||
tab: true,
|
||||
visible: false,
|
||||
};
|
||||
ctx.attrs = {};
|
||||
|
||||
|
||||
let tabName;
|
||||
switch (partId) {
|
||||
case `summary`: {
|
||||
tabName = `HeroSummaryCardV1`;
|
||||
ctx = await HeroSummaryCardV1.prepareGuts(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareWeapons(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareArmor(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareFatePath(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareAbilityRow(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareSpeed(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareLevelData(ctx);
|
||||
break;
|
||||
};
|
||||
case `skills`: {
|
||||
tabName = `HeroSkillsCardV1`;
|
||||
ctx = await HeroSkillsCardV1.prepareGear(ctx);
|
||||
ctx = await HeroSkillsCardV1.prepareAmmo(ctx);
|
||||
ctx = await HeroSkillsCardV1.prepareSkills(ctx);
|
||||
break;
|
||||
};
|
||||
case `craft`: {
|
||||
tabName = `HeroCraftCardV1`;
|
||||
ctx = await HeroCraftCardV1.prepareCraft(ctx);
|
||||
break;
|
||||
};
|
||||
};
|
||||
if (tabName) {
|
||||
ctx.attrs[`data-tab`] = tabName;
|
||||
ctx.attrs[`data-group`] = `root`;
|
||||
ctx.classes.visible = this.#tabs.root === tabName;
|
||||
};
|
||||
|
||||
Logger.debug(`Context keys:`, Object.keys(ctx));
|
||||
return ctx;
|
||||
};
|
||||
// #endregion
|
||||
|
||||
// #region Actions
|
||||
// #endregion
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue