From e1fef44d213d451fceec4c6bdf30024fc2d511b3 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 7 Mar 2026 00:31:33 +0100 Subject: [PATCH] Improved description enrichment to not bloat it outside of the CompendiumBrowser --- module/applications/ui/itemBrowser.mjs | 2 +- module/data/item/armor.mjs | 4 +- module/data/item/base.mjs | 4 +- module/data/item/weapon.mjs | 5 +- system.json | 2 +- templates/sheets/items/armor/description.hbs | 20 ++++---- templates/sheets/items/weapon/description.hbs | 50 ++++++++++--------- 7 files changed, 46 insertions(+), 41 deletions(-) diff --git a/module/applications/ui/itemBrowser.mjs b/module/applications/ui/itemBrowser.mjs index 2d882eba..065d211f 100644 --- a/module/applications/ui/itemBrowser.mjs +++ b/module/applications/ui/itemBrowser.mjs @@ -252,7 +252,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) { /* If any noticeable slowdown occurs, consider replacing with enriching description on clicking to expand descriptions */ for (const item of this.items) { item.system.enrichedDescription = - (await item.system.getEnrichedDescription?.()) ?? + (await item.system.getEnrichedDescription?.({ inCompendiumBrowser: true })) ?? (await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.description)); } diff --git a/module/data/item/armor.mjs b/module/data/item/armor.mjs index 0958a9f3..922cbd69 100644 --- a/module/data/item/armor.mjs +++ b/module/data/item/armor.mjs @@ -53,14 +53,14 @@ export default class DHArmor extends AttachableItem { } /**@inheritdoc */ - async getDescriptionData() { + async getDescriptionData({ inCompendiumBrowser }) { const baseDescription = this.description; const allFeatures = CONFIG.DH.ITEM.allArmorFeatures(); const features = this.armorFeatures.map(x => allFeatures[x.value]).filter(x => x); const prefix = await foundry.applications.handlebars.renderTemplate( 'systems/daggerheart/templates/sheets/items/armor/description.hbs', - { item: this.parent, features } + { item: this.parent, features, inCompendiumBrowser } ); return { prefix, value: baseDescription, suffix: null }; diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index 84f39103..912f5273 100644 --- a/module/data/item/base.mjs +++ b/module/data/item/base.mjs @@ -138,10 +138,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel { * @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' } * @returns {string} */ - async getEnrichedDescription() { + async getEnrichedDescription(options = { inCompendiumBrowser: false }) { if (!this.metadata.hasDescription) return ''; - const { prefix, value, suffix } = await this.getDescriptionData(); + const { prefix, value, suffix } = await this.getDescriptionData(options); const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n
\n'); return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, { diff --git a/module/data/item/weapon.mjs b/module/data/item/weapon.mjs index 051fd42d..43eeec2c 100644 --- a/module/data/item/weapon.mjs +++ b/module/data/item/weapon.mjs @@ -109,7 +109,7 @@ export default class DHWeapon extends AttachableItem { } /**@inheritdoc */ - async getDescriptionData() { + async getDescriptionData({ inCompendiumBrowser }) { const baseDescription = this.description; const tier = game.i18n.localize(`DAGGERHEART.GENERAL.Tiers.${this.tier}`); @@ -129,7 +129,8 @@ export default class DHWeapon extends AttachableItem { trait, range, damage, - burden + burden, + inCompendiumBrowser } ); diff --git a/system.json b/system.json index 40de5fa1..fc5e1615 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "daggerheart", "title": "Daggerheart", "description": "An unofficial implementation of the Daggerheart system", - "version": "1.7.3", + "version": "1.8.0", "compatibility": { "minimum": "13.346", "verified": "13.351", diff --git a/templates/sheets/items/armor/description.hbs b/templates/sheets/items/armor/description.hbs index c234fa10..d4686e4e 100644 --- a/templates/sheets/items/armor/description.hbs +++ b/templates/sheets/items/armor/description.hbs @@ -1,15 +1,17 @@
-
-
-

{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}

- {{item.system.baseThresholds.major}}/{{item.system.baseThresholds.severe}} -
+ {{#if inCompendiumBrowser}} +
+
+

{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}

+ {{item.system.baseThresholds.major}}/{{item.system.baseThresholds.severe}} +
-
-

{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}

- {{item.system.baseScore}} +
+

{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}

+ {{item.system.baseScore}} +
-
+ {{/if}} {{#if features.length}}
diff --git a/templates/sheets/items/weapon/description.hbs b/templates/sheets/items/weapon/description.hbs index d8e128e7..4355d8a4 100644 --- a/templates/sheets/items/weapon/description.hbs +++ b/templates/sheets/items/weapon/description.hbs @@ -1,32 +1,34 @@
-
-
-

{{localize "DAGGERHEART.GENERAL.Tiers.singular"}}

- {{tier}} + {{#if inCompendiumBrowser}} +
+
+

{{localize "DAGGERHEART.GENERAL.Tiers.singular"}}

+ {{tier}} +
+ +
+

{{localize "DAGGERHEART.GENERAL.Trait.single"}}

+ {{trait}} +
+ +
+

{{localize "DAGGERHEART.GENERAL.range"}}

+ {{range}} +
-
-

{{localize "DAGGERHEART.GENERAL.Trait.single"}}

- {{trait}} -
+
+
+

{{localize "DAGGERHEART.GENERAL.damage"}}

+ {{damage}} +
-
-

{{localize "DAGGERHEART.GENERAL.range"}}

- {{range}} +
+

{{localize "DAGGERHEART.GENERAL.burden"}}

+ {{burden}} +
-
- -
-
-

{{localize "DAGGERHEART.GENERAL.damage"}}

- {{damage}} -
- -
-

{{localize "DAGGERHEART.GENERAL.burden"}}

- {{burden}} -
-
+ {{/if}} {{#if features.length}}