time() public static méthode

public static time ( double t ) : string
t double
Résultat string
Exemple #1
0
        void WindowGUI(int windowID)
        {
            Color    savedColor        = GUI.color;
            Color    savedContentColor = GUI.contentColor;
            bool     CrewControl       = vessel.GetCrewCount() > 0;
            GUIStyle Alarm             = new GUIStyle(GUI.skin.label);

            Alarm.fontStyle        = FontStyle.Bold;
            Alarm.normal.textColor = Color.red;

            if (!powered)
            {
                GUI.DragWindow();

                string alarmMessage = "Out of power";
                if (AlarmTime < Time.time)
                {
                    AlarmTime = Time.time + 1;
                    alarmShow = !alarmShow;
                }
                if (alarmShow)
                {
                    alarmMessage += " !";
                }
                GUILayout.Label(alarmMessage, Alarm);
                return;
            }

            try
            {
                if (InContact)
                {
                    if (GUILayout.Button("Path length: " + RTUtils.length(path.Length) + "m, delay: " + RTUtils.time(path.ControlDelay) +
                                         (RTGlobals.AdvInfo ?
                                          "\nRelay path: " + path.ToString() :
                                          ""),
                                         GUI.skin.label, GUILayout.ExpandWidth(true)))
                    {
                        RTGlobals.AdvInfo = !RTGlobals.AdvInfo;
                    }
                }
                else
                {
                    string alarmMessage = "Out of contact";
                    if (AlarmTime < Time.time)
                    {
                        AlarmTime = Time.time + 1;
                        alarmShow = !alarmShow;
                    }
                    if (alarmShow)
                    {
                        alarmMessage += " !";
                    }
                    GUILayout.Label(alarmMessage, Alarm);
                }
            }
            catch (NullReferenceException)
            {
                RTGlobals.network = new RelayNetwork();
                path = RTGlobals.network.GetCommandPath(Rnode);
            }
            GUI.color = savedColor;

            GUILayout.BeginHorizontal();

            RTGlobals.listComsats = GUILayout.Toggle(RTGlobals.listComsats, "List comsats", GUI.skin.button, GUILayout.Height(20));


            if (!CrewControl && !(MechJeb && InContact))
            {
                GUI.contentColor = Color.red;
            }
            localControl = GUILayout.Toggle(localControl, (!CrewControl && MechJeb) ? "MechJeb Control" : "Local Control", GUI.skin.button, GUILayout.Height(20));
            if (!CrewControl && !(MechJeb && InContact))
            {
                localControl     = false;
                GUI.contentColor = savedContentColor;
            }


            RTGlobals.showPathInMapView = GUILayout.Toggle(RTGlobals.showPathInMapView, "Show path on map", GUI.skin.button, GUILayout.Height(20));

            RTGlobals.showFC = GUILayout.Toggle(RTGlobals.showFC, "Flight Computer", GUI.skin.button, GUILayout.Height(20));

            GUILayout.EndHorizontal();

            if (RTGlobals.listComsats)
            {
                if (!LCoLF)
                {
                    Thread thread = new Thread(new ThreadStart(GetCommandPath));
                    thread.Start();
                    LCoLF = true;
                }


                if (!InControl)
                {
                    GUI.contentColor = Color.red;
                }
                if (GUILayout.Button(Rnode.descript, new GUIStyle(GUI.skin.button)) && InControl)
                {
                    settings.Open(Rnode);
                }
                if (!InControl)
                {
                    GUI.contentColor = savedContentColor;
                }

                RTGlobals.comsatListScroll = GUILayout.BeginScrollView(RTGlobals.comsatListScroll, false, true);

                //compiles a list of comsat vessels that are in the current RelayNetwork, Coloring the ones in the current RelayPath green.
                if (InContact || Rnode.HasCommand)
                {
                    foreach (RelayNode node in RTGlobals.network.all)
                    {
                        if (!node.Equals(Rnode) && node.Vessel != null)
                        {
                            GUILayout.BeginHorizontal();
                            bool connection = InContactWith(node);

                            if (!connection)
                            {
                                if (GUI.contentColor != Color.red)
                                {
                                    GUI.contentColor = Color.red;
                                }
                            }
                            else
                            if (InContact && path.nodes.Contains(node))
                            {
                                if (GUI.contentColor != Color.green)
                                {
                                    GUI.contentColor = Color.green;
                                }
                            }
                            else if (GUI.contentColor != Color.white)
                            {
                                GUI.contentColor = Color.white;
                            }
                            if (GUILayout.Button(node.descript, new GUIStyle(GUI.skin.button), GUILayout.Height(50.0F)) && connection)
                            {
                                settings.Open(node);
                            }
                            if ((InContact || Rnode.HasCommand) && connection && node.Vessel.loaded && (RTGlobals.extPack ? Vector3d.Distance(vessel.transform.position, node.Vessel.transform.position) < 2000 : !node.Vessel.packed))
                            {
                                if (GUILayout.Button("Ctrl", new GUIStyle(GUI.skin.button), GUILayout.Width(50.0F), GUILayout.Height(50.0F)))
                                {
                                    bool isThere        = false;
                                    int  ATid           = this.flightComputerGUI.ATTITUDE_ID + 1,
                                         THid           = this.flightComputerGUI.THROTTLE_ID + 1;
                                    GUIcontainer remove = new GUIcontainer();
                                    foreach (GUIcontainer c in this.otherGUI)
                                    {
                                        if (c.gui == RTGlobals.coreList[node.Vessel].flightComputerGUI)
                                        {
                                            isThere = true;
                                            remove  = c;
                                            break;
                                        }
                                        ATid = c.ATTITUDE_ID + 1;
                                        THid = c.THROTTLE_ID + 1;
                                    }

                                    if (isThere)
                                    {
                                        otherGUI.Remove(remove);
                                        if (RTGlobals.extPack && otherGUI.Count == 0 && RTGlobals.Manager != null)
                                        {
                                            RTGlobals.Manager.distantLandedPartPackThreshold   = 350;
                                            RTGlobals.Manager.distantLandedPartUnpackThreshold = 200;
                                            RTGlobals.Manager.distantPartPackThreshold         = 5000;
                                            RTGlobals.Manager.distantPartUnpackThreshold       = 200;
                                        }
                                    }
                                    else
                                    {
                                        otherGUI.Add(new GUIcontainer(RTGlobals.coreList[node.Vessel].flightComputerGUI, ATid, THid));
                                    }
                                }
                            }

                            GUILayout.EndHorizontal();
                        }
                    }
                }
                else
                {
                    GUI.contentColor = Color.red;
                    foreach (RelayNode node in RTGlobals.network.all)
                    {
                        if (!node.Equals(Rnode) && node.Vessel != null)
                        {
                            GUILayout.Label(node.descript, new GUIStyle(GUI.skin.button));
                        }
                    }
                }

                GUI.color        = savedColor;
                GUI.contentColor = savedContentColor;
                GUILayout.EndScrollView();
            }

            GUI.DragWindow();
        }
Exemple #2
0
        public void draw()
        {
            GUILayout.Label((SteeringBar >= 0 ? "Right: " : "Left: ") + Math.Abs(Mathf.RoundToInt(SteeringBar * 100)) + "%", GUI.skin.textField);
            SteeringBar = GUILayout.HorizontalSlider(SteeringBar, -1, 1);

            reverse = GUILayout.Toggle(reverse, reverse ? "Reverse" : "Forward");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Speed (m/s):", GUI.skin.textField, GUILayout.Width(100));
            SpeedS = GUILayout.TextField(SpeedS, GUILayout.Width(50));
            SpeedS = RTUtils.FormatNumString(SpeedS);
            if (SpeedS == "")
            {
                SpeedS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp   += 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp   -= 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }

            Speed  = Mathf.Clamp(Convert.ToSingle(SpeedS), 0, float.MaxValue);
            SpeedS = Speed.ToString();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Drive (m):", GUI.skin.textField, GUILayout.Width(100));
            DistS = GUILayout.TextField(DistS, GUILayout.Width(50));
            DistS = RTUtils.FormatNumString(DistS);
            if (DistS == "")
            {
                DistS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp  += 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp  -= 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }

            Distance = Mathf.Clamp(Convert.ToSingle(DistS), 0, float.MaxValue);
            DistS    = Distance.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer     = false;
                r.Target    = Distance;
                r.Speed     = Speed;
                r.reverse   = reverse;
                r.Steering  = 0;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();

            GUILayout.Label("Turn (°):", GUI.skin.textField, GUILayout.Width(100));
            DegS = GUILayout.TextField(DegS, GUILayout.Width(50));
            DegS = RTUtils.FormatNumString(DegS);
            if (DegS == "")
            {
                DegS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp += 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp -= 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }

            Degrees = Mathf.Clamp(Convert.ToSingle(DegS), 0, 90);
            DegS    = Degrees.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer     = true;
                r.Target    = Degrees;
                r.Speed     = Speed;
                r.reverse   = reverse;
                r.Steering  = Mathf.RoundToInt(SteeringBar * 100) == 0 ? 0 : -SteeringBar;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Label(sending ? "Sending " + computer.arrows :
                            (computer.core.computer.roverActive ? DriveDescript : "")
                            , GUI.skin.textField);
            GUILayout.Label(sending ? RTUtils.time(lastActTime - Planetarium.GetUniversalTime()) : (computer.core.computer.roverActive ? TargetDescript : "")
                            , GUI.skin.textField, GUILayout.Width(100));
            GUILayout.EndHorizontal();
        }
Exemple #3
0
        public void draw()
        {
            GUILayout.Label("Throttle: " + Mathf.RoundToInt(ThrottleBar * 100) + "%", GUI.skin.textField);
            ThrottleBar = GUILayout.HorizontalSlider(ThrottleBar, 0, 1);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button(BT ? "Burn time (s)" : "ΔV (m/s)", GUI.skin.textField, GUILayout.Width(100)))
            {
                BT = !BT;
            }
            BTS = GUILayout.TextField(BTS, GUILayout.Width(50));
            BTS = RTUtils.FormatNumString(BTS, false);
            if (GUILayout.Button("Send", GUI.skin.textField) && (computer.core.localControl || computer.core.InContact))
            {
                ThrottleState tmp = new ThrottleState();
                tmp.Throttle = ThrottleBar;
                if (BTS.EndsWith("."))
                {
                    BTS = BTS.Substring(0, BTS.Length - 1);
                }
                tmp.Target  = Convert.ToSingle(BTS);
                tmp.Bt      = BT;
                lastActTime = tmp.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? (double)burnAt :
                                                                              (computer.core.path.ControlDelay <= (double)burnAt ? (double)burnAt : computer.core.path.ControlDelay)
                                                                              );
                states.Enqueue(tmp);
                BTS     = "";
                burnAts = "";
                burnAt  = 0;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(sending ? "Sending " + computer.arrows : (burning && state.Bt ? "Burning" : (BTS == "" ? "" : "in HH:MM:SS")), GUI.skin.textField, GUILayout.Width(100));

            if (BTS == "")
            {
                GUILayout.Label(sending ? RTUtils.time((lastActTime - Planetarium.GetUniversalTime() > 0) ? lastActTime - Planetarium.GetUniversalTime() : 0) :
                                (burning && state.Bt ? RTUtils.time((state.Target - Planetarium.GetUniversalTime() > 0) ? state.Target - Planetarium.GetUniversalTime() : 0) : "")
                                , GUI.skin.textField, GUILayout.Width(100));
            }
            else
            {
                burnAts = GUILayout.TextField(burnAts, GUILayout.Width(100));
                List <String> temp = burnAts.Split(":".ToCharArray()).ToList();
                string        seconds = "", minutes = "", hours = "", days = "";

                while (temp.Count < 4)
                {
                    temp.Insert(0, "");
                }

                seconds = RTUtils.TFormat(temp[3]);
                burnAt  = Convert.ToSingle(seconds == "" ? "0" : seconds);
                burnAts = seconds;

                if (temp[2] != "")
                {
                    minutes = RTUtils.TFormat(temp[2]);
                    burnAt += Convert.ToSingle(minutes == "" ? "0" : minutes) * 60;
                    burnAts = minutes == "" ? burnAts : (minutes + ":" + burnAts);
                }

                if (temp[1] != "")
                {
                    hours   = RTUtils.TFormat(temp[1]);
                    burnAt += Convert.ToSingle(hours == "" ? "0" : hours) * 3600;
                    burnAts = hours == "" ? burnAts : (hours + ":" + burnAts);
                }

                if (temp[0] != "")
                {
                    days    = RTUtils.TFormat(temp[0]);
                    burnAt += Convert.ToSingle(days == "" ? "0" : days) * 86400;
                    burnAts = days == "" ? burnAts : (days + ":" + burnAts);
                }
            }

            GUILayout.EndHorizontal();
        }
Exemple #4
0
        public void Draw()
        {
            bool locked = on;

            GUILayout.BeginHorizontal();

            Color savedContentColor = GUI.contentColor;

            if (state.Active)
            {
                if (mode == AttitudeMode.MANEUVERNODE)
                {
                    if (state.Active)
                    {
                        if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count > 0)
                        {
                            GUI.contentColor = Color.green;
                        }
                        else
                        {
                            GUI.contentColor = Color.yellow;
                        }
                    }
                }
                else
                if (state.Active)
                {
                    GUI.contentColor = Color.green;
                }
            }
            else
            if (mode == AttitudeMode.MANEUVERNODE && FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count == 0)
            {
                GUI.contentColor = Color.red;
            }

            on = GUILayout.Toggle(on,
                                  (RTGlobals.ColFriend && state.Active ? name + "<" : name)
                                  , GUI.skin.textField, GUILayout.Width(100));
            GUI.contentColor = savedContentColor;

            if (!(computer.core.localControl || computer.core.InContact) || (mode == AttitudeMode.MANEUVERNODE && FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count == 0 && !state.Active))
            {
                on = locked;
            }

            GUILayout.Label(sending ? computer.arrows : "", GUI.skin.textField, GUILayout.Width(50));
            if (sending)
            {
                GUILayout.Label(RTUtils.time((lastActTime - Planetarium.GetUniversalTime() > 0) ? lastActTime - Planetarium.GetUniversalTime() : 0), GUI.skin.textField, GUILayout.Width(90));
            }
            else
            {
                burnAts = GUILayout.TextField(burnAts, GUILayout.Width(90));
                List <String> temp = burnAts.Split(":".ToCharArray()).ToList();
                string        seconds = "", minutes = "", hours = "", days = "";

                while (temp.Count < 4)
                {
                    temp.Insert(0, "");
                }

                seconds = RTUtils.TFormat(temp[3]);
                burnAt  = Convert.ToSingle(seconds == "" ? "0" : seconds);
                burnAts = seconds;

                if (temp[2] != "")
                {
                    minutes = RTUtils.TFormat(temp[2]);
                    burnAt += Convert.ToSingle(minutes == "" ? "0" : minutes) * 60;
                    burnAts = minutes == "" ? burnAts : (minutes + ":" + burnAts);
                }

                if (temp[1] != "")
                {
                    hours   = RTUtils.TFormat(temp[1]);
                    burnAt += Convert.ToSingle(hours == "" ? "0" : hours) * 3600;
                    burnAts = hours == "" ? burnAts : (hours + ":" + burnAts);
                }

                if (temp[0] != "")
                {
                    days    = RTUtils.TFormat(temp[0]);
                    burnAt += Convert.ToSingle(days == "" ? "0" : days) * 86400;
                    burnAts = days == "" ? burnAts : (days + ":" + burnAts);
                }
            }
            GUILayout.EndHorizontal();

            if (mode != AttitudeMode.SURFACE || !on)
            {
                return;
            }
            GUILayout.BeginHorizontal();

            GUILayout.Label("Pitch:", GUI.skin.textField, GUILayout.Width(100));
            PITs = GUILayout.TextField(PITs, GUILayout.Width(50));
            PITs = RTUtils.FormatNumString(PITs);

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(PITs);
                tmp += 1;
                if (tmp >= 360.0F)
                {
                    tmp -= 360.0F;
                }
                PITs = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(PITs);
                tmp -= 1;
                if (tmp < 0)
                {
                    tmp += 360.0F;
                }
                PITs = Mathf.RoundToInt(tmp).ToString();
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label("Heading:", GUI.skin.textField, GUILayout.Width(100));
            HDGs = GUILayout.TextField(HDGs, GUILayout.Width(50));
            HDGs = RTUtils.FormatNumString(HDGs);

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(HDGs);
                tmp += 1;
                if (tmp >= 360.0F)
                {
                    tmp -= 360.0F;
                }
                HDGs = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(HDGs);
                tmp -= 1;
                if (tmp < 0)
                {
                    tmp += 360.0F;
                }
                HDGs = Mathf.RoundToInt(tmp).ToString();
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label("Roll:", GUI.skin.textField, GUILayout.Width(100));
            ROLs = GUILayout.TextField(ROLs, GUILayout.Width(50));
            ROLs = RTUtils.FormatNumString(ROLs);

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(ROLs);
                tmp += 1;
                if (tmp >= 360.0F)
                {
                    tmp -= 360.0F;
                }
                ROLs = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(ROLs);
                tmp -= 1;
                if (tmp < 0)
                {
                    tmp += 360.0F;
                }
                ROLs = Mathf.RoundToInt(tmp).ToString();
            }
            USEROL = GUILayout.Toggle(USEROL, " ", GUI.skin.toggle, GUILayout.Width(21.0F));

            GUILayout.EndHorizontal();
            if (GUILayout.Button("Update", GUI.skin.textField) && (computer.core.localControl || computer.core.InContact))
            {
                if (PITs.EndsWith("."))
                {
                    PITs = PITs.Substring(0, PITs.Length - 1);
                }

                if (HDGs.EndsWith("."))
                {
                    HDGs = HDGs.Substring(0, HDGs.Length - 1);
                }
                if (ROLs.EndsWith("."))
                {
                    ROLs = ROLs.Substring(0, ROLs.Length - 1);
                }

                PIT    = Convert.ToSingle(PITs);
                HDG    = Convert.ToSingle(HDGs);
                ROL    = Convert.ToSingle(ROLs);
                lastOn = false;
            }
        }