Compare commits

..

No commits in common. "5551529a58e0fd0655d9d1c882e39c6b37ba490c" and "4a027e85912892dcf74fc57006b35d53ed902a5b" have entirely different histories.

10 changed files with 57 additions and 23 deletions

View file

@ -2055,6 +2055,7 @@
"partyMembers": "Party Members", "partyMembers": "Party Members",
"projects": "Projects", "projects": "Projects",
"types": "Types", "types": "Types",
"itemFeatures": "Item Features",
"questions": "Questions", "questions": "Questions",
"configuration": "Configuration", "configuration": "Configuration",
"base": "Base" "base": "Base"

View file

@ -79,7 +79,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
switch (partId) { switch (partId) {
case 'description': case 'description':
context.enrichedDescription = await this.document.system.getEnrichedDescription(); context.enrichedDescription = await this.document.system.getEnrichedDescription({
headerStyle: 'large'
});
break; break;
case 'effects': case 'effects':
await this._prepareEffectsContext(context, options); await this._prepareEffectsContext(context, options);

View file

@ -55,18 +55,19 @@ export default class DHArmor extends AttachableItem {
} }
/**@inheritdoc */ /**@inheritdoc */
async getDescriptionData() { async getDescriptionData(options = {}) {
const baseDescription = this.description; const baseDescription = await super.getDescriptionData();
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures(); const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
const features = this.armorFeatures.map(x => allFeatures[x.value]); const features = this.armorFeatures.map(x => allFeatures[x.value]);
if (!features.length) return { prefix: null, value: baseDescription, suffix: null }; if (!features.length) return baseDescription;
const prefix = await foundry.applications.handlebars.renderTemplate( const prepend = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/sheets/items/armor/description.hbs', 'systems/daggerheart/templates/sheets/items/armor/description.hbs',
{ features } { features, headerStyle: options.headerStyle }
); );
return { prefix, value: baseDescription, suffix: null }; const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
return `${prepend}${mainDescription}`;
} }
/**@inheritdoc */ /**@inheritdoc */

View file

@ -130,7 +130,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
* @returns {string} * @returns {string}
*/ */
async getDescriptionData(_options) { async getDescriptionData(_options) {
return { prefix: null, value: this.description, suffix: null }; return this.description;
} }
/** /**
@ -138,13 +138,11 @@ 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) {
if (!this.metadata.hasDescription) return ''; if (!this.metadata.hasDescription) return '';
const { prefix, value, suffix } = await this.getDescriptionData(); const description = await this.getDescriptionData(options);
const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n'); return await foundry.applications.ux.TextEditor.implementation.enrichHTML(description, {
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {
relativeTo: this, relativeTo: this,
rollData: this.getRollData(), rollData: this.getRollData(),
secrets: this.isOwner secrets: this.isOwner

View file

@ -111,18 +111,19 @@ export default class DHWeapon extends AttachableItem {
} }
/**@inheritdoc */ /**@inheritdoc */
async getDescriptionData() { async getDescriptionData(options = {}) {
const baseDescription = this.description; const baseDescription = await super.getDescriptionData();
const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures(); const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures();
const features = this.weaponFeatures.map(x => allFeatures[x.value]); const features = this.weaponFeatures.map(x => allFeatures[x.value]);
if (!features.length) return { prefix: null, value: baseDescription, suffix: null }; if (!features.length) return baseDescription;
const prefix = await foundry.applications.handlebars.renderTemplate( const prepend = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/sheets/items/weapon/description.hbs', 'systems/daggerheart/templates/sheets/items/weapon/description.hbs',
{ features } { features, headerStyle: options.headerStyle }
); );
return { prefix, value: baseDescription, suffix: null }; const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
return `${prepend}${mainDescription}`;
} }
prepareDerivedData() { prepareDerivedData() {

View file

@ -221,14 +221,15 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
const itemIsAction = itemValue instanceof game.system.api.models.actions.actionsTypes.base; const itemIsAction = itemValue instanceof game.system.api.models.actions.actionsTypes.base;
const value = itemIsAction || !itemValue?.item ? itemValue : itemValue.item; const value = itemIsAction || !itemValue?.item ? itemValue : itemValue.item;
const enrichedValue = const enrichedValue =
(await value.system?.getEnrichedDescription?.()) ?? (await value.system?.getEnrichedDescription?.({ headerStyle: 'none' })) ??
(await TextEditor.enrichHTML(value.system?.description ?? value.description)); (await TextEditor.enrichHTML(value.system?.description ?? value.description));
if (itemIsAction) value.enrichedDescription = enrichedValue; if (itemIsAction) value.enrichedDescription = enrichedValue;
else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue); else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue);
} }
} else { } else {
const enrichedValue = const enrichedValue =
(await item.system?.getEnrichedDescription?.()) ?? (await TextEditor.enrichHTML(pathValue)); (await item.system?.getEnrichedDescription?.({ headerStyle: 'none' })) ??
(await TextEditor.enrichHTML(pathValue));
foundry.utils.setProperty( foundry.utils.setProperty(
item, item,
`${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`, `${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`,

View file

@ -211,6 +211,18 @@
ul { ul {
list-style: disc; list-style: disc;
} }
.feature-descriptions {
.features-header {
font-size: 14px;
font-weight: bold;
text-decoration: underline;
&.large {
font-size: 18px;
}
}
}
} }
} }
.item-resources { .item-resources {

View file

@ -10,4 +10,16 @@
font-family: @font-body; font-family: @font-body;
color: light-dark(@chat-blue-bg, @beige-50); color: light-dark(@chat-blue-bg, @beige-50);
} }
.feature-descriptions {
.features-header {
font-size: 14px;
font-weight: bold;
text-decoration: underline;
&.large {
font-size: 18px;
}
}
}
} }

View file

@ -1,4 +1,7 @@
<div> <div class="feature-descriptions">
{{#unless (eq headerStyle 'none')}}
<div class="features-header {{#if (eq headerStyle 'large')}}large{{/if}}">{{localize "DAGGERHEART.SETTINGS.Homebrew.itemFeatures"}}</div>
{{/unless}}
{{#each features as | feature |}} {{#each features as | feature |}}
<div><strong>{{localize feature.label}}</strong>: {{{localize feature.description}}}</div> <div><strong>{{localize feature.label}}</strong>: {{{localize feature.description}}}</div>
{{/each}} {{/each}}

View file

@ -1,4 +1,7 @@
<div> <div class="feature-descriptions">
{{#unless (eq headerStyle 'none')}}
<div class="features-header {{#if (eq headerStyle 'large')}}large{{/if}}">{{localize "DAGGERHEART.SETTINGS.Homebrew.itemFeatures"}}</div>
{{/unless}}
{{#each features as | feature |}} {{#each features as | feature |}}
<div><strong>{{localize feature.label}}</strong>: {{{localize feature.description}}}</div> <div><strong>{{localize feature.label}}</strong>: {{{localize feature.description}}}</div>
{{/each}} {{/each}}