diff --git a/FilterExtension/ConfigNodes/Check.cs b/FilterExtension/ConfigNodes/Check.cs index 40db6b33..d2fa698d 100644 --- a/FilterExtension/ConfigNodes/Check.cs +++ b/FilterExtension/ConfigNodes/Check.cs @@ -122,7 +122,7 @@ public bool Equals(Check c2) { if (c2 == null) return false; - if (this.type == c2.type && this.value == c2.value && this.invert == c2.invert) + if (this.type == c2.type && this.value == c2.value && this.invert == c2.invert && this.contains == c2.contains && this.checks == c2.checks) return true; else return false; @@ -130,7 +130,8 @@ public bool Equals(Check c2) public override int GetHashCode() { - return this.type.GetHashCode() * this.value.GetHashCode() * this.invert.GetHashCode(); + int checks = this.checks.Any() ? this.checks.GetHashCode() : 1; + return this.type.GetHashCode() * this.value.GetHashCode() * this.invert.GetHashCode() * this.contains.GetHashCode() * checks; } } } diff --git a/FilterExtension/Core.cs b/FilterExtension/Core.cs index 8be6e4f5..46fcd0b9 100644 --- a/FilterExtension/Core.cs +++ b/FilterExtension/Core.cs @@ -45,7 +45,7 @@ public class Core : MonoBehaviour void Awake() { instance = this; - Log("Version 1.15.2"); + Log("Version 1.16"); // Add event for when the Editor GUI becomes active. This is never removed because we need it to fire every time GameEvents.onGUIEditorToolbarReady.Add(editor); @@ -71,6 +71,7 @@ void Awake() } } + List editList = new List(); // load all subCategory configs foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("SUBCATEGORY")) { @@ -84,10 +85,13 @@ void Awake() foreach(Filter f in sC.filters) f.checks.Add(new Check("folder", folderToCategoryDict[sC.category])); } - if (checkForConflicts(sC)) + if (sC.hasFilters && checkForConflicts(sC)) subCategories.Add(sC); + if (!sC.hasFilters) + editList.Add(sC); } } + customSCEditDelete(editList); foreach (KeyValuePair kvp in categoryAllSub) { @@ -105,6 +109,35 @@ void Awake() loadIcons(); } + /// + /// creating subcategories and then trying to edit them during initialisation causes all sorts of problems. Instead, make the edits prior to initialisation + /// + /// + private void customSCEditDelete(List sCs) + { + foreach (customSubCategory sC in sCs) + { + customSubCategory sCToEdit = subCategories.FirstOrDefault(sub => sub.category == sC.category && (sub.subCategoryTitle == sC.oldTitle || sub.subCategoryTitle == sC.subCategoryTitle)); + + if (sCToEdit != null) + { + if (!string.IsNullOrEmpty(sC.subCategoryTitle)) + { + sCToEdit.subCategoryTitle = sC.subCategoryTitle; + sCToEdit.iconName = sC.iconName; + } + else + { + subCategories.Remove(sCToEdit); + } + } + else + { + subCategories.Add(sC); + } + } + } + private void associateParts() { // Build list of mod folder names and Dict associating parts with mods diff --git a/GameData/000_FilterExtensions/FilterCreator.dll b/GameData/000_FilterExtensions/FilterCreator.dll index f742eeb7..0b79fed4 100644 Binary files a/GameData/000_FilterExtensions/FilterCreator.dll and b/GameData/000_FilterExtensions/FilterCreator.dll differ diff --git a/GameData/000_FilterExtensions/FilterExtensions.dll b/GameData/000_FilterExtensions/FilterExtensions.dll index e13e0ce3..4352c8e0 100644 Binary files a/GameData/000_FilterExtensions/FilterExtensions.dll and b/GameData/000_FilterExtensions/FilterExtensions.dll differ diff --git a/GameData/000_FilterExtensions/FilterExtensions.version b/GameData/000_FilterExtensions/FilterExtensions.version index 0aafe6c3..564292e1 100644 --- a/GameData/000_FilterExtensions/FilterExtensions.version +++ b/GameData/000_FilterExtensions/FilterExtensions.version @@ -1 +1 @@ -{"NAME":"Filter Extensions","URL":"http://ksp-avc.cybutek.net/version.php?id=97","DOWNLOAD":"https://github.com/Crzyrndm/FilterExtension/releases","VERSION":{"MAJOR":1,"MINOR":15,"PATCH":2,"BUILD":0},"KSP_VERSION":{"MAJOR":0,"MINOR":90,"PATCH":0}} \ No newline at end of file +{"NAME":"Filter Extensions","URL":"http://ksp-avc.cybutek.net/version.php?id=97","DOWNLOAD":"https://github.com/Crzyrndm/FilterExtension/releases","VERSION":{"MAJOR":1,"MINOR":16,"PATCH":0,"BUILD":0},"KSP_VERSION":{"MAJOR":0,"MINOR":90,"PATCH":0}} \ No newline at end of file