199 - Tooltips (#311)

* Set up templates for all 'advanced' tooltips

* Fixed ItemFeature Header label

* Fixed less import
This commit is contained in:
WBHarry 2025-07-11 22:26:56 +02:00 committed by GitHub
parent 72436478c1
commit b6195127fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 505 additions and 54 deletions

View file

@ -2,15 +2,33 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
async activate(element, options = {}) {
let html = options.html;
if (element.dataset.tooltip?.startsWith('#item#')) {
const item = await foundry.utils.fromUuid(element.dataset.tooltip.slice(6));
const splitValues = element.dataset.tooltip.slice(6).split('#action#');
const itemUuid = splitValues[0];
const actionId = splitValues.length > 1 ? splitValues[1] : null;
const baseItem = await foundry.utils.fromUuid(itemUuid);
const item = actionId ? baseItem.system.actions.find(x => x.id === actionId) : baseItem;
if (item) {
const type = actionId ? 'action' : item.type;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${item.type}.hbs`,
item
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{
item: item,
config: CONFIG.DH
}
);
this.tooltip.innerHTML = html;
options.direction = this._determineItemTooltipDirection(element);
}
}
super.activate(element, { ...options, html: html });
}
_determineItemTooltipDirection(element) {
const pos = element.getBoundingClientRect();
const dirs = this.constructor.TOOLTIP_DIRECTIONS;
return dirs[pos.x - this.tooltip.offsetWidth < 0 ? 'DOWN' : 'LEFT'];
}
}