/
MechJebModuleRendezvousAutopilotWindow.cs
86 lines (69 loc) · 3.27 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
75
76
77
78
79
80
81
82
83
84
85
86
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);
}
public override GUILayoutOption[] WindowOptions()
{
return new[] { GUILayout.Width(300), GUILayout.Height(50) };
}
public override string GetName()
{
return Localizer.Format("#MechJeb_RZauto_title"); //"Rendezvous Autopilot"
}
public override string IconName()
{
return "Rendezvous Autopilot";
}
public override bool IsSpaceCenterUpgradeUnlocked()
{
return vessel.patchedConicsUnlocked();
}
}
}