This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix not finding ore tanks, add parsing of stock subcats, add test aut…
…omation
- Loading branch information
Showing
13 changed files
with
268 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
using KSP.UI.Screens; | ||
|
||
namespace FE_Testing | ||
{ | ||
[KSPAddon(KSPAddon.Startup.EditorAny, false)] | ||
public class FE_Test_Script : MonoBehaviour | ||
{ | ||
const string testCatName = "Testing"; | ||
Dictionary<string, string> partSubCatMap = new Dictionary<string, string>() | ||
{ | ||
{ "By Category - Control", "asasmodule1-2" }, | ||
{ "By Check", "fuelTank3-2" }, | ||
{ "By Cost < 100", "basicFin" }, | ||
{ "By Crash Tolerance - 6.0m/s", "fuelTank3-2" }, | ||
{ "By Crew - 1", "Mark1Cockpit" }, | ||
{ "Unpurchased", "" }, | ||
{ "By Folder - Squad", "Mark1Cockpit" }, | ||
{ "Not Squad", "" }, | ||
{ "By Manufacturer - Ionic", "ionEngine" }, | ||
{ "By Mass - 500kg", "fuelTank4-2" }, | ||
{ "By Max Temp > 2k", "nuclearEngine" }, | ||
{ "By Module Name - ModuleEngines", "nuclearEngine" }, | ||
{ "By Module Name - !contains(ModuleEnginesFX & ModuleRCS)" , "basicFin" }, | ||
{ "By Module Title - Module Engines & Module Parachute", "nuclearEngine" }, | ||
{ "By Module Title 2 - !contains(Module Engines & Module Parachute)", "asasmodule1-2" }, | ||
{ "By Name - nosecone & rtg", "pointyNoseConeA" }, | ||
{ "By Path - Squad/Parts/FuelTank/", "fuelTank4-2" }, | ||
{ "By Profile - mk2", "mk2FuselageShortMono" }, | ||
{ "By Profile 2 - !contains(mk2 & mk1)", "basicFin" }, | ||
{ "By Propellant - LF", "nuclearEngine" }, | ||
{ "By Resource - LF", "fuelTankSmallFlat" }, | ||
{ "By Resource 2 - !contains(LF - Ox)", "mk2FuselageShortMono" }, | ||
{ "By Size - 1", "nuclearEngine" }, | ||
{ "By Size 2 - !contains(0-1-3)", "fuelTank4-2" }, | ||
{ "By Subcategory - By Resource", "fuelTank4-2" }, | ||
{ "By Tag - jet", "turboJet" }, | ||
{ "By Tag 2 - !contains(jet | only)", "nuclearEngine" }, | ||
{ "By Tech - experimentalElectronics", "rtg" }, | ||
{ "By Title - PB-NUK & Aerodynamic Nose Cone", "rtg" } | ||
}; | ||
|
||
public void Start() | ||
{ | ||
StartCoroutine(CheckTestSubcategories()); | ||
} | ||
|
||
IEnumerator CheckTestSubcategories() | ||
{ | ||
yield return new WaitForSeconds(5); // wait for the editor to complete startup | ||
|
||
PartCategorizer.Category testCat = PartCategorizer.Instance.filters.FirstOrDefault(C => C.button.categoryName == testCatName); | ||
if (testCat == null) | ||
{ | ||
LogTestResult($"Category named \"{testCatName}\" found", false); | ||
yield break; | ||
} | ||
|
||
foreach (PartCategorizer.Category testingSubCat in testCat.subcategories) | ||
{ | ||
if (partSubCatMap.ContainsKey(testingSubCat.button.categoryName)) | ||
{ | ||
LogTestResult(testingSubCat.button.categoryName, partExistsInSubCategory(partSubCatMap[testingSubCat.button.categoryName], testingSubCat)); | ||
partSubCatMap.Remove(testingSubCat.button.categoryName); | ||
} | ||
} | ||
|
||
// anything that didn't run gets an automatic fail | ||
foreach (var kvp in partSubCatMap) | ||
{ | ||
LogTestResult(kvp.Key, false); | ||
} | ||
} | ||
|
||
void LogTestResult(string test, bool result) | ||
{ | ||
if (result) | ||
{ | ||
Debug.Log($"[FE Testing] {test} with part \"{partSubCatMap[test]}\": {result}"); | ||
} | ||
else | ||
{ | ||
Debug.LogError($"[FE Testing] {test} with part \"{partSubCatMap[test]}\": {result}"); | ||
} | ||
} | ||
|
||
bool partExistsInSubCategory(string partID, PartCategorizer.Category toCheck) | ||
{ | ||
AvailablePart part = PartLoader.LoadedPartsList.FirstOrDefault(ap => string.Equals(ap.name, partID, StringComparison.OrdinalIgnoreCase)); | ||
if (part == null) | ||
{ | ||
Debug.Log($"[FE Testing] could not find any part with the ID {partID}"); | ||
return false; | ||
} | ||
return toCheck.exclusionFilter.FilterCriteria.Invoke(part); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{F544880B-94BB-48C7-9331-76452A1AE9B7}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>FE_Testing</RootNamespace> | ||
<AssemblyName>FE_Testing</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>..\Testing\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<RunPostBuildEvent>Always</RunPostBuildEvent> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\Desktop\Kerbal Space Program Dev\KSP_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\..\Desktop\Kerbal Space Program Dev\KSP_Data\Managed\UnityEngine.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="FE_Test_Script.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent>set SOURCE="D:\Libraries\GitHub\FilterExtension\Testing" | ||
set DESTINATION="D:\Libraries\Desktop\Kerbal Space Program Dev\GameData\000_FilterExtensions Configs\Testing" | ||
xcopy %25SOURCE%25 %25DESTINATION%25 /E /C /R /I /K /Y</PostBuildEvent> | ||
</PropertyGroup> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("FE_Testing")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("FE_Testing")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("f544880b-94bb-48c7-9331-76452a1ae9b7")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"NAME":"Filter Extensions","URL":"https://github.com/Crzyrndm/FilterExtension/blob/master/GameData/000_FilterExtensions/FilterExtensions.version","DOWNLOAD":"https://github.com/Crzyrndm/FilterExtension/releases","VERSION":{"MAJOR":2,"MINOR":7,"PATCH":0,"BUILD":0},"KSP_VERSION":{"MAJOR":1,"MINOR":2,"PATCH":0}} | ||
{"NAME":"Filter Extensions","URL":"https://github.com/Crzyrndm/FilterExtension/blob/master/GameData/000_FilterExtensions/FilterExtensions.version","DOWNLOAD":"https://github.com/Crzyrndm/FilterExtension/releases","VERSION":{"MAJOR":2,"MINOR":7,"PATCH":1,"BUILD":0},"KSP_VERSION":{"MAJOR":1,"MINOR":2,"PATCH":0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.