void BuildStorageItems(Storage storage) { Vessel vessel = FlightGlobals.ActiveVessel; resourceSet.Clear(); resourceList.Clear(); Part rootPart = vessel.parts[0].localRoot; var manager = new RMResourceManager(vessel.parts, rootPart); GetVesselResources(manager); GetStoredResources(storage); storageItems.Clear(); storageItems.Storage = storage; storageItems.Vessel = vessel; for (int i = 0; i < resourceList.Count; i++) { var resDef = resourceList[i]; var storedResource = storage.GetResource(resDef); RMResourceInfo vesselResource; manager.masterSet.resources.TryGetValue(resDef.name, out vesselResource); storageItems.Add(new StorageItem(storage, storedResource, vesselResource)); } UIKit.UpdateListContent(storageItems); }
void SpawnGroup() { EditorGUI.instance.Close(); MapDecalEditor.Instance.Close(); EditorGUI.selectedInstance = null; GroupCenter groupCenter = new GroupCenter { RadialPosition = FlightGlobals.currentMainBody.transform.InverseTransformPoint(FlightGlobals.ActiveVessel.transform.position), Group = "NewGroup", CelestialBody = FlightGlobals.currentMainBody }; groupCenter.Spawn(); GroupEditor.selectedGroup = groupCenter; if (GroupEditor.selectedGroup == null) { Log.UserError("No Group created"); } else { Log.Normal("Group Editor spawned"); localGroups.Add(new GroupItem(groupCenter)); UIKit.UpdateListContent(localGroups); GroupEditor.instance.Open(); } }
void FindLocalGroups() { CelestialBody body = FlightGlobals.currentMainBody; Vector3 position = FlightGlobals.ActiveVessel.GetTransform().position; float range = KerbalKonstructs.localGroupRange; range *= range; localGroups.Clear(); for (int i = 0; i < StaticDatabase.allGroupCenters.Length; i++) { var groupCenter = StaticDatabase.allGroupCenters[i]; //if (groupCenter.isInSavegame || groupCenter.isBuiltIn) { // continue; //} if (groupCenter.CelestialBody == body) { Vector3 dist = position - groupCenter.gameObject.transform.position; if (dist.sqrMagnitude < range) { localGroups.Add(new GroupItem(groupCenter)); } } } UIKit.UpdateListContent(localGroups); }
void BuildFacilities() { facilityItems.Clear(); for (int i = 0, count = allFacilities.Count; i < count; i++) { var facility = allFacilities[i]; facilityItems.Add(new FacilityItem(facility)); } UIKit.UpdateListContent(facilityItems); }
void BuildLaunchsites() { launchsiteItems.Clear(); int index = 0; for (int i = 0, count = center.launchsites.Count; i < count; i++) { var site = center.launchsites[i]; if (site == selectedSite) { index = launchsiteItems.Count; } launchsiteItems.Add(new LaunchsiteItem(site)); } UIKit.UpdateListContent(launchsiteItems); launchsiteItems.Select(index); }
void UpdateSort(ModelSort sort) { modelSort = sort; switch (modelSort) { case ModelSort.Category: modelItems.Sort((a, b) => a.category.CompareTo(b.category)); break; case ModelSort.Title: modelItems.Sort((a, b) => a.title.CompareTo(b.title)); break; case ModelSort.Mesh: modelItems.Sort((a, b) => a.mesh.CompareTo(b.mesh)); break; } UIKit.UpdateListContent(modelItems); }
void BuildLaunchsites() { launchsiteItems.Clear(); int index = 0; for (int i = 0, count = LaunchSiteManager.allLaunchSites.Length; i < count; i++) { var site = LaunchSiteManager.allLaunchSites[i]; if (launchsiteFilter.showFavOnly && (site.favouriteSite != "Yes")) { continue; } if (launchsiteFilter.category != site.sitecategory && !launchsiteFilter.showAllcategorys) { continue; } if (LaunchSiteManager.CheckLaunchSiteIsValid(site) == false) { continue; } if ((!launchsiteFilter.showOpen && site.isOpen) || (!launchsiteFilter.showClosed && !site.isOpen)) { continue; } // Don't show hidden closed Bases if (site.LaunchSiteIsHidden && (!site.isOpen)) { //Log.Normal("Ignoring hidden base: " + site.LaunchSiteName); continue; } if (site == selectedSite) { index = launchsiteItems.Count; } launchsiteItems.Add(new LaunchsiteItem(site)); } UIKit.UpdateListContent(launchsiteItems); launchsiteItems.Select(index); }
void BuildMerchantItems() { merchantItems.Clear(); var merchant = merchantItems.Merchant; Part rootPart = merchantItems.Vessel.parts[0].localRoot; var manager = new RMResourceManager(merchantItems.Vessel.parts, rootPart); var vesselResources = manager.masterSet.resources; var tradedResources = merchant.Resources; for (int i = tradedResources.Count; i-- > 0;) { var resource = tradedResources[i]; RMResourceInfo vesselResource; vesselResources.TryGetValue(resource.resource.name, out vesselResource); merchantItems.Add(new MerchantItem(merchant, resource, vesselResource)); } UIKit.UpdateListContent(merchantItems); }
void BuildDecalList() { CelestialBody body = FlightGlobals.currentMainBody; Vector3 position = FlightGlobals.ActiveVessel.GetTransform().position; float range = KerbalKonstructs.localGroupRange; range *= range; decalItems.Clear(); for (int i = DecalsDatabase.allMapDecalInstances.Length; i-- > 0;) { var decal = DecalsDatabase.allMapDecalInstances[i]; if (decal.CelestialBody == body) { Vector3 dist = position - decal.mapDecal.transform.position; if (dist.sqrMagnitude < range) { decalItems.Add(new MapDecalItem(decal)); } } } UIKit.UpdateListContent(decalItems); }
void FindLocalInstances() { CelestialBody body = FlightGlobals.currentMainBody; Vector3 position = FlightGlobals.ActiveVessel.GetTransform().position; float range = KerbalKonstructs.localGroupRange; range *= range; localInstances.Clear(); for (int i = StaticDatabase.allStaticInstances.Length; i-- > 0;) { var instance = StaticDatabase.allStaticInstances[i]; if (instance.CelestialBody == body) { Vector3 dist = position - instance.position; if (dist.sqrMagnitude < range) { localInstances.Add(new InstanceItem(instance)); } } } UIKit.UpdateListContent(localInstances); }
public ListView Items(UIKit.IListObject items) { UIKit.UpdateListContent(items); return(this); }
void UpdateUI() { landingGuide.SetIsOnWithoutNotify(LandingGuideUI.instance.IsOpen()); navGuidance.SetIsOnWithoutNotify(NavGuidanceSystem.instance.IsOpen()); var Range = float.PositiveInfinity; //FIXME atmo scaling? other worlds? ... if (FlightGlobals.ActiveVessel.altitude > 75000) { center = null; noBasesBeacon.SetActive(true); noNearestBase.SetActive(false); nearestBaseGroup.SetActive(false); } else { center = StaticDatabase.GetClosestLaunchCenter();; if (center == null) { noBasesBeacon.SetActive(false); noNearestBase.SetActive(true); nearestBaseGroup.SetActive(false); } else { noBasesBeacon.SetActive(false); noNearestBase.SetActive(false); nearestBaseGroup.SetActive(true); Vector3 vPosition = FlightGlobals.ActiveVessel.GetTransform().position; ngsSite = LaunchSiteManager.getNearestBase(center, vPosition); Range = Vector3.Distance(center.gameObject.transform.position, vPosition); string info; if (Range < 10000) { info = center.Group + " at " + Range.ToString("#0.0") + " m"; } else { info = center.Group + " at " + (Range / 1000).ToString("#0.0") + " km"; } nearestBase.Info(info); bool ngs = NavGuidanceSystem.instance.IsOpen(); ngsFiller.SetActive(!ngs); setNGSTarget.SetActive(ngs); } } if (!MiscUtils.isCareerGame()) { careerGroup.SetActive(false); } else { careerGroup.SetActive(true); if (!FlightGlobals.ActiveVessel.Landed || Range > 5000) { //FIXME a bouncy landing will be laggy if (launchsiteItems.Count > 0) { launchsiteItems.Clear(); UIKit.UpdateListContent(launchsiteItems); } basesCanBeOpened.SetActive(true); openSite.SetActive(false); siteIsOpen.SetActive(false); siteCannoteBeOpened.SetActive(false); } else { basesCanBeOpened.SetActive(false); if (launchsiteItems.Count != center.launchsites.Count) { BuildLaunchsites(); } UpdateLaunchsite(); } //if (Range > 100000) //{ // if (bLanded) // { // GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); // GUILayout.Space(2); // GUILayout.Label("This feature is WIP.", LabelInfo); // GUI.enabled = false; // if (GUILayout.Button("Found a New Base", GUILayout.Height(23))) // { // foundingBase = true; // } // GUI.enabled = true; // GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); // GUILayout.Space(2); // } //} //else //{ // GUILayout.Label("This feature is WIP.", LabelInfo); //} } UpdateFaclilitiesGroup(); }