Skip to content

Commit

Permalink
Added update to fix Humanoid Playable grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
Piranha91 committed Dec 1, 2023
1 parent e89da48 commit ae0a5e0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions SynthEBD/Patcher/PatcherAux/UpdateHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Mutagen.Bethesda.Plugins;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -39,6 +40,7 @@ public void CheckBackwardCompatibility()
UpdateV1013RecordTemplates();
UpdateV1016AttributeGroups();
UpdateV1018RecordTemplates();
UpdateV1025RaceGroupings();
}
private void UpdateAssetPacks(VM_SettingsTexMesh texMeshVM)
{
Expand Down Expand Up @@ -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<FormKey> 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<string, string> V09PathReplacements { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "Diffuse", "Diffuse.RawPath" },
Expand Down Expand Up @@ -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;
}

0 comments on commit ae0a5e0

Please sign in to comment.