mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
FEAT: add DHHeritageSheet
This commit is contained in:
parent
89e1511aaa
commit
61ea8b85fb
7 changed files with 276 additions and 209 deletions
|
|
@ -1,2 +1,3 @@
|
||||||
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';
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,11 @@ export default function DHApplicationMixin(Base) {
|
||||||
width: 480,
|
width: 480,
|
||||||
height: 'auto'
|
height: 'auto'
|
||||||
},
|
},
|
||||||
|
actions: {
|
||||||
|
addEffect: DHSheetV2.#addEffect,
|
||||||
|
editEffect: DHSheetV2.#editEffect,
|
||||||
|
removeEffect: DHSheetV2.#removeEffect
|
||||||
|
},
|
||||||
dragDrop: []
|
dragDrop: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -96,6 +100,44 @@ export default function DHApplicationMixin(Base) {
|
||||||
context.systemFields = this[objectPath].system ? this[objectPath].system.schema.fields : {};
|
context.systemFields = this[objectPath].system ? this[objectPath].system.schema.fields : {};
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* Application Clicks Actions */
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders an ActiveEffect's sheet sheet.
|
||||||
|
* @param {PointerEvent} event - The originating click event
|
||||||
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||||
|
*/
|
||||||
|
static async #addEffect() {
|
||||||
|
const cls = foundry.documents.ActiveEffect;
|
||||||
|
await cls.create(
|
||||||
|
{
|
||||||
|
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize(cls.metadata.label) })
|
||||||
|
},
|
||||||
|
{ parent: this.document }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders an ActiveEffect's sheet sheet.
|
||||||
|
* @param {PointerEvent} event - The originating click event
|
||||||
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||||
|
*/
|
||||||
|
static async #editEffect(_event, button) {
|
||||||
|
const effect = this.document.effects.get(button.dataset.effect);
|
||||||
|
effect.sheet.render({ force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an ActiveEffect from the item.
|
||||||
|
* @param {PointerEvent} _event - The originating click event
|
||||||
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="removeAction"]
|
||||||
|
*/
|
||||||
|
static async #removeEffect(_event, button) {
|
||||||
|
await this.document.effects.get(button.dataset.effect).delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DHSheetV2;
|
return DHSheetV2;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import DHApplicationMixin from "./application-mixin.mjs";
|
import DHApplicationMixin from './application-mixin.mjs';
|
||||||
import { actionsTypes } from "../../../data/_module.mjs";
|
import { actionsTypes } from '../../../data/_module.mjs';
|
||||||
import DHActionConfig from "../../config/Action.mjs";
|
import DHActionConfig from '../../config/Action.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
const { ItemSheetV2 } = foundry.applications.sheets;
|
||||||
|
|
||||||
|
|
@ -29,15 +29,11 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static TABS = {
|
static TABS = {
|
||||||
primary: {
|
primary: {
|
||||||
tabs: [
|
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }],
|
||||||
{ id: 'description' },
|
initial: 'description',
|
||||||
{ id: 'actions' },
|
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||||
{ id: 'settings' }
|
|
||||||
],
|
|
||||||
initial: "description",
|
|
||||||
labelPrefix: "DAGGERHEART.Sheets.TABS"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Application Clicks Actions */
|
/* Application Clicks Actions */
|
||||||
|
|
@ -79,7 +75,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
* @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"]
|
* @param {HTMLElement} _button - The capturing HTML element which defines the [data-action="addAction"]
|
||||||
*/
|
*/
|
||||||
static async #addAction(_event, _button) {
|
static async #addAction(_event, _button) {
|
||||||
const actionType = await DHBaseItemSheet.selectActionType()
|
const actionType = await DHBaseItemSheet.selectActionType();
|
||||||
try {
|
try {
|
||||||
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
const cls = actionsTypes[actionType?.type] ?? actionsTypes.attack,
|
||||||
action = new cls(
|
action = new cls(
|
||||||
|
|
@ -94,7 +90,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
await this.document.update({ 'system.actions': [...this.document.system.actions, action] });
|
||||||
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render({force: true});
|
await new DHActionConfig(this.document.system.actions[this.document.system.actions.length - 1]).render({
|
||||||
|
force: true
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
@ -102,12 +100,12 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit an existing action on the item
|
* Edit an existing action on the item
|
||||||
* @param {PointerEvent} event - The originating click event
|
* @param {PointerEvent} _event - The originating click event
|
||||||
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="editAction"]
|
* @param {HTMLElement} button - The capturing HTML element which defines the [data-action="editAction"]
|
||||||
*/
|
*/
|
||||||
static async #editAction(_event, button) {
|
static async #editAction(_event, button) {
|
||||||
const action = this.document.system.actions[button.dataset.index];
|
const action = this.document.system.actions[button.dataset.index];
|
||||||
await new DHActionConfig(action).render(true);
|
await new DHActionConfig(action).render({ force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,5 +121,4 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
31
module/applications/sheets/api/heritage-sheet.mjs
Normal file
31
module/applications/sheets/api/heritage-sheet.mjs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import DHBaseItemSheet from './base-item.mjs';
|
||||||
|
|
||||||
|
export default class DHHeritageSheet extends DHBaseItemSheet {
|
||||||
|
/**@inheritdoc */
|
||||||
|
static DEFAULT_OPTIONS = {
|
||||||
|
position: { width: 450, height: 700 }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**@override */
|
||||||
|
static PARTS = {
|
||||||
|
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||||
|
description: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-description.hbs' },
|
||||||
|
actions: {
|
||||||
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-actions.hbs',
|
||||||
|
scrollable: ['.actions']
|
||||||
|
},
|
||||||
|
effects: {
|
||||||
|
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||||
|
scrollable: ['.effects']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @override*/
|
||||||
|
static TABS = {
|
||||||
|
primary: {
|
||||||
|
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'effects' }],
|
||||||
|
initial: 'description',
|
||||||
|
labelPrefix: 'DAGGERHEART.Sheets.TABS'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import DHHeritageSheetV2 from './heritage.mjs';
|
import DHHeritageSheet from '../api/heritage-sheet.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
export default class AncestrySheet extends DHHeritageSheet {
|
||||||
export default class AncestrySheet extends DHHeritageSheetV2(ItemSheetV2) {
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
classes: ['ancestry']
|
classes: ['ancestry']
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,11 @@ export default class ClassSheet extends DHBaseItemSheet {
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static TABS = {
|
static TABS = {
|
||||||
primary: {
|
primary: {
|
||||||
tabs: [
|
tabs: [{ id: 'description' }, { id: 'settings' }],
|
||||||
{ id: 'description' },
|
initial: 'description',
|
||||||
{ id: 'settings' },
|
labelPrefix: 'DAGGERHEART.Sheets.Feature.Tabs'
|
||||||
],
|
|
||||||
initial: "description",
|
|
||||||
labelPrefix: "DAGGERHEART.Sheets.Feature.Tabs"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_attachPartListeners(partId, htmlElement, options) {
|
_attachPartListeners(partId, htmlElement, options) {
|
||||||
super._attachPartListeners(partId, htmlElement, options);
|
super._attachPartListeners(partId, htmlElement, options);
|
||||||
|
|
@ -72,7 +69,6 @@ export default class ClassSheet extends DHBaseItemSheet {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onAddTag(e) {
|
onAddTag(e) {
|
||||||
if (e.detail.index === 2) {
|
if (e.detail.index === 2) {
|
||||||
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.ClassCanOnlyHaveTwoDomains'));
|
ui.notifications.info(game.i18n.localize('DAGGERHEART.Notification.Info.ClassCanOnlyHaveTwoDomains'));
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import DHHeritageSheetV2 from './heritage.mjs';
|
import DHHeritageSheet from '../api/heritage-sheet.mjs';
|
||||||
|
|
||||||
const { ItemSheetV2 } = foundry.applications.sheets;
|
export default class CommunitySheet extends DHHeritageSheet {
|
||||||
export default class CommunitySheet extends DHHeritageSheetV2(ItemSheetV2) {
|
/**@inheritdoc */
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
classes: ['community']
|
classes: ['community']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**@inheritdoc */
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
header: { template: 'systems/daggerheart/templates/sheets/items/community/header.hbs' },
|
header: { template: 'systems/daggerheart/templates/sheets/items/community/header.hbs' },
|
||||||
...super.PARTS
|
...super.PARTS
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue