mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
.
This commit is contained in:
parent
9d353fe54a
commit
4a027e8591
8 changed files with 45 additions and 16 deletions
|
|
@ -79,7 +79,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
|
||||
switch (partId) {
|
||||
case 'description':
|
||||
context.enrichedDescription = await this.document.system.getEnrichedDescription(true);
|
||||
context.enrichedDescription = await this.document.system.getEnrichedDescription({
|
||||
headerStyle: 'large'
|
||||
});
|
||||
break;
|
||||
case 'effects':
|
||||
await this._prepareEffectsContext(context, options);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export default class DHArmor extends AttachableItem {
|
|||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData(large) {
|
||||
async getDescriptionData(options = {}) {
|
||||
const baseDescription = await super.getDescriptionData();
|
||||
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
|
||||
const features = this.armorFeatures.map(x => allFeatures[x.value]);
|
||||
|
|
@ -63,7 +63,7 @@ export default class DHArmor extends AttachableItem {
|
|||
|
||||
const prepend = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/sheets/items/armor/description.hbs',
|
||||
{ features, large }
|
||||
{ features, headerStyle: options.headerStyle }
|
||||
);
|
||||
|
||||
const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
|
||||
|
|
|
|||
|
|
@ -124,16 +124,24 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
return [source, page ? `pg ${page}.` : null].filter(x => x).join('. ');
|
||||
}
|
||||
|
||||
/** */
|
||||
async getDescriptionData() {
|
||||
/**
|
||||
* Augments the description for the item with type specific info to display. Implemented in applicable item subtypes.
|
||||
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
|
||||
* @returns {string}
|
||||
*/
|
||||
async getDescriptionData(_options) {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/** */
|
||||
async getEnrichedDescription(large) {
|
||||
/**
|
||||
* Gets the enriched and augmented description for the item.
|
||||
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
|
||||
* @returns {string}
|
||||
*/
|
||||
async getEnrichedDescription(options) {
|
||||
if (!this.metadata.hasDescription) return '';
|
||||
|
||||
const description = await this.getDescriptionData(large);
|
||||
const description = await this.getDescriptionData(options);
|
||||
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(description, {
|
||||
relativeTo: this,
|
||||
rollData: this.getRollData(),
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ export default class DHWeapon extends AttachableItem {
|
|||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData(large) {
|
||||
async getDescriptionData(options = {}) {
|
||||
const baseDescription = await super.getDescriptionData();
|
||||
const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures();
|
||||
const features = this.weaponFeatures.map(x => allFeatures[x.value]);
|
||||
|
|
@ -119,7 +119,7 @@ export default class DHWeapon extends AttachableItem {
|
|||
|
||||
const prepend = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/sheets/items/weapon/description.hbs',
|
||||
{ features, large }
|
||||
{ features, headerStyle: options.headerStyle }
|
||||
);
|
||||
|
||||
const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
|
||||
|
|
|
|||
|
|
@ -220,12 +220,16 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
for (const [index, itemValue] of pathValue.entries()) {
|
||||
const itemIsAction = itemValue instanceof game.system.api.models.actions.actionsTypes.base;
|
||||
const value = itemIsAction || !itemValue?.item ? itemValue : itemValue.item;
|
||||
const enrichedValue = await TextEditor.enrichHTML(value.system?.description ?? value.description);
|
||||
const enrichedValue =
|
||||
(await value.system?.getEnrichedDescription?.({ headerStyle: 'none' })) ??
|
||||
(await TextEditor.enrichHTML(value.system?.description ?? value.description));
|
||||
if (itemIsAction) value.enrichedDescription = enrichedValue;
|
||||
else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue);
|
||||
}
|
||||
} else {
|
||||
const enrichedValue = await TextEditor.enrichHTML(pathValue);
|
||||
const enrichedValue =
|
||||
(await item.system?.getEnrichedDescription?.({ headerStyle: 'none' })) ??
|
||||
(await TextEditor.enrichHTML(pathValue));
|
||||
foundry.utils.setProperty(
|
||||
item,
|
||||
`${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue