From 79f4590e23113be52dd5f6531fca171425295cd6 Mon Sep 17 00:00:00 2001 From: Themis Date: Mon, 8 Apr 2024 03:18:06 +0100 Subject: [PATCH] Adds a setting to remove the module name from the tooltips. (#81) * Update en.json * Update ac5e-settings.mjs * Update ac5e-helpers.mjs * Update ac5e-helpers.mjs * Update ac5e-settings.mjs * Update Changelog.md * Update module.json --- Changelog.md | 3 +++ lang/en.json | 1 + module.json | 4 +-- scripts/ac5e-helpers.mjs | 54 +++++++++++++++++++++++++++------------ scripts/ac5e-settings.mjs | 18 +++++++++++++ 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/Changelog.md b/Changelog.md index caeb686..c3ab3f0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +## v11.315311.2 +- Added a setting to not show module name in tooltips. Closes [#80](https://github.com/thatlonelybugbear/automated-conditions-5e/issues/80). + ## v11.315311.1 - Initial work for compatibility with all main rollers, like MidiQOL [#49](https://github.com/thatlonelybugbear/automated-conditions-5e/issues/49), Ready Set Roll [#50](https://github.com/thatlonelybugbear/automated-conditions-5e/issues/50) and Group Rolls. - Closing [#72](https://github.com/thatlonelybugbear/automated-conditions-5e/issues/72) bug regarding AC calculations error when not set to equipped armor. diff --git a/lang/en.json b/lang/en.json index 43802e6..c9c64a6 100644 --- a/lang/en.json +++ b/lang/en.json @@ -5,6 +5,7 @@ "AC5E.ShowToolTipsChoicesDialog": "Only on roll dialogs", "AC5E.ShowToolTipsChoicesChat": "Only on chat messages", "AC5E.ShowToolTipsChoicesNone": "Do not show", + "AC5E.ShowModuleNameInTooltipsName": "Show AC5e module name in tooltips", "AC5E.AutoArmorName": "AC5e armor automation.", "AC5E.AutoArmorHint": "When checked, AC5e will automatically process proficiency in the equipped piece of armor for ability, skills and save rolls (STR || DEX) and stealth disadvantage property.", "AC5E.AutoRangedAttacksName": "AC5e ranged attacks automation.", diff --git a/module.json b/module.json index d5426bc..a4c115f 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "automated-conditions-5e", "title": "Automated Conditions 5e", "description": "A small module for Foundry VTT that tries to automate some rolling aspects of the common 5e Conditions.", - "version": "11.315311.1", + "version": "11.315311.2", "authors": [ { "name": "thatlonelybugbear", @@ -52,6 +52,6 @@ "url": "https://github.com/thatlonelybugbear/automated-conditions-5e", "license": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/LICENSE", "manifest": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/latest/download/module.json", - "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315311.1/module.zip", + "download": "https://github.com/thatlonelybugbear/automated-conditions-5e/releases/download/v11.315311.2/module.zip", "changelog": "https://raw.githubusercontent.com/thatlonelybugbear/automated-conditions-5e/main/Changelog.md" } diff --git a/scripts/ac5e-helpers.mjs b/scripts/ac5e-helpers.mjs index e7450d3..edf0a82 100644 --- a/scripts/ac5e-helpers.mjs +++ b/scripts/ac5e-helpers.mjs @@ -220,50 +220,63 @@ export function _systemCheck(testVersion) { } export function _getTooltip(ac5eConfig) { - let tooltip = '
Automated Conditions 5e
'; + let tooltip = settings.showNameTooltips + ? '
Automated Conditions 5e

' + : ''; if (ac5eConfig.critical.length) tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'Critical' )}: ${ac5eConfig.critical.join(', ')}` ); - if (ac5eConfig.advantage?.length) + if (ac5eConfig.advantage?.length) { + if (ac5eConfig.critical.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'Advantage' )}: ${ac5eConfig.advantage.join(', ')}` ); - if (ac5eConfig.disadvantage?.length) + } + if (ac5eConfig.disadvantage?.length) { + if (ac5eConfig.advantage?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'Disadvantage' )}: ${ac5eConfig.disadvantage.join(', ')}` ); - if (ac5eConfig.fail?.length) + } + if (ac5eConfig.fail?.length) { + if (ac5eConfig.disadvantage?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'AC5E.Fail' )}: ${ac5eConfig.fail.join(', ')}` ); - if (ac5eConfig.advantage?.source?.length) + } + if (ac5eConfig.advantage?.source?.length) { + if (ac5eConfig.fail?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
Attacker ${_localize( + `Attacker ${_localize( 'Advantage' ) .substring(0, 3) .toLocaleLowerCase()}: ${ac5eConfig.advantage.source.join(', ')}` ); - if (ac5eConfig.advantage?.target?.length) + } + if (ac5eConfig.advantage?.target?.length) { + if (ac5eConfig.advantage?.source?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'Target' )} grants ${_localize('Advantage') .substring(0, 3) .toLocaleLowerCase()}: ${ac5eConfig.advantage.target.join(', ')}` ); - if (ac5eConfig.disadvantage?.source?.length) + } + if (ac5eConfig.disadvantage?.source?.length) { + if (ac5eConfig.advantage?.target?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
Attacker ${_localize( + `Attacker ${_localize( 'Disadvantage' ) .substring(0, 3) @@ -271,9 +284,11 @@ export function _getTooltip(ac5eConfig) { ', ' )}` ); - if (ac5eConfig.disadvantage?.target?.length) + } + if (ac5eConfig.disadvantage?.target?.length) { + if (ac5eConfig.disadvantage?.source?.length) tooltip = tooltip.concat('
'); tooltip = tooltip.concat( - `
${_localize( + `${_localize( 'Target' )} grants ${_localize('Disadvantage') .substring(0, 3) @@ -281,7 +296,12 @@ export function _getTooltip(ac5eConfig) { ', ' )}` ); - if (tooltip === '
Automated Conditions 5e
') + } + if ( + tooltip === settings.showNameTooltips + ? '
Automated Conditions 5e
' + : '' + ) return null; else return tooltip; } diff --git a/scripts/ac5e-settings.mjs b/scripts/ac5e-settings.mjs index d4ae93a..d374078 100644 --- a/scripts/ac5e-settings.mjs +++ b/scripts/ac5e-settings.mjs @@ -3,6 +3,7 @@ import Constants from './ac5e-constants.mjs'; export default class Settings { // KEYS FOR WORLD CONFIG SETTINGS static SHOW_TOOLTIPS = 'showTooltips'; + static SHOW_MODULE_NAME_IN_TOOLTIPS = 'shownNameTooltip'; static AUTOMATE_ARMOR_PROF_STEALTH = 'autoArmor'; static AUTOMATE_RANGED_ATTACKS = 'autoRangedAttacks'; static AUTOMATE_EXHAUSTION = 'autoExhaustion'; //to-do: add module solution for dndone exhaustion. @@ -37,6 +38,17 @@ export default class Settings { none: 'AC5E.ShowToolTipsChoicesNone', }, }); + game.settings.register( + Constants.MODULE_ID, + Settings.SHOW_MODULE_NAME_IN_TOOLTIPS, + { + name: 'AC5E.ShowModuleNameInTooltipsName', + scope: 'client', + config: true, + default: true, + type: Boolean, + } + ); game.settings.register( Constants.MODULE_ID, Settings.AUTOMATE_ARMOR_PROF_STEALTH, @@ -110,6 +122,12 @@ export default class Settings { get showTooltips() { return game.settings.get(Constants.MODULE_ID, Settings.SHOW_TOOLTIPS); } + get showNameTooltips() { + return game.settings.get( + Constants.MODULE_ID, + Settings.SHOW_MODULE_NAME_IN_TOOLTIPS + ); + } get autoArmor() { return game.settings.get( Constants.MODULE_ID,