-
Notifications
You must be signed in to change notification settings - Fork 96
/
SCANcolorSelection.cs
1403 lines (1210 loc) · 46.3 KB
/
SCANcolorSelection.cs
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
#region license
/*
* [Scientific Committee on Advanced Navigation]
* S.C.A.N. Satellite
*
* SCANsat - Color Selection and Settings Menu
*
* Copyright (c)2013 damny;
* Copyright (c)2014 David Grandy <david.grandy@gmail.com>;
* Copyright (c)2014 technogeeky <technogeeky@gmail.com>;
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
*
*/
#endregion
using System;
using System.Collections.Generic;
using SCANsat.SCAN_Data;
using SCANsat.SCAN_Map;
using SCANsat.SCAN_UI.UI_Framework;
using SCANsat.SCAN_Platform;
using SCANsat.SCAN_Platform.Palettes;
using FinePrint.Utilities;
using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette;
using UnityEngine;
namespace SCANsat.SCAN_UI
{
class SCANcolorSelection: SCAN_MBW
{
private bool dropDown, paletteBox, resourceBox, planetBox, saveWarning;
private bool oldReverseState, oldDiscreteState;
private bool controlLock, clampState, oldClampState;
private Rect ddRect;
private int paletteIndex;
private SCANmapLegend currentLegend, previewLegend;
private int windowMode = 0;
private SCANterrainConfig currentTerrain;
private SCANterrainConfig bodyTerrain;
private float minT, maxT, clampT, pSize;
private SCANuiSlider minTerrainSlider, maxTerrainSlider, clampTerrainSlider, paletteSizeSlider, resourceMinSlider, resourceMaxSlider, resourceTransSlider, biomeTransSlider, slopeSlider;
private SCANuiColorPicker slopeColorPickerLow, slopeColorPickerHigh, biomeColorPicker, resourceColorPicker;
private float bTrans, rTrans, sCutoff;
private bool stockBiomes = false;
private bool biomeBorders = true;
private SCANresourceGlobal currentResource;
private float lowRCutoff, highRCutoff;
private List<SCANresourceGlobal> loadedResources;
private bool fineControlMode, oldFineControl;
private int bodyIndex;
private Vector2 scrollR;
private const string lockID = "colorLockID";
internal readonly static Rect defaultRect = new Rect(100, 400, 780, 360);
private static Rect sessionRect = defaultRect;
//SCAN_MBW objects to sync the color selection fields to the currently displayed map
//private SCANkscMap kscMapObj;
//private SCANBigMap bigMapObj;
//private static SCANmap bigMap;
private CelestialBody body;
private string colorTerrainHelpMin = "Defines the low altitude cutoff for the terrain color palette. Anything below this altitude will be shown with the lowest color.";
private string colorTerrainHelpMax = "Defines the high altitude cutoff for the terrain color palette. Anything above this altitude will be shown with the highest color.";
private string colorTerrainHelpClampToggle = "Used to define a cutoff between the low and high altitude values. This is particularly useful for ocean planets where it helps to define a sharp distinction between land and ocean.";
private string colorTerrainHelpClamp = "Defines the clamp altitude cutoff. Anything below the cutoff will be represented by the first two colors in the selected color palette. Anything above the cutoff will be represented with the remaining colors.";
private string colorTerrainHelpReverse = "Reverses the order of the currently\nselected color palette.";
private string colorTerrainHelpDiscrete = "Draws the map using only the specific colors defined by each palette, instead of smoothly interpolating between them.";
private string colorTerrainHelpPaletteSize = "Adjust the number of colors available in the currently selected color palette.";
private string colorBiomeHelpStock = "Use the stock biome color scheme for\nSCANsat biome maps.";
private string colorBiomeHelpWhiteBorder = "Draw a white border between biomes. Does not apply to the planetary overlay biome maps.";
private string colorBiomeHelpTransparency = "Adjust the transparency of biome maps. Terrain elevation is shown behind the biome maps. Set to 0% to disable terrain drawing.";
private string colorPickerHelpLow = "The top color swatch shows the updated color selection for the low end of this color spectrum. The bottom color swatch shows the currently active color.";
private string colorPickerHelpHigh = "The top color swatch shows the updated color selection for the high end of this color spectrum. The bottom color swatch shows the currently active color.";
private string colorPickerHelpValue = "This slider adjusts the Value (in HSV color terms) or Brightness for the currently selected color.";
private string colorResourceHelpFineControl = "Activates Fine Control Mode where the sliders will only show values within 5% of the current selection.";
private string colorResourceHelpMin = "The low cutoff for resource concentration on the selected celestial body. Resource deposits at this level will be displayed using the low end of the current resource overlay color spectrum. Resource deposits below this value will not be shown.";
private string colorResourceHelpMax = "The high cutoff for resource concentration on the selected celestial body. Resource deposits above this value will be shown using the high end of the current resource overlay color spectrum.";
private string colorResourceHelpTransparency = "Defines the level of transparency for resource overlays. Increase to allow more of the underlying terrain, slope, or biome map to be visible. This also affect the transparency of resource deposits on the planetary overlay resource map.";
private string colorResourceHelpApply = "Applies the current values for the selected resource and celestial body only.";
private string colorResourceHelpApplyAll = "Applies the current values for the selected resource for all celestial bodies.";
private string colorResourceHelpDefault = "Reverts to the default values for the selected resource and celestial body only.";
private string colorResourceHelpDefaultAll = "Reverts to the default values for the selected resource for all celestial bodies.";
private string colorHelpSaveToConfig = "Save all color configuration values to the config file found in your SCANsat/Resources folder. These values serve as the defaults for new saves and for all Revert To Default buttons. Values do not need to be saved to the config file to be applied for this save file.";
private string colorSlopeHelpCutoff = "Adjust the cutoff level between the two selected slope color pairs.";
protected override void Awake()
{
base.Awake();
WindowCaption = "S.C.A.N. Color Management";
WindowRect = sessionRect;
WindowStyle = SCANskins.SCAN_window;
WindowOptions = new GUILayoutOption[2] { GUILayout.Width(780), GUILayout.Height(360) };
Visible = false;
DragEnabled = true;
TooltipMouseOffset = new Vector2d(-10, -25);
TooltipMaxWidth = 350;
TooltipDisplayForSecs = 60;
ClampToScreenOffset = new RectOffset(-450, -450, -250, -250);
SCAN_SkinsLibrary.SetCurrent("SCAN_Unity");
removeControlLocks();
}
protected override void Start()
{
TooltipsEnabled = false;
if (SCANconfigLoader.languagePack != null)
loadStrings();
if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
{
//kscMapObj = (SCANkscMap)SCANcontroller.controller.kscMap;
//if (SCANkscMap.BigMap != null)
// bigMap = SCANkscMap.BigMap;
//if (kscMapObj.Data != null)
// body = kscMapObj.Body;
if (body == null)
body = Planetarium.fetch.Home;
}
else if (HighLogic.LoadedSceneIsFlight)
{
//bigMapObj = (SCANBigMap)SCANcontroller.controller.BigMap;
//if (SCANBigMap.BigMap != null)
// bigMap = SCANBigMap.BigMap;
//if (bigMapObj.Data != null)
// body = bigMapObj.Data.Body;
if (body == null)
body = FlightGlobals.currentMainBody;
}
setBodyTerrain();
currentTerrain = new SCANterrainConfig(bodyTerrain);
stockBiomes = SCAN_Settings_Config.Instance.StockBiomes;
biomeBorders = SCAN_Settings_Config.Instance.BiomeBorder;
minTerrainSlider = new SCANuiSlider(currentTerrain.DefaultMinHeight - SCANconfigLoader.SCANNode.RangeBelowMinHeight, currentTerrain.MaxTerrain - 100, currentTerrain.MinTerrain, "Min: ", "m", colorTerrainHelpMin, -2);
maxTerrainSlider = new SCANuiSlider(currentTerrain.MinTerrain + 100, currentTerrain.DefaultMaxHeight + SCANconfigLoader.SCANNode.RangeAboveMaxHeight, currentTerrain.MaxTerrain, "Max: ", "m", colorTerrainHelpMax, -2);
clampTerrainSlider = new SCANuiSlider(currentTerrain.MinTerrain + 10, currentTerrain.MaxTerrain - 10, currentTerrain.ClampTerrain ?? currentTerrain.MinTerrain + 10, "Clamp: ", "m", colorTerrainHelpClamp, -1);
paletteSizeSlider = new SCANuiSlider(3, 12, currentTerrain.PalSize, "Palette Size: ", "", colorTerrainHelpPaletteSize, 0);
sCutoff = SCAN_Settings_Config.Instance.SlopeCutoff;
slopeSlider = new SCANuiSlider(0.2f, 1.8f, sCutoff, "Slope Cutoff: ", "", colorSlopeHelpCutoff, 2, 180, 10);
slopeColorPickerLow = new SCANuiColorPicker(SCAN_Settings_Config.Instance.BottomLowSlopeColor, SCAN_Settings_Config.Instance.BottomHighSlopeColor, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, true);
slopeColorPickerHigh = new SCANuiColorPicker(SCAN_Settings_Config.Instance.TopLowSlopeColor, SCAN_Settings_Config.Instance.TopHighSlopeColor, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, true);
slopeColorPickerLow.updateOldSwatches();
slopeColorPickerHigh.updateOldSwatches();
bTrans = SCAN_Settings_Config.Instance.BiomeTransparency * 100;
biomeTransSlider = new SCANuiSlider(0, 80, bTrans, "Ter. Trans: ", "%", colorBiomeHelpTransparency, 0);
biomeColorPicker = new SCANuiColorPicker(SCAN_Settings_Config.Instance.LowBiomeColor, SCAN_Settings_Config.Instance.HighBiomeColor, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, true);
biomeColorPicker.updateOldSwatches();
if (SCANconfigLoader.GlobalResource)
{
loadedResources = SCANcontroller.setLoadedResourceList();
currentResource = new SCANresourceGlobal(loadedResources[0]);
currentResource.CurrentBodyConfig(body.name);
if (currentResource != null)
{
resourceMinSlider = new SCANuiSlider(0, currentResource.CurrentBody.MinValue - 0.1f, currentResource.CurrentBody.MinValue, "Min: ", "%", colorResourceHelpMin, 1);
resourceMaxSlider = new SCANuiSlider(currentResource.CurrentBody.MinValue + 0.1f, 100, currentResource.CurrentBody.MaxValue, "Max: ", "%", colorResourceHelpMax, 1);
resourceTransSlider = new SCANuiSlider(0, 80, currentResource.Transparency, "Trans: ", "%", colorResourceHelpTransparency, 0);
resourceColorPicker = new SCANuiColorPicker(currentResource.MinColor, currentResource.MaxColor, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, true);
}
}
bodyIndex = body.flightGlobalsIndex;
if (windowMode > 3 || (windowMode > 2 && !SCANconfigLoader.GlobalResource))
windowMode = 0;
setSizeSlider(currentTerrain.ColorPal.kind);
}
private void loadStrings()
{
colorTerrainHelpMin = SCANconfigLoader.languagePack.colorTerrainHelpMin;
colorTerrainHelpMax = SCANconfigLoader.languagePack.colorTerrainHelpMax;
colorTerrainHelpClampToggle = SCANconfigLoader.languagePack.colorTerrainHelpClampToggle;
colorTerrainHelpClamp = SCANconfigLoader.languagePack.colorTerrainHelpClamp;
colorTerrainHelpReverse = SCANconfigLoader.languagePack.colorTerrainHelpReverse;
colorTerrainHelpDiscrete = SCANconfigLoader.languagePack.colorTerrainHelpDiscrete;
colorTerrainHelpPaletteSize = SCANconfigLoader.languagePack.colorTerrainHelpPaletteSize;
colorBiomeHelpStock = SCANconfigLoader.languagePack.colorBiomeHelpStock;
colorBiomeHelpWhiteBorder = SCANconfigLoader.languagePack.colorBiomeHelpWhiteBorder;
colorBiomeHelpTransparency = SCANconfigLoader.languagePack.colorBiomeHelpTransparency;
colorPickerHelpLow = SCANconfigLoader.languagePack.colorPickerHelpLow;
colorPickerHelpHigh = SCANconfigLoader.languagePack.colorPickerHelpHigh;
colorPickerHelpValue = SCANconfigLoader.languagePack.colorPickerHelpValue;
colorResourceHelpFineControl = SCANconfigLoader.languagePack.colorResourceHelpFineControl;
colorResourceHelpMin = SCANconfigLoader.languagePack.colorResourceHelpMin;
colorResourceHelpMax = SCANconfigLoader.languagePack.colorResourceHelpMax;
colorResourceHelpTransparency = SCANconfigLoader.languagePack.colorResourceHelpTransparency;
colorResourceHelpApply = SCANconfigLoader.languagePack.colorResourceHelpApply;
colorResourceHelpApplyAll = SCANconfigLoader.languagePack.colorResourceHelpApplyAll;
colorResourceHelpDefault = SCANconfigLoader.languagePack.colorResourceHelpDefault;
colorResourceHelpDefaultAll = SCANconfigLoader.languagePack.colorResourceHelpDefaultAll;
colorHelpSaveToConfig = SCANconfigLoader.languagePack.colorHelpSaveToConfig;
colorSlopeHelpCutoff = SCANconfigLoader.languagePack.colorSlopeHelpCutoff;
}
protected override void OnDestroy()
{
removeControlLocks();
TooltipsEnabled = false;
}
internal void removeControlLocks()
{
InputLockManager.RemoveControlLock(lockID);
controlLock = false;
}
protected override void DrawWindowPre(int id)
{
//Some clumsy logic is used here to ensure that the color selection fields always remain in sync with the current map in each scene
switch (HighLogic.LoadedScene)
{
case GameScenes.FLIGHT:
//if (SCANBigMap.BigMap != null)
//{
// bigMap = SCANBigMap.BigMap;
//}
if (body == null)
{
body = FlightGlobals.currentMainBody;
}
break;
case GameScenes.SPACECENTER:
//if (kscMapObj.Visible)
//{
// bigMap = SCANkscMap.BigMap;
//}
if (body == null)
{
body = Planetarium.fetch.Home;
}
Vector2 mousePos = Input.mousePosition;
mousePos.y = Screen.height - mousePos.y;
if (WindowRect.Contains(mousePos) && !controlLock)
{
InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
controlLock = true;
}
else if (!WindowRect.Contains(mousePos) && controlLock)
{
removeControlLocks();
}
break;
case GameScenes.TRACKSTATION:
//if (kscMapObj.Visible)
//{
// bigMap = SCANkscMap.BigMap;
//}
if (body == null)
{
body = Planetarium.fetch.Home;
}
Vector2 mousePosT = Input.mousePosition;
mousePosT.y = Screen.height - mousePosT.y;
if (WindowRect.Contains(mousePosT) && !controlLock)
{
InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
controlLock = true;
}
else if (!WindowRect.Contains(mousePosT) && controlLock)
{
removeControlLocks();
}
break;
}
//This updates all of the fields whenever the palette selection is changed
if (windowMode == 0 && (currentLegend == null || bodyIndex != body.flightGlobalsIndex))
{
setBodyTerrain();
currentTerrain = new SCANterrainConfig(bodyTerrain);
bodyIndex = body.flightGlobalsIndex;
updateUI();
}
if (windowMode == 0 && previewLegend == null)
{
drawPreviewLegend();
}
if (!dropDown)
{
paletteBox = false;
resourceBox = false;
planetBox = false;
saveWarning = false;
}
}
protected override void DrawWindow(int id)
{
versionLabel(id); /* The standard version number and close button */
closeBox(id);
growS();
windowTabs(id); /* Draws the window selection tabs across the top */
if (windowMode == 0)
{
growE();
paletteTextures(id); /* Draws the palette selection button and preview swatches */
paletteOptions(id); /* All of the terrain and palette options */
stopE();
fillS(8);
growE();
palettePreview(id); /* Draws the two preview palette legends */
paletteConfirmation(id); /* The buttons for default, apply, and cancel */
stopE();
}
else if (windowMode == 1)
{
growE();
fillS(10);
slopeColorPickerLow.drawColorSelector(WindowRect);
fillS(40);
slopeColorPickerHigh.drawColorSelector(WindowRect);
stopE();
fillS(100);
growE();
slopeOptions(id);
slopeConfirm(id);
stopE();
}
else if (windowMode == 2)
{
growE();
fillS(10);
biomeColorPicker.drawColorSelector(WindowRect);
fillS(80);
growS();
biomeOptions(id);
biomeConfirm(id);
stopS();
stopE();
}
else if (windowMode == 3 && SCANconfigLoader.GlobalResource)
{
growE();
fillS(10);
resourceColorPicker.drawColorSelector(WindowRect);
fillS(120);
growS();
resourceOptions(id);
resourceConfirm(id);
stopS();
stopE();
}
else
windowMode = 0;
stopS();
dropDownBox(id); /* Draw the drop down menu for the palette selection box */
}
protected override void DrawWindowPost(int id)
{
if (dropDown && Event.current.type == EventType.mouseDown && !ddRect.Contains(Event.current.mousePosition))
{
dropDown = false;
}
//These methods update all of the UI elements whenever any of the options are changed
switch (windowMode)
{
case 0:
if (currentTerrain.PalRev != oldReverseState)
{
oldReverseState = currentTerrain.PalRev;
drawPreviewLegend();
}
if (minTerrainSlider.valueChanged() || maxTerrainSlider.valueChanged())
{
setTerrainSliders();
}
if (currentTerrain.PalDis != oldDiscreteState)
{
oldDiscreteState = currentTerrain.PalDis;
drawPreviewLegend();
}
if (clampState != oldClampState)
{
oldClampState = clampState;
drawPreviewLegend();
}
if (paletteSizeSlider.valueChanged())
{
regenPaletteSets();
currentTerrain.ColorPal = palette.CurrentPalettes.availablePalettes[paletteIndex];
drawPreviewLegend();
}
break;
case 1:
slopeColorPickerLow.colorStateChanged();
slopeColorPickerLow.brightnessChanged();
slopeColorPickerHigh.colorStateChanged();
slopeColorPickerHigh.brightnessChanged();
break;
case 2:
biomeColorPicker.colorStateChanged();
biomeColorPicker.brightnessChanged();
break;
case 3:
if (resourceMinSlider.valueChanged() || resourceMaxSlider.valueChanged())
{
setResourceSliders();
}
if (bodyIndex != body.flightGlobalsIndex)
{
SCANUtil.SCANdebugLog("Trigger Body Change");
bodyIndex = body.flightGlobalsIndex;
currentResource.CurrentBodyConfig(body.name);
lowRCutoff = currentResource.CurrentBody.MinValue;
highRCutoff = currentResource.CurrentBody.MaxValue;
oldFineControl = fineControlMode = false;
setResourceSliders();
}
if (oldFineControl != fineControlMode)
{
oldFineControl = fineControlMode;
if (fineControlMode)
{
if (lowRCutoff < 5f)
resourceMinSlider.MinValue = 0f;
else
resourceMinSlider.MinValue = lowRCutoff - 5;
if (lowRCutoff > 95f)
resourceMinSlider.MaxValue = 100f;
else if (highRCutoff < lowRCutoff + 5f)
resourceMinSlider.MaxValue = highRCutoff - 0.1f;
else
resourceMinSlider.MaxValue = lowRCutoff + 5f;
if (highRCutoff < 5f)
resourceMaxSlider.MinValue = 0f;
else if (lowRCutoff > highRCutoff - 5f)
resourceMaxSlider.MinValue = lowRCutoff + 0.1f;
else
resourceMaxSlider.MinValue = highRCutoff - 5f;
if (highRCutoff > 95f)
resourceMaxSlider.MaxValue = 100f;
else
resourceMaxSlider.MaxValue = highRCutoff + 5f;
}
else
setResourceSliders();
}
resourceColorPicker.colorStateChanged();
resourceColorPicker.brightnessChanged();
break;
default:
break;
}
sessionRect = WindowRect;
}
//Draw the version label in the upper left corner
private void versionLabel(int id)
{
Rect r = new Rect(6, 0, 50, 18);
GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel);
}
//Draw the close button in the upper right corner
private void closeBox(int id)
{
Rect r = new Rect(WindowRect.width - 42, 1, 18, 18);
if (GUI.Button(r, textWithTT("?", "Show Help Tips"), SCANskins.SCAN_closeButton))
{
TooltipsEnabled = !TooltipsEnabled;
}
r.x += 22;
if (GUI.Button(r, "X", SCANskins.SCAN_closeButton))
{
removeControlLocks();
Visible = false;
TooltipsEnabled = false;
}
}
//Draw the window tab options
private void windowTabs(int id)
{
growE();
if (GUILayout.Button("Altimetry"))
{
windowMode = 0;
setBodyTerrain();
currentTerrain = new SCANterrainConfig(bodyTerrain);
bodyIndex = body.flightGlobalsIndex;
updateUI();
}
if (GUILayout.Button("Slope"))
{
windowMode = 1;
}
if (GUILayout.Button("Biome"))
{
windowMode = 2;
}
if (SCANconfigLoader.GlobalResource)
{
if (GUILayout.Button("Resources"))
{
windowMode = 3;
fineControlMode = oldFineControl = false;
currentResource.CurrentBodyConfig(body.name);
bodyIndex = body.flightGlobalsIndex;
updateUI();
}
}
stopE();
}
//Draw the palette selection field
private void paletteTextures(int id)
{
growS();
GUILayout.Label("Palette Selection", SCANskins.SCAN_headline);
fillS(12);
growE();
if (GUILayout.Button("Palette Style:", GUILayout.MaxWidth(120)))
{
dropDown = !dropDown;
paletteBox = !paletteBox;
}
fillS(10);
GUILayout.Label(palette.getPaletteTypeName, SCANskins.SCAN_whiteReadoutLabel);
stopE();
growE();
// This integer stores the amount of palettes of each type
int j = 9;
if (palette.CurrentPalettes.paletteType == Palette.Kind.Sequential)
j = 12;
else if (palette.CurrentPalettes.paletteType == Palette.Kind.Qualitative)
j = 8;
else if (palette.CurrentPalettes.paletteType == Palette.Kind.Fixed)
j = 11;
else if (palette.CurrentPalettes.paletteType == Palette.Kind.Invertable || palette.CurrentPalettes.paletteType == Palette.Kind.Unknown)
j = 0;
for (int i = 0; i < j; i++)
{
if (i % 3 == 0)
{
stopE();
fillS(9);
growE();
}
Texture2D t = palette.CurrentPalettes.paletteSwatch[i];
if (paletteBox)
{
GUILayout.Label("", GUILayout.Width(110), GUILayout.Height(25));
}
else
{
if (GUILayout.Button("", SCANskins.SCAN_texButton, GUILayout.Width(110), GUILayout.Height(25)))
{
currentTerrain.ColorPal = palette.CurrentPalettes.availablePalettes[i];
paletteIndex = currentTerrain.ColorPal.index;
updateUI();
drawPreviewLegend();
}
}
Rect r = GUILayoutUtility.GetLastRect();
r.width -= 10;
GUI.DrawTexture(r, t);
}
stopE();
stopS();
}
//Main palette option settings
private void paletteOptions(int id)
{
growS();
fillS(4);
growE();
fillS(20);
GUILayout.Label("Terrain Options: ", SCANskins.SCAN_headlineSmall, GUILayout.Width(150));
if (GUILayout.Button(body.name, SCANskins.SCAN_headerButton, GUILayout.Width(170)))
{
dropDown = !dropDown;
planetBox = !planetBox;
}
stopE();
growE();
fillS(10);
currentTerrain.MinTerrain = minTerrainSlider.drawSlider(dropDown, ref minT);
stopE();
fillS(8);
growE();
fillS(10);
currentTerrain.MaxTerrain = maxTerrainSlider.drawSlider(dropDown, ref maxT);
stopE();
fillS(6);
growE();
fillS();
if (dropDown)
GUILayout.Label("Clamp Terrain", SCANskins.SCAN_settingsToggle, GUILayout.Width(100));
else
clampState = GUILayout.Toggle(clampState, textWithTT("Clamp Terrain", colorTerrainHelpClampToggle), SCANskins.SCAN_settingsToggle, GUILayout.Width(100));
fillS();
stopE();
if (clampState)
{
growE();
fillS(10);
currentTerrain.ClampTerrain = clampTerrainSlider.drawSlider(dropDown, ref clampT);
stopE();
}
fillS(6);
GUILayout.Label("Palette Options", SCANskins.SCAN_headlineSmall);
if (palette.CurrentPalettes.paletteType != Palette.Kind.Fixed)
{
growE();
fillS(10);
currentTerrain.PalSize = (int)paletteSizeSlider.drawSlider(dropDown, ref pSize);
stopE();
}
growE();
if (dropDown)
{
GUILayout.Label(" Reverse Order", SCANskins.SCAN_boldToggle, GUILayout.Width(120));
fillS(10);
GUILayout.Label(" Discrete Gradient", SCANskins.SCAN_boldToggle, GUILayout.Width(140));
}
else
{
currentTerrain.PalRev = GUILayout.Toggle(currentTerrain.PalRev, textWithTT(" Reverse Order", colorTerrainHelpReverse), SCANskins.SCAN_boldToggle, GUILayout.Width(120));
fillS(10);
currentTerrain.PalDis = GUILayout.Toggle(currentTerrain.PalDis, textWithTT(" Discrete Gradient", colorTerrainHelpDiscrete), SCANskins.SCAN_boldToggle, GUILayout.Width(140));
}
stopE();
stopS();
}
//Two boxes to show the current and new palettes as they appear on the legend
private void palettePreview(int id)
{
growS();
GUILayout.Label("Current Palette", SCANskins.SCAN_headlineSmall);
GUILayout.Label("", SCANskins.SCAN_legendTex, GUILayout.Width(180), GUILayout.Height(25));
Rect r = GUILayoutUtility.GetLastRect();
GUI.DrawTexture(r, currentLegend.Legend);
stopS();
fillS(8);
growS();
GUILayout.Label("New Palette", SCANskins.SCAN_headlineSmall);
GUILayout.Label("", SCANskins.SCAN_legendTex, GUILayout.Width(180), GUILayout.Height(25));
r = GUILayoutUtility.GetLastRect();
GUI.DrawTexture(r, previewLegend.Legend);
stopS();
}
//Buttons to apply the new palette or cancel and return to the original
private void paletteConfirmation(int id)
{
growS();
fillS(6);
growE();
if (!dropDown)
{
if (GUILayout.Button("Apply Values", GUILayout.Width(110)))
{
if (!clampState)
currentTerrain.ClampTerrain = null;
SCANcontroller.updateTerrainConfig(currentTerrain);
updateUI();
//if (bigMap != null && bigMap.Body == body)
//{
// if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
fillS(6);
if (GUILayout.Button("Default Values", GUILayout.Width(110)))
{
setBodyTerrain();
currentTerrain.MinTerrain = bodyTerrain.DefaultMinHeight;
currentTerrain.MaxTerrain = bodyTerrain.DefaultMaxHeight;
currentTerrain.ClampTerrain = bodyTerrain.DefaultClampHeight;
currentTerrain.ColorPal = bodyTerrain.DefaultPalette;
currentTerrain.PalRev = bodyTerrain.DefaultReverse;
currentTerrain.PalDis = bodyTerrain.DefaultDiscrete;
currentTerrain.PalSize = bodyTerrain.DefaultPaletteSize;
SCANcontroller.updateTerrainConfig(currentTerrain);
updateUI();
//if (bigMap != null && bigMap.Body == body)
//{
// if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
}
else
{
GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110));
fillS(6);
GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110));
}
stopE();
fillS(8);
if (!dropDown)
{
if (GUILayout.Button(textWithTT("Save Values To Config", colorHelpSaveToConfig), GUILayout.Width(180)))
{
dropDown = true;
saveWarning = true;
}
}
else
GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180));
stopS();
}
private void biomeOptions(int id)
{
GUILayout.Label("Biome Options", SCANskins.SCAN_headline, GUILayout.Width(300));
fillS(20);
stockBiomes = GUILayout.Toggle(stockBiomes, textWithTT("Use Stock Biome Maps", colorBiomeHelpStock), SCANskins.SCAN_toggle, GUILayout.Width(200));
fillS(8);
biomeBorders = GUILayout.Toggle(biomeBorders, textWithTT("White Biome Borders", colorBiomeHelpWhiteBorder), SCANskins.SCAN_toggle, GUILayout.Width(190));
fillS(8);
growE();
fillS(10);
biomeTransSlider.drawSlider(false, ref bTrans);
stopE();
}
private void slopeOptions(int id)
{
slopeSlider.drawSlider(false, ref sCutoff);
}
private void resourceOptions(int id)
{
growE();
fillS(30);
GUILayout.Label("Resource Options: ", SCANskins.SCAN_headlineSmall, GUILayout.Width(150));
if (GUILayout.Button(body.name, SCANskins.SCAN_headerButton, GUILayout.Width(170)))
{
dropDown = !dropDown;
planetBox = !planetBox;
}
stopE();
fillS(10);
growE();
fillS(20);
GUILayout.Label("Resource Selection: ", SCANskins.SCAN_headlineSmall, GUILayout.Width(180));
if (dropDown)
{
GUILayout.Label(currentResource.Name, SCANskins.SCAN_headerButton, GUILayout.Width(140));
}
else
{
if (GUILayout.Button(currentResource.Name, SCANskins.SCAN_headerButton, GUILayout.Width(140)))
{
dropDown = !dropDown;
resourceBox = !resourceBox;
}
}
stopE();
fillS(10);
growE();
fillS(110);
if (dropDown)
GUILayout.Label(" Fine Control Mode", SCANskins.SCAN_boldToggle, GUILayout.Width(140));
else
fineControlMode = GUILayout.Toggle(fineControlMode, textWithTT(" Fine Control Mode", colorResourceHelpFineControl), SCANskins.SCAN_boldToggle, GUILayout.Width(140));
stopE();
growE();
fillS(10);
currentResource.CurrentBody.MinValue = resourceMinSlider.drawSlider(dropDown, ref lowRCutoff);
stopE();
fillS(8);
growE();
fillS(10);
currentResource.CurrentBody.MaxValue = resourceMaxSlider.drawSlider(dropDown, ref highRCutoff);
stopE();
fillS(8);
growE();
fillS(10);
currentResource.Transparency = resourceTransSlider.drawSlider(dropDown, ref rTrans);
stopE();
}
private void biomeConfirm(int id)
{
fillS(10);
growE();
if (!dropDown)
{
if (GUILayout.Button("Apply Values", GUILayout.Width(110)))
{
SCAN_Settings_Config.Instance.LowBiomeColor = biomeColorPicker.ColorLow;
SCANcontroller.controller.lowBiomeColor32 = biomeColorPicker.ColorLow;
SCAN_Settings_Config.Instance.HighBiomeColor = biomeColorPicker.ColorHigh;
SCANcontroller.controller.highBiomeColor32 = biomeColorPicker.ColorHigh;
SCAN_Settings_Config.Instance.StockBiomes = stockBiomes;
SCAN_Settings_Config.Instance.BiomeBorder = biomeBorders;
SCAN_Settings_Config.Instance.BiomeTransparency = bTrans / 100;
biomeColorPicker.updateOldSwatches();
//if (bigMap != null)
//{
// if (bigMap.MType == mapType.Biome)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
fillS(8);
if (GUILayout.Button("Default Values", GUILayout.Width(110)))
{
SCAN_Settings_Config.Instance.LowBiomeColor = palette.xkcd_CamoGreen;
SCANcontroller.controller.lowBiomeColor32 = palette.xkcd_CamoGreen;
SCAN_Settings_Config.Instance.HighBiomeColor = palette.xkcd_Marigold;
SCANcontroller.controller.highBiomeColor32 = palette.xkcd_Marigold;
SCAN_Settings_Config.Instance.StockBiomes = false;
SCAN_Settings_Config.Instance.BiomeBorder = true;
SCAN_Settings_Config.Instance.BiomeTransparency = 0.4f;
stockBiomes = false;
biomeBorders = true;
biomeColorPicker = new SCANuiColorPicker(palette.xkcd_CamoGreen, palette.xkcd_Marigold, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, biomeColorPicker.LowColorChange);
biomeColorPicker.updateOldSwatches();
bTrans = 40f;
//if (bigMap != null)
//{
// if (bigMap.MType == mapType.Biome)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
}
else
{
GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110));
fillS(8);
GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110));
}
stopE();
fillS(8);
if (!dropDown)
{
if (GUILayout.Button(textWithTT("Save Values To Config", colorHelpSaveToConfig), GUILayout.Width(180)))
{
dropDown = true;
saveWarning = true;
}
}
else
GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180));
}
private void slopeConfirm(int id)
{
if (!dropDown)
{
fillS(20);
if (GUILayout.Button("Apply Values", GUILayout.Width(110)))
{
SCAN_Settings_Config.Instance.BottomLowSlopeColor = slopeColorPickerLow.ColorLow;
SCAN_Settings_Config.Instance.BottomHighSlopeColor = slopeColorPickerLow.ColorHigh;
SCAN_Settings_Config.Instance.TopLowSlopeColor = slopeColorPickerHigh.ColorLow;
SCAN_Settings_Config.Instance.TopHighSlopeColor = slopeColorPickerHigh.ColorHigh;
SCANcontroller.controller.lowSlopeColorOne32 = slopeColorPickerLow.ColorLow;
SCANcontroller.controller.highSlopeColorOne32 = slopeColorPickerLow.ColorHigh;
SCANcontroller.controller.lowSlopeColorTwo32 = slopeColorPickerHigh.ColorLow;
SCANcontroller.controller.highSlopeColorTwo32 = slopeColorPickerHigh.ColorHigh;
SCAN_Settings_Config.Instance.SlopeCutoff = sCutoff;
slopeColorPickerLow.updateOldSwatches();
slopeColorPickerHigh.updateOldSwatches();
//if (bigMap != null)
//{
// if (bigMap.MType == mapType.Slope)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
fillS(8);
if (GUILayout.Button("Default Values", GUILayout.Width(110)))
{
SCAN_Settings_Config.Instance.BottomLowSlopeColor = palette.xkcd_PukeGreen;
SCAN_Settings_Config.Instance.BottomHighSlopeColor = palette.xkcd_Lemon;
SCAN_Settings_Config.Instance.TopLowSlopeColor = palette.xkcd_Lemon;
SCAN_Settings_Config.Instance.TopHighSlopeColor = palette.xkcd_OrangeRed;
SCANcontroller.controller.lowSlopeColorOne32 = palette.xkcd_PukeGreen;
SCANcontroller.controller.highSlopeColorOne32 = palette.xkcd_Lemon;
SCANcontroller.controller.lowSlopeColorTwo32 = palette.xkcd_Lemon;
SCANcontroller.controller.highSlopeColorTwo32 = palette.xkcd_OrangeRed;
SCAN_Settings_Config.Instance.SlopeCutoff = 1;
slopeColorPickerLow = new SCANuiColorPicker(palette.xkcd_PukeGreen, palette.xkcd_Lemon, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, slopeColorPickerLow.LowColorChange);
slopeColorPickerHigh = new SCANuiColorPicker(palette.xkcd_Lemon, palette.xkcd_OrangeRed, colorPickerHelpLow, colorPickerHelpHigh, colorPickerHelpValue, slopeColorPickerHigh.LowColorChange);
sCutoff = 1;
slopeColorPickerLow.updateOldSwatches();
slopeColorPickerHigh.updateOldSwatches();
//if (bigMap != null)
//{
// if (bigMap.MType == mapType.Slope)
// bigMap.resetMap(SCANcontroller.controller.map_ResourceOverlay);
//}
}
fillS(20);
if (GUILayout.Button(textWithTT("Save Values To Config", colorHelpSaveToConfig), GUILayout.Width(180)))