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.categorydisplayName == "#autoLOC_453547"); // 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.categorydisplayName == "#autoLOC_453705").subcategories; // Filter by Module 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); }
// Changer de filtre/catégorie internal static void SelectPartCategory(bool dirScrolling, List <PartCategorizer.Category> categories, int index, UIList list) { if (QSettings.Instance.EnableWheelBlockTopEnd) { if (dirScrolling && index == 0) { return; } if (!dirScrolling && index == categories.Count - 1) { return; } } PartCategorizer.Category _category = (dirScrolling ? PrevCategory(categories, index) : NextCategory(categories, index)); UIRadioButton _btn = _category.button.activeButton; _btn.SetState(UIRadioButton.State.True, UIRadioButton.CallType.APPLICATION, null, true); //PartListTooltipsTWEAK (false); QuickScroll.Log("SelectPartCategory " + (dirScrolling ? "Prev" : "Next"), "QCategory"); }