Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =======================
- RoverDude 1:
- ========================
- using RUI.Icons.Selectable;
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace USITools
- {
- [KSPAddon(KSPAddon.Startup.MainMenu, true)]
- public class USI_KolonyFilter : MonoBehaviour
- {
- private static System.Collections.Generic.List<AvailablePart> kolonyParts = new System.Collections.Generic.List<AvailablePart>();
- internal string category = "Filter by Function";
- internal string subCategoryTitle = "Kolonization";
- internal string defaultTitle = "UKS";
- internal string iconName = "R&D_node_icon_start";
- internal bool filter = true;
- private void Awake()
- {
- GameEvents.onGUIEditorToolbarReady.Add(new EventVoid.OnEvent(this.SubCategories));
- USI_KolonyFilter.kolonyParts.Clear();
- foreach (AvailablePart current in PartLoader.LoadedPartsList)
- {
- if (current.partPrefab && current.manufacturer == "USI - Kolonization Division")
- {
- USI_KolonyFilter.kolonyParts.Add(current);
- }
- }
- }
- private bool EditorItemsFilter(AvailablePart avPart)
- {
- return USI_KolonyFilter.kolonyParts.Contains(avPart);
- }
- private void SubCategories()
- {
- Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(this.iconName);
- PartCategorizer.Category category = PartCategorizer.Instance.filters.Find((PartCategorizer.Category f) => f.button.categoryName == this.category);
- PartCategorizer.AddCustomSubcategoryFilter(category, this.subCategoryTitle, icon, (AvailablePart p) => this.EditorItemsFilter(p));
- RUIToggleButtonTyped activeButton = category.button.activeButton;
- activeButton.SetFalse(activeButton, RUIToggleButtonTyped.ClickType.FORCED);
- activeButton.SetTrue(activeButton, RUIToggleButtonTyped.ClickType.FORCED, true);
- }
- }
- }
- ============================
- RoverDude 2:
- ============================
- using RUI.Icons.Selectable;
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace USITools
- {
- [KSPAddon(KSPAddon.Startup.MainMenu, true)]
- public class USI_FreightFilter : MonoBehaviour
- {
- private static System.Collections.Generic.List<AvailablePart> kolonyParts = new System.Collections.Generic.List<AvailablePart>();
- internal string category = "Filter by Function";
- internal string subCategoryTitle = "Freight";
- internal string defaultTitle = "FTT";
- internal string iconName = "RDicon_fuelSystems-highPerformance";
- internal bool filter = true;
- private void Awake()
- {
- GameEvents.onGUIEditorToolbarReady.Add(new EventVoid.OnEvent(this.SubCategories));
- USI_FreightFilter.kolonyParts.Clear();
- foreach (AvailablePart current in PartLoader.LoadedPartsList)
- {
- if (current.partPrefab && current.manufacturer == "USI - Freight Division")
- {
- USI_FreightFilter.kolonyParts.Add(current);
- }
- }
- }
- private bool EditorItemsFilter(AvailablePart avPart)
- {
- return USI_FreightFilter.kolonyParts.Contains(avPart);
- }
- private void SubCategories()
- {
- Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(this.iconName);
- PartCategorizer.Category category = PartCategorizer.Instance.filters.Find((PartCategorizer.Category f) => f.button.categoryName == this.category);
- PartCategorizer.AddCustomSubcategoryFilter(category, this.subCategoryTitle, icon, (AvailablePart p) => this.EditorItemsFilter(p));
- RUIToggleButtonTyped activeButton = category.button.activeButton;
- activeButton.SetFalse(activeButton, RUIToggleButtonTyped.ClickType.FORCED);
- activeButton.SetTrue(activeButton, RUIToggleButtonTyped.ClickType.FORCED, true);
- }
- }
- }
- ============================
- Infernal Robotics:
- ============================
- using System.Collections.Generic;
- using InfernalRobotics.Control.Servo;
- using UnityEngine;
- namespace InfernalRobotics.Gui
- {
- [KSPAddon(KSPAddon.Startup.MainMenu, true)]
- public class IREditorCategory : MonoBehaviour
- {
- private static readonly List<AvailablePart> availableParts = new List<AvailablePart>();
- void Awake()
- {
- GameEvents.onGUIEditorToolbarReady.Add(IRCustomFilter);
- //create list of parts that have MuMechToggle module in them
- availableParts.Clear();
- availableParts.AddRange(PartLoader.LoadedPartsList.InfernalParts());
- }
- private void IRCustomFilter()
- {
- const string FILTER_CATEGORY = "Filter by Function";
- const string CUSTOM_CATEGORY_NAME = "Robotic Parts";
- var texture_on = new Texture2D(36, 36, TextureFormat.RGBA32, false);
- var texture_off = new Texture2D(36, 36, TextureFormat.RGBA32, false);
- InfernalRobotics.Utility.TextureLoader.LoadImageFromFile(texture_on, "icon_filter_on.png");
- InfernalRobotics.Utility.TextureLoader.LoadImageFromFile(texture_off, "icon_filter_off.png");
- RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon("Infernal Robotics", texture_off, texture_on);
- //Adding our own subcategory to main filter
- PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == FILTER_CATEGORY);
- PartCategorizer.AddCustomSubcategoryFilter(filter, CUSTOM_CATEGORY_NAME, icon, p => availableParts.Contains(p));
- RUIToggleButtonTyped button = filter.button.activeButton;
- button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
- button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
- }
- }
- }
- ============================
- KIS:
- ============================
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- namespace KIS
- {
- //using UnityEngine;
- [KSPAddon(KSPAddon.Startup.MainMenu, true)]
- public class KISAddonEditorFilter : MonoBehaviour
- {
- private static List<AvailablePart> avPartItems = new List<AvailablePart>();
- internal string category = "Filter by Function";
- internal string subCategoryTitle = "EVA Items";
- internal string defaultTitle = "KIS";
- internal string iconName = "R&D_node_icon_evatech";
- internal bool filter = true;
- void Awake()
- {
- GameEvents.onGUIEditorToolbarReady.Add(SubCategories);
- avPartItems.Clear();
- foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
- {
- if (avPart.name == "kerbalEVA" || avPart.name == "kerbalEVA_RD" || !avPart.partPrefab) continue;
- ModuleKISItem moduleItem = avPart.partPrefab.GetComponent<ModuleKISItem>();
- if (moduleItem)
- {
- if (moduleItem.editorItemsCategory)
- {
- avPartItems.Add(avPart);
- }
- }
- }
- }
- private bool EditorItemsFilter(AvailablePart avPart)
- {
- if (avPartItems.Contains(avPart))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void SubCategories()
- {
- RUI.Icons.Selectable.Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(iconName);
- PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
- PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, icon, p => EditorItemsFilter(p));
- RUIToggleButtonTyped button = Filter.button.activeButton;
- button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
- button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement