public ConfigPlanetaryInstallations LoadSettings() { if (MyAPIGateway.Utilities.FileExistsInWorldStorage("Config-PlanetaryInstallations.xml", typeof(ConfigPlanetaryInstallations)) == true) { try{ ConfigPlanetaryInstallations config = null; var reader = MyAPIGateway.Utilities.ReadFileInWorldStorage("Config-PlanetaryInstallations.xml", typeof(ConfigPlanetaryInstallations)); string configcontents = reader.ReadToEnd(); config = MyAPIGateway.Utilities.SerializeFromXML <ConfigPlanetaryInstallations>(configcontents); Logger.AddMsg("Loaded Existing Settings From Config-PlanetaryInstallations.xml"); return(config); }catch (Exception exc) { Logger.AddMsg("ERROR: Could Not Load Settings From Config-PlanetaryInstallations.xml. Using Default Configuration."); var defaultSettings = new ConfigPlanetaryInstallations(); return(defaultSettings); } } var settings = new ConfigPlanetaryInstallations(); try{ using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-PlanetaryInstallations.xml", typeof(ConfigPlanetaryInstallations))){ writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigPlanetaryInstallations>(settings)); } }catch (Exception exc) { Logger.AddMsg("ERROR: Could Not Create Config-PlanetaryInstallations.xml. Default Settings Will Be Used."); } return(settings); }
public static void InitSettings() { General = General.LoadSettings(); SpaceCargoShips = SpaceCargoShips.LoadSettings(); PlanetaryCargoShips = PlanetaryCargoShips.LoadSettings(); RandomEncounters = RandomEncounters.LoadSettings(); PlanetaryInstallations = PlanetaryInstallations.LoadSettings(); BossEncounters = BossEncounters.LoadSettings(); OtherNPCs = OtherNPCs.LoadSettings(); CustomBlocks = CustomBlocks.LoadSettings(); CheckGlobalEvents(); }
public string SaveSettings(ConfigPlanetaryInstallations settings) { try{ using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-PlanetaryInstallations.xml", typeof(ConfigPlanetaryInstallations))){ writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigPlanetaryInstallations>(settings)); } Logger.AddMsg("Settings In Config-PlanetaryInstallations.xml Updated Successfully!"); return("Settings Updated Successfully."); }catch (Exception exc) { Logger.AddMsg("ERROR: Could Not Save To Config-PlanetaryInstallations.xml. Changes Will Be Lost On World Reload."); } return("Settings Changed, But Could Not Be Saved To XML. Changes May Be Lost On Session Reload."); }