diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 0b22a67..80ea907 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -52,6 +52,13 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) { }, }); + static TABS_NPC = /** @type {const} */ ([ + "skills", + "physical", + "gear", + "about", + ]); + static PARTS = /** @type {const} */ ({ header: { template: `${this.TEMPLATE_PATH}/actor/parts/header.html`, @@ -127,6 +134,51 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) { return `${templatePath}/${templateName}`; } + /** @override */ + _configureRenderOptions(options) { + super._configureRenderOptions(options); + switch (this.actor.type) { + case "agent": + break; + case "unnatural": + break; + case "npc": + options.parts = ["header", "tabs", ...this.constructor.TABS_NPC]; + break; + case "vehicle": + break; + default: + break; + } + } + + /** @override - Manipulate which tabs are rendered. */ + _prepareTabs(group) { + const tabs = super._prepareTabs(group); + + /** + * @function + * @name filterTabs + * @param {string[]} tabIds - List of tab IDs to keep. All other tabs will be removed. + * @description Remove all tabs from the `tabs` object except those with IDs in `tabIds`. + */ + const filterTabs = (tabIds) => { + Object.values(tabs) + .filter((tab) => !tabIds.includes(tab.id)) + .forEach(({ id }) => delete tabs[id]); + }; + + switch (this.actor.type) { + case "npc": + filterTabs(this.constructor.TABS_NPC); + break; + default: + break; + } + + return tabs; + } + /** @override */ async _prepareContext(options) { const context = await super._prepareContext(options);