forked from SodiumEyes/AmpYear
/
AYControllerGUI.cs
1998 lines (1890 loc) · 123 KB
/
AYControllerGUI.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
/**
* AYController.cs
*
* AmpYear power management.
* (C) Copyright 2015, Jamie Leighton
* The original code and concept of AmpYear rights go to SodiumEyes on the Kerbal Space Program Forums, which was covered by GNU License GPL (no version stated).
* As such this code continues to be covered by GNU GPL license.
* Parts of this code were copied from Fusebox by the user ratzap on the Kerbal Space Program Forums, which is covered by GNU License GPLv2.
* Concepts which are common to the Game Kerbal Space Program for which there are common code interfaces as such some of those concepts used
* by this program were based on:
* Thunder Aerospace Corporation's Life Support for Kerbal Space Program.
* Written by Taranis Elsu.
* (C) Copyright 2013, Taranis Elsu
* Which is licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 3.0)
* creative commons license. See <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* for full details.
*
* Thanks go to both ratzap and Taranis Elsu for their code.
* Kerbal Space Program is Copyright (C) 2013 Squad. See http://kerbalspaceprogram.com/. This
* project is in no way associated with nor endorsed by Squad.
*
* This file is part of AmpYear.
*
* AmpYear is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AmpYear 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AmpYear. If not, see <http://www.gnu.org/licenses/>.
*
*/
using System;
using System.Collections.Generic;
using Highlighting;
using UnityEngine;
using RSTUtils;
using RSTUtils.Extensions;
using KSP.Localization;
namespace AY
{
public partial class AYController : MonoBehaviour
{
//GUI Properties
//private IButton _button1;
private IconAlertState _iconAlertState = IconAlertState.GREEN;
private AppLauncherToolBar AYMenuAppLToolBar;
//private ApplicationLauncherButton _stockToolbarButton = null; // Stock Toolbar Button
private readonly double[] _reserveTransferIncrements = new double[3] { 0.25, 0.1, 0.01 };
private String[] incrementPercentString = new String[3];
private bool[] _guiSectionEnableFlag = new bool[LoadGlobals.GuiSectionArrayCache.Length];
private const float FWINDOW_WIDTH = 220;
private const float EWINDOW_WIDTH = 220;
private const float WINDOW_BASE_HEIGHT = 140;
private Vector2 _plProdscrollViewVector = Vector2.zero;
private Vector2 _plConsscrollViewVector = Vector2.zero;
private Vector2 _dSscrollViewVector = Vector2.zero;
private GUILayoutOption[] SubsystemButtonOptions;
private static int _fwindowId;
private static int _ewindowId;
private static int _dwindowId;
private static int _wwindowId;
private static int _swindowId;
private static string LOCK_ID = "AmpYear_KeyBinder";
private static double epsilon = 1e-4;
private bool[] _subsystemToggle = new bool[LoadGlobals.SubsystemArrayCache.Length]; // Enum.GetValues(typeof(Subsystem)).Length];
private double[] _subsystemDrain = new double[LoadGlobals.SubsystemArrayCache.Length]; //Enum.GetValues(typeof(Subsystem)).Length];
private bool _managerEnabled = true;
private bool _showCrew = false;
private bool _showParts = false;
private double _timeLastElectricity;
private double _lastUpdate;
private float _powerUpTime = 0.0f;
public static bool EmgcyShutActive = false;
public static bool EmgcyShutOverride = false;
public static bool EmgcyShutOverrideStarted = false;
public static double EmgcyShutOverrideTmeStarted = 0;
private static bool _checkLowEcWarning = true;
private static bool _lowEcWarningWindowDisplay = false;
internal static bool ShowDarkSideWindow = false;
private CelestialBody _bodyTarget;
private int _darkTargetSelection = -1;
private int _selectedDarkTarget = -1;
//private string _selectedHighlitePart = "";
private int _showDarkOrbitAp = 100;
private int _showDarkOrbitPe = 100;
private List<CelestialBody> _darkBodies = new List<CelestialBody>();
private Rect _fwindowPos = new Rect(40, Screen.height / 2 - 100, FWINDOW_WIDTH, 200); // Flight Window position and size
private Rect _ewindowPos = new Rect(40, Screen.height / 2 - 100, EWINDOW_WIDTH, 200); // Editor Window position and size
private Rect _dwindowPos = new Rect(40, Screen.height / 2 - 100, 360, 200); // DarkSide Window position and size
private Rect _epLwindowPos = new Rect(270, Screen.height / 2 - 100, 650, 600); //Extended Parts List Window position and size
private float _eplPartName, _eplPartModuleName, _eplec, _eplProdListHeight, _eplConsListHeight;
private Rect _eplHeaders2, _eplProdlistbox, _eplConslistbox;
private bool _includeStoredEc = true;
private bool _includeSoredRp = true;
private bool _lockReservePower; //Blocks usage of ReservePower automatically
private bool PrtProdEditorIncludeAll = true;
private bool PrtProdESPIncludeAll = true;
private bool PrtConsEditorIncludeAll = true;
private bool PrtConsESPIncludeAll = true;
private double timeRemainReserve;
private double timeRemainMains;
private double powerPercent;
private double reservePercent;
private string ststext = "";
private bool tmpShowDarkSideWindow;
private float _totalProdPower = 0f;
private string partModuleName = string.Empty;
private int OrbitAp;
private string strOrbitAp;
private int OrbitPe;
private string strOrbitPe;
private int tmpESPPriority;
private bool tmpPrtConsEditorIncludeAll, tmpPrtConsEmergShutDnIncludeAll, tmpPrtConsOneAll, tmpPrtConsThreeAll, tmpPrtConsTwoAll;
private bool prodPartsHighlightAll = false;
private bool consPartsHighlightAll = false;
private bool tmpPrtEditorInclude,
tmpPrtEmergShutDnInclude,
tmpPrtProdEditorIncludeAll,
tmpPrtProdEmergShutDnIncludeAll;
private double tmpPrtPowerV;
private string tmpPrtPower, Units;
private bool tmpPrtProdOneAll, tmpPrtProdThreeAll, tmpPrtProdTwoAll;
private float _totalConsPower;
private Vector3d sun_dir;
private double sun_dist;
private double darkTime, eCdifference, ECprodfordarkTime, ECreqdfordarkTime, ECreqdfordarkTimeSurface, ECprodfordarkTimeSurface, powerSupply, rotPeriod;
private uint tmpPartKey;
#region GUIFunctions
private ControlTypes EditorLocks = ControlTypes.EDITOR_ICON_HOVER | ControlTypes.EDITOR_ICON_PICK | ControlTypes.EDITOR_TAB_SWITCH | ControlTypes.EDITOR_PAD_PICK_PLACE |
ControlTypes.EDITOR_PAD_PICK_COPY | ControlTypes.EDITOR_GIZMO_TOOLS | ControlTypes.EDITOR_ROOT_REFLOW | ControlTypes.EDITOR_SYM_SNAP_UI | ControlTypes.EDITOR_EDIT_STAGES |
ControlTypes.EDITOR_UNDO_REDO | ControlTypes.EDITOR_MODE_SWITCH | ControlTypes.EDITOR_UI;
//Lifted this more or less directly from the Kerbal Engineer source. Thanks cybutek!
/// <summary>
/// Gets and sets the input lock state.
/// </summary>
public bool InputLock
{
get
{
return InputLockManager.GetControlLock(LOCK_ID) != ControlTypes.None;
}
set
{
if (value)
{
InputLockManager.SetControlLock(EditorLocks | ControlTypes.UI_DIALOGS, LOCK_ID);
}
else
{
InputLockManager.SetControlLock(ControlTypes.None, LOCK_ID);
}
}
}
//GUI Functions Follow
private void OnGUI()
{
try
{
if (!Textures.StylesSet)
{
Textures.SetupStyles();
//Textures.SetupHighLightStyles(AYsettings.ProdPartHighlightColor, AYsettings.ConsPartHighlightColor);
}
}
catch (Exception ex)
{
Utilities.Log("Unable to set GUI Styles to draw the GUI");
Utilities.Log("Exception: {0}", ex);
}
try
{
SetIcon();
}
catch (Exception ex)
{
Utilities.Log("Unable to set GUI Icon");
Utilities.Log("Exception: {0}", ex);
}
if (!AYMenuAppLToolBar.GuiVisible || AYMenuAppLToolBar.gamePaused || AYMenuAppLToolBar.hideUI || (!Utilities.GameModeisEditor && !Utilities.GameModeisFlight)) return;
GUI.skin = HighLogic.Skin;
if (Utilities.GameModeisFlight) //FlightScene GUI
{
try
{
_fwindowPos.ClampInsideScreen();
_fwindowPos = GUILayout.Window(_fwindowId, _fwindowPos, WindowF, Localizer.Format("#autoLOC_AmpYear_1000001"), GUILayout.Width(FWINDOW_WIDTH), GUILayout.Height(WINDOW_BASE_HEIGHT)); // #autoLOC_AmpYear_1000001 = AmpYear
if (_showParts)
{
_epLwindowPos.ClampToScreen();
_epLwindowPos = GUILayout.Window(_swindowId, _epLwindowPos, WindowScrollParts, Localizer.Format("#autoLOC_AmpYear_1000002"), GUILayout.Width(_epLwindowPos.width), GUILayout.Height(_epLwindowPos.height), GUILayout.MinWidth(150), GUILayout.MinHeight(150)); // #autoLOC_AmpYear_1000002 = AmpYear Parts List
}
CheckPowerLowWarning();
if (_lowEcWarningWindowDisplay)
{
PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "AmpYear Warning!", Localizer.Format("#autoLOC_AmpYear_1000003"), // #autoLOC_AmpYear_1000003 = AmpYear Warning!
Localizer.Format("#autoLOC_AmpYear_1000004"), Localizer.Format("#autoLOC_AmpYear_1000005"), false, HighLogic.UISkin, false); // #autoLOC_AmpYear_1000004 = Ship Electric charge has dropped below the Warp Warning Percentage.\n This will not trigger again until Electric charge > Warning Percentage again. // #autoLOC_AmpYear_1000005 = OK
_lowEcWarningWindowDisplay = false;
}
}
catch (Exception ex)
{
Utilities.Log("Unable to draw FlightScene GUI");
Utilities.Log("Exception: {0}", ex);
}
}
if (Utilities.GameModeisEditor)
{
try
{
_ewindowPos.ClampInsideScreen();
_ewindowPos = GUILayout.Window(_ewindowId, _ewindowPos, WindowE, Localizer.Format("#autoLOC_AmpYear_1000001"), GUILayout.Width(EWINDOW_WIDTH), GUILayout.Height(WINDOW_BASE_HEIGHT));
if (_showParts)
{
_epLwindowPos.ClampToScreen();
_epLwindowPos = GUILayout.Window(_swindowId, _epLwindowPos, WindowScrollParts, Localizer.Format("#autoLOC_AmpYear_1000002"), GUILayout.Width(_epLwindowPos.width), GUILayout.Height(_epLwindowPos.height), GUILayout.MinWidth(150), GUILayout.MinHeight(150));
}
}
catch (Exception ex)
{
Utilities.Log("Unable to draw EditorScene GUI");
Utilities.Log("Exception: {0}", ex);
}
}
if (ShowDarkSideWindow)
{
try
{
_dwindowPos.ClampToScreen();
_dwindowPos = GUILayout.Window(_dwindowId, _dwindowPos, WindowD, Localizer.Format("#autoLOC_AmpYear_1000006"), GUILayout.MinWidth(360), GUILayout.MinHeight(320)); // #autoLOC_AmpYear_1000006 = AmpYear Dark-Side & Solar SOI
}
catch (Exception ex)
{
Utilities.Log("Unable to draw DarkSide GUI");
Utilities.Log("Exception: {0}", ex);
}
}
if (AYsettings.TooltipsOn)
Utilities.DrawToolTip();
}
/// <summary>
/// Called by unity every frame.
/// </summary>
protected virtual void Update()
{
UpdateInputLock();
}
private void CheckPowerLowWarning()
{
double chrgpct = TotalElectricCharge / TotalElectricChargeCapacity * 100;
if (_checkLowEcWarning && !_lowEcWarningWindowDisplay) // If Warning is on check if it's triggered
{
if ((TimeWarp.CurrentRate > 0) && (chrgpct < AYsettings.POWER_LOW_WARNING_AMT)) // We have hit the warning stop timewarp and show warning
{
Utilities.Log_Debug("cutting timewarp power warning limit reached");
TimeWarp.SetRate(0, false);
_checkLowEcWarning = false;
_lowEcWarningWindowDisplay = true;
}
}
if ((chrgpct > AYsettings.POWER_LOW_WARNING_AMT) && !_checkLowEcWarning) // Reset the Warning indicator
{
Utilities.Log_Debug("Reset power warning");
_checkLowEcWarning = true;
}
}
private void WindowF(int id)
{
_iconAlertState = IconAlertState.GREEN;
GUIContent closeContent = new GUIContent(Textures.BtnRedCross, Localizer.Format("#autoLOC_AmpYear_1000007")); // #autoLOC_AmpYear_1000007 = Close Window
Rect closeRect = new Rect(_fwindowPos.width - 21, 4, 16, 16);
if (GUI.Button(closeRect, closeContent, Textures.PartListbtnStyle))
{
AYMenuAppLToolBar.onAppLaunchToggle();
return;
}
AYsettings.showSI = GUI.Toggle(new Rect(_fwindowPos.width - 45, 4, 16, 16), AYsettings.showSI, new GUIContent(Textures.BtnIS, Localizer.Format("#autoLOC_AmpYear_1000008")), Textures.PartListbtnStyle); // #autoLOC_AmpYear_1000008 = Toggle the display to use EC or SI units
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
for (int i = LoadGlobals.GuiSectionArrayCache.Length - 1; i >= 0; --i)
{
if (LoadGlobals.GuiSectionArrayCache[i] == GUISection.LUXURY)
{
if (KKPresent)
{
_guiSectionEnableFlag[(int)LoadGlobals.GuiSectionArrayCache[i]]
= GUILayout.Toggle(_guiSectionEnableFlag[(int)LoadGlobals.GuiSectionArrayCache[i]], GuiSectionName(LoadGlobals.GuiSectionArrayCache[i]), GUI.skin.button);
}
else
{
_guiSectionEnableFlag[(int)LoadGlobals.GuiSectionArrayCache[i]] = false;
}
}
else
{
_guiSectionEnableFlag[(int)LoadGlobals.GuiSectionArrayCache[i]]
= GUILayout.Toggle(_guiSectionEnableFlag[(int)LoadGlobals.GuiSectionArrayCache[i]], GuiSectionName(LoadGlobals.GuiSectionArrayCache[i]), GUI.skin.button);
}
}
GUILayout.EndHorizontal();
//Manager status+drain
if (TimewarpIsValid)
{
GUILayout.BeginHorizontal();
if (_rt2Present && !RT2UnderControl)
{
GUI.enabled = false;
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000009"), Localizer.Format("#autoLOC_AmpYear_1000010")), Textures.AlertStyle); // #autoLOC_AmpYear_1000009 = Remote Tech - No Control // #autoLOC_AmpYear_1000010 = No Remote Tech Connection or Local Control - Unable to use AmpYear Functions.
}
_managerEnabled = GUILayout.Toggle(_managerEnabled, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000011"), Localizer.Format("#autoLOC_AmpYear_1000012")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000011 = Manager // #autoLOC_AmpYear_1000012 = Turn on to Enable the AmpYear Management Unit
GUI.enabled = true;
if (ManagerIsActive)
ConsumptionLabel(ManagerCurrentDrain, false);
else
ConsumptionLabel(managerActiveDrain, true);
GUILayout.EndHorizontal();
}
//Manager status label
if (hasPower || HasReservePower)
{
if (ManagerIsActive)
{
if (hasPower)
{
if (TotalElectricChargeCapacity > 0.0)
{
powerPercent = TotalElectricCharge / TotalElectricChargeCapacity * 100.0;
if (powerPercent < 20.00)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000013", powerPercent.ToString("0.00")), Localizer.Format("#autoLOC_AmpYear_1000014")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000013 = Power: <<1>>% // #autoLOC_AmpYear_1000014 = The Total Percentage of Main Power stored as a percentage of total capacity
SetIconalertstate(IconAlertState.RED);
}
else
{
if (powerPercent < 35.00)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000013", powerPercent.ToString("0.00")), Localizer.Format("#autoLOC_AmpYear_1000014")), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000013 = Power: <<1>>% // #autoLOC_AmpYear_1000014 = The Total Percentage of Main Power stored as a percentage of total capacity
SetIconalertstate(IconAlertState.YELLOW);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000013", powerPercent.ToString("0.00")), Localizer.Format("#autoLOC_AmpYear_1000014")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000013 = Power: <<1>>% // #autoLOC_AmpYear_1000014 = The Total Percentage of Main Power stored as a percentage of total capacity
}
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalPowerDrain, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalPowerDrain.ToString("0.##");
}
if (TotalPowerDrain > TotalPowerProduced)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000015", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000016")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000015 = Power Drain : // #autoLOC_AmpYear_1000016 = The Total Power Drain on this vessel
SetIconalertstate(IconAlertState.RED);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000015", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000016")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000015 = Power Drain : // #autoLOC_AmpYear_1000016 = The Total Power Drain on this vessel
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalPowerProduced, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalPowerProduced.ToString("0.##");
}
if (TotalPowerProduced > 0)
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000017", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000018")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000017 = Power Prod : // #autoLOC_AmpYear_1000018 = The Total Power Production of this vessel
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000017", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000018")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000017 = Power Prod : // #autoLOC_AmpYear_1000018 = The Total Power Production of this vessel
SetIconalertstate(IconAlertState.YELLOW);
}
//Time Remaining in Main batteries
timeRemainMains = TotalElectricCharge / TotalPowerDrain;
if (timeRemainMains < 300) //5 mins
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000020")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000019 = Mains Time: // #autoLOC_AmpYear_1000020 = Time remaining in Main Power Batteries
SetIconalertstate(IconAlertState.RED);
}
else
{
if (timeRemainMains < 1800) //30 mins
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000020")), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000019 = Mains Time: // #autoLOC_AmpYear_1000020 = Time remaining in Main Power Batteries
SetIconalertstate(IconAlertState.YELLOW);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000020")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000019 = Mains Time: // #autoLOC_AmpYear_1000020 = Time remaining in Main Power Batteries
}
//Time Remaining in Reserver Batteries
timeRemainReserve = TotalReservePower / TotalPowerDrain;
GUILayout.Label(
new GUIContent(
Localizer.Format("#autoLOC_AmpYear_1000021", KSPUtil.PrintTimeCompact((int) timeRemainReserve, false)), // #autoLOC_AmpYear_1000021 = Reserve Time:
Localizer.Format("#autoLOC_AmpYear_1000022")), // #autoLOC_AmpYear_1000022 = Time remaining in Reserve Power Batteries
timeRemainReserve < 30 ? Textures.AlertStyle : Textures.StatusStyleLeft);
if (_lockReservePower)
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000023"), Localizer.Format("#autoLOC_AmpYear_1000024")),Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000023 = Reserve Power Isolated // #autoLOC_AmpYear_1000024 = Reserve Power Isolation Switch is ON
if (TotalElectricChargeFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalElectricChargeFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalElectricChargeFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000025", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000026")), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000025 = Disabled EC: // #autoLOC_AmpYear_1000026 = You still have Main EC power, but you have disabled it in the part right click menu.
}
if (TotalReservePowerFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalReservePowerFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalReservePowerFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000027", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000028")), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000027 = Disabled ReservePower: // #autoLOC_AmpYear_1000028 = You still have ReservePower, but you have disabled it in the part right click menu.
}
}
}
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000029"), Localizer.Format("#autoLOC_AmpYear_1000030")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000029 = Running on Reserve Power! // #autoLOC_AmpYear_1000030 = Main EC power is exhausted, we are running on Reserve Power. Until that runs out...
if (TotalElectricChargeFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalElectricChargeFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalElectricChargeFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000027", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000028")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000027 = Disabled ReservePower: // #autoLOC_AmpYear_1000028 = You still have ReservePower, but you have disabled it in the part right click menu.
}
if (TotalReservePowerFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalReservePowerFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalReservePowerFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000027", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000028")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000027 = Disabled ReservePower: // #autoLOC_AmpYear_1000028 = You still have ReservePower, but you have disabled it in the part right click menu.
}
SetIconalertstate(IconAlertState.RED);
}
}
else
{
if (TimewarpIsValid)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000031"), Localizer.Format("#autoLOC_AmpYear_1000032")), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000031 = Manager Disabled // #autoLOC_AmpYear_1000032 = The AmpYear Power Management Unit has been disabled
SetIconalertstate(IconAlertState.GRAY);
}
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000033"), Localizer.Format("#autoLOC_AmpYear_1000034")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000033 = Auto-Hibernation // #autoLOC_AmpYear_1000034 = AmpYear functions are disabled at High rates of Time Warp
}
}
}
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000035"), Localizer.Format("#autoLOC_AmpYear_1000036")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000035 = Insufficient Power // #autoLOC_AmpYear_1000036 = There is insufficient Power to run ANY of the vessels systems
if (TotalElectricChargeFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalElectricChargeFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalElectricChargeFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000025", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000026")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000025 = Disabled EC: // #autoLOC_AmpYear_1000026 = You still have Main EC power, but you have disabled it in the part right click menu.
}
if (TotalReservePowerFlowOff > 0)
{
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalReservePowerFlowOff, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.##") + Units;
}
else
{
tmpPrtPower = TotalReservePowerFlowOff.ToString("0.##");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000027", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000028")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000027 = Disabled ReservePower: // #autoLOC_AmpYear_1000028 = You still have ReservePower, but you have disabled it in the part right click menu.
}
SetIconalertstate(IconAlertState.RED);
}
//if (AYsettings.Craziness_Function)
if (KKPresent)
{
KKKrazyWrngs();
}
//Subsystems
if (ManagerIsActive && GuiSectionEnabled(GUISection.SUBSYSTEM))
{
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000037"), Textures.SectionTitleStyle); // #autoLOC_AmpYear_1000037 = Subsystems
for (int i = LoadGlobals.SubsystemArrayCache.Length - 1; i >= 0; --i)
{
if (!SubsystemIsLuxury(LoadGlobals.SubsystemArrayCache[i]) && SubsystemVisible(LoadGlobals.SubsystemArrayCache[i]))
{
GUILayout.BeginHorizontal();
SubsystemButton(LoadGlobals.SubsystemArrayCache[i]);
SubsystemConsumptionLabel(LoadGlobals.SubsystemArrayCache[i]);
GUILayout.EndHorizontal();
}
}
}
if (GuiSectionEnabled(GUISection.SUBSYSTEM))
{
if (_rt2Present && !RT2UnderControl) GUI.enabled = false;
GUILayout.BeginHorizontal();
_showCrew = GUILayout.Toggle(_showCrew, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000038"), Localizer.Format("#autoLOC_AmpYear_1000039")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000038 = ShowCrew // #autoLOC_AmpYear_1000039 = Show a list of crew on board the current vessel
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EmgcyShutActive = GUILayout.Toggle(EmgcyShutActive, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000040"), Localizer.Format("#autoLOC_AmpYear_1000041")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000040 = Emergency SP Auto Active // #autoLOC_AmpYear_1000041 = Activate Automatic Emergency Shutdown Procedures
GUILayout.EndHorizontal();
if (Emergencypowerdownactivated || Emergencypowerdownreset) //Do a status if Auto ESP is processing
{
ststext = "";
if (Emergencypowerdownactivated)
{
ststext = Localizer.Format("#autoLOC_AmpYear_1000042"); // #autoLOC_AmpYear_1000042 = PwrDown
}
else
{
ststext = Localizer.Format("#autoLOC_AmpYear_1000043"); // #autoLOC_AmpYear_1000043 = PwrUp
}
switch (_espPriority)
{
case ESPPriority.HIGH:
ststext += Localizer.Format("#autoLOC_AmpYear_1000044"); // #autoLOC_AmpYear_1000044 = High
break;
case ESPPriority.MEDIUM:
ststext += Localizer.Format("#autoLOC_AmpYear_1000045"); // #autoLOC_AmpYear_1000045 = Medium
break;
case ESPPriority.LOW:
ststext += Localizer.Format("#autoLOC_AmpYear_1000046"); // #autoLOC_AmpYear_1000046 = Low
break;
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000047", ststext), Localizer.Format("#autoLOC_AmpYear_1000048")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000047 = Auto ESP Active: // #autoLOC_AmpYear_1000048 = Automatic ESP is Actively processing
}
GUILayout.BeginHorizontal();
GUIContent btntext = new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000049"), // #autoLOC_AmpYear_1000049 = Emerg. SP Manual
EmgcyShutActive
? Localizer.Format("#autoLOC_AmpYear_1000050") // #autoLOC_AmpYear_1000050 = Manually Activate Emergency Shutdown Procedures right now.
: Localizer.Format("#autoLOC_AmpYear_1000051")); // #autoLOC_AmpYear_1000051 = Automatic ESP (above) must be turned on first for manual override to become available.
if (!EmgcyShutActive || EmgcyShutOverride || EmgcyShutOverrideTmeStarted > 0)
{
GUI.enabled = false;
if (EmgcyShutOverride)
btntext = new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000049"), Localizer.Format("#autoLOC_AmpYear_1000052")); // #autoLOC_AmpYear_1000049 = Emerg. SP Manual // #autoLOC_AmpYear_1000052 = Manual Emergency Shutdown Process has been activated.
if (EmgcyShutOverrideTmeStarted > 0)
{
double tmeRemaining = AYsettings.EmgcyShutOverrideCooldown - (Planetarium.GetUniversalTime() - EmgcyShutOverrideTmeStarted);
string tmeRemStr = KSPUtil.PrintTimeCompact(tmeRemaining, true);
btntext = new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000053", tmeRemStr), Localizer.Format("#autoLOC_AmpYear_1000054")); // #autoLOC_AmpYear_1000053 = Manual CoolDown Rem:\n // #autoLOC_AmpYear_1000054 = Manual Emergency Shutdown Process is in cooldown mode.
}
}
if (GUILayout.Button(btntext))
{
if (EmgcyShutActive)
{
Utilities.Log_Debug("emergency shutdown manual override activated");
EmgcyShutActive = true;
EmgcyShutOverride = true;
_espPriority = ESPPriority.LOW;
}
else
{
Utilities.Log_Debug("emergency shutdown manual override NOT activated - automatic not activated first");
EmgcyShutActive = false;
EmgcyShutOverride = false;
ScreenMessages.PostScreenMessage(
Localizer.Format("#autoLOC_AmpYear_1000055"), 5.0f, // #autoLOC_AmpYear_1000055 = You must activate the Automatic ESP system before you can activate the manual override button
ScreenMessageStyle.UPPER_CENTER);
}
}
GUI.enabled = true;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
_showParts = GUILayout.Toggle(_showParts, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000056"), Localizer.Format("#autoLOC_AmpYear_1000057")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000056 = ShowParts // #autoLOC_AmpYear_1000057 = Show all the Parts and PartModules list in the current vessel
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
tmpShowDarkSideWindow = ShowDarkSideWindow;
ShowDarkSideWindow = GUILayout.Toggle(ShowDarkSideWindow, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000058"), Localizer.Format("#autoLOC_AmpYear_1000059")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000058 = Dark-Side & Solar Calcs // #autoLOC_AmpYear_1000059 = Open the Dark-Side and Solar Panel SOI Calculator
if (tmpShowDarkSideWindow != ShowDarkSideWindow)
{
AYVesselPartLists.ResetSolarPartToggles();
}
GUILayout.EndHorizontal();
}
//Luxury
if (ManagerIsActive && GuiSectionEnabled(GUISection.LUXURY))
{
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000060"), Textures.SectionTitleStyle); // #autoLOC_AmpYear_1000060 = Luxury
if (_rt2Present && !RT2UnderControl) GUI.enabled = false;
for (int i = LoadGlobals.SubsystemArrayCache.Length - 1; i >= 0; --i)
{
if (SubsystemIsLuxury(LoadGlobals.SubsystemArrayCache[i]) && SubsystemVisible(LoadGlobals.SubsystemArrayCache[i]))
{
GUILayout.BeginHorizontal();
SubsystemButton(LoadGlobals.SubsystemArrayCache[i]);
SubsystemConsumptionLabel(LoadGlobals.SubsystemArrayCache[i]);
GUILayout.EndHorizontal();
}
}
GUI.enabled = true;
}
//Reserve
if (ManagerIsActive && GuiSectionEnabled(GUISection.RESERVE))
{
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000061"), Textures.SectionTitleStyle); // #autoLOC_AmpYear_1000061 = Reserve Power
//Reserve status label
if (TotalReservePowerCapacity > 0.0)
{
if (HasReservePower)
{
reservePercent = TotalReservePower / TotalReservePowerCapacity * 100.0;
if (reservePercent < 20.0)
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000062", reservePercent.ToString("0.00")), Localizer.Format("#autoLOC_AmpYear_1000063")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000062 = Reserve Power: // #autoLOC_AmpYear_1000063 = Percentage of Reserve Power Available
else
{
GUILayout.Label(
new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000062", reservePercent.ToString("0.00")), // #autoLOC_AmpYear_1000062 = Reserve Power:
Localizer.Format("#autoLOC_AmpYear_1000063")), // #autoLOC_AmpYear_1000063 = Percentage of Reserve Power Available
reservePercent < 40.0 ? Textures.WarningStyle : Textures.StatusStyleLeft);
}
}
else
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000064"), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000064 = Reserve Power Depleted
}
else
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000065"), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000065 = Reserve Power not Found!
//Reserve transfer
//String[] incrementPercentString = new String[_reserveTransferIncrements.Length];
//if (_rt2Present && !RT2UnderControl) GUI.enabled = false;
GUILayout.BeginHorizontal();
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000066"), Localizer.Format("#autoLOC_AmpYear_1000067"))); // #autoLOC_AmpYear_1000066 = XFer Reserve to Main // #autoLOC_AmpYear_1000067 = Transfer a percentage of Reserve Power to Mains Power
for (int i = 0; i < _reserveTransferIncrements.Length; i++)
{
incrementPercentString[i] = (_reserveTransferIncrements[i] * 100).ToString("F0") + '%';
if (GUILayout.Button(new GUIContent(incrementPercentString[i], Localizer.Format("#autoLOC_AmpYear_1000068", incrementPercentString[i])))) // #autoLOC_AmpYear_1000068 = Transfer <<1>> of Reserve Power to Mains EC
TransferReserveToMain(TotalReservePowerCapacity * _reserveTransferIncrements[i]);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000069"), Localizer.Format("#autoLOC_AmpYear_1000070"))); // #autoLOC_AmpYear_1000069 = XFer Main to Reserve // #autoLOC_AmpYear_1000070 = Transfer a percentage of Main Power to Reserve Power
for (int i = 0; i < _reserveTransferIncrements.Length; i++)
{
if (GUILayout.Button(new GUIContent(incrementPercentString[i], Localizer.Format("#autoLOC_AmpYear_1000071", incrementPercentString[i])))) // #autoLOC_AmpYear_1000071 = Transfer <<1>> of Mains EC to Reserve Power
TransferMainToReserve(TotalReservePowerCapacity * _reserveTransferIncrements[i]);
}
GUILayout.EndHorizontal();
GUI.enabled = true;
}
if (GuiSectionEnabled(GUISection.RESERVE))
{
//if (_rt2Present && !RT2UnderControl) GUI.enabled = false;
GUILayout.BeginHorizontal();
_lockReservePower = GUILayout.Toggle(_lockReservePower, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000072"), Localizer.Format("#autoLOC_AmpYear_1000073")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000072 = Isolate Reserve Power // #autoLOC_AmpYear_1000073 = Isolation Switch for Reserve Power, ReservePower will not be used if this switch is on
GUILayout.EndHorizontal();
GUI.enabled = true;
}
//ShowCrew
if (_showCrew)
{
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000074"), Textures.SectionTitleStyle); // #autoLOC_AmpYear_1000074 = Crew
//VslRstr = FlightGlobals.ActiveVessel.GetVesselCrew();
if (VslRstr.Count > 0)
{
for (int i = VslRstr.Count - 1; i >= 0; --i)
{
GUILayout.Label(VslRstr[i].name + " - " + VslRstr[i].experienceTrait.Title, Textures.StatusStyleLeft);
}
}
else //if (timewarpIsValid)
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000075"), Textures.WarningStyleLeft); // #autoLOC_AmpYear_1000075 = No Crew OnBoard
}
GUILayout.EndVertical();
if (AYsettings.TooltipsOn)
Utilities.SetTooltipText();
GUI.DragWindow();
}
private void WindowE(int id)
{
_iconAlertState = IconAlertState.GREEN;
GUIContent closeContent = new GUIContent(Textures.BtnRedCross, Localizer.Format("#autoLOC_AmpYear_1000007")); // #autoLOC_AmpYear_1000007 = Close Window
Rect closeRect = new Rect(_ewindowPos.width - 21, 4, 16, 16);
if (GUI.Button(closeRect, closeContent, Textures.PartListbtnStyle))
{
AYMenuAppLToolBar.onAppLaunchToggle();
return;
}
AYsettings.showSI = GUI.Toggle(new Rect(_ewindowPos.width - 45, 4, 16, 16), AYsettings.showSI, new GUIContent(Textures.BtnIS, Localizer.Format("#autoLOC_AmpYear_1000008")), Textures.PartListbtnStyle); // #autoLOC_AmpYear_1000008 = Toggle the display to use EC or SI units
GUILayout.BeginVertical();
//Manager status+drain
GUILayout.BeginHorizontal();
_managerEnabled = GUILayout.Toggle(_managerEnabled, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000011"), Localizer.Format("#autoLOC_AmpYear_1000012")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000011 = Manager // #autoLOC_AmpYear_1000012 = Turn on to Enable the AmpYear Management Unit
if (ManagerIsActive)
ConsumptionLabel(ManagerCurrentDrain, false);
else
ConsumptionLabel(managerActiveDrain, true);
GUILayout.EndHorizontal();
_showParts = GUILayout.Toggle(_showParts, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000056"), Localizer.Format("#autoLOC_AmpYear_1000057")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000056 = ShowParts // #autoLOC_AmpYear_1000057 = Show all the Parts and PartModules list in the current vessel
tmpShowDarkSideWindow = ShowDarkSideWindow;
ShowDarkSideWindow = GUILayout.Toggle(ShowDarkSideWindow, new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000058"), Localizer.Format("#autoLOC_AmpYear_1000059")), Textures.SubsystemButtonStyle, SubsystemButtonOptions); // #autoLOC_AmpYear_1000058 = Dark-Side & Solar Calcs // #autoLOC_AmpYear_1000059 = Open the Dark-Side and Solar Panel SOI Calculator
if (tmpShowDarkSideWindow != ShowDarkSideWindow)
{
AYVesselPartLists.ResetSolarPartToggles();
}
//ShowSOIWindow = GUILayout.Toggle(ShowSOIWindow, new GUIContent("Select Solar Panel SOI", "Open the Solar Panel SOI Selector"), Textures.SubsystemButtonStyle, SubsystemButtonOptions);
//Power Capacity
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalElectricChargeCapacity, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.00") + Units;
}
else
{
tmpPrtPower = TotalElectricChargeCapacity.ToString("0.00");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000076", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000077")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000076 = Power Capacity: // #autoLOC_AmpYear_1000077 = Total Power Capacity of this vessel
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalPowerDrain, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.00") + Units;
}
else
{
tmpPrtPower = TotalPowerDrain.ToString("0.00");
}
if (TotalPowerDrain > TotalPowerProduced)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000015", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000016")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000015 = Power Drain : // #autoLOC_AmpYear_1000016 = The Total Power Drain on this vessel
SetIconalertstate(IconAlertState.RED);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000015", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000016")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000015 = Power Drain : // #autoLOC_AmpYear_1000016 = The Total Power Drain on this vessel
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalPowerProduced, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.00") + Units;
}
else
{
tmpPrtPower = TotalPowerProduced.ToString("0.00");
}
if (TotalPowerProduced > 0)
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000017", tmpPrtPower), Textures.StatusStyleLeft); //#autoLOC_AmpYear_1000017 = Power Prod : <<1>>
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000017", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000018")), Textures.AlertStyleLeft); // #autoLOC_AmpYear_1000017 = Power Prod : // #autoLOC_AmpYear_1000018 = The Total Power Production of this vessel
SetIconalertstate(IconAlertState.YELLOW);
}
//Time Remaining in Main batteries
double timeRemainMains = TotalElectricCharge / TotalPowerDrain;
if (timeRemainMains < 300) //5 mins
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000078")), Textures.AlertStyleLeft); //#autoLOC_AmpYear_1000019 = Mains Time: <<1>> // #autoLOC_AmpYear_1000078 = The time remaining of Main EC stored based on current power production and usage
SetIconalertstate(IconAlertState.RED);
}
else
{
if (timeRemainMains < 1800) //30 mins
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000078")), Textures.WarningStyleLeft); //#autoLOC_AmpYear_1000019 = Mains Time: <<1>> // #autoLOC_AmpYear_1000078 = The time remaining of Main EC stored based on current power production and usage
SetIconalertstate(IconAlertState.YELLOW);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000019", KSPUtil.PrintTimeCompact((int)timeRemainMains, false)), Localizer.Format("#autoLOC_AmpYear_1000078")), Textures.StatusStyleLeft); //#autoLOC_AmpYear_1000019 = Mains Time: <<1>> // #autoLOC_AmpYear_1000078 = The time remaining of Main EC stored based on current power production and usage
}
//Time Remaining in Reserver Batteries
double timeRemainReserve = TotalReservePower / TotalPowerDrain;
if (timeRemainReserve < 30)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000021", KSPUtil.PrintTimeCompact((int)timeRemainReserve, false)), Localizer.Format("#autoLOC_AmpYear_1000079")), Textures.AlertStyleLeft); //#autoLOC_AmpYear_1000021 = Reserve Time: <<1>> // #autoLOC_AmpYear_1000079 = The time remaining of Main EC stored based on current power production and usage
SetIconalertstate(IconAlertState.YELLOW);
}
else
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000021", KSPUtil.PrintTimeCompact((int)timeRemainReserve, false)), Localizer.Format("#autoLOC_AmpYear_1000079")), Textures.StatusStyleLeft); //#autoLOC_AmpYear_1000021 = Reserve Time: <<1>> // #autoLOC_AmpYear_1000079 = The time remaining of Main EC stored based on current power production and usage
//Reserve
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000061"), Textures.SectionTitleStyle); //#autoLOC_AmpYear_1000061 = Reserve Power
//Reserve status label
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(TotalReservePowerCapacity, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("0.00") + Units;
}
else
{
tmpPrtPower = TotalReservePowerCapacity.ToString("0.00");
}
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000080", tmpPrtPower), Localizer.Format("#autoLOC_AmpYear_1000081")), Textures.StatusStyleLeft); // #autoLOC_AmpYear_1000080 = Reserve Capacity: // #autoLOC_AmpYear_1000081 = The total capacity of ReservePower of the current vessel
GUILayout.EndVertical();
if (AYsettings.TooltipsOn)
Utilities.SetTooltipText();
GUI.DragWindow();
}
private void WindowScrollParts(int id)
{
GUIContent closeContent = new GUIContent(Textures.BtnRedCross, Localizer.Format("#autoLOC_AmpYear_1000007")); //#autoLOC_AmpYear_1000007 = Close Window
Rect closeRect = new Rect(_epLwindowPos.width - 21, 4, 16, 16);
if (GUI.Button(closeRect, closeContent, Textures.PartListbtnStyle))
{
_showParts = false;
return;
}
//Rect showSIRect = new Rect(_epLwindowPos.width - 45, 4, 16, 16);
AYsettings.showSI = GUI.Toggle(new Rect(_epLwindowPos.width - 45, 4, 16, 16), AYsettings.showSI, new GUIContent(Textures.BtnIS, Localizer.Format("#autoLOC_AmpYear_1000008")), Textures.PartListbtnStyle); // #autoLOC_AmpYear_1000008 = Toggle the display to use EC or SI units
GUILayout.BeginVertical();
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000082"), Textures.PartListStyle); // #autoLOC_AmpYear_1000082 = Power Production Parts
GUILayout.BeginHorizontal();
GUILayout.Label("", Textures.PartListpartHeadingStyle, GUILayout.Width(5));
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000083"), Localizer.Format("#autoLOC_AmpYear_1000084")), Textures.PartListpartHeadingStyle, GUILayout.Width(28)); // #autoLOC_AmpYear_1000083 = Calc // #autoLOC_AmpYear_1000084 = If on, this PartModule will be Included in AmpYear Power Calculations
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000085"), Localizer.Format("#autoLOC_AmpYear_1000086")), Textures.PartListpartHeadingStyle, GUILayout.Width(24)); // #autoLOC_AmpYear_1000085 = ESP // #autoLOC_AmpYear_1000086 = If on, this PartModule will be Included in Emergency Shutdown Procedures
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000087"), Localizer.Format("#autoLOC_AmpYear_1000088")), Textures.PartListpartHeadingStyle, GUILayout.Width(80)); // #autoLOC_AmpYear_1000087 = Priority // #autoLOC_AmpYear_1000088 = PartModule Priority in Emergency Shutdown Procedures
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000089"), Localizer.Format("#autoLOC_AmpYear_1000090")), Textures.PartListpartHeadingStyle, GUILayout.Width(_eplPartName)); // #autoLOC_AmpYear_1000089 = PartTitle // #autoLOC_AmpYear_1000090 = The Title of the Part
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000091"), Localizer.Format("#autoLOC_AmpYear_1000092")), Textures.PartListpartHeadingStyle, GUILayout.Width(_eplPartModuleName)); // #autoLOC_AmpYear_1000091 = Module // #autoLOC_AmpYear_1000092 = The name of the PartModule
if (!AYsettings.showSI)
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000093"), Localizer.Format("#autoLOC_AmpYear_1000094")),Textures.PartListpartHeadingStyle, GUILayout.Width(_eplec)); // #autoLOC_AmpYear_1000093 = EC // #autoLOC_AmpYear_1000094 = Electric Charge produced by this PartModule
}
else
{
GUILayout.Label(new GUIContent(Localizer.Format("#autoLOC_AmpYear_1000095"), Localizer.Format("#autoLOC_AmpYear_1000096")), Textures.PartListpartHeadingStyle, GUILayout.Width(_eplec)); // #autoLOC_AmpYear_1000095 = SI // #autoLOC_AmpYear_1000096 = Electric Charge produced by this PartModule, in Système international Units
}
//AYsettings.showSI = GUILayout.Toggle(AYsettings.showSI, new GUIContent("Units", "Toggle the display to use EC or SI units"), Textures.SubsystemButtonStyle, SubsystemButtonOptions);
GUILayout.EndHorizontal();
// Begin the ScrollView
_plProdscrollViewVector = GUILayout.BeginScrollView(_plProdscrollViewVector, true, true, GUILayout.Height(_eplProdListHeight));
// Put something inside the ScrollView
if (AYVesselPartLists.VesselProdPartsList.Count == 0)
GUILayout.Label(Localizer.Format("#autoLOC_AmpYear_1000097"), Textures.PartListPartStyle); // #autoLOC_AmpYear_1000097 = No Power Producing Parts
_totalProdPower = 0f;
foreach (var entry in AYVesselPartLists.VesselProdPartsList)
{
partModuleName = string.Empty;
tmpPartKey = AYVesselPartLists.GetPartKeyVals(entry.Key, out partModuleName);
partModuleName = Utilities.RemoveSubStr(partModuleName, "Module");
if (entry.Value.PrtEditorInclude)
_totalProdPower += entry.Value.PrtPowerF;
if (ShowDarkSideWindow && entry.Value.PrtSolarDependant)
{
GUI.enabled = false;
entry.Value.PrtEditorInclude = false;
GUILayout.BeginHorizontal();
bool tmpPrtEditorInclude = GUILayout.Toggle(entry.Value.PrtEditorInclude,
new GUIContent(Textures.BtnIncInCalcs, Localizer.Format("#autoLOC_AmpYear_1000098")), Textures.PartListbtnStyle, GUILayout.Width(20)); // #autoLOC_AmpYear_1000098 = Include this PartModule in AmpYear Calcs
entry.Value.PrtEditorInclude = tmpPrtEditorInclude;
bool tmpPrtEmergShutDnInclude = GUILayout.Toggle(entry.Value.PrtEmergShutDnInclude,
new GUIContent(Textures.BtnEspInc, Localizer.Format("#autoLOC_AmpYear_1000099")), Textures.PartListbtnStyle, GUILayout.Width(20)); // #autoLOC_AmpYear_1000099 = Include this PartModule in Emergency Shutdown Procedures
entry.Value.PrtEmergShutDnInclude = tmpPrtEmergShutDnInclude;
List<GUIContent> tmpList = new List<GUIContent>();
tmpList.Add(new GUIContent(Textures.BtnPriority1, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000100") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000100 = Emergency Shutdown Procedures - Priority One // #autoLOC_AmpYear_1000101 = Part not Supported by Emergency Shutdown Procedure
tmpList.Add(new GUIContent(Textures.BtnPriority2, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000102") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000102 = Emergency Shutdown Procedures - Priority Two
tmpList.Add(new GUIContent(Textures.BtnPriority3, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000103") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000103 = Emergency Shutdown Procedures - Priority Three
GUIContent[] tmpToggles = tmpList.ToArray();
List<GUIStyle> tmpStylesList = new List<GUIStyle>();
tmpStylesList.Add(Textures.PartListbtnStyle);
tmpStylesList.Add(Textures.PartListbtnStyle);
tmpStylesList.Add(Textures.PartListbtnStyle);
GUIStyle[] tmpStylesToggles = tmpStylesList.ToArray();
int tmpESPPriority = Utilities.ToggleList((int)entry.Value.PrtEmergShutDnPriority - 1, tmpToggles, tmpStylesToggles, 20);
entry.Value.PrtEmergShutDnPriority = (ESPPriority)(tmpESPPriority + 1);
GUILayout.Label(entry.Value.PrtTitle, entry.Value.PrtEditorInclude ? Textures.PartListPartStyle : Textures.PartListPartGrayStyle, GUILayout.Width(_eplPartName));
if (GUILayout.Button(partModuleName, entry.Value.HighlightOn ? Textures.PartListProdPartHighlightStyle :
entry.Value.PrtEditorInclude ? Textures.PartListPartStyle : Textures.PartListPartGrayStyle,
GUILayout.Width(_eplPartModuleName)))
{
if (entry.Value.PrtReference == null)
{
findPartReference(entry.Value);
}
if (entry.Value.PrtReference != null)
{
togglePartHighlight(entry.Value);
}
}
if (entry.Value.PrtReference != null)
{
setPartHighlight(entry.Value, true); //Set Part Highlight
}
if (AYsettings.showSI)
{
tmpPrtPowerV = Utilities.ConvertECtoSI(entry.Value.PrtPowerF, out Units);
tmpPrtPower = tmpPrtPowerV.ToString("####0.###") + Units;
}
else
{
tmpPrtPower = entry.Value.PrtPower;
}
GUILayout.Label(tmpPrtPower, entry.Value.PrtEditorInclude ? Textures.PartListPartStyle : Textures.PartListPartGrayStyle, GUILayout.Width(_eplec));
GUILayout.EndHorizontal();
GUI.enabled = true;
}
else
{
GUILayout.BeginHorizontal();
tmpPrtEditorInclude = GUILayout.Toggle(entry.Value.PrtEditorInclude,
new GUIContent(Textures.BtnIncInCalcs, Localizer.Format("#autoLOC_AmpYear_1000104")), Textures.PartListbtnStyle, GUILayout.Width(20)); // #autoLOC_AmpYear_1000104 = Include this PartModule in AmpYear Calcs
entry.Value.PrtEditorInclude = tmpPrtEditorInclude;
if (!entry.Value.ValidprtEmergShutDn)
GUI.enabled = false;
tmpPrtEmergShutDnInclude = GUILayout.Toggle(entry.Value.PrtEmergShutDnInclude,
new GUIContent(Textures.BtnEspInc, GUI.enabled ? Localizer.Format("#autoLOC_AmpYear_1000099") : Localizer.Format("#autoLOC_AmpYear_1000101")), Textures.PartListbtnStyle, GUILayout.Width(20)); // #autoLOC_AmpYear_1000099 = Include this PartModule in Emergency Shutdown Procedures // #autoLOC_AmpYear_1000101 = Part not Supported by Emergency Shutdown Procedure
entry.Value.PrtEmergShutDnInclude = tmpPrtEmergShutDnInclude;
List<GUIContent> tmpList = new List<GUIContent>();
tmpList.Add(new GUIContent(Textures.BtnPriority1, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000100") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000100 = Emergency Shutdown Procedures - Priority One // #autoLOC_AmpYear_1000101 = Part not Supported by Emergency Shutdown Procedure
tmpList.Add(new GUIContent(Textures.BtnPriority2, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000102") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000102 = Emergency Shutdown Procedures - Priority Two
tmpList.Add(new GUIContent(Textures.BtnPriority3, entry.Value.ValidprtEmergShutDn ? Localizer.Format("#autoLOC_AmpYear_1000103") : Localizer.Format("#autoLOC_AmpYear_1000101"))); // #autoLOC_AmpYear_1000103 = Emergency Shutdown Procedures - Priority Three
GUIContent[] tmpToggles = tmpList.ToArray();
List<GUIStyle> tmpStylesList = new List<GUIStyle>();
tmpStylesList.Add(Textures.PartListbtnStyle);
tmpStylesList.Add(Textures.PartListbtnStyle);
tmpStylesList.Add(Textures.PartListbtnStyle);
GUIStyle[] tmpStylesToggles = tmpStylesList.ToArray();
tmpESPPriority = Utilities.ToggleList((int)entry.Value.PrtEmergShutDnPriority - 1, tmpToggles, tmpStylesToggles, 20);
entry.Value.PrtEmergShutDnPriority = (ESPPriority)(tmpESPPriority + 1);
GUI.enabled = true;
GUILayout.Label(entry.Value.PrtTitle, entry.Value.PrtEditorInclude ? Textures.PartListPartStyle : Textures.PartListPartGrayStyle, GUILayout.Width(_eplPartName));
if (GUILayout.Button(partModuleName, entry.Value.HighlightOn ? Textures.PartListProdPartHighlightStyle :
entry.Value.PrtEditorInclude ? Textures.PartListPartStyle : Textures.PartListPartGrayStyle,
GUILayout.Width(_eplPartModuleName)))
{
if (entry.Value.PrtReference == null)
{
findPartReference(entry.Value);
}
if (entry.Value.PrtReference != null)