private void LoadConfiguration() { EquipmentOverrideConfigurationV2 configuration = GlobalData.Instance.Configuration.InParameters.EquipmentOverride; if (configuration.IsStoringPossessed) { foreach (EquipmentGroupViewModel group in AllEquipments) { foreach (EquipmentViewModel equipment in group.Equipments) { equipment.IsPossessed = configuration.Items.Contains(Localization.GetDefault(equipment.Name)); } } } else { foreach (EquipmentGroupViewModel group in AllEquipments) { foreach (EquipmentViewModel equipment in group.Equipments) { equipment.IsPossessed = configuration.Items.Contains(Localization.GetDefault(equipment.Name)) == false; } } } }
public void SaveConfiguration() { int total = 0; int totalPossessed = 0; foreach (EquipmentGroupViewModel group in AllEquipments) { foreach (EquipmentViewModel equipment in group.Equipments) { total++; if (equipment.IsPossessed) { totalPossessed++; } } } EquipmentOverrideConfigurationV2 configuration = GlobalData.Instance.Configuration.InParameters.EquipmentOverride; configuration.UseOverride = rootViewModel.InParameters.UseEquipmentOverride; configuration.Items.Clear(); if (totalPossessed < (total - totalPossessed)) { // save possessed ones configuration.IsStoringPossessed = true; foreach (EquipmentGroupViewModel group in AllEquipments) { foreach (EquipmentViewModel equipment in group.Equipments.Where(x => x.IsPossessed)) { configuration.Items.Add(Localization.GetDefault(equipment.Name)); } } } else { // save not possessed ones configuration.IsStoringPossessed = false; foreach (EquipmentGroupViewModel group in AllEquipments) { foreach (EquipmentViewModel equipment in group.Equipments.Where(x => x.IsPossessed == false)) { configuration.Items.Add(Localization.GetDefault(equipment.Name)); } } } ConfigurationManager.Save(GlobalData.Instance.Configuration); }