Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
fixed "Engines" icon issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Jan 16, 2015
1 parent e8964da commit 254dc97
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
5 changes: 3 additions & 2 deletions FilterExtension/ConfigNodes/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ 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;
}

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;
}
}
}
37 changes: 35 additions & 2 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -71,6 +71,7 @@ void Awake()
}
}

List<customSubCategory> editList = new List<customSubCategory>();
// load all subCategory configs
foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("SUBCATEGORY"))
{
Expand All @@ -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<string, customSubCategory> kvp in categoryAllSub)
{
Expand All @@ -105,6 +109,35 @@ void Awake()
loadIcons();
}

/// <summary>
/// creating subcategories and then trying to edit them during initialisation causes all sorts of problems. Instead, make the edits prior to initialisation
/// </summary>
/// <param name="sCs"></param>
private void customSCEditDelete(List<customSubCategory> 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
Expand Down
Binary file modified GameData/000_FilterExtensions/FilterCreator.dll
Binary file not shown.
Binary file modified GameData/000_FilterExtensions/FilterExtensions.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion GameData/000_FilterExtensions/FilterExtensions.version
Original file line number Diff line number Diff line change
@@ -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}}
{"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}}

0 comments on commit 254dc97

Please sign in to comment.