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

Commit

Permalink
First part
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Dec 20, 2014
1 parent ecce61f commit d9abe12
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 0 deletions.
22 changes: 22 additions & 0 deletions FilterExtension.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartFilters", "FilterExtension\PartFilters.csproj", "{8633A568-654E-409D-A7B2-95839F2EBD3D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8633A568-654E-409D-A7B2-95839F2EBD3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8633A568-654E-409D-A7B2-95839F2EBD3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8633A568-654E-409D-A7B2-95839F2EBD3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8633A568-654E-409D-A7B2-95839F2EBD3D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
22 changes: 22 additions & 0 deletions FilterExtension/ControlSurface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace PartFilters
{
class ControlSurface
{
internal void SurfaceFilter()
{
PartCategorizer.Icon icon = PartCategorizer.Instance.GetIcon("R&D_node_icon_stability");

PartCategorizer.Category filterByFunction = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
PartCategorizer.AddCustomSubcategoryFilter(filterByFunction, "Control Surfaces", icon, p => p.moduleInfos.Any(m => m.moduleName == "Control Surface" || m.moduleName == "FAR Controllable"));

RUIToggleButtonTyped button = filterByFunction.button.activeButton;
button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
}
}
}
27 changes: 27 additions & 0 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace PartFilters
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class Core : MonoBehaviour
{
Wheel wheelFilt;
ControlSurface contrSurfaceFilt;

void Awake()
{
GameEvents.onGUIEditorToolbarReady.Add(Filters);

wheelFilt = new Wheel();
contrSurfaceFilt = new ControlSurface();
}

private void Filters()
{
wheelFilt.WheelFilter();
contrSurfaceFilt.SurfaceFilter();
}
}
}
61 changes: 61 additions & 0 deletions FilterExtension/PartFilters.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.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>{8633A568-654E-409D-A7B2-95839F2EBD3D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PartFilters</RootNamespace>
<AssemblyName>PartFilters</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>..\..\..\..\..\Desktop\Kerbal Space Program Dev\GameData\Filters\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\Desktop\Kerbal Space Program Dev\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</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>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ControlSurface.cs" />
<Compile Include="Core.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Wheel.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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>
36 changes: 36 additions & 0 deletions FilterExtension/Properties/AssemblyInfo.cs
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("PartFilters")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PartFilters")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[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("7397ad0e-7874-458b-9b25-d904a6c98b4a")]

// 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")]
22 changes: 22 additions & 0 deletions FilterExtension/Wheel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace PartFilters
{
class Wheel
{
internal void WheelFilter()
{
PartCategorizer.Icon icon = PartCategorizer.Instance.GetIcon("R&D_node_icon_fieldscience");

PartCategorizer.Category filterByFunction = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
PartCategorizer.AddCustomSubcategoryFilter(filterByFunction, "Wheels", icon, p => p.moduleInfos.Any(m => m.moduleName == "Wheel" || m.moduleName == "Landing Gear"));

RUIToggleButtonTyped button = filterByFunction.button.activeButton;
button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
}
}
}

0 comments on commit d9abe12

Please sign in to comment.