Beispiel #1
0
        public void Draw()
        {
            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame);
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                foreach (VesselSatellite sat in RTCore.Instance.Satellites)
                {
                    if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel)
                    {
                        continue;
                    }

                    String text = sat.Name.Truncate(25);
                    RTUtil.StateButton(text, mSelection == sat ? 1 : 0, 1, s =>
                    {
                        mSelection = (s > 0) ? sat : null;
                        if (mSelection != null)
                        {
                            Vessel vessel = sat.SignalProcessor.Vessel;
                            ScaledMovement scaledMovement   = new GameObject().AddComponent <ScaledMovement>();
                            scaledMovement.tgtRef           = vessel.transform;
                            scaledMovement.name             = sat.Name;
                            scaledMovement.transform.parent = ScaledSpace.Instance.transform;
                            scaledMovement.vessel           = vessel;
                            scaledMovement.type             = MapObject.MapObjectType.VESSEL;

                            var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement));
                            PlanetariumCamera.fetch.targets.Remove(scaledMovement);
                            this.resetTarget();
                        }
                        else
                        {
                            // go back to the active vessel
                            PlanetariumCamera.fetch.SetTarget(this.resetTarget());
                        }
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
Beispiel #2
0
        public void Draw()
        {
            if (Satellite == null)
            {
                return;
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.TextField(Satellite.Name.Truncate(25), GUILayout.ExpandWidth(true));
                RTUtil.Button(Localizer.Format("#RT_NetworkFB_NameButton"), () =>//"Name"
                {
                    var vessel = RTUtil.GetVesselById(Satellite.Guid);
                    if (vessel)
                    {
                        vessel.RenameVessel();
                    }
                }, GUILayout.ExpandWidth(false), GUILayout.Height(24));
            }
            GUILayout.EndHorizontal();

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true));
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                foreach (var a in Satellite.Antennas.Where(a => a.CanTarget))
                {
                    GUI.contentColor = (a.Powered) ? XKCDColors.ElectricLime : XKCDColors.Scarlet;
                    String text = a.Name.Truncate(25) + Environment.NewLine + Localizer.Format("#RT_NetworkFB_Target") + RTUtil.TargetName(a.Target).Truncate(18);//"Target: "
                    RTUtil.StateButton(text, Antenna, a, s =>
                    {
                        Antenna = (s > 0) ? a : null;
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
        public void DrawInterface()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            Color      pushColor = GUI.backgroundColor;
            TextAnchor pushAlign = GUI.skin.button.alignment;

            try
            {
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                // Depth-first tree traversal.
                Stack <Entry> dfs = new Stack <Entry>();
                for (int i = 0; i < rootEntry.SubEntries.Count; i++)
                {
                    var child = rootEntry.SubEntries[i];
                    dfs.Push(child);
                }

                while (dfs.Count > 0)
                {
                    var current = dfs.Pop();
                    GUI.backgroundColor = current.Color;

                    // draw child
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24));
                        if (current.SubEntries.Count > 0)
                        {
                            RTUtil.Button(current.Expanded ? " <" : " >",
                                          () =>
                            {
                                current.Expanded = !current.Expanded;
                            },
                                          GUILayout.Width(24));
                        }

                        RTUtil.StateButton(current.Text, selectedEntry == current ? 1 : 0, 1,
                                           (s) =>
                        {
                            selectedEntry  = current;
                            Antenna.Target = selectedEntry.Guid;
                        });
                    }
                    GUILayout.EndHorizontal();

                    // draw child's grandchilden if expanded
                    if (current.Expanded)
                    {
                        for (int j = 0; j < current.SubEntries.Count; j++)
                        {
                            var child2 = current.SubEntries[j];
                            dfs.Push(child2);
                        }
                    }
                }
            }
            finally
            {
                GUILayout.EndScrollView();
                GUI.skin.button.alignment = pushAlign;
                GUI.backgroundColor       = pushColor;
            }
        }
Beispiel #4
0
        public void Draw()
        {
            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame);
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;

                var TSWList = UnityEngine.Object.FindObjectsOfType <KSP.UI.Screens.TrackingStationWidget>();

                foreach (VesselSatellite sat in RTCore.Instance.Satellites)
                {
                    if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel)
                    {
                        continue;
                    }

                    String text = sat.Name.Truncate(25);
                    RTUtil.StateButton(text, mSelection == sat.parentVessel ? 1 : 0, 1, s =>
                    {
                        mSelection = (s > 0) ? sat.parentVessel : null;
                        if (mSelection != null)
                        {
                            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                            {
                                foreach (var tsw in TSWList)
                                {
                                    if (tsw.vessel == sat.parentVessel)
                                    {
                                        tsw.toggle.isOn = true;
                                    }
                                }
                            }
                            else
                            {
                                Vessel vessel = sat.parentVessel;
                                ScaledMovement scaledMovement   = new GameObject().AddComponent <ScaledMovement>();
                                scaledMovement.tgtRef           = vessel.transform;
                                scaledMovement.name             = sat.Name;
                                scaledMovement.transform.parent = ScaledSpace.Instance.transform;
                                scaledMovement.vessel           = vessel;
                                scaledMovement.type             = MapObject.ObjectType.Vessel;

                                var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement));
                                PlanetariumCamera.fetch.targets.Remove(scaledMovement);
                                this.resetTarget();

                                if (mLastVessel != vessel)
                                {
                                    if (mLastVessel)
                                    {
                                        mLastVessel.DetachPatchedConicsSolver();
                                        mLastVessel.orbitRenderer.isFocused = false;
                                    }

                                    vessel.AttachPatchedConicsSolver();
                                    vessel.orbitRenderer.isFocused = true;
                                    vessel.orbitRenderer.drawIcons = OrbitRenderer.DrawIcons.OBJ;
                                    mLastVessel = vessel;
                                }
                            }
                        }
                        else
                        {
                            if (HighLogic.LoadedScene != GameScenes.TRACKSTATION)
                            {
                                // go back to the active vessel
                                PlanetariumCamera.fetch.SetTarget(this.resetTarget());
                            }
                        }
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
Beispiel #5
0
        public void Draw()
        {
            // Allow update for non-triggering changes (e.g., changing map view filters or changing a vessel's type)
            // This is the best way I could find to do periodic refreshes;
            //  RTCore.Instance.InvokeRepeating() would require a search for instances
            //  of AntennaFragment, and would keep running after all target windows
            //  closed. Replace with something less clunky later! -- Starstrider42
            if (++refreshCounter >= 100)
            {
                Refresh();
                refreshCounter = 0;
            }

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition);
            Color pushColor = GUI.backgroundColor;
            // starstriders changes
            //Color pushCtColor = GUI.contentColor;
            //Color pushBgColor = GUI.backgroundColor;
            TextAnchor pushAlign = GUI.skin.button.alignment;

            try {
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                // Depth-first tree traversal.
                Stack <Entry> dfs = new Stack <Entry>();
                foreach (Entry child in mRootEntry.SubEntries)
                {
                    dfs.Push(child);
                }

                // Set the inital mouseover to the selected entry
                mouseOverEntry = mSelection;

                while (dfs.Count > 0)
                {
                    Entry current = dfs.Pop();
                    GUI.backgroundColor = current.Color;

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24));
                        if (current.SubEntries.Count > 0)
                        {
                            RTUtil.Button(current.Expanded ? " <" : " >",
                                          () =>
                            {
                                current.Expanded = !current.Expanded;
                            }, GUILayout.Width(24));
                        }

                        RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1,
                                           (s) =>
                        {
                            mSelection     = current;
                            Antenna.Target = mSelection.Guid;
                        });

                        // Mouse is over the button
                        if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && triggerMouseOverListEntry)
                        {
                            // reset current entry
                            mouseOverEntry = null;
                            if (current.Text.ToLower() != "active vessel" && current.Text.ToLower() != "no target")
                            {
                                mouseOverEntry = current;
                            }
                            onMouseOverListEntry.Invoke();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (current.Expanded)
                    {
                        foreach (Entry child in current.SubEntries)
                        {
                            dfs.Push(child);
                        }
                    }
                }
            } finally {
                GUILayout.EndScrollView();
                GUI.skin.button.alignment = pushAlign;
                GUI.backgroundColor       = pushColor;
            }
        }