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

            var settings = new ConfigOtherNPCs();

            try{
                using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-OtherNPCs.xml", typeof(ConfigOtherNPCs))){
                    writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigOtherNPCs>(settings));
                }
            }catch (Exception exc) {
                Logger.AddMsg("ERROR: Could Not Create Config-OtherNPCs.xml. Default Settings Will Be Used.");
            }

            return(settings);
        }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
        public string SaveSettings(ConfigOtherNPCs settings)
        {
            try{
                using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage("Config-OtherNPCs.xml", typeof(ConfigOtherNPCs))){
                    writer.Write(MyAPIGateway.Utilities.SerializeToXML <ConfigOtherNPCs>(settings));
                }

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