mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Added the display
This commit is contained in:
parent
01dd5ced94
commit
4954e41b02
13 changed files with 125 additions and 43 deletions
|
|
@ -1,8 +1,26 @@
|
|||
export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager {
|
||||
#bordered = false;
|
||||
|
||||
async activate(element, options = {}) {
|
||||
const { TextEditor } = foundry.applications.ux;
|
||||
|
||||
let html = options.html;
|
||||
if (element.dataset.tooltip === '#effect-display#') {
|
||||
this.#bordered = true;
|
||||
const effect = await foundry.utils.fromUuid(element.dataset.uuid);
|
||||
html = await foundry.applications.handlebars.renderTemplate(
|
||||
`systems/daggerheart/templates/ui/tooltip/effect-display.hbs`,
|
||||
{
|
||||
effect
|
||||
}
|
||||
);
|
||||
|
||||
this.tooltip.innerHTML = html;
|
||||
options.direction = this._determineItemTooltipDirection(element);
|
||||
} else {
|
||||
this.#bordered = false;
|
||||
}
|
||||
|
||||
if (element.dataset.tooltip?.startsWith('#item#')) {
|
||||
const itemUuid = element.dataset.tooltip.slice(6);
|
||||
const item = await foundry.utils.fromUuid(itemUuid);
|
||||
|
|
@ -112,6 +130,14 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
|||
super.activate(element, { ...options, html: html });
|
||||
}
|
||||
|
||||
_setStyle(position = {}) {
|
||||
super._setStyle(position);
|
||||
|
||||
if (this.#bordered) {
|
||||
this.tooltip.classList.add('bordered-tooltip');
|
||||
}
|
||||
}
|
||||
|
||||
_determineItemTooltipDirection(element, prefered = this.constructor.TOOLTIP_DIRECTIONS.LEFT) {
|
||||
const pos = element.getBoundingClientRect();
|
||||
const dirs = this.constructor.TOOLTIP_DIRECTIONS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue