From fbca7824b133b370c21636cbcb4a256390618ae5 Mon Sep 17 00:00:00 2001 From: tobifroe Date: Fri, 5 Sep 2025 16:28:41 +0200 Subject: [PATCH 1/4] fix(#255): allow disabling the display of skill tooltips in the agent sheet --- lang/en.json | 2 ++ module/other/register-helpers.js | 4 ++++ module/settings.js | 10 ++++++++++ templates/actor/parts/skills-tab.html | 5 ++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lang/en.json b/lang/en.json index cfe707b..e36837f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -395,6 +395,8 @@ "DG.Settings.charactersheet.program": "The Program", "DG.Settings.sortskills.name": "Sort Skills By Column?", "DG.Settings.sortskills.hint": "Checked sorts by column. Unchecked sorts by row.", + "DG.Settings.hideSkillTooltips.name": "Hide Skill Tooltips", + "DG.Settings.hideSkillTooltips.hint": "Do not display skill tooltips in Agent sheets.", "DG.Settings.keepSanityPrivate.name": "Keep Sanity Private", "DG.Settings.keepSanityPrivate.hint": "Hide sanity from players in both Agent sheets and rolls.", "DG.Settings.skillImprovementFormula.name": "Default Skill Improvement Roll", diff --git a/module/other/register-helpers.js b/module/other/register-helpers.js index 1356dde..58e25f9 100644 --- a/module/other/register-helpers.js +++ b/module/other/register-helpers.js @@ -254,4 +254,8 @@ export default function registerHandlebarsHelpers() { return result; }); + + Handlebars.registerHelper("hideSkillTooltips", () => { + return game.settings.get("deltagreen", "hideSkillTooltips"); + }); } diff --git a/module/settings.js b/module/settings.js index 420460b..20a17bd 100644 --- a/module/settings.js +++ b/module/settings.js @@ -312,6 +312,16 @@ export default function registerSystemSettings() { default: false, }); + game.settings.register("deltagreen", "hideSkillTooltips", { + name: game.i18n.localize("DG.Settings.hideSkillTooltips.name"), + hint: game.i18n.localize("DG.Settings.hideSkillTooltips.hint"), + scope: "client", + config: true, + requiresReload: true, + type: Boolean, + default: false, + }); + // obsolete - will be removed at some point game.settings.register("deltagreen", "characterSheetFont", { name: "World Font Choice", diff --git a/templates/actor/parts/skills-tab.html b/templates/actor/parts/skills-tab.html index 4708941..2bfead3 100644 --- a/templates/actor/parts/skills-tab.html +++ b/templates/actor/parts/skills-tab.html @@ -24,7 +24,10 @@ data-key="{{skill.key}}" data-rolltype="skill" for="system.skills.{{skill.key}}.value" - data-tooltip="{{concat (localize (concat 'DG.Skills.Tooltip.' skill.key)) '

' (localize (ifThen skill.proficiency 'DG.Tooltip.SkillLabel' 'DG.Tooltip.CannotRollSkillLabel')) }}"> + {{#unless (hideSkillTooltips) }} + data-tooltip="{{concat (localize (concat 'DG.Skills.Tooltip.' skill.key)) '

' (localize (ifThen skill.proficiency 'DG.Tooltip.SkillLabel' 'DG.Tooltip.CannotRollSkillLabel')) }}" + {{/unless }} + > {{localizeWithFallback (concat "DG.Skills." skill.key) skill.label }} From d0b92774e2e443f95b20e3d09d42683d2b00ca9c Mon Sep 17 00:00:00 2001 From: tobifroe Date: Fri, 5 Sep 2025 18:38:15 +0200 Subject: [PATCH 2/4] fix(#255, #252): refactor skill tooltip preparation --- module/sheets/base-actor-sheet.js | 24 ++++++++++++++++++++++++ templates/actor/parts/skills-tab.html | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index 0ffcaa3..95fca9d 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -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, + "

", + 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. * diff --git a/templates/actor/parts/skills-tab.html b/templates/actor/parts/skills-tab.html index 2bfead3..456794b 100644 --- a/templates/actor/parts/skills-tab.html +++ b/templates/actor/parts/skills-tab.html @@ -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)) '

' (localize (ifThen skill.proficiency 'DG.Tooltip.SkillLabel' 'DG.Tooltip.CannotRollSkillLabel')) }}" + data-tooltip="{{ skill.tooltip }}" {{/unless }} > {{localizeWithFallback (concat "DG.Skills." skill.key) skill.label }} From 0a34c1159b190fe4ed93da2e63c755cf3272e437 Mon Sep 17 00:00:00 2001 From: tobifroe Date: Sat, 6 Sep 2025 12:44:21 +0200 Subject: [PATCH 3/4] chore: code quality improvements, update CHANGELOG.md --- CHANGELOG.md | 5 +++++ module/settings.js | 9 ++++++++- module/sheets/base-actor-sheet.js | 5 +---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a7825..2dabb94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,16 @@ ## Version 1.6.1 - ????-??-?? +### **Features:** + +- [#255](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/255) - Added option to toggle display of tooltips per client + ### **Bug Fixes:** - [#259](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/259) - Fixed "Keep Sanity Private" setting in agent sheets. - [#263](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/263) - Fixed inability to edit item descriptions. - [#253](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/253) - Close "Automation Menu" & "Handler Settings" when settings are saved. +- [#252](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/252) - Removed redundant lines in tooltip texts ## Version 1.6.0 - 2025-09-04 diff --git a/module/settings.js b/module/settings.js index 20a17bd..e9f7b11 100644 --- a/module/settings.js +++ b/module/settings.js @@ -1,5 +1,6 @@ /* eslint-disable max-classes-per-file */ import DG, { BASE_TEMPLATE_PATH } from "./config.js"; +import DGActorSheet from "./sheets/base-actor-sheet.js"; const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; @@ -317,9 +318,15 @@ export default function registerSystemSettings() { hint: game.i18n.localize("DG.Settings.hideSkillTooltips.hint"), scope: "client", config: true, - requiresReload: true, type: Boolean, default: false, + onChange: () => { + foundry.applications.instances.forEach((app) => { + if (app instanceof DGActorSheet) { + app.render(); + } + }); + }, }); // obsolete - will be removed at some point diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index 95fca9d..657213e 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -399,8 +399,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { * @returns {void} */ _prepareSkillTooltips() { - const skillsWithTooltips = []; - for (const [_, skill] of Object.entries(this.actor.system.sortedSkills)) { + for (const skill of Object.values(this.actor.system.sortedSkills)) { skill.tooltip = game.i18n.localize(`DG.Skills.Tooltip.${skill.key}`); if (!skill.proficiency) { skill.tooltip = skill.tooltip.concat( @@ -409,9 +408,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { game.i18n.localize("DG.Tooltip.CannotRollSkillLabel"), ); } - skillsWithTooltips.push(skill); } - this.actor.system.sortedSkills = skillsWithTooltips; } /** From 2e2d19d4e66d169f5b10cedced948114eb5085f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Fr=C3=B6lich?= Date: Tue, 9 Sep 2025 12:48:45 +0200 Subject: [PATCH 4/4] fix: move tooltip hide/show check to prepareContext --- module/other/register-helpers.js | 4 ---- module/sheets/base-actor-sheet.js | 12 ++++++++++-- templates/actor/parts/skills-tab.html | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/module/other/register-helpers.js b/module/other/register-helpers.js index 58e25f9..1356dde 100644 --- a/module/other/register-helpers.js +++ b/module/other/register-helpers.js @@ -254,8 +254,4 @@ export default function registerHandlebarsHelpers() { return result; }); - - Handlebars.registerHelper("hideSkillTooltips", () => { - return game.settings.get("deltagreen", "hideSkillTooltips"); - }); } diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index 657213e..7b1227c 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -83,8 +83,16 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { this._sortSkills(); this._sortCustomSkills(); - // Setup tooltips - this._prepareSkillTooltips(); + // Wether to hide skill tooltips + context.hideSkillTooltips = game.settings.get( + "deltagreen", + "hideSkillTooltips", + ); + + if (!context.hideSkillTooltips) { + // Setup tooltips + this._prepareSkillTooltips(); + } // Set sanity block per actor type. context.sanityInputs = await foundry.applications.handlebars.renderTemplate( diff --git a/templates/actor/parts/skills-tab.html b/templates/actor/parts/skills-tab.html index 456794b..9b561d6 100644 --- a/templates/actor/parts/skills-tab.html +++ b/templates/actor/parts/skills-tab.html @@ -24,7 +24,7 @@ data-key="{{skill.key}}" data-rolltype="skill" for="system.skills.{{skill.key}}.value" - {{#unless (hideSkillTooltips) }} + {{#unless ../hideSkillTooltips }} data-tooltip="{{ skill.tooltip }}" {{/unless }} >