Exemple #1
0
        public ConfigPlanetaryCargoShips LoadSettings()
        {
            if (MyAPIGateway.Utilities.FileExistsInWorldStorage("Config-PlanetaryCargoShips.xml", typeof(ConfigPlanetaryCargoShips)) == true)
            {
                try{
                    ConfigPlanetaryCargoShips config = null;
                    var    reader         = MyAPIGateway.Utilities.ReadFileInWorldStorage("Config-PlanetaryCargoShips.xml", typeof(ConfigPlanetaryCargoShips));
                    string configcontents = reader.ReadToEnd();
                    config = MyAPIGateway.Utilities.SerializeFromXML <ConfigPlanetaryCargoShips>(configcontents);
                    Logger.AddMsg("Loaded Existing Settings From Config-PlanetaryCargoShips.xml");
                    return(config);
                }catch (Exception exc) {
                    Logger.AddMsg("ERROR: Could Not Load Settings From Config-PlanetaryCargoShips.xml. Using Default Configuration.");
                    var defaultSettings = new ConfigPlanetaryCargoShips();
                    return(defaultSettings);
                }
            }

            var settings = new ConfigPlanetaryCargoShips();

            try{
                using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-PlanetaryCargoShips.xml", typeof(ConfigPlanetaryCargoShips))){
                    writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigPlanetaryCargoShips>(settings));
                }
            }catch (Exception exc) {
                Logger.AddMsg("ERROR: Could Not Create Config-PlanetaryCargoShips.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();
 }
Exemple #3
0
        public string SaveSettings(ConfigPlanetaryCargoShips settings)
        {
            try{
                using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-PlanetaryCargoShips.xml", typeof(ConfigPlanetaryCargoShips))){
                    writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigPlanetaryCargoShips>(settings));
                }

                Logger.AddMsg("Settings In Config-PlanetaryCargoShips.xml Updated Successfully!");
                return("Settings Updated Successfully.");
            }catch (Exception exc) {
                Logger.AddMsg("ERROR: Could Not Save To Config-PlanetaryCargoShips.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.");
        }