Ejemplo n.º 1
0
 public ConfigFile(Version sv, FissionValues fs, Dictionary <string, FuelValues> f, Dictionary <string, CoolerValues> c, CraftingMaterials cm)
 {
     saveVersion   = sv;
     Fission       = fs;
     Fuels         = f;
     Coolers       = c;
     ResourceCosts = cm;
 }
Ejemplo n.º 2
0
        public static bool Load(FileInfo file)
        {
            configFileInfo = file;
            ConfigFile cf;

            using (StreamReader sr = File.OpenText(file.FullName))
            {
                JsonSerializer jss = new JsonSerializer();
                try
                {
                    cf = (ConfigFile)jss.Deserialize(sr, typeof(ConfigFile));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message + "\r\nConfig file was corrupt!");
                    return(false);
                }
            }
            if ((cf.Fuels == null) | (cf.Coolers == null))
            {
                System.Windows.Forms.MessageBox.Show("Invalid config file contents!");
                return(false);
            }

            if (cf.saveVersion <= new Version(1, 2, 3))
            {
                var fuelvalue = cf.Fuels["HELP-239  Oxide"];
                cf.Fuels.Remove("HELP-239  Oxide");
                cf.Fuels.Add("HEP-239 Oxide", fuelvalue);
            }

            if (cf.saveVersion < new Version(1, 2, 22))
            {
                System.Windows.Forms.MessageBox.Show("There have been changes to cooler descriptions, that required a config reset.\r" +
                                                     "Re-import nuclearcraft.cfg and overwrite your DefaultConfig.json if necessary!");
                return(false);
            }

            Fission = cf.Fission;
            if (cf.saveVersion < new Version(1, 2, 14))
            {
                Fission.ActiveCoolerMaxRate = 5;
            }
            //ResourceCosts = cf.ResourceCosts;
            //if (ResourceCosts.CasingCosts == null)
            //    SetDefaultResourceCosts();
            Fuels   = cf.Fuels;
            Coolers = cf.Coolers;
            Reactor.ReloadValuesFromConfig();
            return(true);
        }