static void onToolbarToggle(ClickEvent e)
 {
     if (TCA != null)
     {
         TCAGui.Toggle();
     }
     else if (HighLogic.LoadedSceneIsEditor && EnginesProfileEditor.Available)
     {
         EnginesProfileEditor.Toggle();
     }
     else
     {
         TCAManual.Toggle();
     }
 }
 static void onToolbarToggle(ClickEvent e)
 {
     if (TCA != null)
     {
         TCAGui.ToggleWithButton(TCAButton);
     }
     else if (HighLogic.LoadedSceneIsEditor && TCAGuiEditor.Available)
     {
         TCAGuiEditor.ToggleWithButton(TCAButton);
     }
     else
     {
         TCAManual.ToggleWithButton(TCAButton);
     }
 }
예제 #3
0
 protected override void onLeftClick()
 {
     if (TCA != null)
     {
         TCAGui.ToggleWithButton(ALButton);
     }
     else if (HighLogic.LoadedSceneIsEditor && TCAGuiEditor.Available)
     {
         TCAGuiEditor.ToggleWithButton(ALButton);
     }
     else
     {
         TCAManual.ToggleWithButton(ALButton);
     }
 }
예제 #4
0
 public override void OnLoad(ConfigNode node)
 {
     Globals.Load();
     #if DEBUG
     //UI = ConfigNodeObjectGUI.FromObject(Globals.Instance);
     #endif
     LoadConfigs(node);
     //navigation paths
     var paths = node.GetNode(PathDB.NODE_NAME);
     if (paths != null)
     {
         Paths.Load(paths);
     }
     else
     {
         Paths.Clear();
     }
     //patched conics availability
     HavePatchedConics = GameVariables.Instance
                         .GetOrbitDisplayMode(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation))
                         == GameVariables.OrbitDisplayMode.PatchedConics;
     //check if MM is successfully installed ModuleTCA in any of the parts
     ModuleInstalled = false;
     foreach (var p in PartLoader.LoadedPartsList)
     {
         if (p.partPrefab != null && p.partPrefab.HasModule <ModuleTCA>())
         {
             ModuleInstalled = true;
             break;
         }
     }
     if (!ModuleInstalled)
     {
         TCAManual.ShowStatus();
     }
     //check for PersistentRotation
     HavePersistentRotation = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == Globals.Instance.PersistentRotationName) != null;
 }
예제 #5
0
 public override void OnLoad(ConfigNode node)
 {
     LoadConfigs(node);
     //patched conics availability
     HavePatchedConics = GameVariables.Instance
                         .GetOrbitDisplayMode(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation))
                         == GameVariables.OrbitDisplayMode.PatchedConics;
     //update available parts
     Parts = TCAModulesDatabase.GetPurchasedParts();
     //check if MM is successfully installed ModuleTCA in any of the parts
     ModuleInstalled = false;
     foreach (var p in PartLoader.LoadedPartsList)
     {
         if (p.partPrefab != null && p.partPrefab.HasModule <ModuleTCA>())
         {
             ModuleInstalled = true;
             break;
         }
     }
     if (!ModuleInstalled)
     {
         TCAManual.ShowStatus();
     }
     //check for PersistentRotation
     HavePersistentRotation = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == Globals.Instance.PersistentRotationName) != null;
     //deprecated: Old config conversion
     if (Configs.Count == 0 && NamedConfigs.Count == 0)
     {
         var cnode = loadNode(Globals.Instance.PluginData("TCA.conf"));
         if (cnode != null)
         {
             LoadLegacyConfigs(cnode);
         }
     }
     Globals.Load();
 }
예제 #6
0
 void DrawMainWindow(int windowID)
 {
     //help button
     if (GUI.Button(new Rect(WindowPos.width - 23f, 2f, 20f, 18f),
                    new GUIContent("?", "Help")))
     {
         TCAManual.ToggleInstance();
     }
     GUILayout.BeginVertical();
     {
         GUILayout.BeginHorizontal();
         {
             if (GUILayout.Button(new GUIContent("Select Modules", "Select which TCA Modules should be installed on this ship"),
                                  Styles.active_button, GUILayout.ExpandWidth(true)))
             {
                 PartsEditor.Toggle();
             }
             if (Modules[typeof(MacroProcessor)])
             {
                 if (TCAMacroEditor.Editing)
                 {
                     GUILayout.Label("Edit Macros", Styles.inactive_button, GUILayout.ExpandWidth(true));
                 }
                 else if (GUILayout.Button("Edit Macros", Styles.active_button, GUILayout.ExpandWidth(true)))
                 {
                     TCAMacroEditor.Edit(CFG);
                 }
             }
             if (GUILayout.Button(new GUIContent("Save As Default", "Save current configuration as default for new ships in this facility (VAB/SPH)"),
                                  Styles.active_button, GUILayout.ExpandWidth(true)))
             {
                 var facility = EditorLogic.fetch.ship.shipFacility;
                 warning.Message     = string.Format("Are you sure you want to save current ship configuration as default for {0}?", facility);
                 warning.yesCallback = () => TCAScenario.UpdateDefaultConfig(facility, CFG);
                 warning.Show(true);
             }
         }
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         {
             GUILayout.BeginVertical();
             {
                 GUILayout.BeginHorizontal();
                 {
                     if (Utils.ButtonSwitch("Enable TCA", ref CFG.Enabled, "", GUILayout.ExpandWidth(true)))
                     {
                         if (!CFG.Enabled)
                         {
                             Engines.ForEach(e => e.forceThrustPercentage(100));
                         }
                         CFG.GUIVisible = CFG.Enabled;
                     }
                     if (Modules[typeof(AltitudeControl)])
                     {
                         if (Utils.ButtonSwitch("Hover", CFG.VF[VFlight.AltitudeControl],
                                                "Enable Altitude Control", GUILayout.ExpandWidth(false)))
                         {
                             CFG.VF.Toggle(VFlight.AltitudeControl);
                         }
                         Utils.ButtonSwitch("Follow Terrain", ref CFG.AltitudeAboveTerrain,
                                            "Enable follow terrain mode", GUILayout.ExpandWidth(false));
                     }
                     if (Modules[typeof(VTOLControl)])
                     {
                         if (Utils.ButtonSwitch("VTOL Mode", CFG.CTRL[ControlMode.VTOL],
                                                "Keyboard controls thrust direction instead of torque", GUILayout.ExpandWidth(false)))
                         {
                             CFG.CTRL.XToggle(ControlMode.VTOL);
                         }
                     }
                     if (Modules[typeof(VTOLAssist)])
                     {
                         Utils.ButtonSwitch("VTOL Assist", ref CFG.VTOLAssistON,
                                            "Automatic assistance with vertical takeof or landing", GUILayout.ExpandWidth(false));
                     }
                     if (Modules[typeof(FlightStabilizer)])
                     {
                         Utils.ButtonSwitch("Flight Stabilizer", ref CFG.StabilizeFlight,
                                            "Automatic flight stabilization when vessel is out of control", GUILayout.ExpandWidth(false));
                     }
                     if (Modules[typeof(CollisionPreventionSystem)])
                     {
                         Utils.ButtonSwitch("CPS", ref CFG.UseCPS,
                                            "Enable Collistion Prevention System", GUILayout.ExpandWidth(false));
                     }
                 }
                 GUILayout.EndHorizontal();
                 GUILayout.BeginHorizontal();
                 {
                     Utils.ButtonSwitch("AutoThrottle", ref CFG.BlockThrottle,
                                        "Change altitude/vertical velocity using main throttle control", GUILayout.ExpandWidth(true));
                     if (Utils.ButtonSwitch("SmartEngines", ref CFG.UseSmartEngines,
                                            "Group engines by thrust direction and automatically use appropriate group for a meneuver", GUILayout.ExpandWidth(true)))
                     {
                         if (CFG.UseSmartEngines)
                         {
                             CFG.SmartEngines.OnIfNot(SmartEnginesMode.Best);
                         }
                     }
                     Utils.ButtonSwitch("AutoGear", ref CFG.AutoGear,
                                        "Automatically deploy/retract landing gear when needed", GUILayout.ExpandWidth(true));
                     Utils.ButtonSwitch("AutoBrakes", ref CFG.AutoBrakes,
                                        "Automatically ebable/disable brakes when needed", GUILayout.ExpandWidth(true));
                     Utils.ButtonSwitch("AutoStage", ref CFG.AutoStage,
                                        "Automatically activate next stage when previous falmeouted", GUILayout.ExpandWidth(true));
                     Utils.ButtonSwitch("AutoChute", ref CFG.AutoParachutes,
                                        "Automatically activate parachutes when needed", GUILayout.ExpandWidth(true));
                 }
                 GUILayout.EndHorizontal();
                 GUILayout.BeginHorizontal();
                 if (Modules[typeof(HorizontalSpeedControl)])
                 {
                     Utils.ButtonSwitch("RCS Translation", ref CFG.CorrectWithTranslation,
                                        "Use RCS to correct horizontal velocity", GUILayout.ExpandWidth(true));
                 }
                 Utils.ButtonSwitch("RCS Rotation", ref CFG.RotateWithRCS,
                                    "Use RCS for attitude control", GUILayout.ExpandWidth(true));
                 GUILayout.EndHorizontal();
             }
             GUILayout.EndVertical();
         }
         GUILayout.EndHorizontal();
         if (Engines.Count > 0)
         {
             if (GUILayout.Button(new GUIContent("Autoconfigure Active Profile",
                                                 "This will overwrite any existing groups and roles"),
                                  Styles.danger_button, GUILayout.ExpandWidth(true)))
             {
                 autoconfigure_profile = true;
             }
             CFG.EnginesProfiles.Draw(height);
             if (CFG.ActiveProfile.Changed)
             {
                 CFG.ActiveProfile.Apply(Engines);
                 update_engines = true;
             }
         }
         GUILayout.BeginHorizontal(Styles.white);
         {
             GUILayout.Label("Ship Info:");
             GUILayout.FlexibleSpace();
             GUILayout.Label("Mass:", Styles.boxed_label);
             if (Utils.ButtonSwitch(Utils.formatMass(Mass), use_wet_mass, "Balance engines using Wet Mass"))
             {
                 use_wet_mass = true;
                 update_stats = true;
             }
             GUILayout.Label("►");
             if (Utils.ButtonSwitch(Utils.formatMass(DryMass), !use_wet_mass, "Balance engines using Dry Mass"))
             {
                 use_wet_mass = false;
                 update_stats = true;
             }
             if (CFG.Enabled)
             {
                 if (ActiveEngines.Count > 0)
                 {
                     GUILayout.Label(new GUIContent(string.Format("TMR: {0:F2} ► {1:F2}", MinTWR, MaxTWR),
                                                    "Thrust ot Mass Ratio"),
                                     Styles.fracStyle(Utils.Clamp(MinTWR - 1, 0, 1)));
                     GUILayout.Label(new GUIContent(string.Format("Balanced: {0:P1}", MinLimit),
                                                    "The efficacy of the least efficient of balanced engines"),
                                     Styles.fracStyle(MinLimit));
                     Utils.ButtonSwitch("HL", ref show_imbalance, "Highlight engines with low efficacy deu to balancing");
                 }
                 else
                 {
                     GUILayout.Label("No active engines", Styles.boxed_label);
                 }
             }
             else
             {
                 GUILayout.Label("TCA is disabled", Styles.boxed_label);
             }
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
     TooltipsAndDragWindow();
 }
 void DrawMainWindow(int windowID)
 {
     //help button
     if (GUI.Button(new Rect(0, 0f, 20f, 18f),
                    Collapsed? uncollapse_button : collapse_button, Styles.label))
     {
         Collapsed = !Collapsed;
         update_collapsed_rect();
     }
     if (GUI.Button(new Rect(WindowPos.width - 20f, 0f, 20f, 18f),
                    new GUIContent("?", "Help"), Styles.label))
     {
         TCAManual.ToggleInstance();
     }
     //vessel switching
     if (HaveRemoteControl)
     {
         if (GUI.Button(new Rect(22, 0f, 20f, 18f), prev_vessel_button, Styles.label))
         {
             switch_vessel(FlightGlobals.Vessels.Next);
         }
         if (RemoteControl &&
             GUI.Button(new Rect(44, 0f, 20f, 18f), active_vessel_button, Styles.label))
         {
             onVesselChange(ActiveVesselTCA.vessel);
         }
         if (RemoteControl &&
             GUI.Button(new Rect(WindowPos.width - 64f, 0f, 20f, 18f), switch_vessel_button, Styles.label))
         {
             FlightGlobals.SetActiveVessel(vessel);
         }
         if (GUI.Button(new Rect(WindowPos.width - 42f, 0f, 20f, 18f), next_vessel_button, Styles.label))
         {
             switch_vessel(FlightGlobals.Vessels.Prev);
         }
     }
     if (TCA.IsControllable)
     {
         GUILayout.BeginVertical();
         GUILayout.BeginHorizontal();
         //tca toggle
         var enabled_style = Styles.inactive_button;
         if (CFG.Enabled)
         {
             enabled_style = Styles.enabled_button;
         }
         else if (!VSL.LandedOrSplashed)
         {
             if (EnabledBlinker.On)
             {
                 enabled_style = Styles.danger_button;
             }
             Status(0.1, "red", "<b>TCA is disabled</b>");
         }
         if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70)))
         {
             TCA.ToggleTCA();
         }
                         #if DEBUG
         if (GUILayout.Button("ReGlobals", Styles.active_button, GUILayout.ExpandWidth(false)))
         {
             Globals.Load();
             Styles.ConfigureButtons();
             TCA.OnReloadGlobals();
         }
                         #endif
         //squad mode switch
         if (SQD != null)
         {
             SQD.Draw();
         }
         GUILayout.FlexibleSpace();
         StatusLabel();
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.BeginVertical(Styles.white, GUILayout.MinHeight(ControlsHeight), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true));
         if (ActiveTab != null)
         {
             ActiveTab.Draw();
         }
         GUILayout.EndVertical();
         tabs_scroll = GUILayout.BeginScrollView(tabs_scroll, Styles.white, GUILayout.ExpandHeight(true), GUILayout.Width(55));
         for (int i = 0, AllTabsCount = AllTabs.Count; i < AllTabsCount; i++)
         {
             var t = AllTabs[i];
             if (t.DrawTabButton(t == ActiveTab))
             {
                 ActiveTab     = t;
                 CFG.ActiveTab = i;
             }
         }
         GUILayout.EndScrollView();
         GUILayout.EndHorizontal();
         DrawStatusMessage();
         GUILayout.EndVertical();
     }
     else
     {
         GUILayout.BeginVertical();
         GUILayout.BeginHorizontal();
         VSL.Info.Draw();
         GUILayout.FlexibleSpace();
         StatusLabel();
         GUILayout.EndHorizontal();
         GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
         DrawStatusMessage();
         GUILayout.EndVertical();
     }
     TooltipsAndDragWindow();
 }
 void DrawMainWindow(int windowID)
 {
     //help button
     if (GUI.Button(new Rect(WindowPos.width - 23f, 2f, 20f, 18f),
                    new GUIContent("?", "Help")))
     {
         TCAManual.Toggle();
     }
     GUILayout.BeginVertical();
     if (HasMacroProcessor)
     {
         if (TCAMacroEditor.Editing)
         {
             GUILayout.Label("Edit Macros", Styles.inactive_button, GUILayout.ExpandWidth(true));
         }
         else if (GUILayout.Button("Edit Macros", Styles.normal_button, GUILayout.ExpandWidth(true)))
         {
             TCAMacroEditor.Edit(CFG);
         }
     }
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
     GUILayout.BeginHorizontal();
     Utils.ButtonSwitch("Enable TCA", ref CFG.Enabled, "", GUILayout.ExpandWidth(false));
     if (HasAltitudeControl)
     {
         if (Utils.ButtonSwitch("Hover", CFG.VF[VFlight.AltitudeControl],
                                "Enable Altitude Control", GUILayout.ExpandWidth(false)))
         {
             CFG.VF.Toggle(VFlight.AltitudeControl);
         }
         Utils.ButtonSwitch("Follow Terrain", ref CFG.AltitudeAboveTerrain,
                            "Enable follow terrain mode", GUILayout.ExpandWidth(false));
         Utils.ButtonSwitch("AutoThrottle", ref CFG.BlockThrottle,
                            "Change altitude/vertical velocity using main throttle control", GUILayout.ExpandWidth(false));
     }
     if (HasVTOLControls)
     {
         if (Utils.ButtonSwitch("VTOL Mode", CFG.CTRL[ControlMode.VTOL],
                                "Keyboard controls thrust direction instead of torque", GUILayout.ExpandWidth(false)))
         {
             CFG.CTRL.XToggle(ControlMode.VTOL);
         }
     }
     if (HasVTOLAssist)
     {
         Utils.ButtonSwitch("VTOL Assist", ref CFG.VTOLAssistON,
                            "Automatic assistnce with vertical takeof or landing", GUILayout.ExpandWidth(false));
     }
     if (HasFlightStabilizer)
     {
         Utils.ButtonSwitch("Flight Stabilizer", ref CFG.StabilizeFlight,
                            "Automatic flight stabilization when vessel is out of control", GUILayout.ExpandWidth(false));
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     Utils.ButtonSwitch("AutoGear", ref CFG.AutoGear,
                        "Automatically deploy/retract landing gear when needed", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoBrakes", ref CFG.AutoBrakes,
                        "Automatically ebable/disable brakes when needed", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoStage", ref CFG.AutoStage,
                        "Automatically activate next stage when previous falmeouted", GUILayout.ExpandWidth(true));
     Utils.ButtonSwitch("AutoChute", ref CFG.AutoParachutes,
                        "Automatically activate parachutes when needed", GUILayout.ExpandWidth(true));
     GUILayout.EndHorizontal();
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
     CFG.EnginesProfiles.Draw(height);
     if (CFG.ActiveProfile.Changed)
     {
         CFG.ActiveProfile.Apply(Engines);
         update_engines = true;
     }
     GUILayout.BeginHorizontal(Styles.white);
     GUILayout.Label("Ship Info:");
     GUILayout.FlexibleSpace();
     GUILayout.Label(string.Format("Mass: {0} ► {1}", Utils.formatMass(Mass), Utils.formatMass(DryMass)), Styles.boxed_label);
     GUILayout.Label(string.Format("TWR: {0:F2} ► {1:F2}", MinTWR, MaxTWR), Styles.boxed_label);
     GUILayout.EndHorizontal();
     GUILayout.EndVertical();
     TooltipsAndDragWindow(WindowPos);
 }
예제 #9
0
        void DrawMainWindow(int windowID)
        {
            //help button
            if (GUI.Button(new Rect(WindowPos.width - 23f, 2f, 20f, 18f),
                           new GUIContent("?", "Help")))
            {
                TCAManual.Toggle();
            }
            if (TCA.Controllable)
            {
                //options button
                if (GUI.Button(new Rect(2f, 2f, 70f, 18f),
                               new GUIContent("advanced", "Advanced configuration"),
                               adv_options? Styles.enabled_button : Styles.normal_button))
                {
                    adv_options = !adv_options;
                }
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                //tca toggle
                var enabled_style = Styles.inactive_button;
                if (CFG.Enabled)
                {
                    enabled_style = Styles.enabled_button;
                }
                else if (!VSL.LandedOrSplashed)
                {
                    if (EnabledBlinker.On)
                    {
                        enabled_style = Styles.danger_button;
                    }
                    Status(0.1, "red", "<b>TCA is disabled</b>");
                }
                if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70)))
                {
                    if (SQD == null)
                    {
                        TCA.ToggleTCA();
                    }
                    else
                    {
                        SQD.Apply(tca => tca.ToggleTCA());
                    }
                }
                //squad mode switch
                SquadControls.Draw();
                GUILayout.FlexibleSpace();
                StatusString();
                GUILayout.EndHorizontal();
                SelectConfig_start();
                AdvancedOptions();
                AttitudeControls.Draw();
                InOrbitControls.Draw();
                OnPlanetControls.Draw();
                NavigationControls.Draw();
                MacroControls.Draw();
                NavigationControls.WaypointList();
                EnginesControl();
                                #if DEBUG
                DebugInfo();
//				EnginesInfo();
                                #endif
                if (!string.IsNullOrEmpty(StatusMessage))
                {
                    if (GUILayout.Button(new GUIContent(StatusMessage, "Click to dismiss"),
                                         Styles.boxed_label, GUILayout.ExpandWidth(true)) ||
                        StatusEndTime > DateTime.MinValue && DateTime.Now > StatusEndTime)
                    {
                        StatusMessage = "";
                    }
                }
                SelectConfig_end();
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            TooltipsAndDragWindow(WindowPos);
        }