/
MechJebModuleRendezvousAutopilotWindow.cs
74 lines (57 loc) · 3.13 KB
/
MechJebModuleRendezvousAutopilotWindow.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
using JetBrains.Annotations;
using KSP.Localization;
using UnityEngine;
namespace MuMech
{
[UsedImplicitly]
public class MechJebModuleRendezvousAutopilotWindow : DisplayModule
{
public MechJebModuleRendezvousAutopilotWindow(MechJebCore core) : base(core) { }
protected override void WindowGUI(int windowID)
{
if (!Core.Target.NormalTargetExists)
{
GUILayout.Label(Localizer.Format("#MechJeb_RZauto_label1")); //"Select a target to rendezvous with."
base.WindowGUI(windowID);
return;
}
MechJebModuleRendezvousAutopilot autopilot = Core.GetComputerModule<MechJebModuleRendezvousAutopilot>();
if (Core.Target.TargetOrbit.referenceBody != Orbit.referenceBody)
{
GUILayout.Label(Localizer.Format("#MechJeb_RZauto_label2")); //"Rendezvous target must be in the same sphere of influence."
if (autopilot.Enabled)
autopilot.Users.Remove(this);
base.WindowGUI(windowID);
return;
}
GUILayout.BeginVertical();
if (autopilot != null)
{
GuiUtils.SimpleLabel(Localizer.Format("#MechJeb_RZauto_label3"), Core.Target.Name); //"Rendezvous target"
if (!autopilot.Enabled)
{
if (GUILayout.Button(Localizer.Format("#MechJeb_RZauto_button1"))) autopilot.Users.Add(this); //"Engage autopilot"
}
else
{
if (GUILayout.Button(Localizer.Format("#MechJeb_RZauto_button2"))) autopilot.Users.Remove(this); //"Disengage autopilot"
}
GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RZauto_label4"), autopilot.desiredDistance, "m"); //"Desired final distance:"
GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RZauto_label5"), autopilot.maxPhasingOrbits); //"Max # of phasing orbits:"
GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RZauto_label8"), autopilot.maxClosingSpeed, "m/s"); //"Max closing velocity:"
if (autopilot.maxPhasingOrbits < 5)
{
GUILayout.Label(Localizer.Format("#MechJeb_RZauto_label6"), GuiUtils.yellowLabel); //"Max # of phasing orbits must be at least 5."
}
if (autopilot.Enabled) GUILayout.Label(Localizer.Format("#MechJeb_RZauto_label7", autopilot.status)); //"Status: <<1>>"
}
Core.Node.Autowarp = GUILayout.Toggle(Core.Node.Autowarp, Localizer.Format("#MechJeb_RZauto_checkbox1")); //"Auto-warp"
GUILayout.EndVertical();
base.WindowGUI(windowID);
}
protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(50) };
public override string GetName() => Localizer.Format("#MechJeb_RZauto_title"); //"Rendezvous Autopilot"
public override string IconName() => "Rendezvous Autopilot";
protected override bool IsSpaceCenterUpgradeUnlocked() => Vessel.patchedConicsUnlocked();
}
}