Skip to content

Commit

Permalink
Drental#113 Add option to prevent closing categories on action press
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamish committed Nov 23, 2020
1 parent c7885e5 commit 55b69ee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
10 changes: 10 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 8 additions & 5 deletions scripts/tokenactionhud.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 55b69ee

Please sign in to comment.