forked from Summerfirefly/ASW
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NASCategory.cs
33 lines (29 loc) · 1.3 KB
/
NASCategory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using KSP.UI.Screens;
using System.Collections.Generic;
using UnityEngine;
namespace AntiSubmarineWeapon
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class NASCategory:MonoBehaviour
{
private static readonly List<AvailablePart> availableParts = new List<AvailablePart>();
void Awake()
{
GameEvents.onGUIEditorToolbarReady.Add(NASCategoryFunc);
}
void NASCategoryFunc()
{
const string customCategoryName = "NAS";
const string customDisplayCategoryName = "NAS Parts";
availableParts.Clear();
availableParts.AddRange(PartLoader.LoadedPartsList.NASParts());
Texture2D iconTex = GameDatabase.Instance.GetTexture("NAS/Plugins/NASIcon", false);
RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon("NAS", iconTex, iconTex, false);
PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
if (filter == null)
Debug.Log("filter is null");
else
PartCategorizer.AddCustomSubcategoryFilter(filter, customCategoryName, customDisplayCategoryName, icon, p => availableParts.Contains(p));
}
}
}