/
MechJebModuleSettings.cs
148 lines (116 loc) · 5.6 KB
/
MechJebModuleSettings.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
using KSP.IO;
using KSP.Localization;
using UnityEngine;
namespace MuMech
{
public class MechJebModuleSettings : DisplayModule
{
public MechJebModuleSettings(MechJebCore core) : base(core)
{
ShowInEditor = true;
ShowInFlight = true;
}
// Kept for old conf compatibility
[Persistent(pass = (int)Pass.Global)]
public bool useOldSkin;
[Persistent(pass = (int)Pass.Global)]
public int skinId = 2;
[Persistent(pass = (int)Pass.Global)]
public EditableDouble UIScale = 1.0;
[Persistent(pass = (int)Pass.Global)]
public bool dontUseDropDownMenu;
[ToggleInfoItem("#MechJeb_hideBrakeOnEject", InfoItem.Category.Misc)]
[Persistent(pass = (int)Pass.Global)] //Hide 'Brake on Eject' in Rover Controller
public bool hideBrakeOnEject = false;
[ToggleInfoItem("#MechJeb_useTitlebarDragging", InfoItem.Category.Misc)]
[Persistent(pass = (int)Pass.Global)] //Use only the titlebar for window dragging
public bool useTitlebarDragging = false;
[ToggleInfoItem("#MechJeb_rssMode", InfoItem.Category.Misc)]
[Persistent(pass = (int)Pass.Global)] //Module disabling does not kill throttle (RSS/RO)
public bool rssMode = false;
[Persistent(pass = (int)Pass.Global)]
public bool showAdvancedWindowSettings;
public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global)
{
base.OnLoad(local, type, global);
GuiUtils.SetGUIScale(UIScale.val);
GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu;
if (useOldSkin)
{
skinId = 1;
useOldSkin = false;
}
}
protected override void WindowGUI(int windowID)
{
GUILayout.BeginVertical();
if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button1"))) //"\nRestore factory default settings\n"
{
FileInfo.CreateForType<MechJebCore>("mechjeb_settings_global.cfg").Delete();
if (vessel != null && vessel.vesselName != null)
FileInfo.CreateForType<MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
core.ReloadAllComputerModules();
GuiUtils.SetGUIScale(1);
}
GUILayout.Label(Localizer.Format("#MechJeb_Settings_label1", (GuiUtils.SkinType)skinId)); //"Current skin: <<1>>"
if (GuiUtils.skin == null || skinId != 1)
{
if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button2"))) //"Use MechJeb 1 GUI skin"
{
GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
skinId = 1;
}
}
if (GuiUtils.skin == null || skinId != 0)
{
if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button3"))) //"Use MechJeb 2 GUI skin"
{
GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
skinId = 0;
}
}
if (GuiUtils.skin == null || skinId != 2)
{
if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button4"))) //"Use MJ2 Compact GUI skin"
{
GuiUtils.LoadSkin(GuiUtils.SkinType.Compact);
skinId = 2;
}
}
GUILayout.BeginHorizontal();
GUILayout.Label(Localizer.Format("#MechJeb_Settings_label2"), GUILayout.ExpandWidth(true)); //"UI Scale:"
UIScale.text = GUILayout.TextField(UIScale.text, GUILayout.Width(60));
GUILayout.EndHorizontal();
GuiUtils.SetGUIScale(UIScale.val);
dontUseDropDownMenu =
GUILayout.Toggle(dontUseDropDownMenu, Localizer.Format("#MechJeb_Settings_checkbox1")); //"Replace drop down menu with arrow selector"
GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu;
showAdvancedWindowSettings = GUILayout.Toggle(showAdvancedWindowSettings, "Show Advanced Window Settings");
GuiUtils.showAdvancedWindowSettings = showAdvancedWindowSettings;
MechJebModuleCustomWindowEditor ed = core.GetComputerModule<MechJebModuleCustomWindowEditor>();
ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Settings.useTitlebarDragging").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Menu.useAppLauncher").DrawItem();
if (ToolbarManager.ToolbarAvailable || core.GetComputerModule<MechJebModuleMenu>().useAppLauncher)
ed.registry.Find(i => i.id == "Toggle:Menu.hideButton").DrawItem();
ed.registry.Find(i => i.id == "General:Menu.MenuPosition").DrawItem();
ed.registry.Find(i => i.id == "Toggle:Settings.rssMode").DrawItem();
core.warp.activateSASOnWarp =
GUILayout.Toggle(core.warp.activateSASOnWarp, Localizer.Format("#MechJeb_Settings_checkbox2")); //"Activate SAS on Warp"
GUILayout.EndVertical();
base.WindowGUI(windowID);
}
public override string GetName()
{
return Localizer.Format("#MechJeb_Settings_title"); //"Settings"
}
public override string IconName()
{
return "Settings";
}
public override GUILayoutOption[] WindowOptions()
{
return new[] { GUILayout.Width(200), GUILayout.Height(100) };
}
}
}