From b7974634b179518e17ab2363f09bc88dcf0cab2e Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 20 Jul 2025 02:51:03 +0200 Subject: [PATCH] Added BeastformTooltip --- module/data/actor/character.mjs | 3 +- module/documents/tooltipManager.mjs | 33 ++++++++++++++++++- module/systemRegistration/handlebars.mjs | 1 + styles/less/ux/tooltip/tooltip.less | 16 +++++++++ .../global/partials/inventory-item-V2.hbs | 9 ++++- templates/ui/tooltip/action.hbs | 2 +- templates/ui/tooltip/adversary.hbs | 2 +- templates/ui/tooltip/armor.hbs | 2 +- templates/ui/tooltip/attack.hbs | 29 ++++++++++++++++ templates/ui/tooltip/beastform.hbs | 8 +++++ templates/ui/tooltip/consumable.hbs | 2 +- templates/ui/tooltip/domainCard.hbs | 2 +- templates/ui/tooltip/feature.hbs | 2 +- templates/ui/tooltip/miscellaneous.hbs | 2 +- templates/ui/tooltip/parts/tooltipChips.hbs | 6 ++++ templates/ui/tooltip/parts/tooltipTags.hbs | 2 +- templates/ui/tooltip/weapon.hbs | 2 +- 17 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 templates/ui/tooltip/attack.hbs create mode 100644 templates/ui/tooltip/beastform.hbs create mode 100644 templates/ui/tooltip/parts/tooltipChips.hbs diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 638465e5..484c821c 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -336,7 +336,8 @@ export default class DhCharacter extends BaseDataActor { ...this.attack, id: this.attack.id, name: this.activeBeastform ? 'DAGGERHEART.ITEMS.Beastform.attackName' : this.attack.name, - img: this.activeBeastform ? 'icons/creatures/claws/claw-straight-brown.webp' : this.attack.img + img: this.activeBeastform ? 'icons/creatures/claws/claw-straight-brown.webp' : this.attack.img, + actor: this.parent } : null; } diff --git a/module/documents/tooltipManager.mjs b/module/documents/tooltipManager.mjs index e622059d..96b13103 100644 --- a/module/documents/tooltipManager.mjs +++ b/module/documents/tooltipManager.mjs @@ -1,5 +1,7 @@ export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager { async activate(element, options = {}) { + const { TextEditor } = foundry.applications.ux; + let html = options.html; if (element.dataset.tooltip?.startsWith('#item#')) { const splitValues = element.dataset.tooltip.slice(6).split('#action#'); @@ -10,10 +12,16 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti const item = actionId ? baseItem.system.actions.find(x => x.id === actionId) : baseItem; if (item) { const type = actionId ? 'action' : item.type; + const description = await TextEditor.enrichHTML(item.system.description); + for (let feature of item.system.features) { + feature.system.enrichedDescription = await TextEditor.enrichHTML(feature.system.description); + } + html = await foundry.applications.handlebars.renderTemplate( `systems/daggerheart/templates/ui/tooltip/${type}.hbs`, { item: item, + description: description, config: CONFIG.DH } ); @@ -22,6 +30,26 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti options.direction = this._determineItemTooltipDirection(element); } } else { + const attack = element.dataset.tooltip?.startsWith('#attack#'); + if (attack) { + const actorUuid = element.dataset.tooltip.slice(8); + const actor = await foundry.utils.fromUuid(actorUuid); + const attack = actor.system.attack; + + const description = await TextEditor.enrichHTML(attack.description); + html = await foundry.applications.handlebars.renderTemplate( + `systems/daggerheart/templates/ui/tooltip/attack.hbs`, + { + attack: attack, + description: description, + parent: actor, + config: CONFIG.DH + } + ); + + this.tooltip.innerHTML = html; + } + const shortRest = element.dataset.tooltip?.startsWith('#shortRest#'); const longRest = element.dataset.tooltip?.startsWith('#longRest#'); if (shortRest || longRest) { @@ -29,11 +57,14 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti const downtimeOptions = shortRest ? CONFIG.DH.GENERAL.defaultRestOptions.shortRest() : CONFIG.DH.GENERAL.defaultRestOptions.longRest(); + const move = downtimeOptions[key]; + const description = await TextEditor.enrichHTML(move.description); html = await foundry.applications.handlebars.renderTemplate( `systems/daggerheart/templates/ui/tooltip/downtime.hbs`, { - move: move + move: move, + description: description } ); diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index f732fbd9..b15bf820 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -28,6 +28,7 @@ export const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/settings/components/settings-item-line.hbs', 'systems/daggerheart/templates/ui/chat/parts/damage-chat.hbs', 'systems/daggerheart/templates/ui/chat/parts/target-chat.hbs', + 'systems/daggerheart/templates/ui/tooltip/parts/tooltipChips.hbs', 'systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs', 'systems/daggerheart/templates/dialogs/downtime/activities.hbs' ]); diff --git a/styles/less/ux/tooltip/tooltip.less b/styles/less/ux/tooltip/tooltip.less index 0060f74b..e6b660a5 100644 --- a/styles/less/ux/tooltip/tooltip.less +++ b/styles/less/ux/tooltip/tooltip.less @@ -74,6 +74,22 @@ } } + .tooltip-chips { + display: flex; + justify-content: space-around; + flex-wrap: wrap; + gap: 8px; + + .tooltip-chip { + font-size: 18px; + padding: 2px 4px; + border: 1px solid light-dark(@dark-blue, @golden); + border-radius: 6px; + color: light-dark(@dark, @beige); + background-image: url(../assets/parchments/dh-parchment-dark.png); + } + } + .tooltip-tags { width: 100%; display: flex; diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index e3ffa64a..b58f6f44 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -21,7 +21,14 @@ Parameters: {{!-- Image --}}
+ {{#unless hideTooltip}} + {{#if (eq type 'attack')}} + data-tooltip="#attack#{{item.actor.uuid}}" + {{else}} + data-tooltip="#item#{{item.uuid}}" + {{/if}} + {{/unless}} + > d20
diff --git a/templates/ui/tooltip/action.hbs b/templates/ui/tooltip/action.hbs index c101ee68..1683f7fd 100644 --- a/templates/ui/tooltip/action.hbs +++ b/templates/ui/tooltip/action.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.description}}}
+
{{{description}}}
{{#if item.uses.max}}

{{localize "DAGGERHEART.GENERAL.uses"}}

diff --git a/templates/ui/tooltip/adversary.hbs b/templates/ui/tooltip/adversary.hbs index fa555611..cb8a9bc0 100644 --- a/templates/ui/tooltip/adversary.hbs +++ b/templates/ui/tooltip/adversary.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
diff --git a/templates/ui/tooltip/armor.hbs b/templates/ui/tooltip/armor.hbs index 456fb226..6bdf9ce3 100644 --- a/templates/ui/tooltip/armor.hbs +++ b/templates/ui/tooltip/armor.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
diff --git a/templates/ui/tooltip/attack.hbs b/templates/ui/tooltip/attack.hbs new file mode 100644 index 00000000..e07e1d55 --- /dev/null +++ b/templates/ui/tooltip/attack.hbs @@ -0,0 +1,29 @@ +
+

{{attack.name}}

+ +
{{{description}}}
+ +
+
+ + {{#with (lookup config.ACTOR.abilities attack.roll.trait) as | trait |}} +
{{localize trait.label}}
+ {{/with}} +
+
+ + {{#with (lookup config.GENERAL.range attack.range) as | range |}} +
{{localize range.label}}
+ {{/with}} +
+ +
+ +
{{{damageFormula attack parent}}}
+
+
+ +
{{{damageSymbols attack.damage.parts}}}
+
+
+
\ No newline at end of file diff --git a/templates/ui/tooltip/beastform.hbs b/templates/ui/tooltip/beastform.hbs new file mode 100644 index 00000000..3afc0c84 --- /dev/null +++ b/templates/ui/tooltip/beastform.hbs @@ -0,0 +1,8 @@ +
+

{{item.name}}

+ +
{{{description}}}
+ + {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipChips.hbs" chips=item.system.advantageOn label=(localize "DAGGERHEART.ITEMS.Beastform.FIELDS.advantageOn.label")}} + {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.features label=(localize "DAGGERHEART.GENERAL.features")}} +
\ No newline at end of file diff --git a/templates/ui/tooltip/consumable.hbs b/templates/ui/tooltip/consumable.hbs index 2c998b1d..f4c4c700 100644 --- a/templates/ui/tooltip/consumable.hbs +++ b/templates/ui/tooltip/consumable.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
diff --git a/templates/ui/tooltip/domainCard.hbs b/templates/ui/tooltip/domainCard.hbs index dad00b1b..ae2fe349 100644 --- a/templates/ui/tooltip/domainCard.hbs +++ b/templates/ui/tooltip/domainCard.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
diff --git a/templates/ui/tooltip/feature.hbs b/templates/ui/tooltip/feature.hbs index 17ff2db6..ce475664 100644 --- a/templates/ui/tooltip/feature.hbs +++ b/templates/ui/tooltip/feature.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
{{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.actions label=(localize "DAGGERHEART.GENERAL.Action.plural") }} {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.effects label=(localize "DAGGERHEART.GENERAL.Effect.plural") }} diff --git a/templates/ui/tooltip/miscellaneous.hbs b/templates/ui/tooltip/miscellaneous.hbs index 83014a88..b4912b4d 100644 --- a/templates/ui/tooltip/miscellaneous.hbs +++ b/templates/ui/tooltip/miscellaneous.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}
{{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.system.actions label=(localize "DAGGERHEART.GENERAL.Action.plural") }}
\ No newline at end of file diff --git a/templates/ui/tooltip/parts/tooltipChips.hbs b/templates/ui/tooltip/parts/tooltipChips.hbs new file mode 100644 index 00000000..a8d9ec44 --- /dev/null +++ b/templates/ui/tooltip/parts/tooltipChips.hbs @@ -0,0 +1,6 @@ +

{{localize label}}

+
+ {{#each chips as | chip |}} +
{{ifThen chip.value chip.value chip}}
+ {{/each}} +
\ No newline at end of file diff --git a/templates/ui/tooltip/parts/tooltipTags.hbs b/templates/ui/tooltip/parts/tooltipTags.hbs index ba4e875f..711945a0 100644 --- a/templates/ui/tooltip/parts/tooltipTags.hbs +++ b/templates/ui/tooltip/parts/tooltipTags.hbs @@ -6,7 +6,7 @@
{{localize feature.name}}
{{#if feature.img}}{{/if}}
-
{{{localize (ifThen feature.description feature.description feature.system.description)}}}
+
{{{localize (ifThen feature.description feature.description (ifThen feature.system.enrichedDescription feature.system.enrichedDescription feature.system.description))}}}
{{/each}}
\ No newline at end of file diff --git a/templates/ui/tooltip/weapon.hbs b/templates/ui/tooltip/weapon.hbs index 963b0714..8b152f22 100644 --- a/templates/ui/tooltip/weapon.hbs +++ b/templates/ui/tooltip/weapon.hbs @@ -1,7 +1,7 @@

{{item.name}}

-
{{{item.system.description}}}
+
{{{description}}}