-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathsettings-menu.ts
774 lines (715 loc) · 34.3 KB
/
settings-menu.ts
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
/* eslint-disable @typescript-eslint/no-explicit-any */
import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces';
import { keepTrackApi } from '@app/keepTrackApi';
import { ColorPick } from '@app/lib/color-pick';
import { getEl } from '@app/lib/get-el';
import { parseRgba } from '@app/lib/rgba';
import { rgbCss } from '@app/lib/rgbCss';
import { PersistenceManager, StorageKey } from '@app/singletons/persistence-manager';
import { LegendManager } from '@app/static/legend-manager';
import { OrbitCruncherType, OrbitDrawTypes } from '@app/webworker/orbitCruncher';
import settingsPng from '@public/img/icons/settings.png';
import { KeepTrackPlugin } from '../KeepTrackPlugin';
import { SoundNames } from '../sounds/SoundNames';
import { TimeMachine } from '../time-machine/time-machine';
import { SettingsManager } from '@app/settings/settings';
/**
* /////////////////////////////////////////////////////////////////////////////
*
* https://keeptrack.space
*
* @Copyright (C) 2016-2024 Theodore Kruczek
* @Copyright (C) 2020-2024 Heather Kruczek
*
* KeepTrack is free software: you can redistribute it and/or modify it under the
* terms of the GNU Affero General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* KeepTrack is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with
* KeepTrack. If not, see <http://www.gnu.org/licenses/>.
*
* /////////////////////////////////////////////////////////////////////////////
*/
declare module '@app/interfaces' {
interface UserSettings {
isBlackEarth: boolean;
isDrawMilkyWay: boolean;
}
}
export class SettingsMenuPlugin extends KeepTrackPlugin {
readonly id = 'SettingsMenuPlugin';
dependencies_ = [];
bottomIconElementName: string = 'settings-menu-icon';
bottomIconImg = settingsPng;
sideMenuElementName: string = 'settings-menu';
sideMenuElementHtml: string = keepTrackApi.html`
<div id="settings-menu" class="side-menu-parent start-hidden text-select">
<div id="settings-content" class="side-menu">
<div class="row">
<form id="settings-form">
<div id="settings-general">
<div class="row center"></div>
</br>
<div class="row center">
<button id="settings-submit" class="btn btn-ui waves-effect waves-light" type="submit" name="action">Update Settings ►</button>
</div>
<div class="row center">
<button id="settings-reset" class="btn btn-ui waves-effect waves-light" type="button" name="action">Reset to Defaults ►</button>
</div>
<h5 class="center-align">General Settings</h5>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide notional satellites">
<input id="settings-notionalSats" type="checkbox" checked/>
<span class="lever"></span>
Show Notional Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide LEO satellites">
<input id="settings-leoSats" type="checkbox" checked/>
<span class="lever"></span>
Show LEO Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide Starlink satellites">
<input id="settings-starlinkSats" type="checkbox" checked/>
<span class="lever"></span>
Show Starlink Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide HEO satellites">
<input id="settings-heoSats" type="checkbox" checked/>
<span class="lever"></span>
Show HEO Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide MEO satellites">
<input id="settings-meoSats" type="checkbox" checked/>
<span class="lever"></span>
Show MEO Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide GEO satellites">
<input id="settings-geoSats" type="checkbox" checked/>
<span class="lever"></span>
Show GEO Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide Payloads">
<input id="settings-showPayloads" type="checkbox" checked/>
<span class="lever"></span>
Show Payloads
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide Rocket Bodies">
<input id="settings-showRocketBodies" type="checkbox" checked/>
<span class="lever"></span>
Show Rocket Bodies
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide Debris">
<input id="settings-showDebris" type="checkbox" checked/>
<span class="lever"></span>
Show Debris
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Planned feature - This will show agencies on the globe.">
<input id="settings-showAgencies" type="checkbox" disabled/>
<span class="lever"></span>
Show Agencies
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable this to hide the camera widget">
<input id="settings-drawCameraWidget" type="checkbox" checked/>
<span class="lever"></span>
Show Camera Widget
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable this to hide orbit lines">
<input id="settings-drawOrbits" type="checkbox" checked/>
<span class="lever"></span>
Draw Orbits
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Enable this to show where a satellite was instead of where it is going">
<input id="settings-drawTrailingOrbits" type="checkbox"/>
<span class="lever"></span>
Draw Trailing Orbits
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Orbits will be drawn using ECF vs ECI (Mainly for GEO Orbits)">
<input id="settings-drawEcf" type="checkbox" />
<span class="lever"></span>
Draw Orbits in ECF
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Draw lines from sensor to satellites when in FOV">
<input id="settings-isDrawInCoverageLines" type="checkbox" checked/>
<span class="lever"></span>
Draw FOV Lines
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Draw the Sun">
<input id="settings-drawSun" type="checkbox" checked/>
<span class="lever"></span>
Draw the Sun
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Hides Earth Textures">
<input id="settings-drawBlackEarth" type="checkbox"/>
<span class="lever"></span>
Draw Black Earth
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide the Atmosphere">
<input id="settings-drawAtmosphere" type="checkbox" checked/>
<span class="lever"></span>
Draw Atmosphere
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Disable to hide the Aurora">
<input id="settings-drawAurora" type="checkbox" checked/>
<span class="lever"></span>
Draw Aurora
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Change the Skybox to Gray">
<input id="settings-graySkybox" type="checkbox" checked/>
<span class="lever"></span>
Draw Gray Background
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Draw Milky Way in Background">
<input id="settings-drawMilkyWay" type="checkbox" checked/>
<span class="lever"></span>
Draw the Milky Way
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Display ECI Coordinates on Hover">
<input id="settings-eciOnHover" type="checkbox"/>
<span class="lever"></span>
Display ECI on Hover
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Non-selectable satellites will be hidden instead of grayed out.">
<input id="settings-hos" type="checkbox" />
<span class="lever"></span>
Hide Other Satellites
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Show confidence levels for satellite's element sets.">
<input id="settings-confidence-levels" type="checkbox" />
<span class="lever"></span>
Show Confidence Levels
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Every 3 seconds a new satellite will be selected from FOV">
<input id="settings-demo-mode" type="checkbox" />
<span class="lever"></span>
Enable Demo Mode
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Small text labels will appear next to all satellites in FOV.">
<input id="settings-sat-label-mode" type="checkbox" checked />
<span class="lever"></span>
Enable Satellite Label Mode
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Time will freeze as you rotate the camera.">
<input id="settings-freeze-drag" type="checkbox" />
<span class="lever"></span>
Enable Freeze Time on Click
</label>
</div>
<div class="switch row">
<label data-position="top" data-delay="50" data-tooltip="Time Machine stop showing toast messages.">
<input id="settings-time-machine-toasts" type="checkbox" />
<span class="lever"></span>
Disable Time Machine Toasts
</label>
</div>
</div>
<div class="row light-blue darken-3" style="height:4px; display:block;"></div>
<div id="settings-colors" class="row">
<h5 class="center-align">Color Settings</h5>
<div class="row">
<div class="input-field col s6">
<center>
<p>Payload</p>
<button id="settings-color-payload" class="btn waves-effect waves-light"></button>
</center>
</div>
<div class="input-field col s6">
<center>
<p>Rocket Body</p>
<button id="settings-color-rocketBody" class="btn waves-effect waves-light"></button>
</center>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<center>
<p>Debris</p>
<button id="settings-color-debris" class="btn waves-effect waves-light"></button>
</center>
</div>
<div class="input-field col s6">
<center>
<p>In View</p>
<button id="settings-color-inview" class="btn waves-effect waves-light"></button>
</center>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<center>
<p>Missile</p>
<button id="settings-color-missile" class="btn waves-effect waves-light"></button>
</center>
</div>
<div class="input-field col s6">
<center>
<p>Missile (FOV)</p>
<button id="settings-color-missileInview" class="btn waves-effect waves-light"></button>
</center>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<center>
<p>Special Sats</p>
<button id="settings-color-special" class="btn waves-effect waves-light"></button>
</center>
</div>
</div>
</div>
<div id="settings-opt" class="row">
<div class="row">
<h5 class="center-align">Settings Overrides</h5>
</div>
<div class="row">
<div class="input-field col s12">
<input value="150" id="maxSearchSats" type="text" data-position="top" data-delay="50" data-tooltip="Maximum satellites to display in search" />
<label for="maxSearchSats" class="active">Maximum Satellites in Search</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input value="30" id="satFieldOfView" type="text" data-position="top" data-delay="50" data-tooltip="What is the satellite's field of view in degrees" />
<label for="satFieldOfView" class="active">Satellite Field of View</label>
</div>
</div>
</div>
<div id="fastCompSettings" class="row">
<h5 class="center-align">Fast CPU Required</h5>
<div class="switch row">
<label>
<input id="settings-snp" type="checkbox" />
<span class="lever"></span>
Show Next Pass on Hover
</label>
</div>
</div>
</form>
</div>
</div>
</div>`;
isNotColorPickerInitialSetup = false;
addHtml(): void {
super.addHtml();
keepTrackApi.register({
event: KeepTrackApiEvents.uiManagerFinal,
cbName: this.id,
cb: () => {
getEl('settings-form').addEventListener('change', SettingsMenuPlugin.onFormChange_);
getEl('settings-form').addEventListener('submit', SettingsMenuPlugin.onSubmit_);
getEl('settings-reset').addEventListener('click', SettingsMenuPlugin.resetToDefaults);
const colorPalette = [
// Reds
rgbCss([1.0, 0.0, 0.0, 1.0]), // Red
rgbCss([1.0, 0.4, 0.4, 1.0]), // Light Red
rgbCss([1.0, 0.0, 0.6, 1.0]), // Pink
rgbCss([1.0, 0.75, 0.8, 1.0]), // Light Pink
rgbCss([1.0, 0.0, 1.0, 1.0]), // Magenta
// Oranges
rgbCss([1.0, 0.65, 0.0, 1.0]), // Orange
rgbCss([0.85, 0.5, 0.0, 1.0]), // Dark Orange
rgbCss([1.0, 0.8, 0.6, 1.0]), // Peach
// Yellows
rgbCss([1.0, 1.0, 0.0, 1.0]), // Yellow
rgbCss([0.8, 0.4, 0.0, 1.0]), // Dark Yellow
// Greens
rgbCss([0.4, 0.8, 0.0, 1.0]), // Chartreuse
rgbCss([0.0, 1.0, 0.0, 1.0]), // Lime Green
rgbCss([0.2, 1.0, 0.0, 0.5]), // Dark Green (with transparency)
rgbCss([0.5, 1.0, 0.5, 1.0]), // Mint Green
rgbCss([0.6, 0.8, 0.2, 1.0]), // Olive Green
// Cyans
rgbCss([0.0, 1.0, 1.0, 1.0]), // Cyan
rgbCss([0.0, 0.8, 0.8, 1.0]), // Light Blue
rgbCss([0.0, 0.5, 0.5, 1.0]), // Teal
rgbCss([0.0, 0.2, 0.4, 1.0]), // Dark Teal
// Blues
rgbCss([0.2, 0.4, 1.0, 1.0]), // Dark Blue
rgbCss([0.0, 0.0, 0.5, 1.0]), // Navy Blue
// Purples
rgbCss([0.5, 0.0, 1.0, 1.0]), // Purple
rgbCss([0.5, 0.0, 0.5, 1.0]), // Dark Purple
rgbCss([0.8, 0.2, 0.8, 1.0]), // Violet
// Browns
rgbCss([0.5, 0.25, 0.0, 1.0]), // Brown
rgbCss([0.6, 0.4, 0.2, 1.0]), // Tan
rgbCss([0.9, 0.9, 0.5, 1.0]), // Beige
// Grays
rgbCss([0.9, 0.9, 0.9, 1.0]), // Light Gray
rgbCss([0.5, 0.5, 0.5, 1.0]), // Gray
rgbCss([0.1, 0.1, 0.1, 1.0]), // Dark Gray
];
ColorPick.initColorPick('#settings-color-payload', {
initialColor: rgbCss(settingsManager.colors?.payload || [0.2, 1.0, 0.0, 0.5]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'payload'),
});
ColorPick.initColorPick('#settings-color-rocketBody', {
initialColor: rgbCss(settingsManager.colors?.rocketBody || [0.2, 0.4, 1.0, 1]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'rocketBody'),
});
ColorPick.initColorPick('#settings-color-debris', {
initialColor: rgbCss(settingsManager.colors?.debris || [0.5, 0.5, 0.5, 1]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'debris'),
});
ColorPick.initColorPick('#settings-color-inview', {
initialColor: rgbCss(settingsManager.colors?.inFOV || [0.85, 0.5, 0.0, 1.0]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'inview'),
});
ColorPick.initColorPick('#settings-color-missile', {
initialColor: rgbCss(settingsManager.colors?.missile || [1.0, 1.0, 0.0, 1.0]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'missile'),
});
ColorPick.initColorPick('#settings-color-missileInview', {
initialColor: rgbCss(settingsManager.colors?.missileInview || [1.0, 0.0, 0.0, 1.0]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'missileInview'),
});
ColorPick.initColorPick('#settings-color-special', {
initialColor: rgbCss(settingsManager.colors?.pink || [1.0, 0.0, 0.6, 1.0]),
palette: colorPalette,
onColorSelected: (colorpick: ColorPick) => this.onColorSelected_(colorpick, 'pink'),
});
this.isNotColorPickerInitialSetup = true;
},
});
}
addJs(): void {
super.addJs();
keepTrackApi.register({
event: KeepTrackApiEvents.uiManagerFinal,
cbName: this.id,
cb: () => {
SettingsMenuPlugin.syncOnLoad();
},
});
}
static syncOnLoad() {
const drawCameraWidgetEl = <HTMLInputElement>getEl('settings-drawCameraWidget');
if (drawCameraWidgetEl) {
drawCameraWidgetEl.checked = settingsManager.drawCameraWidget;
const cameraControlWidgetEl = getEl('camera-control-widget');
if (cameraControlWidgetEl) {
cameraControlWidgetEl.style.display = settingsManager.drawCameraWidget ? 'block' : 'none';
}
}
const settingsElements = [
{ id: 'settings-notionalSats', setting: 'isShowNotionalSats' },
{ id: 'settings-leoSats', setting: 'isShowLeoSats' },
{ id: 'settings-starlinkSats', setting: 'isShowStarlinkSats' },
{ id: 'settings-heoSats', setting: 'isShowHeoSats' },
{ id: 'settings-meoSats', setting: 'isShowMeoSats' },
{ id: 'settings-geoSats', setting: 'isShowGeoSats' },
{ id: 'settings-showPayloads', setting: 'isShowPayloads' },
{ id: 'settings-showRocketBodies', setting: 'isShowRocketBodies' },
{ id: 'settings-showDebris', setting: 'isShowDebris' },
{ id: 'settings-showAgencies', setting: 'isShowAgencies' },
{ id: 'settings-drawOrbits', setting: 'isDrawOrbits' },
{ id: 'settings-drawTrailingOrbits', setting: 'isDrawTrailingOrbits' },
{ id: 'settings-drawEcf', setting: 'isOrbitCruncherInEcf' },
{ id: 'settings-isDrawInCoverageLines', setting: 'isDrawInCoverageLines' },
{ id: 'settings-drawSun', setting: 'isDrawSun' },
{ id: 'settings-drawBlackEarth', setting: 'isBlackEarth' },
{ id: 'settings-drawAtmosphere', setting: 'isDrawAtmosphere' },
{ id: 'settings-drawAurora', setting: 'isDrawAurora' },
{ id: 'settings-drawMilkyWay', setting: 'isDrawMilkyWay' },
{ id: 'settings-graySkybox', setting: 'isGraySkybox' },
{ id: 'settings-eciOnHover', setting: 'isEciOnHover' },
{ id: 'settings-hos', setting: 'colors.transparent[3] === 0' },
{ id: 'settings-confidence-levels', setting: 'isShowConfidenceLevels' },
{ id: 'settings-demo-mode', setting: 'isDemoModeOn' },
{ id: 'settings-sat-label-mode', setting: 'isSatLabelModeOn' },
{ id: 'settings-freeze-drag', setting: 'isFreezePropRateOnDrag' },
{ id: 'settings-time-machine-toasts', setting: 'isDisableTimeMachineToasts' },
];
settingsElements.forEach(({ id, setting }) => {
const element = <HTMLInputElement>getEl(id);
if (element) {
if (setting.includes('colors.transparent')) {
element.checked = settingsManager.colors.transparent[3] === 0;
} else {
element.checked = settingsManager[setting];
}
}
});
const maxSearchSatsEl = <HTMLInputElement>getEl('maxSearchSats');
if (maxSearchSatsEl) {
maxSearchSatsEl.value = settingsManager.searchLimit.toString();
}
// (<HTMLInputElement>getEl('satFieldOfView')).value = settingsManager.selectedSatFOV.toString();
}
private onColorSelected_(context: ColorPick, colorStr: string) {
if (typeof context === 'undefined' || context === null) {
throw new Error('context is undefined');
}
if (typeof colorStr === 'undefined' || colorStr === null) {
throw new Error('colorStr is undefined');
}
context.element.style.cssText = `background-color: ${context.color} !important; color: ${context.color};`;
if (this.isNotColorPickerInitialSetup) {
settingsManager.colors[colorStr] = parseRgba(context.color);
LegendManager.legendColorsChange();
const colorSchemeManagerInstance = keepTrackApi.getColorSchemeManager();
colorSchemeManagerInstance.setColorScheme(colorSchemeManagerInstance.currentColorScheme, true);
PersistenceManager.getInstance().saveItem(StorageKey.SETTINGS_MANAGER_COLORS, JSON.stringify(settingsManager.colors));
}
}
private static onFormChange_(e: any, isDMChecked?: boolean, isSLMChecked?: boolean) {
if (typeof e === 'undefined' || e === null) {
throw new Error('e is undefined');
}
switch (e.target?.id) {
case 'settings-notionalSats':
case 'settings-leoSats':
case 'settings-starlinkSats':
case 'settings-heoSats':
case 'settings-meoSats':
case 'settings-geoSats':
case 'settings-showPayloads':
case 'settings-showRocketBodies':
case 'settings-showDebris':
case 'settings-showAgencies':
case 'settings-drawOrbits':
case 'settings-drawCameraWidget':
case 'settings-drawTrailingOrbits':
case 'settings-drawEcf':
case 'settings-isDrawInCoverageLines':
case 'settings-drawSun':
case 'settings-drawBlackEarth':
case 'settings-drawAtmosphere':
case 'settings-drawAurora':
case 'settings-drawMilkyWay':
case 'settings-graySkybox':
case 'settings-eciOnHover':
case 'settings-hos':
case 'settings-confidence-levels':
case 'settings-demo-mode':
case 'settings-sat-label-mode':
case 'settings-freeze-drag':
case 'settings-time-machine-toasts':
case 'settings-snp':
if ((<HTMLInputElement>getEl(e.target.id)).checked) {
// Play sound for enabling option
keepTrackApi.getSoundManager()?.play(SoundNames.TOGGLE_ON);
} else {
// Play sound for disabling option
keepTrackApi.getSoundManager()?.play(SoundNames.TOGGLE_OFF);
}
break;
default:
break;
}
isDMChecked ??= (<HTMLInputElement>getEl('settings-demo-mode')).checked;
isSLMChecked ??= (<HTMLInputElement>getEl('settings-sat-label-mode')).checked;
if (isSLMChecked && (<HTMLElement>e.target).id === 'settings-demo-mode') {
(<HTMLInputElement>getEl('settings-sat-label-mode')).checked = false;
getEl('settings-demo-mode').classList.remove('lever:after');
}
if (isDMChecked && (<HTMLElement>e.target).id === 'settings-sat-label-mode') {
(<HTMLInputElement>getEl('settings-demo-mode')).checked = false;
getEl('settings-sat-label-mode').classList.remove('lever:after');
}
}
static resetToDefaults() {
keepTrackApi.getSoundManager().play(SoundNames.BUTTON_CLICK);
settingsManager.isShowLeoSats = true;
settingsManager.isShowHeoSats = true;
settingsManager.isShowMeoSats = true;
settingsManager.isShowGeoSats = true;
settingsManager.isShowPayloads = true;
settingsManager.isShowRocketBodies = true;
settingsManager.isShowDebris = true;
settingsManager.isShowAgencies = false;
settingsManager.isDrawOrbits = true;
settingsManager.drawCameraWidget = false;
settingsManager.isDrawTrailingOrbits = false;
settingsManager.isOrbitCruncherInEcf = false;
settingsManager.isDrawInCoverageLines = true;
settingsManager.isDrawSun = true;
if (settingsManager.isBlackEarth) {
settingsManager.isBlackEarth = false;
keepTrackApi.getScene().earth.reloadEarthHiResTextures();
}
settingsManager.isDrawAtmosphere = true;
settingsManager.isDrawAurora = true;
settingsManager.isDrawMilkyWay = true;
settingsManager.isGraySkybox = false;
settingsManager.isEciOnHover = false;
settingsManager.isDemoModeOn = false;
settingsManager.isSatLabelModeOn = true;
settingsManager.isFreezePropRateOnDrag = false;
settingsManager.isDisableTimeMachineToasts = false;
settingsManager.searchLimit = 600;
SettingsManager.preserveSettings();
SettingsMenuPlugin.syncOnLoad();
}
private static onSubmit_(e: any) {
if (typeof e === 'undefined' || e === null) {
throw new Error('e is undefined');
}
e.preventDefault();
const uiManagerInstance = keepTrackApi.getUiManager();
const colorSchemeManagerInstance = keepTrackApi.getColorSchemeManager();
keepTrackApi.getSoundManager()?.play(SoundNames.BUTTON_CLICK);
settingsManager.isShowNotionalSats = (<HTMLInputElement>getEl('settings-notionalSats')).checked;
settingsManager.isShowLeoSats = (<HTMLInputElement>getEl('settings-leoSats')).checked;
settingsManager.isShowStarlinkSats = (<HTMLInputElement>getEl('settings-starlinkSats')).checked;
settingsManager.isShowHeoSats = (<HTMLInputElement>getEl('settings-heoSats')).checked;
settingsManager.isShowMeoSats = (<HTMLInputElement>getEl('settings-meoSats')).checked;
settingsManager.isShowGeoSats = (<HTMLInputElement>getEl('settings-geoSats')).checked;
settingsManager.isShowPayloads = (<HTMLInputElement>getEl('settings-showPayloads')).checked;
settingsManager.isShowRocketBodies = (<HTMLInputElement>getEl('settings-showRocketBodies')).checked;
settingsManager.isShowDebris = (<HTMLInputElement>getEl('settings-showDebris')).checked;
settingsManager.isShowAgencies = (<HTMLInputElement>getEl('settings-showAgencies')).checked;
settingsManager.isOrbitCruncherInEcf = (<HTMLInputElement>getEl('settings-drawEcf')).checked;
settingsManager.isDrawInCoverageLines = (<HTMLInputElement>getEl('settings-isDrawInCoverageLines')).checked;
settingsManager.isDrawSun = (<HTMLInputElement>getEl('settings-drawSun')).checked;
if (settingsManager.isDrawSun) {
keepTrackApi.getScene().drawTimeArray = Array(150).fill(16);
}
const isBlackEarthChanged = settingsManager.isBlackEarth !== (<HTMLInputElement>getEl('settings-drawBlackEarth')).checked;
const isDrawAtmosphereChanged = settingsManager.isDrawAtmosphere !== (<HTMLInputElement>getEl('settings-drawAtmosphere')).checked;
const isDrawAuroraChanged = settingsManager.isDrawAurora !== (<HTMLInputElement>getEl('settings-drawAurora')).checked;
settingsManager.drawCameraWidget = (<HTMLInputElement>getEl('settings-drawCameraWidget')).checked;
const ccWidgetCanvas = getEl('camera-control-widget');
if (ccWidgetCanvas) {
if (settingsManager.drawCameraWidget) {
ccWidgetCanvas.style.display = 'block';
} else {
ccWidgetCanvas.style.display = 'none';
}
}
settingsManager.isBlackEarth = (<HTMLInputElement>getEl('settings-drawBlackEarth')).checked;
settingsManager.isDrawAtmosphere = (<HTMLInputElement>getEl('settings-drawAtmosphere')).checked;
settingsManager.isDrawAurora = (<HTMLInputElement>getEl('settings-drawAurora')).checked;
if (isBlackEarthChanged || isDrawAtmosphereChanged || isDrawAuroraChanged) {
keepTrackApi.getScene().earth.reloadEarthHiResTextures();
}
const isDrawOrbitsChanged = settingsManager.isDrawOrbits !== (<HTMLInputElement>getEl('settings-drawOrbits')).checked;
settingsManager.isDrawOrbits = (<HTMLInputElement>getEl('settings-drawOrbits')).checked;
if (isDrawOrbitsChanged) {
keepTrackApi.getOrbitManager().drawOrbitsSettingChanged();
}
settingsManager.isDrawTrailingOrbits = (<HTMLInputElement>getEl('settings-drawTrailingOrbits')).checked;
if (keepTrackApi.getOrbitManager().orbitWorker) {
if (settingsManager.isDrawTrailingOrbits) {
keepTrackApi.getOrbitManager().orbitWorker.postMessage({
typ: OrbitCruncherType.CHANGE_ORBIT_TYPE,
orbitType: OrbitDrawTypes.TRAIL,
});
} else {
keepTrackApi.getOrbitManager().orbitWorker.postMessage({
typ: OrbitCruncherType.CHANGE_ORBIT_TYPE,
orbitType: OrbitDrawTypes.ORBIT,
});
}
}
// Must come after the above checks
const isDrawMilkyWayChanged = settingsManager.isDrawMilkyWay !== (<HTMLInputElement>getEl('settings-drawMilkyWay')).checked;
const isGraySkyboxChanged = settingsManager.isGraySkybox !== (<HTMLInputElement>getEl('settings-graySkybox')).checked;
settingsManager.isDrawMilkyWay = (<HTMLInputElement>getEl('settings-drawMilkyWay')).checked;
settingsManager.isGraySkybox = (<HTMLInputElement>getEl('settings-graySkybox')).checked;
if (isDrawMilkyWayChanged || isGraySkyboxChanged) {
keepTrackApi.getScene().skybox.init(settingsManager, keepTrackApi.getRenderer().gl);
}
settingsManager.isEciOnHover = (<HTMLInputElement>getEl('settings-eciOnHover')).checked;
const isHOSChecked = (<HTMLInputElement>getEl('settings-hos')).checked;
settingsManager.colors.transparent = isHOSChecked ? [1.0, 1.0, 1.0, 0] : [1.0, 1.0, 1.0, 0.1];
settingsManager.isShowConfidenceLevels = (<HTMLInputElement>getEl('settings-confidence-levels')).checked;
settingsManager.isDemoModeOn = (<HTMLInputElement>getEl('settings-demo-mode')).checked;
settingsManager.isSatLabelModeOn = (<HTMLInputElement>getEl('settings-sat-label-mode')).checked;
settingsManager.isShowNextPass = (<HTMLInputElement>getEl('settings-snp')).checked;
settingsManager.isFreezePropRateOnDrag = (<HTMLInputElement>getEl('settings-freeze-drag')).checked;
settingsManager.isDisableTimeMachineToasts = (<HTMLInputElement>getEl('settings-time-machine-toasts')).checked;
/*
* TODO: These settings buttons should be inside the plugins themselves
* Stop Time Machine
*/
if (keepTrackApi.getPlugin(TimeMachine)) {
keepTrackApi.getPlugin(TimeMachine).isMenuButtonActive = false;
}
/*
* if (orbitManagerInstance.isTimeMachineRunning) {
* settingsManager.colors.transparent = orbitManagerInstance.tempTransColor;
* }
*/
keepTrackApi.getGroupsManager().clearSelect();
colorSchemeManagerInstance.setColorScheme(colorSchemeManagerInstance.default, true); // force color recalc
keepTrackApi.getPlugin(TimeMachine)?.setBottomIconToUnselected();
colorSchemeManagerInstance.reloadColors();
const newFieldOfView = parseInt((<HTMLInputElement>getEl('satFieldOfView')).value);
if (isNaN(newFieldOfView)) {
(<HTMLInputElement>getEl('satFieldOfView')).value = '30';
uiManagerInstance.toast('Invalid field of view value!', ToastMsgType.critical);
}
const maxSearchSats = parseInt((<HTMLInputElement>getEl('maxSearchSats')).value);
if (isNaN(maxSearchSats)) {
(<HTMLInputElement>getEl('maxSearchSats')).value = settingsManager.searchLimit.toString();
uiManagerInstance.toast('Invalid max search sats value!', ToastMsgType.critical);
} else {
settingsManager.searchLimit = maxSearchSats;
uiManagerInstance.searchManager.doSearch(keepTrackApi.getUiManager().searchManager.getCurrentSearch());
}
colorSchemeManagerInstance.setColorScheme(colorSchemeManagerInstance.currentColorScheme, true);
SettingsManager.preserveSettings();
}
}