示例#1
0
        /// <summary>
        /// Draws the Conics window.
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void drawConicsWindow(int id)
        {
            PatchedConicSolver solver = NodeTools.getSolver();
            Color defaultColor        = GUI.backgroundColor;

            GUILayout.BeginVertical();

            // Conics mode controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Conics mode: ", GUILayout.Width(100));
            GUIParts.drawButton("0", (options.conicsMode == 0?Color.yellow:defaultColor), delegate() { options.setConicsMode(0); });
            GUIParts.drawButton("1", (options.conicsMode == 1?Color.yellow:defaultColor), delegate() { options.setConicsMode(1); });
            GUIParts.drawButton("2", (options.conicsMode == 2?Color.yellow:defaultColor), delegate() { options.setConicsMode(2); });
            GUIParts.drawButton("3", (options.conicsMode == 3?Color.yellow:defaultColor), delegate() { options.setConicsMode(3); });
            GUIParts.drawButton("4", (options.conicsMode == 4?Color.yellow:defaultColor), delegate() { options.setConicsMode(4); });
            GUILayout.EndHorizontal();

            // conics patch limit editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Change Conics Samples", GUILayout.Width(200));
            GUIParts.drawButton("-", Color.red, delegate() { solver.DecreasePatchLimit(); });
            GUIParts.drawButton("+", Color.red, delegate() { solver.IncreasePatchLimit(); });
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#2
0
        private void drawRadialControls(Color contentColor)
        {
            Color oldContentColor    = GUI.contentColor;
            Color oldBackgroundColor = GUI.backgroundColor;

            // radial controls
            GUILayout.BeginHorizontal();
            GUI.contentColor = RADIAL_COLOR;
            GUILayout.Label("Radial:", GUILayout.Width(100));
            if (!curState.radialParsed)
            {
                GUI.contentColor    = Color.red;
                GUI.backgroundColor = Color.red;
            }
            string check = GUILayout.TextField(curState.radialText, GUILayout.Width(70));

            GUI.contentColor    = oldContentColor;
            GUI.backgroundColor = oldBackgroundColor;
            if (!curState.radialText.Equals(check, StringComparison.Ordinal))
            {
                curState.setRadial(check);
            }
            GUI.contentColor = contentColor;
            GUIParts.drawPlusMinusButtons(() => {
                curState.addRadial(options.increment);
            }, () => {
                curState.addRadial(-options.increment);
            });
            GUILayout.EndHorizontal();
        }
示例#3
0
 /// <summary>
 /// Draws the Conics window.
 /// </summary>
 private void drawConicsWindow()
 {
     GUILayout.BeginVertical();
     GUIParts.drawConicsControls(options);
     GUILayout.EndVertical();
     GUI.DragWindow();
 }
示例#4
0
        private void drawProgradeControls(Color contentColor)
        {
            Color oldContentColor    = GUI.contentColor;
            Color oldBackgroundColor = GUI.backgroundColor;

            // Prograde controls
            GUILayout.BeginHorizontal();
            GUI.contentColor = PROGRADE_COLOR;
            GUILayout.Label("Prograde:", GUILayout.Width(100));
            if (!curState.progradeParsed)
            {
                GUI.contentColor    = Color.red;
                GUI.backgroundColor = Color.red;
            }
            string check = GUILayout.TextField(curState.progradeText, GUILayout.Width(70));

            GUI.contentColor    = oldContentColor;
            GUI.backgroundColor = oldBackgroundColor;
            if (!curState.progradeText.Equals(check, StringComparison.Ordinal))
            {
                curState.setPrograde(check);
            }
            GUIParts.drawPlusMinusButtons(() => {
                curState.addPrograde(options.increment);
            }, () => {
                curState.addPrograde(-options.increment);
            });
            GUILayout.EndHorizontal();
        }
示例#5
0
        private void drawEAngle()
        {
            // Ejection angle
            if (options.showEAngle)
            {
                String eangle = "n/a";
                if (!FlightGlobals.ActiveVessel.orbit.referenceBody.isSun())
                {
                    double angle = FlightGlobals.ActiveVessel.orbit.getEjectionAngle(curState.node);
                    if (!double.IsNaN(angle))
                    {
                        eangle = Math.Abs(angle).ToString("0.##") + "° from " + ((angle >= 0) ? "prograde" : "retrograde");
                    }
                }
                GUIParts.drawDoubleLabel("Ejection angle:", 100, eangle, 150);

                String einclination = "n/a";
                if (!FlightGlobals.ActiveVessel.orbit.referenceBody.isSun())
                {
                    double angle = FlightGlobals.ActiveVessel.orbit.getEjectionInclination(curState.node);
                    if (!double.IsNaN(angle))
                    {
                        einclination = Math.Abs(angle).ToString("0.##") + "° " + ((angle >= 0) ? "north" : "south");
                    }
                }
                GUIParts.drawDoubleLabel("Eject. inclination:", 100, einclination, 150);
            }
        }
示例#6
0
 private void drawKeyControls(string title, Key key, KeyCode currentKeyCode)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label(title + ": " + currentKeyCode.ToString(), GUILayout.Width(200));
     GUIParts.drawButton("Set", GUI.backgroundColor, () => {
         doWaitForKey("Press a key to bind " + title.ToLower() + "...", key);
     });
     GUILayout.EndHorizontal();
 }
示例#7
0
        private void drawTripWindow()
        {
            PatchedConicSolver solver = NodeTools.getSolver();

            GUILayout.BeginVertical();
            if (solver.maneuverNodes.Count < 1)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("No nodes to show.", GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }
            else
            {
                double total   = 0.0;
                double timeNow = Planetarium.GetUniversalTime();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(60));
                GUILayout.Label("Δv", GUILayout.Width(90));
                GUILayout.Label("Time Until", GUILayout.Width(200));
                GUILayout.Label("", GUILayout.Width(120));
                GUILayout.EndHorizontal();

                foreach (ManeuverNode curNode in solver.maneuverNodes)
                {
                    int    idx      = solver.maneuverNodes.IndexOf(curNode);
                    double timeDiff = curNode.UT - timeNow;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Node " + (idx + 1), GUILayout.Width(60));
                    GUILayout.Label(curNode.DeltaV.magnitude.ToString("F2") + " m/s", GUILayout.Width(90));
                    GUILayout.Label(timeDiff.convertUTtoHumanDuration(), GUILayout.Width(200));
                    if (idx > 0)
                    {
                        GUIParts.drawButton("▲ Merge", Color.white, () => {
                            // schedule for next layout pass to not mess up maneuver nodes while iterating over them
                            scheduledForLayout.Add(() => {
                                solver.maneuverNodes[idx].mergeNodeDown();
                            });
                        });
                    }
                    GUILayout.EndHorizontal();
                    total += curNode.DeltaV.magnitude;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Total", GUILayout.Width(60));
                GUILayout.Label(total.ToString("F2") + " m/s", GUILayout.Width(90));
                GUILayout.Label("", GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#8
0
 // debugging function
 private void drawEAngle()
 {
     // Ejection angle
     if (options.showEAngle)
     {
         String eangle = "n/a";
         if (FlightGlobals.ActiveVessel.orbit.referenceBody.name != "Sun")
         {
             eangle = NodeTools.getEjectionAngle(FlightGlobals.ActiveVessel.orbit, curState.currentUT()).ToString("0.##") + "°";
         }
         GUIParts.drawDoubleLabel("Ejection Angle:", 100, eangle, 130);
     }
 }
示例#9
0
        public void drawTripWindow(int id)
        {
            PatchedConicSolver solver = NodeTools.getSolver();

            GUILayout.BeginVertical();
            if (solver.maneuverNodes.Count < 1)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("No nodes to show.", GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }
            else
            {
                double total   = 0.0;
                double timeNow = Planetarium.GetUniversalTime();

                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(60));
                GUILayout.Label("Δv", GUILayout.Width(90));
                GUILayout.Label("Time Until", GUILayout.Width(200));
                GUILayout.Label("", GUILayout.Width(120));
                GUILayout.EndHorizontal();

                foreach (ManeuverNode curNode in solver.maneuverNodes)
                {
                    int    idx      = solver.maneuverNodes.IndexOf(curNode);
                    double timeDiff = curNode.UT - timeNow;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Node " + idx, GUILayout.Width(60));
                    GUILayout.Label(curNode.DeltaV.magnitude.ToString("F2") + "m/s", GUILayout.Width(90));
                    GUILayout.Label(NodeTools.convertUTtoHumanDuration(timeDiff), GUILayout.Width(200));
                    // these will be scheduled for during the next layout pass
                    if (idx > 0)
                    {
                        GUIParts.drawButton("merge ▲", Color.white, delegate() { scheduledForLayout.Add(new Action(() => { NodeTools.mergeNodeDown(solver.maneuverNodes[idx]); })); });
                    }
                    GUILayout.EndHorizontal();
                    total += curNode.DeltaV.magnitude;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label("Total", GUILayout.Width(60));
                GUILayout.Label(total.ToString("F2") + "m/s", GUILayout.Width(90));
                GUILayout.Label("", GUILayout.Width(200));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#10
0
        private void drawManeuverPager()
        {
            PatchedConicSolver solver = NodeTools.getSolver();

            int idx   = solver.maneuverNodes.IndexOf(curState.node);
            int count = solver.maneuverNodes.Count;

            GUILayout.BeginHorizontal();

            GUI.enabled = count > 1;
            if (GUILayout.Button("◀"))
            {
                if (idx > 0)
                {
                    curState.nextNode = solver.maneuverNodes[idx - 1];
                }
                else
                {
                    curState.nextNode = solver.maneuverNodes[count - 1];
                }
                curState.clearMemory();
            }
            GUI.enabled = true;
            if (GUILayout.Button("Node " + (idx + 1)))
            {
                MapView.MapCamera.SetTarget(curState.node.scaledSpaceTarget);
            }
            GUIParts.drawButton("Del", Color.red, () => {
                curState.node.RemoveSelf();
                //solver.RemoveManeuverNode(curState.node);
                curState.clearMemory();
            });
            GUI.enabled = count > 1;
            if (GUILayout.Button("▶"))
            {
                if (idx < (count - 1))
                {
                    curState.nextNode = solver.maneuverNodes[idx + 1];
                }
                else
                {
                    curState.nextNode = solver.maneuverNodes[0];
                }
                curState.clearMemory();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
        }
示例#11
0
        private void drawEncounter(Color defaultColor)
        {
            // Additional Information
            if (options.showOrbitInfo)
            {
                // Find the next encounter, if any, in our flight plan.
                if (showEncounter)
                {
                    Orbit  nextEnc = curState.node.findNextEncounter();
                    string name    = "n/a";
                    string theName = "n/a";
                    string PeA     = "n/a";

                    if (nextEnc != null)
                    {
                        name    = nextEnc.referenceBody.name;
                        theName = nextEnc.referenceBody.theName;
                        PeA     = nextEnc.PeA.formatMeters();
                    }
                    else
                    {
                        curState.encounter = false;
                    }
                    // Next encounter periapsis
                    GUIParts.drawDoubleLabel("(" + name + ") Pe:", 100, PeA, 130);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("", GUILayout.Width(100));
                    GUIParts.drawButton("Focus on " + theName, defaultColor, () => {
                        MapObject mapObject = PlanetariumCamera.fetch.targets.Find(o => (o.celestialBody != null) && (o.celestialBody.name == name));
                        MapView.MapCamera.SetTarget(mapObject);
                    });
                    GUILayout.EndHorizontal();
                }
                else
                {
                    if (curState.node.solver.flightPlan.Count > 1)
                    {
                        // output the apoapsis and periapsis of our projected orbit.
                        GUIParts.drawDoubleLabel("Apoapsis:", 100, curState.node.nextPatch.ApA.formatMeters(), 100);
                        GUIParts.drawDoubleLabel("Periapsis:", 100, curState.node.nextPatch.PeA.formatMeters(), 130);
                        GUIParts.drawDoubleLabel("Inclination:", 100, Math.Abs(curState.node.nextPatch.inclination).ToString("0.##") + "°", 150);
                    }
                }
            }
        }
示例#12
0
        // debugging function
        private void drawRadialControls(Color contentColor)
        {
            // radial controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Radial:", GUILayout.Width(100));
            if (!curState.radialParsed)
            {
                GUI.contentColor = Color.red;
            }
            string check = GUILayout.TextField(curState.radialText, GUILayout.Width(100));

            if (!curState.radialText.Equals(check, StringComparison.Ordinal))
            {
                curState.setRadial(check);
            }
            GUI.contentColor = contentColor;
            GUIParts.drawButton("-", Color.red, delegate() { curState.addRadial(options.increment * -1.0); });
            GUIParts.drawButton("+", Color.green, delegate() { curState.addRadial(options.increment); });
            GUILayout.EndHorizontal();
        }
示例#13
0
        // debugging function
        private void drawEncounter(Color defaultColor)
        {
            // Additional Information
            if (options.showOrbitInfo)
            {
                // Find the next encounter, if any, in our flight plan.
                if (showEncounter)
                {
                    Orbit  nextEnc = NodeTools.findNextEncounter(curState.node);
                    string name    = "N/A";
                    string PeA     = "N/A";

                    if (nextEnc != null)
                    {
                        name = nextEnc.referenceBody.name;
                        PeA  = NodeTools.formatMeters(nextEnc.PeA);
                    }
                    else
                    {
                        curState.encounter = false;
                    }
                    // Next encounter periapsis
                    GUIParts.drawDoubleLabel("(" + name + ") Pe:", 100, PeA, 130);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("", GUILayout.Width(100));
                    GUIParts.drawButton("Focus on " + name, defaultColor, delegate() { MapView.MapCamera.SetTarget(name); });
                    GUILayout.EndHorizontal();
                }
                else
                {
                    if (curState.node.solver.flightPlan.Count > 1)
                    {
                        // output the apoapsis and periapsis of our projected orbit.
                        GUIParts.drawDoubleLabel("Apoapsis:", 100, NodeTools.formatMeters(curState.node.nextPatch.ApA), 100);
                        GUIParts.drawDoubleLabel("Periapsis:", 100, NodeTools.formatMeters(curState.node.nextPatch.PeA), 130);
                    }
                }
            }
        }
示例#14
0
        /// <summary>
        /// Draws the Clock window.
        /// </summary>
        private void drawClockWindow()
        {
            Color  defaultColor = GUI.backgroundColor;
            double timeNow      = Planetarium.GetUniversalTime();
            String timeUT       = timeNow.ToString("F0");
            String timeHuman    = timeNow.convertUTtoHumanTime();

            GUILayout.BeginVertical();

            GUIParts.drawDoubleLabel("Time:", 35, timeHuman, 150);
            GUIParts.drawDoubleLabel("UT:", 35, Math.Floor(timeNow).ToString("F0"), 150);

            if (showTimeNext)
            {
                double next      = 0.0;
                string labelText = "";
                if (NodeTools.getSolver().maneuverNodes.Count > 0)
                {
                    // protection from index out of range errors.
                    // should probably handle this better.
                    next = timeNow - NodeTools.getSolver().maneuverNodes[0].UT;
                }
                if (next < 0)
                {
                    labelText = "T-" + next.convertUTtoHumanDuration();
                }
                else
                {
                    labelText = "T+" + next.convertUTtoHumanDuration();
                }
                GUIParts.drawDoubleLabel("Next:", 35, labelText, 150);
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#15
0
        /// <summary>
        /// Draws the Node Editor window.
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void drawMainWindow(int id)
        {
            Color defaultColor        = GUI.backgroundColor;
            Color contentColor        = GUI.contentColor;
            Color curColor            = defaultColor;
            PatchedConicSolver solver = NodeTools.getSolver();

            // Options button
            if (showOptions)
            {
                GUI.backgroundColor = Color.green;
            }
            if (GUI.Button(new Rect(options.mainWindowPos.width - 48, 2, 22, 18), "O"))
            {
                showOptions = !showOptions;
            }
            GUI.backgroundColor = defaultColor;

            // Keymapping button
            if (showKeymapper)
            {
                GUI.backgroundColor = Color.green;
            }
            if (GUI.Button(new Rect(options.mainWindowPos.width - 24, 2, 22, 18), "K"))
            {
                showKeymapper = !showKeymapper;
            }
            GUI.backgroundColor = defaultColor;

            GUILayout.BeginVertical();
            if (options.showManeuverPager)
            {
                GUIParts.drawManeuverPager(curState);
            }

            // Human-readable time
            GUIParts.drawDoubleLabel("Time:", 100, NodeTools.convertUTtoHumanTime(curState.currentUT()), 130);

            // Increment buttons
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment:", GUILayout.Width(100));
            GUIParts.drawButton("0.01", (options.increment == 0.01?Color.yellow:defaultColor), delegate() { options.increment = 0.01; });
            GUIParts.drawButton("0.1", (options.increment == 0.1?Color.yellow:defaultColor), delegate() { options.increment = 0.1; });
            GUIParts.drawButton("1", (options.increment == 1?Color.yellow:defaultColor), delegate() { options.increment = 1; });
            GUIParts.drawButton("10", (options.increment == 10?Color.yellow:defaultColor), delegate() { options.increment = 10; });
            GUIParts.drawButton("100", (options.increment == 100?Color.yellow:defaultColor), delegate() { options.increment = 100; });
            GUILayout.EndHorizontal();

            drawTimeControls(contentColor);
            drawProgradeControls(contentColor);
            drawNormalControls(contentColor);
            drawRadialControls(contentColor);

            // total delta-V display
            GUIParts.drawDoubleLabel("Total delta-V:", 100, curState.currentMagnitude().ToString("0.##") + "m/s", 130);

            drawEAngle();
            drawEncounter(defaultColor);

            // Conics mode controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Conics mode: ", GUILayout.Width(100));
            GUIParts.drawButton("0", (options.conicsMode == 0?Color.yellow:defaultColor), delegate() { options.setConicsMode(0); });
            GUIParts.drawButton("1", (options.conicsMode == 1?Color.yellow:defaultColor), delegate() { options.setConicsMode(1); });
            GUIParts.drawButton("2", (options.conicsMode == 2?Color.yellow:defaultColor), delegate() { options.setConicsMode(2); });
            GUIParts.drawButton("3", (options.conicsMode == 3?Color.yellow:defaultColor), delegate() { options.setConicsMode(3); });
            GUIParts.drawButton("4", (options.conicsMode == 4?Color.yellow:defaultColor), delegate() { options.setConicsMode(4); });
            GUILayout.EndHorizontal();

            // conics patch limit editor.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Change Conics Samples", GUILayout.Width(200));
            GUIParts.drawButton("-", Color.red, delegate() { solver.DecreasePatchLimit(); });
            GUIParts.drawButton("+", Color.red, delegate() { solver.IncreasePatchLimit(); });
            GUILayout.EndHorizontal();

            // trip info button and vessel focus buttons
            GUILayout.BeginHorizontal();
            GUIParts.drawButton("Trip Info", (options.showTrip?Color.yellow:defaultColor), delegate() { options.showTrip = !options.showTrip; });
            GUIParts.drawButton("Focus on Vessel", defaultColor, delegate() { MapView.MapCamera.SetTarget(FlightGlobals.ActiveVessel.vesselName); });
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#16
0
        // debugging function
        private void drawTimeControls(Color contentColor)
        {
            // Universal time controls
            GUILayout.BeginHorizontal();
            GUILayout.Label((options.largeUTIncrement?"UT: (10x inc)":"UT:"), GUILayout.Width(100));
            GUI.backgroundColor = Color.green;
            if (!curState.timeParsed)
            {
                GUI.contentColor = Color.red;
            }
            string check = GUILayout.TextField(curState.timeText, GUILayout.Width(100));

            if (!curState.timeText.Equals(check, StringComparison.Ordinal))
            {
                curState.setUT(check);
            }
            GUI.contentColor = contentColor;
            double ut_increment = options.increment * (options.largeUTIncrement ? 10.0 : 1.0);

            GUIParts.drawButton("-", Color.red, delegate() { curState.addUT(ut_increment * -1.0); });
            GUIParts.drawButton("+", Color.green, delegate() { curState.addUT(ut_increment); });
            GUILayout.EndHorizontal();

            // extended time controls
            if (options.showUTControls)
            {
                GUILayout.BeginHorizontal();
                GUIParts.drawButton("Peri", Color.yellow, delegate() { curState.setPeriapsis(); });
                GUIParts.drawButton("DN", Color.magenta, delegate() {
                    Orbit targ = NodeTools.getTargetOrbit();
                    if (targ != null)
                    {
                        curState.setUT(NodeTools.getTargetDNUT(curState.node.patch, targ));
                    }
                    else
                    {
                        curState.setUT(NodeTools.getEquatorialDNUT(curState.node.patch));
                    }
                });
                if (options.largeUTIncrement)
                {
                    GUIParts.drawButton("-Orb", Color.red, delegate() { curState.addUT(-curState.node.patch.period); });
                    GUIParts.drawButton("+Orb", Color.green, delegate() { curState.addUT(curState.node.patch.period); });
                }
                else
                {
                    GUIParts.drawButton("-1K", Color.red, delegate() { curState.addUT(-1000); });
                    GUIParts.drawButton("+1K", Color.green, delegate() { curState.addUT(1000); });
                }
                GUIParts.drawButton("AN", Color.cyan, delegate() {
                    Orbit targ = NodeTools.getTargetOrbit();
                    if (targ != null)
                    {
                        curState.setUT(NodeTools.getTargetANUT(curState.node.patch, targ));
                    }
                    else
                    {
                        curState.setUT(NodeTools.getEquatorialANUT(curState.node.patch));
                    }
                });
                GUIParts.drawButton("Apo", Color.blue, delegate() { curState.setApoapsis(); });
                GUILayout.EndHorizontal();
            }
        }
示例#17
0
        /// <summary>
        /// Draws the Keymapper window.
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void drawKeymapperWindow(int id)
        {
            Color defaultColor = GUI.backgroundColor;

            // Close button
            if (GUI.Button(new Rect(options.keymapperWindowPos.width - 24, 2, 22, 18), "X"))
            {
                showKeymapper = false;
            }

            GUILayout.BeginVertical();

            // Set window control
            GUILayout.BeginHorizontal();
            GUILayout.Label("Hide/Show Window: " + options.hideWindow.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Hide/Show Window...", (byte)KEYS.HIDEWINDOW); });
            GUILayout.EndHorizontal();

            // Set add node widget button
            GUILayout.BeginHorizontal();
            GUILayout.Label("Open Node Gizmo: " + options.addWidget.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Open Node Gizmo...", (byte)KEYS.ADDWIDGET); });
            GUILayout.EndHorizontal();

            // Set prograde controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment Prograde: " + options.progInc.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Increment Prograde...", (byte)KEYS.PROGINC); });
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Decrement Prograde: " + options.progDec.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Decrement Prograde...", (byte)KEYS.PROGDEC); });
            GUILayout.EndHorizontal();

            // set normal controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment Normal: " + options.normInc.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Increment Normal...", (byte)KEYS.NORMINC); });
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Decrement Normal: " + options.normDec.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Decrement Normal...", (byte)KEYS.NORMDEC); });
            GUILayout.EndHorizontal();

            // set radial controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment Radial: " + options.radiInc.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Increment Radial...", (byte)KEYS.RADIINC); });
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Decrement Radial: " + options.radiDec.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Decrement Radial...", (byte)KEYS.RADIDEC); });
            GUILayout.EndHorizontal();

            // set time controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment Time: " + options.timeInc.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Increment Time...", (byte)KEYS.TIMEINC); });
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Decrement Time: " + options.timeDec.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Decrement Time...", (byte)KEYS.TIMEDEC); });
            GUILayout.EndHorizontal();

            // set paging controls
            GUILayout.BeginHorizontal();
            GUILayout.Label("Page Increment: " + options.pageIncrement.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Page Increment...", (byte)KEYS.PAGEINC); });
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Page Conics: " + options.pageConics.ToString(), GUILayout.Width(200));
            GUIParts.drawButton("set", defaultColor, delegate() { doWaitForKey("Press a key to bind Page Conics Mode...", (byte)KEYS.PAGECON); });
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
示例#18
0
        private void drawTimeControls(Color contentColor)
        {
            // Universal time controls
            GUILayout.BeginHorizontal();
            GUILayout.Label((options.largeUTIncrement?"UT: (x10 inc)":"UT:"), GUILayout.Width(100));
            if (!curState.timeParsed)
            {
                GUI.contentColor = Color.red;
            }
            string check = GUILayout.TextField(curState.timeText, GUILayout.Width(100));

            if (!curState.timeText.Equals(check, StringComparison.Ordinal))
            {
                curState.setUT(check);
            }
            GUI.contentColor = contentColor;
            double currentUT    = curState.currentUT();
            double ut_increment = options.increment * (options.largeUTIncrement ? 10.0 : 1.0);

            GUIParts.drawPlusMinusButtons(() => { curState.addUT(ut_increment); }, () => { curState.addUT(-ut_increment); },
                                          true, curState.node.patch.isUTInsidePatch(currentUT - ut_increment));
            GUILayout.EndHorizontal();

            // extended time controls
            if (options.showUTControls)
            {
                Orbit targ = NodeTools.getTargetOrbit();

                GUILayout.BeginHorizontal();
                GUIParts.drawButton("Peri", Color.yellow, () => { curState.setPeriapsis(); });
                GUI.enabled = curState.node.hasDN(targ);
                GUIParts.drawButton("DN", Color.magenta, () => {
                    if (targ != null)
                    {
                        curState.setUT(curState.node.patch.getTargetDNUT(targ));
                    }
                    else
                    {
                        curState.setUT(curState.node.patch.getEquatorialDNUT());
                    }
                });
                if (options.largeUTIncrement)
                {
                    GUI.enabled = curState.node.patch.isUTInsidePatch(currentUT - curState.node.patch.period);
                    GUIParts.drawButton("-Orb", Color.red, () => { curState.addUT(-curState.node.patch.period); });
                    GUI.enabled = curState.node.patch.isUTInsidePatch(currentUT + curState.node.patch.period);
                    GUIParts.drawButton("+Orb", Color.green, () => { curState.addUT(curState.node.patch.period); });
                }
                else
                {
                    GUI.enabled = curState.node.patch.isUTInsidePatch(currentUT - 1000);
                    GUIParts.drawButton("-1K", Color.red, () => { curState.addUT(-1000); });
                    GUI.enabled = true;
                    GUIParts.drawButton("+1K", Color.green, () => { curState.addUT(1000); });
                }
                GUI.enabled = curState.node.hasAN(targ);
                GUIParts.drawButton("AN", Color.cyan, () => {
                    if (targ != null)
                    {
                        curState.setUT(curState.node.patch.getTargetANUT(targ));
                    }
                    else
                    {
                        curState.setUT(curState.node.patch.getEquatorialANUT());
                    }
                });
                GUI.enabled = curState.node.patch.hasAP();
                GUIParts.drawButton("Apo", Color.blue, () => { curState.setApoapsis(); });
                GUILayout.EndHorizontal();
            }

            GUI.enabled = true;
        }
示例#19
0
        /// <summary>
        /// Draws the Node Editor window.
        /// </summary>
        private void drawMainWindow()
        {
            Color defaultColor        = GUI.backgroundColor;
            Color contentColor        = GUI.contentColor;
            Color curColor            = defaultColor;
            PatchedConicSolver solver = NodeTools.getSolver();

            // Options button
            if (showOptions)
            {
                GUI.backgroundColor = Color.green;
            }
            if (GUI.Button(new Rect(options.mainWindowPos.width - 48, 2, 22, 18), "O"))
            {
                showOptions = !showOptions;
            }
            GUI.backgroundColor = defaultColor;

            // Keymapping button
            if (showKeymapper)
            {
                GUI.backgroundColor = Color.green;
            }
            if (GUI.Button(new Rect(options.mainWindowPos.width - 24, 2, 22, 18), "K"))
            {
                showKeymapper = !showKeymapper;
            }
            GUI.backgroundColor = defaultColor;

            GUILayout.BeginVertical();
            if (options.showManeuverPager)
            {
                drawManeuverPager();
            }

            // Human-readable time
            GUIParts.drawDoubleLabel("Time:", 100, curState.currentUT().convertUTtoHumanTime(), 150);

            // Increment buttons
            GUILayout.BeginHorizontal();
            GUILayout.Label("Increment:", GUILayout.Width(100));
            GUIParts.drawButton("0.01", (options.increment == 0.01?Color.yellow:defaultColor), () => { options.increment = 0.01; });
            GUIParts.drawButton("0.1", (options.increment == 0.1?Color.yellow:defaultColor), () => { options.increment = 0.1; });
            GUIParts.drawButton("1", (options.increment == 1?Color.yellow:defaultColor), () => { options.increment = 1; });
            GUIParts.drawButton("10", (options.increment == 10?Color.yellow:defaultColor), () => { options.increment = 10; });
            GUIParts.drawButton("100", (options.increment == 100?Color.yellow:defaultColor), () => { options.increment = 100; });
            GUILayout.EndHorizontal();

            drawTimeControls(contentColor);

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            drawProgradeControls(contentColor);
            drawNormalControls(contentColor);
            drawRadialControls(contentColor);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUIParts.drawButton("MS", defaultColor, () => {
                curState.memorize();
            }, GUILayout.ExpandHeight(true));
            GUI.enabled = curState.HasMemorized;
            GUIParts.drawButton("MR", defaultColor, () => {
                curState.recallMemory();
            }, GUILayout.ExpandHeight(true));
            GUI.enabled = true;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            // total delta-V display
            GUIParts.drawDoubleLabel("Total Δv:", 100, curState.currentMagnitude().ToString("0.##") + " m/s", 130);

            drawEAngle();
            drawEncounter(defaultColor);

            // Conics mode controls
            if (options.showConics)
            {
                GUIParts.drawConicsControls(options);
            }

            // trip info button and vessel focus buttons
            GUILayout.BeginHorizontal();
            GUIParts.drawButton("Trip Info", (options.showTrip?Color.yellow:defaultColor), () => { options.showTrip = !options.showTrip; });
            GUIParts.drawButton("Focus on Vessel", defaultColor, () => {
                MapObject mapObject = PlanetariumCamera.fetch.targets.Find(o => (o.vessel != null) && o.vessel.Equals(FlightGlobals.ActiveVessel));
                MapView.MapCamera.SetTarget(mapObject);
            });
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow();
        }