Ejemplo n.º 1
0
        private void saveData()
        {
            var saveMap = new Dictionary <string, List <IniPropertyMaster> >();

            saveMap[@"BioEngine.ini"] = BioEngineEntries.ToList();
            saveMap[@"BioGame.ini"]   = BioGameEntries.ToList();
            saveMap[@"BioParty.ini"]  = BioPartyEntries.ToList();
            string configFileFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\BioWare\Mass Effect\Config";

            foreach (var kp in saveMap)
            {
                string configFileBeingUpdated = Path.Combine(configFileFolder, kp.Key);
                if (File.Exists(configFileBeingUpdated))
                {
                    Log.Information(@"MEIM: Saving ini file: " + configFileBeingUpdated);

                    //unset readonly
                    File.SetAttributes(configFileBeingUpdated, File.GetAttributes(configFileBeingUpdated) & ~FileAttributes.ReadOnly);

                    DuplicatingIni ini = DuplicatingIni.LoadIni(configFileBeingUpdated);
                    foreach (IniPropertyMaster prop in kp.Value)
                    {
                        string validation = prop.Validate(@"CurrentValue");
                        if (validation == null)
                        {
                            var itemToUpdate = ini.GetValue(prop.SectionName, prop.PropertyName);
                            if (itemToUpdate != null)
                            {
                                itemToUpdate.Value = prop.ValueToWrite;
                            }
                            else
                            {
                                Log.Error($@"Could not find property to update in ini! [{prop.SectionName}] {prop.PropertyName}");
                            }
                        }
                        else
                        {
                            Log.Error($@"Could not save property {prop.FriendlyPropertyName} because {validation}");
                            M3L.ShowDialog(this, M3L.GetString(M3L.string_interp_propertyNotSaved, prop.FriendlyPropertyName, validation), M3L.GetString(M3L.string_errorSavingProperties), MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    Analytics.TrackEvent(@"Saved game config in MEIM");
                    File.WriteAllText(configFileBeingUpdated, ini.ToString());
                    ShowMessage(M3L.GetString(M3L.string_saved));
                }
            }
        }
Ejemplo n.º 2
0
        private void Reset_Click(object sender, RoutedEventArgs e)
        {
            var items = new[] { BioEngineEntries.ToList(), BioGameEntries.ToList(), BioPartyEntries.ToList() };

            foreach (var list in items)
            {
                foreach (IniPropertyMaster prop in list)
                {
                    if (prop.CanAutoReset)
                    {
                        prop.Reset();
                    }
                }
            }

            ShowMessage(M3L.GetString(M3L.string_resetIniItemsExceptBasic), 7000);
        }