[Fix] Itemlink Redux Revengeance (#399)

* Small random fixes

* Added use of ItemLinkFields

* Multiclass levelup fixes

* Fixed our onCreate methods unintentionally being run on all clients

* Remade apps handling

* Added for all class items and subclass

* Restored foreignDocumentUuidField

* Improved

* PR fxies

* Fixed tooltip enrichment

* .

* Reverted silly change
This commit is contained in:
WBHarry 2025-07-26 00:37:30 +02:00 committed by GitHub
parent fcba5041e9
commit 2a4777f1a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 648 additions and 489 deletions

View file

@ -8,19 +8,15 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
const item = await foundry.utils.fromUuid(itemUuid);
if (item) {
const isAction = item instanceof game.system.api.models.actions.actionsTypes.base;
const description = await TextEditor.enrichHTML(isAction ? item.description : item.system.description);
if (item.system?.features) {
for (let feature of item.system.features) {
feature.system.enrichedDescription = await TextEditor.enrichHTML(feature.system.description);
}
}
const isEffect = item instanceof ActiveEffect;
await this.enrichText(item, isAction || isEffect);
const type = isAction ? 'action' : item.type;
const type = isAction ? 'action' : isEffect ? 'effect' : item.type;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{
item: item,
description: description,
description: item.system?.enrichedDescription ?? item.enrichedDescription,
config: CONFIG.DH
}
);
@ -126,4 +122,37 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
];
}
}
async enrichText(item, flatStructure) {
const { TextEditor } = foundry.applications.ux;
const enrichPaths = [
{ path: flatStructure ? '' : 'system', name: 'description' },
{ path: 'system', name: 'features' },
{ path: 'system', name: 'actions' },
{ path: 'system', name: 'customActions' }
];
for (let data of enrichPaths) {
const basePath = `${data.path ? `${data.path}.` : ''}${data.name}`;
const pathValue = foundry.utils.getProperty(item, basePath);
if (!pathValue) continue;
if (Array.isArray(pathValue) || pathValue.size) {
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.description);
if (itemIsAction) value.enrichedDescription = enrichedValue;
else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue);
}
} else {
const enrichedValue = await TextEditor.enrichHTML(pathValue);
foundry.utils.setProperty(
item,
`${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`,
enrichedValue
);
}
}
}
}