From 4bff46668dc1988b8b8663887a629a4d4eed0a45 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 30 Oct 2023 10:39:22 -0700 Subject: [PATCH] DisplayModule cleanup Signed-off-by: Lamont Granquist --- MechJeb2/DisplayModule.cs | 238 ++++++++---------- MechJeb2/GuiUtils.cs | 4 +- MechJeb2/MechJebAR202.cs | 2 +- MechJeb2/MechJebCore.cs | 10 +- MechJeb2/MechJebModuleAirplaneGuidance.cs | 2 +- .../MechJebModuleAscentClassicPathMenu.cs | 4 +- MechJeb2/MechJebModuleAscentMenu.cs | 2 +- .../MechJebModuleAscentPVGSettingsMenu.cs | 4 +- MechJeb2/MechJebModuleAscentSettingsMenu.cs | 4 +- MechJeb2/MechJebModuleAttitudeAdjustment.cs | 2 +- MechJeb2/MechJebModuleCustomInfoWindow.cs | 28 +-- MechJeb2/MechJebModuleDockingGuidance.cs | 2 +- MechJeb2/MechJebModuleFlightRecorderGraph.cs | 63 ++--- MechJeb2/MechJebModuleLandingGuidance.cs | 2 +- MechJeb2/MechJebModuleManeuverPlanner.cs | 2 +- MechJeb2/MechJebModuleMenu.cs | 50 ++-- MechJeb2/MechJebModuleNodeEditor.cs | 2 +- MechJeb2/MechJebModuleRCSBalancerWindow.cs | 2 +- .../MechJebModuleRendezvousAutopilotWindow.cs | 2 +- MechJeb2/MechJebModuleRendezvousGuidance.cs | 2 +- MechJeb2/MechJebModuleRoverWindow.cs | 4 +- MechJeb2/MechJebModuleSettings.cs | 2 +- MechJeb2/MechJebModuleSmartASS.cs | 2 +- MechJeb2/MechJebModuleSmartRcs.cs | 2 +- MechJeb2/MechJebModuleSpaceplaneGuidance.cs | 2 +- MechJeb2/MechJebModuleThrustController.cs | 4 +- MechJeb2/MechJebModuleThrustWindow.cs | 4 +- MechJeb2/MechJebModuleTranslatron.cs | 8 +- MechJeb2/MechJebModuleWarpHelper.cs | 4 +- MechJeb2/MechJebModuleWaypointWindow.cs | 10 +- 30 files changed, 227 insertions(+), 242 deletions(-) diff --git a/MechJeb2/DisplayModule.cs b/MechJeb2/DisplayModule.cs index 7248d9ae..672c9267 100644 --- a/MechJeb2/DisplayModule.cs +++ b/MechJeb2/DisplayModule.cs @@ -6,17 +6,15 @@ namespace MuMech { public class DisplayModule : ComputerModule { - public bool hidden; + public bool Hidden; - public Rect windowPos + public Rect WindowPos { - get - { - if (!HighLogic.LoadedSceneIsEditor) - return new Rect(windowVector.x, windowVector.y, windowVector.z, windowVector.w); - return new Rect(windowVectorEditor.x, windowVectorEditor.y, windowVectorEditor.z, windowVectorEditor.w); - } - set + get => !HighLogic.LoadedSceneIsEditor + ? new Rect(_windowVector.x, _windowVector.y, _windowVector.z, _windowVector.w) + : new Rect(_windowVectorEditor.x, _windowVectorEditor.y, _windowVectorEditor.z, _windowVectorEditor.w); + + protected set { var newPos = new Vector4( Math.Min(Math.Max(value.x, 0), GuiUtils.scaledScreenWidth - value.width), @@ -28,18 +26,18 @@ public Rect windowPos if (!HighLogic.LoadedSceneIsEditor) { - if (windowVector != newPos) + if (_windowVector != newPos) { - Dirty = true; - windowVector = newPos; + Dirty = true; + _windowVector = newPos; } } else { - if (windowVectorEditor != newPos) + if (_windowVectorEditor != newPos) { - Dirty = true; - windowVectorEditor = newPos; + Dirty = true; + _windowVectorEditor = newPos; } } } @@ -48,98 +46,92 @@ public Rect windowPos // Those field should be private but Persistent has a bug that prevent it to work properly on parent class private fields [Persistent(pass = (int)Pass.GLOBAL)] - public Vector4 windowVector = new Vector4(10, 40, 0, 0); //Persistence is via a Vector4 since ConfigNode doesn't know how to serialize Rects + private Vector4 _windowVector = new Vector4(10, 40, 0, 0); //Persistence is via a Vector4 since ConfigNode doesn't know how to serialize Rects [Persistent(pass = (int)Pass.GLOBAL)] - public Vector4 - windowVectorEditor = new Vector4(10, 40, 0, 0); //Persistence is via a Vector4 since ConfigNode doesn't know how to serialize Rects + private Vector4 + _windowVectorEditor = new Vector4(10, 40, 0, 0); //Persistence is via a Vector4 since ConfigNode doesn't know how to serialize Rects [Persistent(pass = (int)Pass.GLOBAL)] - public bool showInFlight = true; + private bool _showInFlight = true; public bool ShowInFlight { - get => showInFlight; + get => _showInFlight; set { - if (showInFlight != value) + if (_showInFlight != value) { - showInFlight = value; - Dirty = true; + _showInFlight = value; + Dirty = true; } } } [Persistent(pass = (int)Pass.GLOBAL)] - public bool showInEditor; + private bool _showInEditor; public bool ShowInEditor { - get => showInEditor; + get => _showInEditor; set { - if (showInEditor != value) - { - showInEditor = value; - Dirty = true; - } + if (_showInEditor == value) return; + _showInEditor = value; + Dirty = true; } } [Persistent(pass = (int)Pass.GLOBAL)] - public bool isOverlay; + private bool _isOverlay; public bool IsOverlay { - get => isOverlay; + get => _isOverlay; set { - if (isOverlay != value) - { - isOverlay = value; - Dirty = true; - } + if (_isOverlay == value) return; + _isOverlay = value; + Dirty = true; } } [Persistent(pass = (int)Pass.GLOBAL)] - public bool locked; + private bool _locked; public bool Locked { - get => locked; + get => _locked; set { - if (locked != value) - { - locked = value; - Dirty = true; - } + if (_locked == value) return; + _locked = value; + Dirty = true; } } - internal bool enabledEditor; - internal bool enabledFlight; + internal bool EnabledEditor; + internal bool EnabledFlight; - private GUILayoutOption[] windowOptions; + private GUILayoutOption[] _windowOptions; - public bool showInCurrentScene => HighLogic.LoadedSceneIsEditor ? showInEditor : showInFlight; + public bool ShowInCurrentScene => HighLogic.LoadedSceneIsEditor ? _showInEditor : _showInFlight; - public int ID; - public static int nextID = 72190852; + private readonly int _id; + private static int _nextID = 72190852; - public DisplayModule(MechJebCore core) + protected DisplayModule(MechJebCore core) : base(core) { - ID = nextID; - nextID++; + _id = _nextID; + _nextID++; } - public virtual GUILayoutOption[] WindowOptions() => new GUILayoutOption[0]; + protected virtual GUILayoutOption[] WindowOptions() => Array.Empty(); protected void WindowGUI(int windowID, bool draggable) { - if (!isOverlay && GUI.Button(new Rect(windowPos.width - 18, 2, 16, 16), "")) + if (!_isOverlay && GUI.Button(new Rect(WindowPos.width - 18, 2, 16, 16), "")) { Enabled = false; } @@ -149,20 +141,20 @@ protected void WindowGUI(int windowID, bool draggable) // locked = !locked; // } - bool allowDrag = !locked; - if (!locked && !isOverlay && Core.Settings.useTitlebarDragging) + bool allowDrag = !_locked; + if (!_locked && !_isOverlay && Core.Settings.useTitlebarDragging) { float x = Mouse.screenPos.x / GuiUtils.scale; float y = Mouse.screenPos.y / GuiUtils.scale; - allowDrag = x >= windowPos.xMin + 3 && x <= windowPos.xMin + windowPos.width - 3 && - y >= windowPos.yMin + 3 && y <= windowPos.yMin + 17; + allowDrag = x >= WindowPos.xMin + 3 && x <= WindowPos.xMin + WindowPos.width - 3 && + y >= WindowPos.yMin + 3 && y <= WindowPos.yMin + 17; } if (draggable && allowDrag) GUI.DragWindow(); } - protected void ProfiledWindowGUI(int windowID) + private void ProfiledWindowGUI(int windowID) { Profiler.BeginSample(GetType().Name); WindowGUI(windowID); @@ -173,36 +165,34 @@ protected void ProfiledWindowGUI(int windowID) public virtual void DrawGUI(bool inEditor) { - if (showInCurrentScene) - { - // Cache the array to not create one each frame - if (windowOptions == null) - windowOptions = WindowOptions(); - - windowPos = GUILayout.Window(ID, windowPos, ProfiledWindowGUI, isOverlay ? "" : GetName(), windowOptions); - - // var windows = core.GetComputerModules(); // on ice until there's a way to find which window is active, unless you like dragging other windows by snapping - // - // foreach (var w in windows) - // { - // if (w == this) { continue; } - // - // var diffL = (w.windowPos.x + w.windowPos.width - 2) - windowPos.x; - // var diffR = w.windowPos.x - (windowPos.x + windowPos.width + 2); - // var diffT = (w.windowPos.y + w.windowPos.height - 2) - windowPos.y; - // var diffB = w.windowPos.y - (windowPos.y + windowPos.height + 2); - // - // if (Math.Abs(diffL) <= 8) - // { - // SetPos(w.windowPos.x + w.windowPos.width - 2, windowPos.y); - // } - // - // if (Math.Abs(diffR) <= 8) - // { - // SetPos(w.windowPos.x - windowPos.width + 2, windowPos.y); - // } - // } - } + if (!ShowInCurrentScene) return; + + // Cache the array to not create one each frame + _windowOptions ??= WindowOptions(); + + WindowPos = GUILayout.Window(_id, WindowPos, ProfiledWindowGUI, _isOverlay ? "" : GetName(), _windowOptions); + + // var windows = core.GetComputerModules(); // on ice until there's a way to find which window is active, unless you like dragging other windows by snapping + // + // foreach (var w in windows) + // { + // if (w == this) { continue; } + // + // var diffL = (w.windowPos.x + w.windowPos.width - 2) - windowPos.x; + // var diffR = w.windowPos.x - (windowPos.x + windowPos.width + 2); + // var diffT = (w.windowPos.y + w.windowPos.height - 2) - windowPos.y; + // var diffB = w.windowPos.y - (windowPos.y + windowPos.height + 2); + // + // if (Math.Abs(diffL) <= 8) + // { + // SetPos(w.windowPos.x + w.windowPos.width - 2, windowPos.y); + // } + // + // if (Math.Abs(diffR) <= 8) + // { + // SetPos(w.windowPos.x - windowPos.width + 2, windowPos.y); + // } + // } } public override void OnSave(ConfigNode local, ConfigNode type, ConfigNode global) @@ -212,12 +202,12 @@ public override void OnSave(ConfigNode local, ConfigNode type, ConfigNode global if (global != null) { if (HighLogic.LoadedSceneIsEditor) - enabledEditor = Enabled; + EnabledEditor = Enabled; if (HighLogic.LoadedSceneIsFlight) - enabledFlight = Enabled; + EnabledFlight = Enabled; - global.AddValue("enabledEditor", enabledEditor); - global.AddValue("enabledFlight", enabledFlight); + global.AddValue("enabledEditor", EnabledEditor); + global.AddValue("enabledFlight", EnabledFlight); } // if (global != null) global.AddValue("locked", locked); } @@ -229,10 +219,9 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global bool useOldConfig = true; if (global != null && global.HasValue("enabledEditor")) { - bool loadedEnabled; - if (bool.TryParse(global.GetValue("enabledEditor"), out loadedEnabled)) + if (bool.TryParse(global.GetValue("enabledEditor"), out bool loadedEnabled)) { - enabledEditor = loadedEnabled; + EnabledEditor = loadedEnabled; useOldConfig = false; if (HighLogic.LoadedSceneIsEditor) Enabled = loadedEnabled; @@ -241,10 +230,9 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global if (global != null && global.HasValue("enabledFlight")) { - bool loadedEnabled; - if (bool.TryParse(global.GetValue("enabledFlight"), out loadedEnabled)) + if (bool.TryParse(global.GetValue("enabledFlight"), out bool loadedEnabled)) { - enabledFlight = loadedEnabled; + EnabledFlight = loadedEnabled; useOldConfig = false; if (HighLogic.LoadedSceneIsFlight) Enabled = loadedEnabled; @@ -255,15 +243,14 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global { if (global != null && global.HasValue("enabled")) { - bool loadedEnabled; - if (bool.TryParse(global.GetValue("enabled"), out loadedEnabled)) + if (bool.TryParse(global.GetValue("enabled"), out bool loadedEnabled)) { Enabled = loadedEnabled; } } - enabledEditor = Enabled; - enabledFlight = Enabled; + EnabledEditor = Enabled; + EnabledFlight = Enabled; } // if (global != null && global.HasValue("locked")) @@ -273,22 +260,20 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global // } } - private ComputerModule[] makesActive; + private ComputerModule[] _makesActive; - public virtual bool isActive() + public virtual bool IsActive() { - if (makesActive == null) - makesActive = new ComputerModule[] { Core.Attitude, Core.Thrust, Core.Rover, Core.Node, Core.RCS, Core.Rcsbal }; + _makesActive ??= new ComputerModule[] { Core.Attitude, Core.Thrust, Core.Rover, Core.Node, Core.RCS, Core.Rcsbal }; bool active = false; - for (int i = 0; i < makesActive.Length; i++) + for (int i = 0; i < _makesActive.Length; i++) { - ComputerModule m = makesActive[i]; - if (m != null) - { - if (active |= m.Users.RecursiveUser(this)) - break; - } + ComputerModule m = _makesActive[i]; + if (m == null) continue; + + if (active |= m.Users.RecursiveUser(this)) + break; } return active; @@ -296,22 +281,21 @@ public virtual bool isActive() public override void UnlockCheck() { - if (!UnlockChecked) + if (UnlockChecked) return; + + bool prevEn = Enabled; + Enabled = true; + base.UnlockCheck(); + if (UnlockParts.Trim().Length > 0 || UnlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked()) { - bool prevEn = Enabled; - Enabled = true; - base.UnlockCheck(); - if (UnlockParts.Trim().Length > 0 || UnlockTechs.Trim().Length > 0 || !IsSpaceCenterUpgradeUnlocked()) + Hidden = !Enabled; + if (Hidden) { - hidden = !Enabled; - if (hidden) - { - prevEn = false; - } + prevEn = false; } - - Enabled = prevEn; } + + Enabled = prevEn; } public virtual string GetName() => "Display Module"; diff --git a/MechJeb2/GuiUtils.cs b/MechJeb2/GuiUtils.cs index a9ccb3f1..cf22d354 100644 --- a/MechJeb2/GuiUtils.cs +++ b/MechJeb2/GuiUtils.cs @@ -769,8 +769,8 @@ public static bool MouseIsOverWindow(MechJebCore core) //try to check if the mouse is over any active DisplayModule foreach (DisplayModule m in core.GetComputerModules()) { - if (m.Enabled && m.showInCurrentScene && !m.IsOverlay - && m.windowPos.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y) / scale)) + if (m.Enabled && m.ShowInCurrentScene && !m.IsOverlay + && m.WindowPos.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y) / scale)) { return true; } diff --git a/MechJeb2/MechJebAR202.cs b/MechJeb2/MechJebAR202.cs index 5e47154d..f52c6524 100644 --- a/MechJeb2/MechJebAR202.cs +++ b/MechJeb2/MechJebAR202.cs @@ -100,7 +100,7 @@ private void HandleLights() foreach (DisplayModule display in core.GetDisplayModules(MechJebModuleMenu.DisplayOrder.instance)) { if (display is MechJebModuleMenu) continue; - if (display.Enabled && display.showInCurrentScene) + if (display.Enabled && display.ShowInCurrentScene) { somethingEnabled = true; } diff --git a/MechJeb2/MechJebCore.cs b/MechJeb2/MechJebCore.cs index 51c806d4..08f7bf7f 100644 --- a/MechJeb2/MechJebCore.cs +++ b/MechJeb2/MechJebCore.cs @@ -166,7 +166,7 @@ private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target smartassT MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule(); - if (masterSmartASS is { hidden: false }) + if (masterSmartASS is { Hidden: false }) { masterSmartASS.mode = MechJebModuleSmartASS.Mode.ORBITAL; masterSmartASS.target = smartassTarget; @@ -190,7 +190,7 @@ public void OnPanicAction(KSPActionParam param) MechJebModuleTranslatron moduleTranslatron = masterMechJeb.GetComputerModule(); - if (moduleTranslatron is { hidden: false }) + if (moduleTranslatron is { Hidden: false }) moduleTranslatron.PanicSwitch(); } @@ -218,7 +218,7 @@ public void OnTranslatronToggleHSAction(KSPActionParam param) { MechJebModuleTranslatron moduleTranslatron = masterMechJeb.GetComputerModule(); - if (moduleTranslatron is { hidden: false }) + if (moduleTranslatron is { Hidden: false }) { Thrust.TransKillH = !Thrust.TransKillH; } @@ -264,7 +264,7 @@ private void EngageTranslatronControl(MechJebModuleThrustController.TMode mode) MechJebModuleTranslatron moduleTranslatron = masterMechJeb.GetComputerModule(); - if (moduleTranslatron is { hidden: false }) + if (moduleTranslatron is { Hidden: false }) { if (Thrust.Users.Count > 1 && !Thrust.Users.Contains(moduleTranslatron)) return; @@ -289,7 +289,7 @@ private void SetTranslatronSpeed(float speed, bool relative = false) MechJebModuleTranslatron moduleTranslatron = masterMechJeb.GetComputerModule(); - if (moduleTranslatron is { hidden: false }) + if (moduleTranslatron is { Hidden: false }) Thrust.TransSpdAct = (relative ? Thrust.TransSpdAct : 0) + speed; else Debug.LogError("MechJeb couldn't find MechJebModuleTranslatron for translatron control via action group."); diff --git a/MechJeb2/MechJebModuleAirplaneGuidance.cs b/MechJeb2/MechJebModuleAirplaneGuidance.cs index bde99e9b..66c1e6ed 100644 --- a/MechJeb2/MechJebModuleAirplaneGuidance.cs +++ b/MechJeb2/MechJebModuleAirplaneGuidance.cs @@ -415,7 +415,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(200) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(200) }; public override string GetName() => Localizer.Format("#MechJeb_Aircraftauto_title"); //Aircraft Autopilot diff --git a/MechJeb2/MechJebModuleAscentClassicPathMenu.cs b/MechJeb2/MechJebModuleAscentClassicPathMenu.cs index e6dc2f62..339dc1b6 100644 --- a/MechJeb2/MechJebModuleAscentClassicPathMenu.cs +++ b/MechJeb2/MechJebModuleAscentClassicPathMenu.cs @@ -12,7 +12,7 @@ public class MechJebModuleAscentClassicPathMenu : DisplayModule public MechJebModuleAscentClassicPathMenu(MechJebCore core) : base(core) { - hidden = true; + Hidden = true; } private MechJebModuleAscentSettings _ascentSettings; @@ -28,7 +28,7 @@ public override void OnStart(PartModule.StartState state) _path = Core.GetComputerModule(); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(100) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(100) }; protected override void WindowGUI(int windowID) { diff --git a/MechJeb2/MechJebModuleAscentMenu.cs b/MechJeb2/MechJebModuleAscentMenu.cs index 75c517d9..226850ba 100644 --- a/MechJeb2/MechJebModuleAscentMenu.cs +++ b/MechJeb2/MechJebModuleAscentMenu.cs @@ -520,7 +520,7 @@ private string PhaseString(Solution solution, double t, int pvgPhase) return $"burn: {kspStage} {solution.Tgo(t, pvgPhase):F1}s {solution.DV(t, pvgPhase):F1}m/s ({excessDV:F1}m/s)"; } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(275), GUILayout.Height(30) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(275), GUILayout.Height(30) }; public override string GetName() => CachedLocalizer.Instance.MechJebAscentTitle; //"Ascent Guidance" diff --git a/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs b/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs index 0aac1fc4..33998967 100644 --- a/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs +++ b/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs @@ -11,7 +11,7 @@ public class MechJebModuleAscentPVGSettingsMenu : DisplayModule { public MechJebModuleAscentPVGSettingsMenu(MechJebCore core) : base(core) { - hidden = true; + Hidden = true; } private MechJebModuleAscentSettings _ascentSettings => Core.AscentSettings; @@ -19,7 +19,7 @@ public MechJebModuleAscentPVGSettingsMenu(MechJebCore core) : base(core) private static GUIStyle _btNormal; private static GUIStyle _btActive; - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(100) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(100) }; private void SetupButtonStyles() { diff --git a/MechJeb2/MechJebModuleAscentSettingsMenu.cs b/MechJeb2/MechJebModuleAscentSettingsMenu.cs index 5626c1fa..86511187 100644 --- a/MechJeb2/MechJebModuleAscentSettingsMenu.cs +++ b/MechJeb2/MechJebModuleAscentSettingsMenu.cs @@ -9,7 +9,7 @@ public class MechJebModuleAscentSettingsMenu : DisplayModule { public MechJebModuleAscentSettingsMenu(MechJebCore core) : base(core) { - hidden = true; + Hidden = true; } private MechJebModuleAscentSettings _ascentSettings => Core.AscentSettings; @@ -123,7 +123,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(275), GUILayout.Height(30) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(275), GUILayout.Height(30) }; public override string GetName() => "Ascent Settings"; diff --git a/MechJeb2/MechJebModuleAttitudeAdjustment.cs b/MechJeb2/MechJebModuleAttitudeAdjustment.cs index fdeb4aeb..a560e659 100644 --- a/MechJeb2/MechJebModuleAttitudeAdjustment.cs +++ b/MechJeb2/MechJebModuleAttitudeAdjustment.cs @@ -154,7 +154,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(350), GUILayout.Height(150) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(350), GUILayout.Height(150) }; public override string GetName() => Localizer.Format("#MechJeb_AttitudeAdjust_title"); //Attitude Adjustment diff --git a/MechJeb2/MechJebModuleCustomInfoWindow.cs b/MechJeb2/MechJebModuleCustomInfoWindow.cs index 3a9ee589..11ada7e3 100644 --- a/MechJeb2/MechJebModuleCustomInfoWindow.cs +++ b/MechJeb2/MechJebModuleCustomInfoWindow.cs @@ -135,7 +135,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(250), GUILayout.Height(30) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(250), GUILayout.Height(30) }; public override void DrawGUI(bool inEditor) { @@ -253,7 +253,7 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global bool loadedEnabled; if (bool.TryParse(windowNode.GetValue("enabledEditor"), out loadedEnabled)) { - window.enabledEditor = loadedEnabled; + window.EnabledEditor = loadedEnabled; useOldConfig = false; if (HighLogic.LoadedSceneIsEditor) window.Enabled = loadedEnabled; @@ -265,7 +265,7 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global bool loadedEnabled; if (bool.TryParse(windowNode.GetValue("enabledFlight"), out loadedEnabled)) { - window.enabledFlight = loadedEnabled; + window.EnabledFlight = loadedEnabled; useOldConfig = false; if (HighLogic.LoadedSceneIsFlight) window.Enabled = loadedEnabled; @@ -280,13 +280,13 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global if (bool.TryParse(windowNode.GetValue("enabled"), out loadedEnabled)) { window.Enabled = loadedEnabled; - window.enabledEditor = window.Enabled; - window.enabledFlight = window.Enabled; + window.EnabledEditor = window.Enabled; + window.EnabledFlight = window.Enabled; } } - window.enabledEditor = window.Enabled; - window.enabledFlight = window.Enabled; + window.EnabledEditor = window.Enabled; + window.EnabledFlight = window.Enabled; } window.items = new List(); @@ -320,12 +320,12 @@ public override void OnSave(ConfigNode local, ConfigNode type, ConfigNode global var windowNode = ConfigNode.CreateConfigFromObject(window, (int)Pass.GLOBAL, null); if (HighLogic.LoadedSceneIsEditor) - window.enabledEditor = window.Enabled; + window.EnabledEditor = window.Enabled; if (HighLogic.LoadedSceneIsFlight) - window.enabledFlight = window.Enabled; + window.EnabledFlight = window.Enabled; - windowNode.AddValue("enabledFlight", window.enabledFlight); - windowNode.AddValue("enabledEditor", window.enabledEditor); + windowNode.AddValue("enabledFlight", window.EnabledFlight); + windowNode.AddValue("enabledEditor", window.EnabledEditor); windowNode.CopyTo(global.AddNode(name)); window.Dirty = false; } @@ -380,7 +380,7 @@ public override void DrawGUI(bool inEditor) { editedWindow.Init(); - Color newColor = ColorPickerRGB.DrawGUI((int)windowPos.xMax + 5, (int)windowPos.yMin, editedWindow.backgroundColor); + Color newColor = ColorPickerRGB.DrawGUI((int)WindowPos.xMax + 5, (int)WindowPos.yMin, editedWindow.backgroundColor); if (editedWindow.backgroundColor != newColor) { @@ -396,7 +396,7 @@ public override void DrawGUI(bool inEditor) { if (editedWindow != null) { - Color newColor = ColorPickerRGB.DrawGUI((int)windowPos.xMax + 5, (int)windowPos.yMin, editedWindow.text); + Color newColor = ColorPickerRGB.DrawGUI((int)WindowPos.xMax + 5, (int)WindowPos.yMin, editedWindow.text); if (editedWindow.text != newColor) { editedWindow.text = newColor; @@ -552,7 +552,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(540) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(540) }; public override string GetName() => CachedLocalizer.Instance.MechJebWindowEdTitle; //Custom Window Editor diff --git a/MechJeb2/MechJebModuleDockingGuidance.cs b/MechJeb2/MechJebModuleDockingGuidance.cs index 1c682096..3058acf6 100644 --- a/MechJeb2/MechJebModuleDockingGuidance.cs +++ b/MechJeb2/MechJebModuleDockingGuidance.cs @@ -139,7 +139,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(50) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(50) }; protected override void OnModuleDisabled() { diff --git a/MechJeb2/MechJebModuleFlightRecorderGraph.cs b/MechJeb2/MechJebModuleFlightRecorderGraph.cs index a99fc090..54374a6a 100644 --- a/MechJeb2/MechJebModuleFlightRecorderGraph.cs +++ b/MechJeb2/MechJebModuleFlightRecorderGraph.cs @@ -326,7 +326,8 @@ protected override void WindowGUI(int windowID) GUI.color = XKCDColors.Cerise; graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].display = GUILayout.Toggle( - graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].display, Localizer.Format("#MechJeb_Flightrecord_checkbox17"), + graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].display, + Localizer.Format("#MechJeb_Flightrecord_checkbox17"), GUILayout.ExpandWidth(false)); //"Steering Loss" GUI.color = color; @@ -727,40 +728,40 @@ private void UpdateScale() private void ResetScale() { // Avoid min = max and set sane minimums - graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_ASL].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.DOWN_RANGE].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.ACCELERATION].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_SURFACE].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_ORBITAL].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.MASS].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.Q].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_A].minimum = -5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_S].minimum = -5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_D].minimum = 0; // is never negative - graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_TRUE].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.PITCH].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_ASL].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.DOWN_RANGE].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.ACCELERATION].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_SURFACE].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_ORBITAL].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.MASS].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.Q].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_A].minimum = -5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_S].minimum = -5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_D].minimum = 0; // is never negative + graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_TRUE].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.PITCH].minimum = 0; graphStates[(int)MechJebModuleFlightRecorder.RecordType.DELTA_V_EXPENDED].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.GRAVITY_LOSSES].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.DRAG_LOSSES].minimum = 0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.GRAVITY_LOSSES].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.DRAG_LOSSES].minimum = 0; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].minimum = 0; graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_ASL].maximum = MainBody != null && MainBody.atmosphere ? MainBody.RealMaxAtmosphereAltitude() : 10000.0; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.DOWN_RANGE].maximum = 500; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.ACCELERATION].maximum = 2; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_SURFACE].maximum = 300; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_ORBITAL].maximum = 300; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.MASS].maximum = 5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.Q].maximum = 1000; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_A].maximum = 5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_S].maximum = 5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_D].maximum = 5; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_TRUE].maximum = 100; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.PITCH].maximum = 90; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.DOWN_RANGE].maximum = 500; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.ACCELERATION].maximum = 2; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_SURFACE].maximum = 300; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.SPEED_ORBITAL].maximum = 300; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.MASS].maximum = 5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.Q].maximum = 1000; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_A].maximum = 5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_S].maximum = 5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.AO_D].maximum = 5; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.ALTITUDE_TRUE].maximum = 100; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.PITCH].maximum = 90; graphStates[(int)MechJebModuleFlightRecorder.RecordType.DELTA_V_EXPENDED].maximum = 100; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.GRAVITY_LOSSES].maximum = 100; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.DRAG_LOSSES].maximum = 100; - graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].maximum = 100; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.GRAVITY_LOSSES].maximum = 100; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.DRAG_LOSSES].maximum = 100; + graphStates[(int)MechJebModuleFlightRecorder.RecordType.STEERING_LOSSES].maximum = 100; } private double heckbertNiceNum(double x, bool round) @@ -795,7 +796,7 @@ private double heckbertNiceNum(double x, bool round) return nf * Math.Pow(10.0, exp); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(400), GUILayout.Height(300) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(400), GUILayout.Height(300) }; public override string GetName() => Localizer.Format("#MechJeb_Flightrecord_title"); //"Flight Recorder" diff --git a/MechJeb2/MechJebModuleLandingGuidance.cs b/MechJeb2/MechJebModuleLandingGuidance.cs index 3c0773e3..e1cedb02 100644 --- a/MechJeb2/MechJebModuleLandingGuidance.cs +++ b/MechJeb2/MechJebModuleLandingGuidance.cs @@ -33,7 +33,7 @@ public override void OnStart(PartModule.StartState state) InitLandingSitesList(); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(150) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(150) }; private void MoveByMeter(ref EditableAngle angle, double distance, double alt) { diff --git a/MechJeb2/MechJebModuleManeuverPlanner.cs b/MechJeb2/MechJebModuleManeuverPlanner.cs index fe56fd65..d74fbf6e 100644 --- a/MechJeb2/MechJebModuleManeuverPlanner.cs +++ b/MechJeb2/MechJebModuleManeuverPlanner.cs @@ -186,7 +186,7 @@ public List GetManeuverNodes() return Vessel.patchedConicSolver.maneuverNodes.Where(n => n != predictor.aerobrakeNode).ToList(); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; public override string GetName() => Localizer.Format("#MechJeb_Maneuver_Planner_title"); //Maneuver Planner diff --git a/MechJeb2/MechJebModuleMenu.cs b/MechJeb2/MechJebModuleMenu.cs index 1e234649..0ddf9580 100644 --- a/MechJeb2/MechJebModuleMenu.cs +++ b/MechJeb2/MechJebModuleMenu.cs @@ -18,7 +18,7 @@ public MechJebModuleMenu(MechJebCore core) { Priority = -1000; Enabled = true; - hidden = true; + Hidden = true; ShowInFlight = true; ShowInEditor = true; @@ -80,22 +80,22 @@ public Rect displayedPos switch (windowSide) { case WindowSide.LEFT: - return new Rect((windowProgr - 1) * windowPos.width, - Mathf.Clamp(-100 - windowVPos, 0, GuiUtils.scaledScreenHeight - windowPos.height), windowPos.width, windowPos.height); + return new Rect((windowProgr - 1) * WindowPos.width, + Mathf.Clamp(-100 - windowVPos, 0, GuiUtils.scaledScreenHeight - WindowPos.height), WindowPos.width, WindowPos.height); case WindowSide.RIGHT: - return new Rect(GuiUtils.scaledScreenWidth - windowProgr * windowPos.width, - Mathf.Clamp(-100 - windowVPos, 0, GuiUtils.scaledScreenHeight - windowPos.height), windowPos.width, windowPos.height); + return new Rect(GuiUtils.scaledScreenWidth - windowProgr * WindowPos.width, + Mathf.Clamp(-100 - windowVPos, 0, GuiUtils.scaledScreenHeight - WindowPos.height), WindowPos.width, WindowPos.height); case WindowSide.TOP: return new Rect( - Mathf.Clamp(GuiUtils.scaledScreenWidth - 50 - windowPos.width * 0.5f - windowHPos, 0, - GuiUtils.scaledScreenWidth - windowPos.width), (windowProgr - 1) * windowPos.height, windowPos.width, - windowPos.height); + Mathf.Clamp(GuiUtils.scaledScreenWidth - 50 - WindowPos.width * 0.5f - windowHPos, 0, + GuiUtils.scaledScreenWidth - WindowPos.width), (windowProgr - 1) * WindowPos.height, WindowPos.width, + WindowPos.height); case WindowSide.BOTTOM: default: return new Rect( - Mathf.Clamp(GuiUtils.scaledScreenWidth - 50 - windowPos.width * 0.5f - windowHPos, 0, - GuiUtils.scaledScreenWidth - windowPos.width), GuiUtils.scaledScreenHeight - windowProgr * windowPos.height, - windowPos.width, windowPos.height); + Mathf.Clamp(GuiUtils.scaledScreenWidth - 50 - WindowPos.width * 0.5f - windowHPos, 0, + GuiUtils.scaledScreenWidth - WindowPos.width), GuiUtils.scaledScreenHeight - windowProgr * WindowPos.height, + WindowPos.width, WindowPos.height); } } } @@ -107,17 +107,17 @@ public Rect buttonPos switch (windowSide) { case WindowSide.LEFT: - return new Rect(Mathf.Clamp(windowVPos, -GuiUtils.scaledScreenHeight, -100), windowPos.width * windowProgr, 100, 25); + return new Rect(Mathf.Clamp(windowVPos, -GuiUtils.scaledScreenHeight, -100), WindowPos.width * windowProgr, 100, 25); case WindowSide.RIGHT: return new Rect(Mathf.Clamp(windowVPos, -GuiUtils.scaledScreenHeight, -100), - GuiUtils.scaledScreenWidth - 25 - windowPos.width * windowProgr, 100, 25); + GuiUtils.scaledScreenWidth - 25 - WindowPos.width * windowProgr, 100, 25); case WindowSide.TOP: return new Rect(Mathf.Clamp(GuiUtils.scaledScreenWidth - windowHPos - 100, 0, GuiUtils.scaledScreenWidth - 50), - windowProgr * windowPos.height, 100, 25); + windowProgr * WindowPos.height, 100, 25); case WindowSide.BOTTOM: default: return new Rect(Mathf.Clamp(GuiUtils.scaledScreenWidth - windowHPos - 100, 0, GuiUtils.scaledScreenWidth - 50), - GuiUtils.scaledScreenHeight - windowProgr * windowPos.height - 25, 100, 25); + GuiUtils.scaledScreenHeight - windowProgr * WindowPos.height - 25, 100, 25); } } } @@ -210,14 +210,14 @@ protected override void WindowGUI(int windowID) List displayModules = Core.GetDisplayModules(DisplayOrder.instance); int i = 0; - int step = Mathf.CeilToInt((float)(displayModules.Count(d => !d.hidden && d.showInCurrentScene) + 1) / columns); + int step = Mathf.CeilToInt((float)(displayModules.Count(d => !d.Hidden && d.ShowInCurrentScene) + 1) / columns); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); foreach (DisplayModule module in displayModules) { - if (!module.hidden && module.showInCurrentScene) + if (!module.Hidden && module.ShowInCurrentScene) { if (i == step) { @@ -226,7 +226,7 @@ protected override void WindowGUI(int windowID) i = 0; } - module.Enabled = GUILayout.Toggle(module.Enabled, module.GetName(), module.isActive() ? toggleActive : toggleInactive); + module.Enabled = GUILayout.Toggle(module.Enabled, module.GetName(), module.IsActive() ? toggleActive : toggleInactive); i++; } } @@ -278,7 +278,7 @@ public void SetupToolBarButtons() SetupMainToolbarButton(); - foreach (DisplayModule module in Core.GetDisplayModules(DisplayOrder.instance).Where(m => !m.hidden)) + foreach (DisplayModule module in Core.GetDisplayModules(DisplayOrder.instance).Where(m => !m.Hidden)) { Button button; if (!toolbarButtons.ContainsKey(module)) @@ -331,15 +331,15 @@ public void SetupToolBarButtons() button = toolbarButtons[module]; } - button.button.Visible = module.showInCurrentScene; - button.button.TexturePath = module.isActive() ? button.texturePathActive : button.texturePath; + button.button.Visible = module.ShowInCurrentScene; + button.button.TexturePath = module.IsActive() ? button.texturePathActive : button.texturePath; } // create toolbar buttons for features if (featureButtons.Count == 0) { MechJebModuleManeuverPlanner maneuverPlannerModule = Core.GetComputerModule(); - if (!HighLogic.LoadedSceneIsEditor && maneuverPlannerModule != null && !maneuverPlannerModule.hidden) + if (!HighLogic.LoadedSceneIsEditor && maneuverPlannerModule != null && !maneuverPlannerModule.Hidden) { CreateFeatureButton(maneuverPlannerModule, "Exec_Node", "MechJeb Execute Next Node", b => { @@ -437,7 +437,7 @@ public void CreateFeatureButton(DisplayModule module, string nameId, string tool : button.texturePath; }, button); - button.button.Visible = module.showInCurrentScene; + button.button.Visible = module.ShowInCurrentScene; button.button.TexturePath = button.texturePath; } @@ -569,12 +569,12 @@ public override void DrawGUI(bool inEditor) if (windowStat != WindowStat.HIDDEN) { - windowPos = GUILayout.Window(GetType().FullName.GetHashCode(), displayedPos, WindowGUI, "MechJeb " + Core.version, + WindowPos = GUILayout.Window(GetType().FullName.GetHashCode(), displayedPos, WindowGUI, "MechJeb " + Core.version, GUILayout.Width(colWidth), GUILayout.Height(20)); } else { - windowPos = new Rect(GuiUtils.scaledScreenWidth, GuiUtils.scaledScreenHeight, 0, 0); // make it small so the mouse can't hoover it + WindowPos = new Rect(GuiUtils.scaledScreenWidth, GuiUtils.scaledScreenHeight, 0, 0); // make it small so the mouse can't hoover it } GUI.depth = -98; diff --git a/MechJeb2/MechJebModuleNodeEditor.cs b/MechJeb2/MechJebModuleNodeEditor.cs index d432468f..b23dd80f 100644 --- a/MechJeb2/MechJebModuleNodeEditor.cs +++ b/MechJeb2/MechJebModuleNodeEditor.cs @@ -317,7 +317,7 @@ private void RelativityModeSelectUI() GUILayout.EndVertical(); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; public override string GetName() => Localizer.Format("#MechJeb_NodeEd_title"); //"Maneuver Node Editor" diff --git a/MechJeb2/MechJebModuleRCSBalancerWindow.cs b/MechJeb2/MechJebModuleRCSBalancerWindow.cs index 2143b076..352cefa6 100644 --- a/MechJeb2/MechJebModuleRCSBalancerWindow.cs +++ b/MechJeb2/MechJebModuleRCSBalancerWindow.cs @@ -117,7 +117,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(240), GUILayout.Height(30) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(240), GUILayout.Height(30) }; public override string GetName() => Localizer.Format("#MechJeb_RCSBalancer_title"); //"RCS Balancer" diff --git a/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs b/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs index 7b93f7c3..16601068 100644 --- a/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs +++ b/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs @@ -63,7 +63,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(50) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(50) }; public override string GetName() => Localizer.Format("#MechJeb_RZauto_title"); //"Rendezvous Autopilot" diff --git a/MechJeb2/MechJebModuleRendezvousGuidance.cs b/MechJeb2/MechJebModuleRendezvousGuidance.cs index 98081cb9..8b0f199e 100644 --- a/MechJeb2/MechJebModuleRendezvousGuidance.cs +++ b/MechJeb2/MechJebModuleRendezvousGuidance.cs @@ -172,7 +172,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(300), GUILayout.Height(150) }; public override string GetName() => Localizer.Format("#MechJeb_RZplan_title"); //"Rendezvous Planner" diff --git a/MechJeb2/MechJebModuleRoverWindow.cs b/MechJeb2/MechJebModuleRoverWindow.cs index 3cf455a3..9291673d 100644 --- a/MechJeb2/MechJebModuleRoverWindow.cs +++ b/MechJeb2/MechJebModuleRoverWindow.cs @@ -18,14 +18,14 @@ public class MechJebModuleRoverWindow : DisplayModule public override string IconName() => "Rover Autopilot"; - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(50) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(50) }; protected override void WindowGUI(int windowID) { MechJebModuleCustomWindowEditor ed = Core.GetComputerModule(); bool alt = GameSettings.MODIFIER_KEY.GetKey(); - if (GUI.Button(new Rect(windowPos.width - 48, 0, 13, 20), "?", GuiUtils.yellowOnHover)) + if (GUI.Button(new Rect(WindowPos.width - 48, 0, 13, 20), "?", GuiUtils.yellowOnHover)) { MechJebModuleWaypointHelpWindow help = Core.GetComputerModule(); help.selTopic = ((IList)help.topics).IndexOf("Controller"); diff --git a/MechJeb2/MechJebModuleSettings.cs b/MechJeb2/MechJebModuleSettings.cs index f2aea9ba..cd8646e7 100644 --- a/MechJeb2/MechJebModuleSettings.cs +++ b/MechJeb2/MechJebModuleSettings.cs @@ -134,6 +134,6 @@ protected override void WindowGUI(int windowID) public override string IconName() => "Settings"; - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(100) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(200), GUILayout.Height(100) }; } } diff --git a/MechJeb2/MechJebModuleSmartASS.cs b/MechJeb2/MechJebModuleSmartASS.cs index 6aca1af9..7ed223d8 100644 --- a/MechJeb2/MechJebModuleSmartASS.cs +++ b/MechJeb2/MechJebModuleSmartASS.cs @@ -667,7 +667,7 @@ public void Engage(bool resetPID = true) if (resetPID) { Core.Attitude.Controller.Reset(); } } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(180), GUILayout.Height(100) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(180), GUILayout.Height(100) }; public override string GetName() => Core.eduMode diff --git a/MechJeb2/MechJebModuleSmartRcs.cs b/MechJeb2/MechJebModuleSmartRcs.cs index 133ad7c7..c0dde562 100644 --- a/MechJeb2/MechJebModuleSmartRcs.cs +++ b/MechJeb2/MechJebModuleSmartRcs.cs @@ -113,7 +113,7 @@ public void Engage() } } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(180), GUILayout.Height(100) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(180), GUILayout.Height(100) }; public override string GetName() => Localizer.Format("#MechJeb_SmartRcs_title"); //"SmartRcs" diff --git a/MechJeb2/MechJebModuleSpaceplaneGuidance.cs b/MechJeb2/MechJebModuleSpaceplaneGuidance.cs index 463d7bab..1777960f 100644 --- a/MechJeb2/MechJebModuleSpaceplaneGuidance.cs +++ b/MechJeb2/MechJebModuleSpaceplaneGuidance.cs @@ -86,7 +86,7 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(350), GUILayout.Height(200) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(350), GUILayout.Height(200) }; public override void OnFixedUpdate() { diff --git a/MechJeb2/MechJebModuleThrustController.cs b/MechJeb2/MechJebModuleThrustController.cs index 3b5f1a22..52a6eeca 100644 --- a/MechJeb2/MechJebModuleThrustController.cs +++ b/MechJeb2/MechJebModuleThrustController.cs @@ -353,7 +353,7 @@ public override void Drive(FlightCtrlState s) _userCommandingRotationSmoothed--; } - if (Core.GetComputerModule().hidden && Core.GetComputerModule().hidden) { return; } + if (Core.GetComputerModule().Hidden && Core.GetComputerModule().Hidden) { return; } if (Tmode != TMode.OFF && VesselState.thrustAvailable > 0) { @@ -815,7 +815,7 @@ private float AccelerationLimitedThrottle() public override void OnUpdate() { - if (Core.GetComputerModule().hidden && Core.GetComputerModule().hidden) + if (Core.GetComputerModule().Hidden && Core.GetComputerModule().Hidden) { return; } diff --git a/MechJeb2/MechJebModuleThrustWindow.cs b/MechJeb2/MechJebModuleThrustWindow.cs index 7c75843a..41e936dd 100644 --- a/MechJeb2/MechJebModuleThrustWindow.cs +++ b/MechJeb2/MechJebModuleThrustWindow.cs @@ -125,9 +125,9 @@ protected override void WindowGUI(int windowID) base.WindowGUI(windowID); } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(250), GUILayout.Height(30) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(250), GUILayout.Height(30) }; - public override bool isActive() => Core.Thrust.Limiter != MechJebModuleThrustController.LimitMode.NONE; + public override bool IsActive() => Core.Thrust.Limiter != MechJebModuleThrustController.LimitMode.NONE; public override string GetName() => Localizer.Format("#MechJeb_Utilities_title"); //"Utilities" diff --git a/MechJeb2/MechJebModuleTranslatron.cs b/MechJeb2/MechJebModuleTranslatron.cs index a1c4affd..b18eeeda 100644 --- a/MechJeb2/MechJebModuleTranslatron.cs +++ b/MechJeb2/MechJebModuleTranslatron.cs @@ -44,7 +44,7 @@ public enum AbortStage public override string IconName() => "Translatron"; - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(130) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(130) }; protected override void WindowGUI(int windowID) { @@ -64,7 +64,7 @@ protected override void WindowGUI(int windowID) { if (!autoMode) { - windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); + WindowPos = new Rect(WindowPos.x, WindowPos.y, 10, 10); autoMode = true; } @@ -77,7 +77,7 @@ protected override void WindowGUI(int windowID) { if (autoMode) { - windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); + WindowPos = new Rect(WindowPos.x, WindowPos.y, 10, 10); autoMode = false; } @@ -153,7 +153,7 @@ public void SetMode(MechJebModuleThrustController.TMode newMode) if (Core.Thrust.Tmode != oldMode) { Core.Thrust.TransSpdAct = Convert.ToInt16(trans_spd); - windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); + WindowPos = new Rect(WindowPos.x, WindowPos.y, 10, 10); if (Core.Thrust.Tmode == MechJebModuleThrustController.TMode.OFF) { Core.Thrust.Users.Remove(this); diff --git a/MechJeb2/MechJebModuleWarpHelper.cs b/MechJeb2/MechJebModuleWarpHelper.cs index 4f2ee17b..8d90c644 100644 --- a/MechJeb2/MechJebModuleWarpHelper.cs +++ b/MechJeb2/MechJebModuleWarpHelper.cs @@ -197,9 +197,9 @@ public override void OnFixedUpdate() } } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(240), GUILayout.Height(50) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(240), GUILayout.Height(50) }; - public override bool isActive() => warping; + public override bool IsActive() => warping; public override string GetName() => Localizer.Format("#MechJeb_WarpHelper_title"); //"Warp Helper" diff --git a/MechJeb2/MechJebModuleWaypointWindow.cs b/MechJeb2/MechJebModuleWaypointWindow.cs index 0dc3d38f..d36db427 100644 --- a/MechJeb2/MechJebModuleWaypointWindow.cs +++ b/MechJeb2/MechJebModuleWaypointWindow.cs @@ -315,7 +315,7 @@ private enum pages { waypoints, settings, routes } public override void OnStart(PartModule.StartState state) { - hidden = true; + Hidden = true; ap = Core.GetComputerModule(); if (HighLogic.LoadedSceneIsFlight && Vessel.isActiveVessel) { @@ -597,7 +597,7 @@ public int SelectedWaypointIndex set => selIndex = value; } - public override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(500), GUILayout.Height(400) }; + protected override GUILayoutOption[] WindowOptions() => new[] { GUILayout.Width(500), GUILayout.Height(400) }; public void DrawPageWaypoints() { @@ -1016,7 +1016,7 @@ public void DrawPageRoutes() protected override void WindowGUI(int windowID) { - if (GUI.Button(new Rect(windowPos.width - 48, 0, 13, 20), "?", GuiUtils.yellowOnHover)) + if (GUI.Button(new Rect(WindowPos.width - 48, 0, 13, 20), "?", GuiUtils.yellowOnHover)) { MechJebModuleWaypointHelpWindow help = Core.GetComputerModule(); switch (showPage) @@ -1157,7 +1157,7 @@ private void HelpTopic(string title, string text) if (GUILayout.Button(title, selSubTopic == title ? btnActive : btnInactive)) { selSubTopic = selSubTopic != title ? title : ""; - windowPos = new Rect(windowPos.x, windowPos.y, windowPos.width, 0); + WindowPos = new Rect(WindowPos.x, WindowPos.y, WindowPos.width, 0); } if (selSubTopic == title) @@ -1176,7 +1176,7 @@ private void HelpTopic(string title, string text) public override void OnStart(PartModule.StartState state) { - hidden = true; + Hidden = true; base.OnStart(state); }