diff --git a/changelog.md b/changelog.md index a4044cd3..d11df50d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +## [0.9.17] 2020-11-23 +### Changed/added +- Added option to keep categories open (if click-to-open is enabled) when an action is pressed, so categories don't have to be constantly reopened + ## [0.9.16] 2020-11-21 ### Bugfix - DND Check for null combat diff --git a/lang/en.json b/lang/en.json index 2c54d554..fbe7c3a6 100644 --- a/lang/en.json +++ b/lang/en.json @@ -156,6 +156,8 @@ "tokenactionhud.settings.showIcons.hint": "If enabled, the action image will be displayed on the HUD button where available.", "tokenactionhud.settings.clickOpenCategory.name": "Click-to-open categories", "tokenactionhud.settings.clickOpenCategory.hint": "If enabled, categories will open on click instead of hover.", + "tokenactionhud.settings.clickCloseCategory.name": "Close categories on action", + "tokenactionhud.settings.clickCloseCategory.hint": "If enabled, categories will close when an action is chosen. Has no effect is click-to-open (above) is disabled.", "tokenactionhud.settings.dnd5e.ignorePassiveFeats.name": "Ignore passive feats", "tokenactionhud.settings.dnd5e.ignorePassiveFeats.hint": "If enabled, passive feats are not shown.", diff --git a/scripts/settings.js b/scripts/settings.js index 5ba12f60..96d1749a 100644 --- a/scripts/settings.js +++ b/scripts/settings.js @@ -87,6 +87,16 @@ export const registerSettings = function(app, systemManager, rollHandlers) { default : false, onChange: value => { updateFunc(value); } }); + + game.settings.register(appName,'clickCloseCategory', { + name : game.i18n.localize('tokenactionhud.settings.clickCloseCategory.name'), + hint : game.i18n.localize('tokenactionhud.settings.clickCloseCategory.hint'), + scope : 'client', + config : true, + type : Boolean, + default : false, + onChange: value => { updateFunc(value); } + }); systemManager.doRegisterSettings(appName, updateFunc); diff --git a/scripts/tokenactionhud.js b/scripts/tokenactionhud.js index ac36230a..15c1de0c 100644 --- a/scripts/tokenactionhud.js +++ b/scripts/tokenactionhud.js @@ -76,6 +76,9 @@ export class TokenActionHUD extends Application { const action = '.tah-action'; const handleClick = e => { + if (settings.get('clickOpenCategory') && !settings.get('clickCloseCategory')) + e.stopPropagation(); + let target = e.target; if (target.tagName !== 'BUTTON') @@ -149,13 +152,13 @@ export class TokenActionHUD extends Application { let category = $(this)[0]; let boundClick; - if (!$(category).hasClass('hover')) { - boundClick = openCategory.bind(this); - boundClick = boundClick(event); - } - else { + if ($(category).hasClass('hover')) { boundClick = closeCategory.bind(this); boundClick(event); + } + else { + boundClick = openCategory.bind(this); + boundClick(event); } }