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

Commit

Permalink
Added subcategory check type
Browse files Browse the repository at this point in the history
Moved subcategories to a more generic location to accommodate this
  • Loading branch information
Crzyrndm committed Jun 28, 2015
1 parent a5a2b47 commit 8a04f1f
Show file tree
Hide file tree
Showing 40 changed files with 412 additions and 261 deletions.
12 changes: 11 additions & 1 deletion FilterExtension/ConfigNodes/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum CheckType
crashTolerance,
maxTemp,
profile,
check
check,
subcategory
}

public class Check
Expand Down Expand Up @@ -187,12 +188,17 @@ public bool checkPart(AvailablePart part)
result = false;
}
break;
case CheckType.subcategory:
result = PartType.checkSubcategory(part, value);
break;
default:
Core.Log("invalid Check type specified");
result = false;
break;
}



if (invert)
result = !result;

Expand Down Expand Up @@ -243,6 +249,8 @@ public static CheckType getType(string type)
return CheckType.profile;
case "check":
return CheckType.check;
case "subcategory":
return CheckType.subcategory;
default:
return CheckType.category;
}
Expand Down Expand Up @@ -292,6 +300,8 @@ public static string getTypeString(CheckType type)
return "profile";
case CheckType.check:
return "check";
case CheckType.subcategory:
return "subcategory";
default:
return "category";
}
Expand Down
17 changes: 3 additions & 14 deletions FilterExtension/ConfigNodes/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,10 @@ internal bool checkFilter(AvailablePart part)
if (!ResearchAndDevelopment.PartModelPurchased(part) && !ResearchAndDevelopment.IsExperimentalPart(part))
return false;
}
bool val = true;
foreach (Check c in checks)
{
bool val = c.checkPart(part);
if (!val)
{
if (invert)
return true; // part failed a check, result inverted
else
return false; // part failed a check
}
}
if (invert)
return false; // part passed all checks, result inverted
else
return true; // part passed all checks, thus meets the filter requirements
val &= c.checkPart(part);
return invert ? !val : val;
}

public bool Equals(Filter f2)
Expand Down
4 changes: 1 addition & 3 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ void Awake()

loadIcons();
checkAndMarkConflicts();


}

private void getConfigs()
Expand Down Expand Up @@ -189,7 +187,7 @@ private void processFilterDefinitions()
customSubCategory sC = new customSubCategory(node);
if (sC.hasFilters)
{
if (sC.subCategoryTitle != null && checkSubCategoryHasParts(sC))
if (sC.subCategoryTitle != null)
{
if (!subCategoriesDict.ContainsKey(sC.subCategoryTitle)) // if nothing else has the same title
subCategoriesDict.Add(sC.subCategoryTitle, sC);
Expand Down
9 changes: 3 additions & 6 deletions FilterExtension/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ class Settings : MonoBehaviour
public void Start()
{
showWindow = false;
if (btnLauncher != null)
return;

btnLauncher = ApplicationLauncher.Instance.AddModApplication(() => showWindow = !showWindow, () => showWindow = !showWindow,
null, null, null, null,
ApplicationLauncher.AppScenes.SPACECENTER,
if (btnLauncher == null)
btnLauncher = ApplicationLauncher.Instance.AddModApplication(() => showWindow = !showWindow, () => showWindow = !showWindow,
null, null, null, null, ApplicationLauncher.AppScenes.SPACECENTER,
GameDatabase.Instance.GetTexture("000_FilterExtensions/Icons/FilterCreator", false));
}

Expand Down
14 changes: 12 additions & 2 deletions FilterExtension/Utility/PartType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ namespace FilterExtensions.Utility
{
public static class PartType
{
private static bool categoryCheck(AvailablePart part)
public static bool checkSubcategory(AvailablePart part, string value)
{
foreach (string s in value.Split(','))
{
string sTrimmed = s.Trim();
if (Core.Instance.subCategoriesDict.ContainsKey(sTrimmed) && Core.Instance.subCategoriesDict[sTrimmed].checkFilters(part))
return true;
}
return false;
}

public static bool categoryCheck(AvailablePart part)
{
if (part.category != PartCategories.none)
return false;
Expand All @@ -27,7 +38,6 @@ internal static bool checkCustom(AvailablePart part, string value)
val = isMultiCoupler(part);
break;
default:
Core.Log("incorrect value in custom type check");
val = false;
break;
}
Expand Down
35 changes: 35 additions & 0 deletions GameData/000_FilterExtensions Configs/Default/NamesAndIcons.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,39 @@ FilterSetIcon
FilterRemove
{
// remove = subCatName
}

FilterRename
{
name = LqdHydrogen, Nuclear Engines
name = LiquidFuel, Nuclear Rockets
name = ElectricCharge/IntakeAtm, Electric Fans
name = Airflow/ElectricCharge, Electric Jet
name = Karbonite, Karbonite Engines
name = IntakeAtm/Karbonite, Karbonite Jets
name = ElectricCharge/Karborundum, Karborundum Engines
name = Aluminium/LqdOxygen, Aluminium Engines
name = IntakeAtm, Thermal Engines
name = LqdHydrogen/Oxidizer, Cryo Engines
name = MJPropellant, MJ Propellant Engines
name = LqdMethane/LqdOxygen, Methane Engines
name = LqdDeuterium/LqdHydrogen/LqdTritium, Fusion Engines

}

FilterSetIcon
{
icon = Nuclear Engines, NuclearRocket
icon = Nuclear Rockets, NuclearRocket
icon = Electric Fans, FanEngine
icon = Electric Jet, FanEngine
icon = Karbonite Engines, EngineKarbonite
icon = Karbonite Jets, EngineJetKarbonite
icon = Karborundum Engines, EngineKarborundum
icon = Aluminium Engines, EngineAluminium
icon = Thermal Engines, EngineThermal
icon = Cryo Engines, EngineCryo
icon = MJ Propellant Engines, EngineMJ
icon = Methane Engines, EngineMethane
icon = Fusion Engines, EngineFusion
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8a04f1f

Please sign in to comment.