-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathSettings.js
More file actions
2177 lines (2037 loc) · 93.1 KB
/
Settings.js
File metadata and controls
2177 lines (2037 loc) · 93.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function token_setting_options() {
return [
{
name: 'tokenStyleSelect',
label: 'Token Style',
type: 'dropdown',
options: [
{ value: "circle", label: "Circle", description: `The token is round and is contained within the border. We set "Ignore Aspect Ratio" to true and "Square" to false. Great for tokens with a portrait art style!` },
{ value: "square", label: "Square", description: `The token is square and is contained within the border. We set "Ignore Aspect Ratio" to true and "Square" to true. Great for tokens with a portrait art style!` },
{ value: "virtualMiniCircle", label: "Virtual Mini w/ Round Base", description: `The token looks like a physical mini with a round base. The image will show up as it is naturally with the largest side being equal to the token size, we set "Ignore Aspect Ratio" to false and "Square" to true. We also add a virtual token base to this Style with Borders and Health Aura on the base of the token. Great for tokens with a top-down art style!` },
{ value: "virtualMiniSquare", label: "Virtual Mini w/ Square Base", description: `The token looks like a physical mini with a round base. The image will show up as it is naturally with The largest side being equal to the token size, we set "Ignore Aspect Ratio" to false and "Square" to true. We also add a virtual token base to this Style with Borders and Health Aura on the base of the token. Great for tokens with a top-down art style!` },
{ value: "noConstraint", label: "No Constraint", description: `The token will show up as it is naturally largest side being equal to token size, we set "Ignore Aspect Ratio" to false and "Square to true. Borders and Health Aura are drawn as a drop shadow to fit the shape of the token.` },
{ value: "definitelyNotAToken", label: "Definitely Not a Token", description: `This token will have the shape of no contraints and be made to appear as a object tile` },
{ value: "labelToken", label: "Map Pin Token", description: `This token will have the settings of Definitely Not a Token and have it's name always displayed` },
{ value: "inPersonMini", dmOnly: true, label: "TV Table Mini - Hidden from Players", description: `This token will not be displayed to players on the scene but they will still see it in the combat tracker.` }
],
defaultValue: "circle",
menuPosition: '1',
player: true
},
{
name: 'tokenBaseStyleSelect',
label: 'Token Base Style',
type: 'dropdown',
options: [
{ value: "default", label: "Default", description: "A default dark semi-opaque plastic base." },
{ value: "border-color", label: "Match Border Color", description: "A base that matches the border color of the token." },
{ value: "grass", label: "Grass", description: "A grass covered base.." },
{ value: "tile", label: "Tile", description: "A tile base." },
{ value: "sand", label: "Sand", description: "A sand covered base." },
{ value: "rock", label: "Rock", description: "A rock base." },
{ value: "water", label: "Water", description: "A water base." }
],
defaultValue: "default",
menuPosition: '2',
player: true
},
{
name: "healthauratype",
label: "Health Visual",
type: 'dropdown',
options: [
{ value: "aura", label: "Aura", description: "Tokens will have a colored aura" },
{ value: "aura-bloodied-50", label: "Aura Bloodied 50", description: "Tokens will have a red aura when bloodied" },
{ value: "condition-bloodied-50", label: "Condition Bloodied 50", description: "Tokens will have the bloodied condition automatically applied." },
{ value: "bar", label: "HP Meter", description: "How this meter is displayed depends on token type. Color blind alternative to auras." },
{ value: "none", label: "None", description: "Tokens will not have a health visual" }
],
defaultValue: "aura",
menuPosition: '3',
player: true
},
{
name: 'lockRestrictDrop',
label: 'Token Lock',
type: 'dropdown',
options: [
{ value: "none", label: "None", description: "Token is freely moveable by all players and the DM." },
{ value: "restrict", label: "Restrict player access", description: "Players will not be able to move this token unless it is thier owned PC Token. Will not be added to Players group selections." },
{ value: "lock", label: "Lock", description: "Locks token for both DM and Players. Will not be added to group selections." },
{ value: "declutter", label: "Lock and Declutter Hidden", description: "Locks token for both DM and Players. Will fully hide for DM when hidden."}
],
defaultValue: "none"
},
{
name: 'hidden',
label: 'Hide',
type: 'toggle',
options: [
{ value: true, label: "Hidden", description: "The token is hidden to players." },
{ value: false, label: "Visible", description: "The token is visible to players." }
],
defaultValue: false
},
{
name: 'square',
label: 'Square Token',
type: 'toggle',
options: [
{ value: true, label: "Square", description: "The token is square." },
{ value: false, label: "Round", description: "The token is clipped to fit within a circle." }
],
defaultValue: false,
hiddenSetting: true
},
{
name: 'locked',
label: 'Disable All Interaction',
type: 'toggle',
options: [
{ value: true, label: "Interaction Disabled", description: "The token can not be interacted with in any way. Not movable, not selectable by players, no hp/ac displayed, no border displayed, no nothing. Players shouldn't even know it's a token." },
{ value: false, label: "Interaction Allowed", description: "The token can be interacted with." }
],
defaultValue: false,
hiddenSetting: true
},
{
name: 'restrictPlayerMove',
label: 'Restrict Player Movement',
type: 'toggle',
options: [
{ value: true, label: "Restricted", description: "Players can not move the token unless it is their token." },
{ value: false, label: "Unrestricted", description: "Players can move the token." }
],
defaultValue: false,
hiddenSetting: true
},
{
name: 'revealInFog',
label: `Reveal in Fog/Ignore LoS Checks`,
type: 'toggle',
options: [
{ value: true, label: "Revealed in Fog", description: "The token will not be hidden by fog or vision checks. Below darkness tokens will still be hidden by full darkness. Useful for scene props/items when using darkness." },
{ value: false, label: "Hidden in Fog", description: "The token will be hidden if in fog and vision checks." }
],
defaultValue: false
},
{
name: 'underDarkness',
label: 'Move token below darkness/light',
type: 'toggle',
options: [
{ value: true, label: "Below darkness", description: "The token will appear below darkness/light." },
{ value: false, label: "Above darkness", description: "The token will appear above darkness/light" }
],
defaultValue: false,
menuPosition: '14',
player: true
},
{
name: 'disablestat',
label: 'Remove HP/AC',
type: 'toggle',
options: [
{ value: true, label: "Removed", description: "The token does not have HP/AC shown to either the DM or the players." },
{ value: false, label: "Visible to DM", description: "The token has HP/AC shown to only the DM." }
],
defaultValue: false
},
{
name: 'hidestat',
label: 'Hide Player HP/AC',
type: 'toggle',
options: [
{ value: true, label: "Hidden", description: "Each player can see their own HP/AC, but can't see the HP/AC of other players." },
{ value: false, label: "Visible", description: "Each player can see their own HP/AC as well as the HP/AC of other players." }
],
defaultValue: false
},
{
name: 'hidehpbar',
label: 'Only show HP values on hover',
type: 'toggle',
options: [
{ value: true, label: "On Hover", description: "HP values are only shown when you hover or select the token. The 'Disable HP/AC' option overrides this one." },
{ value: false, label: "Always", description: "HP values are always displayed on the token. The 'Disable HP/AC' option overrides this one." }
],
defaultValue: false
},
{
name: 'disableborder',
label: 'Disable Border',
type: 'toggle',
options: [
{ value: true, label: 'No Border', description: "The token does not have a border around it." },
{ value: false, label: 'Border', description: "The token has a border around it." }
],
defaultValue: false,
menuPosition: '13',
player: true
},
{
name: 'disableaura',
label: 'Disable Health Aura',
type: 'toggle',
options: [
{ value: true, label: 'No Aura', description: "The token does not have an aura representing its current health." },
{ value: false, label: 'Health Aura', description: "The token has an aura representing current health around it." }
],
defaultValue: false,
hiddenSetting: true
},
{
name: 'enablepercenthpbar',
label: 'Enable Token HP% Bar',
type: 'toggle',
options: [
{ value: true, label: 'Health Bar', description: "The token has a traditional visual hp% bar below it" },
{ value: false, label: 'No Bar', description: "The token does not have a traditional visual hp% bar below it" }
],
defaultValue: false,
hiddenSetting: true
},
{
name: 'revealname',
label: 'Show name to players',
type: 'toggle',
options: [
{ value: true, label: 'Visible', description: "The token's name is visible to players" },
{ value: false, label: 'Hidden', description: "The token's name is hidden from players" }
],
defaultValue: false
},
{
name: 'alwaysshowname',
label: 'Always display name',
type: 'toggle',
options: [
{ value: true, label: "Always display name", description: "Always displays name." },
{ value: false, label: "Only display name on hover", description: "Only displays name on hover" }
],
defaultValue: false
},
{
name: 'legacyaspectratio',
label: 'Ignore Image Aspect Ratio',
type: 'toggle',
options: [
{ value: true, label: 'Stretch', description: "The token's image will stretch to fill the token space" },
{ value: false, label: 'Maintain', description: "New token's image will respect the aspect ratio of the image provided" }
],
defaultValue: false,
hiddenSetting: true
},
{
name: "player_owned",
label: "Player Accessible Stats",
type: 'toggle',
options: [
{ value: true, label: 'Player & DM', description: "The token's stat block is accessible to players via the token context menu. Players can also alter the HP/AC of this token." },
{ value: false, label: 'DM only', description: "The token's stat block is not accessible to players via the token context menu. Players can not alter the HP/AC of this token." }
],
defaultValue: false
},
{
name: "defaultmaxhptype",
label: "Max HP Calculation",
type: 'dropdown',
options: [
{ value: "average", label: "Average", description: "Monster Max HP will be set to the average value." },
{ value: "roll", label: "Roll", description: "Monster Max HP will be individually rolled." },
{ value: "max", label: "Max", description: "Monster Max HP will be set to the maximum value." }
],
defaultValue: "average"
},
{
name: "placeType",
label: "Token Name Adjustment",
type: 'dropdown',
options: [
{ value: "count", label: "Count", description: "Tokens's name have a number appended to them." },
{ value: "personality", label: "Personality Trait", description: "Tokens's name have a personaility trait prepended." },
{ value: "none", label: "None", description: "Tokens's name will not be modified." }
],
defaultValue: "count"
},
{
name: "auraislight",
label: "Enable Token Vision/Light",
type: 'toggle',
globalSettingOnly: true,
options: [
{ value: true, label: 'Enabled', description: "Token line of sight will be calculated and token vision/light can be used." },
{ value: false, label: 'Disabled', description: "Token line of sight will be disabled and token vision/light can not be used." }
],
defaultValue: true
},
{
name: "videoToken",
label: "Video Token",
type: 'toggle',
options: [
{ value: true, label: 'Enabled', description: "Token is using a video file for an image (webm, mp4, m4v, etc.) Use this if the URL does not have the file extention at the end." },
{ value: false, label: 'Disabled', description: "The Token is using an image file for it's image (png, jpg, gif, etc.)" }
],
defaultValue: false
},
{
name: "maxAge",
label: "Token has time limit",
type: 'dropdown',
options: [
{ value: false, label: "None", description: "No timer added." },
{ value: "1", label: "1 round", description: "Duration of one round - timer will turn red after it's reached it's time limit." },
{ value: "10", label: "1 minute", description: "Duration of 10 rounds - timer will turn red after it's reached it's time limit." },
{ value: "custom", label: "Custom Timer", description: "Timer will be added - timer will turn red after it's reached it's time limit." }
],
defaultValue: false,
hiddenSetting: true
},
{
name: "tokenWall",
label: "Block Vision",
type: 'dropdown',
options: [
{ value: false, label: 'Disabled', description: "Token will not block line of sight." },
{ value: "circle", label: 'Circle Wall', description: "Token will block line of sight as if walls in a cirle." },
{ value: "circleObject", label: 'Circle Object Wall', description: "Token will block line of sight as if object walls in a cirle." },
{ value: "circleWindow", label: 'Circle Window', description: "Token will block line of sight as if windows in a cirle." },
{ value: "circleCurtain", label: 'Circle Curtain', description: "Token will block line of sight as if curtains in a cirle." },
{ value: "square", label: 'Square Wall', description: "Token will block line of sight as if walls in a square." },
{ value: "squareObject", label: 'Square Object Wall', description: "Token will block line of sight as if object walls in a square." },
{ value: "squareWindow", label: 'Square Window', description: "Token will block line of sight as if windows in a square." },
{ value: "squareCurtain", label: 'Square Curtain', description: "Token will block line of sight as if curtains in a square." },
{ value: "poly", label: 'Polygon Wall', description: "Token will block line of sight as if walls in a square." },
{ value: "polyObject", label: 'Polygon Object Wall', description: "Token will block line of sight as if object walls in a square." },
{ value: "polyWindow", label: 'Polygon Window', description: "Token will block line of sight as if windows in a square." },
{ value: "polyCurtain", label: 'Polygon Curtain', description: "Token will block line of sight as if curtains in a square." },
],
defaultValue: false
}
];
}
function avtt_settings() {
let settings = [
{
name: "iconUi",
label: "Mobile/Icon UI",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `` },
{ value: false, label: "Disable", description: `` }
],
defaultValue: true,
class: 'ui',
global: 1
},
{
name: 'allowTokenMeasurement',
label: 'Measure while dragging tokens',
type: 'toggle',
options: [
{ value: true, label: "Measure", description: `When you drag a token, the distance dragged will automatically be measured. Dropping the token and picking it back up will create a waypoint in the measurement. Clicking anywhere else, or dragging another token will stop the measurement.` },
{ value: false, label: "Not Measuring", description: `Enable this to automatically measure the distance that you drag a token. When enabled, dropping the token and picking it back up will create a waypoint in the measurement. Clicking anywhere else, or dragging another token will stop the measurement.` }
],
defaultValue: false,
class: 'ui',
global: 1
},
{
name: "dragLight",
label: "Vision check while token moves",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `While moving a token vision will update` },
{ value: false, label: "Disable", description: `Vision will only update on drop of a token` }
],
defaultValue: false,
class: 'ui',
global: 1
},
{
name: "gridZoomConversion",
label: "Store Grid Visual Size",
description: "<p>This allows you to save a grid visual size. This is useful for in person play where you want to quickly set the grid size to match physical mini sizes.</p><p>The stored value will be based on the current scenes grid size and zoom level. It will then be able to calculate the correct zoom level to make the grid match the stored visual size on any scene. This may be different per device so you will have to store the value on the device you plan on adjusting zoom to match the stored visual size.</p><p>A quick toggle button will be added to the right side buttons when a value is stored</p>",
buttonText: ["Clear", "Store"],
type: "customButton",
customFunction: [
function (clickEvent, body) {
clear_avtt_setting('gridZoomConversion');
showTempMessage(`Grid visual size cleared`, { fadeDelay: 600, fadeTime: 400 });
$("#grid_zoom_conversion").css('display', 'none');
}, function (clickEvent, body) {
set_avtt_setting_value('gridZoomConversion', window.ZOOM*parseFloat(window.CURRENT_SCENE_DATA.hpps));
showTempMessage(`Grid visual size stored`, { fadeDelay: 600, fadeTime: 400 });
$("#grid_zoom_conversion").css('display', '');
}
],
class: 'ui'
},
{
name: "disableCombatText",
label: "Disable DM Damage Button Text",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `If enabled removes the scrolling text on tokens displayed to DM when using gamelog damage buttons.` },
{ value: false, label: "Disable", description: `If enabled removes the scrolling text on tokens displayed to DM when using gamelog damage buttons.` }
],
defaultValue: false,
class: 'ui',
global: 1
},
{
name: 'streamDiceRolls',
label: 'Stream Dice Rolls',
type: 'toggle',
options: [
{ value: true, label: "Streaming", description: `When you roll DDB dice (to Everyone), all players who also enable this feature will see your rolls and you will see theirs. Disclaimer: the dice will start small then grow to normal size after a few rolls. They will be contained to the smaller of your window or the sending screen size.` },
{ value: false, label: "Not Streaming", description: `When you enable this, DDB dice rolls will be visible to you and all other players who also enable this. Disclaimer: the dice will start small then grow to normal size after a few rolls. They will be contained to the smaller of your window or the sending screen size.` }
],
defaultValue: false,
class: 'stream'
},
{
name: 'iframeStatBlocks',
label: 'Fallback Monster Statblocks',
type: 'toggle',
options: [
{ value: true, label: "Load from DDB", description: `Monster details pages are being fetched and shown as Stat Blocks. Disabling this will build monster stat blocks locally instead. Disabling this will improve performance and reduce network data usage. Enabling this is not recommended unless you are experiencing issues with the default stat blocks.` },
{ value: false, label: "Build Locally", description: `Monster stat blocks are currently being built locally by AboveVTT. Enabling this will fetch and load monster details pages rather than building stat blocks locally. Enabling this will impact performance and will use a lot more network data. Enabling this is not recommended unless you are experiencing issues with the default stat blocks.` }
],
defaultValue: false,
class: 'debug',
},
{
name: "peerStreaming",
label: "Allow Streaming Cursor/Ruler",
type: "toggle",
options: [
{ value: true, label: "Allow", description: `If you are experiencing performance issues or if you have slow internet, you may want to disable this.` },
{ value: false, label: "Never", description: `If you are experiencing performance issues or if you have slow internet, you may want to disable this.` }
],
defaultValue: false,
class: 'stream'
},
{
name: 'alwaysShowSplash',
label: 'Always show splash screen',
type: 'toggle',
options: [
{ value: true, label: "Always", description: `You will always see the splash screen on startup.` },
{ value: false, label: "Only When New", description: `You will only see the splash screen on startup after updating to a new version.` }
],
defaultValue: true,
class: 'ui',
global: 1
},
{
name: "alwaysHideScrollbar",
label: "Always Hide Scrollbar",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `Scrollbar is hidden` },
{ value: false, label: "Disable", description: `Scrollbar is allowed` }
],
defaultValue: false,
class: 'ui',
global: 1
}
];
if (window.DM) {
// Remove the `dm` an option for the DM and tweak the descriptions to remove references to the DM.
settings.push(
{
name: "receiveCursorFromPeers",
label: "Cursors You See",
type: "dropdown",
options: [
{ value: "all", label: "Everyone", description: `When players move their cursor, you will see where their cursor is. You will not see cursors of any player that disables cursor/ruler streaming.` },
{ value: "none", label: "No One", description: `You will not see the cursor position of any player.` },
{ value: "combatTurn", label: "Current Combat Turn", description: `You will only see players' cursors during their turn in combat. You will not see cursors of any player that disables cursor/ruler streaming.` }
],
defaultValue: "all",
class: 'stream'
},
{
name: "receiveRulerFromPeers",
label: "Rulers You See",
type: "dropdown",
options: [
{ value: "all", label: "Everyone", description: `When players measure while dragging a token or measure with the ruler tool, you will see their ruler. You will not see rulers of any player that disables cursor/ruler streaming.` },
{ value: "none", label: "No One", description: `You will not see any token measurement or ruler measurement from any player.` },
{ value: "combatTurn", label: "Current Combat Turn", description: `You will only see players' token measurement and ruler measurement during their turn in combat. You will not see rulers of any player that disables cursor/ruler streaming.` }
],
defaultValue: "all",
class: 'stream'
},
{
name: "projector",
label: "Streaming/TV Projector Mode",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `If you have another tab with the player view open it will receive your scroll and zoom events.` },
{ value: false, label: "Disable", description: `If you have another tab with the player view open it will not receive your scroll and zoom events.` }
],
defaultValue: false,
class: 'stream'
},
{
name: "tokenDefaults",
label: "Token Settings Defaults",
buttonText: "Edit",
type: "customButton",
customFunction: function (clickEvent, body) {
build_and_display_sidebar_flyout(clickEvent.clientY, function (flyout) {
let optionsContainer = build_sidebar_token_options_flyout(token_setting_options(), window.TOKEN_SETTINGS, function (name, value) {
if (value === true || value === false || typeof value === 'string' || typeof value === 'object') {
window.TOKEN_SETTINGS[name] = value;
} else {
delete window.TOKEN_SETTINGS[name];
}
}, function() {
let visionInput = $("input[name='visionColor']").spectrum("get");
let light1Input = $("input[name='light1Color']").spectrum("get");
let light2Input = $("input[name='light2Color']").spectrum("get");
window.TOKEN_SETTINGS.vision.color= `rgba(${visionInput._r}, ${visionInput._g}, ${visionInput._b}, ${visionInput._a})`;
window.TOKEN_SETTINGS.light1.color = `rgba(${light1Input._r}, ${light1Input._g}, ${light1Input._b}, ${light1Input._a})`;
window.TOKEN_SETTINGS.light2.color = `rgba(${light2Input._r}, ${light2Input._g}, ${light2Input._b}, ${light2Input._a})`;
persist_token_settings(window.TOKEN_SETTINGS);
redraw_settings_panel_token_examples();
}, true);
optionsContainer.prepend(`<div class="sidebar-panel-header-explanation">Every time you place a token on the scene, these settings will be used. You can override these settings on a per-token basis by clicking the gear on a specific token row in the tokens tab.</div>`);
const clearAllOverridesWarning = `This will remove ALL overridden token options from every player, monster, custom token, and folder in the Tokens Panel. This shouldn't remove any custom images from those tokens. This will not update any tokens that have been placed on a scene. This cannot be undone.`;
let clearAllTokenOverrides = $(`<button class='token-image-modal-remove-all-button sidebar-hover-text' data-hover="${clearAllOverridesWarning}" style="width:100%;padding:8px;margin:10px 0px;">Clear All Token Option Overrides</button>`);
clearAllTokenOverrides.on("click", function() {
if (confirm(clearAllOverridesWarning)) {
window.TOKEN_CUSTOMIZATIONS.forEach(tc => tc.clearTokenOptions());
persist_all_token_customizations(window.TOKEN_CUSTOMIZATIONS);
redraw_settings_panel_token_examples();
}
});
optionsContainer.append(clearAllTokenOverrides);
flyout.append(optionsContainer);
position_flyout_left_of(body, flyout);
});
},
class: 'defaults'
},
{
name: "sceneDefaults",
label: "Scene Settings Defaults",
buttonText: "Edit",
type: "customButton",
customFunction: function (clickEvent, body) {
const self=this;
build_and_display_sidebar_flyout(clickEvent.clientY, function (flyout) {
let optionsContainer = build_sidebar_token_options_flyout(scene_setting_options(), window.SCENE_DEFAULT_SETTINGS, function (name, value) {
if (value != 'undefined' && (value === true || value === false || typeof value === 'string' || typeof value === 'object' || typeof value === 'number')) {
window.SCENE_DEFAULT_SETTINGS[name] = value;
} else {
delete window.SCENE_DEFAULT_SETTINGS[name];
}
}, function() {
persist_default_scene_settings(window.SCENE_DEFAULT_SETTINGS);
}, false, true, true);
optionsContainer.prepend(`<div class="sidebar-panel-header-explanation">Every time you create a scene these settings will be used</div>`);
const clearAllSceneDefaultWarning = `Are you sure you want to reset your scene defaults?`;
let clearAllSceneDefault = $(`<button class='token-image-modal-remove-all-button sidebar-hover-text' data-hover="${clearAllSceneDefaultWarning}" style="width:100%;padding:8px;margin:10px 0px;">Reset Scene Defaults</button>`);
clearAllSceneDefault.on("click", function() {
if (confirm(clearAllSceneDefaultWarning)) {
window.SCENE_DEFAULT_SETTINGS = {};
persist_default_scene_settings(window.SCENE_DEFAULT_SETTINGS);
self.customFunction(clickEvent, body);
}
});
optionsContainer.append(clearAllSceneDefault);
flyout.append(optionsContainer);
position_flyout_left_of(body, flyout);
});
},
class: 'defaults'
}
);
} else {
settings.push(
{
name: "receiveCursorFromPeers",
label: "Cursors You See",
type: "dropdown",
options: [
{ value: "all", label: "Everyone", description: `When other players or the DM move their cursor, you will see where their cursor is. You will not see cursors of any player or DM that disables cursor/ruler streaming.` },
{ value: "none", label: "No One", description: `You will not see the cursor position of any player or the DM.` },
{ value: "dm", label: "DM Only", description: `You will only see the DM's cursor position. You will not see cursors of any player or DM that disables cursor/ruler streaming.` },
{ value: "combatTurn", label: "Current Combat Turn", description: `You will only see other players' cursors during their turn in combat. You will also see the DM's cursor position. You will not see cursors of any player or DM that disables cursor/ruler streaming.` }
],
defaultValue: "all",
class: 'stream'
},
{
name: "receiveRulerFromPeers",
label: "Rulers You See",
type: "dropdown",
options: [
{ value: "all", label: "Everyone", description: `When other players or the DM measure while dragging a token or measure with the ruler tool, you will see their ruler. You will not see rulers of any player or DM that disables cursor/ruler streaming.` },
{ value: "none", label: "No One", description: `You will not see any token measurement or ruler measurement from any player or the DM.` },
{ value: "dm", label: "DM Only", description: `You will only see the DM's token or ruler measurement. You will not see rulers of any player or DM that disables cursor/ruler streaming.` },
{ value: "combatTurn", label: "Current Combat Turn", description: `You will only see other players' token measurement and ruler measurement during their turn in combat. You will also see the DM's token measurement and ruler tool. You will not see rulers of any player or DM that disables cursor/ruler streaming.` }
],
defaultValue: "all",
class: 'stream'
}
);
}
settings.push(
{
name: "rpgRoller",
label: "Disable DDB dice where possible",
type: "toggle",
options: [
{ value: true, label: "RNG Dice", description: `Disables DDB dice and uses a random number generator` },
{ value: false, label: "DDB Dice", description: `Defaults to DDB dice` }
],
defaultValue: false,
class: 'performance',
global: 1
})
settings.push({
name: "colorBlindText",
label: "Red/Green Colorblind Text",
type: "toggle",
options: [
{ value: true, label: "Enable", description: `If enabled adjusts green text to yellow` },
{ value: false, label: "Disable", description: `If enabled adjusts green text to yellow` }
],
defaultValue: false,
class: 'ui',
global: 1
})
settings.push(
{
name: "disableSendToTab",
label: "Disable capture of pc tab rolls",
type: "toggle",
options: [
{ value: true, label: "Disabled", description: `By default AVTT captures data and rolls from player sheets in tabs and iframes.<p>It's only recommended to toggle this on when using player sheets in a tab in the same window of AboveVTT.</p><p>If the tab is in another window/monitor it's recommended for this to be toggled off.</p>` },
{ value: false, label: "Enabled", description: `By default AVTT captures data and rolls from player sheets in tabs and iframes.<p>It's only recommended to toggle this on when using player sheets in a tab in the same window of AboveVTT.</p><p>If the tab is in another window/monitor it's recommended for this to be toggled off.</p>` }
],
defaultValue: false,
class: 'ui'
})
settings.push(
{
name: "reduceMovement",
label: "Reduce animation movement",
type: "toggle",
options: [
{ value: true, label: "Disabled", description: `Reduces movement by disabling some animations` },
{ value: false, label: "Enabled", description: `All animations will be enabled` }
],
defaultValue: false,
class: 'performance',
global: 1
})
settings.push(
{
name: "autoReconnect",
label: "Auto Reconnect",
type: "toggle",
options: [
{ value: true, label: "Enabled", description: `It is only recommended to use this setting if you have an unstable connection that is causing several disconnects. It may cause desync or tokens to reset due to missing messages.` },
{ value: false, label: "Disabled", description: `It is only recommended to use this setting if you have an unstable connection that is causing several disconnects. It may cause desync or tokens to reset due to missing messages.` }
],
defaultValue: false,
class: 'debug'
})
settings.push(
{
name: "statBlockStyle",
label: "Statblock Style",
type: "dropdown",
options: [
{ value: 0, label: "Auto detect", description: `Will auto detect 2014 vs 2024 and apply appropriate style` },
{ value: 1, label: "Always 2014", description: `Will always display in 2014 style` },
{ value: 2, label: "Always 2024", description: `Will always display in 2024 style` },
],
defaultValue: false,
class: 'ui',
global: 1
})
settings.push(
{
name: "monsterCritType",
label: "Monster Action Crit Type",
type: "dropdown",
options: [
{ value: "0", label: "Double damage dice", description: "Doubles damage dice for crits." },
{ value: "1", label: "Perfect Crits", description: "Rolls the original dice and adds a max roll" },
{ value: "3", label: "Double total damage", description: "Rolls the original dice adds modifier then doubles it" },
{ value: "2", label: "Manual", description: "Rolls are not modified based on crit" },
],
defaultValue: 0,
class: 'ui'
})
settings.push({
name: 'quickToggleDefaults',
label: 'Quick Toggle Defaults on Load',
type: 'flyoutButton',
options: [
{ name: "selectedTokenVision", label: "Selected Token Vision", defaultValue: false, dmOnly: false, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "snapTooltoGrid", label: "Grid Snap Most Tools", defaultValue: false, dmOnly: false, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "centerPing", label: "Center Player View on Ping", defaultValue: true, dmOnly: true, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "selectLocked", label: "Locked Tokens Selectable", defaultValue: true, dmOnly: true, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "rulerToPlayers", label: "Send ruler/cursor to Players", defaultValue: true, dmOnly: true, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "projectorMode", label: "Projector Mode Quick Toggle", defaultValue: false, dmOnly: true, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "projectorLock", label: "Projector Mode Lock Zoom", defaultValue: false, dmOnly: true, type: 'toggle',options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
], },
{ name: "spectatorHideUi", label: "Spectate View Hide UI", defaultValue: false, dmOnly: false, type: 'toggle', options: [
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
],
},
],
defaultValue: {},
class: 'defaults'
})
settings.push({
name: 'quickRoll',
label: 'Numkey Quick Roll options',
type: 'flyoutButton',
options: [
{
name: 'autoRoll',
label: 'Auto-roll the below',
type: 'toggle',
options:[
{ value: true, label: "Enabled", description: `` },
{ value: false, label: "Disabled", description: `` }
],
defaultValue: false
},
{
name: 'customDieRoll1',
label: 'Custom Roll 1 Key',
type: 'text',
defaultValue: '1d4'
},
{
name: 'customDieRoll2',
label: 'Custom Roll 2 Key',
type: 'text',
defaultValue: '1d6'
},
{
name: 'customDieRoll3',
label: 'Custom Roll 3 Key',
type: 'text',
defaultValue: '1d8'
},
{
name: 'customDieRoll4',
label: 'Custom Roll 4 Key',
type: 'text',
defaultValue: '1d100'
},
{
name: 'customDieRoll5',
label: 'Custom Roll 5 Key',
type: 'text',
defaultValue: '1d10'
},
{
name: 'customDieRoll6',
label: 'Custom Roll 6 Key',
type: 'text',
defaultValue: '1d12'
},
{
name: 'customDieRoll7',
label: 'Custom Roll 7 Key',
type: 'text',
defaultValue: '1d20'
},
{
name: 'customDieRoll8',
label: 'Custom Roll 8 Key',
type: 'text',
defaultValue: '2d20kl1'
},
{
name: 'customDieRoll9',
label: 'Custom Roll 9 Key',
type: 'text',
defaultValue: '2d20kh1'
},
],
defaultValue: {
'autoRoll': false,
'customDieRoll1': '1d4',
'customDieRoll2': '1d6',
'customDieRoll3': '1d8',
'customDieRoll4': '1d100',
'customDieRoll5': '1d10',
'customDieRoll6': '1d12',
'customDieRoll7': '1d20',
'customDieRoll8': '2d20kl1',
'customDieRoll9': '2d20kh1',
},
class: 'ui'
})
if (AVTT_ENVIRONMENT.versionSuffix) {
// This is either a local or a beta build, so allow this helpful debugging tool
settings.push({
name: "aggressiveErrorMessages",
label: "Alert Every Concerning Log",
type: "toggle",
options: [
{ value: true, label: "Show", description: `This will show an error dialog for every error or warning log that AboveVTT encounters.` },
{ value: false, label: "Don't Show", description: `Only show an error dialog when AboveVTT explicitly coded for it.` }
],
defaultValue: false,
class: 'debug'
});
}
return settings;
}
function scene_setting_options(){
return [
{
name: 'dm_map_usable',
label: 'DM Map',
type: 'toggle',
options: [
{ value: true, label: "DM Map Enabled", description: "Will enable a DM map field to have a DM only version of the map." },
{ value: false, label: "DM Map Disabled", description: "DM and Players will see the same map" }
],
defaultValue: false,
convertToDropdownInSettings: true,
notOverridenLabeleLabel: 'DM Map Enabled if link already exists in scene data'
},
{
name: 'grid',
label: 'Display Grid',
type: 'toggle',
options: [
{ value: true, label: "Display Grid", description: "Grid is visible" },
{ value: false, label: "Hide Grid", description: "Grid is not drawn" }
],
defaultValue: false
},
{
name: 'grid_color',
label: 'Grid Color',
type: 'colorSelect',
defaultValue: '#000'
},
{
name: 'gridOver',
label: 'Grid Layer',
type: 'dropdown',
options: [
{ value: 0, label: "Under Darkness/Fog", description: "Grid will be drawn under darkness/fog" },
{ value: 1, label: "Over Darkness/Fog", description: "Grid will be drawn over darkness/fog" }
],
defaultValue: false
},
{
name: 'grid_line_width',
label: 'Grid Line Width',
type: 'rangeInput',
options: [
{ min: 0.5, max: 10, step: 0.5, description: "Grid line width" },
],
defaultValue: 1
},
{
name: 'snap',
label: 'Snap to Grid',
type: 'toggle',
options: [
{ value: true, label: "Snap to Grid", description: "Tokens will be snapped to the grid" },
{ value: false, label: "Disable Snap to Grid", description: "Tokens will not snap to grid" }
],
defaultValue: false
},
{
name: 'disableSceneVision',
label: 'Disable token vision/light',
type: 'toggle',
options: [
{ value: true, label: "Disable token vision/light", description: "Tokens vision checks won't be run, walls will be ignored" },
{ value: false, label: "Enabled token vision/light", description: "Tokens will run vision checks" }
],
defaultValue: false
},
{
name: 'darkness_filter',
label: 'Line of Sight/Darkness Opacity',
type: 'rangeInput',
options: [
{ min: 0, max: 100, step: 1, description: "Darkness and line of sight opacity. At 100% areas out of vision will be opaque black." },
],
defaultValue: 0
},
{
name: 'visionTrail',
label: 'Player Explored Vision Trail',
type: 'toggle',
options: [
{ value: true, label: "Enable Player Explored Vision Trail", description: "Explored areas out of line of sight will remain visible. Tokens will still be hidden when out of line of sight unless line of sight checks are disabled on that token." },
{ value: false, label: "Disable Player Explored Vision Trail", description: "Explored areas out of line of sight won't be visible." }
],
defaultValue: false
},
{
name: 'daylight',
label: 'Daylight Color',
type: 'colorSelect',
defaultValue: '#fff'
},
];
}
function get_custom_scene_settings(){
const settings = {};
for(let i in window.SCENE_DEFAULT_SETTINGS){
settings[i] = window.SCENE_DEFAULT_SETTINGS[i] === true || window.SCENE_DEFAULT_SETTINGS[i] === 'true' ? "1" : window.SCENE_DEFAULT_SETTINGS[i] == false || window.SCENE_DEFAULT_SETTINGS[i] === 'false' ? "0" : window.SCENE_DEFAULT_SETTINGS[i]
}
return settings;
}
function get_avtt_setting_default_value(name) {
return avtt_settings().find(s => s.name === name)?.defaultValue;
}
function get_avtt_setting_value(name) {
if (name === "aggressiveErrorMessages" && is_release_build()) {
return false; // never allow this in a release build
}
switch (name) {
case "iframeStatBlocks": return should_use_iframes_for_monsters();
default:
const setValue = window.EXPERIMENTAL_SETTINGS[name];
if (setValue !== undefined) {
return setValue;
}
return get_avtt_setting_default_value(name);
}
}
function get_avtt_setting_is_global(name) {
return avtt_settings().find(s => s.name === name)?.global === 1;
}
function set_avtt_setting_value(name, newValue) {
console.log(`set_avtt_setting_value ${name} is now ${newValue}`);
// store the setting
window.EXPERIMENTAL_SETTINGS[name] = newValue;
persist_experimental_settings(window.EXPERIMENTAL_SETTINGS);
// take action based on the newly changed setting
switch (name) {
case "iframeStatBlocks":
// TODO: change this to use window.EXPERIMENTAL_SETTINGS[name] instead of using special logic
if (newValue === true) {
use_iframes_for_monsters();
} else {
stop_using_iframes_for_monsters();
}
break;
case "streamDiceRolls":
// TODO: change this to use window.EXPERIMENTAL_SETTINGS[name] instead of using special logic
if (newValue === true || newValue === false) {
window.JOINTHEDICESTREAM = newValue;
enable_dice_streaming_feature(newValue)
} else {
const defaultValue = get_avtt_setting_default_value(name);
window.JOINTHEDICESTREAM = defaultValue;
enable_dice_streaming_feature(defaultValue);
}
break;
case "peerStreaming":
toggle_peer_settings_visibility(newValue);
local_peer_setting_changed(name, newValue);
break;
case "projector":
$('#projector_toggle, #projector_zoom_lock').toggleClass('enabled', newValue);
break;
case "receiveCursorFromPeers":
case "receiveRulerFromPeers":
local_peer_setting_changed(name, newValue);
break;
case "rpgRoller":
if(is_abovevtt_page()){
tabCommunicationChannel.postMessage({
msgType: 'setupObserver',