mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 12:11:07 +01:00
Bug/103 enrich htmlfield content before its used in applications (#369)
* FIX: Add enritch to HTMLField FIX: Remove no-HTMLField from Manifest FIX: Convert Scar's HTMLField to StringField FIX: Remove unused HTMLField * REMOVE unused hanldebars helpers * FEAT: add inventory-fieldset-items-V2 and inventory-item-V2 partials for Actors * FIX showLabels to hideTags * FEAT: add template to items sheet * FEAT: add effects tabs on ItemSheet * FEAT: add context menus for all inventory-items * FEAT: add resources to inventory-item template * FEAT: add enritch on inventory-item description FEAT: add extensible behavior on inventory-item-content FEAT: add fade effect on item-img to roll-itmg * FEAT: add eritch to NPC description FIX: missing htmlFieldss on manfiest FIX: add misisng localizations * FIX_ minor fixes * Little resource fix. Noone will notice ._. * FIX: remove default list styles FIX: .extended css reduce max-height, shorten animation duration to 0.5s, and set overflow to auto. FIX: set enriched=notes.enriche on notes.hbs FIX: set experience.value on sidebar.hbs FIX: move tooltip from item-img to img-portrait on inventory-item-V2.hbs REMOVE: unused files --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
615df65415
commit
b8930b18a4
61 changed files with 1768 additions and 1434 deletions
|
|
@ -5,7 +5,6 @@ export default class AncestrySheet extends DHHeritageSheet {
|
|||
static DEFAULT_OPTIONS = {
|
||||
classes: ['ancestry'],
|
||||
actions: {
|
||||
addFeature: AncestrySheet.#addFeature,
|
||||
editFeature: AncestrySheet.#editFeature,
|
||||
removeFeature: AncestrySheet.#removeFeature
|
||||
},
|
||||
|
|
@ -23,23 +22,6 @@ export default class AncestrySheet extends DHHeritageSheet {
|
|||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add a new feature to the item, prompting the user for its type.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #addFeature(_event, button) {
|
||||
const feature = await game.items.documentClass.create({
|
||||
type: 'feature',
|
||||
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') }),
|
||||
system: {
|
||||
subType: button.dataset.type
|
||||
}
|
||||
});
|
||||
await this.document.update({
|
||||
'system.features': [...this.document.system.features.map(x => x.uuid), feature.uuid]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing feature on the item
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ export default class ArmorSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
|
|||
template: 'systems/daggerheart/templates/sheets/items/armor/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
...super.PARTS
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
},
|
||||
...super.PARTS,
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
|
|
|
|||
|
|
@ -28,20 +28,4 @@ export default class BeastformSheet extends DHBaseItemSheet {
|
|||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
||||
context.document = context.document.toObject();
|
||||
context.document.effects = this.document.effects.map(effect => {
|
||||
const data = effect.toObject();
|
||||
data.id = effect.id;
|
||||
if (effect.type === 'beastform') data.mandatory = true;
|
||||
|
||||
return data;
|
||||
});
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,6 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
actions: {
|
||||
removeItemFromCollection: ClassSheet.#removeItemFromCollection,
|
||||
removeSuggestedItem: ClassSheet.#removeSuggestedItem,
|
||||
viewDoc: ClassSheet.#viewDoc,
|
||||
addFeature: this.addFeature,
|
||||
editFeature: this.editFeature,
|
||||
deleteFeature: this.deleteFeature
|
||||
},
|
||||
tagifyConfigs: [
|
||||
{
|
||||
|
|
@ -46,13 +42,17 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/class/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }],
|
||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }, { id: 'effects' }],
|
||||
initial: 'description',
|
||||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
|
|
@ -179,59 +179,4 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
const { target } = element.dataset;
|
||||
await this.document.update({ [`system.characterGuide.${target}`]: null });
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the sheet of a item by UUID.
|
||||
* @param {PointerEvent} _event -
|
||||
* @param {HTMLElement} button
|
||||
*/
|
||||
static async #viewDoc(_event, button) {
|
||||
const doc = await fromUuid(button.dataset.uuid);
|
||||
doc.sheet.render({ force: true });
|
||||
}
|
||||
|
||||
static async addFeature(_, target) {
|
||||
const feature = await game.items.documentClass.create({
|
||||
type: 'feature',
|
||||
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') }),
|
||||
system: {
|
||||
subType:
|
||||
target.dataset.type === 'hope'
|
||||
? CONFIG.DH.ITEM.featureSubTypes.hope
|
||||
: CONFIG.DH.ITEM.featureSubTypes.class
|
||||
}
|
||||
});
|
||||
await this.document.update({
|
||||
[`system.features`]: [...this.document.system.features.filter(x => x).map(x => x.uuid), feature.uuid]
|
||||
});
|
||||
}
|
||||
|
||||
static async editFeature(_, button) {
|
||||
const target = button.closest('.feature-item');
|
||||
const feature = this.document.system.features.find(x => x?.id === target.dataset.featureId);
|
||||
if (!feature) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async deleteFeature(event, button) {
|
||||
event.stopPropagation();
|
||||
const target = button.closest('.feature-item');
|
||||
|
||||
const feature = this.document.system.features.find(
|
||||
feature => feature && feature.id === target.dataset.featureId
|
||||
);
|
||||
if (feature) {
|
||||
await feature.update({ 'system.subType': null });
|
||||
}
|
||||
|
||||
await this.document.update({
|
||||
[`system.features`]: this.document.system.features
|
||||
.filter(feature => feature && feature.id !== target.dataset.featureId)
|
||||
.map(x => x.uuid)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default class CommunitySheet extends DHHeritageSheet {
|
|||
static PARTS = {
|
||||
header: { template: 'systems/daggerheart/templates/sheets/items/community/header.hbs' },
|
||||
...super.PARTS,
|
||||
feature: {
|
||||
features: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-features.hbs',
|
||||
scrollable: ['.feature']
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ export default class ConsumableSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/consumable/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { actionsTypes } from '../../../data/action/_module.mjs';
|
||||
import DHActionConfig from '../../sheets-configs/action-config.mjs';
|
||||
import DHBaseItemSheet from '../api/base-item.mjs';
|
||||
|
||||
export default class FeatureSheet extends DHBaseItemSheet {
|
||||
|
|
@ -7,13 +5,7 @@ export default class FeatureSheet extends DHBaseItemSheet {
|
|||
static DEFAULT_OPTIONS = {
|
||||
id: 'daggerheart-feature',
|
||||
classes: ['feature'],
|
||||
position: { height: 600 },
|
||||
window: { resizable: true },
|
||||
actions: {
|
||||
addAction: FeatureSheet.#addAction,
|
||||
editAction: FeatureSheet.#editAction,
|
||||
removeAction: FeatureSheet.#removeAction
|
||||
}
|
||||
actions: {}
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -40,96 +32,4 @@ export default class FeatureSheet extends DHBaseItemSheet {
|
|||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Render a dialog prompting the user to select an action type.
|
||||
*
|
||||
* @returns {Promise<object>} An object containing the selected action type.
|
||||
*/
|
||||
static async selectActionType() {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
||||
{
|
||||
types: CONFIG.DH.ACTIONS.actionTypes,
|
||||
itemName: game.i18n.localize('DAGGERHEART.CONFIG.SelectAction.selectType')
|
||||
}
|
||||
),
|
||||
title = game.i18n.localize('DAGGERHEART.CONFIG.SelectAction.selectType');
|
||||
|
||||
return foundry.applications.api.DialogV2.prompt({
|
||||
window: { title },
|
||||
classes: ['daggerheart', 'dh-style'],
|
||||
content,
|
||||
ok: {
|
||||
label: title,
|
||||
callback: (event, button, dialog) => button.form.elements.type.value
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"]
|
||||
*/
|
||||
static async #addAction(_event, _button) {
|
||||
const actionType = await FeatureSheet.selectActionType();
|
||||
if (!actionType) return;
|
||||
try {
|
||||
const cls = actionsTypes[actionType] ?? actionsTypes.attack,
|
||||
action = new cls(
|
||||
{
|
||||
_id: foundry.utils.randomID(),
|
||||
type: actionType,
|
||||
name: game.i18n.localize(CONFIG.DH.ACTIONS.actionTypes[actionType].name),
|
||||
...cls.getSourceConfig(this.document)
|
||||
},
|
||||
{
|
||||
parent: this.document
|
||||
}
|
||||
);
|
||||
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
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"]
|
||||
*/
|
||||
static async #editAction(_event, button) {
|
||||
const action = this.document.system.actions[button.dataset.index];
|
||||
await new DHActionConfig(action).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"]
|
||||
*/
|
||||
static async #removeAction(event, button) {
|
||||
event.stopPropagation();
|
||||
const actionIndex = button.closest('[data-index]').dataset.index;
|
||||
await this.document.update({
|
||||
'system.actions': this.document.system.actions.filter((_, index) => index !== Number.parseInt(actionIndex))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ export default class MiscellaneousSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/miscellaneous/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
|||
classes: ['subclass'],
|
||||
position: { width: 600 },
|
||||
window: { resizable: false },
|
||||
actions: {
|
||||
addFeature: this.addFeature,
|
||||
editFeature: this.editFeature,
|
||||
deleteFeature: this.deleteFeature
|
||||
}
|
||||
actions: {}
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -25,64 +21,22 @@ export default class SubclassSheet extends DHBaseItemSheet {
|
|||
settings: {
|
||||
template: 'systems/daggerheart/templates/sheets/items/subclass/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }],
|
||||
tabs: [{ id: 'description' }, { id: 'features' }, { id: 'settings' }, { id: 'effects' }],
|
||||
initial: 'description',
|
||||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
};
|
||||
|
||||
static async addFeature(_, target) {
|
||||
const feature = await game.items.documentClass.create({
|
||||
type: 'feature',
|
||||
name: game.i18n.format('DOCUMENT.New', { type: game.i18n.localize('TYPES.Item.feature') }),
|
||||
system: {
|
||||
subType:
|
||||
target.dataset.type === 'foundation'
|
||||
? CONFIG.DH.ITEM.featureSubTypes.foundation
|
||||
: target.dataset.type === 'specialization'
|
||||
? CONFIG.DH.ITEM.featureSubTypes.specialization
|
||||
: CONFIG.DH.ITEM.featureSubTypes.mastery
|
||||
}
|
||||
});
|
||||
await this.document.update({
|
||||
[`system.features`]: [...this.document.system.features.map(x => x.uuid), feature.uuid]
|
||||
});
|
||||
}
|
||||
|
||||
static async editFeature(_, button) {
|
||||
const feature = this.document.system.features.find(x => x.id === button.dataset.feature);
|
||||
if (!feature) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (feature) {
|
||||
await feature.update({ 'system.subType': null });
|
||||
}
|
||||
|
||||
feature.sheet.render(true);
|
||||
}
|
||||
|
||||
static async deleteFeature(event, target) {
|
||||
event.stopPropagation();
|
||||
const feature = this.document.system.features.find(feature => feature.id === target.dataset.feature);
|
||||
if (feature) {
|
||||
await feature.update({ 'system.subType': null });
|
||||
}
|
||||
|
||||
await this.document.update({
|
||||
[`system.features`]: this.document.system.features
|
||||
.filter(feature => feature && feature.id !== target.dataset.feature)
|
||||
.map(x => x.uuid)
|
||||
});
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
const featureItem = event.currentTarget.closest('.drop-section');
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,11 @@ export default class WeaponSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
|
|||
template: 'systems/daggerheart/templates/sheets/items/weapon/settings.hbs',
|
||||
scrollable: ['.settings']
|
||||
},
|
||||
...super.PARTS
|
||||
effects: {
|
||||
template: 'systems/daggerheart/templates/sheets/global/tabs/tab-effects.hbs',
|
||||
scrollable: ['.effects']
|
||||
},
|
||||
...super.PARTS,
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue