mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] EffectsDisplay (#1340)
* Merged with main * Added the display * . * Removed unused override function * Fixed layout for generic effects * feat: add basic style to effects tooltip * Corrected distancing * Use CSS based solution for shifting the countdowns * Centered tooltip header --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com> Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
parent
f41f0b20b7
commit
165068a9ee
25 changed files with 399 additions and 41 deletions
|
|
@ -1,8 +1,45 @@
|
|||
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;
|
||||
let effect = {};
|
||||
if (element.dataset.uuid) {
|
||||
const effectData = (await foundry.utils.fromUuid(element.dataset.uuid)).toObject();
|
||||
effect = {
|
||||
...effectData,
|
||||
name: game.i18n.localize(effectData.name),
|
||||
description: game.i18n.localize(effectData.description ?? effectData.parent.system.description)
|
||||
};
|
||||
} else {
|
||||
const conditions = CONFIG.DH.GENERAL.conditions();
|
||||
const condition = conditions[element.dataset.condition];
|
||||
effect = {
|
||||
...condition,
|
||||
name: game.i18n.localize(condition.name),
|
||||
description: game.i18n.localize(condition.description),
|
||||
appliedBy: element.dataset.appliedBy,
|
||||
isLockedCondition: true
|
||||
};
|
||||
}
|
||||
|
||||
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 +149,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