convertUTtoHumanTime() public static method

Converts the UT to human-readable Kerbal local time.
public static convertUTtoHumanTime ( double UT ) : String
UT double Kerbal Spece Program Universal Time.
return String
Esempio n. 1
0
        /// <summary>
        /// Draws the Clock window.
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void drawClockWindow(int id)
        {
            Color  defaultColor = GUI.backgroundColor;
            double timeNow      = Planetarium.GetUniversalTime();
            String timeUT       = timeNow.ToString("F0");
            String timeHuman    = NodeTools.convertUTtoHumanTime(timeNow);

            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- " + NodeTools.convertUTtoHumanDuration(next);
                }
                else
                {
                    labelText = "T+ " + NodeTools.convertUTtoHumanDuration(next);
                }
                GUIParts.drawDoubleLabel("Next:", 35, labelText, 150);
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Esempio n. 2
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();
        }