@@ -556,62 +556,63 @@ Hooks.once('ready', () => {
556
556
557
557
558
558
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 ) ;
563
565
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
+ }
572
580
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
574
582
if ( game . settings . get ( "custom-hotbar" , "chbDisabled" ) === false ) {
575
- let chbFlagDiv = $ ( coreSetDiv ) . next ( ) ;
583
+ let chbFlagDiv = $ ( usrFirstDiv ) ;
576
584
$ ( chbFlagDiv ) . addClass ( 'chb-setting' ) ;
577
585
$ ( chbFlagDiv ) . addClass ( 'chb-user' ) ;
578
586
$ ( chbFlagDiv ) . attr ( 'id' , 'chbFlagDiv' ) ;
579
587
}
580
588
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
582
590
if ( game . settings . get ( "custom-hotbar" , "coreDisabled" ) === false ) {
583
- let coreFlagDiv = $ ( coreSetDiv ) . next ( ) ;
591
+ let coreFlagDiv = $ ( usrFirstDiv ) . next ( ) ;
584
592
//check to make sure that the custom hotbar is enabled and ajdust if it isn't
585
593
if ( game . settings . get ( "custom-hotbar" , "chbDisabled" ) === true ) {
586
- coreFlagDiv = $ ( coreSetDiv ) . next ( ) ;
587
- } else {
588
- coreFlagDiv = $ ( chbFlagDiv ) . next ( ) ;
594
+ coreFlagDiv = $ ( usrFirstDiv ) ;
589
595
}
590
596
$ ( coreFlagDiv ) . addClass ( 'chb-setting' ) ;
591
597
$ ( coreFlagDiv ) . addClass ( 'chb-user' ) ;
592
598
$ ( coreFlagDiv ) . attr ( 'id' , 'coreFlagDiv' ) ;
593
599
}
594
600
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
- }
614
601
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
615
616
$ ( chbDisableDiv ) . addClass ( 'chb-setting' ) ;
616
617
$ ( chbDisableDiv ) . addClass ( 'chb-disable' ) ;
617
618
$ ( chbDisableDiv ) . attr ( 'id' , 'chbDisableDiv' ) ;
0 commit comments