diff --git a/SynthEBD/Patcher/PatcherAux/UpdateHandler.cs b/SynthEBD/Patcher/PatcherAux/UpdateHandler.cs index 6b3205d2..cfb468a7 100644 --- a/SynthEBD/Patcher/PatcherAux/UpdateHandler.cs +++ b/SynthEBD/Patcher/PatcherAux/UpdateHandler.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using Mutagen.Bethesda.Plugins; using System; using System.Collections.Generic; using System.IO; @@ -39,6 +40,7 @@ public void CheckBackwardCompatibility() UpdateV1013RecordTemplates(); UpdateV1016AttributeGroups(); UpdateV1018RecordTemplates(); + UpdateV1025RaceGroupings(); } private void UpdateAssetPacks(VM_SettingsTexMesh texMeshVM) { @@ -181,6 +183,53 @@ private void UpdateV1018RecordTemplates() } } + private void UpdateV1025RaceGroupings() + { + if (!_patcherState.UpdateLog.Performed1_0_2_5RGUpdate) + { + if (CustomMessageBox.DisplayNotificationYesNo("Version 1.0.2.5 Update", "In previous SynthEBD versions, the Humanoid Playable race grouping erroneously included Elder Race. Would you like to fix this? (Recommend: Yes)")) + { + var humanoidPlayableVM = _generalVM.RaceGroupingEditor.RaceGroupings.Where(x => x.Label.Equals("Humanoid Playable", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (humanoidPlayableVM != null && (humanoidPlayableVM.Races.Contains(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRace.FormKey) || humanoidPlayableVM.Races.Contains(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRaceVampire.FormKey))) + { + + RemoveEldersFromGrouping(humanoidPlayableVM.Races); + } + + foreach (var assetPack in _texMeshVM.AssetPacks) + { + var humanoidPlayableM = assetPack.RaceGroupingEditor.RaceGroupings.Where(x => x.Label.Equals("Humanoid Playable", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (humanoidPlayableM != null) + { + RemoveEldersFromGrouping(humanoidPlayableM.Races); + } + } + + foreach (var assetPack in _patcherState.AssetPacks) + { + var humanoidPlayableM = assetPack.RaceGroupings.Where(x => x.Label.Equals("Humanoid Playable", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (humanoidPlayableM != null) + { + RemoveEldersFromGrouping(humanoidPlayableM.Races); + } + } + } + } + _patcherState.UpdateLog.Performed1_0_2_5RGUpdate = true; + } + + private void RemoveEldersFromGrouping(ICollection raceGroupingList) + { + if (raceGroupingList.Contains(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRace.FormKey)) + { + raceGroupingList.Remove(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRace.FormKey); + } + if (raceGroupingList.Contains(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRaceVampire.FormKey)) + { + raceGroupingList.Remove(Mutagen.Bethesda.FormKeys.SkyrimSE.Skyrim.Race.ElderRaceVampire.FormKey); + } + } + public Dictionary V09PathReplacements { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "Diffuse", "Diffuse.RawPath" }, @@ -212,4 +261,5 @@ public class UpdateLog public bool Performed1_0_1_3RTUpdate { get; set; } = false; public bool Performed1_0_1_6AttributeUpdate { get; set; } = false; public bool Performed1_0_1_8RTUpdate { get; set; } = false; + public bool Performed1_0_2_5RGUpdate { get; set; } = false; }