public void Save()
        {
            DifficultyOptionsSerializable options = new DifficultyOptionsSerializable();

            options.Difficulty = this.Difficulty;
            options.ConstructionCostMultiplier         = this.ConstructionCostMultiplier.CustomValue;
            options.ConstructionCostMultiplier_Road    = this.ConstructionCostMultiplier_Road.CustomValue;
            options.ConstructionCostMultiplier_Service = this.ConstructionCostMultiplier_Service.CustomValue;
            options.ConstructionCostMultiplier_Public  = this.ConstructionCostMultiplier_Public.CustomValue;
            options.MaintenanceCostMultiplier          = this.MaintenanceCostMultiplier.CustomValue;
            options.MaintenanceCostMultiplier_Road     = this.MaintenanceCostMultiplier_Road.CustomValue;
            options.MaintenanceCostMultiplier_Service  = this.MaintenanceCostMultiplier_Service.CustomValue;
            options.MaintenanceCostMultiplier_Public   = this.MaintenanceCostMultiplier_Public.CustomValue;
            options.RelocationCostMultiplier           = this.RelocationCostMultiplier.CustomValue;
            options.AreaCostMultiplier = this.AreaCostMultiplier.CustomValue;
            options.InitialMoney       = this.InitialMoney.CustomValue;
            options.RewardMultiplier   = this.RewardMultiplier.CustomValue;
            options.DemandOffset       = this.DemandOffset.CustomValue;
            options.DemandMultiplier   = this.DemandMultiplier.CustomValue;
            options.ResidentialTargetLandValueIndex = this.ResidentialTargetLandValue.nCustom;
            options.CommercialTargetLandValueIndex  = this.CommercialTargetLandValue.nCustom;
            options.IndustrialTargetScoreIndex      = this.IndustrialTargetScore.nCustom;
            options.OfficeTargetScoreIndex          = this.OfficeTargetScore.nCustom;
            options.PopulationTargetMultiplier      = this.PopulationTargetMultiplier.CustomValue;
            options.LoanMultiplier = this.LoanMultiplier.CustomValue;
            options.GroundPollutionRadiusMultiplier = this.GroundPollutionRadiusMultiplier.CustomValue;
            options.NoisePollutionRadiusMultiplier  = this.NoisePollutionRadiusMultiplier.CustomValue;

            options.Save();

            Modified = false;
        }
        public static DifficultyOptionsSerializable CreateFromFile()
        {
            if (!File.Exists(optionsFileName))
            {
                return(null);
            }

            XmlSerializer ser    = new XmlSerializer(typeof(DifficultyOptionsSerializable));
            TextReader    reader = new StreamReader(optionsFileName);
            DifficultyOptionsSerializable instance = (DifficultyOptionsSerializable)ser.Deserialize(reader);

            reader.Close();

            return(instance);
        }
        public void Load()
        {
            DifficultyOptionsSerializable options = DifficultyOptionsSerializable.CreateFromFile();

            if (options == null)
            {
                // Force to save if the options file does not exist yet.
                Modified = true;

                tryLoadFromOldVersion();
            }
            else
            {
                this.Difficulty = options.Difficulty;
                this.ConstructionCostMultiplier.CustomValue         = options.ConstructionCostMultiplier;
                this.ConstructionCostMultiplier_Road.CustomValue    = options.ConstructionCostMultiplier_Road;
                this.ConstructionCostMultiplier_Service.CustomValue = options.ConstructionCostMultiplier_Service;
                this.ConstructionCostMultiplier_Public.CustomValue  = options.ConstructionCostMultiplier_Public;
                this.MaintenanceCostMultiplier.CustomValue          = options.MaintenanceCostMultiplier;
                this.MaintenanceCostMultiplier_Road.CustomValue     = options.MaintenanceCostMultiplier_Road;
                this.MaintenanceCostMultiplier_Service.CustomValue  = options.MaintenanceCostMultiplier_Service;
                this.MaintenanceCostMultiplier_Public.CustomValue   = options.MaintenanceCostMultiplier_Public;
                this.RelocationCostMultiplier.CustomValue           = options.RelocationCostMultiplier;
                this.AreaCostMultiplier.CustomValue              = options.AreaCostMultiplier;
                this.InitialMoney.CustomValue                    = options.InitialMoney;
                this.RewardMultiplier.CustomValue                = options.RewardMultiplier;
                this.DemandOffset.CustomValue                    = options.DemandOffset;
                this.DemandMultiplier.CustomValue                = options.DemandMultiplier;
                this.ResidentialTargetLandValue.nCustom          = options.ResidentialTargetLandValueIndex;
                this.CommercialTargetLandValue.nCustom           = options.CommercialTargetLandValueIndex;
                this.IndustrialTargetScore.nCustom               = options.IndustrialTargetScoreIndex;
                this.OfficeTargetScore.nCustom                   = options.OfficeTargetScoreIndex;
                this.PopulationTargetMultiplier.CustomValue      = options.PopulationTargetMultiplier;
                this.LoanMultiplier.CustomValue                  = options.LoanMultiplier;
                this.GroundPollutionRadiusMultiplier.CustomValue = options.GroundPollutionRadiusMultiplier;
                this.NoisePollutionRadiusMultiplier.CustomValue  = options.NoisePollutionRadiusMultiplier;
            }
        }