This commit is contained in:
Joaquin Pereyra 2025-07-07 17:02:23 -03:00
parent 179deae6df
commit dead31db03
11 changed files with 175 additions and 172 deletions

View file

@ -1,4 +1,4 @@
import DHBaseActorSettings from "../sheets/api/actor-setting.mjs"; import DHBaseActorSettings from '../sheets/api/actor-setting.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */ /**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -9,7 +9,7 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
position: { width: 455, height: 'auto' }, position: { width: 455, height: 'auto' },
actions: { actions: {
addExperience: DHAdversarySettings.#addExperience, addExperience: DHAdversarySettings.#addExperience,
removeExperience: DHAdversarySettings.#removeExperience, removeExperience: DHAdversarySettings.#removeExperience
}, },
dragDrop: [ dragDrop: [
{ dragSelector: null, dropSelector: '.tab.features' }, { dragSelector: null, dropSelector: '.tab.features' },
@ -42,7 +42,6 @@ export default class DHAdversarySettings extends DHBaseActorSettings {
} }
}; };
/** @override */ /** @override */
static TABS = { static TABS = {
primary: { primary: {

View file

@ -11,7 +11,7 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
position: { width: 455, height: 'auto' }, position: { width: 455, height: 'auto' },
actions: { actions: {
levelUp: DHCompanionSettings.#levelUp levelUp: DHCompanionSettings.#levelUp
}, }
}; };
/**@inheritdoc */ /**@inheritdoc */
@ -35,7 +35,6 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
} }
}; };
/** @inheritdoc */ /** @inheritdoc */
static TABS = { static TABS = {
primary: { primary: {
@ -68,9 +67,7 @@ export default class DHCompanionSettings extends DHBaseActorSettings {
*/ */
async onPartnerChange(event) { async onPartnerChange(event) {
const value = event.target.value; const value = event.target.value;
const partnerDocument = value const partnerDocument = value ? await foundry.utils.fromUuid(value) : this.actor.system.partner;
? await foundry.utils.fromUuid(value)
: this.actor.system.partner;
const partnerUpdate = { 'system.companion': value ? this.actor.uuid : null }; const partnerUpdate = { 'system.companion': value ? this.actor.uuid : null };
if (!partnerDocument.isOwner) { if (!partnerDocument.isOwner) {

View file

@ -1,4 +1,4 @@
import DHBaseActorSettings from "../sheets/api/actor-setting.mjs"; import DHBaseActorSettings from '../sheets/api/actor-setting.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */ /**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -49,7 +49,6 @@ export default class DHEnvironmentSettings extends DHBaseActorSettings {
} }
}; };
/** /**
* Adds a new category entry to the actor. * Adds a new category entry to the actor.
* @type {ApplicationClickAction} * @type {ApplicationClickAction}

View file

@ -9,11 +9,11 @@ export default class AdversarySheet extends DHBaseActorSheet {
actions: { actions: {
reactionRoll: AdversarySheet.#reactionRoll, reactionRoll: AdversarySheet.#reactionRoll,
useItem: this.useItem, useItem: this.useItem,
toChat: this.toChat, toChat: this.toChat
}, },
window: { window: {
resizable: true resizable: true
}, }
}; };
static PARTS = { static PARTS = {
@ -24,7 +24,6 @@ export default class AdversarySheet extends DHBaseActorSheet {
effects: { template: 'systems/daggerheart/templates/sheets/actors/adversary/effects.hbs' } effects: { template: 'systems/daggerheart/templates/sheets/actors/adversary/effects.hbs' }
}; };
/** @inheritdoc */ /** @inheritdoc */
static TABS = { static TABS = {
primary: { primary: {
@ -74,7 +73,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
} }
/** /**
* *
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async useItem(event) { static async useItem(event) {
@ -83,7 +82,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
} }
/** /**
* *
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async toChat(event, button) { static async toChat(event, button) {
@ -92,8 +91,9 @@ export default class AdversarySheet extends DHBaseActorSheet {
const cls = getDocumentClass('ChatMessage'); const cls = getDocumentClass('ChatMessage');
const systemData = { const systemData = {
name: game.i18n.localize('DAGGERHEART.GENERAL.Experience.single'), name: game.i18n.localize('DAGGERHEART.GENERAL.Experience.single'),
description: `${experience.name} ${experience.modifier < 0 ? experience.modifier : `+${experience.modifier}` description: `${experience.name} ${
}` experience.modifier < 0 ? experience.modifier : `+${experience.modifier}`
}`
}; };
const msg = new cls({ const msg = new cls({
type: 'abilityUse', type: 'abilityUse',
@ -111,5 +111,4 @@ export default class AdversarySheet extends DHBaseActorSheet {
item.toChat(this.document.id); item.toChat(this.document.id);
} }
} }
} }

View file

@ -24,7 +24,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
levelManagement: CharacterSheet.#levelManagement, levelManagement: CharacterSheet.#levelManagement,
toggleEquipItem: CharacterSheet.#toggleEquipItem, toggleEquipItem: CharacterSheet.#toggleEquipItem,
useItem: this.useItem, //TODO Fix this useItem: this.useItem, //TODO Fix this
toChat: this.toChat, toChat: this.toChat
}, },
window: { window: {
resizable: true resizable: true
@ -89,7 +89,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
async _onRender(context, options) { async _onRender(context, options) {
await super._onRender(context, options); await super._onRender(context, options);
this.element.querySelector('.level-value')?.addEventListener('change', (event) => this.document.updateLevel(Number(event.currentTarget.value))); this.element
.querySelector('.level-value')
?.addEventListener('change', event => this.document.updateLevel(Number(event.currentTarget.value)));
this._createFilterMenus(); this._createFilterMenus();
this._createSearchFilter(); this._createSearchFilter();
@ -152,8 +154,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
async _preparePartContext(partId, context, options) { async _preparePartContext(partId, context, options) {
context = await super._preparePartContext(partId, context, options); context = await super._preparePartContext(partId, context, options);
switch (partId) { switch (partId) {
case "loadout": await this._prepareLoadoutContext(context, options); break; case 'loadout':
case "sidebar": await this._prepareSidebarContext(context, options); break; await this._prepareLoadoutContext(context, options);
break;
case 'sidebar':
await this._prepareSidebarContext(context, options);
break;
} }
return context; return context;
} }
@ -177,67 +183,75 @@ export default class CharacterSheet extends DHBaseActorSheet {
* @protected * @protected
*/ */
static _getContextMenuOptions() { static _getContextMenuOptions() {
/** /**
* Get the item from the element. * Get the item from the element.
* @param {HTMLElement} el * @param {HTMLElement} el
* @returns {foundry.documents.Item?} * @returns {foundry.documents.Item?}
*/ */
const getItem = (el) => this.actor.items.get(el.closest('[data-item-id]')?.dataset.itemId); const getItem = el => this.actor.items.get(el.closest('[data-item-id]')?.dataset.itemId);
return [{ return [
name: 'DAGGERHEART.Sheets.PC.ContextMenu.UseItem', {
icon: '<i class="fa-solid fa-burst"></i>', name: 'DAGGERHEART.Sheets.PC.ContextMenu.UseItem',
condition: el => { icon: '<i class="fa-solid fa-burst"></i>',
const item = getItem(el); condition: el => {
return !['class', 'subclass'].includes(item.type); const item = getItem(el);
return !['class', 'subclass'].includes(item.type);
},
callback: (button, event) => CharacterSheet.useItem.call(this, event, button)
}, },
callback: (button, event) => CharacterSheet.useItem.call(this, event, button) {
}, { name: 'DAGGERHEART.Sheets.PC.ContextMenu.Equip',
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Equip', icon: '<i class="fa-solid fa-hands"></i>',
icon: '<i class="fa-solid fa-hands"></i>', condition: el => {
condition: el => { const item = getItem(el);
const item = getItem(el); return ['weapon', 'armor'].includes(item.type) && !item.system.equipped;
return ['weapon', 'armor'].includes(item.type) && !item.system.equipped; },
callback: CharacterSheet.#toggleEquipItem.bind(this)
}, },
callback: CharacterSheet.#toggleEquipItem.bind(this) {
}, { name: 'DAGGERHEART.Sheets.PC.ContextMenu.Unequip',
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Unequip', icon: '<i class="fa-solid fa-hands"></i>',
icon: '<i class="fa-solid fa-hands"></i>', condition: el => {
condition: el => { const item = getItem(el);
const item = getItem(el); return ['weapon', 'armor'].includes(item.type) && item.system.equipped;
return ['weapon', 'armor'].includes(item.type) && item.system.equipped; },
callback: CharacterSheet.#toggleEquipItem.bind(this)
}, },
callback: CharacterSheet.#toggleEquipItem.bind(this) {
}, { name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToLoadout',
name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToLoadout', icon: '<i class="fa-solid fa-arrow-up"></i>',
icon: '<i class="fa-solid fa-arrow-up"></i>', condition: el => {
condition: (el) => { const item = getItem(el);
const item = getItem(el); return ['domainCard'].includes(item.type) && item.system.inVault;
return ['domainCard'].includes(item.type) && item.system.inVault; },
callback: target => getItem(target).update({ 'system.inVault': false })
}, },
callback: (target) => getItem(target).update({ 'system.inVault': false }) {
}, { name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToVault',
name: 'DAGGERHEART.Sheets.PC.ContextMenu.ToVault', icon: '<i class="fa-solid fa-arrow-down"></i>',
icon: '<i class="fa-solid fa-arrow-down"></i>', condition: el => {
condition: el => { const item = getItem(el);
const item = getItem(el); return ['domainCard'].includes(item.type) && !item.system.inVault;
return ['domainCard'].includes(item.type) && !item.system.inVault; },
callback: target => getItem(target).update({ 'system.inVault': true })
}, },
callback: (target) => getItem(target).update({ 'system.inVault': true }) {
}, { name: 'DAGGERHEART.Sheets.PC.ContextMenu.SendToChat',
name: 'DAGGERHEART.Sheets.PC.ContextMenu.SendToChat', icon: '<i class="fa-regular fa-message"></i>',
icon: '<i class="fa-regular fa-message"></i>', callback: CharacterSheet.toChat.bind(this)
callback: CharacterSheet.toChat.bind(this) },
}, { {
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Edit', name: 'DAGGERHEART.Sheets.PC.ContextMenu.Edit',
icon: '<i class="fa-solid fa-pen-to-square"></i>', icon: '<i class="fa-solid fa-pen-to-square"></i>',
callback: (target) => getItem(target).sheet.render({ force: true }), callback: target => getItem(target).sheet.render({ force: true })
}, { },
name: 'DAGGERHEART.Sheets.PC.ContextMenu.Delete', {
icon: '<i class="fa-solid fa-trash"></i>', name: 'DAGGERHEART.Sheets.PC.ContextMenu.Delete',
callback: (el) => getItem(el).delete() icon: '<i class="fa-solid fa-trash"></i>',
}]; callback: el => getItem(el).delete()
}
];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Filter Tracking */ /* Filter Tracking */
@ -359,7 +373,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Filter Menus */ /* Filter Menus */
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -450,7 +463,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
return new DhCharacterCreation(this.document).render({ force: true }); return new DhCharacterCreation(this.document).render({ force: true });
const { value, subclass } = this.document.system.class; const { value, subclass } = this.document.system.class;
if (!value || !subclass) return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClassOrSubclass')); if (!value || !subclass)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.missingClassOrSubclass'));
new DhCharacterlevelUp(this.document).render({ force: true }); new DhCharacterlevelUp(this.document).render({ force: true });
} }
@ -493,7 +507,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
/** /**
* Toggles the equipped state of an item (armor or weapon). * Toggles the equipped state of an item (armor or weapon).
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async #toggleEquipItem(_event, button) { static async #toggleEquipItem(_event, button) {
//TODO: redo this //TODO: redo this
@ -543,12 +557,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
/** /**
* Toggles whether an item is stored in the vault. * Toggles whether an item is stored in the vault.
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async #toggleVault(event, button) { static async #toggleVault(event, button) {
const docId = button.closest('[data-item-id]')?.dataset.itemId; const docId = button.closest('[data-item-id]')?.dataset.itemId;
const doc = this.document.items.get(docId); const doc = this.document.items.get(docId);
await doc?.update({ 'system.inVault': !doc.system.inVault }) await doc?.update({ 'system.inVault': !doc.system.inVault });
} }
/** /**
@ -637,5 +651,4 @@ export default class CharacterSheet extends DHBaseActorSheet {
itemData = itemData instanceof Array ? itemData : [itemData]; itemData = itemData instanceof Array ? itemData : [itemData];
return this.document.createEmbeddedDocuments('Item', itemData); return this.document.createEmbeddedDocuments('Item', itemData);
} }
} }

View file

@ -2,7 +2,6 @@ import DHBaseActorSheet from '../api/base-actor.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */ /**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
export default class DhCompanionSheet extends DHBaseActorSheet { export default class DhCompanionSheet extends DHBaseActorSheet {
static DEFAULT_OPTIONS = { static DEFAULT_OPTIONS = {
classes: ['actor', 'companion'], classes: ['actor', 'companion'],
@ -10,8 +9,8 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
actions: { actions: {
viewActor: this.viewActor, viewActor: this.viewActor,
useItem: this.useItem, useItem: this.useItem,
toChat: this.toChat, toChat: this.toChat
}, }
}; };
static PARTS = { static PARTS = {
@ -34,7 +33,7 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Application Clicks Actions */ /* Application Clicks Actions */
/* -------------------------------------------- */ /* -------------------------------------------- */
static async viewActor(_, button) { static async viewActor(_, button) {
const target = button.closest('[data-item-uuid]'); const target = button.closest('[data-item-uuid]');
const actor = await foundry.utils.fromUuid(target.dataset.itemUuid); const actor = await foundry.utils.fromUuid(target.dataset.itemUuid);

View file

@ -48,7 +48,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
* *
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
async viewAdversary(_, button) { async viewAdversary(_, button) {

View file

@ -1,5 +1,5 @@
export { default as DHApplicationMixin } from './application-mixin.mjs'; export { default as DHApplicationMixin } from './application-mixin.mjs';
export { default as DHBaseItemSheet } from './base-item.mjs'; export { default as DHBaseItemSheet } from './base-item.mjs';
export { default as DHHeritageSheet } from './heritage-sheet.mjs'; export { default as DHHeritageSheet } from './heritage-sheet.mjs';
export { default as DHBaseActorSheet } from "./base-actor.mjs"; export { default as DHBaseActorSheet } from './base-actor.mjs';
export { default as DHBaseActorSettings } from "./actor-setting.mjs"; export { default as DHBaseActorSettings } from './actor-setting.mjs';

View file

@ -8,44 +8,43 @@ const { DocumentSheetV2 } = foundry.applications.api;
* @extends {DHApplicationMixin<DocumentSheetV2>} * @extends {DHApplicationMixin<DocumentSheetV2>}
*/ */
export default class DHBaseActorSettings extends DHApplicationMixin(DocumentSheetV2) { export default class DHBaseActorSettings extends DHApplicationMixin(DocumentSheetV2) {
/**@inheritdoc */
static DEFAULT_OPTIONS = {
classes: ['dialog'],
window: {
icon: 'fa-solid fa-wrench',
resizable: false,
title: 'DAGGERHEART.GENERAL.Tabs.settings'
},
position: { width: 455, height: 'auto' },
actions: {},
form: {
submitOnChange: true
},
dragDrop: [
{ dragSelector: null, dropSelector: '.tab.features' },
{ dragSelector: '.feature-item', dropSelector: null }
]
};
/**@inheritdoc */ /** @inheritDoc */
static DEFAULT_OPTIONS = { _initializeApplicationOptions(options) {
classes: ['dialog'], options = super._initializeApplicationOptions(options);
window: { options.classes = options.classes.filter(c => c !== 'sheet');
icon: 'fa-solid fa-wrench', return options;
resizable: false, }
title: "DAGGERHEART.GENERAL.Tabs.settings"
},
position: { width: 455, height: 'auto' },
actions: {},
form: {
submitOnChange: true,
},
dragDrop: [
{ dragSelector: null, dropSelector: '.tab.features' },
{ dragSelector: '.feature-item', dropSelector: null }
]
};
/** @inheritDoc */ /**@returns {foundry.documents.Actor} */
_initializeApplicationOptions(options) { get actor() {
options = super._initializeApplicationOptions(options); return this.document;
options.classes = options.classes.filter(c => c !== "sheet"); }
return options;
}
/**@returns {foundry.documents.Actor} */ /**@inheritdoc */
get actor() { async _prepareContext(options) {
return this.document; const context = await super._prepareContext(options);
} context.systemFields.attack.fields = this.actor.system.attack.schema.fields;
context.isNPC = this.actor.isNPC;
/**@inheritdoc */ return context;
async _prepareContext(options) { }
const context = await super._prepareContext(options); }
context.systemFields.attack.fields = this.actor.system.attack.schema.fields;
context.isNPC = this.actor.isNPC;
return context
}
}

View file

@ -5,7 +5,7 @@ import { tagifyElement } from '../../../helpers/utils.mjs';
* @typedef {object} DragDropConfig * @typedef {object} DragDropConfig
* @property {string} [dragSelector] - A CSS selector that identifies draggable elements. * @property {string} [dragSelector] - A CSS selector that identifies draggable elements.
* @property {string} [dropSelector] - A CSS selector that identifies drop targets. * @property {string} [dropSelector] - A CSS selector that identifies drop targets.
* *
* @typedef {object} ContextMenuConfig * @typedef {object} ContextMenuConfig
* @property {() => ContextMenuEntry[]} handler - A handler function that provides initial context options * @property {() => ContextMenuEntry[]} handler - A handler function that provides initial context options
* @property {string} selector - A CSS selector to which the ContextMenu will be bound * @property {string} selector - A CSS selector to which the ContextMenu will be bound
@ -37,7 +37,7 @@ import { tagifyElement } from '../../../helpers/utils.mjs';
/** /**
* @typedef {import("@client/applications/api/handlebars-application.mjs").HandlebarsRenderOptions} HandlebarsRenderOptions * @typedef {import("@client/applications/api/handlebars-application.mjs").HandlebarsRenderOptions} HandlebarsRenderOptions
* @typedef {foundry.applications.types.ApplicationConfiguration} FoundryAppConfig * @typedef {foundry.applications.types.ApplicationConfiguration} FoundryAppConfig
* *
* @typedef {FoundryAppConfig & HandlebarsRenderOptions & { * @typedef {FoundryAppConfig & HandlebarsRenderOptions & {
* dragDrop?: DragDropConfig[], * dragDrop?: DragDropConfig[],
* tagifyConfigs?: TagifyConfig[], * tagifyConfigs?: TagifyConfig[],
@ -45,8 +45,6 @@ import { tagifyElement } from '../../../helpers/utils.mjs';
* }} DHSheetV2Configuration * }} DHSheetV2Configuration
*/ */
/** /**
* @template {Constructor<foundry.applications.api.DocumentSheet>} BaseDocumentSheet * @template {Constructor<foundry.applications.api.DocumentSheet>} BaseDocumentSheet
* @param {BaseDocumentSheet} Base - The base class to extend. * @param {BaseDocumentSheet} Base - The base class to extend.
@ -164,15 +162,14 @@ export default function DHApplicationMixin(Base) {
* @param {DragEvent} event * @param {DragEvent} event
* @protected * @protected
*/ */
_onDragStart(event) { } _onDragStart(event) {}
/** /**
* Handle drop event. * Handle drop event.
* @param {DragEvent} event * @param {DragEvent} event
* @protected * @protected
*/ */
_onDrop(event) { } _onDrop(event) {}
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Context Menu */ /* Context Menu */
@ -187,7 +184,6 @@ export default function DHApplicationMixin(Base) {
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
* Get the set of ContextMenu options which should be used for journal entry pages in the sidebar. * Get the set of ContextMenu options which should be used for journal entry pages in the sidebar.
* @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]}
@ -226,10 +222,15 @@ export default function DHApplicationMixin(Base) {
const parent = this.document; const parent = this.document;
const cls = getDocumentClass(documentClass); const cls = getDocumentClass(documentClass);
return await cls.createDocuments([{ return await cls.createDocuments(
name: cls.defaultName({ type, parent }), [
type, {
}], { parent, renderSheet: !event.shiftKey }); name: cls.defaultName({ type, parent }),
type
}
],
{ parent, renderSheet: !event.shiftKey }
);
} }
/** /**
@ -251,7 +252,6 @@ export default function DHApplicationMixin(Base) {
const { type, docId } = button.dataset; const { type, docId } = button.dataset;
await this.document.getEmbeddedDocument(type, docId, { strict: true }).delete(); await this.document.getEmbeddedDocument(type, docId, { strict: true }).delete();
} }
} }
return DHSheetV2; return DHSheetV2;

View file

@ -11,44 +11,42 @@ const { ActorSheetV2 } = foundry.applications.sheets;
* @mixes DHSheetV2 * @mixes DHSheetV2
*/ */
export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
/** @inheritDoc */ /** @inheritDoc */
static DEFAULT_OPTIONS = { static DEFAULT_OPTIONS = {
classes: ['actor'], classes: ['actor'],
position: { position: {
width: 480, width: 480
}, },
form: { form: {
submitOnChange: true submitOnChange: true
}, },
actions: { actions: {
openSettings: DHBaseActorSheet.#openSettings openSettings: DHBaseActorSheet.#openSettings
}, },
dragDrop: [], dragDrop: []
}; };
/**@type {typeof DHBaseActorSettings}*/ /**@type {typeof DHBaseActorSettings}*/
#settingSheet; #settingSheet;
/**@returns {DHBaseActorSettings|null} */ /**@returns {DHBaseActorSettings|null} */
get settingSheet() { get settingSheet() {
const SheetClass = this.document.system.metadata.settingSheet; const SheetClass = this.document.system.metadata.settingSheet;
return this.#settingSheet ??= SheetClass ? new SheetClass({document: this.document}): null; return (this.#settingSheet ??= SheetClass ? new SheetClass({ document: this.document }) : null);
} }
/**@inheritdoc */ /**@inheritdoc */
async _prepareContext(_options) { async _prepareContext(_options) {
const context = await super._prepareContext(_options); const context = await super._prepareContext(_options);
context.isNPC = this.document.isNPC; context.isNPC = this.document.isNPC;
return context; return context;
} }
/** /**
* Open the Actor Setting Sheet * Open the Actor Setting Sheet
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async #openSettings() { static async #openSettings() {
await this.settingSheet.render({ force: true }); await this.settingSheet.render({ force: true });
} }
}
}