Example #1
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            GUIStyle s = new GUIStyle(GUI.skin.label);

            s.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("Landing", s);

            Runway[] runways     = MechJebModuleSpaceplaneAutopilot.runways;
            int      runwayIndex = Array.IndexOf(runways, autopilot.runway);

            runwayIndex      = GuiUtils.ArrowSelector(runwayIndex, runways.Length, autopilot.runway.name);
            autopilot.runway = runways[runwayIndex];

            GUILayout.Label("Distance to runway: " + MuUtils.ToSI(Vector3d.Distance(vesselState.CoM, autopilot.runway.Start(vesselState.CoM)), 0) + "m");

            showLandingTarget = GUILayout.Toggle(showLandingTarget, "Show landing navball guidance");

            if (GUILayout.Button("Autoland"))
            {
                autopilot.Autoland(this);
            }
            if (autopilot.enabled && autopilot.mode == MechJebModuleSpaceplaneAutopilot.Mode.AUTOLAND &&
                GUILayout.Button("Abort"))
            {
                autopilot.AutopilotOff();
            }

            GuiUtils.SimpleTextBox("Autoland glideslope:", autopilot.glideslope, "º");

            GUILayout.Label("Hold", s);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Initiate hold:"))
            {
                autopilot.HoldHeadingAndAltitude(this);
            }
            GUILayout.Label("Heading:");
            autopilot.targetHeading.text = GUILayout.TextField(autopilot.targetHeading.text, GUILayout.Width(40));
            GUILayout.Label("º Altitude:");
            autopilot.targetAltitude.text = GUILayout.TextField(autopilot.targetAltitude.text, GUILayout.Width(40));
            GUILayout.Label("m");
            GUILayout.EndHorizontal();

            if (autopilot.enabled && autopilot.mode == MechJebModuleSpaceplaneAutopilot.Mode.HOLD &&
                GUILayout.Button("Abort"))
            {
                autopilot.AutopilotOff();
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Example #2
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUIStyle s = new GUIStyle(GUI.skin.label);

            s.alignment = TextAnchor.MiddleCenter;

            List <Runway> availableRunways = MechJebModuleSpaceplaneAutopilot.runways.Where(p => p.body == mainBody).ToList();

            if (runwayIndex > availableRunways.Count)
            {
                runwayIndex = 0;
            }

            if (availableRunways.Any())
            {
                GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label1"), s);//Landing

                runwayIndex     = GuiUtils.ComboBox.Box(runwayIndex, availableRunways.Select(p => p.name).ToArray(), this);
                autoland.runway = availableRunways[runwayIndex];

                GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label2") + MuUtils.ToSI(Vector3d.Distance(vesselState.CoM, autoland.runway.Start()), 0) + "m"); //Distance to runway:

                showLandingTarget = GUILayout.Toggle(showLandingTarget, Localizer.Format("#MechJeb_ApproAndLand_label3"));                                              //Show landing navball guidance

                if (GUILayout.Button(Localizer.Format("#MechJeb_ApproAndLan_button1")))                                                                                 //Autoland
                {
                    autoland.Autoland(this);
                }
                if (autoland.enabled && GUILayout.Button(Localizer.Format("#MechJeb_ApproAndLan_button2")))//Abort
                {
                    autoland.AutopilotOff();
                }

                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_ApproAndLand_label14"), autoland.glideslope, "°");                                         //Autoland glideslope:
                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_ApproAndLand_label4"), autoland.approachSpeed, "m/s");                                     //Approach speed:
                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_ApproAndLand_label5"), autoland.touchdownSpeed, "m/s");                                    //Touchdown speed:

                autoland.bEngageReverseIfAvailable = GUILayout.Toggle(autoland.bEngageReverseIfAvailable, Localizer.Format("#MechJeb_ApproAndLand_label6")); //Reverse thrust upon touchdown
                autoland.bBreakAsSoonAsLanded      = GUILayout.Toggle(autoland.bBreakAsSoonAsLanded, Localizer.Format("#MechJeb_ApproAndLand_label7"));      //Brake as soon as landed

                if (autoland.enabled)
                {
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label8") + autoland.AutolandApproachStateToHumanReadableDescription());                            //State:
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label9", Math.Round(autoland.GetAutolandLateralDistanceToNextWaypoint(), 0)));                     //Distance to waypoint: {0}m
                    //GUILayout.Label(string.Format("Distance to waypoint: {0} m", Math.Round(autoland.GetAutolandLateralDistanceToNextWaypoint(), 0)));
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label10", Math.Round(autoland.Autopilot.SpeedTarget, 1)));                                         //Target speed: {0} m/s
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label11", Math.Round(autoland.GetAutolandTargetAltitude(autoland.GetAutolandTargetVector()), 0))); //Target altitude: {0} m
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label12", Math.Round(autoland.Autopilot.VertSpeedTarget, 1)));                                     //Target vertical speed: {0} m/s
                    GUILayout.Label(Localizer.Format("#MechJeb_ApproAndLand_label13", Math.Round(autoland.Autopilot.HeadingTarget, 0)));                                       //Target heading: {0}º
                }
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUIStyle s = new GUIStyle(GUI.skin.label);

            s.alignment = TextAnchor.MiddleCenter;

            List <Runway> availableRunways = MechJebModuleSpaceplaneAutopilot.runways.Where(p => p.body == mainBody).ToList();

            if (runwayIndex > availableRunways.Count)
            {
                runwayIndex = 0;
            }

            if (availableRunways.Any())
            {
                GUILayout.Label("Landing", s);

                runwayIndex     = GuiUtils.ComboBox.Box(runwayIndex, availableRunways.Select(p => p.name).ToArray(), this);
                autoland.runway = availableRunways[runwayIndex];

                GUILayout.Label("Distance to runway: " + MuUtils.ToSI(Vector3d.Distance(vesselState.CoM, autoland.runway.Start()), 0) + "m");

                showLandingTarget = GUILayout.Toggle(showLandingTarget, "Show landing navball guidance");

                if (GUILayout.Button("Autoland"))
                {
                    autoland.Autoland(this);
                }
                if (autoland.enabled && GUILayout.Button("Abort"))
                {
                    autoland.AutopilotOff();
                }

                GuiUtils.SimpleTextBox("Autoland glideslope:", autoland.glideslope);
                GuiUtils.SimpleTextBox("Approach speed:", autoland.approachSpeed);
                GuiUtils.SimpleTextBox("Touchdown speed:", autoland.touchdownSpeed);
                autoland.bEngageReverseIfAvailable = GUILayout.Toggle(autoland.bEngageReverseIfAvailable, "Reverse thrust upon touchdown");
                autoland.bBreakAsSoonAsLanded      = GUILayout.Toggle(autoland.bBreakAsSoonAsLanded, "Break As Soon As Landed");

                if (autoland.enabled)
                {
                    GUILayout.Label("State: " + autoland.AutolandApproachStateToHumanReadableDescription());
                    GUILayout.Label(string.Format("Distance to waypoint: {0} m", Math.Round(autoland.GetAutolandLateralDistanceToNextWaypoint(), 0)));
                    GUILayout.Label(string.Format("Target speed: {0} m/s", Math.Round(autoland.Autopilot.SpeedTarget, 1)));
                    GUILayout.Label(string.Format("Target altitude: {0} m", Math.Round(autoland.GetAutolandTargetAltitude(autoland.GetAutolandTargetVector()), 0)));
                    GUILayout.Label(string.Format("Target vertical speed: {0} m/s", Math.Round(autoland.Autopilot.VertSpeedTarget, 1)));
                    GUILayout.Label(string.Format("Target heading: {0}º", Math.Round(autoland.Autopilot.HeadingTarget, 0)));
                }
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }