Skip to content

Commit 38ae805

Browse files
committed
settings fixed 2
1 parent f68d1dd commit 38ae805

File tree

2 files changed

+47
-50
lines changed

2 files changed

+47
-50
lines changed

css/custom-hotbar.css

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,20 @@ div#client-settings div#coreSetDiv {
230230
border-top: none;
231231
}
232232

233-
#client-settings div#chbDisableDiv > label
234-
,#client-settings div#coreDisableDiv > label {
233+
#client-settings div#chbDisableDiv > span
234+
,#client-settings div#coreDisableDiv > span {
235235
margin-left: 0;
236236
flex: none;
237237
}
238238

239-
/* with apologies to sdenec, lifted from Tidy UI Settings module, which you should install... */
240-
#client-settings .chb-setting label,
241-
#client-settings .chb-setting > label {
242-
flex-grow: unset;
243-
flex-basis: unset;
244-
flex: 1 1 100%;
245-
line-height: 1.2;
246-
margin: 0 0 .25rem calc(13px + 1rem);
247-
order: -1;
239+
div.chb-setting > button {
240+
flex: 1 1 100%;
248241
}
249242

250-
#disableDiv
243+
244+
div.chbDisable {
245+
padding-left: 45px;
246+
}
251247

252248
.macro .tooltip span {
253249
z-index: 4;

index.js

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -556,62 +556,63 @@ Hooks.once('ready', () => {
556556

557557

558558
Hooks.on("renderSettingsConfig", async () => {
559-
//add CSS ids and classes to CustomHotbar settings section for styling
560-
let settingsDiv = document.getElementById("client-settings");
561-
562-
let chbSetDiv = $( `#${settingsDiv.id} div h2.module-header:contains("Custom Hotbar")` ).next();
559+
//customize styling for CHB settings
560+
//add CSS ids and classes to CustomHotbar settings section for styling
561+
let settingsDiv = document.getElementById("client-settings");
562+
563+
let chbSetDiv = $( `#${settingsDiv.id} div h2.module-header:contains("Custom Hotbar")` ).next();
564+
let usrFirstDiv = $(chbSetDiv);
563565

564-
$(chbSetDiv).addClass('chb-setting');
565-
$(chbSetDiv).addClass('chb-global');
566-
$(chbSetDiv).attr('id', 'chbSetDiv');
567-
568-
let coreSetDiv = $(chbSetDiv).next();
569-
$(coreSetDiv).addClass('chb-setting');
570-
$(coreSetDiv).addClass('chb-global');
571-
$(coreSetDiv).attr('id', 'coreSetDiv');
566+
//Add ids and classes for "GM only" button divs if user is GM.
567+
if (game.users.current.isGM ===true ) {
568+
569+
$(chbSetDiv).addClass('chb-setting');
570+
$(chbSetDiv).addClass('chb-global');
571+
$(chbSetDiv).attr('id', 'chbSetDiv');
572+
573+
let coreSetDiv = $(chbSetDiv).next();
574+
$(coreSetDiv).addClass('chb-setting');
575+
$(coreSetDiv).addClass('chb-global');
576+
$(coreSetDiv).attr('id', 'coreSetDiv');
577+
578+
usrFirstDiv = $(coreSetDiv).next();
579+
}
572580

573-
//only apply these classes and id if the custom hotbar is enabled for the user
581+
//Add ids and classes for the custom hotbar menu button divs, if it's enabled for the user
574582
if (game.settings.get("custom-hotbar","chbDisabled") === false) {
575-
let chbFlagDiv = $(coreSetDiv).next();
583+
let chbFlagDiv = $(usrFirstDiv);
576584
$(chbFlagDiv).addClass('chb-setting');
577585
$(chbFlagDiv).addClass('chb-user');
578586
$(chbFlagDiv).attr('id', 'chbFlagDiv');
579587
}
580588

581-
//only apply these classes and id if the core Foundry hotbar is enabled for the user
589+
//Add ids and classes for the core hotbar menu button divs, if it's enabled for the user
582590
if (game.settings.get("custom-hotbar","coreDisabled") === false) {
583-
let coreFlagDiv = $(coreSetDiv).next();
591+
let coreFlagDiv = $(usrFirstDiv).next();
584592
//check to make sure that the custom hotbar is enabled and ajdust if it isn't
585593
if (game.settings.get("custom-hotbar","chbDisabled") === true) {
586-
coreFlagDiv = $(coreSetDiv).next();
587-
} else {
588-
coreFlagDiv = $(chbFlagDiv).next();
594+
coreFlagDiv = $(usrFirstDiv);
589595
}
590596
$(coreFlagDiv).addClass('chb-setting');
591597
$(coreFlagDiv).addClass('chb-user');
592598
$(coreFlagDiv).attr('id', 'coreFlagDiv');
593599
}
594600

595-
//find which is the previous displayed div based on disable settings
596-
let chbDisableDiv = {};
597-
//check to see if the first possible flag div, the custom hotbar, is disabled
598-
if (game.settings.get("custom-hotbar","chbDisabled") === true) {
599-
//check to see if Core hotbar is also disabled
600-
if (game.settings.get("custom-hotbar","coreDisabled") === true) {
601-
//skip both flag divs
602-
chbDisableDiv = $(coreSetDiv).next();
603-
} else {
604-
//skip just the first div
605-
chbDisableDiv = $(coreFlagDiv).next();
606-
}
607-
} else {
608-
if (game.settings.get("custom-hotbar","coreDisabled") === true) {
609-
chbDisableDiv = $(chbFlagDiv).next();
610-
} else {
611-
chbDisableDiv = $(coreFlagDiv).next();
612-
}
613-
}
614601

602+
//Assess disable settings to help determine which div precedes Disable
603+
let chbDisabled = game.settings.get("custom-hotbar","chbDisabled");
604+
let coreDisabled = game.settings.get("custom-hotbar","coreDisabled");
605+
606+
//Default case for convenience: Both are disabled
607+
let chbDisableDiv = usrFirstDiv;
608+
609+
//Case: Core Hotbar is enabled (so state of Custom Hotbar doesn't matter)
610+
if ( coreDisabled === false ) chbDisableDiv = $(coreFlagDiv).next();
611+
612+
//Case: Core hotbar is disabled but Custom hotbar is not
613+
if (chbDisabled === false && coreDisabled === true ) chbDisableDiv = $(chbFlagDiv).next();
614+
615+
//Add ids and classes for the disable checkbox divs
615616
$(chbDisableDiv).addClass('chb-setting');
616617
$(chbDisableDiv).addClass('chb-disable');
617618
$(chbDisableDiv).attr('id', 'chbDisableDiv');

0 commit comments

Comments
 (0)