/
MechJebModuleAscentSettingsMenu.cs
132 lines (110 loc) · 6.08 KB
/
MechJebModuleAscentSettingsMenu.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
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Profiling;
namespace MuMech
{
[UsedImplicitly]
public class MechJebModuleAscentSettingsMenu : DisplayModule
{
public MechJebModuleAscentSettingsMenu(MechJebCore core) : base(core)
{
Hidden = true;
}
private MechJebModuleAscentSettings _ascentSettings => Core.AscentSettings;
private MechJebModuleAscentBaseAutopilot _autopilot => Core.Ascent;
private readonly string _climbString = $"{CachedLocalizer.Instance.MechJebAscentLabel22}: ";
private readonly string _turnString = $"{CachedLocalizer.Instance.MechJebAscentLabel23}: ";
private void ShowAscentSettingsGUIElements()
{
Profiler.BeginSample("MJ.GUIWindow.AscentItems");
GUILayout.BeginVertical(GUI.skin.box);
Core.Thrust.LimitToPreventOverheatsInfoItem();
Core.Thrust.LimitToMaxDynamicPressureInfoItem();
Core.Thrust.LimitAccelerationInfoItem();
if (_ascentSettings.AscentType != AscentType.PVG) Core.Thrust.LimitThrottleInfoItem();
Core.Thrust.LimiterMinThrottleInfoItem();
if (_ascentSettings.AscentType != AscentType.PVG) Core.Thrust.LimitElectricInfoItem();
if (_ascentSettings.AscentType == AscentType.PVG)
{
Core.Thrust.LimitThrottle = false;
Core.Thrust.LimitToTerminalVelocity = false;
Core.Thrust.ElectricThrottle = false;
}
_ascentSettings.ForceRoll = GUILayout.Toggle(_ascentSettings.ForceRoll, CachedLocalizer.Instance.MechJebAscentCheckbox2); //Force Roll
if (_ascentSettings.ForceRoll)
{
GUILayout.BeginHorizontal();
GUILayout.Space(15);
GuiUtils.SimpleTextBox(_climbString, _ascentSettings.VerticalRoll, "º", 30); //climb
GuiUtils.SimpleTextBox(_turnString, _ascentSettings.TurnRoll, "º", 30); //turn
GuiUtils.SimpleTextBox("Alt: ", _ascentSettings.RollAltitude, "m", 30);
GUILayout.EndHorizontal();
}
if (_ascentSettings.AscentType != AscentType.PVG)
{
GUIStyle s = _ascentSettings.LimitingAoA ? GuiUtils.greenToggle : null;
string sCurrentMaxAoA = $"º ({_autopilot.CurrentMaxAoA:F1}°)";
GuiUtils.ToggledTextBox(ref _ascentSettings.LimitAoA, CachedLocalizer.Instance.MechJebAscentCheckbox3, _ascentSettings.MaxAoA,
sCurrentMaxAoA, s,
30); //Limit AoA to
if (_ascentSettings.LimitAoA)
{
GUILayout.BeginHorizontal();
GUILayout.Space(25);
GUIStyle sl = _ascentSettings.LimitingAoA && VesselState.dynamicPressure < _ascentSettings.AOALimitFadeoutPressure
? GuiUtils.greenLabel
: GuiUtils.skin.label;
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel24, _ascentSettings.AOALimitFadeoutPressure, "Pa", 50,
sl); //Dynamic Pressure Fadeout
GUILayout.EndHorizontal();
}
_ascentSettings.LimitQaEnabled = false; // this is only for PVG
}
if (_ascentSettings.AscentType == AscentType.CLASSIC)
{
// corrective steering only applies to Classic
GUILayout.BeginHorizontal();
_ascentSettings.CorrectiveSteering = GUILayout.Toggle(_ascentSettings.CorrectiveSteering,
CachedLocalizer.Instance.MechJebAscentCheckbox4,
GuiUtils.ExpandWidth(false)); //Corrective steering
if (_ascentSettings.CorrectiveSteering)
GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel25, _ascentSettings.CorrectiveSteeringGain, width: 40,
horizontalFraming: false); // Gain
GUILayout.EndHorizontal();
}
_ascentSettings.Autostage = GUILayout.Toggle(_ascentSettings.Autostage, CachedLocalizer.Instance.MechJebAscentCheckbox5); //Autostage
if (_ascentSettings.Autostage) Core.Staging.AutostageSettingsInfoItem();
_ascentSettings.AutodeploySolarPanels =
GUILayout.Toggle(_ascentSettings.AutodeploySolarPanels, CachedLocalizer.Instance.MechJebAscentCheckbox6); //Auto-deploy solar panels
_ascentSettings.AutoDeployAntennas =
GUILayout.Toggle(_ascentSettings.AutoDeployAntennas, CachedLocalizer.Instance.MechJebAscentCheckbox7); //Auto-deploy antennas
GUILayout.BeginHorizontal();
Core.Node.Autowarp = GUILayout.Toggle(Core.Node.Autowarp, CachedLocalizer.Instance.MechJebAscentCheckbox8); //Auto-warp
if (_ascentSettings.AscentType != AscentType.PVG)
{
_ascentSettings.SkipCircularization =
GUILayout.Toggle(_ascentSettings.SkipCircularization, CachedLocalizer.Instance.MechJebAscentCheckbox9); //Skip Circularization
}
else
{
// skipCircularization is always true for Optimizer
_ascentSettings.SkipCircularization = true;
}
GUILayout.EndHorizontal();
if (_ascentSettings.AscentType == AscentType.PVG)
Core.Settings.rssMode = GUILayout.Toggle(Core.Settings.rssMode, "Module disabling does not kill throttle");
GUILayout.EndVertical();
Profiler.EndSample();
}
protected override void WindowGUI(int windowID)
{
GUILayout.BeginVertical();
ShowAscentSettingsGUIElements();
GUILayout.EndVertical();
base.WindowGUI(windowID);
}
protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(275), GUILayout.Height(30) };
public override string GetName() => "Ascent Settings";
public override string IconName() => "Ascent Settings";
}
}