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

Commit

Permalink
CSV mods and categories for subC's
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Dec 26, 2014
1 parent b330583 commit 8c7db66
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 36 deletions.
18 changes: 18 additions & 0 deletions FilterExtension/Categoriser/PartType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ internal static bool checkFolder(AvailablePart part, string value)
return folderCheck;
}

internal static bool checkFolder(AvailablePart part, string[] values)
{
if (part.name == "PotatoRoid")
return false;

if (Core.partFolderDict.ContainsKey(part.name))
{
foreach (string s in values)
{
if (Core.partFolderDict[part.name] == s.Trim())
return true;
}
}
Debug.Log("[Filter Extensions] Unable to assign a mod to the part " + part.title);

return false;
}

public static int partSize(AvailablePart part)
{
int size = -1;
Expand Down
9 changes: 5 additions & 4 deletions FilterExtension/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ class customCategory
internal string iconName;
internal Color colour;
internal string type;
internal string value; // mod folder name for mod type categories
internal string location; // filter == top set, category = custom section
internal string[] value; // mod folder name for mod type categories
// internal string location; // filter == top set, category = custom section

public customCategory(ConfigNode node)
{
categoryTitle = node.GetValue("title");
iconName = node.GetValue("icon");
convertToColor(node.GetValue("colour"));
type = node.GetValue("type");
value = node.GetValue("value");
location = node.GetValue("location");
string temp = node.GetValue("value");
if (!string.IsNullOrEmpty(temp))
value = temp.Split(',');
}

internal void initialise()
Expand Down
4 changes: 1 addition & 3 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private bool checkForConflicts(subCategory sCToCheck)
{
foreach (subCategory sC in subCategories) // iterate through the already added sC's
{
if (sCToCheck.category == sC.category)
if (sCToCheck.categories == sC.categories)
{
if (compareFilterLists(sC.filters, sCToCheck.filters)) // check for duplicated filters
{
Expand Down Expand Up @@ -219,7 +219,6 @@ private void loadIcons()
if (!texDict.ContainsKey(t.name))
texDict.Add(t.name, t);
}
Debug.Log("just a checkpoint");
foreach (GameDatabase.TextureInfo t in texList)
{
bool simple = false;
Expand All @@ -237,7 +236,6 @@ private void loadIcons()
if (!PartCategorizer.Instance.iconDictionary.ContainsKey(icon.name))
PartCategorizer.Instance.iconDictionary.Add(icon.name, icon);
}
print(texList.Count);
}

internal static PartCategorizer.Icon getIcon(string name)
Expand Down
57 changes: 32 additions & 25 deletions FilterExtension/subCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FilterExtensions
{
class subCategory
{
internal string category; // parent category
internal string[] categories; // parent category
internal string subCategoryTitle; // title of this subcategory
internal string oldTitle; // title generated for the auto extending categories to search by
internal string iconName; // default icon to use
Expand All @@ -16,7 +16,7 @@ class subCategory

public subCategory(ConfigNode node)
{
category = node.GetValue("category");
categories = node.GetValue("category").Split(',');
subCategoryTitle = node.GetValue("title");
iconName = node.GetValue("icon");
oldTitle = node.GetValue("oldTitle");
Expand All @@ -41,33 +41,40 @@ internal bool checkFilters(AvailablePart part)

internal void initialise()
{
PartCategorizer.Icon icon;
if (string.IsNullOrEmpty(iconName))
foreach (string s in categories)
{
Debug.Log("[Filter Extensions] " + this.subCategoryTitle + " missing icon reference");
icon = PartCategorizer.Instance.fallbackIcon;
}
else
{
icon = Core.getIcon(iconName);
}
if (filter)
{
PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, icon, p => checkFilters(p));
}
else if (!string.IsNullOrEmpty(oldTitle))
{
List<PartCategorizer.Category> subCategories = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category).subcategories;
if (string.IsNullOrEmpty(subCategoryTitle))
subCategories.Remove(subCategories.Find(m => m.button.categoryName == oldTitle));
Debug.Log(s);
PartCategorizer.Icon icon;
if (string.IsNullOrEmpty(iconName))
{
Debug.Log("[Filter Extensions] " + this.subCategoryTitle + " missing icon reference");
icon = PartCategorizer.Instance.fallbackIcon;
}
else
{
PartCategorizerButton but = subCategories.FirstOrDefault(sC => sC.button.categoryName == oldTitle).button;
if (but != null)
icon = Core.getIcon(iconName);
}
Debug.Log("1");
if (filter)
{
Debug.Log("2");
PartCategorizer.Category Filter = PartCategorizer.Instance.filters.FirstOrDefault(f => f.button.categoryName == s.Trim());
Debug.Log("3");
PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, icon, p => checkFilters(p));
}
else if (!string.IsNullOrEmpty(oldTitle))
{
List<PartCategorizer.Category> subCategories = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == s.Trim()).subcategories;
if (string.IsNullOrEmpty(subCategoryTitle))
subCategories.Remove(subCategories.Find(m => m.button.categoryName == oldTitle));
else
{
but.categoryName = subCategoryTitle;
but.SetIcon(icon);
PartCategorizerButton but = subCategories.FirstOrDefault(sC => sC.button.categoryName == oldTitle).button;
if (but != null)
{
but.categoryName = subCategoryTitle;
but.SetIcon(icon);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CATEGORY

SUBCATEGORY
{
category = TestSQUAD
title = TestCustom1
category = TestSQUAD, TestCategory
title = TestCustom11
icon = R&D_node_icon_advrocketry
FILTER
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ CATEGORY
{
title = TestNASA
icon = R&D_node_icon_experimentalmotors
colour = #FF00FF00
colour = #FF00F000
type = mod
value = NASAmission
value = NASAmission, NearFuturePropulsion
location = filter
}

Expand Down
Binary file modified GameData/Filter Extensions/FilterExtensions.dll
Binary file not shown.

0 comments on commit 8c7db66

Please sign in to comment.