Ejemplo n.º 1
0
 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, EditorItemsFilter);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Categorize parts.
        /// </summary>
        public void Categorize()
        {
            Texture imgBlack = (Texture)GameDatabase.Instance.GetTexture("RATPack/Textures/raticon", false);
            Texture imgWhite = (Texture)GameDatabase.Instance.GetTexture("RATPack/Textures/raticon_white", false);
            Icon    icon     = new Icon("RAT", imgBlack, imgWhite);

            Icon rats          = PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_advelectrics");
            Icon thrustReverse = PartCategorizer.Instance.iconLoader.GetIcon("RDicon_aerospaceTech2");
            Icon taws          = PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_highaltitudeflight");

            PartCategorizer.Category cat = PartCategorizer.AddCustomFilter("RATPack", icon, Color.gray);
            cat.displayType = EditorPartList.State.PartsList;

            // All of the parts.
            PartCategorizer.AddCustomSubcategoryFilter(cat, "RATPack", icon, p => p.manufacturer.Contains("SatNet"));

            // Rats.
            PartCategorizer.AddCustomSubcategoryFilter(cat, "RATs", rats, p => p.moduleInfos.Exists(m => m.moduleName.Contains("RAT")));

            // Find TRs via title because module name doesn't seem to work.
            PartCategorizer.AddCustomSubcategoryFilter(cat, "Thrust Reversers", thrustReverse, p => p.title.Contains("Thrust Reverse"));

            // TAWS.
            PartCategorizer.AddCustomSubcategoryFilter(cat, "TAWS", taws,
                                                       p => p.moduleInfos.Exists(m => (m.moduleName.Contains("TAWS"))) || p.title.Contains("Terrain Radar"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// refresh the visible subcategories to ensure all changes are visible
        /// </summary>
        public static void SetSelectedCategory()
        {
            try
            {
                if (HighLogic.CurrentGame.Parameters.CustomParams <Settings>().categoryDefault != string.Empty)
                {
                    PartCategorizer.Category cat = PartCategorizer.Instance.filters.FirstOrDefault(f => f.button.categoryName == HighLogic.CurrentGame.Parameters.CustomParams <Settings>().categoryDefault);
                    if (cat != null)
                    {
                        cat.button.activeButton.SetState(KSP.UI.UIRadioButton.State.True, KSP.UI.UIRadioButton.CallType.APPLICATION, null, true);
                    }
                }

                if (HighLogic.CurrentGame.Parameters.CustomParams <Settings>().subCategoryDefault != string.Empty)
                {
                    // set the subcategory button
                    KSP.UI.UIRadioButton but = PartCategorizer.Instance.filters.FirstOrDefault(f => f.button.activeButton.Value)?.subcategories.FirstOrDefault(sC => {
                        return(sC.button.categoryName == HighLogic.CurrentGame.Parameters.CustomParams <Settings>().subCategoryDefault);
                    })?.button.activeButton;
                    but.SetState(KSP.UI.UIRadioButton.State.True, KSP.UI.UIRadioButton.CallType.APPLICATION, null, true);
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Category refresh failed\r\n{e.InnerException}\r\n{e.StackTrace}", Logger.LogLevel.Error);
            }
        }
Ejemplo n.º 4
0
        IEnumerator CheckTestSubcategories()
        {
            yield return(new WaitForSeconds(5)); // wait for the editor to complete startup

            PartCategorizer.Category testCat = PartCategorizer.Instance.filters.FirstOrDefault(C => string.Equals(Localizer.Format(C.button.categoryName), testCatName));
            if (testCat == null)
            {
                LogTestResult($"Category named \"{testCatName}\" found", false);
                yield break;
            }

            foreach (PartCategorizer.Category testingSubCat in testCat.subcategories)
            {
                if (partSubCatMap.ContainsKey(testingSubCat.button.categoryName))
                {
                    LogTestResult(testingSubCat.button.categoryName, PartExistsInSubCategory(partSubCatMap[testingSubCat.button.categoryName], testingSubCat));
                    partSubCatMap.Remove(testingSubCat.button.categoryName);
                }
            }

            // anything that didn't run gets an automatic fail
            foreach (KeyValuePair <string, string> kvp in partSubCatMap)
            {
                LogTestResult(kvp.Key, false);
            }
        }
Ejemplo n.º 5
0
 public void Initialise()
 {
     if (Type == CategoryNode.CategoryType.NEW)
     {
         RUI.Icons.Selectable.Icon icon     = IconLib.GetIcon(this);
         PartCategorizer.Category  category = PartCategorizer.AddCustomFilter(Name, Localizer.Format(Name), icon, Colour);
         category.displayType     = EditorPartList.State.PartsList;
         category.exclusionFilter = PartCategorizer.Instance.filterGenericNothing;
         InstanceSubcategories(category);
     }
     else
     {
         if (!PartCategorizer.Instance.filters.TryGetValue(c => string.Equals(Localizer.Format(c.button.categoryName), Name, StringComparison.OrdinalIgnoreCase),
                                                           out PartCategorizer.Category category))
         {
             Logger.Log($"No category of this name was found to manipulate: {Name}", Logger.LogLevel.Warn);
             return;
         }
         else if (Behaviour == CategoryNode.CategoryBehaviour.Replace)
         {
             if (category.button.activeButton.CurrentState == KSP.UI.UIRadioButton.State.True)
             {
                 PartCategorizer.Category subcat = category.subcategories.Find(c => c.button.activeButton.CurrentState == KSP.UI.UIRadioButton.State.True);
                 if (subcat != null)
                 {
                     subcat.OnFalseSUB(subcat);
                 }
                 PartCategorizer.Instance.scrollListSub.Clear(false);
             }
             category.subcategories.Clear();
         }
         InstanceSubcategories(category);
     }
 }
Ejemplo n.º 6
0
        private IEnumerator BDArmoryCategory()
        {
            // Wait for filter extensions to do their thing
            yield return(null);

            yield return(null);

            yield return(null);

            // BDA Category
            const string customCategoryName        = "BDAParts";
            const string customDisplayCategoryName = "Armory";

            FilterByFunctionCategory = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == "#autoLOC_453547");
            if (BDACategory != null && FilterByFunctionCategory.subcategories.Contains(BDACategory))
            {
                yield break;
            }

            Texture2D iconTex = GameDatabase.Instance.GetTexture("BDArmory/Textures/icon", false);

            RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon("BDArmory", iconTex, iconTex, false);

            BDACategory = PartCategorizer.AddCustomSubcategoryFilter(
                FilterByFunctionCategory,
                customCategoryName,
                customDisplayCategoryName,
                icon,
                part => PartInCurrentCategory(part)
                );

            BDACategory.button.btnToggleGeneric.onClick.AddListener(CategoryButtonClick);
        }
Ejemplo n.º 7
0
        void InstanceSubcategories(PartCategorizer.Category category, bool debug)
        {
#if DEBUG
            if (debug)
            {
                Debug.Log("InstanceSubcategories, category: " + category);
            }
#endif
            foreach (SubCategoryInstance sc in Subcategories)
            {
                try
                {
#if DEBUG
                    if (debug)
                    {
                        Debug.Log("SubCategoryInstance " + sc.Name);
                    }
#endif
                    sc.Initialise(category, debug);
                }
                catch (Exception ex)
                {
                    Logger.Log($"{sc} failed to initialise"
                               + $"\r\nCategory: {Name}"
                               + $"\r\nSubcategory Valid: {sc.Valid}"
                               + $"\r\n{ex.Message}"
                               + $"\r\n{ex.StackTrace}",
                               Logger.LogLevel.Error);
                }
            }
        }
 void ProcessProfiles(PartCategorizer.Category profilesCategory)
 {
     for (int i = profilesCategory.subcategories.Count; i-- > 0;)
     {
         var cat    = profilesCategory.subcategories[i];
         var button = cat.button;
         //Debug.Log ($"[BulkheadProfiles] {button.categoryName} {button.categorydisplayName}");
         BulkheadProfileData bp = null;
         if (bulkheadProfiles.TryGetValue(button.categoryName, out bp))
         {
             SetButtonDisplayName(button, bp.displayName);
             if (bp.icon != null)
             {
                 button.SetIcon(bp.icon);
             }
         }
         else
         {
             // KSP does not set the display name (which is used for
             // the tool tip), so set it to the category name so at
             // least something shows.
             if (string.IsNullOrEmpty(button.categorydisplayName))
             {
                 SetButtonDisplayName(button, button.categoryName);
             }
         }
     }
 }
Ejemplo n.º 9
0
        private void addIIfilter()
        {
            try
            {
                Icon currentPartsIcon = this.GenIcons("II_filter_icon", "SmallLogo", "SmallLogoON");
                Icon legacyPartsIcon  = this.GenIcons("II_filter_icon_legacy", "SmallLogoGrey", "SmallLogoGreyON");

                PartCategorizer.Category IIfilter = PartCategorizer.AddCustomFilter(Constants.PLUGIN_ID, Constants.MANUFACTURER_NAME, this.icon, Color.white);

                //filters for all II parts
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "AllParts", string.Format("All {0} Parts", Constants.MANUFACTURER_NAME), currentPartsIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "CommandPods", "Command Pods", currentPartsIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString() == "Pods" && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Control", "Control", currentPartsIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString().Contains("Control") && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Tanks", "Tanks", currentPartsIcon, p => p.resourceInfos.Exists(q => q.resourceName == "HydrogenProtium" || q.resourceName == "HydrogenDeuterium" || q.resourceName == "HydrogenTritium") && p.manufacturer == Constants.MANUFACTURER_NAME);
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Electrical", "Electrical", currentPartsIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString() == "Electrical" && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Engines", "Engines", currentPartsIcon, r => r.title.Contains("Fusion Engine") && r.manufacturer == Constants.MANUFACTURER_NAME);
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "BoostersCL20", "CL-20 Boosters", currentPartsIcon, s => s.resourceInfos.Exists(t => t.resourceName == "CL-20") && s.manufacturer == Constants.MANUFACTURER_NAME);
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "WingsIonized", "Ionized Wings", currentPartsIcon, u => u.title.Contains("Ionized") && !u.title.Contains("(LEGACY)") && u.manufacturer == Constants.MANUFACTURER_NAME);
                PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Legacy", "Legacy Parts", legacyPartsIcon, v => v.title.Contains("(LEGACY)") && v.manufacturer == Constants.MANUFACTURER_NAME);
            }
            catch (Exception e)
            {
                Log.ex(this, e);
            }
        }
Ejemplo n.º 10
0
        private void SubCategories()
        {
            Icon icon = GetIcon(categoryTitle);

            PartCategorizer.Category category = PartCategorizer.Instance.filters.Find((PartCategorizer.Category f) => f.button.categorydisplayName == "#autoLOC_453547");
            PartCategorizer.AddCustomSubcategoryFilter(category, categoryTitle, categoryTitle, icon, (Func <AvailablePart, bool>)EditorItemsFilter);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        private void IRCustomFilter()
        {
            const string FILTER_CATEGORY      = "Filter by function";
            const string CUSTOM_CATEGORY_NAME = "Robotic";

            //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");

            var texture_off = UIAssetsLoader.iconAssets.Find(i => i.name == "icon_filter_off");
            var texture_on  = UIAssetsLoader.iconAssets.Find(i => i.name == "icon_filter_on");

            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.categorydisplayName == "#autoLOC_453547");//change for 1.3.1
            PartCategorizer.AddCustomSubcategoryFilter(filter, CUSTOM_CATEGORY_NAME, CUSTOM_CATEGORY_NAME, icon, p => availableParts.Contains(p));

            //KSP.UI.UIRadioButton button = filter.button.activeButton;

            //button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
            //button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
        }
Ejemplo n.º 13
0
        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")));
            PartCategorizer.Icon icon = new PartCategorizer.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", 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
            RUIToggleButtonTyped button = filterByFunction.button.activeButton;

            button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
            button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
        }
Ejemplo n.º 14
0
        private void SubCategories()
        {
            RemoveSubFilter();
            Icon filterDeepFreeze = new Icon("DeepFreezeEditor", Textures.DeepFreeze_Editor, Textures.DeepFreeze_Editor, true);

            PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
            PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, filterDeepFreeze, p => EditorItemsFilter(p));
        }
Ejemplo n.º 15
0
        public void refreshList()
        {
            PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
            RUIToggleButtonTyped     button = Filter.button.activeButton;

            button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
            button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
        }
Ejemplo n.º 16
0
 void addEditorCategory()
 {
     if (PartLoader.LoadedPartsList.Find(k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0) != null)
     {
         var icon = new RUI.Icons.Selectable.Icon("Kerbalism", Lib.GetTexture("category_normal"), Lib.GetTexture("category_selected"));
         PartCategorizer.Category category = PartCategorizer.Instance.filters.Find(k => k.button.categoryName == "Filter by Function");
         PartCategorizer.AddCustomSubcategoryFilter(category, "", icon, k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0);
     }
 }
Ejemplo n.º 17
0
		void AddEditorCategory()
		{
			if (PartLoader.LoadedPartsList.Find(k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0) != null)
			{
				var icon = new RUI.Icons.Selectable.Icon("Kerbalism", Icons.category_normal, Icons.category_selected);
				PartCategorizer.Category category = PartCategorizer.Instance.filters.Find(k => k.button.categoryName.ToLower() == "filter by function");
				PartCategorizer.AddCustomSubcategoryFilter(category, "Kerbalism", "Kerbalism", icon, k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0);
			}
		}
Ejemplo n.º 18
0
 void AddEditorCategory()
 {
     if (PartLoader.LoadedPartsList.Find(k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0) != null)
     {
         RUI.Icons.Selectable.Icon icon     = new RUI.Icons.Selectable.Icon("Kerbalism", Textures.category_normal, Textures.category_selected);
         PartCategorizer.Category  category = PartCategorizer.Instance.filters.Find(k => string.Equals(k.button.categoryName, "filter by function", StringComparison.OrdinalIgnoreCase));
         PartCategorizer.AddCustomSubcategoryFilter(category, "Kerbalism", "Kerbalism", icon, k => k.tags.IndexOf("_kerbalism", StringComparison.Ordinal) >= 0);
     }
 }
Ejemplo n.º 19
0
        private void SubCategories()
        {
            RemoveSubFilter();
            Icon filterTacLS = new Icon("TACLSEditor", Textures.EditorCatIcon, Textures.EditorCatIcon, true);

            PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
            PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, filterTacLS, p => EditorItemsFilter(p));
            //GameEvents.onGUIEditorToolbarReady.Remove(SubCategories);
        }
Ejemplo n.º 20
0
 private void SubCategories()
 {
     PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == category);
     if (filter == null)
     {
         // This can only happen if there are major changes in the KSP code
         Debug.Log($"[TF] Cannot find the 'Filter by Function' button for category: {categoryTitle}.");
         return;
     }
     PartCategorizer.AddCustomSubcategoryFilter(filter, categoryTitle, categoryTitle, GenerateIcon(), EditorItemsFilter);
 }
Ejemplo n.º 21
0
 private void checkIcons(PartCategorizer.Category category)
 {
     foreach (PartCategorizer.Category c in category.subcategories)
     {
         // if any of the names of the loaded icons match the subCategory name, then replace their current icon with the match
         if (iconDict.ContainsKey(c.button.categoryName))
         {
             c.button.SetIcon(getIcon(c.button.categoryName));
         }
     }
 }
Ejemplo n.º 22
0
 private bool CheckPartVisible(AvailablePart part, PartCategorizer.Category category)
 {
     foreach (PartCategorizer.Category subcat in category.subcategories)
     {
         if (subcat.exclusionFilter.FilterCriteria(part))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 23
0
 private bool CheckIsEmptyCategory(PartCategorizer.Category category)
 {
     foreach (AvailablePart part in PartLoader.LoadedPartsList)
     {
         if (CheckPartVisible(part, category))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        bool PartExistsInSubCategory(string partID, PartCategorizer.Category toCheck)
        {
            AvailablePart part = PartLoader.LoadedPartsList.FirstOrDefault(ap => string.Equals(ap.name, partID, StringComparison.OrdinalIgnoreCase));

            if (part == null)
            {
                Debug.Log($"[FE Testing] could not find any part with the ID {partID}");
                return(false);
            }
            return(toCheck.exclusionFilter.FilterCriteria.Invoke(part));
        }
Ejemplo n.º 26
0
        public void CreateInventoryPartCategory()
        {
            IconLoader loader = UnityEngine.Object.FindObjectOfType <IconLoader>();
            Icon       icon   = loader.icons.FirstOrDefault(i => string.Equals(i.name, "stockIcon_structural", StringComparison.Ordinal));

            PartCategorizer.Category category = PartCategorizer.AddCustomFilter("ScrapYard", "ScrapYard", icon, new UnityEngine.Color(0.75f, 0.75f, 0.75f));
            category.displayType     = EditorPartList.State.PartsList;
            category.exclusionFilter = PartCategorizer.Instance.filterGenericNothing;

            PartCategorizer.AddCustomSubcategoryFilter(category, "Inventory", "Inventory", icon, Filter);
        }
Ejemplo n.º 27
0
 private void GenFilter(PartCategorizer.Category filter, string subFilterName, string subFilterdisplayName, string iconName, Func <AvailablePart, bool> exclusionFilter)
 {
     try
     {
         Icon icon = GenIcons(iconName);
         PartCategorizer.AddCustomSubcategoryFilter(filter, subFilterName, subFilterdisplayName, icon, exclusionFilter);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
        void onGUIEditorToolbarReady()
        {
            if (icon == null)
            {
                IconLoader iconloader = PartCategorizer.Instance.iconLoader;
                icon = iconloader.GetIcon("R&D_node_icon_fuelsystems");
            }
            PartCategorizer.Category cat    = PartCategorizer.Instance.filters.Find(c => c.button.categoryName == "Filter by Module");
            PartCategorizer.Category subcat = cat.subcategories.Find(c => c.button.categoryName == "Modular Fuel Tank");
            subcat.button.SetIcon(icon);

            cat = PartCategorizer.Instance.filters.Find(c => c.button.categoryName == "Filter by Function");
            PartCategorizer.AddCustomSubcategoryFilter(cat, "MFT Tanks", "MFT Tanks", icon, mftItemFilter);
        }
Ejemplo n.º 29
0
        private void AddAdvMenufilter()
        {
            // TODO Better add'on Icons!
            PartCategorizer.Category filter = PartCategorizer.AddCustomFilter(Constants.PLUGIN_ID, Constants.MANUFACTURER_NAME, GenIcons("KAX"), Color.white);

            // TODO Better "All Parts" icons. Localization for it too!
            GenFilter(filter, "AllParts", string.Format("All {0} Parts", Constants.MANUFACTURER_NAME), "KAX", o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)"));
            GenFilter(filter, "CommandPods", "#autoLOC_453549", "Pods", o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString() == "Pods" && !o.title.Contains("(LEGACY)"));
            GenFilter(filter, "Tanks", "#autoLOC_453552", "Tanks", p => p.manufacturer == Constants.MANUFACTURER_NAME && !p.title.Contains("(LEGACY)") && p.resourceInfos.Exists(q => q.resourceName == "LiquidFuel" || q.resourceName == "Oxidizer" || q.resourceName == "Monopropellant"));
            GenFilter(filter, "Structural", "#autoLOC_453561", "Structural", o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)") && o.category.ToString() == "Structural");
            //GenFilter(filter, "Electrical", "#autoLOC_453579", "Electrical", o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)") && o.category.ToString() == "Electrical" );
            GenFilter(filter, "Engines", "#autoLOC_453555", "Engines", o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)") && o.moduleInfos.Exists(q => q.moduleName == "Engine"));
            //GenFilter(filter, "Legacy", "#autoLOC_1900223", "Legacy", o => o.manufacturer == Constants.MANUFACTURER_NAME && o.title.Contains("(LEGACY)"));
        }
Ejemplo n.º 30
0
 private void RemoveSubFilter()
 {
     if (PartCategorizer.Instance != null)
     {
         PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
         if (Filter != null)
         {
             PartCategorizer.Category subFilter = Filter.subcategories.Find(f => f.button.categoryName == subCategoryTitle);
             if (subFilter != null)
             {
                 subFilter.DeleteSubcategory();
             }
         }
     }
 }
Ejemplo n.º 31
0
 IEnumerator initialise()
 {
     for (int i = 0; i < 14; i++) // FE will do a refresh after a count of 16. Deletion is done after a count of 12.
         yield return null;
     customTestCategory.initialise(PartCategorizer.Instance.filters[0]);
     testCategory = PartCategorizer.Instance.filters[0].subcategories.First(c => c.button.categoryName == "testCategory");
 }