TFormat() public static method

public static TFormat ( String inputString ) : string
inputString String
return string
Esempio n. 1
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();
        }
Esempio n. 2
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;
            }
        }