Esempio n. 1
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical(GUILayout.Width(156), GUILayout.Height(300));
            {
                selected = GUILayout.Toolbar(selected, Tabs, GUILayout.Width(160 - GUI.skin.button.margin.right * 2.0f));

                switch (selected)
                {
                case 0:
                    Target();
                    break;

                case 1:
                    HDG();
                    break;

                case 2:
                    Fine();
                    break;
                }

                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    RTUtil.Button(new GUIContent(">>", "Toggles the queue and delay functionality."),
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 2
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUIStyle guiTableRow = new GUIStyle(HighLogic.Skin.label);
                    guiTableRow.normal.textColor = Color.white;

                    RTUtil.FakeStateButton(new GUIContent("HBNT", "Ultra-low power hibernation with all active antennas shut down."), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Hibernate)), (int)mPowerMode, (int)PowerModes.Hibernate, GUILayout.Width(width3));
                    RTUtil.FakeStateButton(new GUIContent("THLD", "Optimally adaptive power-saving threshold control on all antennas"), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.AntennaSaver)), (int)mPowerMode, (int)PowerModes.AntennaSaver, GUILayout.Width(width3));
                    RTUtil.Button(new GUIContent("WAKE", "Terminate any power-saving state."), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Wake)), GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(300);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    RTUtil.Button(new GUIContent(">>", "Toggles the queue and delay functionality."),
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 3
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUIStyle guiTableRow = new GUIStyle(HighLogic.Skin.label);
                    guiTableRow.normal.textColor = Color.white;

                    RTUtil.FakeStateButton(new GUIContent("HBNT", "Ultra-low power state with activated antennas shut down."), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Hibernate)), (int)mPowerMode, (int)PowerModes.Hibernate, GUILayout.Width(width3));
                    GUILayout.Label("", new GUILayoutOption[] { GUILayout.Width(width3) });
                    RTUtil.Button(new GUIContent("WAKE", "Exit from a power-saving state."), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Wake)), GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(200);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    RTUtil.Button(new GUIContent(">>", "Toggles the queue and delay functionality."),
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 4
0
        public void Draw()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "rt_xd")
            {
                RTCore.Instance.StartCoroutine(onClickAddExtraDelay());
            }
            GUILayout.BeginVertical();
            {
                mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.Width(250));
                {
                    {
                        GUILayout.BeginHorizontal(GUI.skin.box);
                        {
                            var s = new StringBuilder();
                            foreach (var c in mFlightComputer.ActiveCommands)
                            {
                                s.Append(c.Description);
                            }
                            GUILayout.Label(s.ToString().TrimEnd(Environment.NewLine.ToCharArray()));
                            GUILayout.FlexibleSpace();
                            RTUtil.Button("x", () => RTCore.Instance.StartCoroutine(OnClickReset()), GUILayout.Width(21), GUILayout.Height(21));
                        }
                        GUILayout.EndHorizontal();

                        foreach (var c in mFlightComputer.QueuedCommands)
                        {
                            GUILayout.BeginHorizontal(GUI.skin.box);
                            {
                                GUILayout.Label(c.Description);
                                GUILayout.FlexibleSpace();
                                GUILayout.BeginVertical();
                                {
                                    RTUtil.Button("x", () => RTCore.Instance.StartCoroutine(OnClickCancel(c)), GUILayout.Width(21), GUILayout.Height(21));
                                    RTUtil.Button(new GUIContent("v", Localizer.Format("#RT_QueueFragment_Setsignaldelay", RTUtil.FormatDuration(c.Delay + c.ExtraDelay + getBurnTime(c), false))), () => RTCore.Instance.StartCoroutine(onClickAddExtraDelayFromQueuedCommand(c)), GUILayout.Width(21), GUILayout.Height(21));//string.Format("Set the signal delay right after this - Current: {0}", )
                                }
                                GUILayout.EndVertical();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
                GUILayout.EndScrollView();

                GUILayout.Label(Status);
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_QueueFragment_Signaldelay", RTUtil.FormatDuration(mFlightComputer.TotalDelay)), Localizer.Format("#RT_QueueFragment_Signaldelay_desc")));//"Delay (+ signal): "  "Total delay including signal delay."
                    GUILayout.FlexibleSpace();
                    GUI.SetNextControlName("rt_xd");
                    RTUtil.TextField(ref mExtraDelay, GUILayout.Width(45));
                    RTUtil.Button(new GUIContent(">", Localizer.Format("#RT_QueueFragment_AddExtraDelay_desc")), () => RTCore.Instance.StartCoroutine(onClickAddExtraDelay()), GUILayout.Width(21), GUILayout.Height(21));//"Add extra signal delay - Example: 125, 125s, 5m20s, 1d6h20m10s"
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 5
0
        public void Draw()
        {
            if (Satellite == null)
            {
                return;
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.TextField(Satellite.Name.Truncate(25), GUILayout.ExpandWidth(true));
                RTUtil.Button(Localizer.Format("#RT_NetworkFB_NameButton"), () =>//"Name"
                {
                    var vessel = RTUtil.GetVesselById(Satellite.Guid);
                    if (vessel)
                    {
                        vessel.RenameVessel();
                    }
                }, GUILayout.ExpandWidth(false), GUILayout.Height(24));
            }
            GUILayout.EndHorizontal();

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true));
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                foreach (var a in Satellite.Antennas.Where(a => a.CanTarget))
                {
                    GUI.contentColor = (a.Powered) ? XKCDColors.ElectricLime : XKCDColors.Scarlet;
                    String text = a.Name.Truncate(25) + Environment.NewLine + Localizer.Format("#RT_NetworkFB_Target") + RTUtil.TargetName(a.Target).Truncate(18);//"Target: "
                    RTUtil.StateButton(text, Antenna, a, s =>
                    {
                        Antenna = (s > 0) ? a : null;
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
Esempio n. 6
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical();
            {
                selectedModeIndex = GUILayout.Toolbar(selectedModeIndex, Tabs, GUILayout.Width(width3 * 3 + GUI.skin.button.margin.right * 2.0f));

                GUILayout.Space(5);

                switch (selectedModeIndex)
                {
                case (int)RoverModes.TargetMode:
                    DrawTargetContent();
                    break;

                case (int)RoverModes.HeadingMode:
                    DrawHDGContent();
                    break;

                case (int)RoverModes.FineMode:
                    DrawFineContent();
                    break;
                }

                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_RoverFragment_DRIVE"), Localizer.Format("#RT_RoverFragment_DRIVE_desc")),//"DRIVE", "Starts the automatic driving."
                                  delegate { OnExecClick(selectedModeIndex); }, GUILayout.Width(width3));
                    GUILayout.FlexibleSpace();
                    RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_RoverFragment_Queue_desc")),//"Toggles the queue and delay functionality."
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 7
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_PowerFragment_HBNT"), Localizer.Format("#RT_PowerFragment_HBNT_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Hibernate)), (int)mPowerMode, (int)PowerModes.Hibernate, GUILayout.Width(width3));       //"HBNT", "Ultra-low power hibernation with all active antennas shut down."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_PowerFragment_THLD"), Localizer.Format("#RT_PowerFragment_THLD_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.AntennaSaver)), (int)mPowerMode, (int)PowerModes.AntennaSaver, GUILayout.Width(width3)); //"THLD", "Optimally adaptive power-saving threshold control on all antennas"
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_PowerFragment_WAKE"), Localizer.Format("#RT_PowerFragment_WAKE_desc")), () => RTCore.Instance.StartCoroutine(OnPowerClick(PowerModes.Wake)), GUILayout.Width(width3));                                                                 //"WAKE", "Terminate any power-saving state."
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(200);

                GUILayout.BeginHorizontal();
                {
                    RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_PowerFragment_Queue_desc")),//"Toggles the queue and delay functionality."
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 8
0
        /// <summary>
        /// Draws the content of the window
        /// </summary>
        public override void Window(int uid)
        {
            // push the current GUI.skin
            var pushSkin = GUI.skin;

            GUI.skin = HighLogic.Skin;

            GUILayout.BeginVertical(GUILayout.Width(500), GUILayout.Height(350));
            {
                #region Draw debug menue
                // Draw the debug menue
                GUILayout.BeginHorizontal();
                {
                    // push the font size of buttons
                    var pushFontsize = GUI.skin.button.fontSize;
                    GUI.skin.button.fontSize = 11;

                    int menueItemCounter = 0;
                    foreach (string menueItem in this.debugMenueItems)
                    {
                        RTUtil.FakeStateButton(new GUIContent(menueItem), () => { this.currentDebugMenue = menueItemCounter; }, currentDebugMenue, menueItemCounter, GUILayout.Height(16));
                        menueItemCounter++;
                    }

                    // pop the saved button size back
                    GUI.skin.button.fontSize = pushFontsize;
                }
                GUILayout.EndHorizontal();
                #endregion

                #region Draw content
                contentScrollPosition = GUILayout.BeginScrollView(contentScrollPosition);
                {
                    switch (this.currentDebugMenue)
                    {
                    case 0: { this.drawRTSettingsTab(); break; }

                    case 1: { this.drawAPITester(); break; }

                    case 2: { this.drawGuidReader(); break; }

                    default: { GUILayout.Label("Item " + this.currentDebugMenue.ToString() + " not yet implemented"); break; }
                    }
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndScrollView();
                #endregion

                #region Draw debug log
                // Draw a 100 height debug-console at the bottom of the debug-window
                GUILayout.BeginVertical(GUILayout.Height(150));
                this.drawRTDebugLogEntrys();
                GUILayout.EndVertical();
                // Draw the clear log button
                // Clear Logs Button
                GUILayout.BeginHorizontal();
                {
                    var pushFontsize = GUI.skin.button.fontSize;
                    GUI.skin.button.fontSize = 12;
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_DEBUG_Clearbutton", this.currentLogLevel.ToString()), Localizer.Format("#RT_DEBUG_Clearbutton_desc")), () => RTLog.RTLogList[this.currentLogLevel].Clear());//"Clear Logs in ""tbd."
                    GUI.skin.button.fontSize = pushFontsize;
                }
                GUILayout.EndHorizontal();
                #endregion
            }
            GUILayout.EndVertical();

            base.Window(uid);

            // pop back the saved skin
            GUI.skin = pushSkin;
        }
        public void DrawInterface()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            Color      pushColor = GUI.backgroundColor;
            TextAnchor pushAlign = GUI.skin.button.alignment;

            try
            {
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                // Depth-first tree traversal.
                Stack <Entry> dfs = new Stack <Entry>();
                for (int i = 0; i < rootEntry.SubEntries.Count; i++)
                {
                    var child = rootEntry.SubEntries[i];
                    dfs.Push(child);
                }

                while (dfs.Count > 0)
                {
                    var current = dfs.Pop();
                    GUI.backgroundColor = current.Color;

                    // draw child
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24));
                        if (current.SubEntries.Count > 0)
                        {
                            RTUtil.Button(current.Expanded ? " <" : " >",
                                          () =>
                            {
                                current.Expanded = !current.Expanded;
                            },
                                          GUILayout.Width(24));
                        }

                        RTUtil.StateButton(current.Text, selectedEntry == current ? 1 : 0, 1,
                                           (s) =>
                        {
                            selectedEntry  = current;
                            Antenna.Target = selectedEntry.Guid;
                        });
                    }
                    GUILayout.EndHorizontal();

                    // draw child's grandchilden if expanded
                    if (current.Expanded)
                    {
                        for (int j = 0; j < current.SubEntries.Count; j++)
                        {
                            var child2 = current.SubEntries[j];
                            dfs.Push(child2);
                        }
                    }
                }
            }
            finally
            {
                GUILayout.EndScrollView();
                GUI.skin.button.alignment = pushAlign;
                GUI.backgroundColor       = pushColor;
            }
        }
Esempio n. 10
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            if (Event.current.Equals(Event.KeyboardEvent("return")))
            {
                if (GUI.GetNameOfFocusedControl().StartsWith("rt_phr"))
                {
                    mPitch   = Pitch.ToString();
                    mHeading = Heading.ToString();
                    mRoll    = Roll.ToString();
                    if (mFlightComputer.InputAllowed)
                    {
                        mMode = ComputerMode.Custom;
                        Confirm();
                    }
                }
                else if (GUI.GetNameOfFocusedControl() == "rt_burn")
                {
                    OnBurnClick();
                }
            }
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_KILL"), Localizer.Format("#RT_AttitudeFragment_KILL_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Kill)), (int)mMode, (int)ComputerMode.Kill, GUILayout.Width(width3));           //"KILL", "Kill rotation."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NODE"), Localizer.Format("#RT_AttitudeFragment_NODE_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Node)), (int)mMode, (int)ComputerMode.Node, GUILayout.Width(width3));           //"NODE", "Prograde points in the direction of the first maneuver node."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RVEL"), Localizer.Format("#RT_AttitudeFragment_RVEL_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.TargetVel)), (int)mMode, (int)ComputerMode.TargetVel, GUILayout.Width(width3)); //"RVEL", "Prograde relative to target velocity."
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_ORB"), Localizer.Format("#RT_AttitudeFragment_ORB_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Orbital)), (int)mMode, (int)ComputerMode.Orbital, GUILayout.Width(width3));     //"ORB", "Prograde relative to orbital velocity."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_SRF"), Localizer.Format("#RT_AttitudeFragment_SRF_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Surface)), (int)mMode, (int)ComputerMode.Surface, GUILayout.Width(width3));     //"SRF", "Prograde relative to surface velocity."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_TGT"), Localizer.Format("#RT_AttitudeFragment_TGT_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.TargetPos)), (int)mMode, (int)ComputerMode.TargetPos, GUILayout.Width(width3)); //"TGT", "Prograde points directly at target."
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_OFF"), Localizer.Format("#RT_AttitudeFragment_OFF_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Off)), (int)mMode, (int)ComputerMode.Off, GUILayout.Width(width3));                 //"OFF", "Set Attitude to Off."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_CUSTOM"), Localizer.Format("#RT_AttitudeFragment_CUSTOM_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Custom)), (int)mMode, (int)ComputerMode.Custom, GUILayout.ExpandWidth(true)); //"CUSTOM", "Prograde fixed as pitch, heading, roll relative to north pole."
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_Prograde"), Localizer.Format("#RT_AttitudeFragment_Prograde_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.Prograde)), (int)mAttitude, (int)FlightAttitude.Prograde, GUILayout.Width(width3));         //"GRD\n+", "Orient to Prograde."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RadialPlus"), Localizer.Format("#RT_AttitudeFragment_RadialPlus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.RadialPlus)), (int)mAttitude, (int)FlightAttitude.RadialPlus, GUILayout.Width(width3)); //"RAD\n+", "Orient to Radial."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NormalPlus"), Localizer.Format("#RT_AttitudeFragment_NormalPlus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.NormalPlus)), (int)mAttitude, (int)FlightAttitude.NormalPlus, GUILayout.Width(width3)); //"NRM\n+", "Orient to Normal."
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_Retrograde"), Localizer.Format("#RT_AttitudeFragment_Retrograde_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.Retrograde)), (int)mAttitude, (int)FlightAttitude.Retrograde, GUILayout.Width(width3));     //"GRD\n-", "Orient to Retrograde."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RadialMinus"), Localizer.Format("#RT_AttitudeFragment_RadialMinus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.RadialMinus)), (int)mAttitude, (int)FlightAttitude.RadialMinus, GUILayout.Width(width3)); //"RAD\n-", "Orient to Anti-radial."
                    RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NormalMinus"), Localizer.Format("#RT_AttitudeFragment_NormalMinus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.NormalMinus)), (int)mAttitude, (int)FlightAttitude.NormalMinus, GUILayout.Width(width3)); //"NRM\n-", "Orient to Anti-normal."
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_PIT"), Localizer.Format("#RT_AttitudeFragment_PIT_desc")), GUILayout.Width(width3));//"PIT:", "Sets pitch."
                    RTUtil.RepeatButton("+", () => { Pitch++; });
                    RTUtil.RepeatButton("-", () => { Pitch--; });
                    RTUtil.MouseWheelTriggerField(ref mPitch, "rt_phr1", () => { Pitch++; }, () => { Pitch--; }, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_HDG"), Localizer.Format("#RT_AttitudeFragment_HDG_desc")), GUILayout.Width(width3));//"HDG:", "Sets heading."
                    RTUtil.RepeatButton("+", () => { Heading++; });
                    RTUtil.RepeatButton("-", () => { Heading--; });
                    RTUtil.MouseWheelTriggerField(ref mHeading, "rt_phr2", () => { Heading++; }, () => { Heading--; }, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RLL"), Localizer.Format("#RT_AttitudeFragment_RLL_desc")), GUILayout.Width(width3));//"RLL:", "Sets roll."
                    RTUtil.RepeatButton("+", () => { Roll++; });
                    RTUtil.RepeatButton("-", () => { Roll--; });
                    RTUtil.MouseWheelTriggerField(ref mRoll, "rt_phr3", () => { Roll++; }, () => { Roll--; }, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(Localizer.Format("#RT_AttitudeFragment_Throttle"));//"Throttle: "
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(mThrottle.ToString("P"));
                }
                GUILayout.EndHorizontal();

                RTUtil.HorizontalSlider(ref mThrottle, 0, 1);
                GUI.SetNextControlName("rt_burn");
                RTUtil.TextField(ref mDuration);

                GUILayout.BeginHorizontal();
                {
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_AttitudeFragment_BURN"), Localizer.Format("#RT_AttitudeFragment_BURN_desc")), //"BURN", "Example: 125, 125s, 5m20s, 1d6h20m10s, 123m/s."
                                  OnBurnClick, GUILayout.Width(width3));
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_AttitudeFragment_EXEC"), Localizer.Format("#RT_AttitudeFragment_EXEC_desc")), //"EXEC", "Executes next and subsequent maneuver nodes."
                                  OnExecClick, GUILayout.Width(width3));
                    RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_AttitudeFragment_Queue_desc")),                                         //"Toggles the queue and delay functionality."
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 11
0
        public void Draw()
        {
            float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;

            GUILayout.BeginVertical();
            {
                Vector3 Torque = SteeringHelper.TorqueAvailable;
                var     MoI    = mFlightComputer.Vessel.MOI;

                ////////////////
                //PITCH INFO
                ////////////////
                GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Pitch") + "</b>"));//"Pitch"
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent((Torque[0] / MoI[0]).ToString("F3")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[0].ToString("F2")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.pitch.ToString("F2")));
                }
                GUILayout.EndHorizontal();

                ////////////////
                //ROLL INFO
                ////////////////
                GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Roll") + "</b>"));//"Roll"
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent((Torque[1] / MoI[1]).ToString("F3")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[1].ToString("F2")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.roll.ToString("F2")));
                }
                GUILayout.EndHorizontal();

                ////////////////
                //YAW INFO
                ////////////////
                GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Yaw") + "</b>"));//"Yaw"
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent((Torque[2] / MoI[2]).ToString("F3")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[2].ToString("F2")));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State"
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.yaw.ToString("F2")));
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(10);
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_PIDHelp")));//"See ni.com/white-paper/3782/en"

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Kp"), Localizer.Format("#RT_PIDControllerFragment_Kp_desc")));//"Proportional gain", "(1) With I and D terms set to 0, increase until the output of the loop oscillates."
                    RTUtil.TextField(ref kp, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Ki"), Localizer.Format("#RT_PIDControllerFragment_Ki_desc")));//"Integral", "(2) Increase to stop the oscillations."
                    RTUtil.TextField(ref ki, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Kd"), Localizer.Format("#RT_PIDControllerFragment_Kd_desc")));//"Derivative", "(3) Increase until the loop is acceptably quick to its target point."
                    RTUtil.TextField(ref kd, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_button1"), Localizer.Format("#RT_PIDControllerFragment_button1_desc")), //"SAVE", "Save all values persistently."
                                  OnSaveClick, GUILayout.Width(width3));
                    RTUtil.Button(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_button2"), Localizer.Format("#RT_PIDControllerFragment_button2_desc")), //"APLY", "Interface all values to Flight PID Controller."
                                  () => RTCore.Instance.StartCoroutine(OnApplyClick()), GUILayout.Width(width3));
                    RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_PIDControllerFragment_Queue_desc")),                                                    //"Toggles the queue and delay functionality."
                                  mOnClickQueue, GUILayout.Width(width3));
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
Esempio n. 12
0
        public void Draw()
        {
            // Allow update for non-triggering changes (e.g., changing map view filters or changing a vessel's type)
            // This is the best way I could find to do periodic refreshes;
            //  RTCore.Instance.InvokeRepeating() would require a search for instances
            //  of AntennaFragment, and would keep running after all target windows
            //  closed. Replace with something less clunky later! -- Starstrider42
            if (++refreshCounter >= 100)
            {
                Refresh();
                refreshCounter = 0;
            }

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition);
            Color pushColor = GUI.backgroundColor;
            // starstriders changes
            //Color pushCtColor = GUI.contentColor;
            //Color pushBgColor = GUI.backgroundColor;
            TextAnchor pushAlign = GUI.skin.button.alignment;

            try {
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                // Depth-first tree traversal.
                Stack <Entry> dfs = new Stack <Entry>();
                foreach (Entry child in mRootEntry.SubEntries)
                {
                    dfs.Push(child);
                }

                // Set the inital mouseover to the selected entry
                mouseOverEntry = mSelection;

                while (dfs.Count > 0)
                {
                    Entry current = dfs.Pop();
                    GUI.backgroundColor = current.Color;

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24));
                        if (current.SubEntries.Count > 0)
                        {
                            RTUtil.Button(current.Expanded ? " <" : " >",
                                          () =>
                            {
                                current.Expanded = !current.Expanded;
                            }, GUILayout.Width(24));
                        }

                        RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1,
                                           (s) =>
                        {
                            mSelection     = current;
                            Antenna.Target = mSelection.Guid;
                        });

                        // Mouse is over the button
                        if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && triggerMouseOverListEntry)
                        {
                            // reset current entry
                            mouseOverEntry = null;
                            if (current.Text.ToLower() != "active vessel" && current.Text.ToLower() != "no target")
                            {
                                mouseOverEntry = current;
                            }
                            onMouseOverListEntry.Invoke();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (current.Expanded)
                    {
                        foreach (Entry child in current.SubEntries)
                        {
                            dfs.Push(child);
                        }
                    }
                }
            } finally {
                GUILayout.EndScrollView();
                GUI.skin.button.alignment = pushAlign;
                GUI.backgroundColor       = pushColor;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Draws the content of the window
        /// </summary>
        public override void Window(int uid)
        {
            // push the current GUI.skin
            var pushSkin = GUI.skin;

            GUI.skin = HighLogic.Skin;

            GUILayout.BeginVertical(GUILayout.Width(500), GUILayout.Height(350));
            {
                #region Draw debug menue
                // Draw the debug menue
                GUILayout.BeginHorizontal();
                {
                    // push the font size of buttons
                    var pushFontsize = GUI.skin.button.fontSize;
                    GUI.skin.button.fontSize = 11;

                    int menueItemCounter = 0;
                    foreach (string menueItem in this.debugMenueItems)
                    {
                        RTUtil.FakeStateButton(new GUIContent(menueItem), () => { this.currentDebugMenue = menueItemCounter; }, currentDebugMenue, menueItemCounter, GUILayout.Height(16));
                        menueItemCounter++;
                    }

                    // pop the saved button size back
                    GUI.skin.button.fontSize = pushFontsize;
                }
                GUILayout.EndHorizontal();
                #endregion

                #region Draw content
                contentScrollPosition = GUILayout.BeginScrollView(contentScrollPosition);
                {
                    switch (this.currentDebugMenue)
                    {
                    case 0: { this.drawRTSettingsTab(); break; }

                    case 1: { this.drawAPITester(); break; }

                    case 2: { this.drawGuidReader(); break; }

                    default: { GUILayout.Label("Item " + this.currentDebugMenue.ToString() + " not yet implemented"); break; }
                    }
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndScrollView();
                #endregion

                #region Draw debug log
                // Draw a 100 height debug-console at the bottom of the debug-window
                GUILayout.BeginVertical(GUILayout.Height(150));
                this.drawRTDebugLogEntrys();
                GUILayout.EndVertical();
                // Draw the clear log button
                // Clear Logs Button
                GUILayout.BeginHorizontal();
                {
                    var pushFontsize = GUI.skin.button.fontSize;
                    GUI.skin.button.fontSize = 12;
                    RTUtil.Button(new GUIContent("Clear Logs in " + this.currentLogLevel.ToString(), "tbd."), () => RTLog.RTLogList[this.currentLogLevel].Clear());
                    GUI.skin.button.fontSize = pushFontsize;
                }
                GUILayout.EndHorizontal();
                #endregion
            }
            GUILayout.EndVertical();

            // Set a control lock that we can scroll through textareas
            InputLockManager.RemoveControlLock("RTLockDebug");
            if (this.backupPosition.ContainsMouse())
            {
                InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS, "RTLockDebug");
            }

            base.Window(uid);

            // pop back the saved skin
            GUI.skin = pushSkin;
        }