From ee8a48f73d42b32d61952e7af4058c5b594d6bb8 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Wed, 2 Jul 2025 23:21:02 +0200 Subject: [PATCH] Added DhTooltipManager aswell as placeholder rendering for Armor/Weapon/DomainCard (#245) --- daggerheart.mjs | 1 + module/applications/_module.mjs | 1 + module/applications/tooltipManager.mjs | 16 ++++++++++++++++ .../sheets/global/partials/inventory-item.hbs | 2 +- templates/tooltip/armor.hbs | 5 +++++ templates/tooltip/domainCard.hbs | 5 +++++ templates/tooltip/weapon.hbs | 5 +++++ 7 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 module/applications/tooltipManager.mjs create mode 100644 templates/tooltip/armor.hbs create mode 100644 templates/tooltip/domainCard.hbs create mode 100644 templates/tooltip/weapon.hbs diff --git a/daggerheart.mjs b/daggerheart.mjs index dbe5aa21..2415c857 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -124,6 +124,7 @@ Hooks.once('init', () => { CONFIG.ui.resources = Resources; CONFIG.ux.ContextMenu = applications.DhContextMenu; + CONFIG.ux.TooltipManager = applications.DhTooltipManager; game.socket.on(`system.${SYSTEM.id}`, handleSocketEvent); diff --git a/module/applications/_module.mjs b/module/applications/_module.mjs index a74cb8cf..1a769052 100644 --- a/module/applications/_module.mjs +++ b/module/applications/_module.mjs @@ -15,5 +15,6 @@ export { default as DhpChatMessage } from './chatMessage.mjs'; export { default as DhpEnvironment } from './sheets/actors/environment.mjs'; export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs'; export { default as DhContextMenu } from './contextMenu.mjs'; +export { default as DhTooltipManager } from './tooltipManager.mjs'; export * as api from './sheets/api/_modules.mjs'; diff --git a/module/applications/tooltipManager.mjs b/module/applications/tooltipManager.mjs new file mode 100644 index 00000000..d7d3117c --- /dev/null +++ b/module/applications/tooltipManager.mjs @@ -0,0 +1,16 @@ +export default class DhTooltipManager extends TooltipManager { + 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)); + if (item) { + html = await foundry.applications.handlebars.renderTemplate( + `systems/daggerheart/templates/tooltip/${item.type}.hbs`, + item + ); + } + } + + super.activate(element, { ...options, html: html }); + } +} diff --git a/templates/sheets/global/partials/inventory-item.hbs b/templates/sheets/global/partials/inventory-item.hbs index 491829d1..7c91f032 100644 --- a/templates/sheets/global/partials/inventory-item.hbs +++ b/templates/sheets/global/partials/inventory-item.hbs @@ -1,4 +1,4 @@ -