private void PlanetListForm_Load(object sender, EventArgs e) { if (Galaxy.Current == null) { return; } // show planet counts var systems = Empire.Current.ExploredStarSystems; txtSystems.Text = systems.Count().ToString(); txtSystemsWithColonies.Text = systems.Where(s => s.FindSpaceObjects <Planet>(p => p.Owner == Empire.Current).Any()).Count().ToString(); // HACK - why are there null explored star systems? planets = systems.Where(sys => sys != null).SelectMany(sys => sys.FindSpaceObjects <Planet>()); txtPlanets.Text = planets.Count().ToString(); txtUs.Text = Empire.Current.ColonizedPlanets.Count().ToString(); var colonizable = planets.Where(p => p.Owner != Empire.Current && Empire.Current.CanColonize(p)); txtColonizable.Text = colonizable.Count().ToString(); txtEnemies.Text = colonizable.Count(p => p.Owner != null && p.Owner.IsEnemyOf(Empire.Current, p.StarSystem)).ToString(); txtAllies.Text = colonizable.Count(p => p.Owner != null && p.Owner.IsAllyOf(Empire.Current, p.StarSystem)).ToString(); txtNonAligned.Text = colonizable.Count(p => p.Owner != null && p.Owner.IsNeutralTo(Empire.Current, p.StarSystem)).ToString(); var uncolonized = colonizable.Where(p => p.Owner == null); txtUncolonized.Text = uncolonized.Count().ToString(); txtBreathableUs.Text = uncolonized.Where(p => p.Atmosphere == Empire.Current.PrimaryRace.NativeAtmosphere).Count().ToString(); var otherAtmospheres = Empire.Current.ColonizedPlanets.SelectMany(p => p.Colony.Population).Select(kvp => kvp.Key.NativeAtmosphere).Distinct().Where(a => a != Empire.Current.PrimaryRace.NativeAtmosphere).Union(Empire.Current.OwnedSpaceObjects.OfType <ICargoContainer>().SelectMany(sobj => sobj.Cargo.Population.Keys.Select(r => r.NativeAtmosphere)).Distinct()); txtBreathableOther.Text = uncolonized.Where(p => otherAtmospheres.Contains(p.Atmosphere)).Count().ToString(); // show colony ship counts colonizers = Galaxy.Current.FindSpaceObjects <SpaceVehicle>(v => v.Owner == Empire.Current && ( v.Abilities().Any(a => a.Rule.Name.StartsWith("Colonize Planet - ")) )); txtShips.Text = colonizers.Count().ToString(); availableColonizers = colonizers.Where(v => v.Orders.Count == 0 && v.StrategicSpeed > 0); txtAvailable.Text = availableColonizers.Count().ToString(); // show population and resources txtPopulation.Text = Empire.Current.ColonizedPlanets.Sum(p => p.Colony.Population.Sum(kvp => kvp.Value)).ToUnitString(true); var stored = Empire.Current.StoredResources; var income = Empire.Current.NetIncomeLessConstruction; var storage = Empire.Current.ResourceStorage; resMin.Amount = stored[Resource.Minerals]; resMin.Change = income[Resource.Minerals]; resOrg.Amount = stored[Resource.Organics]; resOrg.Change = income[Resource.Organics]; resRad.Amount = stored[Resource.Radioactives]; resRad.Change = income[Resource.Radioactives]; resRes.Amount = income[Resource.Research]; resInt.Amount = income[Resource.Intelligence]; resStorageMin.Amount = storage[Resource.Minerals]; resStorageOrg.Amount = storage[Resource.Organics]; resStorageRad.Amount = storage[Resource.Radioactives]; // show planet data grid.Data = planets.ToArray(); grid.CreateDefaultGridConfig = ClientSettings.CreateDefaultPlanetListConfig; grid.LoadCurrentGridConfig = () => ClientSettings.Instance.CurrentPlanetListConfig; grid.LoadGridConfigs = () => ClientSettings.Instance.PlanetListConfigs; grid.ResetGridConfigs = () => new List <GridConfig> { ClientSettings.CreateDefaultPlanetListConfig(), ClientSettings.CreateDefaultColonyPlanetListConfig() }; grid.Initialize(); // show galaxy view background // TODO - galaxy view background image can depend on galaxy template? galaxyView.BackgroundImage = Pictures.GetModImage(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Pictures", "UI", "Map", "quadrant")); }