mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
REFACTOR: remove unused method on setting sheet
FEAT: create BaseActorSetting FIX: add type="button" to button on actor's sheet
This commit is contained in:
parent
79a4c13a1b
commit
0189805dd6
20 changed files with 185 additions and 387 deletions
|
|
@ -2,3 +2,4 @@ export { default as DHApplicationMixin } from './application-mixin.mjs';
|
|||
export { default as DHBaseItemSheet } from './base-item.mjs';
|
||||
export { default as DHHeritageSheet } from './heritage-sheet.mjs';
|
||||
export { default as DHBaseActorSheet } from "./base-actor.mjs";
|
||||
export { default as DHBaseActorSettings } from "./actor-setting.mjs";
|
||||
|
|
|
|||
51
module/applications/sheets/api/actor-setting.mjs
Normal file
51
module/applications/sheets/api/actor-setting.mjs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import DHApplicationMixin from './application-mixin.mjs';
|
||||
const { DocumentSheetV2 } = foundry.applications.api;
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
||||
/**
|
||||
* Base settings sheet for Daggerheart actors.
|
||||
* @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 */
|
||||
_initializeApplicationOptions(options) {
|
||||
options = super._initializeApplicationOptions(options);
|
||||
options.classes = options.classes.filter(c => c !== "sheet");
|
||||
return options;
|
||||
}
|
||||
|
||||
/**@returns {foundry.documents.Actor} */
|
||||
get actor() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -221,17 +221,15 @@ export default function DHApplicationMixin(Base) {
|
|||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||
*/
|
||||
static async #createDoc(event, button) {
|
||||
const { type } = button.dataset;
|
||||
const operation = {
|
||||
parent: this.document,
|
||||
pack: this.document.pack,
|
||||
renderSheet: !event.shiftKey,
|
||||
}
|
||||
const { documentClass, type } = button.dataset;
|
||||
console.log(documentClass, type);
|
||||
const parent = this.document;
|
||||
|
||||
const cls = getDocumentClass(type);
|
||||
const cls = getDocumentClass(documentClass);
|
||||
return await cls.createDocuments([{
|
||||
name: cls.defaultName(operation)
|
||||
}], operation);
|
||||
name: cls.defaultName({ type, parent }),
|
||||
type,
|
||||
}], { parent, renderSheet: !event.shiftKey });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import DHBaseActorSettings from './actor-setting.mjs';
|
||||
import DHApplicationMixin from './application-mixin.mjs';
|
||||
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
|
|
@ -25,14 +26,13 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
dragDrop: [],
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**@type {typeof DHBaseActorSettings}*/
|
||||
#settingSheet;
|
||||
|
||||
/**@returns {DHBaseActorSettings|null} */
|
||||
get settingSheet() {
|
||||
const SheetClass = this.document.system.metadata.settingSheet;
|
||||
return this.#settingSheet ??= SheetClass ? new SheetClass(this.document): null;
|
||||
return this.#settingSheet ??= SheetClass ? new SheetClass({document: this.document}): null;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
|
|
@ -43,7 +43,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Open the Actor Setting Sheet
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #openSettings() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import DHApplicationMixin from './application-mixin.mjs';
|
|||
|
||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
||||
/**
|
||||
* A base item sheet extending {@link ItemSheetV2} via {@link DHApplicationMixin}
|
||||
* @extends ItemSheetV2
|
||||
|
|
@ -92,8 +94,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Add a new action to the item, prompting the user for its type.
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #addAction(_event, _button) {
|
||||
const actionType = await DHBaseItemSheet.selectActionType();
|
||||
|
|
@ -124,8 +125,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Edit an existing action on the item
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="editAction"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #editAction(_event, button) {
|
||||
const action = this.document.system.actions[button.dataset.index];
|
||||
|
|
@ -134,8 +134,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Remove an action from the item.
|
||||
* @param {PointerEvent} event - The originating click event
|
||||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #removeAction(event, button) {
|
||||
event.stopPropagation();
|
||||
|
|
@ -147,8 +146,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Add a new feature to the item, prompting the user for its type.
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addFeature"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #addFeature(_event, _button) {
|
||||
const feature = await game.items.documentClass.create({
|
||||
|
|
@ -162,8 +160,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Edit an existing feature on the item
|
||||
* @param {PointerEvent} _event - The originating click event
|
||||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="editFeature"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #editFeature(_event, button) {
|
||||
const target = button.closest('.feature-item');
|
||||
|
|
@ -178,8 +175,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
/**
|
||||
* Remove a feature from the item.
|
||||
* @param {PointerEvent} event - The originating click event
|
||||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeFeature"]
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #removeFeature(event, button) {
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue