-
Notifications
You must be signed in to change notification settings - Fork 97
/
SCAN_BigMap.cs
1305 lines (975 loc) · 27.6 KB
/
SCAN_BigMap.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
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SCANsat.Unity.Interfaces;
namespace SCANsat.Unity.Unity
{
public class SCAN_BigMap : CanvasFader, IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerDownHandler
{
[SerializeField]
private TextHandler m_Version = null;
[SerializeField]
private TextHandler m_Title = null;
[SerializeField]
private Transform m_Projection = null;
[SerializeField]
private Transform m_MapType = null;
[SerializeField]
private Transform m_Resources = null;
[SerializeField]
private Transform m_CelestialBody = null;
[SerializeField]
private ToggleGroup m_DropDownToggles = null;
[SerializeField]
private GameObject m_DropDownPrefab = null;
[SerializeField]
private GameObject m_OrbitObject = null;
[SerializeField]
private GameObject m_WaypointObject = null;
[SerializeField]
private SCAN_Toggle m_ColorToggle = null;
[SerializeField]
private SCAN_Toggle m_GridToggle = null;
[SerializeField]
private SCAN_Toggle m_OrbitToggle = null;
[SerializeField]
private SCAN_Toggle m_WaypointToggle = null;
[SerializeField]
private SCAN_Toggle m_AnomalyToggle = null;
[SerializeField]
private SCAN_Toggle m_FlagToggle = null;
[SerializeField]
private SCAN_Toggle m_AsteroidToggle = null;
[SerializeField]
private SCAN_Toggle m_LegendToggle = null;
[SerializeField]
private SCAN_Toggle m_ResourcesToggle = null;
[SerializeField]
private TextHandler m_ReadoutText = null;
[SerializeField]
private RawImage m_MapImage = null;
[SerializeField]
private RawImage m_GridMap = null;
[SerializeField]
private RawImage m_EQMap = null;
[SerializeField]
private LayoutElement m_MapLayout = null;
[SerializeField]
private GameObject m_MapLabelPrefab = null;
[SerializeField]
private GameObject m_LegendObject = null;
[SerializeField]
private RawImage m_LegendImage = null;
[SerializeField]
private TextHandler m_LegendLabelOne = null;
[SerializeField]
private TextHandler m_LegendLabelTwo = null;
[SerializeField]
private TextHandler m_LegendLabelThree = null;
[SerializeField]
private GameObject m_WaypointBar = null;
[SerializeField]
private InputField m_WaypointInput = null;
[SerializeField]
private GameObject m_SmallMapButton = null;
[SerializeField]
private GameObject m_ZoomMapButton = null;
[SerializeField]
private GameObject m_OverlayButton = null;
[SerializeField]
private GameObject m_InstrumentsButton = null;
[SerializeField]
private GameObject m_SettingsButton = null;
[SerializeField]
private GameObject m_NorthSouthMarkers = null;
private ISCAN_BigMap bigInterface;
private bool loaded;
private RectTransform rect;
private Vector2 mouseStart;
private Vector3 windowStart;
private bool inMap;
private Vector2 rectPos = new Vector2();
private bool waypointSelecting;
private string waypoint;
private List<SCAN_SimpleLabel> orbitLabels = new List<SCAN_SimpleLabel>();
private List<SCAN_MapLabel> orbitIconLabels = new List<SCAN_MapLabel>();
private List<SCAN_MapLabel> anomalyLabels = new List<SCAN_MapLabel>();
private List<SCAN_MapLabel> waypointLabels = new List<SCAN_MapLabel>();
private List<SCAN_MapLabel> flagLabels = new List<SCAN_MapLabel>();
private SCAN_MapLabel vesselLabel;
private SCAN_MapLabel tempWaypointLabel;
private SCAN_DropDown dropDown;
protected override void Awake()
{
base.Awake();
rect = GetComponent<RectTransform>();
Alpha(0);
}
private void Update()
{
if (bigInterface == null || !bigInterface.IsVisible)
return;
if (bigInterface.LockInput)
{
if (m_WaypointInput != null && !m_WaypointInput.isFocused)
bigInterface.LockInput = false;
}
bigInterface.Update();
if (vesselLabel != null)
vesselLabel.UpdatePosition(bigInterface.VesselPosition());
if (inMap && m_MapImage != null && m_ReadoutText != null)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(m_MapImage.rectTransform, Input.mousePosition, bigInterface.MainCanvas.worldCamera, out rectPos);
m_ReadoutText.OnTextUpdate.Invoke(bigInterface.MapInfo(rectPos));
}
if (bigInterface.OrbitToggle && bigInterface.ShowOrbit)
{
for (int i = orbitLabels.Count - 1; i >= 0; i--)
{
SCAN_SimpleLabel label = orbitLabels[i];
label.UpdateIcon(bigInterface.OrbitInfo(i));
}
for (int i = orbitIconLabels.Count - 1; i >= 0; i--)
{
SCAN_MapLabel label = orbitIconLabels[i];
label.UpdatePositionActivation(bigInterface.OrbitIconInfo(label.StringID));
}
}
}
private Vector2 ScreenPosition(RectTransform r, Canvas canvas)
{
Vector3[] corners = new Vector3[4];
Vector2 pos = new Vector2();
r.GetWorldCorners(corners);
if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
{
pos = RectTransformUtility.WorldToScreenPoint(null, corners[0]);
}
else
{
pos = RectTransformUtility.WorldToScreenPoint(canvas.worldCamera, corners[0]);
}
pos.y = Screen.height - pos.y - r.sizeDelta.y;
return pos;
}
public void setMap(ISCAN_BigMap map)
{
if (map == null)
return;
bigInterface = map;
if (m_Version != null)
m_Version.OnTextUpdate.Invoke(map.Version);
if (m_ColorToggle != null)
m_ColorToggle.isOn = map.ColorToggle;
if (m_GridToggle != null)
m_GridToggle.isOn = map.GridToggle;
if (m_OrbitToggle != null)
m_OrbitToggle.isOn = map.OrbitToggle;
if (m_WaypointToggle != null)
m_WaypointToggle.isOn = map.WaypointToggle;
if (m_AnomalyToggle != null)
m_AnomalyToggle.isOn = map.AnomalyToggle;
if (m_FlagToggle != null)
m_FlagToggle.isOn = map.FlagToggle;
if (m_AsteroidToggle != null)
m_AsteroidToggle.isOn = map.AsteroidToggle;
if (m_LegendToggle != null)
m_LegendToggle.isOn = map.LegendToggle;
if (m_ResourcesToggle != null)
m_ResourcesToggle.isOn = map.ResourceToggle;
if (!map.OrbitAvailable && m_OrbitObject != null)
m_OrbitObject.SetActive(false);
if (!map.ShowWaypoint && m_WaypointObject != null)
m_WaypointObject.SetActive(false);
if (!map.ShowResource && m_Resources != null)
m_Resources.gameObject.SetActive(false);
SetLegend(map.LegendToggle, map.LegendImage, map.LegendLabels);
SetButtons(map.CurrentScene);
SetScale(map.Scale);
SetPosition(map.Position);
SetSize(map.Size);
SetIcons();
SetNorthSouth();
ProcessTooltips();
FadeIn();
loaded = true;
}
public void FadeIn()
{
Fade(1, true);
}
public void FadeOut()
{
Fade(0, false, Kill, false);
}
private void Kill()
{
gameObject.SetActive(false);
Destroy(gameObject);
}
public void Close()
{
if (bigInterface != null)
bigInterface.IsVisible = false;
}
public void ProcessTooltips()
{
if (bigInterface == null)
return;
TooltipHandler[] handlers = gameObject.GetComponentsInChildren<TooltipHandler>(true);
if (handlers == null)
return;
for (int j = 0; j < handlers.Length; j++)
ProcessTooltip(handlers[j], bigInterface.TooltipsOn, bigInterface.TooltipCanvas, bigInterface.Scale);
}
private void ProcessTooltip(TooltipHandler handler, bool isOn, Canvas c, float scale)
{
if (handler == null)
return;
handler.IsActive = isOn && !handler.HelpTip;
handler._Canvas = c;
handler.Scale = scale;
}
private void SetNorthSouth()
{
if (bigInterface == null || m_NorthSouthMarkers == null)
return;
if (bigInterface.CurrentProjection == "Polar")
m_NorthSouthMarkers.SetActive(true);
else
m_NorthSouthMarkers.SetActive(false);
}
private void SetButtons(int i)
{
switch(i)
{
case -1:
if (m_SmallMapButton != null)
m_SmallMapButton.SetActive(false);
if (m_ZoomMapButton != null)
m_ZoomMapButton.SetActive(false);
if (m_OverlayButton != null)
m_OverlayButton.SetActive(false);
if (m_InstrumentsButton != null)
m_InstrumentsButton.SetActive(false);
if (m_SettingsButton != null)
m_SettingsButton.SetActive(false);
break;
case 1:
if (m_SmallMapButton != null)
m_SmallMapButton.SetActive(false);
if (m_InstrumentsButton != null)
m_InstrumentsButton.SetActive(false);
break;
case 2:
if (m_SmallMapButton != null)
m_SmallMapButton.SetActive(false);
if (m_OverlayButton != null)
m_OverlayButton.SetActive(false);
if (m_InstrumentsButton != null)
m_InstrumentsButton.SetActive(false);
break;
}
}
public void SetScale(float scale)
{
rect.localScale = Vector3.one * scale;
}
public void SetPosition(Vector2 pos)
{
if (rect == null)
return;
rect.anchoredPosition = new Vector3(pos.x, pos.y, 0);
}
public void SetSize(Vector2 size)
{
if (m_MapLayout == null)
return;
if (size.x < m_MapLayout.minWidth)
size.x = m_MapLayout.minWidth;
else if (size.x > 8192)
size.x = 8192;
if (size.x % 2 != 0)
size.x += 1;
m_MapLayout.preferredWidth = size.x;
m_MapLayout.preferredHeight = m_MapLayout.preferredWidth / 2;
}
private void SetLegend(bool isOn, Texture2D tex, IList<string> labels)
{
if (m_LegendObject == null)
return;
if (bigInterface.CurrentMapType == "Altimetry")
m_LegendObject.SetActive(isOn);
else
{
m_LegendObject.SetActive(false);
return;
}
if (!isOn)
return;
if (m_LegendImage != null)
m_LegendImage.texture = tex;
if (labels == null || labels.Count != 3)
return;
if (m_LegendLabelOne != null)
m_LegendLabelOne.OnTextUpdate.Invoke(labels[0]);
if (m_LegendLabelTwo != null)
m_LegendLabelTwo.OnTextUpdate.Invoke(labels[1]);
if (m_LegendLabelThree != null)
m_LegendLabelThree.OnTextUpdate.Invoke(labels[2]);
}
private void SetFlagIcons(Dictionary<Guid, MapLabelInfo> flags)
{
if (flags == null)
return;
if (bigInterface == null || m_MapLabelPrefab == null || m_MapImage == null)
return;
for (int i = 0; i < flags.Count; i++)
{
Guid id = flags.ElementAt(i).Key;
MapLabelInfo info;
if (!flags.TryGetValue(id, out info))
continue;
createFlag(id, info);
}
}
private void createFlag(Guid id, MapLabelInfo info)
{
SCAN_MapLabel mapLabel = Instantiate(m_MapLabelPrefab).GetComponent<SCAN_MapLabel>();
if (mapLabel == null)
return;
mapLabel.transform.SetParent(m_MapImage.transform, false);
mapLabel.Setup(id, info);
flagLabels.Add(mapLabel);
}
private void SetAnomalyIcons(Dictionary<string, MapLabelInfo> anomalies)
{
if (anomalies == null)
return;
if (bigInterface == null || m_MapLabelPrefab == null || m_MapImage == null)
return;
for (int i = 0; i < anomalies.Count; i++)
{
string id = anomalies.ElementAt(i).Key;
MapLabelInfo info;
if (!anomalies.TryGetValue(id, out info))
continue;
createAnomaly(id, info);
}
}
private void createAnomaly(string id, MapLabelInfo info)
{
SCAN_MapLabel mapLabel = Instantiate(m_MapLabelPrefab).GetComponent<SCAN_MapLabel>();
if (mapLabel == null)
return;
mapLabel.transform.SetParent(m_MapImage.transform, false);
mapLabel.Setup(id, info);
anomalyLabels.Add(mapLabel);
}
private void SetWaypointIcons(Dictionary<int, MapLabelInfo> waypoints)
{
if (waypoints == null)
return;
if (bigInterface == null || m_MapLabelPrefab == null || m_MapImage == null)
return;
for (int i = 0; i < waypoints.Count; i++)
{
int id = waypoints.ElementAt(i).Key;
MapLabelInfo info;
if (!waypoints.TryGetValue(id, out info))
continue;
createWaypoint(id, info);
}
}
private SCAN_MapLabel createWaypoint(int id, MapLabelInfo info, bool temp = false)
{
SCAN_MapLabel mapLabel = Instantiate(m_MapLabelPrefab).GetComponent<SCAN_MapLabel>();
if (mapLabel == null)
return null;
mapLabel.transform.SetParent(m_MapImage.transform, false);
mapLabel.Setup(id, info);
if (!temp)
waypointLabels.Add(mapLabel);
return mapLabel;
}
private void SetVesselIcon(KeyValuePair<Guid, MapLabelInfo> vessel)
{
if (vessel.Value.label == "null")
return;
if (bigInterface == null || m_MapLabelPrefab == null || m_MapImage == null)
return;
SCAN_MapLabel mapLabel = Instantiate(m_MapLabelPrefab).GetComponent<SCAN_MapLabel>();
if (mapLabel == null)
return;
mapLabel.transform.SetParent(m_MapImage.transform, false);
mapLabel.Setup(vessel.Key, vessel.Value);
vesselLabel = mapLabel;
}
private void SetOrbitIcons(int count)
{
if (bigInterface == null || m_MapImage == null)
return;
for (int i = 0; i < count; i++)
{
SimpleLabelInfo info = bigInterface.OrbitInfo(i);
CreateOrbitIcon(info);
}
}
private void CreateOrbitIcon(SimpleLabelInfo info)
{
GameObject labelObj = new GameObject("SCAN_SimpleLabel");
SCAN_SimpleLabel label = labelObj.AddComponent<SCAN_SimpleLabel>();
if (label == null)
return;
label.transform.SetParent(m_MapImage.transform, false);
label.Setup(info);
orbitLabels.Add(label);
}
private void SetOrbitMapIcons(Dictionary<string, MapLabelInfo> orbitLabels)
{
if (orbitLabels == null)
return;
if (bigInterface == null || m_MapLabelPrefab == null || m_MapImage == null)
return;
for (int i = 0; i < orbitLabels.Count; i++)
{
string id = orbitLabels.ElementAt(i).Key;
MapLabelInfo info;
if (!orbitLabels.TryGetValue(id, out info))
continue;
CreateOrbitMapIcon(id, info);
}
}
private void CreateOrbitMapIcon(string id, MapLabelInfo info)
{
SCAN_MapLabel mapLabel = Instantiate(m_MapLabelPrefab).GetComponent<SCAN_MapLabel>();
if (mapLabel == null)
return;
mapLabel.transform.SetParent(m_MapImage.transform, false);
mapLabel.Setup(id, info);
orbitIconLabels.Add(mapLabel);
}
private void ClearIcons()
{
for (int i = waypointLabels.Count - 1; i >= 0; i--)
{
SCAN_MapLabel m = waypointLabels[i];
m.gameObject.SetActive(false);
Destroy(m.gameObject);
}
for (int i = anomalyLabels.Count - 1; i >= 0; i--)
{
SCAN_MapLabel m = anomalyLabels[i];
m.gameObject.SetActive(false);
Destroy(m.gameObject);
}
for (int i = flagLabels.Count - 1; i >= 0; i--)
{
SCAN_MapLabel m = flagLabels[i];
m.gameObject.SetActive(false);
Destroy(m.gameObject);
}
for (int i = orbitLabels.Count - 1; i >= 0; i--)
{
SCAN_SimpleLabel s = orbitLabels[i];
s.gameObject.SetActive(false);
Destroy(s.gameObject);
}
for (int i = orbitIconLabels.Count - 1; i >= 0; i--)
{
SCAN_MapLabel m = orbitIconLabels[i];
m.gameObject.SetActive(false);
Destroy(m.gameObject);
}
if (vesselLabel != null)
{
vesselLabel.gameObject.SetActive(false);
Destroy(vesselLabel.gameObject);
}
if (tempWaypointLabel != null)
{
tempWaypointLabel.gameObject.SetActive(false);
Destroy(tempWaypointLabel.gameObject);
}
flagLabels.Clear();
anomalyLabels.Clear();
waypointLabels.Clear();
orbitLabels.Clear();
orbitIconLabels.Clear();
vesselLabel = null;
tempWaypointLabel = null;
}
public void RefreshIcons()
{
ClearIcons();
SetIcons();
}
private void SetIcons()
{
if (bigInterface == null)
return;
if (bigInterface.FlagToggle)
SetFlagIcons(bigInterface.FlagInfoList);
if (bigInterface.AnomalyToggle)
SetAnomalyIcons(bigInterface.AnomalyInfoList);
if (bigInterface.WaypointToggle && bigInterface.ShowWaypoint)
SetWaypointIcons(bigInterface.WaypointInfoList);
if (bigInterface.OrbitToggle && bigInterface.ShowOrbit)
{
SetOrbitIcons(bigInterface.OrbitSteps);
SetOrbitMapIcons(bigInterface.OrbitLabelList);
}
SetVesselIcon(bigInterface.VesselInfo);
}
public void OnEnterMap(BaseEventData eventData)
{
inMap = true;
}
public void OnExitMap(BaseEventData eventData)
{
inMap = false;
if (m_ReadoutText != null)
m_ReadoutText.OnTextUpdate.Invoke("");
}
public void OnBeginDrag(PointerEventData eventData)
{
if (rect == null)
return;
mouseStart = eventData.position;
windowStart = rect.position;
}
public void OnDrag(PointerEventData eventData)
{
if (rect == null)
return;
rect.position = windowStart + (Vector3)(eventData.position - mouseStart);
}
public void OnEndDrag(PointerEventData eventData)
{
if (rect == null || bigInterface == null)
return;
bigInterface.Position = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y);
}
public void OnStartResize(BaseEventData eventData)
{
if (!(eventData is PointerEventData))
return;
ClearIcons();
}
public void OnResize(BaseEventData eventData)
{
if (m_MapLayout == null)
return;
if (!(eventData is PointerEventData))
return;
m_MapLayout.preferredWidth += ((PointerEventData)eventData).delta.x;
if (m_MapLayout.preferredWidth < m_MapLayout.minWidth)
m_MapLayout.preferredWidth = m_MapLayout.minWidth;
else if (m_MapLayout.preferredWidth > 8192)
m_MapLayout.preferredWidth = 8192;
if (m_MapLayout.preferredWidth % 2 != 0)
m_MapLayout.preferredWidth += 1;
m_MapLayout.preferredHeight = m_MapLayout.preferredWidth / 2;
}
public void OnEndResize(BaseEventData eventData)
{
if (m_MapLayout == null || bigInterface == null)
return;
bigInterface.Size = new Vector2(m_MapLayout.preferredWidth, m_MapLayout.preferredHeight);
SetIcons();
}
public void OnPointerDown(PointerEventData eventData)
{
transform.SetAsLastSibling();
if (dropDown == null)
return;
RectTransform r = dropDown.GetComponent<RectTransform>();
if (r == null)
return;
if (RectTransformUtility.RectangleContainsScreenPoint(r, eventData.position, eventData.pressEventCamera))
return;
dropDown.FadeOut();
dropDown = null;
if (m_DropDownToggles != null)
m_DropDownToggles.SetAllTogglesOff();
}
public void OnClickMap(BaseEventData eventData)
{
if (!inMap || bigInterface == null || m_MapImage == null || !(eventData is PointerEventData))
return;
OnPointerDown((PointerEventData)eventData);
Vector2 pos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(m_MapImage.rectTransform, Input.mousePosition, bigInterface.MainCanvas.worldCamera, out pos);
if (waypointSelecting)
{
if (tempWaypointLabel != null)
{
tempWaypointLabel.gameObject.SetActive(false);
Destroy(tempWaypointLabel.gameObject);
tempWaypointLabel = null;
}
SetWaypoint(pos);
}
else
bigInterface.ClickMap(pos);
}
private void SetWaypoint(Vector2 p)
{
Vector2 mapPos = new Vector2(p.x, p.y + bigInterface.Size.y);
MapLabelInfo info = new MapLabelInfo()
{
label = "",
image = bigInterface.WaypointSprite,
pos = mapPos,
baseColor = Color.white,
flash = false,
width = 20,
alignBottom = true,
show = true
};
tempWaypointLabel = createWaypoint(0, info, true);
}
public void UpdateTitle(string text)
{
if (m_Title == null)
return;
m_Title.OnTextUpdate.Invoke(text);
}
public void UpdateMapTexture(Texture2D map)
{
if (m_MapImage == null)
return;
m_MapImage.texture = map;
}
public void UpdateGridTexture(Texture2D grid)
{
if (m_GridMap == null)
return;
m_GridMap.texture = grid;
}
public void UpdateEQMapTexture(Texture2D eq)
{
if (m_EQMap != null)
m_EQMap.texture = eq;
}
public void ToggleProjectionSelection(bool isOn)
{
if (dropDown != null)
{
dropDown.FadeOut(true);
dropDown = null;
}
if (!isOn)
return;
if (bigInterface == null || m_DropDownPrefab == null || m_Projection == null)
return;
dropDown = Instantiate(m_DropDownPrefab).GetComponent<SCAN_DropDown>();
if (dropDown == null)
return;
dropDown.transform.SetParent(m_Projection, false);
dropDown.Setup(bigInterface.Projections, bigInterface.CurrentProjection);
dropDown.OnSelectUpdate.AddListener(new UnityEngine.Events.UnityAction<string>(SetProjection));
}
private void SetProjection(string selection)
{
if (bigInterface == null)
return;
bigInterface.CurrentProjection = selection;
dropDown.FadeOut();
dropDown = null;
if (m_DropDownToggles != null)
m_DropDownToggles.SetAllTogglesOff();
RefreshIcons();
SetNorthSouth();
}
public void ToggleTypeSelection(bool isOn)
{
if (dropDown != null)
{
dropDown.FadeOut(true);
dropDown = null;
}
if (!isOn)
return;
if (bigInterface == null || m_DropDownPrefab == null || m_MapType == null)
return;
dropDown = Instantiate(m_DropDownPrefab).GetComponent<SCAN_DropDown>();
if (dropDown == null)
return;
dropDown.transform.SetParent(m_MapType, false);
dropDown.Setup(bigInterface.MapTypes, bigInterface.CurrentMapType);
dropDown.OnSelectUpdate.AddListener(new UnityEngine.Events.UnityAction<string>(SetType));
}
private void SetType(string selection)
{
if (bigInterface == null)
return;
bigInterface.CurrentMapType = selection;
dropDown.FadeOut();
dropDown = null;
if (m_DropDownToggles != null)
m_DropDownToggles.SetAllTogglesOff();
RefreshIcons();
SetLegend(bigInterface.LegendToggle, bigInterface.LegendImage, bigInterface.LegendLabels);
}
public void ToggleResourceSelection(bool isOn)
{
if (dropDown != null)
{
dropDown.FadeOut(true);
dropDown = null;
}
if (!isOn)
return;
if (bigInterface == null || m_DropDownPrefab == null || m_Resources == null)
return;
dropDown = Instantiate(m_DropDownPrefab).GetComponent<SCAN_DropDown>();
if (dropDown == null)
return;
dropDown.transform.SetParent(m_Resources, false);
dropDown.Setup(bigInterface.Resources, bigInterface.CurrentResource);
dropDown.OnSelectUpdate.AddListener(new UnityEngine.Events.UnityAction<string>(SetResource));
}
private void SetResource(string selection)
{
if (bigInterface == null)
return;
bigInterface.CurrentResource = selection;
dropDown.FadeOut();
dropDown = null;
if (m_DropDownToggles != null)
m_DropDownToggles.SetAllTogglesOff();
RefreshIcons();
}
public void ToggleCelestialBodySelection(bool isOn)
{
if (dropDown != null)
{
dropDown.FadeOut(true);
dropDown = null;
}
if (!isOn)
return;