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);
        }
示例#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"));
        }
示例#3
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);
        }
示例#4
0
        private void SubCategories()
        {
            var icon   = GenIcon(categoryTitle);
            var filter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == category);

            PartCategorizer.AddCustomSubcategoryFilter(filter, categoryTitle, categoryTitle, icon, EditorItemsFilter);
        }
        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);
        }
示例#6
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);
 }
        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);
            }
        }
示例#8
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);
     }
 }
示例#9
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);
        }
示例#10
0
        private void SubCategories()
        {
            var icon   = PartCategorizer.Instance.iconLoader.GetIcon(IconName);
            var filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == Category);

            PartCategorizer.AddCustomSubcategoryFilter(filter, SubCategoryTitle, icon, p => AvPartItems.Contains(p.name));
        }
示例#11
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);
        }
示例#12
0
        private void SubCategories()
        {
            var icon   = GenIcon(categoryTitle);
            var filter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == "#autoLOC_453547");//change for 1.3.1

            PartCategorizer.AddCustomSubcategoryFilter(filter, categoryTitle, categoryTitle, icon, EditorItemsFilter);
        }
        /// <summary>
        /// Callback to be called by the KSP editor when it's time to populate the filter.
        /// </summary>
        void SubCategories()
        {
            var filter = PartCategorizer.Instance.filters.Find(
                f => f.button.categoryName == Category);

            PartCategorizer.AddCustomSubcategoryFilter(
                filter, title, GenIcon(), avParts.Contains);
        }
示例#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));
        }
示例#15
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);
			}
		}
示例#16
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);
     }
 }
示例#17
0
        private void AddFilterByMod()
        {
            ConfigNode[] nodes        = GameDatabase.Instance.GetConfigNodes("MODCAT");
            Texture2D    normalIcon   = new Texture2D(32, 32);
            Texture2D    selectedIcon = new Texture2D(32, 32);
            string       normalPath;
            string       selectedPath;
            string       folderName;
            string       title;
            Color        defaultButtonColor = new Color(0, 54, 99);

            char[] delimiters = { ',' };
            Icon   categoryIcon;

            PartCategorizer.Category categoryFilter;
            KSP.UI.UIRadioButton     categoryButton;

            foreach (ConfigNode configNode in nodes)
            {
                title = configNode.GetValue("title");
                if (string.IsNullOrEmpty(title))
                {
                    continue;
                }

                folderName = configNode.GetValue("folderName");
                if (string.IsNullOrEmpty(folderName))
                {
                    continue;
                }

                normalPath   = configNode.GetValue("normalPath");
                selectedPath = configNode.GetValue("selectedPath");
                if (string.IsNullOrEmpty(normalPath) || string.IsNullOrEmpty(selectedPath))
                {
                    continue;
                }

                normalIcon   = GameDatabase.Instance.GetTexture(normalPath, false);
                selectedIcon = GameDatabase.Instance.GetTexture(selectedPath, false);
                if (selectedIcon == null || normalIcon == null)
                {
                    continue;
                }

                ModFilter modFilter = new ModFilter();
                modFilter.modName = folderName;

                categoryIcon   = new Icon(folderName + " icon", normalIcon, selectedIcon);
                categoryFilter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
                PartCategorizer.AddCustomSubcategoryFilter(categoryFilter, title, categoryIcon, p => modFilter.IsPartInCat(p));

                categoryButton = categoryFilter.button.activeButton;
//                categoryButton.SetFalse(categoryButton, RUIToggleButtonTyped.ClickType.FORCED);
//                categoryButton.SetTrue(categoryButton, RUIToggleButtonTyped.ClickType.FORCED);
            }
        }
示例#18
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);
        }
示例#19
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);
     }
 }
示例#20
0
 public void AddSubCat()
 {
     Debug.Log("[FE_Testing Testing] Test subcat created");
     PartCategorizer.AddCustomSubcategoryFilter(
         PartCategorizer.Instance.filters.Find(c => string.Equals(c.button.categoryName, "Filter by Function", StringComparison.OrdinalIgnoreCase))
         , "testing"
         , Localizer.Format("testing")
         , new RUI.Icons.Selectable.Icon("abc", null, null, true)
         , p => allowedParts.Contains(p.name));
 }
示例#21
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);
 }
示例#22
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);
        }
示例#23
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);
        }
示例#24
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);
     }
 }
示例#25
0
        private void SubCategories()
        {
            var icon   = PartCategorizer.Instance.iconLoader.GetIcon(IconName);
            var filter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == CategoryButtonLocalizationId);

            if (filter == null)
            {
                WorkshopUtils.LogError($"Cannot find 'Filter by function' button for category: {SubCategoryTitle}");
                return;
            }
            PartCategorizer.AddCustomSubcategoryFilter(filter, SubCategoryTitle, SubCategoryTitle, icon, p => AvPartItems.Contains(p.name));
        }
        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);
        }
示例#27
0
        void onGUIEditorToolbarReady()
        {
            var cat = PartCategorizer.Instance.filters.Where(c => c.button.categoryName == "Filter by module").FirstOrDefault();

            foreach (var subcat in cat.subcategories)
            {
                if (subcat.button.categoryName.StartsWith("EL "))
                {
                    subcat.button.SetIcon(icon);
                }
            }
            cat = PartCategorizer.Instance.filters.Find(c => c.button.categoryName == "Filter by function");
            PartCategorizer.AddCustomSubcategoryFilter(cat, "EL Items", "EL Items", icon, elItemFilter);
        }
示例#28
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)"));
        }
示例#29
0
        /// <summary>
        /// Callback to be called by the KSP editor when it's time to populate the filter.
        /// </summary>
        void SubCategories()
        {
            var filter = PartCategorizer.Instance.filters.Find(
                f => f.button.categorydisplayName == CategoryButtonLocalizationId);

            if (filter == null)
            {
                // It can only happen due to a major changes in the KSP core.
                Debug.LogErrorFormat(
                    "Cannot find 'Filter by function' button for category: {0}", title);
                return;
            }
            PartCategorizer.AddCustomSubcategoryFilter(
                filter, title, title, GenIcon(), avParts.Contains);
        }
示例#30
0
        public void initialise()
        {
            if (categoryName == null)
            {
                return;
            }
            PartCategorizer.Icon icon = Core.getIcon(iconName);
            if (icon == null)
            {
                icon = PartCategorizer.Instance.fallbackIcon;
            }
            PartCategorizer.AddCustomFilter(categoryName, icon, colour);

            PartCategorizer.Category category = PartCategorizer.Instance.filters.Find(c => c.button.categoryName == categoryName);
            category.displayType     = EditorPartList.State.PartsList;
            category.exclusionFilter = PartCategorizer.Instance.filterGenericNothing;
        }
 /// <summary>
 /// called in the editor when creating the subcategory
 /// </summary>
 /// <param name="cat">The category to add this subcategory to</param>
 public void initialise(PartCategorizer.Category cat)
 {
     if (cat == null)
         return;
     RUI.Icons.Selectable.Icon icon = Core.getIcon(iconName);
     PartCategorizer.AddCustomSubcategoryFilter(cat, this.subCategoryTitle, icon, p => checkFilters(p));
 }
示例#32
0
        /// <summary>
        /// checks all subcategories and edits their names/icons if required
        /// </summary>
        public void namesAndIcons(PartCategorizer.Category category)
        {
            List<string> toRemove = new List<string>();
            foreach (PartCategorizer.Category c in category.subcategories)
            {
                if (removeSubCategory.Contains(c.button.categoryName))
                    toRemove.Add(c.button.categoryName);
                else
                {
                    string tmp;
                    if (Rename.TryGetValue(c.button.categoryName, out tmp)) // update the name first
                        c.button.categoryName = tmp;

                    RUI.Icons.Selectable.Icon icon;
                    if (tryGetIcon(tmp, out icon) || tryGetIcon(c.button.categoryName, out icon)) // if there is an explicit setIcon for the subcategory or if the name matches an icon
                        c.button.SetIcon(icon); // change the icon
                }
            }
            category.subcategories.RemoveAll(c => toRemove.Contains(c.button.categoryName));
        }