convertUTtoHumanDuration() public static method

Converts the UT to human-readable duration.
public static convertUTtoHumanDuration ( double UT ) : String
UT double Kerbal Spece Program Universal Time.
return String
Example #1
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();
        }
Example #2
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();
        }