Esempio n. 1
0
        void UpdateOtherGUI()
        {
            if (otherGUI.Count == 0)
            {
                return;
            }

            if (RTGlobals.extPack && RTGlobals.Manager != null && RTGlobals.Manager.distantLandedPartPackThreshold == 350)
            {
                RTGlobals.Manager.distantLandedPartPackThreshold   = RTGlobals.Manager.distantPartPackThreshold = 2250;
                RTGlobals.Manager.distantLandedPartUnpackThreshold = RTGlobals.Manager.distantPartUnpackThreshold = 2000;
                return;
            }


            GUIcontainer remove = null;

            foreach (GUIcontainer c in otherGUI)
            {
                if (c.gui.core.vessel.loaded && FlightGlobals.Vessels.Contains(c.gui.core.vessel) && !c.gui.core.vessel.packed && c.gui.core.InControl)
                {
                    c.gui.update();
                }
                else
                {
                    remove = c;
                }
            }
            if (remove != null)
            {
                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;
                }
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
 public bool Equals(GUIcontainer other)
 {
     return(this.gui == other.gui);
 }