Example #1
0
        /// <summary>Rebuilds list of target vessels</summary>
        /// <description>Rebuilds the list of target vessels, preserving the rest of the target list state. Does
        ///     not alter planets or special targets, call RefreshPlanets() for that.</description>
        public void Refresh()
        {
            // Clear the satellites
            RemoveVessels(mRootEntry);

            if (Antenna == null)
            {
                return;
            }

            // Add the satellites
            foreach (ISatellite s in RTCore.Instance.Network)
            {
                if (s.Guid == Antenna.Guid)
                {
                    continue;
                }

                if (s.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(s.parentVessel))
                {
                    continue;
                }

                Entry current = new Entry()
                {
                    Text  = s.Name,
                    Guid  = s.Guid,
                    Color = Color.white,
                };
                mEntries[s.Body].SubEntries.Add(current);

                if (s.Guid == Antenna.Target)
                {
                    mSelection = current;
                }
            }

            // Set a local depth variable so we can refer to it when rendering.
            Stack <Entry> dfs = new Stack <Entry>();

            foreach (Entry child in mRootEntry.SubEntries)
            {
                child.Depth = 0;
                dfs.Push(child);
            }
            while (dfs.Count > 0)
            {
                Entry current = dfs.Pop();
                foreach (Entry child in current.SubEntries)
                {
                    child.Depth = current.Depth + 1;
                    dfs.Push(child);
                }
            }
        }
Example #2
0
        private void onMapEntered()
        {
            this.pluginConfiguration.load();

            MapViewFiltering.VesselTypeFilter stateToRestore = (MapViewFiltering.VesselTypeFilter) this.pluginConfiguration.GetValue(ManeuverQueue.configurationFiltersKey, (int)MapViewFiltering.VesselTypeFilter.All);
            if (stateToRestore != MapViewFiltering.VesselTypeFilter.All)
            {
                MapViewFiltering.SetFilter(stateToRestore);
                this.pluginConfiguration.SetValue(ManeuverQueue.configurationFiltersKey, ManeuverQueue.savedFilterState);
                this.pluginConfiguration.save();
            }

            GameEvents.OnMapEntered.Remove(this.onMapEntered);
        }
Example #3
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))
                    {
                        continue;
                    }

                    String text = sat.Name.Truncate(25);
                    RTUtil.StateButton(text, mSelection == sat ? 1 : 0, 1, s =>
                    {
                        mSelection = (s > 0) ? sat : null;
                        if (mSelection != null)
                        {
                            MapObject newTarget = PlanetariumCamera.fetch.targets.FirstOrDefault(t => t != null && t.gameObject.name == sat.Name);
                            if (newTarget == 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;
                                newTarget = scaledMovement;
                                PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(newTarget));
                                PlanetariumCamera.fetch.targets.Remove(newTarget);
                            }
                            else
                            {
                                PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(newTarget));
                            }
                        }
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }
Example #4
0
        protected void SetVesselList(List <Vessel> vessels, MapViewFiltering.VesselTypeFilter filters)
        {
            if (this.spaceTrackingScene == null)
            {
                return;
            }

            this.spaceTrackingScene.GetType().GetField("trackedVessels", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this.spaceTrackingScene, vessels);

            MethodInfo clearMethod     = this.spaceTrackingScene.GetType().GetMethod("ClearUIList", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo constructMethod = this.spaceTrackingScene.GetType().GetMethod("ConstructUIList", BindingFlags.NonPublic | BindingFlags.Instance);

            clearMethod.Invoke(this.spaceTrackingScene, new object[0]);
            constructMethod.Invoke(this.spaceTrackingScene, new object[0]);

            MapViewFiltering.SetFilter(filters);

            this.ResetWidgetsForActiveVessel();
        }
        private List <DialogGUIHorizontalLayout> populateVesselRows(VesselTypeFilter filter)
        {
            List <DialogGUIHorizontalLayout> newRows    = new List <DialogGUIHorizontalLayout>();
            List <CNCCommNetVessel>          allVessels = CNCCommNetScenario.Instance.getCommNetVessels();

            switch (currentVesselSort)
            {
            case VesselListSort.RADIOFREQ:
                allVessels.Sort((x, y) => x.getStrongestFrequency() - y.getStrongestFrequency());
                break;

            case VesselListSort.VESSELNAME:
                allVessels.Sort((x, y) => x.Vessel.GetName().CompareTo(y.Vessel.GetName()));
                break;

            case VesselListSort.CBODY:
                allVessels.Sort((x, y) => x.Vessel.mainBody.name.CompareTo(y.Vessel.mainBody.name));
                break;

            default:
                allVessels.Sort((x, y) => x.Vessel.launchTime.CompareTo(y.Vessel.launchTime));
                break;
            }

            var itr = allVessels.GetEnumerator();

            while (itr.MoveNext())
            {
                CNCCommNetVessel thisVessel = itr.Current;
                if (MapViewFiltering.CheckAgainstFilter(thisVessel.Vessel))
                {
                    newRows.Add(createVesselRow(thisVessel));
                }
            }

            return(newRows);
        }
 protected void OnMapViewFiltersModified(MapViewFiltering.VesselTypeFilter filter)
 {
     if (filter == MapViewFiltering.VesselTypeFilter.None)
     {
         // Reset state of renderers
         foreach (WaypointData wpData in waypoints)
         {
             WaypointManager.RemoveWaypoint(wpData.waypoint);
             wpData.isAdded = false;
             AddWayPoint(wpData);
         }
     }
 }
Example #7
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();
        }
        protected void OnMapViewFiltersModified(MapViewFiltering.VesselTypeFilter filter)
        {
            if (filter == MapViewFiltering.VesselTypeFilter.None)
            {
                // Reset state of renderers
                foreach (OrbitData obData in orbits)
                {
                    ContractConfiguratorParameters parms = HighLogic.CurrentGame.Parameters.CustomParams<ContractConfiguratorParameters>();

                    if (contract.ContractState == Contract.State.Active && parms.DisplayActiveOrbits ||
                        contract.ContractState == Contract.State.Offered && parms.DisplayOfferedOrbits)
                    {
                        obData.SetupRenderer();
                    }
                    else
                    {
                        obData.CleanupRenderer();
                    }
                }
            }
        }