fix(#255, #252): refactor skill tooltip preparation

This commit is contained in:
tobifroe
2025-09-09 12:49:37 +02:00
committed by Tobias Frölich
parent fbca7824b1
commit d0b92774e2
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -83,6 +83,9 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
this._sortSkills();
this._sortCustomSkills();
// Setup tooltips
this._prepareSkillTooltips();
// Set sanity block per actor type.
context.sanityInputs = await foundry.applications.handlebars.renderTemplate(
`${DGActorSheet.TEMPLATE_PATH}/partials/sanity-${this.actor.type}.html`,
@@ -390,6 +393,27 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
}
}
/**
* Sets up the list of sorted skills with their respective tooltips.
*
* @returns {void}
*/
_prepareSkillTooltips() {
const skillsWithTooltips = [];
for (const [_, skill] of Object.entries(this.actor.system.sortedSkills)) {
skill.tooltip = game.i18n.localize(`DG.Skills.Tooltip.${skill.key}`);
if (!skill.proficiency) {
skill.tooltip = skill.tooltip.concat(
skill.tooltip,
"<br><br>",
game.i18n.localize("DG.Tooltip.CannotRollSkillLabel"),
);
}
skillsWithTooltips.push(skill);
}
this.actor.system.sortedSkills = skillsWithTooltips;
}
/**
* Prepares a simplified version of the special training for display on sheet.
*
+1 -1
View File
@@ -25,7 +25,7 @@
data-rolltype="skill"
for="system.skills.{{skill.key}}.value"
{{#unless (hideSkillTooltips) }}
data-tooltip="{{concat (localize (concat 'DG.Skills.Tooltip.' skill.key)) '<br><br>' (localize (ifThen skill.proficiency 'DG.Tooltip.SkillLabel' 'DG.Tooltip.CannotRollSkillLabel')) }}"
data-tooltip="{{ skill.tooltip }}"
{{/unless }}
>
{{localizeWithFallback (concat "DG.Skills." skill.key) skill.label }}