mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Improved description enrichment to not bloat it outside of the CompendiumBrowser
This commit is contained in:
parent
83c3da0130
commit
e1fef44d21
7 changed files with 46 additions and 41 deletions
|
|
@ -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 */
|
/* If any noticeable slowdown occurs, consider replacing with enriching description on clicking to expand descriptions */
|
||||||
for (const item of this.items) {
|
for (const item of this.items) {
|
||||||
item.system.enrichedDescription =
|
item.system.enrichedDescription =
|
||||||
(await item.system.getEnrichedDescription?.()) ??
|
(await item.system.getEnrichedDescription?.({ inCompendiumBrowser: true })) ??
|
||||||
(await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.description));
|
(await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,14 @@ export default class DHArmor extends AttachableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
async getDescriptionData() {
|
async getDescriptionData({ inCompendiumBrowser }) {
|
||||||
const baseDescription = this.description;
|
const baseDescription = this.description;
|
||||||
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
|
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
|
||||||
const features = this.armorFeatures.map(x => allFeatures[x.value]).filter(x => x);
|
const features = this.armorFeatures.map(x => allFeatures[x.value]).filter(x => x);
|
||||||
|
|
||||||
const prefix = await foundry.applications.handlebars.renderTemplate(
|
const prefix = await foundry.applications.handlebars.renderTemplate(
|
||||||
'systems/daggerheart/templates/sheets/items/armor/description.hbs',
|
'systems/daggerheart/templates/sheets/items/armor/description.hbs',
|
||||||
{ item: this.parent, features }
|
{ item: this.parent, features, inCompendiumBrowser }
|
||||||
);
|
);
|
||||||
|
|
||||||
return { prefix, value: baseDescription, suffix: null };
|
return { prefix, value: baseDescription, suffix: null };
|
||||||
|
|
|
||||||
|
|
@ -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' }
|
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
async getEnrichedDescription() {
|
async getEnrichedDescription(options = { inCompendiumBrowser: false }) {
|
||||||
if (!this.metadata.hasDescription) return '';
|
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<hr>\n');
|
const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
|
||||||
|
|
||||||
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {
|
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ export default class DHWeapon extends AttachableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@inheritdoc */
|
/**@inheritdoc */
|
||||||
async getDescriptionData() {
|
async getDescriptionData({ inCompendiumBrowser }) {
|
||||||
const baseDescription = this.description;
|
const baseDescription = this.description;
|
||||||
|
|
||||||
const tier = game.i18n.localize(`DAGGERHEART.GENERAL.Tiers.${this.tier}`);
|
const tier = game.i18n.localize(`DAGGERHEART.GENERAL.Tiers.${this.tier}`);
|
||||||
|
|
@ -129,7 +129,8 @@ export default class DHWeapon extends AttachableItem {
|
||||||
trait,
|
trait,
|
||||||
range,
|
range,
|
||||||
damage,
|
damage,
|
||||||
burden
|
burden,
|
||||||
|
inCompendiumBrowser
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "daggerheart",
|
"id": "daggerheart",
|
||||||
"title": "Daggerheart",
|
"title": "Daggerheart",
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "1.7.3",
|
"version": "1.8.0",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "13.346",
|
"minimum": "13.346",
|
||||||
"verified": "13.351",
|
"verified": "13.351",
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
<div class="item-description-outer-container">
|
<div class="item-description-outer-container">
|
||||||
<div class="two-columns">
|
{{#if inCompendiumBrowser}}
|
||||||
<div class="item-description-container">
|
<div class="two-columns">
|
||||||
<h4>{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}</h4>
|
<div class="item-description-container">
|
||||||
<span>{{item.system.baseThresholds.major}}/{{item.system.baseThresholds.severe}}</span>
|
<h4>{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}</h4>
|
||||||
</div>
|
<span>{{item.system.baseThresholds.major}}/{{item.system.baseThresholds.severe}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="item-description-container">
|
<div class="item-description-container">
|
||||||
<h4>{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}</h4>
|
<h4>{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}</h4>
|
||||||
<span>{{item.system.baseScore}}</span>
|
<span>{{item.system.baseScore}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{/if}}
|
||||||
|
|
||||||
{{#if features.length}}
|
{{#if features.length}}
|
||||||
<div class="item-description-container">
|
<div class="item-description-container">
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,34 @@
|
||||||
<div class="item-description-outer-container">
|
<div class="item-description-outer-container">
|
||||||
<div class="three-columns">
|
{{#if inCompendiumBrowser}}
|
||||||
<div class="item-description-container">
|
<div class="three-columns">
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.Tiers.singular"}}</h4>
|
<div class="item-description-container">
|
||||||
<span>{{tier}}</span>
|
<h4>{{localize "DAGGERHEART.GENERAL.Tiers.singular"}}</h4>
|
||||||
|
<span>{{tier}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-description-container">
|
||||||
|
<h4>{{localize "DAGGERHEART.GENERAL.Trait.single"}}</h4>
|
||||||
|
<span>{{trait}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-description-container">
|
||||||
|
<h4>{{localize "DAGGERHEART.GENERAL.range"}}</h4>
|
||||||
|
<span>{{range}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item-description-container">
|
<div class="three-columns">
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.Trait.single"}}</h4>
|
<div class="item-description-container">
|
||||||
<span>{{trait}}</span>
|
<h4>{{localize "DAGGERHEART.GENERAL.damage"}}</h4>
|
||||||
</div>
|
<span>{{damage}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="item-description-container">
|
<div class="item-description-container">
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.range"}}</h4>
|
<h4>{{localize "DAGGERHEART.GENERAL.burden"}}</h4>
|
||||||
<span>{{range}}</span>
|
<span>{{burden}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{/if}}
|
||||||
|
|
||||||
<div class="three-columns">
|
|
||||||
<div class="item-description-container">
|
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.damage"}}</h4>
|
|
||||||
<span>{{damage}}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="item-description-container">
|
|
||||||
<h4>{{localize "DAGGERHEART.GENERAL.burden"}}</h4>
|
|
||||||
<span>{{burden}}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if features.length}}
|
{{#if features.length}}
|
||||||
<div class="item-description-container">
|
<div class="item-description-container">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue