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

Commit

Permalink
filter based on tech "unresearchable"
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Oct 14, 2016
1 parent 0bb0970 commit f9d58d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 43 deletions.
9 changes: 9 additions & 0 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ private void getConfigs()
private void getPartData()
{
List<string> modNames = new List<string>();
Editor.blackListedParts = new HashSet<string>();

foreach (AvailablePart p in PartLoader.LoadedPartsList)
{
if (p == null)
continue;
if (string.Equals(p.TechRequired, "Unresearchable", StringComparison.OrdinalIgnoreCase))
{
Log(p.name);
Editor.blackListedParts.Add(p.name);
continue;
}

if (string.IsNullOrEmpty(p.partUrl))
RepairAvailablePartUrl(p);
Expand All @@ -135,7 +142,9 @@ private void getPartData()

// associate the path to the part
if (!partPathDict.ContainsKey(p.name))
{
partPathDict.Add(p.name, p.partUrl);
}
else
Log(p.name + " duplicated part key in part path dictionary", LogLevel.Warn);

Expand Down
43 changes: 0 additions & 43 deletions FilterExtension/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ private IEnumerator editorInit()
if (HighLogic.CurrentGame.Parameters.CustomParams<FESettings>().debug)
Core.Log("Starting on late categories", Core.LogLevel.Log);

// generate the set of parts to block
if (blackListedParts == null)
{
findPartsToBlock();
}

// this is to be used for altering subcategories in a category added by another mod
foreach (customCategory c in Core.Instance.Categories)
{
Expand Down Expand Up @@ -176,43 +170,6 @@ public static void setSelectedCategory()
}
}

private void findPartsToBlock()
{
blackListedParts = new HashSet<string>();

// Only checking the category which should be Filter by Function (should I find FbF explicitly?)
PartCategorizer.Category mainCat = PartCategorizer.Instance.filters[0];

foreach (AvailablePart part in PartLoader.LoadedPartsList)
{
if (part.category == PartCategories.none && !checkPartVisible(part, mainCat))
{
blackListedParts.Add(part.name);
}
}

// since this wasn't initialised until now, the already created categories may be completely empty
// culling them now
PartCategorizer.Category cat;
for (int i = PartCategorizer.Instance.categories.Count - 1; i >= 0; --i)
{
cat = PartCategorizer.Instance.categories[i];

for (int j = cat.subcategories.Count - 1; j >= 0; --j)
{
Core.Log(cat.subcategories[j]);
Core.Log(cat.subcategories[j].button.categoryName);
// if (checkIsEmptyCategory(cat.subcategories[j]))
// {
// cat.subcategories[j].DeleteSubcategory();
// }
}
// if (cat.subcategories.Count > 0)
// continue;
// cat.DeleteCategory();
}
}

private bool checkPartVisible(AvailablePart part, PartCategorizer.Category category)
{
for (int i = 0; i < category.subcategories.Count; ++i)
Expand Down
2 changes: 2 additions & 0 deletions FilterExtension/Utility/PartType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ public static bool checkFolder(AvailablePart part, string[] value)
{
string path;
if (Core.Instance.partPathDict.TryGetValue(part.name, out path))
{
return value.Contains(path.Substring(0, path.IndexOfAny(new char[] { '\\', '/' })));
}
return false;
}

Expand Down
Binary file modified GameData/000_FilterExtensions/FilterExtensions.dll
Binary file not shown.

0 comments on commit f9d58d6

Please sign in to comment.