Exemple #1
0
        public bool RegisterTo <S>(Func <VesselWrapper, bool> predicate = null)
            where S : TCAService
        {
            var srv = TCA.GetModule <S>();

            return(srv != null && srv.Register(this, predicate));
        }
Exemple #2
0
 protected override void draw_gui()
 {
     Utils.LockIfMouseOver(LockName, WindowPos, !MapView.MapIsEnabled);
     WindowPos =
         GUILayout.Window(TCA.GetInstanceID(),
                          WindowPos,
                          DrawMainWindow,
                          vessel.vesselName,
                          GUILayout.Width(ControlsWidth),
                          GUILayout.Height(50)).clampToScreen();
     if (ORB != null)
     {
         ORB.OrbitEditorWindow();
     }
     if (NAV != null)
     {
         NAV.DrawWaypoints();
     }
     AllWindows.ForEach(w => w.Draw());
     ModulesGraph.Draw();
                 #if DEBUG
     GUI.Label(debug_rect,
               string.Format("[{0}] {1:HH:mm:ss.fff}",
                             TCA != null && vessel != null? vessel.situation.ToString() : "",
                             DateTime.Now),
               Styles.boxed_label);
                 #endif
 }
Exemple #3
0
        public void UpdateState()
        {
            //update onPlanet state
            var on_planet = _OnPlanet();
            var in_orbit  = _InOrbit();

            if (on_planet != OnPlanet)
            {
                CFG.EnginesProfiles.OnPlanetChanged(on_planet);
                if (!on_planet)
                {
                    if (CFG.BlockThrottle)
                    {
                        var THR = TCA.GetModule <ThrottleControl>();
                        if (THR != null)
                        {
                            THR.Throttle = 0f;
                        }
                    }
                    CFG.DisableVSC();
                    CFG.Nav.Off();
                    CFG.HF.Off();
                }
            }
            OnPlanet       = on_planet;
            InOrbit        = in_orbit;
            IsActiveVessel = vessel != null && vessel == FlightGlobals.ActiveVessel;
        }
Exemple #4
0
        public bool UnregisterFrom <S>()
            where S : TCAService
        {
            var srv = TCA.GetModule <S>();

            return(srv != null && srv.Unregister(this));
        }
 void create_fields()
 {
     TCA.InitModuleFields(this);
     AllWindows.ForEach(w => w.Init(TCA));
     foreach (var fi in AllTabFields)
     {
         var tab = TCA.CreateComponent(fi.FieldType) as ControlTab;
         if (tab == null)
         {
             continue;
         }
         tab.Init();
         if (!tab.Valid)
         {
             continue;
         }
         var info = fi.GetCustomAttributes(typeof(TabInfo), false).FirstOrDefault() as TabInfo;
         if (info != null)
         {
             tab.SetupTab(info);
         }
         fi.SetValue(this, tab);
         AllTabs.Add(tab);
     }
     AllTabs.Sort((a, b) => a.Index.CompareTo(b.Index));
     if (CFG != null && CFG.ActiveTab < AllTabs.Count - 1)
     {
         ActiveTab = AllTabs[CFG.ActiveTab];
     }
     else
     {
         ActiveTab = AllTabs[0];
     }
 }
Exemple #6
0
 public void PreUpdateState(FlightCtrlState s)
 {
     //update control info
     PreUpdateControls = s;
     IsActiveVessel = vessel != null && vessel == FlightGlobals.ActiveVessel;
     HasUserInput = 
         !Mathfx.Approx(PreUpdateControls.pitch, PreUpdateControls.pitchTrim, 0.01f) ||
         !Mathfx.Approx(PreUpdateControls.roll, PreUpdateControls.rollTrim, 0.01f) ||
         !Mathfx.Approx(PreUpdateControls.yaw, PreUpdateControls.yawTrim, 0.01f);
     AutopilotDisabled = HasUserInput;
     //update onPlanet state
     var on_planet = vessel.OnPlanet();
     var in_orbit = vessel.InOrbit();
     if(on_planet != OnPlanet) 
     {
         if(CFG.Enabled)
             CFG.EnginesProfiles.OnPlanetChanged(on_planet);
         if(!on_planet) 
         { 
             if(CFG.BlockThrottle)
             {
                 var THR = TCA.GetModule<ThrottleControl>();
                 if(THR != null) THR.Throttle = 0f;
             }
             CFG.DisableVSC();
             CFG.Nav.Off(); 
             CFG.HF.Off();
             if(IsActiveVessel && TCAGui.Instance.ORB != null)
                 TCAGui.Instance.ActiveTab = TCAGui.Instance.ORB;
         }
     }
     OnPlanet = on_planet;
     InOrbit = in_orbit;
 }
Exemple #7
0
 protected override void OnLateUpdate()
 {
     base.OnLateUpdate();
     // disable sub-panels depending on situation
     Controller.ToggleOnPlanet(VSL.OnPlanet);
     Controller.ToggleInOrbit(VSL.InOrbit);
     // set states of the indicators
     Controller.Ascending.isOn           = TCA.IsStateSet(TCAState.Ascending);
     Controller.LoosingAltitude.isOn     = TCA.IsStateSet(TCAState.LoosingAltitude);
     Controller.TerrainCollision.isOn    = TCA.IsStateSet(TCAState.GroundCollision);
     Controller.VesselCollision.isOn     = TCA.IsStateSet(TCAState.VesselCollision);
     Controller.LowControlAuthority.isOn = !VSL.Controls.HaveControlAuthority;
     Controller.EnginesUnoptimized.isOn  = TCA.IsStateSet(TCAState.Unoptimized);
     Controller.VSC.isOn         = TCAModule.ExistsAndActive(VSC);
     Controller.ALT.isOn         = TCAModule.ExistsAndActive(ALT);
     Controller.VTOLMode.isOn    = TCAModule.ExistsAndActive(VTOL_control);
     Controller.VTOLAssist.isOn  = TCA.IsStateSet(TCAState.VTOLAssist);
     Controller.Stabilizing.isOn = TCA.IsStateSet(TCAState.StabilizeFlight);
     Controller.NoEngines.isOn   = TCA.IsStateSet(TCAState.HaveEC) &&
                                   !TCA.IsStateSet(TCAState.HaveActiveEngines);
     Controller.NoEC.isOn = TCA.IsStateSet(TCAState.Enabled) &&
                            !TCA.IsStateSet(TCAState.HaveEC);
     Controller.SmartEngines.isOn = CFG.UseSmartEngines;
     Controller.Stop.isOn         = CFG.HF[HFlight.Stop] ||
                                    TCAModule.ExistsAndActive(anchor);
     Controller.Navigation.isOn = CFG.Nav.Any(Navigation.GoToTarget,
                                              Navigation.FollowPath,
                                              Navigation.FollowTarget);
     // fade out irrelevant indicators
     Controller.TerrainCollision.SetActive(TCAModule.ExistsAndActive(RAD));
     Controller.VesselCollision.SetActive(CFG.UseCPS);
     Controller.VTOLAssist.SetActive(CFG.VTOLAssistON);
     Controller.Stabilizing.SetActive(CFG.StabilizeFlight);
     Controller.SmartEngines.SetActive(VSL.Engines.Clusters.Multi);
 }
Exemple #8
0
 void set_vspeed(float vspeed)
 {
     TCA.SquadConfigAction(cfg =>
     {
         cfg.VerticalCutoff = vspeed;
         cfg.BlockThrottle |= cfg.VSCIsActive;
     });
 }
Exemple #9
0
 public void SetVerticalCutoff(float cutoff)
 {
     TCA.SquadConfigAction(cfg =>
     {
         cfg.VerticalCutoff = cutoff;
         cfg.BlockThrottle |= cfg.VSCIsActive;
     });
 }
Exemple #10
0
 public override void Draw()
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label(UI.Title, Styles.label, GUILayout.ExpandWidth(true));
     if (GUILayout.Button(new GUIContent("Reload", "Reload TCA settings from file"),
                          Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         Globals.Load();
         TCA.OnReloadGlobals();
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     //change key binding
     if (GUILayout.Button(SelectingKey ? new GUIContent("HotKey: ?", "Choose new TCA hotkey") :
                          new GUIContent(string.Format("HotKey: {0}", UI.TCA_Key), "Select TCA Hotkey"),
                          SelectingKey ? Styles.enabled_button : Styles.active_button,
                          GUILayout.ExpandWidth(true)))
     {
         SelectingKey = true;
         Utils.Message("Press a key that will toggle TCA.\n" +
                       "Press BACKSPACE to remove TCA hotkey.\n" +
                       "Press ESCAPE to cancel.");
     }
     if (Utils.ButtonSwitch("AutoSave", ref Globals.Instance.AutosaveBeforeLanding,
                            "Automatically save the game before executing complex autopilot programs",
                            GUILayout.ExpandWidth(true)))
     {
         Globals.Save(":AutosaveBeforeLanding");
     }
     if (Utils.ButtonSwitch(Globals.Instance.UseStockAppLauncher ? "Launcher" : "Toolbar",
                            ref Globals.Instance.UseStockAppLauncher,
                            "Use stock AppLauncher or Toolbar plugin?",
                            GUILayout.ExpandWidth(true)))
     {
         TCAAppToolbar.Init();
         Globals.Save(":UseStockAppLauncher");
     }
     Utils.ButtonSwitch("AutoShow", ref UI.ShowOnHover,
                        "Show collapsed TCA window when mouse hovers over it",
                        GUILayout.ExpandWidth(true));
     if (GUILayout.Button(new GUIContent("InfoPanel",
                                         "Show test info message to change the position of the info panel"),
                          GUILayout.ExpandWidth(true)) &&
         string.IsNullOrEmpty(TCAGui.StatusMessage))
     {
         Status(InfoPanel.TEST_MSG);
     }
     GUILayout.EndHorizontal();
     Toggles();
     if (THR != null)
     {
         GUILayout.BeginHorizontal();
         CFG.ControlSensitivity = Utils.FloatSlider("Keyboard sensitivity", CFG.ControlSensitivity, 0.001f, 0.05f, "P2");
         GUILayout.EndHorizontal();
     }
     ControllerProperties();
     ConfigsGUI();
 }
 protected bool GetREN()
 {
     if (TCA == null && !GetTCA())
     {
         return(false);
     }
     REN = TCA.GetModule <RendezvousAutopilot>();
     return(REN != null);
 }
 protected bool GetModule()
 {
     if (TCA == null && !GetTCA())
     {
         return(false);
     }
     ORB = TCA.GetModule <ToOrbitAutopilot>();
     return(ORB != null);
 }
Exemple #13
0
 void onFollowTerrain(bool follow_terrain)
 {
     CFG.AltitudeAboveTerrain = follow_terrain;
     TCA.SquadAction(tca =>
     {
         var alt = tca.GetModule <AltitudeControl>();
         alt?.SetAltitudeAboveTerrain(CFG.AltitudeAboveTerrain);
     });
 }
 void land(SurfaceNode n)
 {
     CFG.Anchor        = n.ToWayPoint();
     CFG.Anchor.Radius = C.NodeTargetRange;
     SetTarget(CFG.Anchor);
     CFG.Nav.OnIfNot(Navigation.Anchor);
     WideCheckAlt = VSL.Geometry.H * (C.StopAtH + 1);
     TCA.SquadConfigAction(cfg => cfg.AP1.XOnIfNot(Autopilot1.Land));
     stage = Stage.Land;
 }
 public override void Draw()
 {
     GUILayout.Label(UI.Title, Styles.label, GUILayout.ExpandWidth(true));
     GUILayout.BeginHorizontal();
     //change key binding
     if (GUILayout.Button(SelectingKey? new GUIContent("HotKey: ?", "Choose new TCA hotkey") :
                          new GUIContent(string.Format("HotKey: {0}", UI.TCA_Key), "Select TCA Hotkey"),
                          SelectingKey? Styles.enabled_button : Styles.active_button,
                          GUILayout.ExpandWidth(true)))
     {
         SelectingKey = true;
         Utils.Message("Press a key that will toggle TCA.\n" +
                       "Press BACKSPACE to remove TCA hotkey.\n" +
                       "Press ESCAPE to cancel.");
     }
     Utils.ButtonSwitch("Autosave", ref Globals.Instance.AutosaveBeforeLanding,
                        "Automatically save the game before executing complex autopilot programs",
                        GUILayout.ExpandWidth(true));
     if (Utils.ButtonSwitch(Globals.Instance.UseStockAppLauncher? "Launcher" : "Toolbar",
                            ref Globals.Instance.UseStockAppLauncher,
                            "Use stock AppLauncher or Toolbar plugin?",
                            GUILayout.ExpandWidth(true)))
     {
         TCAToolbarManager.Init();
     }
     if (GUILayout.Button(new GUIContent("Reload", "Reload TCA settings from file"),
                          Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         Globals.Load();
         Styles.ConfigureButtons();
         TCA.OnReloadGlobals();
     }
     if (GUILayout.Button(new GUIContent("Modules", "Show TCA modules installed on this ship"),
                          Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         UI.ModulesGraph.Toggle();
     }
     GUILayout.EndHorizontal();
     Toggles();
     if (THR != null)
     {
         GUILayout.BeginHorizontal();
         CFG.ControlSensitivity = Utils.FloatSlider("Keyboard sensitivity", CFG.ControlSensitivity, 0.001f, 0.05f, "P2");
         GUILayout.EndHorizontal();
     }
     ControllerProperties();
     ConfigsGUI();
     #if DEBUG
     GUILayout.Space(10);
     TCA.TEST.Draw();
     #endif
 }
        protected override void DrawContent()
        {
            GUILayout.BeginVertical();
            GUILayout.Label(CFG.Enabled?
                            new GUIContent(
                                string.Format("{0} {1} ►{2}",
                                              Utils.formatBigValue(VSL.Altitude.Current, "m"),
                                              Utils.formatBigValue(VSL.VerticalSpeed.Display, "m/s", "▲ 0.0;▼ 0.0;▲ 0.0"),
                                              Utils.formatBigValue(VSL.HorizontalSpeed.Absolute, "m/s")),
                                "Altitude, Vertical speed, Horizontal speed.") : new GUIContent(""),
                            Styles.boxed_label, GUILayout.MinWidth(240), GUILayout.ExpandWidth(true));
            GUILayout.BeginHorizontal();
            if (ALT != null && CFG.VF[VFlight.AltitudeControl])
            {
                ALT.Draw();
            }
            else if (VSC != null)
            {
                VSC.Draw();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (ALT != null)
            {
                if (Utils.ButtonSwitch("Hover", CFG.VF[VFlight.AltitudeControl], "Maintain altitude", GUILayout.ExpandWidth(true)))
                {
                    TCA.SquadConfigAction(cfg => cfg.VF.XToggle(VFlight.AltitudeControl));
                }
                if (RAD != null)
                {
                    if (Utils.ButtonSwitch("Follow Terrain", ref CFG.AltitudeAboveTerrain,
                                           "Keep altitude above the ground", GUILayout.ExpandWidth(true)))
                    {
                        TCA.SquadAction(tca =>
                        {
                            var alt = tca.GetModule <AltitudeControl>();
                            if (alt != null)
                            {
                                alt.SetAltitudeAboveTerrain(CFG.AltitudeAboveTerrain);
                            }
                        });
                    }
//					RAD.DrawDebugLines();//debug
                }
            }
            if (THR != null)
            {
                THR.Draw();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Exemple #17
0
        void land()
        {
            var c = center_node;

            CFG.Anchor        = new WayPoint(c.position, VSL.Body);
            CFG.Anchor.Radius = LND.NodeTargetRange;
            CFG.Target        = CFG.Anchor;
            CFG.Nav.OnIfNot(Navigation.Anchor);
            CFG.DesiredAltitude = VSL.Geometry.H * (LND.StopAtH + 1);
            //Log("land: H {}, Alt {}", VSL.Geometry.H, CFG.DesiredAltitude);//debug
            TCA.SquadConfigAction(cfg => cfg.AP1.XOnIfNot(Autopilot1.Land));
            stage = Stage.Land;
        }
Exemple #18
0
 static void create_fields()
 {
     AllPanels.Clear();
     foreach (var fi in AllPanelFields)
     {
         var panel = TCA.CreateComponent(fi.FieldType) as ControlPanel;
         if (panel != null)
         {
             AllPanels.Add(panel);
         }
         fi.SetValue(null, panel);
     }
     ModuleFields.ForEach(fi => fi.SetValue(null, TCA.GetModule(fi.FieldType)));
 }
 void onHover(bool hover)
 {
     if (hover)
     {
         TCA.SquadConfigAction(cfg => {
             cfg.VF.XOnIfNot(VFlight.AltitudeControl);
             cfg.BlockThrottle = true;
         });
     }
     else
     {
         TCA.SquadConfigAction(cfg => cfg.VF.XOffIfOn(VFlight.AltitudeControl));
     }
 }
Exemple #20
0
 protected override void draw_gui()
 {
     Utils.LockIfMouseOver(LockName, WindowPos, !MapView.MapIsEnabled);
     WindowPos =
         GUILayout.Window(TCA.GetInstanceID(),
                          WindowPos,
                          DrawMainWindow,
                          VSL.vessel.vesselName,
                          GUILayout.Width(ControlsWidth),
                          GUILayout.Height(ControlsHeight)).clampToScreen();
     InOrbitControls.OrbitEditorWindow();
     if (Event.current.type == EventType.Repaint)
     {
         NavigationControls.WaypointOverlay();
     }
 }
 public void Update()
 {
     if (TCA == null)
     {
         return;
     }
     if (!TCA.Available && !init())
     {
         return;
     }
     if (!TCA.IsControllable)
     {
         return;
     }
     if (ADV != null && ADV.SelectingKey)
     {
         ADV.Update();
     }
     else if (!FlightDriver.Pause)
     {
         if (Input.GetKeyDown(TCA_Key))
         {
             TCA.ToggleTCA();
         }
         if (CFG.Enabled)
         {
             if (CFG.BlockThrottle && THR != null)
             {
                 if (CFG.VF[VFlight.AltitudeControl])
                 {
                     if (ALT != null)
                     {
                         ALT.ProcessKeys();
                     }
                 }
                 else if (VSC != null)
                 {
                     VSC.ProcessKeys();
                 }
             }
             if (WRP != null)
             {
                 WRP.ProcessKeys();
             }
         }
     }
 }
Exemple #22
0
 void AdvancedOptions()
 {
     if (!adv_options)
     {
         return;
     }
     GUILayout.BeginVertical(Styles.white);
     GUILayout.Label(Title, Styles.label, GUILayout.ExpandWidth(true));
     GUILayout.BeginHorizontal();
     //change key binding
     if (GUILayout.Button(selecting_key? new GUIContent("Change TCA hotkey: ?", "Choose new TCA hotkey") :
                          new GUIContent(string.Format("Change TCA hotkey: {0}", TCA_Key), "Select TCA Hotkey"),
                          selecting_key? Styles.enabled_button : Styles.active_button,
                          GUILayout.ExpandWidth(true)))
     {
         selecting_key = true; Utils.Message("Press a key that will toggle TCA");
     }
     Utils.ButtonSwitch("Autosave on landing", ref Globals.Instance.AutosaveBeforeLanding);
     if (Utils.ButtonSwitch("Use Stock Toolbar", ref Globals.Instance.UseStockAppLauncher))
     {
         TCAToolbarManager.Init();
     }
     if (GUILayout.Button("Reload TCA Settings", Styles.active_button, GUILayout.ExpandWidth(true)))
     {
         Globals.Load();
         Styles.ConfigureButtons();
         TCA.OnReloadGlobals();
     }
     GUILayout.EndHorizontal();
     Toggles.Draw();
     if (THR != null)
     {
         GUILayout.BeginHorizontal();
         CFG.ControlSensitivity = Utils.FloatSlider("Keyboard controls sensitivity", CFG.ControlSensitivity, 0.001f, 0.05f, "P2");
         GUILayout.EndHorizontal();
     }
     ControllerProperties();
     ConfigsGUI();
     GUILayout.EndVertical();
 }
 protected virtual bool GetModule()
 {
     MOD = TCA.GetModule <T>();
     return(MOD != null);
 }
        protected override void draw_gui()
        {
            //handle collapsed state
            if (Collapsed)
            {
                if (ShowOnHover)
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        draw_main_window = WindowPos.Contains(Event.current.mousePosition);
                    }
                    if (!draw_main_window)
                    {
                        UnlockControls();
                        var prefix = CFG.Enabled?
                                     "<b><color=lime>TCA: </color></b>" :
                                     (VSL.LandedOrSplashed? "<b>TCA: </b>" : "<b><color=red>TCA: </color></b>");
                        GUI.Label(collapsed_rect, prefix + StatusString(), Styles.boxed_label);
                    }
                }
                else
                {
                    UnlockControls();
                    GUI.Label(collapsed_rect, new GUIContent("TCA", "Push to show Main Window"),
                              CFG.Enabled? Styles.green : (VSL.LandedOrSplashed? Styles.white : Styles.red));
                    if (Input.GetMouseButton(0) && collapsed_rect.Contains(Event.current.mousePosition))
                    {
                        Collapsed = false;
                    }
                    TooltipManager.GetTooltip();
                }
            }
            else
            {
                draw_main_window = true;
            }
            //draw main window if allowed
            if (draw_main_window)
            {
                LockControls();
                WindowPos =
                    GUILayout.Window(TCA.GetInstanceID(),
                                     WindowPos,
                                     DrawMainWindow,
                                     RemoteControl? "RC: " + vessel.vesselName : vessel.vesselName,
                                     GUILayout.Width(ControlsWidth),
                                     GUILayout.Height(50)).clampToScreen();
                update_collapsed_rect();
            }
            //draw waypoints and all subwindows
            if (RemoteControl && Event.current.type == EventType.Repaint)
            {
                Markers.DrawWorldMarker(TCA.vessel.transform.position, Color.green,
                                        "Remotely Controlled Vessel", NavigationTab.PathNodeMarker, 8);
            }
            if (NAV != null)
            {
                NAV.DrawWaypoints();
            }
            AllWindows.ForEach(w => w.Draw());
            ModulesGraph.Draw();

                        #if DEBUG
            GUI.Label(debug_rect,
                      string.Format("[{0}] {1:HH:mm:ss.fff}",
                                    TCA != null && vessel != null? vessel.situation.ToString() : "",
                                    DateTime.Now),
                      Styles.boxed_label);
                        #endif
        }
 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();
 }
 string StatusString()
 {
     if (TCA.IsStateSet(TCAState.Enabled))
     {
         if (TCA.IsStateSet(TCAState.ObstacleAhead))
         {
             return("<color=red>Obstacle On Course</color>");
         }
         else if (TCA.IsStateSet(TCAState.GroundCollision))
         {
             return("<color=red>Ground Collision Possible</color>");
         }
         else if (TCA.IsStateSet(TCAState.LoosingAltitude))
         {
             return("<color=red>Loosing Altitude</color>");
         }
         else if (!VSL.Controls.HaveControlAuthority)
         {
             return("<color=red>Low Control Authority</color>");
         }
         else if (TCA.IsStateSet(TCAState.Unoptimized))
         {
             return("<color=yellow>Engines Unoptimized</color>");
         }
         else if (TCA.IsStateSet(TCAState.Ascending))
         {
             return("<color=yellow>Ascending</color>");
         }
         else if (TCA.IsStateSet(TCAState.VTOLAssist))
         {
             return("<color=yellow>VTOL Assist On</color>");
         }
         else if (TCA.IsStateSet(TCAState.StabilizeFlight))
         {
             return("<color=yellow>Stabilizing Flight</color>");
         }
         else if (TCA.IsStateSet(TCAState.AltitudeControl))
         {
             return("<color=lime>Altitude Control</color>");
         }
         else if (TCA.IsStateSet(TCAState.VerticalSpeedControl))
         {
             return("<color=lime>Vertical Speed Control</color>");
         }
         else if (TCA.State == TCAState.Nominal)
         {
             return("<color=lime>Systems Nominal</color>");
         }
         else if (TCA.State == TCAState.NoActiveEngines)
         {
             return("<color=yellow>No Active Engines</color>");
         }
         else if (TCA.State == TCAState.NoEC)
         {
             return("<color=red>No Electric Charge</color>");
         }
         else                 //this should never happen
         {
             return("<color=magenta>Unknown State</color>");
         }
     }
     return("<color=grey>Disabled</color>");
 }
 void set_altitude()
 {
     TCA.SquadConfigAction(set_altitude);
     set_altitude(CFG);
 }
Exemple #28
0
        void StatusString()
        {
            var state = "Disabled";
            var style = Styles.grey;

            if (TCA.IsStateSet(TCAState.Enabled))
            {
                if (TCA.IsStateSet(TCAState.ObstacleAhead))
                {
                    state = "Obstacle On Course"; style = Styles.red;
                }
                else if (TCA.IsStateSet(TCAState.GroundCollision))
                {
                    state = "Ground Collision Possible"; style = Styles.red;
                }
                else if (TCA.IsStateSet(TCAState.LoosingAltitude))
                {
                    state = "Loosing Altitude"; style = Styles.red;
                }
                else if (!VSL.Controls.HaveControlAuthority)
                {
                    state = "Low Control Authority"; style = Styles.red;
                }
                else if (TCA.IsStateSet(TCAState.Unoptimized))
                {
                    state = "Engines Unoptimized"; style = Styles.yellow;
                }
                else if (TCA.IsStateSet(TCAState.Ascending))
                {
                    state = "Ascending"; style = Styles.yellow;
                }
                else if (TCA.IsStateSet(TCAState.VTOLAssist))
                {
                    state = "VTOL Assist On"; style = Styles.yellow;
                }
                else if (TCA.IsStateSet(TCAState.StabilizeFlight))
                {
                    state = "Stabilizing Flight"; style = Styles.yellow;
                }
                else if (TCA.IsStateSet(TCAState.AltitudeControl))
                {
                    state = "Altitude Control"; style = Styles.green;
                }
                else if (TCA.IsStateSet(TCAState.VerticalSpeedControl))
                {
                    state = "Vertical Speed Control"; style = Styles.green;
                }
                else if (TCA.State == TCAState.Nominal)
                {
                    state = "Systems Nominal"; style = Styles.green;
                }
                else if (TCA.State == TCAState.NoActiveEngines)
                {
                    state = "No Active Engines"; style = Styles.yellow;
                }
                else if (TCA.State == TCAState.NoEC)
                {
                    state = "No Electric Charge"; style = Styles.red;
                }
                else                 //this should never happen
                {
                    state = "Unknown State"; style = Styles.magenta;
                }
            }
            GUILayout.Label(state, style, GUILayout.ExpandWidth(false));
        }
Exemple #29
0
 protected string GetID() =>
 string.Format("{0}.{1}[{2:X}]", TCA.GetID(), GetType().Name, GetHashCode());
Exemple #30
0
 public void InitModuleFields()
 {
     TCA.InitModuleFields(this);
 }