Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void AddFilter()
- {
- //Loads the RealChute parachutes icon
- Texture2D normal = new Texture2D(32, 32), selected = new Texture2D(32, 32);
- normal.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.PluginDataURL, "FilterIcon.png")));
- selected.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.PluginDataURL, "FilterIcon_selected.png")));
- Icon icon = new Icon("RC_Parachutes", normal, selected);
- //Adds the Parachutes filter to the Filter by Function category
- PartCategorizer.Category filterByFunction = PartCategorizer.Instance.filters
- .Find(f => f.button.categoryName == "Filter by Function");
- PartCategorizer.AddCustomSubcategoryFilter(filterByFunction, "Parachutes", "Parachutes", icon,
- p => p.moduleInfos.Any(m => m.moduleName == "RealChute" || m.moduleName == "Parachute"));
- //Sets the buttons in the Filter by Module category
- List<PartCategorizer.Category> modules = PartCategorizer.Instance.filters
- .Find(f => f.button.categoryName == "Filter by Module").subcategories;
- modules.Remove(modules.Find(m => m.button.categoryName == "Procedural Chute"));
- modules.Select(m => m.button).Single(b => b.categoryName == "RealChute").SetIcon(icon);
- //Apparently needed to make sure the buttons in Filter by Function show when the editor is loaded
- UIRadioButton button = filterByFunction.button.activeButton;
- button.SetState(UIRadioButton.State.False, UIRadioButton.CallType.APPLICATION, null, false);
- button.SetState(UIRadioButton.State.True, UIRadioButton.CallType.APPLICATION, null, false);
- }
- private void Awake()
- {
- GameEvents.onGUIEditorToolbarReady.Add(AddFilter);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement