Added partless flight activation, compact right collapse and settings in build engineer.
Added partless flight activation, compact right collapse and settings in build engineer.

--- a/KerbalEngineer/Editor/BuildAdvanced.cs
+++ b/KerbalEngineer/Editor/BuildAdvanced.cs
@@ -17,12 +17,13 @@
 //     along with this program.  If not, see <http://www.gnu.org/licenses/>.

 // 

 

-#region

+#region Using Directives

 

 using System;

 using System.Linq;

 

 using KerbalEngineer.Extensions;

+using KerbalEngineer.Flight;

 using KerbalEngineer.Settings;

 using KerbalEngineer.VesselSimulator;

 

@@ -46,11 +47,14 @@
 

         #region Fields

 

+        private float atmosphericPercentage = 1.0f;

+        private float atmosphericVelocity;

+        private int compactCheck;

+        private bool compactCollapseRight;

+        private float compactRight;

         private bool hasChanged;

         private bool isEditorLocked;

         private int numberOfStages;

-        private float atmosphericPercentage = 1.0f;

-        private float atmosphericVelocity;

         private int windowId;

         private Rect windowPosition = new Rect(265.0f, 45.0f, 0, 0);

 

@@ -60,6 +64,7 @@
         private GUIStyle areaStyle;

         private GUIStyle buttonStyle;

         private GUIStyle infoStyle;

+        private GUIStyle settingStyle;

         private GUIStyle titleStyle;

         private GUIStyle windowStyle;

 

@@ -73,6 +78,7 @@
         private bool showAllStages;

         private bool showAtmosphericDetails;

         private bool showReferenceBodies;

+        private bool showSettings;

         private bool visible = true;

 

         /// <summary>

@@ -96,7 +102,7 @@
             get { return this.compactMode; }

             set

             {

-                this.compactMode = value; 

+                this.compactMode = value;

                 Logger.Log("BuildAdvanced->CompactMode = " + value);

             }

         }

@@ -109,7 +115,7 @@
             get { return this.showAllStages; }

             set

             {

-                this.showAllStages = value; 

+                this.showAllStages = value;

                 Logger.Log("BuildAdvanced->ShowAllStages = " + value);

             }

         }

@@ -122,7 +128,7 @@
             get { return this.showAtmosphericDetails; }

             set

             {

-                this.showAtmosphericDetails = value; 

+                this.showAtmosphericDetails = value;

                 Logger.Log("BuildAdvanced->ShowAtmosphericDetails = " + value);

             }

         }

@@ -135,8 +141,18 @@
             get { return this.showReferenceBodies; }

             set

             {

-                this.showReferenceBodies = value; 

+                this.showReferenceBodies = value;

                 Logger.Log("BuildAdvanced->ShowReferenceBodies = " + value);

+            }

+        }

+

+        public bool ShowSettings

+        {

+            get { return this.showSettings; }

+            set

+            {

+                this.showSettings = value;

+                Logger.Log("BuildAdvanced->ShowSettings = " + value);

             }

         }

 

@@ -196,7 +212,7 @@
                     fontSize = 11,

                     fontStyle = FontStyle.Bold,

                     alignment = TextAnchor.MiddleCenter,

-                    stretchWidth = true

+                    stretchWidth = true,

                 };

 

                 this.infoStyle = new GUIStyle(HighLogic.Skin.label)

@@ -206,6 +222,11 @@
                     alignment = TextAnchor.MiddleCenter,

                     stretchWidth = true

                 };

+

+                this.settingStyle = new GUIStyle(this.titleStyle)

+                {

+                    stretchHeight = true

+                };

             }

             catch (Exception ex)

             {

@@ -276,6 +297,16 @@
 

                     this.windowPosition = GUILayout.Window(this.windowId, this.windowPosition, this.Window, title, this.windowStyle).ClampToScreen();

 

+                    if (this.compactCheck > 0 && this.compactCollapseRight)

+                    {

+                        this.windowPosition.x = this.compactRight - this.windowPosition.width;

+                        this.compactCheck--;

+                    }

+                    else if (this.compactCheck > 0)

+                    {

+                        this.compactCheck = 0;

+                    }

+

                     // Check editor lock to manage click-through.

                     this.CheckEditorLock();

                 }

@@ -321,25 +352,33 @@
                 if (GUI.Toggle(new Rect(this.windowPosition.width - 70.0f, 5.0f, 65.0f, 20.0f), this.compactMode, "COMPACT", this.buttonStyle) != this.compactMode)

                 {

                     this.hasChanged = true;

+                    this.compactCheck = 2;

+                    this.compactRight = this.windowPosition.xMax;

                     this.compactMode = !this.compactMode;

                 }

 

                 // When not in compact mode draw the 'All Stages' and 'Atmospheric' toggles.

                 if (!this.compactMode)

                 {

-                    if (GUI.Toggle(new Rect(this.windowPosition.width - 153.0f, 5.0f, 80.0f, 20.0f), this.showAllStages, "ALL STAGES", this.buttonStyle) != this.showAllStages)

+                    if (GUI.Toggle(new Rect(this.windowPosition.width - 143.0f, 5.0f, 70.0f, 20.0f), this.showSettings, "SETTINGS", this.buttonStyle) != this.showSettings)

+                    {

+                        this.hasChanged = true;

+                        this.showSettings = !this.showSettings;

+                    }

+

+                    if (GUI.Toggle(new Rect(this.windowPosition.width - 226.0f, 5.0f, 80.0f, 20.0f), this.showAllStages, "ALL STAGES", this.buttonStyle) != this.showAllStages)

                     {

                         this.hasChanged = true;

                         this.showAllStages = !this.showAllStages;

                     }

 

-                    if (GUI.Toggle(new Rect(this.windowPosition.width - 251.0f, 5.0f, 95.0f, 20.0f), this.showAtmosphericDetails, "ATMOSPHERIC", this.buttonStyle) != this.showAtmosphericDetails)

+                    if (GUI.Toggle(new Rect(this.windowPosition.width - 324.0f, 5.0f, 95.0f, 20.0f), this.showAtmosphericDetails, "ATMOSPHERIC", this.buttonStyle) != this.showAtmosphericDetails)

                     {

                         this.hasChanged = true;

                         this.showAtmosphericDetails = !this.showAtmosphericDetails;

                     }

 

-                    if (GUI.Toggle(new Rect(this.windowPosition.width - 379.0f, 5.0f, 125.0f, 20.0f), this.showReferenceBodies, "REFERENCE BODIES", this.buttonStyle) != this.showReferenceBodies)

+                    if (GUI.Toggle(new Rect(this.windowPosition.width - 452.0f, 5.0f, 125.0f, 20.0f), this.showReferenceBodies, "REFERENCE BODIES", this.buttonStyle) != this.showReferenceBodies)

                     {

                         this.hasChanged = true;

                         this.showReferenceBodies = !this.showReferenceBodies;

@@ -375,6 +414,13 @@
                         this.DrawReferenceBodies();

                         GUILayout.EndVertical();

                     }

+

+                    if (this.showSettings)

+                    {

+                        GUILayout.BeginVertical(this.areaStyle);

+                        this.DrawSettings();

+                        GUILayout.EndVertical();

+                    }

                 }

                 else // Draw only a few details when in compact mode.

                 {

@@ -401,13 +447,13 @@
             try

             {

                 GUILayout.BeginHorizontal();

-                GUILayout.Label("Pressure " + (this.atmosphericPercentage * 100.0f).ToString("F1") + "%", this.titleStyle, GUILayout.Width(125.0f));

+                GUILayout.Label("Pressure " + (this.atmosphericPercentage * 100.0f).ToString("F1") + "%", this.settingStyle, GUILayout.Width(125.0f));

                 GUI.skin = HighLogic.Skin;

                 this.atmosphericPercentage = GUILayout.HorizontalSlider(this.atmosphericPercentage, 0, 1.0f);

                 GUI.skin = null;

                 GUILayout.EndHorizontal();

                 GUILayout.BeginHorizontal();

-                GUILayout.Label("Velocity " + this.atmosphericVelocity.ToString("F1") + "m/s", this.titleStyle, GUILayout.Width(125.0f));

+                GUILayout.Label("Velocity " + this.atmosphericVelocity.ToString("F1") + "m/s", this.settingStyle, GUILayout.Width(125.0f));

                 GUI.skin = HighLogic.Skin;

                 this.atmosphericVelocity = GUILayout.HorizontalSlider(this.atmosphericVelocity, 0, 2500f);

                 GUI.skin = null;

@@ -452,6 +498,28 @@
             }

         }

 

+        private void DrawSettings()

+        {

+            try

+            {

+                GUILayout.BeginHorizontal();

+                GUILayout.Label("Compact mode collapses to the:", this.settingStyle);

+                this.compactCollapseRight = !GUILayout.Toggle(!this.compactCollapseRight, "LEFT", this.buttonStyle, GUILayout.Width(100.0f));

+                this.compactCollapseRight = GUILayout.Toggle(this.compactCollapseRight, "RIGHT", this.buttonStyle, GUILayout.Width(100.0f));

+                GUILayout.EndHorizontal();

+

+                GUILayout.BeginHorizontal();

+                GUILayout.Label("Flight Engineer activation mode:", this.settingStyle);

+                FlightEngineerPartless.IsPartless = GUILayout.Toggle(FlightEngineerPartless.IsPartless, "PARTLESS", this.buttonStyle, GUILayout.Width(100.0f));

+                FlightEngineerPartless.IsPartless = !GUILayout.Toggle(!FlightEngineerPartless.IsPartless, "MODULE", this.buttonStyle, GUILayout.Width(100.0f));

+                GUILayout.EndHorizontal();

+            }

+            catch (Exception ex)

+            {

+                Logger.Exception(ex, "BuildAdvanced->DrawSettings");

+            }

+        }

+

         /// <summary>

         ///     Draws the stage number column.

         /// </summary>

@@ -483,7 +551,6 @@
         {

             try

             {

-

                 GUILayout.BeginVertical(GUILayout.Width(50.0f));

                 GUILayout.Label("PARTS", this.titleStyle);

                 foreach (var stage in SimManager.Stages)

@@ -532,7 +599,6 @@
         {

             try

             {

-

                 GUILayout.BeginVertical(GUILayout.Width(110.0f));

                 GUILayout.Label("MASS", this.titleStyle);

                 foreach (var stage in SimManager.Stages)

@@ -689,6 +755,7 @@
                 handler.Set("showAllStages", this.showAllStages);

                 handler.Set("showAtmosphericDetails", this.showAtmosphericDetails);

                 handler.Set("showReferenceBodies", this.showReferenceBodies);

+                handler.Set("showSettings", this.showSettings);

                 handler.Set("selectedBodyName", CelestialBodies.Instance.SelectedBodyName);

                 handler.Save("BuildAdvanced.xml");

             }

@@ -712,6 +779,7 @@
                 handler.Get("compactMode", ref this.compactMode);

                 handler.Get("showAllStages", ref this.showAllStages);

                 handler.Get("showAtmosphericDetails", ref this.showAtmosphericDetails);

+                handler.Get("showSettings", ref this.showSettings);

                 CelestialBodies.Instance.SelectedBodyName = handler.Get("selectedBodyName", CelestialBodies.Instance.SelectedBodyName);

             }

             catch (Exception ex)


--- a/KerbalEngineer/Flight/FlightEngineerModule.cs
+++ b/KerbalEngineer/Flight/FlightEngineerModule.cs
@@ -49,7 +49,7 @@
         {

             try

             {

-                if (!HighLogic.LoadedSceneIsFlight)

+                if (!HighLogic.LoadedSceneIsFlight || FlightEngineerPartless.IsPartless)

                 {

                     return;

                 }

@@ -59,7 +59,7 @@
                     // Checks for an existing instance of FlightEngineerCore, and if this part is the first part containing FlightEngineerModule within the vessel.

                     if (flightEngineerCore == null && this.part == this.vessel.parts.FirstOrDefault(p => p.Modules.Contains("FlightEngineerModule")))

                     {

-                        flightEngineerCore = this.gameObject.AddComponent<FlightEngineerCore>();

+                        this.flightEngineerCore = this.gameObject.AddComponent<FlightEngineerCore>();

                     }

                 }

                 else if (flightEngineerCore != null)


--- /dev/null
+++ b/KerbalEngineer/Flight/FlightEngineerPartless.cs
@@ -1,1 +1,102 @@
-
+// 

+//     Kerbal Engineer Redux

+// 

+//     Copyright (C) 2014 CYBUTEK

+// 

+//     This program is free software: you can redistribute it and/or modify

+//     it under the terms of the GNU General Public License as published by

+//     the Free Software Foundation, either version 3 of the License, or

+//     (at your option) any later version.

+// 

+//     This program is distributed in the hope that it will be useful,

+//     but WITHOUT ANY WARRANTY; without even the implied warranty of

+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+//     GNU General Public License for more details.

+// 

+//     You should have received a copy of the GNU General Public License

+//     along with this program.  If not, see <http://www.gnu.org/licenses/>.

+// 

+

+#region Using Directives

+

+using System;

+

+using KerbalEngineer.Settings;

+

+using UnityEngine;

+

+#endregion

+

+namespace KerbalEngineer.Flight

+{

+    [KSPAddon(KSPAddon.Startup.Flight, false)]

+    public class FlightEngineerPartless : MonoBehaviour

+    {

+        #region Fields

+

+        private FlightEngineerCore flightEngineerCore;

+

+        #endregion

+

+        #region Initialisation

+

+        static FlightEngineerPartless()

+        {

+            try

+            {

+                var handler = SettingHandler.Load("FlightEngineerPartless.xml");

+                handler.Get("isPartless", ref isPartless);

+            }

+            catch (Exception ex)

+            {

+                Logger.Exception(ex, "FlightEngineerPartless->FlightEngineerPartless");

+            }

+        }

+

+        private void Awake()

+        {

+            try

+            {

+                if (isPartless)

+                {

+                    this.flightEngineerCore = this.gameObject.AddComponent<FlightEngineerCore>();

+                }

+            }

+            catch (Exception ex)

+            {

+                Logger.Exception(ex, "FlightEngineerPartless->Awake");

+            }

+        }

+

+        #endregion

+

+        #region Properties

+

+        private static bool isPartless = true;

+

+        public static bool IsPartless

+        {

+            get { return isPartless; }

+            set

+            {

+                try

+                {

+                    if (isPartless != value)

+                    {

+                        var handler = SettingHandler.Load("FlightEngineerPartless.xml");

+                        handler.Set("isPartless", value);

+                        handler.Save("FlightEngineerPartless.xml");

+                    }

+                    isPartless = value;

+                    Logger.Log("FlightEngineerPartless->IsPartless = " + value);

+                }

+                catch (Exception ex)

+                {

+                    Logger.Exception(ex, "FlightEngineerPartless->IsPartless");

+                }

+            }

+        }

+

+        #endregion

+    }

+}

--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -60,6 +60,7 @@
     <Compile Include="Editor\BuildOverlay.cs" />

     <Compile Include="CelestialBodies.cs" />

     <Compile Include="Editor\BuildToolbar.cs" />

+    <Compile Include="Flight\FlightEngineerPartless.cs" />

     <Compile Include="Flight\Readouts\Vessel\SimulationDelay.cs" />

     <Compile Include="Logger.cs" />

     <Compile Include="EngineerGlobals.cs" />


 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ