From 60990212217878a0d6fe46390098799168684fa8 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 31 Oct 2023 14:53:24 -0700 Subject: [PATCH] GuiUtils cleanup Signed-off-by: Lamont Granquist --- MechJeb2.sln.DotSettings | 3 + .../AttitudeControllers/BetterController.cs | 60 +- .../AttitudeControllers/HybridController.cs | 4 +- .../KosAttitudeController.cs | 4 +- .../MJAttitudeController.cs | 8 +- MechJeb2/CelestialBodyExtensions.cs | 5 +- MechJeb2/DisplayModule.cs | 24 +- MechJeb2/GuiUtils.cs | 704 ++++++++---------- .../Maneuver/OperationAdvancedTransfer.cs | 12 +- .../OperationInterplanetaryTransfer.cs | 2 +- MechJeb2/Maneuver/OperationResonantOrbit.cs | 8 +- MechJeb2/Maneuver/OperationTransfer.cs | 2 +- MechJeb2/Maneuver/TimeSelector.cs | 2 +- MechJeb2/MechJebCore.cs | 6 +- MechJeb2/MechJebModuleAirplaneGuidance.cs | 84 +-- MechJeb2/MechJebModuleAscentBaseAutopilot.cs | 4 +- .../MechJebModuleAscentClassicPathMenu.cs | 4 +- MechJeb2/MechJebModuleAscentMenu.cs | 28 +- MechJeb2/MechJebModuleAscentPVGAutopilot.cs | 4 +- .../MechJebModuleAscentPVGSettingsMenu.cs | 10 +- MechJeb2/MechJebModuleAscentSettings.cs | 80 +- MechJeb2/MechJebModuleAscentSettingsMenu.cs | 6 +- MechJeb2/MechJebModuleAttitudeAdjustment.cs | 2 +- MechJeb2/MechJebModuleCustomInfoWindow.cs | 18 +- MechJeb2/MechJebModuleDebugArrows.cs | 14 +- MechJeb2/MechJebModuleDockingAutopilot.cs | 8 +- MechJeb2/MechJebModuleDockingGuidance.cs | 8 +- MechJeb2/MechJebModuleFlightRecorderGraph.cs | 2 +- MechJeb2/MechJebModuleInfoItems.cs | 4 +- MechJeb2/MechJebModuleManeuverPlanner.cs | 10 +- MechJeb2/MechJebModuleMenu.cs | 32 +- MechJeb2/MechJebModuleNodeEditor.cs | 8 +- MechJeb2/MechJebModuleRCSController.cs | 20 +- MechJeb2/MechJebModuleRendezvousAutopilot.cs | 2 +- .../MechJebModuleRendezvousAutopilotWindow.cs | 2 +- MechJeb2/MechJebModuleRendezvousGuidance.cs | 2 +- MechJeb2/MechJebModuleRoverController.cs | 6 +- MechJeb2/MechJebModuleRoverWindow.cs | 10 +- MechJeb2/MechJebModuleSettings.cs | 24 +- MechJeb2/MechJebModuleSmartASS.cs | 2 +- MechJeb2/MechJebModuleSpaceplaneGuidance.cs | 2 +- MechJeb2/MechJebModuleStagingController.cs | 2 +- MechJeb2/MechJebModuleTargetController.cs | 6 +- MechJeb2/MechJebModuleThrustController.cs | 26 +- MechJeb2/MechJebModuleThrustWindow.cs | 8 +- MechJeb2/MechJebModuleTranslatron.cs | 2 +- MechJeb2/MechJebModuleWarpHelper.cs | 2 +- MechJeb2/MechJebModuleWaypointWindow.cs | 12 +- MechJeb2/MechJebStageStatsHelper.cs | 2 +- 49 files changed, 628 insertions(+), 672 deletions(-) diff --git a/MechJeb2.sln.DotSettings b/MechJeb2.sln.DotSettings index 7693e0700..4186e7fd6 100644 --- a/MechJeb2.sln.DotSettings +++ b/MechJeb2.sln.DotSettings @@ -6,10 +6,13 @@ ATM BCI BS + DHMS + DMS DP ECC ECI ENU + ETA FFS FPA HS diff --git a/MechJeb2/AttitudeControllers/BetterController.cs b/MechJeb2/AttitudeControllers/BetterController.cs index 780525bc6..55e4d29e9 100644 --- a/MechJeb2/AttitudeControllers/BetterController.cs +++ b/MechJeb2/AttitudeControllers/BetterController.cs @@ -96,22 +96,22 @@ internal class BetterController : BaseAttitudeController private void Defaults() { - PosKp.val = 1.98; - PosDeadband.val = 0.002; - VelKp.val = 10; - VelKi.val = 20; - VelKd.val = 0.425; - VelN.val = 84.1994541201249; - VelB.val = 0.994; - VelC.val = 0.0185; - VelDeadband.val = 0.0001; + PosKp.Val = 1.98; + PosDeadband.Val = 0.002; + VelKp.Val = 10; + VelKi.Val = 20; + VelKd.Val = 0.425; + VelN.Val = 84.1994541201249; + VelB.Val = 0.994; + VelC.Val = 0.0185; + VelDeadband.Val = 0.0001; VelClegg = false; - VelSmoothIn.val = 1.0; - VelSmoothOut.val = 1.0; - PosSmoothIn.val = 1.0; - MaxStoppingTime.val = 2; - MinFlipTime.val = 120; - RollControlRange.val = 5; + VelSmoothIn.Val = 1.0; + VelSmoothOut.Val = 1.0; + PosSmoothIn.Val = 1.0; + MaxStoppingTime.Val = 2; + MinFlipTime.Val = 120; + RollControlRange.Val = 5; Version = SETTINGS_VERSION; } @@ -306,12 +306,12 @@ public override void GUI() { GUILayout.BeginHorizontal(); UseStoppingTime = GUILayout.Toggle(UseStoppingTime, "Maximum Stopping Time", GUILayout.ExpandWidth(false)); - MaxStoppingTime.text = GUILayout.TextField(MaxStoppingTime.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + MaxStoppingTime.Text = GUILayout.TextField(MaxStoppingTime.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); UseFlipTime = GUILayout.Toggle(UseFlipTime, "Minimum Flip Time", GUILayout.ExpandWidth(false)); - MinFlipTime.text = GUILayout.TextField(MinFlipTime.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + MinFlipTime.Text = GUILayout.TextField(MinFlipTime.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); if (!UseStoppingTime) @@ -320,57 +320,57 @@ public override void GUI() GUILayout.BeginHorizontal(); UseControlRange = GUILayout.Toggle(UseControlRange, Localizer.Format("#MechJeb_HybridController_checkbox2"), GUILayout.ExpandWidth(false)); //"RollControlRange" - RollControlRange.text = GUILayout.TextField(RollControlRange.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + RollControlRange.Text = GUILayout.TextField(RollControlRange.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pos SmoothIn", GUILayout.ExpandWidth(false)); - PosSmoothIn.text = GUILayout.TextField(PosSmoothIn.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + PosSmoothIn.Text = GUILayout.TextField(PosSmoothIn.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pos Kp", GUILayout.ExpandWidth(false)); - PosKp.text = GUILayout.TextField(PosKp.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + PosKp.Text = GUILayout.TextField(PosKp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pos Deadband", GUILayout.ExpandWidth(false)); - PosDeadband.text = GUILayout.TextField(PosDeadband.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + PosDeadband.Text = GUILayout.TextField(PosDeadband.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel Kp", GUILayout.ExpandWidth(false)); - VelKp.text = GUILayout.TextField(VelKp.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelKp.Text = GUILayout.TextField(VelKp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel Ki", GUILayout.ExpandWidth(false)); - VelKi.text = GUILayout.TextField(VelKi.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelKi.Text = GUILayout.TextField(VelKi.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel Kd", GUILayout.ExpandWidth(false)); - VelKd.text = GUILayout.TextField(VelKd.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelKd.Text = GUILayout.TextField(VelKd.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel N", GUILayout.ExpandWidth(false)); - VelN.text = GUILayout.TextField(VelN.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelN.Text = GUILayout.TextField(VelN.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel B", GUILayout.ExpandWidth(false)); - VelB.text = GUILayout.TextField(VelB.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelB.Text = GUILayout.TextField(VelB.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel C", GUILayout.ExpandWidth(false)); - VelC.text = GUILayout.TextField(VelC.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelC.Text = GUILayout.TextField(VelC.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel Deadband", GUILayout.ExpandWidth(false)); - VelDeadband.text = GUILayout.TextField(VelDeadband.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelDeadband.Text = GUILayout.TextField(VelDeadband.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -379,12 +379,12 @@ public override void GUI() GUILayout.BeginHorizontal(); GUILayout.Label("Vel SmoothIn", GUILayout.ExpandWidth(false)); - VelSmoothIn.text = GUILayout.TextField(VelSmoothIn.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelSmoothIn.Text = GUILayout.TextField(VelSmoothIn.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Vel SmoothOut", GUILayout.ExpandWidth(false)); - VelSmoothOut.text = GUILayout.TextField(VelSmoothOut.text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); + VelSmoothOut.Text = GUILayout.TextField(VelSmoothOut.Text, GUILayout.ExpandWidth(true), GUILayout.Width(50)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); diff --git a/MechJeb2/AttitudeControllers/HybridController.cs b/MechJeb2/AttitudeControllers/HybridController.cs index 545d795f9..95ffeffa5 100644 --- a/MechJeb2/AttitudeControllers/HybridController.cs +++ b/MechJeb2/AttitudeControllers/HybridController.cs @@ -154,13 +154,13 @@ public override void GUI() GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_HybridController_label1"), GUILayout.ExpandWidth(false)); //"MaxStoppingTime" - MaxStoppingTime.text = GUILayout.TextField(MaxStoppingTime.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + MaxStoppingTime.Text = GUILayout.TextField(MaxStoppingTime.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); UseControlRange = GUILayout.Toggle(UseControlRange, Localizer.Format("#MechJeb_HybridController_checkbox2"), GUILayout.ExpandWidth(false)); //"RollControlRange" - RollControlRange.text = GUILayout.TextField(RollControlRange.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + RollControlRange.Text = GUILayout.TextField(RollControlRange.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); // Not used yet diff --git a/MechJeb2/AttitudeControllers/KosAttitudeController.cs b/MechJeb2/AttitudeControllers/KosAttitudeController.cs index 54a7fd59b..18a7bbd53 100644 --- a/MechJeb2/AttitudeControllers/KosAttitudeController.cs +++ b/MechJeb2/AttitudeControllers/KosAttitudeController.cs @@ -164,13 +164,13 @@ public override void GUI() { GUILayout.BeginHorizontal(); GUILayout.Label("MaxStoppingTime", GUILayout.ExpandWidth(false)); - MaxStoppingTime.text = GUILayout.TextField(MaxStoppingTime.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + MaxStoppingTime.Text = GUILayout.TextField(MaxStoppingTime.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("RollControlRange", GUILayout.ExpandWidth(false)); - RollControlRange.text = GUILayout.TextField(RollControlRange.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + RollControlRange.Text = GUILayout.TextField(RollControlRange.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); diff --git a/MechJeb2/AttitudeControllers/MJAttitudeController.cs b/MechJeb2/AttitudeControllers/MJAttitudeController.cs index eba51913c..25003afa5 100644 --- a/MechJeb2/AttitudeControllers/MJAttitudeController.cs +++ b/MechJeb2/AttitudeControllers/MJAttitudeController.cs @@ -3,6 +3,8 @@ using KSP.Localization; using UnityEngine; +// ReSharper disable CompareOfFloatsByEqualityOperator + namespace MuMech.AttitudeControllers { internal class MJAttitudeController : BaseAttitudeController @@ -257,11 +259,11 @@ public override void GUI() GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_AttitudeController_label2"), GUILayout.ExpandWidth(true)); //"Tf (s)" GUILayout.Label(Localizer.Format("#MechJeb_AttitudeController_label3"), GUILayout.ExpandWidth(false)); //"P" - _uiTfX.text = GUILayout.TextField(_uiTfX.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + _uiTfX.Text = GUILayout.TextField(_uiTfX.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.Label(Localizer.Format("#MechJeb_AttitudeController_label4"), GUILayout.ExpandWidth(false)); //"Y" - _uiTfY.text = GUILayout.TextField(_uiTfY.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + _uiTfY.Text = GUILayout.TextField(_uiTfY.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.Label(Localizer.Format("#MechJeb_AttitudeController_label5"), GUILayout.ExpandWidth(false)); //"R" - _uiTfZ.text = GUILayout.TextField(_uiTfZ.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + _uiTfZ.Text = GUILayout.TextField(_uiTfZ.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.EndHorizontal(); _uiTfX = Math.Max(0.01, _uiTfX); diff --git a/MechJeb2/CelestialBodyExtensions.cs b/MechJeb2/CelestialBodyExtensions.cs index b0585b1b2..263d8b374 100644 --- a/MechJeb2/CelestialBodyExtensions.cs +++ b/MechJeb2/CelestialBodyExtensions.cs @@ -1,4 +1,6 @@ -namespace MuMech +using JetBrains.Annotations; + +namespace MuMech { public static class CelestialBodyExtensions { @@ -9,6 +11,7 @@ public static class CelestialBodyExtensions //the ship's drag coefficient. In this equation b has units of inverse length. So 1/b //is a characteristic length: a ship that travels this distance through air will lose a significant //fraction of its initial velocity + [UsedImplicitly] public static double DragLength(this CelestialBody body, Vector3d pos, double dragCoeff, double mass) { double airDensity = diff --git a/MechJeb2/DisplayModule.cs b/MechJeb2/DisplayModule.cs index aa7e2d3c1..cf3c9d981 100644 --- a/MechJeb2/DisplayModule.cs +++ b/MechJeb2/DisplayModule.cs @@ -18,18 +18,18 @@ public Rect WindowPos protected set { var newPos = new Vector4( - Math.Min(Math.Max(value.x, 0), GuiUtils.scaledScreenWidth - value.width), - Math.Min(Math.Max(value.y, 0), GuiUtils.scaledScreenHeight - value.height), + Math.Min(Math.Max(value.x, 0), GuiUtils.ScaledScreenWidth - value.width), + Math.Min(Math.Max(value.y, 0), GuiUtils.ScaledScreenHeight - value.height), value.width, value.height ); - newPos.x = Mathf.Clamp(newPos.x, 10 - value.width, GuiUtils.scaledScreenWidth - 10); - newPos.y = Mathf.Clamp(newPos.y, 10 - value.height, GuiUtils.scaledScreenHeight - 10); + newPos.x = Mathf.Clamp(newPos.x, 10 - value.width, GuiUtils.ScaledScreenWidth - 10); + newPos.y = Mathf.Clamp(newPos.y, 10 - value.height, GuiUtils.ScaledScreenHeight - 10); if (!HighLogic.LoadedSceneIsEditor) { if (WindowVector != newPos) { - Dirty = true; + Dirty = true; WindowVector = newPos; } } @@ -37,7 +37,7 @@ protected set { if (WindowVectorEditor != newPos) { - Dirty = true; + Dirty = true; WindowVectorEditor = newPos; } } @@ -66,7 +66,7 @@ public bool ShowInFlight if (ShowInFlightConfig != value) { ShowInFlightConfig = value; - Dirty = true; + Dirty = true; } } } @@ -82,7 +82,7 @@ public bool ShowInEditor { if (ShowInEditorConfig == value) return; ShowInEditorConfig = value; - Dirty = true; + Dirty = true; } } @@ -97,7 +97,7 @@ public bool IsOverlay { if (IsOverlayConfig == value) return; IsOverlayConfig = value; - Dirty = true; + Dirty = true; } } @@ -112,7 +112,7 @@ public bool Locked { if (LockedConfig == value) return; LockedConfig = value; - Dirty = true; + Dirty = true; } } @@ -150,8 +150,8 @@ protected void WindowGUI(int windowID, bool draggable) bool allowDrag = !LockedConfig; if (!LockedConfig && !IsOverlayConfig && Core.Settings.useTitlebarDragging) { - float x = Mouse.screenPos.x / GuiUtils.scale; - float y = Mouse.screenPos.y / GuiUtils.scale; + 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; } diff --git a/MechJeb2/GuiUtils.cs b/MechJeb2/GuiUtils.cs index d765e99b6..a49a8e01d 100644 --- a/MechJeb2/GuiUtils.cs +++ b/MechJeb2/GuiUtils.cs @@ -10,7 +10,7 @@ namespace MuMech { public interface IEditable { - string text { get; set; } + string Text { get; set; } } //An EditableDouble stores a double value and a text string. The user can edit the string. @@ -23,36 +23,35 @@ public class EditableDoubleMult : IEditable { [UsedImplicitly] [Persistent] - public double _val; + public double ValConfig; - public virtual double val + public virtual double Val { - get => _val; + get => ValConfig; set { - _val = value; - _text = (_val / multiplier).ToString(); + ValConfig = value; + TextConfig = (ValConfig / _multiplier).ToString(); } } - public readonly double multiplier; + private readonly double _multiplier; - public bool parsed; + protected bool Parsed; [UsedImplicitly] [Persistent] - public string _text; + public string TextConfig; - public virtual string text + public virtual string Text { - get => _text; + get => TextConfig; set { - _text = value; - _text = Regex.Replace(_text, @"[^\d+-.]", ""); //throw away junk characters - double parsedValue; - parsed = double.TryParse(_text, out parsedValue); - if (parsed) _val = parsedValue * multiplier; + TextConfig = value; + TextConfig = Regex.Replace(TextConfig, @"[^\d+-.]", ""); //throw away junk characters + Parsed = double.TryParse(TextConfig, out double parsedValue); + if (Parsed) ValConfig = parsedValue * _multiplier; } } @@ -60,12 +59,12 @@ public virtual string text public EditableDoubleMult(double val, double multiplier = 1) { - this.val = val; - this.multiplier = multiplier; - _text = (val / multiplier).ToString(); + Val = val; + _multiplier = multiplier; + TextConfig = (val / multiplier).ToString(); } - public static implicit operator double(EditableDoubleMult x) => x.val; + public static implicit operator double(EditableDoubleMult x) => x.Val; } public class EditableDouble : EditableDoubleMult @@ -82,38 +81,41 @@ public class EditableTime : EditableDouble { public EditableTime() : this(0) { } + [UsedImplicitly] public EditableTime(double seconds) : base(seconds) { - _text = GuiUtils.TimeToDHMS(seconds); + TextConfig = GuiUtils.TimeToDHMS(seconds); } - public override double val + public override double Val { - get => _val; + get => ValConfig; set { - _val = value; - _text = GuiUtils.TimeToDHMS(_val); + ValConfig = value; + TextConfig = GuiUtils.TimeToDHMS(ValConfig); } } - public override string text + public override string Text { - get => _text; + get => TextConfig; set { - _text = value; - _text = Regex.Replace(_text, @"[^\d+-.ydhms ,]", ""); //throw away junk characters - - double parsedValue; - parsed = double.TryParse(_text, out parsedValue); - if (parsed) _val = parsedValue; + TextConfig = value; + TextConfig = Regex.Replace(TextConfig, @"[^\d+-.ydhms ,]", ""); //throw away junk characters - if (!parsed) + Parsed = double.TryParse(TextConfig, out double parsedValue); + switch (Parsed) { - parsed = GuiUtils.TryParseDHMS(_text, out parsedValue); - if (parsed) _val = parsedValue; + case true: + ValConfig = parsedValue; + break; + case false: + Parsed = GuiUtils.TryParseDHMS(TextConfig, out parsedValue); + if (Parsed) ValConfig = parsedValue; + break; } } } @@ -123,32 +125,36 @@ public override string text public class EditableAngle { + [UsedImplicitly] [Persistent] - public EditableDouble degrees = 0; + public readonly EditableDouble Degrees; + [UsedImplicitly] [Persistent] - public EditableDouble minutes = 0; + public readonly EditableDouble Minutes; + [UsedImplicitly] [Persistent] - public EditableDouble seconds = 0; + public readonly EditableDouble Seconds; + [UsedImplicitly] [Persistent] - public bool negative; + public bool Negative; public EditableAngle(double angle) { angle = MuUtils.ClampDegrees180(angle); - negative = angle < 0; + Negative = angle < 0; angle = Math.Abs(angle); - degrees = (int)angle; - angle -= degrees; - minutes = (int)(60 * angle); - angle -= minutes / 60; - seconds = Math.Round(3600 * angle); + Degrees = new EditableDouble((int)angle); + angle -= Degrees.Val; + Minutes = new EditableDouble((int)(60 * angle)); + angle -= Minutes.Val / 60; + Seconds = new EditableDouble(Math.Round(3600 * angle)); } - public static implicit operator double(EditableAngle x) => (x.negative ? -1 : 1) * (x.degrees + x.minutes / 60.0 + x.seconds / 3600.0); + public static implicit operator double(EditableAngle x) => (x.Negative ? -1 : 1) * (x.Degrees + x.Minutes / 60.0 + x.Seconds / 3600.0); public static implicit operator EditableAngle(double x) => new EditableAngle(x); @@ -157,14 +163,14 @@ public enum Direction { NS, EW } public void DrawEditGUI(Direction direction) { GUILayout.BeginHorizontal(); - degrees.text = GUILayout.TextField(degrees.text, GUILayout.Width(30)); + Degrees.Text = GUILayout.TextField(Degrees.Text, GUILayout.Width(30)); GUILayout.Label("°", GUILayout.ExpandWidth(false)); - minutes.text = GUILayout.TextField(minutes.text, GUILayout.Width(30)); + Minutes.Text = GUILayout.TextField(Minutes.Text, GUILayout.Width(30)); GUILayout.Label("'", GUILayout.ExpandWidth(false)); - seconds.text = GUILayout.TextField(seconds.text, GUILayout.Width(30)); + Seconds.Text = GUILayout.TextField(Seconds.Text, GUILayout.Width(30)); GUILayout.Label("\"", GUILayout.ExpandWidth(false)); - string dirString = direction == Direction.NS ? negative ? "S" : "N" : negative ? "W" : "E"; - if (GUILayout.Button(dirString, GUILayout.Width(25))) negative = !negative; + string dirString = direction == Direction.NS ? Negative ? "S" : "N" : Negative ? "W" : "E"; + if (GUILayout.Button(dirString, GUILayout.Width(25))) Negative = !Negative; GUILayout.EndHorizontal(); } } @@ -173,15 +179,15 @@ public class EditableInt : IEditable { [UsedImplicitly] [Persistent] - public int _val; + public int ValConfig; - public int val + public int Val { - get => _val; + get => ValConfig; set { - _val = value; - _text = value.ToString(); + ValConfig = value; + TextConfig = value.ToString(); } } @@ -189,27 +195,27 @@ public int val [UsedImplicitly] [Persistent] - public string _text; + public string TextConfig; - public virtual string text + public virtual string Text { - get => _text; + get => TextConfig; set { - _text = value; - _text = Regex.Replace(_text, @"[^\d+-]", ""); //throw away junk characters - _parsed = int.TryParse(_text, out int parsedValue); - if (_parsed) val = parsedValue; + TextConfig = value; + TextConfig = Regex.Replace(TextConfig, @"[^\d+-]", ""); //throw away junk characters + _parsed = int.TryParse(TextConfig, out int parsedValue); + if (_parsed) Val = parsedValue; } } public EditableInt(int val) { - this.val = val; - _text = val.ToString(); + Val = val; + TextConfig = val.ToString(); } - public static implicit operator int(EditableInt x) => x.val; + public static implicit operator int(EditableInt x) => x.Val; public static implicit operator EditableInt(int x) => new EditableInt(x); } @@ -217,23 +223,23 @@ public EditableInt(int val) public class EditableIntList : IEditable { [Persistent] - public readonly List val = new List(); + public readonly List Val = new List(); [UsedImplicitly] [Persistent] - public string _text = ""; + public string TextConfig = ""; - public string text + public string Text { - get => _text; + get => TextConfig; set { - _text = value; - _text = Regex.Replace(_text, @"[^\d-,]", ""); //throw away junk characters - val.Clear(); + TextConfig = value; + TextConfig = Regex.Replace(TextConfig, @"[^\d-,]", ""); //throw away junk characters + Val.Clear(); // supports "1,2,3" and "1-3" - foreach (string x in _text.Split(',')) + foreach (string x in TextConfig.Split(',')) { string[] y = x.Split('-'); @@ -241,7 +247,7 @@ public string text if (!int.TryParse(y[y.Length - 1].Trim(), out int end)) continue; for (int n = start; n <= end; n++) - val.Add(n); + Val.Add(n); } } } @@ -252,7 +258,7 @@ public class ZombieGUILoader : MonoBehaviour private void OnGUI() { GuiUtils.CopyDefaultSkin(); - if (GuiUtils.skin == null) GuiUtils.skin = GuiUtils.defaultSkin; + if (GuiUtils.Skin == null) GuiUtils.Skin = GuiUtils.DefaultSkin; Destroy(gameObject); } } @@ -261,19 +267,17 @@ public static class GuiUtils { private static GUIStyle _yellowOnHover; - public static GUIStyle yellowOnHover + public static GUIStyle YellowOnHover { get { - if (_yellowOnHover == null) - { - _yellowOnHover = new GUIStyle(GUI.skin.label); - _yellowOnHover.hover.textColor = Color.yellow; - var t = new Texture2D(1, 1); - t.SetPixel(0, 0, new Color(0, 0, 0, 0)); - t.Apply(); - _yellowOnHover.hover.background = t; - } + if (_yellowOnHover != null) return _yellowOnHover; + + _yellowOnHover = new GUIStyle(GUI.skin.label) { hover = { textColor = Color.yellow } }; + var t = new Texture2D(1, 1); + t.SetPixel(0, 0, new Color(0, 0, 0, 0)); + t.Apply(); + _yellowOnHover.hover.background = t; return _yellowOnHover; } @@ -281,16 +285,13 @@ public static GUIStyle yellowOnHover private static GUIStyle _yellowLabel; - public static GUIStyle yellowLabel + public static GUIStyle YellowLabel { get { - if (_yellowLabel == null) - { - _yellowLabel = new GUIStyle(GUI.skin.label); - _yellowLabel.normal.textColor = Color.yellow; - _yellowLabel.hover.textColor = Color.yellow; - } + if (_yellowLabel != null) return _yellowLabel; + + _yellowLabel = new GUIStyle(GUI.skin.label) { normal = { textColor = Color.yellow }, hover = { textColor = Color.yellow } }; return _yellowLabel; } @@ -298,16 +299,13 @@ public static GUIStyle yellowLabel private static GUIStyle _redLabel; - public static GUIStyle redLabel + public static GUIStyle RedLabel { get { - if (_redLabel == null) - { - _redLabel = new GUIStyle(GUI.skin.label); - _redLabel.normal.textColor = Color.red; - _redLabel.hover.textColor = Color.red; - } + if (_redLabel != null) return _redLabel; + + _redLabel = new GUIStyle(GUI.skin.label) { normal = { textColor = Color.red }, hover = { textColor = Color.red } }; return _redLabel; } @@ -315,16 +313,13 @@ public static GUIStyle redLabel private static GUIStyle _greenLabel; - public static GUIStyle greenLabel + public static GUIStyle GreenLabel { get { - if (_greenLabel == null) - { - _greenLabel = new GUIStyle(GUI.skin.label); - _greenLabel.normal.textColor = Color.green; - _greenLabel.hover.textColor = Color.green; - } + if (_greenLabel != null) return _greenLabel; + + _greenLabel = new GUIStyle(GUI.skin.label) { normal = { textColor = Color.green }, hover = { textColor = Color.green } }; return _greenLabel; } @@ -332,16 +327,13 @@ public static GUIStyle greenLabel private static GUIStyle _orangeLabel; - public static GUIStyle orangeLabel + public static GUIStyle OrangeLabel { get { - if (_orangeLabel == null) - { - _orangeLabel = new GUIStyle(GUI.skin.label); - _orangeLabel.normal.textColor = Color.green; - _orangeLabel.hover.textColor = Color.green; - } + if (_orangeLabel != null) return _orangeLabel; + + _orangeLabel = new GUIStyle(GUI.skin.label) { normal = { textColor = Color.green }, hover = { textColor = Color.green } }; return _orangeLabel; } @@ -349,15 +341,13 @@ public static GUIStyle orangeLabel private static GUIStyle _middleCenterLabel; - public static GUIStyle middleCenterLabel + public static GUIStyle MiddleCenterLabel { get { - if (_middleCenterLabel == null) - { - _middleCenterLabel = new GUIStyle(GUI.skin.label); - _middleCenterLabel.alignment = TextAnchor.MiddleCenter; - } + if (_middleCenterLabel != null) return _middleCenterLabel; + + _middleCenterLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }; return _middleCenterLabel; } @@ -365,63 +355,45 @@ public static GUIStyle middleCenterLabel private static GUIStyle _middleRightLabel; - public static GUIStyle middleRightLabel + public static GUIStyle MiddleRightLabel { get { - if (_middleRightLabel == null) - { - _middleRightLabel = new GUIStyle(GUI.skin.label); - _middleRightLabel.alignment = TextAnchor.MiddleRight; - } + if (_middleRightLabel != null) return _middleRightLabel; + + _middleRightLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleRight }; return _middleRightLabel; } } - private static GUIStyle _UpperCenterLabel; + private static GUIStyle _upperCenterLabel; public static GUIStyle UpperCenterLabel { get { - if (_UpperCenterLabel == null) - { - _UpperCenterLabel = new GUIStyle(GUI.skin.label); - _UpperCenterLabel.alignment = TextAnchor.UpperCenter; - } + if (_upperCenterLabel != null) return _upperCenterLabel; - return _UpperCenterLabel; + _upperCenterLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.UpperCenter }; + + return _upperCenterLabel; } } private static GUIStyle _labelNoWrap; - public static GUIStyle LabelNoWrap - { - get - { - if (_labelNoWrap == null) - { - _labelNoWrap = new GUIStyle(GUI.skin.label) { wordWrap = false }; - } - - return _labelNoWrap; - } - } + public static GUIStyle LabelNoWrap => _labelNoWrap ??= new GUIStyle(GUI.skin.label) { wordWrap = false }; private static GUIStyle _greenToggle; - public static GUIStyle greenToggle + public static GUIStyle GreenToggle { get { - if (_greenToggle == null) - { - _greenToggle = new GUIStyle(GUI.skin.toggle); - _greenToggle.onHover.textColor = Color.green; - _greenToggle.onNormal.textColor = Color.green; - } + if (_greenToggle != null) return _greenToggle; + + _greenToggle = new GUIStyle(GUI.skin.toggle) { onHover = { textColor = Color.green }, onNormal = { textColor = Color.green } }; return _greenToggle; } @@ -429,16 +401,13 @@ public static GUIStyle greenToggle private static GUIStyle _redToggle; - public static GUIStyle redToggle + public static GUIStyle RedToggle { get { - if (_redToggle == null) - { - _redToggle = new GUIStyle(GUI.skin.toggle); - _redToggle.onHover.textColor = Color.red; - _redToggle.onNormal.textColor = Color.red; - } + if (_redToggle != null) return _redToggle; + + _redToggle = new GUIStyle(GUI.skin.toggle) { onHover = { textColor = Color.red }, onNormal = { textColor = Color.red } }; return _redToggle; } @@ -446,111 +415,104 @@ public static GUIStyle redToggle private static GUIStyle _yellowToggle; - public static GUIStyle yellowToggle - { - get - { - if (_yellowToggle == null) - { - _yellowToggle = new GUIStyle(GUI.skin.toggle); - _yellowToggle.onHover.textColor = Color.yellow; - _yellowToggle.onNormal.textColor = Color.yellow; - } + public static GUIStyle YellowToggle => _yellowToggle ??= + new GUIStyle(GUI.skin.toggle) { onHover = { textColor = Color.yellow }, onNormal = { textColor = Color.yellow } }; - return _yellowToggle; - } - } + public enum SkinType { DEFAULT, MECH_JEB1, COMPACT } - public enum SkinType { Default, MechJeb1, Compact } - - public static GUISkin skin; - public static float scale = 1; - public static int scaledScreenWidth = 1; - public static int scaledScreenHeight = 1; - public static bool dontUseDropDownMenu = false; - public static bool showAdvancedWindowSettings = false; - public static GUISkin defaultSkin; - public static GUISkin compactSkin; - public static GUISkin transparentSkin; + public static GUISkin Skin; + public static float Scale = 1; + public static int ScaledScreenWidth = 1; + public static int ScaledScreenHeight = 1; + public static bool DontUseDropDownMenu = false; + public static bool ShowAdvancedWindowSettings = false; + public static GUISkin DefaultSkin; + public static GUISkin CompactSkin; + public static GUISkin TransparentSkin; public static void SetGUIScale(double s) { - scale = Mathf.Clamp((float)s, 0.2f, 5f); - scaledScreenHeight = Mathf.RoundToInt(Screen.height / scale); - scaledScreenWidth = Mathf.RoundToInt(Screen.width / scale); + Scale = Mathf.Clamp((float)s, 0.2f, 5f); + ScaledScreenHeight = Mathf.RoundToInt(Screen.height / Scale); + ScaledScreenWidth = Mathf.RoundToInt(Screen.width / Scale); } public static void CopyDefaultSkin() { GUI.skin = null; - defaultSkin = Object.Instantiate(GUI.skin); + DefaultSkin = Object.Instantiate(GUI.skin); } + [UsedImplicitly] public static void CopyCompactSkin() { GUI.skin = null; - compactSkin = Object.Instantiate(GUI.skin); + CompactSkin = Object.Instantiate(GUI.skin); - skin.name = "KSP Compact"; + Skin.name = "KSP Compact"; - compactSkin.label.margin = new RectOffset(1, 1, 1, 1); - compactSkin.label.padding = new RectOffset(0, 0, 2, 2); + CompactSkin.label.margin = new RectOffset(1, 1, 1, 1); + CompactSkin.label.padding = new RectOffset(0, 0, 2, 2); - compactSkin.button.margin = new RectOffset(1, 1, 1, 1); - compactSkin.button.padding = new RectOffset(4, 4, 2, 2); + CompactSkin.button.margin = new RectOffset(1, 1, 1, 1); + CompactSkin.button.padding = new RectOffset(4, 4, 2, 2); - compactSkin.toggle.margin = new RectOffset(1, 1, 1, 1); - compactSkin.toggle.padding = new RectOffset(15, 0, 2, 0); + CompactSkin.toggle.margin = new RectOffset(1, 1, 1, 1); + CompactSkin.toggle.padding = new RectOffset(15, 0, 2, 0); - compactSkin.textField.margin = new RectOffset(1, 1, 1, 1); - compactSkin.textField.padding = new RectOffset(2, 2, 2, 2); + CompactSkin.textField.margin = new RectOffset(1, 1, 1, 1); + CompactSkin.textField.padding = new RectOffset(2, 2, 2, 2); - compactSkin.textArea.margin = new RectOffset(1, 1, 1, 1); - compactSkin.textArea.padding = new RectOffset(2, 2, 2, 2); + CompactSkin.textArea.margin = new RectOffset(1, 1, 1, 1); + CompactSkin.textArea.padding = new RectOffset(2, 2, 2, 2); - compactSkin.window.margin = new RectOffset(0, 0, 0, 0); - compactSkin.window.padding = new RectOffset(5, 5, 20, 5); + CompactSkin.window.margin = new RectOffset(0, 0, 0, 0); + CompactSkin.window.padding = new RectOffset(5, 5, 20, 5); } - public static void CopyTransparentSkin() + private static void CopyTransparentSkin() { GUI.skin = null; - transparentSkin = Object.Instantiate(GUI.skin); + TransparentSkin = Object.Instantiate(GUI.skin); var t = new Texture2D(1, 1); t.SetPixel(0, 0, new Color(0, 0, 0, 0)); t.Apply(); - transparentSkin.window.normal.background = t; - transparentSkin.window.onNormal.background = t; - transparentSkin.window.padding = new RectOffset(5, 5, 5, 5); + TransparentSkin.window.normal.background = t; + TransparentSkin.window.onNormal.background = t; + TransparentSkin.window.padding = new RectOffset(5, 5, 5, 5); } public static void LoadSkin(SkinType skinType) { - if (defaultSkin == null) CopyDefaultSkin(); - if (compactSkin == null) CopyCompactSkin(); - if (transparentSkin == null) CopyTransparentSkin(); + if (DefaultSkin == null) CopyDefaultSkin(); + if (CompactSkin == null) CopyCompactSkin(); + if (TransparentSkin == null) CopyTransparentSkin(); switch (skinType) { - case SkinType.Default: - skin = defaultSkin; + case SkinType.DEFAULT: + Skin = DefaultSkin; break; - case SkinType.MechJeb1: - skin = AssetBase.GetGUISkin("KSP window 2"); + case SkinType.MECH_JEB1: + Skin = AssetBase.GetGUISkin("KSP window 2"); break; - case SkinType.Compact: - skin = compactSkin; + case SkinType.COMPACT: + Skin = CompactSkin; break; } } private static GUILayoutOption _layoutExpandWidth, _layoutNoExpandWidth; - public static GUILayoutOption LayoutExpandWidth => _layoutExpandWidth ??= GUILayout.ExpandWidth(true); - public static GUILayoutOption LayoutNoExpandWidth => _layoutNoExpandWidth ??= GUILayout.ExpandWidth(false); + + [UsedImplicitly] + public static GUILayoutOption LayoutExpandWidth => _layoutExpandWidth ??= GUILayout.ExpandWidth(true); + + [UsedImplicitly] + public static GUILayoutOption LayoutNoExpandWidth => _layoutNoExpandWidth ??= GUILayout.ExpandWidth(false); public static GUILayoutOption ExpandWidth(bool b) => b ? LayoutExpandWidth : LayoutNoExpandWidth; @@ -568,10 +530,10 @@ public static void SimpleTextField(IEditable ed, float width = 100, bool expandW { Profiler.BeginSample("SimpleTextField"); string res = !expandWidth - ? GUILayout.TextField(ed.text, LayoutWidth(width), ExpandWidth(expandWidth)) - : GUILayout.TextField(ed.text, LayoutWidth(width)); - if (res != null && !res.Equals(ed.text)) - ed.text = res; + ? GUILayout.TextField(ed.Text, LayoutWidth(width), ExpandWidth(false)) + : GUILayout.TextField(ed.Text, LayoutWidth(width)); + if (res != null && !res.Equals(ed.Text)) + ed.Text = res; Profiler.EndSample(); } @@ -647,38 +609,24 @@ public static int ArrowSelector(int index, int numIndices, Action centerGuiActio private static GUIStyle _arrowSelectorStyeGuiStyleExpand; - public static GUIStyle arrowSelectorStyeGuiStyleExpand - { - get - { - if (_arrowSelectorStyeGuiStyleExpand == null) - { - _arrowSelectorStyeGuiStyleExpand = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, stretchWidth = true }; - } - - return _arrowSelectorStyeGuiStyleExpand; - } - } + [UsedImplicitly] + public static GUIStyle ArrowSelectorStyeGuiStyleExpand => _arrowSelectorStyeGuiStyleExpand ??= + new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, stretchWidth = true }; private static GUIStyle _arrowSelectorStyeGuiStyleNoExpand; - public static GUIStyle arrowSelectorStyeGuiStyleNoExpand - { - get - { - if (_arrowSelectorStyeGuiStyleNoExpand == null) - { - _arrowSelectorStyeGuiStyleNoExpand = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, stretchWidth = false }; - } - - return _arrowSelectorStyeGuiStyleNoExpand; - } - } + [UsedImplicitly] + public static GUIStyle ArrowSelectorStyeGuiStyleNoExpand => _arrowSelectorStyeGuiStyleNoExpand ??= + new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, stretchWidth = false }; public static int ArrowSelector(int index, int modulo, string label, bool expandWidth = true) { - Action drawLabel = () => GUILayout.Label(label, expandWidth ? arrowSelectorStyeGuiStyleExpand : arrowSelectorStyeGuiStyleNoExpand); - return ArrowSelector(index, modulo, drawLabel); + return ArrowSelector(index, modulo, DrawLabel); + + void DrawLabel() + { + GUILayout.Label(label, expandWidth ? ArrowSelectorStyeGuiStyleExpand : ArrowSelectorStyeGuiStyleNoExpand); + } } public static int HoursPerDay => GameSettings.KERBIN_TIME ? 6 : 24; @@ -743,14 +691,12 @@ public static bool TryParseDHMS(string s, out double seconds) { s = s.Trim(' ', ',', '-'); int unitPos = s.IndexOf(units[i]); - if (unitPos != -1) - { - double value; - if (!double.TryParse(s.Substring(0, unitPos), out value)) return false; - seconds += value * intervals[i]; - s = s.Substring(unitPos + 1); - parsedSomething = true; - } + if (unitPos == -1) continue; + + if (!double.TryParse(s.Substring(0, unitPos), out double value)) return false; + seconds += value * intervals[i]; + s = s.Substring(unitPos + 1); + parsedSomething = true; } if (minus) seconds = -seconds; @@ -758,17 +704,18 @@ public static bool TryParseDHMS(string s, out double seconds) return parsedSomething; } - public static double ArcDistance(Vector3 From, Vector3 To) + private static double ArcDistance(Vector3 from, Vector3 to) { - double a = (FlightGlobals.ActiveVessel.mainBody.transform.position - From).magnitude; - double b = (FlightGlobals.ActiveVessel.mainBody.transform.position - To).magnitude; - double c = Vector3d.Distance(From, To); + Vector3 position = FlightGlobals.ActiveVessel.mainBody.transform.position; + double a = (position - from).magnitude; + double b = (position - to).magnitude; + double c = Vector3d.Distance(from, to); double ang = Math.Acos((a * a + b * b - c * c) / (2f * a * b)); return ang * FlightGlobals.ActiveVessel.mainBody.Radius; } - public static double FromToETA(Vector3 From, Vector3 To, double Speed = 0) => - ArcDistance(From, To) / (Speed > 0 ? Speed : FlightGlobals.ActiveVessel.horizontalSrfSpeed); + public static double FromToETA(Vector3 from, Vector3 to, double speed = 0) => + ArcDistance(from, to) / (speed > 0 ? speed : FlightGlobals.ActiveVessel.horizontalSrfSpeed); public static bool MouseIsOverWindow(MechJebCore core) { @@ -776,7 +723,7 @@ public static bool MouseIsOverWindow(MechJebCore core) 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)) + && m.WindowPos.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y) / Scale)) { return true; } @@ -790,21 +737,18 @@ public static Coordinates GetMouseCoordinates(CelestialBody body) Ray mouseRay = PlanetariumCamera.Camera.ScreenPointToRay(Input.mousePosition); mouseRay.origin = ScaledSpace.ScaledToLocalSpace(mouseRay.origin); Vector3d relOrigin = mouseRay.origin - body.position; - Vector3d relSurfacePosition; double curRadius = body.pqsController.radiusMax; double lastRadius = 0; - double error = 0; int loops = 0; - float st = Time.time; while (loops < 50) { - if (PQS.LineSphereIntersection(relOrigin, mouseRay.direction, curRadius, out relSurfacePosition)) + if (PQS.LineSphereIntersection(relOrigin, mouseRay.direction, curRadius, out Vector3d relSurfacePosition)) { Vector3d surfacePoint = body.position + relSurfacePosition; double alt = body.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(body.GetLongitude(surfacePoint), Vector3d.down) * QuaternionD.AngleAxis(body.GetLatitude(surfacePoint), Vector3d.forward) * Vector3d.right); - error = Math.Abs(curRadius - alt); + double error = Math.Abs(curRadius - alt); if (error < (body.pqsController.radiusMax - body.pqsController.radiusMin) / 100) { return new Coordinates(body.GetLatitude(surfacePoint), MuUtils.ClampDegrees180(body.GetLongitude(surfacePoint))); @@ -830,6 +774,7 @@ public static Coordinates GetMouseCoordinates(CelestialBody body) return null; } + [UsedImplicitly] public class ComboBox { // Easy to use combobox class @@ -840,57 +785,55 @@ public class ComboBox // There is currently no way of knowing when a choice has been made // Position of the popup - private static Rect rect; + private static Rect _rect; // Identifier of the caller of the popup, null if nobody is waiting for a value - private static object popupOwner; - private static string[] entries; + private static object _popupOwner; + private static string[] _entries; - private static bool popupActive; + private static bool _popupActive; // Result to be returned to the owner - private static int selectedItem; + private static int _selectedItem; // Unity identifier of the window, just needs to be unique - private static readonly int id = GUIUtility.GetControlID(FocusType.Passive); + private static readonly int _id = GUIUtility.GetControlID(FocusType.Passive); // ComboBox GUI Style - private static readonly GUIStyle style; + private static readonly GUIStyle _style; static ComboBox() { - style = new GUIStyle(GUI.skin.window); - style.normal.background = null; - style.onNormal.background = null; - style.border.top = style.border.bottom; - style.padding.top = style.padding.bottom; + _style = new GUIStyle(GUI.skin.window) { normal = { background = null }, onNormal = { background = null } }; + _style.border.top = _style.border.bottom; + _style.padding.top = _style.padding.bottom; } public static void DrawGUI() { - if (popupOwner == null || rect.height == 0 || !popupActive) + if (_popupOwner == null || _rect.height == 0 || !_popupActive) return; - if (style.normal.background == null) + if (_style.normal.background == null) { - style.normal.background = MechJebBundlesManager.comboBoxBackground; - style.onNormal.background = MechJebBundlesManager.comboBoxBackground; + _style.normal.background = MechJebBundlesManager.comboBoxBackground; + _style.onNormal.background = MechJebBundlesManager.comboBoxBackground; } // Make sure the rectangle is fully on screen - rect.x = Math.Max(0, Math.Min(rect.x, scaledScreenWidth - rect.width)); - rect.y = Math.Max(0, Math.Min(rect.y, scaledScreenHeight - rect.height)); + _rect.x = Math.Max(0, Math.Min(_rect.x, ScaledScreenWidth - _rect.width)); + _rect.y = Math.Max(0, Math.Min(_rect.y, ScaledScreenHeight - _rect.height)); - rect = GUILayout.Window(id, rect, identifier => + _rect = GUILayout.Window(_id, _rect, identifier => { - selectedItem = GUILayout.SelectionGrid(-1, entries, 1, yellowOnHover); + _selectedItem = GUILayout.SelectionGrid(-1, _entries, 1, YellowOnHover); if (GUI.changed) - popupActive = false; - }, "", style); + _popupActive = false; + }, "", _style); //Cancel the popup if we click outside - if (Event.current.type == EventType.MouseDown && !rect.Contains(Event.current.mousePosition)) - popupOwner = null; + if (Event.current.type == EventType.MouseDown && !_rect.Contains(Event.current.mousePosition)) + _popupOwner = null; } public static int Box(int selectedItem, string[] entries, object caller, bool expandWidth = true) @@ -907,14 +850,14 @@ public static int Box(int selectedItem, string[] entries, object caller, bool ex if (selectedItem >= entries.Length) selectedItem = entries.Length - 1; - if (dontUseDropDownMenu) + if (DontUseDropDownMenu) return ArrowSelector(selectedItem, entries.Length, entries[selectedItem], expandWidth); // A choice has been made, update the return value - if (popupOwner == caller && !popupActive) + if (_popupOwner == caller && !_popupActive) { - popupOwner = null; - selectedItem = ComboBox.selectedItem; + _popupOwner = null; + selectedItem = _selectedItem; GUI.changed = true; } @@ -924,23 +867,23 @@ public static int Box(int selectedItem, string[] entries, object caller, bool ex // We will set the changed status when we return from the menu instead GUI.changed = guiChanged; // Update the global state with the new items - popupOwner = caller; - popupActive = true; - ComboBox.entries = entries; + _popupOwner = caller; + _popupActive = true; + _entries = entries; // Magic value to force position update during repaint event - rect = new Rect(0, 0, 0, 0); + _rect = new Rect(0, 0, 0, 0); } // The GetLastRect method only works during repaint event, but the Button will return false during repaint - if (Event.current.type == EventType.Repaint && popupOwner == caller && rect.height == 0) + if (Event.current.type == EventType.Repaint && _popupOwner == caller && _rect.height == 0) { - rect = GUILayoutUtility.GetLastRect(); + _rect = GUILayoutUtility.GetLastRect(); // But even worse, I can't find a clean way to convert from relative to absolute coordinates Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; Vector2 clippedMousePos = Event.current.mousePosition; - rect.x = (rect.x + mousePos.x) / scale - clippedMousePos.x; - rect.y = (rect.y + mousePos.y) / scale - clippedMousePos.y; + _rect.x = (_rect.x + mousePos.x) / Scale - clippedMousePos.x; + _rect.y = (_rect.y + mousePos.y) / Scale - clippedMousePos.y; } return selectedItem; @@ -950,15 +893,16 @@ public static int Box(int selectedItem, string[] entries, object caller, bool ex public class Coordinates { - public double latitude; - public double longitude; + public readonly double Latitude; + public readonly double Longitude; public Coordinates(double latitude, double longitude) { - this.latitude = latitude; - this.longitude = longitude; + this.Latitude = latitude; + this.Longitude = longitude; } + [UsedImplicitly] public static string ToStringDecimal(double latitude, double longitude, bool newline = false, int precision = 3) { double clampedLongitude = MuUtils.ClampDegrees180(longitude); @@ -968,7 +912,7 @@ public static string ToStringDecimal(double latitude, double longitude, bool new + longitudeAbs.ToString("F" + precision) + "° " + (clampedLongitude > 0 ? "E" : "W"); } - public string ToStringDecimal(bool newline = false, int precision = 3) => ToStringDecimal(latitude, longitude, newline, precision); + public string ToStringDecimal(bool newline = false, int precision = 3) => ToStringDecimal(Latitude, Longitude, newline, precision); public static string ToStringDMS(double latitude, double longitude, bool newline = false) { @@ -977,7 +921,7 @@ public static string ToStringDMS(double latitude, double longitude, bool newline + AngleToDMS(clampedLongitude) + (clampedLongitude > 0 ? " E" : " W"); } - public string ToStringDMS(bool newline = false) => ToStringDMS(latitude, longitude, newline); + public string ToStringDMS(bool newline = false) => ToStringDMS(Latitude, Longitude, newline); public static string AngleToDMS(double angle) { @@ -985,142 +929,146 @@ public static string AngleToDMS(double angle) int minutes = (int)Math.Floor(60 * (Math.Abs(angle) - degrees)); int seconds = (int)Math.Floor(3600 * (Math.Abs(angle) - degrees - minutes / 60.0)); - return string.Format("{0:0}° {1:00}' {2:00}\"", degrees, minutes, seconds); + return $"{degrees:0}° {minutes:00}' {seconds:00}\""; } } public static class ColorPickerHSV { - private static Texture2D displayPicker; + private static Texture2D _displayPicker; - public static Color setColor; - private static Color lastSetColor; + [UsedImplicitly] + public static Color SetColor; - private static readonly int textureWidth = 240; - private static readonly int textureHeight = 240; + private static Color _lastSetColor; - private static float saturationSlider; - private static float alphaSlider; - private static Texture2D saturationTexture; + private const int TEXTURE_WIDTH = 240; + private const int TEXTURE_HEIGHT = 240; + + private static float _saturationSlider; + private static float _alphaSlider; + private static Texture2D _saturationTexture; private static void Init() { - displayPicker = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false); - for (int i = 0; i < textureWidth; i++) + _displayPicker = new Texture2D(TEXTURE_WIDTH, TEXTURE_HEIGHT, TextureFormat.ARGB32, false); + for (int i = 0; i < TEXTURE_WIDTH; i++) { - for (int j = 0; j < textureHeight; j++) + for (int j = 0; j < TEXTURE_HEIGHT; j++) { - displayPicker.SetPixel(i, j, MuUtils.HSVtoRGB(360f / textureWidth * i, 1.0f / j * textureHeight, 1.0f, 1f)); + _displayPicker.SetPixel(i, j, MuUtils.HSVtoRGB(360f / TEXTURE_WIDTH * i, 1.0f / j * TEXTURE_HEIGHT, 1.0f, 1f)); } } - displayPicker.Apply(); + _displayPicker.Apply(); float v = 0.0F; - float diff = 1.0f / textureHeight; - saturationTexture = new Texture2D(20, textureHeight); - for (int i = 0; i < saturationTexture.width; i++) + float diff = 1.0f / TEXTURE_HEIGHT; + _saturationTexture = new Texture2D(20, TEXTURE_HEIGHT); + for (int i = 0; i < _saturationTexture.width; i++) { - for (int j = 0; j < saturationTexture.height; j++) + for (int j = 0; j < _saturationTexture.height; j++) { - saturationTexture.SetPixel(i, j, new Color(v, v, v)); + _saturationTexture.SetPixel(i, j, new Color(v, v, v)); v += diff; } v = 0.0F; } - saturationTexture.Apply(); + _saturationTexture.Apply(); } public static void DrawGUI(int positionLeft, int positionTop) { - if (!displayPicker) + if (!_displayPicker) Init(); - GUI.Box(new Rect(positionLeft - 3, positionTop - 3, textureWidth + 90, textureHeight + 30), ""); + GUI.Box(new Rect(positionLeft - 3, positionTop - 3, TEXTURE_WIDTH + 90, TEXTURE_HEIGHT + 30), ""); - if (GUI.RepeatButton(new Rect(positionLeft, positionTop, textureWidth, textureHeight), displayPicker)) + if (GUI.RepeatButton(new Rect(positionLeft, positionTop, TEXTURE_WIDTH, TEXTURE_HEIGHT), _displayPicker)) { int a = (int)Input.mousePosition.x; int b = Screen.height - (int)Input.mousePosition.y; - setColor = displayPicker.GetPixel(a - positionLeft, -(b - positionTop)); - lastSetColor = setColor; + SetColor = _displayPicker.GetPixel(a - positionLeft, -(b - positionTop)); + _lastSetColor = SetColor; } - saturationSlider = GUI.VerticalSlider(new Rect(positionLeft + textureWidth + 3, positionTop, 10, textureHeight), saturationSlider, 1, 0); - setColor = lastSetColor + new Color(saturationSlider, saturationSlider, saturationSlider); - GUI.Box(new Rect(positionLeft + textureWidth + 20, positionTop, 20, textureHeight), saturationTexture); + _saturationSlider = GUI.VerticalSlider(new Rect(positionLeft + TEXTURE_WIDTH + 3, positionTop, 10, TEXTURE_HEIGHT), _saturationSlider, 1, + 0); + SetColor = _lastSetColor + new Color(_saturationSlider, _saturationSlider, _saturationSlider); + GUI.Box(new Rect(positionLeft + TEXTURE_WIDTH + 20, positionTop, 20, TEXTURE_HEIGHT), _saturationTexture); - alphaSlider = GUI.VerticalSlider(new Rect(positionLeft + textureWidth + 3 + 10 + 20 + 10, positionTop, 10, textureHeight), alphaSlider, 1, + _alphaSlider = GUI.VerticalSlider(new Rect(positionLeft + TEXTURE_WIDTH + 3 + 10 + 20 + 10, positionTop, 10, TEXTURE_HEIGHT), + _alphaSlider, 1, 0); - setColor.a = alphaSlider; - GUI.Box(new Rect(positionLeft + textureWidth + 20 + 10 + 20 + 10, positionTop, 20, textureHeight), saturationTexture); + SetColor.a = _alphaSlider; + GUI.Box(new Rect(positionLeft + TEXTURE_WIDTH + 20 + 10 + 20 + 10, positionTop, 20, TEXTURE_HEIGHT), _saturationTexture); } } public static class ColorPickerRGB { - private static readonly int textureWidth = 240; - private static readonly int textureHeight = 10; + private const int TEXTURE_WIDTH = 240; + private const int TEXTURE_HEIGHT = 10; - private static Texture2D rTexture; - private static Texture2D gTexture; - private static Texture2D bTexture; - private static Texture2D aTexture; + private static Texture2D _rTexture; + private static Texture2D _gTexture; + private static Texture2D _bTexture; + private static Texture2D _aTexture; private static void Init() { - rTexture = new Texture2D(textureWidth, 1); - gTexture = new Texture2D(textureWidth, 1); - bTexture = new Texture2D(textureWidth, 1); - aTexture = new Texture2D(textureWidth, 1); - for (int i = 0; i < textureWidth; i++) + _rTexture = new Texture2D(TEXTURE_WIDTH, 1); + _gTexture = new Texture2D(TEXTURE_WIDTH, 1); + _bTexture = new Texture2D(TEXTURE_WIDTH, 1); + _aTexture = new Texture2D(TEXTURE_WIDTH, 1); + for (int i = 0; i < TEXTURE_WIDTH; i++) { - float v = (float)i / (textureWidth - 1); - rTexture.SetPixel(i, 0, new Color(v, 0, 0)); - gTexture.SetPixel(i, 0, new Color(0, v, 0)); - bTexture.SetPixel(i, 0, new Color(0, 0, v)); - aTexture.SetPixel(i, 0, new Color(v, v, v)); + float v = (float)i / (TEXTURE_WIDTH - 1); + _rTexture.SetPixel(i, 0, new Color(v, 0, 0)); + _gTexture.SetPixel(i, 0, new Color(0, v, 0)); + _bTexture.SetPixel(i, 0, new Color(0, 0, v)); + _aTexture.SetPixel(i, 0, new Color(v, v, v)); } - rTexture.Apply(); - gTexture.Apply(); - bTexture.Apply(); - aTexture.Apply(); + _rTexture.Apply(); + _gTexture.Apply(); + _bTexture.Apply(); + _aTexture.Apply(); - rTexture.wrapMode = TextureWrapMode.Repeat; - gTexture.wrapMode = TextureWrapMode.Repeat; - bTexture.wrapMode = TextureWrapMode.Repeat; - aTexture.wrapMode = TextureWrapMode.Repeat; + _rTexture.wrapMode = TextureWrapMode.Repeat; + _gTexture.wrapMode = TextureWrapMode.Repeat; + _bTexture.wrapMode = TextureWrapMode.Repeat; + _aTexture.wrapMode = TextureWrapMode.Repeat; } public static Color DrawGUI(int positionLeft, int positionTop, Color c) { - if (!rTexture) + if (!_rTexture) Init(); - GUI.Box(new Rect(positionLeft - 3, positionTop - 3, textureWidth + 3, textureHeight + 125), ""); + GUI.Box(new Rect(positionLeft - 3, positionTop - 3, TEXTURE_WIDTH + 3, TEXTURE_HEIGHT + 125), ""); float pos = positionTop + 5; - GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, textureWidth, textureHeight), rTexture, new Rect(0, 0, 1, textureHeight)); - c.r = GUI.HorizontalSlider(new Rect(positionLeft, pos + textureHeight + 5, textureWidth, 10), c.r, 0, 1); + GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, TEXTURE_WIDTH, TEXTURE_HEIGHT), _rTexture, new Rect(0, 0, 1, TEXTURE_HEIGHT)); + c.r = GUI.HorizontalSlider(new Rect(positionLeft, pos + TEXTURE_HEIGHT + 5, TEXTURE_WIDTH, 10), c.r, 0, 1); - pos += textureHeight + 20; + pos += TEXTURE_HEIGHT + 20; - GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, textureWidth, textureHeight), gTexture, new Rect(0, 0, 1, textureHeight)); - c.g = GUI.HorizontalSlider(new Rect(positionLeft, pos + textureHeight + 5, textureWidth, 10), c.g, 0, 1); + GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, TEXTURE_WIDTH, TEXTURE_HEIGHT), _gTexture, new Rect(0, 0, 1, TEXTURE_HEIGHT)); + c.g = GUI.HorizontalSlider(new Rect(positionLeft, pos + TEXTURE_HEIGHT + 5, TEXTURE_WIDTH, 10), c.g, 0, 1); - pos += textureHeight + 20; + pos += TEXTURE_HEIGHT + 20; - GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, textureWidth, textureHeight), bTexture, new Rect(0, 0, 1, textureHeight)); - c.b = GUI.HorizontalSlider(new Rect(positionLeft, pos + textureHeight + 5, textureWidth, 10), c.b, 0, 1); + GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, TEXTURE_WIDTH, TEXTURE_HEIGHT), _bTexture, new Rect(0, 0, 1, TEXTURE_HEIGHT)); + c.b = GUI.HorizontalSlider(new Rect(positionLeft, pos + TEXTURE_HEIGHT + 5, TEXTURE_WIDTH, 10), c.b, 0, 1); - pos += textureHeight + 20; + pos += TEXTURE_HEIGHT + 20; - GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, textureWidth, textureHeight), aTexture, new Rect(0, 0, 1, textureHeight)); - c.a = GUI.HorizontalSlider(new Rect(positionLeft, pos + textureHeight + 5, textureWidth, 10), c.a, 0, 1); + GUI.DrawTextureWithTexCoords(new Rect(positionLeft, pos, TEXTURE_WIDTH, TEXTURE_HEIGHT), _aTexture, new Rect(0, 0, 1, TEXTURE_HEIGHT)); + c.a = GUI.HorizontalSlider(new Rect(positionLeft, pos + TEXTURE_HEIGHT + 5, TEXTURE_WIDTH, 10), c.a, 0, 1); return c; } diff --git a/MechJeb2/Maneuver/OperationAdvancedTransfer.cs b/MechJeb2/Maneuver/OperationAdvancedTransfer.cs index 4429efe0c..fcab89b1e 100644 --- a/MechJeb2/Maneuver/OperationAdvancedTransfer.cs +++ b/MechJeb2/Maneuver/OperationAdvancedTransfer.cs @@ -142,7 +142,7 @@ private void ComputeTimes(Orbit o, Orbit destination, double universalTime) maxDepartureTime = minDepartureTime + synodic_period * 1.5; maxTransferTime = hohmann_transfer_time * 2.0; - maxArrivalTime.val = synodic_period * 1.5 + hohmann_transfer_time * 2.0; + maxArrivalTime.Val = synodic_period * 1.5 + hohmann_transfer_time * 2.0; } private bool layoutSkipped; @@ -229,10 +229,10 @@ private void DoPorkchopGui(Orbit o, double universalTime, MechJebModuleTargetCon if (progressStyle == null) progressStyle = new GUIStyle { - font = GuiUtils.skin.font, - fontSize = GuiUtils.skin.label.fontSize, - fontStyle = GuiUtils.skin.label.fontStyle, - normal = { textColor = GuiUtils.skin.label.normal.textColor } + font = GuiUtils.Skin.font, + fontSize = GuiUtils.Skin.label.fontSize, + fontStyle = GuiUtils.Skin.label.fontStyle, + normal = { textColor = GuiUtils.Skin.label.normal.textColor } }; GUILayout.Box(Localizer.Format("#MechJeb_adv_computing") + worker.Progress + "%", progressStyle, GUILayout.Width(windowWidth), GUILayout.Height(porkchop_Height)); //"Computing:" @@ -241,7 +241,7 @@ private void DoPorkchopGui(Orbit o, double universalTime, MechJebModuleTargetCon GUILayout.BeginHorizontal(); GUILayout.Label("ΔV: " + dv); GUILayout.FlexibleSpace(); - if (GUILayout.Button(Localizer.Format("#MechJeb_adv_reset_button"), GuiUtils.yellowOnHover)) + if (GUILayout.Button(Localizer.Format("#MechJeb_adv_reset_button"), GuiUtils.YellowOnHover)) ComputeTimes(o, target.TargetOrbit, universalTime); GUILayout.EndHorizontal(); diff --git a/MechJeb2/Maneuver/OperationInterplanetaryTransfer.cs b/MechJeb2/Maneuver/OperationInterplanetaryTransfer.cs index e6012a1d3..47b601146 100644 --- a/MechJeb2/Maneuver/OperationInterplanetaryTransfer.cs +++ b/MechJeb2/Maneuver/OperationInterplanetaryTransfer.cs @@ -23,7 +23,7 @@ public override void DoParametersGUI(Orbit o, double universalTime, MechJebModul if (!WaitForPhaseAngle) { - GUILayout.Label(Localizer.Format("#MechJeb_transfer_Label4"), GuiUtils.yellowLabel); //Using this mode voids your warranty + GUILayout.Label(Localizer.Format("#MechJeb_transfer_Label4"), GuiUtils.YellowLabel); //Using this mode voids your warranty } } diff --git a/MechJeb2/Maneuver/OperationResonantOrbit.cs b/MechJeb2/Maneuver/OperationResonantOrbit.cs index 0d70bc90c..6dc8412fe 100644 --- a/MechJeb2/Maneuver/OperationResonantOrbit.cs +++ b/MechJeb2/Maneuver/OperationResonantOrbit.cs @@ -25,12 +25,12 @@ public class OperationResonantOrbit : Operation public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GUILayout.Label(Localizer.Format("#MechJeb_resonant_label1", - ResonanceNumerator.val + "/" + ResonanceDenominator.val)); //"Change your orbital period to <<1>> of your current orbital period" + ResonanceNumerator.Val + "/" + ResonanceDenominator.Val)); //"Change your orbital period to <<1>> of your current orbital period" GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_resonant_label2"), GUILayout.ExpandWidth(true)); //New orbital period ratio : - ResonanceNumerator.text = GUILayout.TextField(ResonanceNumerator.text, GUILayout.Width(30)); + ResonanceNumerator.Text = GUILayout.TextField(ResonanceNumerator.Text, GUILayout.Width(30)); GUILayout.Label("/", GUILayout.ExpandWidth(false)); - ResonanceDenominator.text = GUILayout.TextField(ResonanceDenominator.text, GUILayout.Width(30)); + ResonanceDenominator.Text = GUILayout.TextField(ResonanceDenominator.Text, GUILayout.Width(30)); GUILayout.EndHorizontal(); _timeSelector.DoChooseTimeGUI(); } @@ -38,7 +38,7 @@ public override void DoParametersGUI(Orbit o, double universalTime, MechJebModul protected override List MakeNodesImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double ut = _timeSelector.ComputeManeuverTime(o, universalTime, target); - Vector3d dV = OrbitalManeuverCalculator.DeltaVToResonantOrbit(o, ut, (double)ResonanceNumerator.val / ResonanceDenominator.val); + Vector3d dV = OrbitalManeuverCalculator.DeltaVToResonantOrbit(o, ut, (double)ResonanceNumerator.Val / ResonanceDenominator.Val); return new List { new ManeuverParameters(dV, ut) }; } diff --git a/MechJeb2/Maneuver/OperationTransfer.cs b/MechJeb2/Maneuver/OperationTransfer.cs index 7b8eed994..665a444a9 100644 --- a/MechJeb2/Maneuver/OperationTransfer.cs +++ b/MechJeb2/Maneuver/OperationTransfer.cs @@ -80,7 +80,7 @@ protected override List MakeNodesImpl(Orbit o, double univer Orbit targetOrbit = target.TargetOrbit; - double lagTime = Rendezvous ? LagTime.val : 0; + double lagTime = Rendezvous ? LagTime.Val : 0; bool fixedTime = false; diff --git a/MechJeb2/Maneuver/TimeSelector.cs b/MechJeb2/Maneuver/TimeSelector.cs index 4e4b72aa6..7243d5282 100644 --- a/MechJeb2/Maneuver/TimeSelector.cs +++ b/MechJeb2/Maneuver/TimeSelector.cs @@ -107,7 +107,7 @@ public double ComputeManeuverTime(Orbit o, double ut, MechJebModuleTargetControl switch (_allowedTimeRef[_currentTimeRef]) { case TimeReference.X_FROM_NOW: - ut += LeadTime.val; + ut += LeadTime.Val; break; case TimeReference.APOAPSIS: diff --git a/MechJeb2/MechJebCore.cs b/MechJeb2/MechJebCore.cs index 08f7bf7f6..83b89b7ba 100644 --- a/MechJeb2/MechJebCore.cs +++ b/MechJeb2/MechJebCore.cs @@ -755,7 +755,7 @@ private void LoadComputerModules() public override void OnLoad(ConfigNode sfsNode) { - if (GuiUtils.skin == null) + if (GuiUtils.Skin == null) { //GuiUtils.skin = new GUISkin(); // ReSharper disable once ObjectCreationAsStatement @@ -1101,13 +1101,13 @@ private void OnGUI() if (HighLogic.LoadedSceneIsEditor || (FlightGlobals.ready && vessel == FlightGlobals.ActiveVessel && part.State != PartStates.DEAD)) { Matrix4x4 previousGuiMatrix = GUI.matrix; - GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(GuiUtils.scale, GuiUtils.scale, 1)); + GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(GuiUtils.Scale, GuiUtils.Scale, 1)); GuiUtils.ComboBox.DrawGUI(); GuiUtils.LoadSkin((GuiUtils.SkinType)Settings.skinId); - GUI.skin = GuiUtils.skin; + GUI.skin = GuiUtils.Skin; foreach (ComputerModule computerModule in GetComputerModules()) { diff --git a/MechJeb2/MechJebModuleAirplaneGuidance.cs b/MechJeb2/MechJebModuleAirplaneGuidance.cs index 4e32b13d0..947b407f0 100644 --- a/MechJeb2/MechJebModuleAirplaneGuidance.cs +++ b/MechJeb2/MechJebModuleAirplaneGuidance.cs @@ -24,11 +24,11 @@ public MechJebModuleAirplaneGuidance(MechJebCore core) : base(core) [UsedImplicitly] [Persistent(pass = (int)Pass.GLOBAL)] public EditableDouble AltitudeTargettmp = 0, - HeadingTargettmp = 90, - RollTargettmp = 0, - SpeedTargettmp = 0, - VertSpeedTargettmp = 0, - RollMaxtmp = 30; + HeadingTargettmp = 90, + RollTargettmp = 0, + SpeedTargettmp = 0, + VertSpeedTargettmp = 0, + RollMaxtmp = 30; protected override void WindowGUI(int windowID) { @@ -98,14 +98,14 @@ protected override void WindowGUI(int windowID) bool change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - AltitudeTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + AltitudeTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - AltitudeTargettmp.text = GUILayout.TextField(AltitudeTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + AltitudeTargettmp.Text = GUILayout.TextField(AltitudeTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - AltitudeTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + AltitudeTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -139,14 +139,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - VertSpeedTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + VertSpeedTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - VertSpeedTargettmp.text = GUILayout.TextField(VertSpeedTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + VertSpeedTargettmp.Text = GUILayout.TextField(VertSpeedTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - VertSpeedTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + VertSpeedTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -167,14 +167,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - VertSpeedTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + VertSpeedTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - VertSpeedTargettmp.text = GUILayout.TextField(VertSpeedTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + VertSpeedTargettmp.Text = GUILayout.TextField(VertSpeedTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - VertSpeedTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + VertSpeedTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -205,14 +205,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - HeadingTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + HeadingTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - HeadingTargettmp.text = GUILayout.TextField(HeadingTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + HeadingTargettmp.Text = GUILayout.TextField(HeadingTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - HeadingTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + HeadingTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -235,14 +235,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - RollTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + RollTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - RollTargettmp.text = GUILayout.TextField(RollTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + RollTargettmp.Text = GUILayout.TextField(RollTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - RollTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + RollTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -263,14 +263,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - RollMaxtmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + RollMaxtmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - RollMaxtmp.text = GUILayout.TextField(RollMaxtmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + RollMaxtmp.Text = GUILayout.TextField(RollMaxtmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - RollMaxtmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + RollMaxtmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -301,14 +301,14 @@ protected override void WindowGUI(int windowID) change = false; if (GUILayout.Button("-", GUILayout.Width(18))) { - SpeedTargettmp.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + SpeedTargettmp.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } - SpeedTargettmp.text = GUILayout.TextField(SpeedTargettmp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + SpeedTargettmp.Text = GUILayout.TextField(SpeedTargettmp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); if (GUILayout.Button("+", GUILayout.Width(18))) { - SpeedTargettmp.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; + SpeedTargettmp.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; change = true; } @@ -344,11 +344,11 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_Label8"), GUILayout.ExpandWidth(true)); //Accceleration GUILayout.Label("Kp", GUILayout.ExpandWidth(false)); - autopilot.AccKp.text = GUILayout.TextField(autopilot.AccKp.text, GUILayout.Width(40)); + autopilot.AccKp.Text = GUILayout.TextField(autopilot.AccKp.Text, GUILayout.Width(40)); GUILayout.Label("i", GUILayout.ExpandWidth(false)); - autopilot.AccKi.text = GUILayout.TextField(autopilot.AccKi.text, GUILayout.Width(40)); + autopilot.AccKi.Text = GUILayout.TextField(autopilot.AccKi.Text, GUILayout.Width(40)); GUILayout.Label("d", GUILayout.ExpandWidth(false)); - autopilot.AccKd.text = GUILayout.TextField(autopilot.AccKd.text, GUILayout.Width(40)); + autopilot.AccKd.Text = GUILayout.TextField(autopilot.AccKd.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); if (autopilot.SpeedHoldEnabled) GUILayout.Label( @@ -359,11 +359,11 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_Pitch"), GUILayout.ExpandWidth(true)); //"VertSpeed" GUILayout.Label("Kp", GUILayout.ExpandWidth(false)); - autopilot.PitKp.text = GUILayout.TextField(autopilot.PitKp.text, GUILayout.Width(40)); + autopilot.PitKp.Text = GUILayout.TextField(autopilot.PitKp.Text, GUILayout.Width(40)); GUILayout.Label("i", GUILayout.ExpandWidth(false)); - autopilot.PitKi.text = GUILayout.TextField(autopilot.PitKi.text, GUILayout.Width(40)); + autopilot.PitKi.Text = GUILayout.TextField(autopilot.PitKi.Text, GUILayout.Width(40)); GUILayout.Label("d", GUILayout.ExpandWidth(false)); - autopilot.PitKd.text = GUILayout.TextField(autopilot.PitKd.text, GUILayout.Width(40)); + autopilot.PitKd.Text = GUILayout.TextField(autopilot.PitKd.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); if (autopilot.VertSpeedHoldEnabled) GUILayout.Label(Localizer.Format("#MecgJeb_Aircraftauto_error2", autopilot.PitchErr.ToString("F2"), @@ -373,11 +373,11 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_Label10"), GUILayout.ExpandWidth(true)); //Roll GUILayout.Label("Kp", GUILayout.ExpandWidth(false)); - autopilot.RolKp.text = GUILayout.TextField(autopilot.RolKp.text, GUILayout.Width(40)); + autopilot.RolKp.Text = GUILayout.TextField(autopilot.RolKp.Text, GUILayout.Width(40)); GUILayout.Label("i", GUILayout.ExpandWidth(false)); - autopilot.RolKi.text = GUILayout.TextField(autopilot.RolKi.text, GUILayout.Width(40)); + autopilot.RolKi.Text = GUILayout.TextField(autopilot.RolKi.Text, GUILayout.Width(40)); GUILayout.Label("d", GUILayout.ExpandWidth(false)); - autopilot.RolKd.text = GUILayout.TextField(autopilot.RolKd.text, GUILayout.Width(40)); + autopilot.RolKd.Text = GUILayout.TextField(autopilot.RolKd.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); if (autopilot.RollHoldEnabled) GUILayout.Label(Localizer.Format("#MecgJeb_Aircraftauto_error2", autopilot.RollErr.ToString("F2"), @@ -387,11 +387,11 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label("Yaw", GUILayout.ExpandWidth(true)); GUILayout.Label("Kp", GUILayout.ExpandWidth(false)); - autopilot.YawKp.text = GUILayout.TextField(autopilot.YawKp.text, GUILayout.Width(40)); + autopilot.YawKp.Text = GUILayout.TextField(autopilot.YawKp.Text, GUILayout.Width(40)); GUILayout.Label("i", GUILayout.ExpandWidth(false)); - autopilot.YawKi.text = GUILayout.TextField(autopilot.YawKi.text, GUILayout.Width(40)); + autopilot.YawKi.Text = GUILayout.TextField(autopilot.YawKi.Text, GUILayout.Width(40)); GUILayout.Label("d", GUILayout.ExpandWidth(false)); - autopilot.YawKd.text = GUILayout.TextField(autopilot.YawKd.text, GUILayout.Width(40)); + autopilot.YawKd.Text = GUILayout.TextField(autopilot.YawKd.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); if (autopilot.HeadingHoldEnabled) GUILayout.Label(Localizer.Format("#MecgJeb_Aircraftauto_error2", autopilot.YawErr.ToString("F2"), @@ -404,13 +404,13 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_PitchDownLimit"), GUILayout.ExpandWidth(false)); - autopilot.PitchDownLimit.text = GUILayout.TextField(autopilot.PitchDownLimit.text, GUILayout.Width(40)); + autopilot.PitchDownLimit.Text = GUILayout.TextField(autopilot.PitchDownLimit.Text, GUILayout.Width(40)); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_PitchUpLimit"), GUILayout.ExpandWidth(false)); - autopilot.PitchUpLimit.text = GUILayout.TextField(autopilot.PitchUpLimit.text, GUILayout.Width(40)); + autopilot.PitchUpLimit.Text = GUILayout.TextField(autopilot.PitchUpLimit.Text, GUILayout.Width(40)); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_YawLimit"), GUILayout.ExpandWidth(false)); - autopilot.YawLimit.text = GUILayout.TextField(autopilot.YawLimit.text, GUILayout.Width(40)); + autopilot.YawLimit.Text = GUILayout.TextField(autopilot.YawLimit.Text, GUILayout.Width(40)); GUILayout.Label(Localizer.Format("#MechJeb_Aircraftauto_RollLimit"), GUILayout.ExpandWidth(false)); - autopilot.RollLimit.text = GUILayout.TextField(autopilot.RollLimit.text, GUILayout.Width(40)); + autopilot.RollLimit.Text = GUILayout.TextField(autopilot.RollLimit.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); } diff --git a/MechJeb2/MechJebModuleAscentBaseAutopilot.cs b/MechJeb2/MechJebModuleAscentBaseAutopilot.cs index 9c457b9a1..05826c734 100644 --- a/MechJeb2/MechJebModuleAscentBaseAutopilot.cs +++ b/MechJeb2/MechJebModuleAscentBaseAutopilot.cs @@ -249,8 +249,8 @@ private void DriveCircularizationBurn() if (Vessel.patchedConicSolver.maneuverNodes.Count == 0) { MechJebModuleFlightRecorder recorder = Core.GetComputerModule(); - if (recorder != null) AscentSettings.LaunchPhaseAngle.val = recorder.PhaseAngleFromMark; - if (recorder != null) AscentSettings.LaunchLANDifference.val = VesselState.orbitLAN - recorder.MarkLAN; + if (recorder != null) AscentSettings.LaunchPhaseAngle.Val = recorder.PhaseAngleFromMark; + if (recorder != null) AscentSettings.LaunchLANDifference.Val = VesselState.orbitLAN - recorder.MarkLAN; //finished circularize Users.Clear(); diff --git a/MechJeb2/MechJebModuleAscentClassicPathMenu.cs b/MechJeb2/MechJebModuleAscentClassicPathMenu.cs index 339dc1b69..8ca5756fe 100644 --- a/MechJeb2/MechJebModuleAscentClassicPathMenu.cs +++ b/MechJeb2/MechJebModuleAscentClassicPathMenu.cs @@ -69,7 +69,7 @@ protected override void WindowGUI(int windowID) GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_AscentPathEd_label5")); //"Turn end altitude: " - GUILayout.Label(_ascentSettings.AutoTurnEndAltitude.ToSI(2) + "m", GuiUtils.middleRightLabel, + GUILayout.Label(_ascentSettings.AutoTurnEndAltitude.ToSI(2) + "m", GuiUtils.MiddleRightLabel, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); } @@ -92,7 +92,7 @@ protected override void WindowGUI(int windowID) double sliderTurnShapeExponent = GUILayout.HorizontalSlider((float)_ascentSettings.TurnShapeExponent, 0.0F, 1.0F); if (Math.Round(Math.Abs(sliderTurnShapeExponent - oldTurnShapeExponent), SLIDER_PRECISION) > 0) { - _ascentSettings.TurnShapeExponent.val = Math.Round(sliderTurnShapeExponent, SLIDER_PRECISION); + _ascentSettings.TurnShapeExponent.Val = Math.Round(sliderTurnShapeExponent, SLIDER_PRECISION); } GUILayout.Box(_pathTexture); diff --git a/MechJeb2/MechJebModuleAscentMenu.cs b/MechJeb2/MechJebModuleAscentMenu.cs index 483dee573..3268cfc2a 100644 --- a/MechJeb2/MechJebModuleAscentMenu.cs +++ b/MechJeb2/MechJebModuleAscentMenu.cs @@ -145,15 +145,15 @@ private void ShowTargetingGUIElements() } if (_ascentSettings.DesiredApoapsis >= 0 && _ascentSettings.DesiredApoapsis < _ascentSettings.DesiredOrbitAltitude) - GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel3, GuiUtils.yellowLabel); //Ap < Pe: circularizing orbit + GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel3, GuiUtils.YellowLabel); //Ap < Pe: circularizing orbit else if (_ascentSettings.AttachAltFlag && _ascentSettings.DesiredAttachAlt > _ascentSettings.DesiredApoapsis) GUILayout.Label(CachedLocalizer.Instance.MechJebAscentWarnAttachAltHigh, - GuiUtils.orangeLabel); //Attach > Ap: apoapsis insertion + GuiUtils.OrangeLabel); //Attach > Ap: apoapsis insertion if (_ascentSettings.DesiredApoapsis < 0) - GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel4, GuiUtils.orangeLabel); //Hyperbolic target orbit (neg Ap) + GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel4, GuiUtils.OrangeLabel); //Hyperbolic target orbit (neg Ap) if (_ascentSettings.AttachAltFlag && _ascentSettings.DesiredAttachAlt < _ascentSettings.DesiredOrbitAltitude) GUILayout.Label(CachedLocalizer.Instance.MechJebAscentWarnAttachAltLow, - GuiUtils.orangeLabel); //Attach < Pe: periapsis insertion + GuiUtils.OrangeLabel); //Attach < Pe: periapsis insertion } else { @@ -161,15 +161,15 @@ private void ShowTargetingGUIElements() } GUILayout.BeginHorizontal(); - GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel6, _ascentSettings.DesiredInclination, "º", 75, GuiUtils.skin.label, + GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel6, _ascentSettings.DesiredInclination, "º", 75, GuiUtils.Skin.label, false); //Orbit inc. if (GUILayout.Button(CachedLocalizer.Instance.MechJebAscentButton13, GuiUtils.ExpandWidth(false))) //Current - _ascentSettings.DesiredInclination.val = Math.Round(VesselState.latitude, 3); + _ascentSettings.DesiredInclination.Val = Math.Round(VesselState.latitude, 3); GUILayout.EndHorizontal(); double delta = Math.Abs(VesselState.latitude) - Math.Abs(_ascentSettings.DesiredInclination); if (2.001 < delta) - GUILayout.Label(Localizer.Format("#MechJeb_Ascent_label7", delta), GuiUtils.redLabel); //inc {0:F1}º below current latitude + GUILayout.Label(Localizer.Format("#MechJeb_Ascent_label7", delta), GuiUtils.RedLabel); //inc {0:F1}º below current latitude GUILayout.EndVertical(); Profiler.EndSample(); @@ -227,11 +227,11 @@ private void ShowStatusGUIElements() GUILayout.EndHorizontal(); GUIStyle si; if (Core.Guidance.IsStable()) - si = GuiUtils.greenLabel; + si = GuiUtils.GreenLabel; else if (Core.Guidance.IsInitializing() || Core.Guidance.Status == PVGStatus.FINISHED) - si = GuiUtils.orangeLabel; + si = GuiUtils.OrangeLabel; else - si = GuiUtils.redLabel; + si = GuiUtils.RedLabel; GUILayout.Label(label26, si); //Guidance Status: GUILayout.BeginHorizontal(); GUILayout.Label(label27, GuiUtils.LayoutWidth(90)); //converges: @@ -244,7 +244,7 @@ private void ShowStatusGUIElements() GUILayout.EndHorizontal(); if (Core.Glueball.Exception != null) { - GUILayout.Label(label30, GuiUtils.redLabel); //LAST FAILURE: + GUILayout.Label(label30, GuiUtils.RedLabel); //LAST FAILURE: } Profiler.EndSample(); @@ -298,7 +298,7 @@ private void ShowAutoWarpGUIElements() Core.Target.TargetOrbit.inclination ); _autopilot.StartCountdown(VesselState.time + timeToPlane); - _ascentSettings.DesiredInclination.val = inclination; + _ascentSettings.DesiredInclination.Val = inclination; } //Launch to target LAN @@ -395,7 +395,7 @@ private void UpdateStrings() private void RefreshRateGUI() { int oldRate = _refreshRate; - if (GuiUtils.showAdvancedWindowSettings) + if (GuiUtils.ShowAdvancedWindowSettings) GuiUtils.SimpleTextBox("Update Interval", _refreshRate, "Hz"); if (oldRate != _refreshRate) { @@ -434,7 +434,7 @@ protected override void WindowGUI(int windowID) if (_autopilot.Enabled) GUILayout.Label(autopilotStatus); //Autopilot status: if (Core.DeactivateControl) - GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel36, GuiUtils.redLabel); //CONTROL DISABLED (AVIONICS) + GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel36, GuiUtils.RedLabel); //CONTROL DISABLED (AVIONICS) if (!Vessel.patchedConicsUnlocked() && _ascentSettings.AscentType != AscentType.PVG) { diff --git a/MechJeb2/MechJebModuleAscentPVGAutopilot.cs b/MechJeb2/MechJebModuleAscentPVGAutopilot.cs index 85925ba29..88c240e2b 100644 --- a/MechJeb2/MechJebModuleAscentPVGAutopilot.cs +++ b/MechJeb2/MechJebModuleAscentPVGAutopilot.cs @@ -146,7 +146,7 @@ private void DrivePitchProgram() if (!AscentSettings.StagingTriggerFlag) Status = Localizer.Format("#MechJeb_Ascent_status15", $"{pitch - Core.Guidance.Pitch:F}"); //Pitch program <<1>>° to guidance else - Status = $"Pitch Program until stage {AscentSettings.StagingTrigger.val}"; + Status = $"Pitch Program until stage {AscentSettings.StagingTrigger.Val}"; if (CheckForGuidanceTransition(pitch)) { @@ -185,7 +185,7 @@ private void DriveZeroLift() if (!AscentSettings.StagingTriggerFlag) Status = Localizer.Format("#MechJeb_Ascent_status14", $"{pitch - Core.Guidance.Pitch:F}"); //Gravity Turn <<1>>° to guidance else - Status = $"Gravity Turn until stage {AscentSettings.StagingTrigger.val}"; + Status = $"Gravity Turn until stage {AscentSettings.StagingTrigger.Val}"; if (CheckForGuidanceTransition(pitch)) { diff --git a/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs b/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs index 339989670..6ee3f6c8f 100644 --- a/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs +++ b/MechJeb2/MechJebModuleAscentPVGSettingsMenu.cs @@ -52,12 +52,12 @@ protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(GUI.skin.box); - _ascentSettings.LastStage.val = Clamp(_ascentSettings.LastStage.val, 0, Core.StageStats.VacStats.Count - 1); + _ascentSettings.LastStage.Val = Clamp(_ascentSettings.LastStage.Val, 0, Core.StageStats.VacStats.Count - 1); for (int mjPhase = _ascentSettings.LastStage; mjPhase < Core.StageStats.VacStats.Count; mjPhase++) { FuelStats stats = Core.StageStats.VacStats[mjPhase]; - if (stats.DeltaV < _ascentSettings.MinDeltaV.val) + if (stats.DeltaV < _ascentSettings.MinDeltaV.Val) continue; if (topstage < 0) @@ -78,7 +78,7 @@ protected override void WindowGUI(int windowID) // this should only run once -- maybe it should run in some hook like scene loading or something? // we need DV info though. if (_ascentSettings.OptimizeStageInternal < 0) - _ascentSettings.OptimizeStageInternal.val = topstage; + _ascentSettings.OptimizeStageInternal.Val = topstage; GUILayout.BeginVertical(GUI.skin.box); GuiUtils.SimpleTextBox("Min ∆v: ", _ascentSettings.MinDeltaV, "m/s", 30); @@ -120,10 +120,10 @@ protected override void WindowGUI(int windowID) if (_ascentSettings.LimitQa < 1000 || _ascentSettings.LimitQa > 4000) { if (_ascentSettings.LimitQa < 0 || _ascentSettings.LimitQa > 10000) - GUILayout.Label("Qα limit has been clamped to between 0 and 10000 Pa-rad", GuiUtils.redLabel); + GUILayout.Label("Qα limit has been clamped to between 0 and 10000 Pa-rad", GuiUtils.RedLabel); else GUILayout.Label(CachedLocalizer.Instance.MechJebAscentLabel20, - GuiUtils.yellowLabel); //Qα limit is recommended to be 1000 to 4000 Pa-rad + GuiUtils.YellowLabel); //Qα limit is recommended to be 1000 to 4000 Pa-rad } Core.Guidance.ShouldDrawTrajectory = GUILayout.Toggle(Core.Guidance.ShouldDrawTrajectory, "Draw Trajectory on Map"); diff --git a/MechJeb2/MechJebModuleAscentSettings.cs b/MechJeb2/MechJebModuleAscentSettings.cs index 733a62374..06be4924a 100644 --- a/MechJeb2/MechJebModuleAscentSettings.cs +++ b/MechJeb2/MechJebModuleAscentSettings.cs @@ -235,7 +235,7 @@ public bool Autostage [Persistent(pass = (int)Pass.TYPE)] public bool CoastStageFlag; - public int CoastStage => CoastStageFlag ? CoastStageInternal.val : -1; + public int CoastStage => CoastStageFlag ? CoastStageInternal.Val : -1; [Persistent(pass = (int)Pass.TYPE)] public bool OptimizeStageFlag = true; @@ -243,7 +243,7 @@ public bool Autostage [Persistent(pass = (int)Pass.TYPE)] public readonly EditableInt OptimizeStageInternal = -1; - public int OptimizeStage => OptimizeStageFlag ? OptimizeStageInternal.val : -1; + public int OptimizeStage => OptimizeStageFlag ? OptimizeStageInternal.Val : -1; [Persistent(pass = (int)Pass.TYPE)] public bool SpinupStageFlag = true; @@ -251,7 +251,7 @@ public bool Autostage [Persistent(pass = (int)Pass.TYPE)] public readonly EditableInt SpinupStageInternal = -1; - public int SpinupStage => SpinupStageFlag ? SpinupStageInternal.val : -1; + public int SpinupStage => SpinupStageFlag ? SpinupStageInternal.Val : -1; [Persistent(pass = (int)Pass.TYPE)] public readonly EditableDouble SpinupLeadTime = 50; @@ -267,7 +267,7 @@ public bool Autostage private readonly List _emptyList = new List(); - public List UnguidedStages => UnguidedStagesFlag ? UnguidedStagesInternal.val : _emptyList; + public List UnguidedStages => UnguidedStagesFlag ? UnguidedStagesInternal.Val : _emptyList; /* * some non-persisted values @@ -311,71 +311,71 @@ private void DisableAscentModules() public void ApplyRODefaults() { - PitchStartVelocity.val = PITCH_START_VELOCITY_DEFAULT; - PitchRate.val = PITCH_RATE_DEFAULT; - DesiredAttachAlt.val = DESIRED_ATTACH_ALT_DEFAULT; - DesiredAttachAltFixed.val = DESIRED_ATTACH_ALT_DEFAULT; - DesiredFPA.val = DESIRED_FPA_DEFAULT; - DynamicPressureTrigger.val = DYNAMIC_PRESSURE_TRIGGER_DEFAULT; + PitchStartVelocity.Val = PITCH_START_VELOCITY_DEFAULT; + PitchRate.Val = PITCH_RATE_DEFAULT; + DesiredAttachAlt.Val = DESIRED_ATTACH_ALT_DEFAULT; + DesiredAttachAltFixed.Val = DESIRED_ATTACH_ALT_DEFAULT; + DesiredFPA.Val = DESIRED_FPA_DEFAULT; + DynamicPressureTrigger.Val = DYNAMIC_PRESSURE_TRIGGER_DEFAULT; AttachAltFlag = ATTACH_ALT_FLAG_DEFAULT; StagingTriggerFlag = STAGING_TRIGGER_FLAG_DEFAULT; - LimitQa.val = LIMIT_QA_DEFAULT; + LimitQa.Val = LIMIT_QA_DEFAULT; LimitQaEnabled = LIMIT_QA_ENABLED_DEFAULT; - MinDeltaV.val = MIN_DELTAV_DEFAULT; - MaxCoast.val = MAX_COAST_DEFAULT; - MinCoast.val = MIN_COAST_DEFAULT; + MinDeltaV.Val = MIN_DELTAV_DEFAULT; + MaxCoast.Val = MAX_COAST_DEFAULT; + MinCoast.Val = MIN_COAST_DEFAULT; FixedCoast = FIXED_COAST_DEFAULT; - FixedCoastLength.val = FIXED_COAST_LENGTH_DEFAULT; - LaunchPhaseAngle.val = LAUNCH_PHASE_ANGLE_DEFAULT; - LaunchLANDifference.val = LAUNCH_LAN_DIFFERENCE; - PreStageTime.val = PRE_STAGE_TIME_DEFAULT; - OptimizerPauseTime.val = OPTIMIZER_PAUSE_TIME_DEFAULT; + FixedCoastLength.Val = FIXED_COAST_LENGTH_DEFAULT; + LaunchPhaseAngle.Val = LAUNCH_PHASE_ANGLE_DEFAULT; + LaunchLANDifference.Val = LAUNCH_LAN_DIFFERENCE; + PreStageTime.Val = PRE_STAGE_TIME_DEFAULT; + OptimizerPauseTime.Val = OPTIMIZER_PAUSE_TIME_DEFAULT; - OptimizeStageInternal.val = -1; + OptimizeStageInternal.Val = -1; OptimizeStageFlag = true; SpinupStageFlag = false; - SpinupStageInternal.val = -1; + SpinupStageInternal.Val = -1; CoastStageFlag = false; - CoastStageInternal.val = -1; + CoastStageInternal.Val = -1; UnguidedStagesFlag = false; - if (DesiredOrbitAltitude.val < 145000) - DesiredOrbitAltitude.val = 145000; + if (DesiredOrbitAltitude.Val < 145000) + DesiredOrbitAltitude.Val = 145000; - if (Math.Abs(DesiredInclination.val) < Math.Abs(VesselState.latitude)) - DesiredInclination.val = Math.Round(VesselState.latitude, 3); + if (Math.Abs(DesiredInclination.Val) < Math.Abs(VesselState.latitude)) + DesiredInclination.Val = Math.Round(VesselState.latitude, 3); - if (Math.Abs(DesiredInclination.val) > 180 - Math.Abs(VesselState.latitude)) - DesiredInclination.val = 180 - Math.Round(VesselState.latitude, 3); + if (Math.Abs(DesiredInclination.Val) > 180 - Math.Abs(VesselState.latitude)) + DesiredInclination.Val = 180 - Math.Round(VesselState.latitude, 3); - Core.Guidance.UllageLeadTime.val = 20; + Core.Guidance.UllageLeadTime.Val = 20; Core.Settings.rssMode = true; /* set the thrust controller to sane RO/RSS defaults */ Core.Thrust.LimitToPreventUnstableIgnition = false; Core.Thrust.AutoRCSUllaging = true; - Core.Thrust.MinThrottle.val = 0.05; + Core.Thrust.MinThrottle.Val = 0.05; Core.Thrust.LimiterMinThrottle = true; Core.Thrust.LimitThrottle = false; Core.Thrust.LimitAcceleration = false; Core.Thrust.LimitToPreventOverheats = false; Core.Thrust.LimitDynamicPressure = false; - Core.Thrust.MaxDynamicPressure.val = 20000; + Core.Thrust.MaxDynamicPressure.Val = 20000; /* reset all of the staging controller, and turn on hotstaging and drop solids */ Autostage = true; - Core.Staging.AutostagePreDelay.val = 0.0; - Core.Staging.AutostagePostDelay.val = 0.5; - Core.Staging.AutostageLimit.val = 0; - Core.Staging.FairingMaxDynamicPressure.val = 5000; - Core.Staging.FairingMinAltitude.val = 50000; - Core.Staging.ClampAutoStageThrustPct.val = 0.99; - Core.Staging.FairingMaxAerothermalFlux.val = 1135; + Core.Staging.AutostagePreDelay.Val = 0.0; + Core.Staging.AutostagePostDelay.Val = 0.5; + Core.Staging.AutostageLimit.Val = 0; + Core.Staging.FairingMaxDynamicPressure.Val = 5000; + Core.Staging.FairingMinAltitude.Val = 50000; + Core.Staging.ClampAutoStageThrustPct.Val = 0.99; + Core.Staging.FairingMaxAerothermalFlux.Val = 1135; Core.Staging.HotStaging = true; - Core.Staging.HotStagingLeadTime.val = 1.0; + Core.Staging.HotStagingLeadTime.Val = 1.0; Core.Staging.DropSolids = true; - Core.Staging.DropSolidsLeadTime.val = 1.0; + Core.Staging.DropSolidsLeadTime.Val = 1.0; } private const double LAUNCH_LAN_DIFFERENCE = 0; diff --git a/MechJeb2/MechJebModuleAscentSettingsMenu.cs b/MechJeb2/MechJebModuleAscentSettingsMenu.cs index 865111879..41167f507 100644 --- a/MechJeb2/MechJebModuleAscentSettingsMenu.cs +++ b/MechJeb2/MechJebModuleAscentSettingsMenu.cs @@ -50,7 +50,7 @@ private void ShowAscentSettingsGUIElements() if (_ascentSettings.AscentType != AscentType.PVG) { - GUIStyle s = _ascentSettings.LimitingAoA ? GuiUtils.greenToggle : null; + GUIStyle s = _ascentSettings.LimitingAoA ? GuiUtils.GreenToggle : null; string sCurrentMaxAoA = $"º ({_autopilot.CurrentMaxAoA:F1}°)"; GuiUtils.ToggledTextBox(ref _ascentSettings.LimitAoA, CachedLocalizer.Instance.MechJebAscentCheckbox3, _ascentSettings.MaxAoA, sCurrentMaxAoA, s, @@ -61,8 +61,8 @@ private void ShowAscentSettingsGUIElements() GUILayout.BeginHorizontal(); GUILayout.Space(25); GUIStyle sl = _ascentSettings.LimitingAoA && VesselState.dynamicPressure < _ascentSettings.AOALimitFadeoutPressure - ? GuiUtils.greenLabel - : GuiUtils.skin.label; + ? GuiUtils.GreenLabel + : GuiUtils.Skin.label; GuiUtils.SimpleTextBox(CachedLocalizer.Instance.MechJebAscentLabel24, _ascentSettings.AOALimitFadeoutPressure, "Pa", 50, sl); //Dynamic Pressure Fadeout GUILayout.EndHorizontal(); diff --git a/MechJeb2/MechJebModuleAttitudeAdjustment.cs b/MechJeb2/MechJebModuleAttitudeAdjustment.cs index a560e6595..11de279f4 100644 --- a/MechJeb2/MechJebModuleAttitudeAdjustment.cs +++ b/MechJeb2/MechJebModuleAttitudeAdjustment.cs @@ -121,7 +121,7 @@ protected override void WindowGUI(int windowID) GUILayout.ExpandWidth(false)); //Display the CoT GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_AttitudeAdjust_Label10"), GUILayout.ExpandWidth(true)); //Radius of Sphere - arrows.comSphereRadius.text = GUILayout.TextField(arrows.comSphereRadius.text, GUILayout.Width(40)); + arrows.comSphereRadius.Text = GUILayout.TextField(arrows.comSphereRadius.Text, GUILayout.Width(40)); GUILayout.EndHorizontal(); arrows.displayAtCoM = GUILayout.Toggle(arrows.displayAtCoM, Localizer.Format("#MechJeb_AttitudeAdjust_checkbox10")); //Arrows origins at the CoM diff --git a/MechJeb2/MechJebModuleCustomInfoWindow.cs b/MechJeb2/MechJebModuleCustomInfoWindow.cs index 8b2b89ed0..381dd732f 100644 --- a/MechJeb2/MechJebModuleCustomInfoWindow.cs +++ b/MechJeb2/MechJebModuleCustomInfoWindow.cs @@ -79,7 +79,7 @@ public virtual void UpdateWindowItems() private void RefreshRateGUI() { int oldRate = refreshRate; - if (GuiUtils.showAdvancedWindowSettings) + if (GuiUtils.ShowAdvancedWindowSettings) GuiUtils.SimpleTextBox("Update Interval", refreshRate, "Hz"); if (oldRate != refreshRate) { @@ -90,7 +90,7 @@ private void RefreshRateGUI() protected override void WindowGUI(int windowID) { - GUI.skin = isCompact ? GuiUtils.compactSkin : GuiUtils.skin; + GUI.skin = isCompact ? GuiUtils.CompactSkin : GuiUtils.Skin; GUI.contentColor = text; // Only run the updater during the Layout pass, not the Repaint pass @@ -115,7 +115,7 @@ protected override void WindowGUI(int windowID) GUILayout.EndVertical(); - if (!IsOverlay && GUI.Button(new Rect(10, 0, 13, 20), "E", GuiUtils.yellowOnHover)) + if (!IsOverlay && GUI.Button(new Rect(10, 0, 13, 20), "E", GuiUtils.YellowOnHover)) { MechJebModuleCustomWindowEditor editor = Core.GetComputerModule(); if (editor != null) @@ -125,7 +125,7 @@ protected override void WindowGUI(int windowID) } } - if (!IsOverlay && GUI.Button(new Rect(25, 0, 13, 20), "C", GuiUtils.yellowOnHover)) + if (!IsOverlay && GUI.Button(new Rect(25, 0, 13, 20), "C", GuiUtils.YellowOnHover)) { MuUtils.SystemClipboard = ToSharingString(); ScreenMessages.PostScreenMessage(Localizer.Format("#MechJeb_WindowEd_CustomInfoWindow_Scrmsg1", GetName()), 3.0f, @@ -147,7 +147,7 @@ public override void DrawGUI(bool inEditor) base.DrawGUI(inEditor); if (IsOverlay) - GUI.skin = GuiUtils.skin; + GUI.skin = GuiUtils.Skin; } public void Init() @@ -161,7 +161,7 @@ public void Init() if (IsOverlay && !localSkin) { - localSkin = Object.Instantiate(GuiUtils.transparentSkin); + localSkin = Object.Instantiate(GuiUtils.TransparentSkin); localSkin.window.normal.background = background; localSkin.window.onNormal.background = background; } @@ -484,7 +484,7 @@ protected override void WindowGUI(int windowID) scrollPos = GUILayout.BeginScrollView(scrollPos); for (int i = 0; i < editedWindow.items.Count; i++) { - GUIStyle s = i == selectedItemIndex ? GuiUtils.yellowLabel : GUI.skin.label; + GUIStyle s = i == selectedItemIndex ? GuiUtils.YellowLabel : GUI.skin.label; if (GUILayout.Button(Localizer.Format(editedWindow.items[i].description), s)) selectedItemIndex = i; // } @@ -528,7 +528,7 @@ protected override void WindowGUI(int windowID) scrollPos2 = GUILayout.BeginScrollView(scrollPos2); foreach (InfoItem item in registry.Where(it => it.category == itemCategory).OrderBy(it => it.description)) { - if (GUILayout.Button(Localizer.Format(item.description), GuiUtils.yellowOnHover)) // + if (GUILayout.Button(Localizer.Format(item.description), GuiUtils.YellowOnHover)) // { editedWindow.items.Add(item); } @@ -537,7 +537,7 @@ protected override void WindowGUI(int windowID) GUILayout.EndScrollView(); } - GUILayout.Label(Localizer.Format("#MechJeb_WindowEd_label5"), GuiUtils.middleCenterLabel); //Window presets: + GUILayout.Label(Localizer.Format("#MechJeb_WindowEd_label5"), GuiUtils.MiddleCenterLabel); //Window presets: presetIndex = GuiUtils.ArrowSelector(presetIndex, CustomWindowPresets.presets.Length, () => { diff --git a/MechJeb2/MechJebModuleDebugArrows.cs b/MechJeb2/MechJebModuleDebugArrows.cs index 6e6c76d5c..94a9f2e18 100644 --- a/MechJeb2/MechJebModuleDebugArrows.cs +++ b/MechJeb2/MechJebModuleDebugArrows.cs @@ -164,28 +164,28 @@ public override void OnUpdate() if (comSphereActive) { comSphere.Set(instantCoM); - comSphere.SetRadius((float)comSphereRadius.val); + comSphere.SetRadius((float)comSphereRadius.Val); } colSphere.State(colSphereActive && VesselState.CoLScalar > 0 && Core.ShowGui); if (colSphereActive) { colSphere.Set(VesselState.CoL + frameVel); - colSphere.SetRadius((float)comSphereRadius.val); + colSphere.SetRadius((float)comSphereRadius.Val); } cotSphere.State(cotSphereActive && VesselState.CoTScalar > 0 && Core.ShowGui); if (cotSphereActive) { cotSphere.Set(VesselState.CoT + frameVel); - cotSphere.SetRadius((float)comSphereRadius.val); + cotSphere.SetRadius((float)comSphereRadius.Val); } srfVelocityArrow.State(srfVelocityArrowActive && Core.ShowGui); if (srfVelocityArrowActive) { srfVelocityArrow.Set(arrowPos, Vessel.srf_velocity); - srfVelocityArrow.SetLength((float)arrowsLength.val); + srfVelocityArrow.SetLength((float)arrowsLength.Val); srfVelocityArrow.SeeThrough(seeThrough); } @@ -193,7 +193,7 @@ public override void OnUpdate() if (obtVelocityArrowActive) { obtVelocityArrow.Set(arrowPos, Vessel.obt_velocity); - obtVelocityArrow.SetLength((float)arrowsLength.val); + obtVelocityArrow.SetLength((float)arrowsLength.Val); obtVelocityArrow.SeeThrough(seeThrough); } @@ -209,7 +209,7 @@ public override void OnUpdate() if (forwardArrowActive) { forwardArrow.Set(arrowPos, Vessel.GetTransform().up); - forwardArrow.SetLength((float)arrowsLength.val); + forwardArrow.SetLength((float)arrowsLength.Val); forwardArrow.SeeThrough(seeThrough); } @@ -227,7 +227,7 @@ public override void OnUpdate() if (requestedAttitudeArrowActive && Core.Attitude.Enabled) { requestedAttitudeArrow.Set(arrowPos, Core.Attitude.RequestedAttitude); - requestedAttitudeArrow.SetLength((float)arrowsLength.val); + requestedAttitudeArrow.SetLength((float)arrowsLength.Val); requestedAttitudeArrow.SeeThrough(seeThrough); } diff --git a/MechJeb2/MechJebModuleDockingAutopilot.cs b/MechJeb2/MechJebModuleDockingAutopilot.cs index 5bcd82df4..4ba21b09b 100644 --- a/MechJeb2/MechJebModuleDockingAutopilot.cs +++ b/MechJeb2/MechJebModuleDockingAutopilot.cs @@ -250,12 +250,12 @@ public override void OnFixedUpdate() if (!overrideTargetSize) targetSize = targetBoundingBox.size.magnitude; else - targetSize = (float)overridenTargetSize.val; + targetSize = (float)overridenTargetSize.Val; if (!overrideSafeDistance) safeDistance = vesselBoundingBox.size.magnitude + targetSize + 0.5f; else - safeDistance = (float)overridenSafeDistance.val; + safeDistance = (float)overridenSafeDistance.Val; UpdateDistance(); @@ -333,12 +333,12 @@ private void InitDocking() if (!overrideTargetSize) targetSize = targetBoundingBox.size.magnitude; else - targetSize = (float)overridenTargetSize.val; + targetSize = (float)overridenTargetSize.Val; if (!overrideSafeDistance) safeDistance = vesselBoundingBox.size.magnitude + targetSize + 0.5f; else - safeDistance = (float)overridenSafeDistance.val; + safeDistance = (float)overridenSafeDistance.Val; if (Core.Target.Target is ModuleDockingNode) acquireRange = ((ModuleDockingNode)Core.Target.Target).acquireRange * 0.5; diff --git a/MechJeb2/MechJebModuleDockingGuidance.cs b/MechJeb2/MechJebModuleDockingGuidance.cs index 3058acf62..3df11ebc8 100644 --- a/MechJeb2/MechJebModuleDockingGuidance.cs +++ b/MechJeb2/MechJebModuleDockingGuidance.cs @@ -29,13 +29,13 @@ protected override void WindowGUI(int windowID) if (Vessel.GetReferenceTransformPart() == null || !Vessel.GetReferenceTransformPart().Modules.Contains("ModuleDockingNode")) { GUILayout.Label(Localizer.Format("#MechJeb_Docking_label2"), - GuiUtils.yellowLabel); //Warning: You need to control the vessel from a docking port. Right click a docking port and select "Control from here" + GuiUtils.YellowLabel); //Warning: You need to control the vessel from a docking port. Right click a docking port and select "Control from here" } if (!(Core.Target.Target is ModuleDockingNode)) { GUILayout.Label(Localizer.Format("#MechJeb_Docking_label3"), - GuiUtils.yellowLabel); //Warning: target is not a docking port. Right click the target docking port and select "Set as target" + GuiUtils.YellowLabel); //Warning: target is not a docking port. Right click the target docking port and select "Set as target" } bool onAxisNodeExists = false; @@ -52,7 +52,7 @@ protected override void WindowGUI(int windowID) if (!onAxisNodeExists) { GUILayout.Label(Localizer.Format("#MechJeb_Docking_label4"), - GuiUtils.yellowLabel); //Warning: this vessel is not controlled from a docking node. Right click the desired docking node on this vessel and select "Control from here." + GuiUtils.YellowLabel); //Warning: this vessel is not controlled from a docking node. Right click the desired docking node on this vessel and select "Control from here." } bool active = GUILayout.Toggle(autopilot.Enabled, Localizer.Format("#MechJeb_Docking_checkbox1")); // "Autopilot enabled" @@ -102,7 +102,7 @@ protected override void WindowGUI(int windowID) autopilot.forceRol = GUILayout.Toggle(autopilot.forceRol, Localizer.Format("#MechJeb_Docking_checkbox6"), GUILayout.ExpandWidth(false)); //"Force Roll :" - autopilot.rol.text = GUILayout.TextField(autopilot.rol.text, GUILayout.Width(30)); + autopilot.rol.Text = GUILayout.TextField(autopilot.rol.Text, GUILayout.Width(30)); GUILayout.Label("°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); diff --git a/MechJeb2/MechJebModuleFlightRecorderGraph.cs b/MechJeb2/MechJebModuleFlightRecorderGraph.cs index 54374a6ae..b388462da 100644 --- a/MechJeb2/MechJebModuleFlightRecorderGraph.cs +++ b/MechJeb2/MechJebModuleFlightRecorderGraph.cs @@ -591,7 +591,7 @@ private void DrawScaleLabels(Rect r) for (int i = 0; i < count; i++) { GUI.Label(new Rect(r.xMin - w, yBase - (float)(invScaleY * state.labelsPos[i]) - h * 0.5f, w, h), state.labels[i], - GuiUtils.middleRightLabel); + GuiUtils.MiddleRightLabel); } } diff --git a/MechJeb2/MechJebModuleInfoItems.cs b/MechJeb2/MechJebModuleInfoItems.cs index b3d953430..3bf1e99dc 100644 --- a/MechJeb2/MechJebModuleInfoItems.cs +++ b/MechJeb2/MechJebModuleInfoItems.cs @@ -996,7 +996,7 @@ public void AllPlanetPhaseAngles() while (o.referenceBody != Planetarium.fetch.Sun) o = o.referenceBody.orbit; GUILayout.BeginVertical(); - GUILayout.Label(Localizer.Format("#MechJeb_InfoItems_label6"), GuiUtils.middleCenterLabel); //"Planet phase angles" + GUILayout.Label(Localizer.Format("#MechJeb_InfoItems_label6"), GuiUtils.MiddleCenterLabel); //"Planet phase angles" for (int i = 0; i < FlightGlobals.Bodies.Count; i++) { @@ -1029,7 +1029,7 @@ public void AllPlanetPhaseAngles() public void AllMoonPhaseAngles() { GUILayout.BeginVertical(); - GUILayout.Label(Localizer.Format("#MechJeb_InfoItems_label7"), GuiUtils.middleCenterLabel); //"Moon phase angles" + GUILayout.Label(Localizer.Format("#MechJeb_InfoItems_label7"), GuiUtils.MiddleCenterLabel); //"Moon phase angles" if (Orbit.referenceBody != Planetarium.fetch.Sun) { diff --git a/MechJeb2/MechJebModuleManeuverPlanner.cs b/MechJeb2/MechJebModuleManeuverPlanner.cs index 20b449f6b..35e9cc607 100644 --- a/MechJeb2/MechJebModuleManeuverPlanner.cs +++ b/MechJeb2/MechJebModuleManeuverPlanner.cs @@ -118,7 +118,7 @@ protected override void WindowGUI(int windowID) if (_operation[_operationId].GetErrorMessage().Length > 0) { - GUILayout.Label(_operation[_operationId].GetErrorMessage(), GuiUtils.yellowLabel); + GUILayout.Label(_operation[_operationId].GetErrorMessage(), GuiUtils.YellowLabel); } if (GUILayout.Button(Localizer.Format("#MechJeb_Maneu_button3"))) //Remove ALL nodes @@ -160,17 +160,17 @@ protected override void WindowGUI(int windowID) GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_Maneu_Lead_time"), GUILayout.ExpandWidth(false)); //Lead time: - Core.Node.LeadTime.text = GUILayout.TextField(Core.Node.LeadTime.text, GUILayout.Width(35), GUILayout.ExpandWidth(false)); + Core.Node.LeadTime.Text = GUILayout.TextField(Core.Node.LeadTime.Text, GUILayout.Width(35), GUILayout.ExpandWidth(false)); GUILayout.Label("s", GUILayout.ExpandWidth(false)); if (GUILayout.Button("+", GUILayout.ExpandWidth(false))) - Core.Node.LeadTime.val += 1; + Core.Node.LeadTime.Val += 1; if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) - Core.Node.LeadTime.val -= 1; + Core.Node.LeadTime.Val -= 1; if (GUILayout.Button("R", GUILayout.ExpandWidth(false))) - Core.Node.LeadTime.val = 3; + Core.Node.LeadTime.Val = 3; GUILayout.EndHorizontal(); } diff --git a/MechJeb2/MechJebModuleMenu.cs b/MechJeb2/MechJebModuleMenu.cs index 0ddf95803..4b19ca054 100644 --- a/MechJeb2/MechJebModuleMenu.cs +++ b/MechJeb2/MechJebModuleMenu.cs @@ -81,20 +81,20 @@ public Rect displayedPos { case WindowSide.LEFT: return new Rect((windowProgr - 1) * WindowPos.width, - Mathf.Clamp(-100 - windowVPos, 0, GuiUtils.scaledScreenHeight - WindowPos.height), WindowPos.width, WindowPos.height); + 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, + 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, + 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); + return new Rect(Mathf.Clamp(windowVPos, -GuiUtils.ScaledScreenHeight, -100), + GuiUtils.ScaledScreenWidth - 25 - WindowPos.width * windowProgr, 100, 25); case WindowSide.TOP: - return new Rect(Mathf.Clamp(GuiUtils.scaledScreenWidth - windowHPos - 100, 0, GuiUtils.scaledScreenWidth - 50), + return new Rect(Mathf.Clamp(GuiUtils.ScaledScreenWidth - windowHPos - 100, 0, GuiUtils.ScaledScreenWidth - 50), 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); + return new Rect(Mathf.Clamp(GuiUtils.ScaledScreenWidth - windowHPos - 100, 0, GuiUtils.ScaledScreenWidth - 50), + GuiUtils.ScaledScreenHeight - windowProgr * WindowPos.height - 25, 100, 25); } } } @@ -574,7 +574,7 @@ public override void DrawGUI(bool inEditor) } 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; @@ -609,11 +609,11 @@ public void OnMenuUpdate() { if (windowSide == WindowSide.RIGHT || windowSide == WindowSide.LEFT) { - windowVPos = Mathf.Clamp(Input.mousePosition.y - Screen.height - 50, -Screen.width, 0) / GuiUtils.scale; + windowVPos = Mathf.Clamp(Input.mousePosition.y - Screen.height - 50, -Screen.width, 0) / GuiUtils.Scale; } else { - windowHPos = Mathf.Clamp(Screen.width - Input.mousePosition.x - 50, 0, Screen.width) / GuiUtils.scale; + windowHPos = Mathf.Clamp(Screen.width - Input.mousePosition.x - 50, 0, Screen.width) / GuiUtils.Scale; } } else if (Input.GetMouseButtonUp(1)) diff --git a/MechJeb2/MechJebModuleNodeEditor.cs b/MechJeb2/MechJebModuleNodeEditor.cs index 3bd7f6f8c..fff3af299 100644 --- a/MechJeb2/MechJebModuleNodeEditor.cs +++ b/MechJeb2/MechJebModuleNodeEditor.cs @@ -114,7 +114,7 @@ protected override void WindowGUI(int windowID) node.UpdateNode(new Vector3d(radialPlus, normalPlus, prograde), node.UT); } - progradeDelta.text = GUILayout.TextField(progradeDelta.text, GUILayout.Width(50)); + progradeDelta.Text = GUILayout.TextField(progradeDelta.Text, GUILayout.Width(50)); if (LimitedRepeatButtoon("+")) { prograde += progradeDelta; @@ -132,7 +132,7 @@ protected override void WindowGUI(int windowID) node.UpdateNode(new Vector3d(radialPlus, normalPlus, prograde), node.UT); } - radialPlusDelta.text = GUILayout.TextField(radialPlusDelta.text, GUILayout.Width(50)); + radialPlusDelta.Text = GUILayout.TextField(radialPlusDelta.Text, GUILayout.Width(50)); if (LimitedRepeatButtoon("+")) { radialPlus += radialPlusDelta; @@ -150,7 +150,7 @@ protected override void WindowGUI(int windowID) node.UpdateNode(new Vector3d(radialPlus, normalPlus, prograde), node.UT); } - normalPlusDelta.text = GUILayout.TextField(normalPlusDelta.text, GUILayout.Width(50)); + normalPlusDelta.Text = GUILayout.TextField(normalPlusDelta.Text, GUILayout.Width(50)); if (LimitedRepeatButtoon("+")) { normalPlus += normalPlusDelta; @@ -189,7 +189,7 @@ protected override void WindowGUI(int windowID) node.UpdateNode(node.DeltaV, node.UT - timeOffset); } - timeOffset.text = GUILayout.TextField(timeOffset.text, GUILayout.Width(100)); + timeOffset.Text = GUILayout.TextField(timeOffset.Text, GUILayout.Width(100)); if (GUILayout.Button("+", GUILayout.ExpandWidth(false))) { node.UpdateNode(node.DeltaV, node.UT + timeOffset); diff --git a/MechJeb2/MechJebModuleRCSController.cs b/MechJeb2/MechJebModuleRCSController.cs index 27ca2b004..6f591562c 100644 --- a/MechJeb2/MechJebModuleRCSController.cs +++ b/MechJeb2/MechJebModuleRCSController.cs @@ -95,9 +95,9 @@ public void setPIDParameters() pid.Kp = pid.Kd / (3 * Math.Sqrt(2) * Tf); pid.Ki = pid.Kp / (12 * Math.Sqrt(2) * Tf); - Kd.val = pid.Kd; - Kp.val = pid.Kp; - Ki.val = pid.Ki; + Kd.Val = pid.Kd; + Kp.Val = pid.Kp; + Ki.Val = pid.Ki; } } @@ -110,31 +110,31 @@ public void PIDGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("P", GUILayout.ExpandWidth(false)); - Kp.text = GUILayout.TextField(Kp.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + Kp.Text = GUILayout.TextField(Kp.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.Label("I", GUILayout.ExpandWidth(false)); - Kd.text = GUILayout.TextField(Kd.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + Kd.Text = GUILayout.TextField(Kd.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.Label("D", GUILayout.ExpandWidth(false)); - Ki.text = GUILayout.TextField(Ki.text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); + Ki.Text = GUILayout.TextField(Ki.Text, GUILayout.ExpandWidth(true), GUILayout.Width(60)); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("Tf", GUILayout.ExpandWidth(false)); - Tf.text = GUILayout.TextField(Tf.text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); + Tf.Text = GUILayout.TextField(Tf.Text, GUILayout.ExpandWidth(true), GUILayout.Width(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("P", GUILayout.ExpandWidth(false)); - GUILayout.Label(Kp.val.ToString("F4"), GUILayout.ExpandWidth(true)); + GUILayout.Label(Kp.Val.ToString("F4"), GUILayout.ExpandWidth(true)); GUILayout.Label("I", GUILayout.ExpandWidth(false)); - GUILayout.Label(Ki.val.ToString("F4"), GUILayout.ExpandWidth(true)); + GUILayout.Label(Ki.Val.ToString("F4"), GUILayout.ExpandWidth(true)); GUILayout.Label("D", GUILayout.ExpandWidth(false)); - GUILayout.Label(Kd.val.ToString("F4"), GUILayout.ExpandWidth(true)); + GUILayout.Label(Kd.Val.ToString("F4"), GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); } diff --git a/MechJeb2/MechJebModuleRendezvousAutopilot.cs b/MechJeb2/MechJebModuleRendezvousAutopilot.cs index 06570c5c9..14a594d25 100644 --- a/MechJeb2/MechJebModuleRendezvousAutopilot.cs +++ b/MechJeb2/MechJebModuleRendezvousAutopilot.cs @@ -188,7 +188,7 @@ public override void Drive(FlightCtrlState s) Vessel.PlaceManeuverNode(Orbit, dV, UT); } - status = Localizer.Format("#MechJeb_RZauto_statu7", numPhasingOrbits.ToString("F1"), maxPhasingOrbits.text, + status = Localizer.Format("#MechJeb_RZauto_statu7", numPhasingOrbits.ToString("F1"), maxPhasingOrbits.Text, (phasingOrbitRadius - MainBody.Radius) .ToSI(0)); //"Next intercept window would be <<1>> orbits away, which is more than the maximum of <<2>> phasing orbits. Increasing phasing rate by establishing new phasing orbit at <<3>>m } diff --git a/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs b/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs index 16601068e..ee96b550f 100644 --- a/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs +++ b/MechJeb2/MechJebModuleRendezvousAutopilotWindow.cs @@ -50,7 +50,7 @@ protected override void WindowGUI(int windowID) if (autopilot.maxPhasingOrbits < 5) { - GUILayout.Label(Localizer.Format("#MechJeb_RZauto_label6"), GuiUtils.yellowLabel); //"Max # of phasing orbits must be at least 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>>" diff --git a/MechJeb2/MechJebModuleRendezvousGuidance.cs b/MechJeb2/MechJebModuleRendezvousGuidance.cs index 8b0f199e9..92ca371cc 100644 --- a/MechJeb2/MechJebModuleRendezvousGuidance.cs +++ b/MechJeb2/MechJebModuleRendezvousGuidance.cs @@ -103,7 +103,7 @@ protected override void WindowGUI(int windowID) } } - phasingOrbitAltitude.text = GUILayout.TextField(phasingOrbitAltitude.text, GUILayout.Width(70)); + phasingOrbitAltitude.Text = GUILayout.TextField(phasingOrbitAltitude.Text, GUILayout.Width(70)); GUILayout.Label("km", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); diff --git a/MechJeb2/MechJebModuleRoverController.cs b/MechJeb2/MechJebModuleRoverController.cs index b006a27a1..41b011fa1 100644 --- a/MechJeb2/MechJebModuleRoverController.cs +++ b/MechJeb2/MechJebModuleRoverController.cs @@ -239,7 +239,7 @@ public override void // update GUI text only if the value changed if (newHeading != heading) - heading.val = newHeading; + heading.Val = newHeading; } if (ControlSpeed) @@ -256,7 +256,7 @@ public override void double minSpeed = wp.MinSpeed > 0 ? wp.MinSpeed : nextWP != null ? TurningSpeed(nextWP.MaxSpeed > 0 ? nextWP.MaxSpeed : speed, MuUtils.ClampDegrees180(heading - HeadingToPos(wp.Position, nextWP.Position))) : - distance - wp.Radius > 50 ? turnSpeed.val : 1; + distance - wp.Radius > 50 ? turnSpeed.Val : 1; minSpeed = wp.Quicksave ? 1 : minSpeed; // ^ speed used to go through the waypoint, using half the set speed or maxSpeed as minSpeed for routing waypoints (all except the last) double newSpeed = Math.Min(maxSpeed, Math.Max((distance - wp.Radius) / curSpeed, minSpeed)); // brake when getting closer @@ -351,7 +351,7 @@ public override void { speedPID.INTAccum = Mathf.Clamp((float)speedPID.INTAccum, -5, 5); - speedErr = (WaypointIndex == -1 ? speed.val : tgtSpeed) - Vector3d.Dot(VesselState.surfaceVelocity, VesselState.forward); + speedErr = (WaypointIndex == -1 ? speed.Val : tgtSpeed) - Vector3d.Dot(VesselState.surfaceVelocity, VesselState.forward); if (s.wheelThrottle == s.wheelThrottleTrim || FlightGlobals.ActiveVessel != Vessel) { float act = (float)speedPID.Compute(speedErr); diff --git a/MechJeb2/MechJebModuleRoverWindow.cs b/MechJeb2/MechJebModuleRoverWindow.cs index 9291673d2..180ddc99a 100644 --- a/MechJeb2/MechJebModuleRoverWindow.cs +++ b/MechJeb2/MechJebModuleRoverWindow.cs @@ -25,7 +25,7 @@ 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"); @@ -35,18 +35,18 @@ protected override void WindowGUI(int windowID) ed.registry.Find(i => i.id == "Toggle:RoverController.ControlHeading").DrawItem(); GUILayout.BeginHorizontal(); ed.registry.Find(i => i.id == "Editable:RoverController.heading").DrawItem(); - if (GUILayout.Button("-", GUILayout.Width(18))) { autopilot.heading.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } + if (GUILayout.Button("-", GUILayout.Width(18))) { autopilot.heading.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } - if (GUILayout.Button("+", GUILayout.Width(18))) { autopilot.heading.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } + if (GUILayout.Button("+", GUILayout.Width(18))) { autopilot.heading.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } GUILayout.EndHorizontal(); ed.registry.Find(i => i.id == "Value:RoverController.headingErr").DrawItem(); ed.registry.Find(i => i.id == "Toggle:RoverController.ControlSpeed").DrawItem(); GUILayout.BeginHorizontal(); ed.registry.Find(i => i.id == "Editable:RoverController.speed").DrawItem(); - if (GUILayout.Button("-", GUILayout.Width(18))) { autopilot.speed.val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } + if (GUILayout.Button("-", GUILayout.Width(18))) { autopilot.speed.Val -= GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } - if (GUILayout.Button("+", GUILayout.Width(18))) { autopilot.speed.val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } + if (GUILayout.Button("+", GUILayout.Width(18))) { autopilot.speed.Val += GameSettings.MODIFIER_KEY.GetKey() ? 5 : 1; } GUILayout.EndHorizontal(); ed.registry.Find(i => i.id == "Value:RoverController.speedErr").DrawItem(); diff --git a/MechJeb2/MechJebModuleSettings.cs b/MechJeb2/MechJebModuleSettings.cs index cd8646e7e..d9aae7fe2 100644 --- a/MechJeb2/MechJebModuleSettings.cs +++ b/MechJeb2/MechJebModuleSettings.cs @@ -44,8 +44,8 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global { base.OnLoad(local, type, global); - GuiUtils.SetGUIScale(UIScale.val); - GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu; + GuiUtils.SetGUIScale(UIScale.Val); + GuiUtils.DontUseDropDownMenu = dontUseDropDownMenu; if (useOldSkin) { @@ -68,46 +68,46 @@ protected override void WindowGUI(int windowID) } GUILayout.Label(Localizer.Format("#MechJeb_Settings_label1", (GuiUtils.SkinType)skinId)); //"Current skin: <<1>>" - if (GuiUtils.skin == null || skinId != 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); + GuiUtils.LoadSkin(GuiUtils.SkinType.MECH_JEB1); skinId = 1; } } - if (GuiUtils.skin == null || skinId != 0) + if (GuiUtils.Skin == null || skinId != 0) { if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button3"))) //"Use MechJeb 2 GUI skin" { - GuiUtils.LoadSkin(GuiUtils.SkinType.Default); + GuiUtils.LoadSkin(GuiUtils.SkinType.DEFAULT); skinId = 0; } } - if (GuiUtils.skin == null || skinId != 2) + if (GuiUtils.Skin == null || skinId != 2) { if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button4"))) //"Use MJ2 Compact GUI skin" { - GuiUtils.LoadSkin(GuiUtils.SkinType.Compact); + 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)); + UIScale.Text = GUILayout.TextField(UIScale.Text, GUILayout.Width(60)); GUILayout.EndHorizontal(); - GuiUtils.SetGUIScale(UIScale.val); + GuiUtils.SetGUIScale(UIScale.Val); dontUseDropDownMenu = GUILayout.Toggle(dontUseDropDownMenu, Localizer.Format("#MechJeb_Settings_checkbox1")); //"Replace drop down menu with arrow selector" - GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu; + GuiUtils.DontUseDropDownMenu = dontUseDropDownMenu; showAdvancedWindowSettings = GUILayout.Toggle(showAdvancedWindowSettings, "Show Advanced Window Settings"); - GuiUtils.showAdvancedWindowSettings = showAdvancedWindowSettings; + GuiUtils.ShowAdvancedWindowSettings = showAdvancedWindowSettings; MechJebModuleCustomWindowEditor ed = Core.GetComputerModule(); ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem(); diff --git a/MechJeb2/MechJebModuleSmartASS.cs b/MechJeb2/MechJebModuleSmartASS.cs index 7ed223d8b..bc79439f0 100644 --- a/MechJeb2/MechJebModuleSmartASS.cs +++ b/MechJeb2/MechJebModuleSmartASS.cs @@ -198,7 +198,7 @@ protected void ForceRoll() Engage(); } - rol.text = GUILayout.TextField(rol.text, GUILayout.Width(30)); + rol.Text = GUILayout.TextField(rol.Text, GUILayout.Width(30)); GUILayout.Label("°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); } diff --git a/MechJeb2/MechJebModuleSpaceplaneGuidance.cs b/MechJeb2/MechJebModuleSpaceplaneGuidance.cs index 1777960f8..bef7c40e3 100644 --- a/MechJeb2/MechJebModuleSpaceplaneGuidance.cs +++ b/MechJeb2/MechJebModuleSpaceplaneGuidance.cs @@ -38,7 +38,7 @@ protected override void WindowGUI(int windowID) if (availableRunways.Any()) { - GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label1"), GuiUtils.middleCenterLabel); //Landing + GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label1"), GuiUtils.MiddleCenterLabel); //Landing runwayIndex = GuiUtils.ComboBox.Box(runwayIndex, availableRunways.Select(p => p.name).ToArray(), this); autoland.runway = availableRunways[runwayIndex]; diff --git a/MechJeb2/MechJebModuleStagingController.cs b/MechJeb2/MechJebModuleStagingController.cs index 10e32b0d3..f6619922d 100644 --- a/MechJeb2/MechJebModuleStagingController.cs +++ b/MechJeb2/MechJebModuleStagingController.cs @@ -241,7 +241,7 @@ private void ClampAutostageThrust() 50); //"Clamp AutoStage Thrust " // ReSharper disable once CompareOfFloatsByEqualityOperator if (prev != Core.Staging.ClampAutoStageThrustPct) - Core.Staging.ClampAutoStageThrustPct.val = UtilMath.Clamp(Core.Staging.ClampAutoStageThrustPct, 0, 100); + Core.Staging.ClampAutoStageThrustPct.Val = UtilMath.Clamp(Core.Staging.ClampAutoStageThrustPct, 0, 100); } //internal state: diff --git a/MechJeb2/MechJebModuleTargetController.cs b/MechJeb2/MechJebModuleTargetController.cs index 005a82790..0525709cc 100644 --- a/MechJeb2/MechJebModuleTargetController.cs +++ b/MechJeb2/MechJebModuleTargetController.cs @@ -220,15 +220,15 @@ private void DoCoordinatePicking() if (mouseCoords != null) { - GLUtils.DrawGroundMarker(MainBody, mouseCoords.latitude, mouseCoords.longitude, new Color(1.0f, 0.56f, 0.0f), true, 60); + GLUtils.DrawGroundMarker(MainBody, mouseCoords.Latitude, mouseCoords.Longitude, new Color(1.0f, 0.56f, 0.0f), true, 60); - string biome = MainBody.GetExperimentBiomeSafe(mouseCoords.latitude, mouseCoords.longitude); + string biome = MainBody.GetExperimentBiomeSafe(mouseCoords.Latitude, mouseCoords.Longitude); GUI.Label(new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y, 200, 50), mouseCoords.ToStringDecimal() + "\n" + biome); if (Input.GetMouseButtonDown(0)) { - SetPositionTarget(MainBody, mouseCoords.latitude, mouseCoords.longitude); + SetPositionTarget(MainBody, mouseCoords.Latitude, mouseCoords.Longitude); StopPickPositionTargetOnMap(); } } diff --git a/MechJeb2/MechJebModuleThrustController.cs b/MechJeb2/MechJebModuleThrustController.cs index 52a6eeca0..23f3ac754 100644 --- a/MechJeb2/MechJebModuleThrustController.cs +++ b/MechJeb2/MechJebModuleThrustController.cs @@ -51,7 +51,7 @@ public MechJebModuleThrustController(MechJebCore core) [GeneralInfoItem("#MechJeb_LimittoMaxQ", InfoItem.Category.Thrust)] //Limit to Max Q public void LimitToMaxDynamicPressureInfoItem() { - GUIStyle s = Limiter == LimitMode.DYNAMIC_PRESSURE ? GuiUtils.greenToggle : null; + GUIStyle s = Limiter == LimitMode.DYNAMIC_PRESSURE ? GuiUtils.GreenToggle : null; GuiUtils.ToggledTextBox(ref LimitDynamicPressure, CachedLocalizer.Instance.MechJebAscentCheckbox11, MaxDynamicPressure, "pa", s, 80); } @@ -61,7 +61,7 @@ public void LimitToMaxDynamicPressureInfoItem() [GeneralInfoItem("#MechJeb_PreventEngineOverheats", InfoItem.Category.Thrust)] //Prevent engine overheats public void LimitToPreventOverheatsInfoItem() { - GUIStyle s = Limiter == LimitMode.TEMPERATURE ? GuiUtils.greenToggle : GuiUtils.skin.toggle; + GUIStyle s = Limiter == LimitMode.TEMPERATURE ? GuiUtils.GreenToggle : GuiUtils.Skin.toggle; LimitToPreventOverheats = GUILayout.Toggle(LimitToPreventOverheats, CachedLocalizer.Instance.MechJebAscentCheckbox12, s); //"Prevent engine overheats" } @@ -81,7 +81,7 @@ public void LimitToPreventOverheatsInfoItem() [GeneralInfoItem("#MechJeb_PreventJetFlameout", InfoItem.Category.Thrust)] //Prevent jet flameout public void LimitToPreventFlameoutInfoItem() { - GUIStyle s = Limiter == LimitMode.FLAMEOUT ? GuiUtils.greenToggle : GuiUtils.skin.toggle; + GUIStyle s = Limiter == LimitMode.FLAMEOUT ? GuiUtils.GreenToggle : GuiUtils.Skin.toggle; LimitToPreventFlameout = GUILayout.Toggle(LimitToPreventFlameout, CachedLocalizer.Instance.MechJebAscentCheckbox13, s); //"Prevent jet flameout" } @@ -92,7 +92,7 @@ public void LimitToPreventFlameoutInfoItem() [GeneralInfoItem("#MechJeb_PreventUnstableIgnition", InfoItem.Category.Thrust)] //Prevent unstable ignition public void LimitToPreventUnstableIgnitionInfoItem() { - GUIStyle s = Limiter == LimitMode.UNSTABLE_IGNITION ? GuiUtils.greenToggle : GuiUtils.skin.toggle; + GUIStyle s = Limiter == LimitMode.UNSTABLE_IGNITION ? GuiUtils.GreenToggle : GuiUtils.Skin.toggle; LimitToPreventUnstableIgnition = GUILayout.Toggle(LimitToPreventUnstableIgnition, CachedLocalizer.Instance.MechJebAscentCheckbox14, s); //"Prevent unstable ignition" } @@ -103,7 +103,7 @@ public void LimitToPreventUnstableIgnitionInfoItem() [GeneralInfoItem("#MechJeb_UseRCStoullage", InfoItem.Category.Thrust)] //Use RCS to ullage public void AutoRCsUllageInfoItem() { - GUIStyle s = Limiter == LimitMode.AUTO_RCS_ULLAGE ? GuiUtils.greenToggle : GuiUtils.skin.toggle; + GUIStyle s = Limiter == LimitMode.AUTO_RCS_ULLAGE ? GuiUtils.GreenToggle : GuiUtils.Skin.toggle; AutoRCSUllaging = GUILayout.Toggle(AutoRCSUllaging, CachedLocalizer.Instance.MechJebAscentCheckbox15, s); //"Use RCS to ullage" } @@ -125,7 +125,7 @@ public void AutoRCsUllageInfoItem() [GeneralInfoItem("#MechJeb_LimitAcceleration", InfoItem.Category.Thrust)] //Limit Acceleration public void LimitAccelerationInfoItem() { - GUIStyle s = Limiter == LimitMode.ACCELERATION ? GuiUtils.greenToggle : null; + GUIStyle s = Limiter == LimitMode.ACCELERATION ? GuiUtils.GreenToggle : null; GuiUtils.ToggledTextBox(ref LimitAcceleration, CachedLocalizer.Instance.MechJebAscentCheckbox16, MaxAcceleration, "m/s²", s, 30); //"Limit acceleration to" } @@ -140,7 +140,7 @@ public void LimitAccelerationInfoItem() [GeneralInfoItem("#MechJeb_LimitThrottle", InfoItem.Category.Thrust)] //Limit throttle public void LimitThrottleInfoItem() { - GUIStyle s = Limiter == LimitMode.THROTTLE ? MaxThrottle > 0d ? GuiUtils.greenToggle : GuiUtils.redToggle : null; + GUIStyle s = Limiter == LimitMode.THROTTLE ? MaxThrottle > 0d ? GuiUtils.GreenToggle : GuiUtils.RedToggle : null; GuiUtils.ToggledTextBox(ref LimitThrottle, CachedLocalizer.Instance.MechJebAscentCheckbox17, MaxAcceleration, "%", s, 30); //"Limit throttle to" } @@ -154,7 +154,7 @@ public void LimitThrottleInfoItem() [GeneralInfoItem("#MechJeb_LowerThrottleLimit", InfoItem.Category.Thrust)] //Lower throttle limit public void LimiterMinThrottleInfoItem() { - GUIStyle s = Limiter == LimitMode.MIN_THROTTLE ? GuiUtils.greenToggle : null; + GUIStyle s = Limiter == LimitMode.MIN_THROTTLE ? GuiUtils.GreenToggle : null; GuiUtils.ToggledTextBox(ref LimiterMinThrottle, CachedLocalizer.Instance.MechJebAscentCheckbox18, MinThrottle, "%", s, 30); //"Keep limited throttle over" } @@ -168,8 +168,8 @@ public void DifferentialThrottleMenu() { bool oldDifferentialThrottle = Core.Thrust.DifferentialThrottle; GUIStyle s = DifferentialThrottle && Vessel.LiftedOff() - ? Core.Thrust.DifferentialThrottleSuccess == DifferentialThrottleStatus.SUCCESS ? GuiUtils.greenToggle : GuiUtils.yellowToggle - : GuiUtils.skin.toggle; + ? Core.Thrust.DifferentialThrottleSuccess == DifferentialThrottleStatus.SUCCESS ? GuiUtils.GreenToggle : GuiUtils.YellowToggle + : GuiUtils.Skin.toggle; DifferentialThrottle = GUILayout.Toggle(DifferentialThrottle, CachedLocalizer.Instance.MechJebAscentCheckbox19, s); //"Differential throttle" @@ -196,12 +196,12 @@ public void DifferentialThrottleMenu() public void LimitElectricInfoItem() { GUILayout.BeginHorizontal(); - GUIStyle s = GuiUtils.skin.label; + GUIStyle s = GuiUtils.Skin.label; if (Limiter == LimitMode.ELECTRIC) { - s = VesselState.throttleLimit < 0.001 ? GuiUtils.redLabel : GuiUtils.yellowLabel; + s = VesselState.throttleLimit < 0.001 ? GuiUtils.RedLabel : GuiUtils.YellowLabel; } - else if (ElectricEngineRunning()) s = GuiUtils.greenLabel; + else if (ElectricEngineRunning()) s = GuiUtils.GreenLabel; ElectricThrottle = GUILayout.Toggle(ElectricThrottle, CachedLocalizer.Instance.MechJebAscentCheckbox20, s, diff --git a/MechJeb2/MechJebModuleThrustWindow.cs b/MechJeb2/MechJebModuleThrustWindow.cs index 41e936dde..43f9b190c 100644 --- a/MechJeb2/MechJebModuleThrustWindow.cs +++ b/MechJeb2/MechJebModuleThrustWindow.cs @@ -77,7 +77,7 @@ protected override void WindowGUI(int windowID) try { GUILayout.Label(Localizer.Format("#MechJeb_Utilities_label2")); //"Jet safety margin" - Core.Thrust.FlameoutSafetyPct.text = GUILayout.TextField(Core.Thrust.FlameoutSafetyPct.text, 5); + Core.Thrust.FlameoutSafetyPct.Text = GUILayout.TextField(Core.Thrust.FlameoutSafetyPct.Text, 5); GUILayout.Label("%"); } finally @@ -93,15 +93,15 @@ protected override void WindowGUI(int windowID) { case MechJebModuleThrustController.DifferentialThrottleStatus.MORE_ENGINES_REQUIRED: GUILayout.Label(Localizer.Format("#MechJeb_Utilities_label3"), - GuiUtils.yellowLabel); //"Differential throttle failed\nMore engines required" + GuiUtils.YellowLabel); //"Differential throttle failed\nMore engines required" break; case MechJebModuleThrustController.DifferentialThrottleStatus.ALL_ENGINES_OFF: GUILayout.Label(Localizer.Format("#MechJeb_Utilities_label4"), - GuiUtils.yellowLabel); //"Differential throttle failed\nNo active engine" + GuiUtils.YellowLabel); //"Differential throttle failed\nNo active engine" break; case MechJebModuleThrustController.DifferentialThrottleStatus.SOLVER_FAILED: GUILayout.Label(Localizer.Format("#MechJeb_Utilities_label5"), - GuiUtils.yellowLabel); //"Differential throttle failed\nCannot find solution" + GuiUtils.YellowLabel); //"Differential throttle failed\nCannot find solution" break; case MechJebModuleThrustController.DifferentialThrottleStatus.SUCCESS: break; diff --git a/MechJeb2/MechJebModuleTranslatron.cs b/MechJeb2/MechJebModuleTranslatron.cs index b18eeedab..dbfafc9ba 100644 --- a/MechJeb2/MechJebModuleTranslatron.cs +++ b/MechJeb2/MechJebModuleTranslatron.cs @@ -116,7 +116,7 @@ protected override void WindowGUI(int windowID) if (GUILayout.Button(Localizer.Format("#MechJeb_Trans_spd_act") + ":", buttonStyle, GUILayout.ExpandWidth(true)) || change) { - Core.Thrust.TransSpdAct = (float)trans_spd.val; + Core.Thrust.TransSpdAct = (float)trans_spd.Val; GUIUtility.keyboardControl = 0; } } diff --git a/MechJeb2/MechJebModuleWarpHelper.cs b/MechJeb2/MechJebModuleWarpHelper.cs index eb7c2223f..f17c69cd3 100644 --- a/MechJeb2/MechJebModuleWarpHelper.cs +++ b/MechJeb2/MechJebModuleWarpHelper.cs @@ -47,7 +47,7 @@ protected override void WindowGUI(int windowID) { GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("#MechJeb_WarpHelper_label2"), GUILayout.ExpandWidth(true)); //"Warp for: " - timeOffset.text = GUILayout.TextField(timeOffset.text, GUILayout.Width(100)); + timeOffset.Text = GUILayout.TextField(timeOffset.Text, GUILayout.Width(100)); GUILayout.EndHorizontal(); } else if (warpTarget == WarpTarget.PhaseAngleT) diff --git a/MechJeb2/MechJebModuleWaypointWindow.cs b/MechJeb2/MechJebModuleWaypointWindow.cs index d36db4276..52b7d92e2 100644 --- a/MechJeb2/MechJebModuleWaypointWindow.cs +++ b/MechJeb2/MechJebModuleWaypointWindow.cs @@ -612,7 +612,7 @@ public void DrawPageWaypoints() for (int i = 0; i < ap.Waypoints.Count; i++) { MechJebWaypoint wp = ap.Waypoints[i]; - double maxSpeed = wp.MaxSpeed > 0 ? wp.MaxSpeed : ap.speed.val; + double maxSpeed = wp.MaxSpeed > 0 ? wp.MaxSpeed : ap.speed.Val; float minSpeed = wp.MinSpeed > 0 ? wp.MinSpeed : 0; if (MapView.MapIsEnabled && i == selIndex) { @@ -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) @@ -1037,7 +1037,7 @@ protected override void WindowGUI(int windowID) if (styleInactive == null) { - styleInactive = new GUIStyle(GuiUtils.skin != null ? GuiUtils.skin.button : GuiUtils.defaultSkin.button); + styleInactive = new GUIStyle(GuiUtils.Skin != null ? GuiUtils.Skin.button : GuiUtils.DefaultSkin.button); styleInactive.alignment = TextAnchor.UpperLeft; } @@ -1110,14 +1110,14 @@ protected override void WindowGUI(int windowID) { if (selIndex > -1 && selIndex < ap.Waypoints.Count) { - ap.Waypoints.Insert(selIndex, new MechJebWaypoint(mouseCoords.latitude, mouseCoords.longitude)); + ap.Waypoints.Insert(selIndex, new MechJebWaypoint(mouseCoords.Latitude, mouseCoords.Longitude)); tmpRadius = ap.Waypoints[selIndex].Radius.ToString(); tmpLat = LatToString(ap.Waypoints[selIndex].Latitude); tmpLon = LonToString(ap.Waypoints[selIndex].Longitude); } else { - ap.Waypoints.Add(new MechJebWaypoint(mouseCoords.latitude, mouseCoords.longitude)); + ap.Waypoints.Add(new MechJebWaypoint(mouseCoords.Latitude, mouseCoords.Longitude)); } waitingForPick = alt; @@ -1184,7 +1184,7 @@ protected override void WindowGUI(int windowID) { if (btnInactive == null) { - btnInactive = new GUIStyle(GuiUtils.skin.button); + btnInactive = new GUIStyle(GuiUtils.Skin.button); btnInactive.alignment = TextAnchor.MiddleLeft; } diff --git a/MechJeb2/MechJebStageStatsHelper.cs b/MechJeb2/MechJebStageStatsHelper.cs index d5bcc8314..c5775d59e 100644 --- a/MechJeb2/MechJebStageStatsHelper.cs +++ b/MechJeb2/MechJebStageStatsHelper.cs @@ -323,7 +323,7 @@ public void AllStageStats() private static GUIStyle _columnStyle; public static GUIStyle ColumnStyle => - _columnStyle ??= new GUIStyle(GuiUtils.yellowOnHover) + _columnStyle ??= new GUIStyle(GuiUtils.YellowOnHover) { alignment = TextAnchor.MiddleRight, wordWrap = false, padding = new RectOffset(2, 2, 0, 0) };