From 0e3f2fe6329d0580976bc228584f07e91ebe4ae6 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 9 Mar 2026 14:18:27 +0100 Subject: [PATCH] . --- module/applications/ui/itemBrowser.mjs | 2 +- module/data/item/armor.mjs | 4 +-- module/data/item/base.mjs | 4 +-- module/data/item/weapon.mjs | 17 +++------- module/systemRegistration/handlebars.mjs | 3 +- styles/less/global/global.less | 18 +++++++++++ styles/less/global/inventory-item.less | 18 ----------- .../global/partials/inventory-item-V2.hbs | 30 ++++++----------- .../sheets/global/partials/item-tags.hbs | 8 +++++ templates/sheets/items/armor/description.hbs | 14 ++------ templates/sheets/items/weapon/description.hbs | 32 ++----------------- 11 files changed, 51 insertions(+), 99 deletions(-) create mode 100644 templates/sheets/global/partials/item-tags.hbs diff --git a/module/applications/ui/itemBrowser.mjs b/module/applications/ui/itemBrowser.mjs index 2d882eba..8e51133e 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?.({ inCompendium: 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..6eb3042f 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({ inCompendium }) { 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, inCompendium, features } ); return { prefix, value: baseDescription, suffix: null }; diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index 84f39103..d40c1ceb 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 = { inCompendium: 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..9651efda 100644 --- a/module/data/item/weapon.mjs +++ b/module/data/item/weapon.mjs @@ -109,27 +109,18 @@ export default class DHWeapon extends AttachableItem { } /**@inheritdoc */ - async getDescriptionData() { + async getDescriptionData({ inCompendium }) { const baseDescription = this.description; - const tier = game.i18n.localize(`DAGGERHEART.GENERAL.Tiers.${this.tier}`); - const trait = game.i18n.localize(CONFIG.DH.ACTOR.abilities[this.attack.roll.trait].label); - const range = game.i18n.localize(`DAGGERHEART.CONFIG.Range.${this.attack.range}.name`); - const damage = Roll.replaceFormulaData(this.attack.damageFormula, this.parent.parent ?? this.parent); - const burden = game.i18n.localize(CONFIG.DH.GENERAL.burden[this.burden].label); - const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures(); const features = this.weaponFeatures.map(x => allFeatures[x.value]).filter(x => x); const prefix = await foundry.applications.handlebars.renderTemplate( 'systems/daggerheart/templates/sheets/items/weapon/description.hbs', { - features, - tier, - trait, - range, - damage, - burden + item: this, + inCompendium, + features } ); diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index de085221..9ccb16f4 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -17,9 +17,10 @@ export const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/sheets/global/partials/resource-section/dice-value.hbs', 'systems/daggerheart/templates/sheets/global/partials/resource-section/die.hbs', 'systems/daggerheart/templates/sheets/global/partials/resource-bar.hbs', + 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs', + 'systems/daggerheart/templates/sheets/global/partials/item-tags.hbs', 'systems/daggerheart/templates/components/card-preview.hbs', 'systems/daggerheart/templates/levelup/parts/selectable-card-preview.hbs', - 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs', 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs', 'systems/daggerheart/templates/actionTypes/damage.hbs', 'systems/daggerheart/templates/actionTypes/resource.hbs', diff --git a/styles/less/global/global.less b/styles/less/global/global.less index fb995b8c..b9af67c0 100644 --- a/styles/less/global/global.less +++ b/styles/less/global/global.less @@ -73,6 +73,24 @@ } } } + + .item-tags { + display: flex; + gap: 10px; + + .tag { + align-items: center; + background: light-dark(@dark-15, @beige-15); + border-radius: 3px; + border: 1px solid light-dark(@dark, @beige); + display: flex; + flex-direction: row; + flex-wrap: wrap; + font-size: var(--font-size-12); + justify-content: start; + padding: 3px 5px; + } + } } /* TODO: Remove me when this issue is resolved https://github.com/foundryvtt/foundryvtt/issues/13734 */ diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index d703d189..4bd4d0bb 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -138,24 +138,6 @@ display: none; } } - - .item-tags { - display: flex; - gap: 10px; - - .tag { - align-items: center; - background: light-dark(@dark-15, @beige-15); - border-radius: 3px; - border: 1px solid light-dark(@dark, @beige); - display: flex; - flex-direction: row; - flex-wrap: wrap; - font-size: var(--font-size-12); - justify-content: start; - padding: 3px 5px; - } - } } .item-resource { diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index e496ce4b..86d2e2d3 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -45,30 +45,20 @@ Parameters: {{localize item.name}} {{#unless (or noExtensible (not item.system.description))}}{{/unless}} {{!-- Tags Start --}} - {{#with item}} - {{#if (not ../hideTags)}} -
- {{#each this._getTags as |tag|}} -
- {{tag}} -
- {{/each}} - - {{!-- Feature Form Tag Start --}} - {{#if (eq ../type 'feature')}} - {{#if (or (eq @root.document.type 'adversary') (eq @root.document.type 'environment'))}} - {{#if system.featureForm}} -
- {{localize (concat "DAGGERHEART.CONFIG.FeatureForm." system.featureForm)}} -
+ {{#if (not ../hideTags)}} + {{#> "systems/daggerheart/templates/sheets/global/partials/item-tags.hbs" item }} + {{#if (eq ../type 'feature')}} + {{#if (or (eq @root.document.type 'adversary') (eq @root.document.type 'environment'))}} + {{#if system.featureForm}} +
+ {{localize (concat "DAGGERHEART.CONFIG.FeatureForm." system.featureForm)}} +
+ {{/if}} {{/if}} {{/if}} + {{/ "systems/daggerheart/templates/sheets/global/partials/item-tags.hbs"}} {{/if}} - {{!-- Feature Form Tag End --}} -
- {{/if}} - {{/with}} {{!--Tags End --}} diff --git a/templates/sheets/global/partials/item-tags.hbs b/templates/sheets/global/partials/item-tags.hbs new file mode 100644 index 00000000..b30fcbf2 --- /dev/null +++ b/templates/sheets/global/partials/item-tags.hbs @@ -0,0 +1,8 @@ +
+ {{#each _getTags as |tag|}} +
+ {{tag}} +
+ {{/each}} + {{#if @partial-block}}{{> @partial-block}}{{/if}} +
\ No newline at end of file diff --git a/templates/sheets/items/armor/description.hbs b/templates/sheets/items/armor/description.hbs index c234fa10..e684f3f1 100644 --- a/templates/sheets/items/armor/description.hbs +++ b/templates/sheets/items/armor/description.hbs @@ -1,16 +1,6 @@
-
-
-

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

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

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

- {{item.system.baseScore}} -
-
- + {{#if inCompendium}}{{> "systems/daggerheart/templates/sheets/global/partials/item-tags.hbs" item }}{{/if}} + {{#if features.length}}

{{localize "DAGGERHEART.GENERAL.features"}}

diff --git a/templates/sheets/items/weapon/description.hbs b/templates/sheets/items/weapon/description.hbs index d8e128e7..88d72c99 100644 --- a/templates/sheets/items/weapon/description.hbs +++ b/templates/sheets/items/weapon/description.hbs @@ -1,36 +1,8 @@
-
-
-

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

- {{tier}} -
- -
-

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

- {{trait}} -
- -
-

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

- {{range}} -
-
- -
-
-

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

- {{damage}} -
- -
-

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

- {{burden}} -
-
- + {{#if inCompendium}}{{> "systems/daggerheart/templates/sheets/global/partials/item-tags.hbs" item }}{{/if}} + {{#if features.length}}
-

{{localize "DAGGERHEART.GENERAL.features"}}

{{#each features as | feature |}}
{{localize feature.label}}: {{{localize feature.description}}}
{{/each}}