Added BeastformTooltip

This commit is contained in:
WBHarry 2025-07-20 02:51:03 +02:00
parent 82be5ecd0d
commit b7974634b1
17 changed files with 111 additions and 12 deletions

View file

@ -336,7 +336,8 @@ export default class DhCharacter extends BaseDataActor {
...this.attack, ...this.attack,
id: this.attack.id, id: this.attack.id,
name: this.activeBeastform ? 'DAGGERHEART.ITEMS.Beastform.attackName' : this.attack.name, 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; : null;
} }

View file

@ -1,5 +1,7 @@
export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager { export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager {
async activate(element, options = {}) { async activate(element, options = {}) {
const { TextEditor } = foundry.applications.ux;
let html = options.html; let html = options.html;
if (element.dataset.tooltip?.startsWith('#item#')) { if (element.dataset.tooltip?.startsWith('#item#')) {
const splitValues = element.dataset.tooltip.slice(6).split('#action#'); 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; const item = actionId ? baseItem.system.actions.find(x => x.id === actionId) : baseItem;
if (item) { if (item) {
const type = actionId ? 'action' : item.type; 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( html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`, `systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{ {
item: item, item: item,
description: description,
config: CONFIG.DH config: CONFIG.DH
} }
); );
@ -22,6 +30,26 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
options.direction = this._determineItemTooltipDirection(element); options.direction = this._determineItemTooltipDirection(element);
} }
} else { } 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 shortRest = element.dataset.tooltip?.startsWith('#shortRest#');
const longRest = element.dataset.tooltip?.startsWith('#longRest#'); const longRest = element.dataset.tooltip?.startsWith('#longRest#');
if (shortRest || longRest) { if (shortRest || longRest) {
@ -29,11 +57,14 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
const downtimeOptions = shortRest const downtimeOptions = shortRest
? CONFIG.DH.GENERAL.defaultRestOptions.shortRest() ? CONFIG.DH.GENERAL.defaultRestOptions.shortRest()
: CONFIG.DH.GENERAL.defaultRestOptions.longRest(); : CONFIG.DH.GENERAL.defaultRestOptions.longRest();
const move = downtimeOptions[key]; const move = downtimeOptions[key];
const description = await TextEditor.enrichHTML(move.description);
html = await foundry.applications.handlebars.renderTemplate( html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/downtime.hbs`, `systems/daggerheart/templates/ui/tooltip/downtime.hbs`,
{ {
move: move move: move,
description: description
} }
); );

View file

@ -28,6 +28,7 @@ export const preloadHandlebarsTemplates = async function () {
'systems/daggerheart/templates/settings/components/settings-item-line.hbs', 'systems/daggerheart/templates/settings/components/settings-item-line.hbs',
'systems/daggerheart/templates/ui/chat/parts/damage-chat.hbs', 'systems/daggerheart/templates/ui/chat/parts/damage-chat.hbs',
'systems/daggerheart/templates/ui/chat/parts/target-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/ui/tooltip/parts/tooltipTags.hbs',
'systems/daggerheart/templates/dialogs/downtime/activities.hbs' 'systems/daggerheart/templates/dialogs/downtime/activities.hbs'
]); ]);

View file

@ -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 { .tooltip-tags {
width: 100%; width: 100%;
display: flex; display: flex;

View file

@ -21,7 +21,14 @@ Parameters:
{{!-- Image --}} {{!-- Image --}}
<div class="img-portait" <div class="img-portait"
data-action='{{ifThen (or (hasProperty item "use") (eq type 'attack')) "useItem" (ifThen (hasProperty item "toChat") "toChat" "editDoc") }}' data-action='{{ifThen (or (hasProperty item "use") (eq type 'attack')) "useItem" (ifThen (hasProperty item "toChat") "toChat" "editDoc") }}'
{{#unless hideTooltip}}data-tooltip="#item#{{item.uuid}}" {{/unless}}> {{#unless hideTooltip}}
{{#if (eq type 'attack')}}
data-tooltip="#attack#{{item.actor.uuid}}"
{{else}}
data-tooltip="#item#{{item.uuid}}"
{{/if}}
{{/unless}}
>
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" /> <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" />
<img class="roll-img" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20"> <img class="roll-img" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20">
</div> </div>

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
{{#if item.uses.max}} {{#if item.uses.max}}
<h4 class="tooltip-sub-title">{{localize "DAGGERHEART.GENERAL.uses"}}</h4> <h4 class="tooltip-sub-title">{{localize "DAGGERHEART.GENERAL.uses"}}</h4>

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section triple spaced"> <div class="tooltip-information-section triple spaced">
<div class="tooltip-information"> <div class="tooltip-information">

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section"> <div class="tooltip-information-section">
<div class="tooltip-information full-width"> <div class="tooltip-information full-width">

View file

@ -0,0 +1,29 @@
<div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{attack.name}}</h2>
<img class="tooltip-image" src="{{attack.img}}" />
<div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section spaced">
<div class="tooltip-information">
<label>{{localize "DAGGERHEART.GENERAL.Trait.single"}}</label>
{{#with (lookup config.ACTOR.abilities attack.roll.trait) as | trait |}}
<div>{{localize trait.label}}</div>
{{/with}}
</div>
<div class="tooltip-information">
<label>{{localize "DAGGERHEART.GENERAL.range"}}</label>
{{#with (lookup config.GENERAL.range attack.range) as | range |}}
<div>{{localize range.label}}</div>
{{/with}}
</div>
<div class="tooltip-information">
<label>{{localize "DAGGERHEART.GENERAL.damage"}}</label>
<div>{{{damageFormula attack parent}}}</div>
</div>
<div class="tooltip-information">
<label>{{localize "DAGGERHEART.GENERAL.damageType"}}</label>
<div>{{{damageSymbols attack.damage.parts}}}</div>
</div>
</div>
</div>

View file

@ -0,0 +1,8 @@
<div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{description}}}</div>
{{> "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")}}
</div>

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section"> <div class="tooltip-information-section">
<div class="tooltip-information full-width"> <div class="tooltip-information full-width">

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section"> <div class="tooltip-information-section">
<div class="tooltip-information"> <div class="tooltip-information">

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
{{> "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.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") }} {{> "systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs" features=item.effects label=(localize "DAGGERHEART.GENERAL.Effect.plural") }}

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
{{> "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.system.actions label=(localize "DAGGERHEART.GENERAL.Action.plural") }}
</div> </div>

View file

@ -0,0 +1,6 @@
<h4 class="tooltip-sub-title">{{localize label}}</h4>
<div class="tooltip-chips">
{{#each chips as | chip |}}
<div class="tooltip-chip">{{ifThen chip.value chip.value chip}}</div>
{{/each}}
</div>

View file

@ -6,7 +6,7 @@
<div class="tooltip-tag-label">{{localize feature.name}}</div> <div class="tooltip-tag-label">{{localize feature.name}}</div>
{{#if feature.img}}<img class="tooltip-tag-image" src="{{feature.img}}" />{{/if}} {{#if feature.img}}<img class="tooltip-tag-image" src="{{feature.img}}" />{{/if}}
</div> </div>
<div class="tooltip-tag-description">{{{localize (ifThen feature.description feature.description feature.system.description)}}}</div> <div class="tooltip-tag-description">{{{localize (ifThen feature.description feature.description (ifThen feature.system.enrichedDescription feature.system.enrichedDescription feature.system.description))}}}</div>
</div> </div>
{{/each}} {{/each}}
</div> </div>

View file

@ -1,7 +1,7 @@
<div class="daggerheart dh-style tooltip"> <div class="daggerheart dh-style tooltip">
<h2 class="tooltip-title">{{item.name}}</h2> <h2 class="tooltip-title">{{item.name}}</h2>
<img class="tooltip-image" src="{{item.img}}" /> <img class="tooltip-image" src="{{item.img}}" />
<div class="tooltip-description">{{{item.system.description}}}</div> <div class="tooltip-description">{{{description}}}</div>
<div class="tooltip-information-section"> <div class="tooltip-information-section">
<div class="tooltip-information"> <div class="tooltip-information">