Skip to content

Commit

Permalink
Adds a setting to remove the module name from the tooltips. (#81)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thatlonelybugbear authored Apr 8, 2024
1 parent 5bb5d4c commit 79f4590
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
54 changes: 37 additions & 17 deletions scripts/ac5e-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -220,68 +220,88 @@ export function _systemCheck(testVersion) {
}

export function _getTooltip(ac5eConfig) {
let tooltip = '<center><strong>Automated Conditions 5e</strong></center>';
let tooltip = settings.showNameTooltips
? '<center><strong>Automated Conditions 5e</strong></center><hr>'
: '';
if (ac5eConfig.critical.length)
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'Critical'
)}: ${ac5eConfig.critical.join(', ')}</span>`
);
if (ac5eConfig.advantage?.length)
if (ac5eConfig.advantage?.length) {
if (ac5eConfig.critical.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'Advantage'
)}: ${ac5eConfig.advantage.join(', ')}</span>`
);
if (ac5eConfig.disadvantage?.length)
}
if (ac5eConfig.disadvantage?.length) {
if (ac5eConfig.advantage?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'Disadvantage'
)}: ${ac5eConfig.disadvantage.join(', ')}</span>`
);
if (ac5eConfig.fail?.length)
}
if (ac5eConfig.fail?.length) {
if (ac5eConfig.disadvantage?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'AC5E.Fail'
)}: ${ac5eConfig.fail.join(', ')}</span>`
);
if (ac5eConfig.advantage?.source?.length)
}
if (ac5eConfig.advantage?.source?.length) {
if (ac5eConfig.fail?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">Attacker ${_localize(
`<span style="display: block; text-align: left;">Attacker ${_localize(
'Advantage'
)
.substring(0, 3)
.toLocaleLowerCase()}: ${ac5eConfig.advantage.source.join(', ')}</span>`
);
if (ac5eConfig.advantage?.target?.length)
}
if (ac5eConfig.advantage?.target?.length) {
if (ac5eConfig.advantage?.source?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'Target'
)} grants ${_localize('Advantage')
.substring(0, 3)
.toLocaleLowerCase()}: ${ac5eConfig.advantage.target.join(', ')}</span>`
);
if (ac5eConfig.disadvantage?.source?.length)
}
if (ac5eConfig.disadvantage?.source?.length) {
if (ac5eConfig.advantage?.target?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">Attacker ${_localize(
`<span style="display: block; text-align: left;">Attacker ${_localize(
'Disadvantage'
)
.substring(0, 3)
.toLocaleLowerCase()}: ${ac5eConfig.disadvantage.source.join(
', '
)}</span>`
);
if (ac5eConfig.disadvantage?.target?.length)
}
if (ac5eConfig.disadvantage?.target?.length) {
if (ac5eConfig.disadvantage?.source?.length) tooltip = tooltip.concat('<br>');
tooltip = tooltip.concat(
`<br><span style="display: block; text-align: left;">${_localize(
`<span style="display: block; text-align: left;">${_localize(
'Target'
)} grants ${_localize('Disadvantage')
.substring(0, 3)
.toLocaleLowerCase()}: ${ac5eConfig.disadvantage.target.join(
', '
)}</span>`
);
if (tooltip === '<center><strong>Automated Conditions 5e</strong></center>')
}
if (
tooltip === settings.showNameTooltips
? '<center><strong>Automated Conditions 5e</strong></center>'
: ''
)
return null;
else return tooltip;
}
Expand Down
18 changes: 18 additions & 0 deletions scripts/ac5e-settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 79f4590

Please sign in to comment.