public void Start() { ConfigNode[] cfgs = GameDatabase.Instance.GetConfigNodes("RESEARCHBODIES"); foreach (ConfigNode node in cfgs) { if (node.GetValue("loadAs") == "locale") { Locale l = new Locale(node); locales.Add(l); RSTLogWriter.Log("Added locale \"{0}\"", l.LocaleId); } } if (locales.Count == 0) { RSTLogWriter.Log("No locale added !"); } else { RSTLogWriter.Log("Added {0} locales", locales.Count); } RSTLogWriter.Flush(); Locales.setLocale(""); Available = true; }
public void ApplySettings() { RSTLogWriter.Log("Database ApplySettings"); if (HighLogic.CurrentGame != null) { //if (RB_SettingsParms == null) RB_SettingsParms = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>(); if (ResearchBodies.Instance != null) { ResearchBodies.Enabled = RB_SettingsParms.RBEnabled; } chances = RB_SettingsParms.DiscoverySeed; allowTSlevel1 = RB_SettingsParms.Enabledtslvl1; if (RB_SettingsParms.french) { if (Locales.currentLocale.LocaleFull != "Français") { Locales.setLocale("Français"); if (ResearchBodiesController.instance != null) { ResearchBodiesController.instance.French = true; } } } else { Locales.setLocale(""); } RSTLogWriter.debuggingOn = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>().DebugLogging; } else { RSTLogWriter.Log("Database Failed to apply settings - Fatal Error"); } }
//This is only called by the Startup Menu GUI to show ignored bodies based on the level passed in. public string GetIgnoredBodies(Level l) { Locales.setLocale(""); string _bodies = Locales.FmtLocaleString("#autoLOC_RBodies_00030") + " : "; //string _bodies = ""; List <CelestialBody> TempBodiesList = new List <CelestialBody>(); for (int i = 0; i < BodyList.Count; i++) { if (CelestialBodies[BodyList[i]].IgnoreData.GetLevel(l) && (BodyList[i].Radius > 100 || BodyList[i].name.Contains("TSTGalaxies"))) { TempBodiesList.Add(BodyList[i]); } } for (int i = 0; i < TempBodiesList.Count; i++) { _bodies += BodyList[i].displayName.LocalizeRemoveGender(); if (i < TempBodiesList.Count - 1) { _bodies += ", "; } } return(_bodies); }
public void LoadDatabase() { RSTLogWriter.Log("LoadDatabase"); //RB_SettingsParms = HighLogic.CurrentGame.Parameters.CustomParams<ResearchBodies_SettingsParms>(); Locales.setLocale(""); isTSTInstalled = Utilities.IsTSTInstalled; if (isTSTInstalled) //If TST assembly is present, initialise TST wrapper. { if (!TSTWrapper.InitTSTWrapper()) { isTSTInstalled = false; //If the initialise of wrapper failed set bool to false, we won't be interfacing to TST today. } } Textures.LoadIconAssets(); //Get a list of CBs BodyList = FlightGlobals.Bodies.ToList(); if (isTSTInstalled && TSTWrapper.APITSTReady) //If TST is installed add the TST Galaxies to the list. { BodyList = BodyList.Concat(TSTWrapper.actualTSTAPI.CBGalaxies).ToList(); } //Process Kopernicus Barycenter's. foreach (CelestialBody body in BodyList) { CelestialBodyInfo bodyinfo = new CelestialBodyInfo(body.GetName()); if (body.Radius < 100 && !body.name.Contains("TSTGalaxies")) //This body is a barycenter { bodyinfo.KOPbarycenter = true; } else { if (body.referenceBody.Radius < 100) // This Bodies Reference Body has a Radius < 100m. IE: It's Part of a Barycenter. { bodyinfo.KOPrelbarycenterBody = body.referenceBody; //Yeah so what... well we need it for pass 2 below. } } CelestialBodies.Add(body, bodyinfo); } //Now we look back through any CBs that were related to a barycenter body. foreach (var CB in CelestialBodies.Where(a => a.Value.KOPrelbarycenterBody != null)) { //So does this body have any orbitingBodies? //If it does we need to somehow find and link any related Orbit Body. foreach (CelestialBody orbitingBody in CB.Key.orbitingBodies) { CelestialBody findOrbitBody = FlightGlobals.Bodies.FirstOrDefault(a => a.name.Contains(CB.Key.name) && a.name.Contains(orbitingBody.name) && a.name.Contains("Orbit")); //so if we found the related Orbit body we store it into the CelestialBodies dictionary. if (findOrbitBody != null) { CelestialBodies[orbitingBody].KOPrelbarycenterBody = findOrbitBody; } } } //Load the database.cfg file. //=========================== ConfigNode cfg = ConfigNode.Load(Locales.PathDatabasePath); string[] sep = new string[] { " " }; Observatorylvl1Range = float.Parse(cfg.GetNode("RESEARCHBODIES").GetValue("observatorylvl1range")); Observatorylvl2Range = float.Parse(cfg.GetNode("RESEARCHBODIES").GetValue("observatorylvl2range")); AllowOldResearchinCareer = bool.Parse(cfg.GetNode("RESEARCHBODIES").GetValue("allowOldResearchinCareer")); //Get Costs string[] _startResearchCosts; _startResearchCosts = cfg.GetNode("RESEARCHBODIES").GetValue("StartResearchCosts").Split(sep, StringSplitOptions.RemoveEmptyEntries); StartResearchCosts = new int[] { int.Parse(_startResearchCosts[0]), int.Parse(_startResearchCosts[1]), int.Parse(_startResearchCosts[2]), int.Parse(_startResearchCosts[3]) }; string[] _progressResearchCosts; _progressResearchCosts = cfg.GetNode("RESEARCHBODIES").GetValue("ProgressResearchCosts").Split(sep, StringSplitOptions.RemoveEmptyEntries); ProgressResearchCosts = new int[] { int.Parse(_progressResearchCosts[0]), int.Parse(_progressResearchCosts[1]), int.Parse(_progressResearchCosts[2]), int.Parse(_progressResearchCosts[3]) }; string[] _scienceRewards; _scienceRewards = cfg.GetNode("RESEARCHBODIES").GetValue("ScienceRewards").Split(sep, StringSplitOptions.RemoveEmptyEntries); ScienceRewards = new int[] { int.Parse(_scienceRewards[0]), int.Parse(_scienceRewards[1]), int.Parse(_scienceRewards[2]), int.Parse(_scienceRewards[3]) }; RSTLogWriter.Log("Loading Priority database"); foreach (CelestialBody body in BodyList) { //Load the ondiscovery values - English only, which then get over-written in Locale.cs foreach (ConfigNode.Value value in cfg.GetNode("RESEARCHBODIES").GetNode("ONDISCOVERY").values) { if (value.name.Contains(body.bodyName)) { CelestialBodies[body].discoveryMessage = value.value; } } } //Load the IgnoreData dictionary. RSTLogWriter.Log("Loading ignore body list from database"); foreach (ConfigNode.Value value in cfg.GetNode("RESEARCHBODIES").GetNode("IGNORELEVELS").values) { foreach (CelestialBody body in BodyList) { if (body.GetName() == value.name) { string[] args; args = value.value.Split(sep, StringSplitOptions.RemoveEmptyEntries); BodyIgnoreData ignoredata = new BodyIgnoreData(bool.Parse(args[0]), bool.Parse(args[1]), bool.Parse(args[2]), bool.Parse(args[3])); CelestialBodies[body].IgnoreData = ignoredata; RSTLogWriter.Log("Body Ignore Data for {0} : {1}", body.GetName(), CelestialBodies[body].IgnoreData); } } } RSTLogWriter.Flush(); LoadModDatabaseNodes(); NothingHere.Add("#autoLOC_RBodies_00052"); NothingHere.Add("#autoLOC_RBodies_00053"); NothingHere.Add("#autoLOC_RBodies_00054"); NothingHere.Add("#autoLOC_RBodies_00055"); RSTLogWriter.Log("Chances to get a body is set to {0}", chances); RSTLogWriter.Log("Loaded gamemode-related information : enable mod in sandbox = {0}, allow tracking with Tracking station lvl 1 = {1}", enableInSandbox, allowTSlevel1); // Load locales for OnDiscovery - Locales are loaded Immediately gamescene. Before this is loaded in MainMenu. if (Locales.currentLocale.LocaleId != "en") { foreach (CelestialBody body in BodyList) { CelestialBody bodiesKey = ContainsBodiesKey(body.bodyName); if (Locales.currentLocale.Values.ContainsKey("#autoLOC_RBodies_discovery_" + body.bodyName) && bodiesKey != null) { CelestialBodies[bodiesKey].discoveryMessage = Locales.currentLocale.Values["#autoLOC_RBodies_discovery_" + body.bodyName]; } } } RSTLogWriter.Flush(); }