Ejemplo n.º 1
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.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);
        }
Ejemplo n.º 2
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.º 3
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.º 4
0
        private void addIIfilter()
        {
            //Loading Textures
            Texture2D unselected = new Texture2D(32, 32);
            Texture2D selected = new Texture2D(32, 32);
            Texture2D unselectedLegacy = new Texture2D(32, 32);
            Texture2D selectedLegacy = new Texture2D(32, 32);

            unselected.LoadImage(File.ReadAllBytes("GameData/ImpossibleInnovations/Plugins/PluginData/SmallLogo.png"));
            selected.LoadImage(File.ReadAllBytes("GameData/ImpossibleInnovations/Plugins/PluginData/SmallLogoON.png"));
            RUI.Icons.Selectable.Icon filterIcon = new RUI.Icons.Selectable.Icon("II_filter_icon", unselected, selected); //Defining filterIcon

            unselectedLegacy.LoadImage(File.ReadAllBytes("GameData/ImpossibleInnovations/Plugins/PluginData/SmallLogoGrey.png"));
            selectedLegacy.LoadImage(File.ReadAllBytes("GameData/ImpossibleInnovations/Plugins/PluginData/SmallLogoGreyON.png"));
            RUI.Icons.Selectable.Icon filterIconLegacy = new RUI.Icons.Selectable.Icon("II_filter_icon_legacy", unselectedLegacy, selectedLegacy); //Defining filterIconLegacy

            PartCategorizer.Category IIfilter = PartCategorizer.AddCustomFilter("Impossible Innovations", filterIcon, Color.white);

            //filters for all II parts
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "All Impossible Innovations Parts", filterIcon, o => o.manufacturer == "Impossible Innovations" && !o.title.Contains("(LEGACY)"));
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Tanks", filterIcon, p => p.resourceInfos.Exists(q => q.resourceName == "Deuterium" || q.resourceName == "Tritium") && p.manufacturer == "Impossible Innovations");
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Engines", filterIcon, r => r.title.Contains("Fusion Engine") && r.manufacturer == "Impossible Innovations");
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "CL-20 Boosters", filterIcon, s => s.resourceInfos.Exists(t => t.resourceName == "CL-20") && s.manufacturer == "Impossible Innovations");
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Ionized Wings", filterIcon, u => u.title.Contains("Ionized") && !u.title.Contains("(LEGACY)") && u.manufacturer == "Impossible Innovations");
            PartCategorizer.AddCustomSubcategoryFilter(IIfilter, "Legacy Parts", filterIconLegacy, v => v.title.Contains("(LEGACY)") && v.manufacturer == "Impossible Innovations");
        }
Ejemplo n.º 5
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.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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
0
        void BDAWeaponsCategory()
        {
            const string customCategoryName        = "BDAWeapons";
            const string customDisplayCategoryName = "BDA Weapons";

            availableParts.Clear();
            availableParts.AddRange(PartLoader.LoadedPartsList.BDAParts());

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

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

            PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by function");

            PartCategorizer.AddCustomSubcategoryFilter(filter, customCategoryName, customDisplayCategoryName, icon,
                                                       p => availableParts.Contains(p));
        }
Ejemplo n.º 15
0
        void BDAWeaponsCategory()
        {
            const string FILTER_CATEGORY = "Filter by Function";
            const string CUSTOM_CATEGORY_NAME = "BDA Weapons";

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

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

            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, false);
        }
Ejemplo n.º 16
0
		void BDAWeaponsCategory()
		{
			const string FILTER_CATEGORY = "Filter by Function";
			const string CUSTOM_CATEGORY_NAME = "BDA Weapons";

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

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


			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, false);
		}
Ejemplo n.º 17
0
        private void SubCategory()
        {
            Debug.Log("Adding KerBalloons Catagory");
            const string FILTER_CATEGORY      = "Filter by Function";
            const string CUSTOM_CATEGORY_NAME = "KerBalloons";



            Texture2D iconTexNormal   = GameDatabase.Instance.GetTexture("KerBalloons/Textures/KBIconNormal", false);
            Texture2D iconTexSelected = GameDatabase.Instance.GetTexture("KerBalloons/Textures/KBIconSelected", false);

            Icon icon = new Icon("KerBalloons", iconTexNormal, iconTexSelected, false);

            PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == FILTER_CATEGORY);
            PartCategorizer.AddCustomSubcategoryFilter(filter, CUSTOM_CATEGORY_NAME, icon, p => availableParts.Contains(p));

            UIRadioButton button = filter.button.activeButton;
        }
Ejemplo n.º 18
0
        public static void Load()
        {
            GameDatabase.TextureInfo texInfo = null;
            Texture2D selectedTex            = null;
            var       texDict = new Dictionary <string, GameDatabase.TextureInfo>();

            for (int i = GameDatabase.Instance.databaseTexture.Count - 1; i >= 0; --i)
            {
                texInfo = GameDatabase.Instance.databaseTexture[i];
                if (texInfo.texture != null && texInfo.texture.width == 32 && texInfo.texture.height == 32)
                {
                    Debug.Log("[INVENTORY] textures");
                    if (!texDict.ContainsKey(texInfo.name))
                    {
                        texDict.Add(texInfo.name, texInfo);
                    }
                }
            }

            foreach (KeyValuePair <string, GameDatabase.TextureInfo> kvp in texDict)
            {
                if (kvp.Value.name.Contains("_selected"))
                {
                    continue;
                }

                if (texDict.TryGetValue(kvp.Value.name + "_selected", out texInfo))
                {
                    selectedTex = texInfo.texture;
                }
                else
                {
                    selectedTex = kvp.Value.texture;
                }

                string[] paths = kvp.Value.name.Split(new char[] { '/', '\\' });
                string   name  = paths[paths.Length - 1];
                var      icon  = new RUI.Icons.Selectable.Icon(name, kvp.Value.texture, selectedTex, false);
                if (!IconDict.ContainsKey(icon.name))
                {
                    IconDict.Add(icon.name, icon);
                }
            }
        }
Ejemplo n.º 19
0
        void NASCategoryFunc()
        {
            const string customCategoryName = "NAS";

            availableParts.Clear();
            availableParts.AddRange(PartLoader.LoadedPartsList.NASParts());
            Texture2D iconTex = GameDatabase.Instance.GetTexture("NAS/Plugins/NASIcon", false);

            RUI.Icons.Selectable.Icon icon   = new RUI.Icons.Selectable.Icon("NAS", iconTex, iconTex, false);
            PartCategorizer.Category  filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");

            if (filter == null)
            {
                Debug.Log("filter is null");
            }
            else
            {
                PartCategorizer.AddCustomSubcategoryFilter(filter, customCategoryName, Localizer.Format("#autoLOC_NAS_Category"), icon, p => availableParts.Contains(p));
            }
        }
Ejemplo n.º 20
0
        void BDAWeaponsCategory()
        {
            const string customCategoryName        = "BDAWeapons";
            const string customDisplayCategoryName = "BDA Weapons";

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

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

            PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == "#autoLOC_453547");

            PartCategorizer.AddCustomSubcategoryFilter(filter, customCategoryName, customDisplayCategoryName, icon,
                                                       avPart => availableParts.Contains(avPart));


            // dump parts to .CSV list
            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                dumpParts();
            }
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Add the function filter to the filter
        /// </summary>
        private void KPBSFunctionFilter()
        {
            if (!isValid)
            {
                Debug.LogError("[KPBS] invalid");
                return;
            }

            RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_lifeSupport", icon_surface_structures, icon_surface_structures, true);

            if (filterIconSurfaceStructures == null)
            {
                Debug.LogError("[KPBS] ERROR filterIconSurfaceStructures cannot be loaded");
                return;
            }

            //Find the function filter
            PartCategorizer.Category functionFilter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == filterName);

            //Add a new subcategory to the function filter
            PartCategorizer.AddCustomSubcategoryFilter(functionFilter, functionFilterName, functionFilterName, filterIconSurfaceStructures, p => filter_KKAOSS(p));
        }
Ejemplo n.º 24
0
        private void addIIfilter()
        {
            //Loading Textures
            Texture2D unselected = new Texture2D(32, 32);
            Texture2D selected   = new Texture2D(32, 32);

            try
            {
                {
                    string fn = KSPe.IO.File <CategoryFilter> .Asset.Solve("Icons/normal.png");

                    unselected = KSPe.Util.Image.Texture2D.LoadFromFile(fn);
                }
                {
                    string fn = KSPe.IO.File <CategoryFilter> .Asset.Solve("Icons/selected.png");

                    selected = KSPe.Util.Image.Texture2D.LoadFromFile(fn);
                }
                RUI.Icons.Selectable.Icon filterIcon = new RUI.Icons.Selectable.Icon("FS_filter_icon", unselected, selected);     //Defining filterIcon

                PartCategorizer.Category filter = PartCategorizer.AddCustomFilter(Constants.PLUGIN_ID, Constants.MANUFACTURER_NAME, filterIcon, Color.white);

                //filters for all II parts
                PartCategorizer.AddCustomSubcategoryFilter(filter, "AllParts", string.Format("All {0} Parts", Constants.MANUFACTURER_NAME), filterIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(filter, "CommandPods", "Command Pods", filterIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString() == "Pods" && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(filter, "Control", "Control", filterIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString().Contains("Control") && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(filter, "Tanks", "Tanks", filterIcon, p => p.resourceInfos.Exists(q => q.resourceName == "Fuel" || q.resourceName == "Oxidizer" || q.resourceName == "Monoprolellent") && p.manufacturer == Constants.MANUFACTURER_NAME && !p.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(filter, "Electrical", "Electrical", filterIcon, o => o.manufacturer == Constants.MANUFACTURER_NAME && o.category.ToString() == "Electrical" && !o.title.Contains("(LEGACY)"));
                PartCategorizer.AddCustomSubcategoryFilter(filter, "Engines", "Engines", filterIcon, r => r.title.Contains("Fusion Engine") && r.manufacturer == Constants.MANUFACTURER_NAME);
                PartCategorizer.AddCustomSubcategoryFilter(filter, "Floaters", "Floaters", filterIcon, r => r.title.Contains("Fusion Engine") && r.manufacturer == Constants.MANUFACTURER_NAME);
            }
            catch (Exception e)
            {
                Log.ex(this, e);
            }
        }
Ejemplo n.º 25
0
        /**
         * The function to add the modules of this mod to a separate category
         */
        private void KKAOSS_Filter()
        {
            Debug.Log("[KPBS] KKAOSS_Filter");
            if (!isValid)
            {
                Debug.Log("[KPBS] invalid");
                return;
            }

            //if the configuration is null
            if (KPBSConfiguration.Instance() == null)
            {
                Debug.Log("[KPBS] ERROR Configuration Instance is null");
                return;
            }
            //when the textures could not be loaded
            List <AvailablePart> LS_parts = PartLoader.Instance.parts.FindAll(ap => ap.name.StartsWith("KKAOSS.LS"));

            //----------------manufacturer------------------

            if (KPBSConfiguration.Instance().ShowManufacturer)
            {
                Debug.Log("[KPBS] manufacturer icons");

                RUI.Icons.Selectable.Icon filterIconKandK = new RUI.Icons.Selectable.Icon("KKAOSS_icon_k_and_k", icon_k_and_k, icon_k_and_k, true);
                RUI.Icons.Selectable.Icon filterIconKLife = new RUI.Icons.Selectable.Icon("KKAOSS_icon_k_lifesupport", icon_k_lifesupport, icon_k_lifesupport, true);

                if (filterIconKandK == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconKandK cannot be loaded");
                    return;
                }

                if (filterIconKLife == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconKLife cannot be loaded");
                    return;
                }


                //get manufacturer filter
                KSP.UI.Screens.PartCategorizer.Category manufacturerFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Manufacturer");

                //add the manufacturers
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(manufacturerFilter, manufacturer1, filterIconKandK, p => filterManufacturer(p, manufacturer1));

                //when there are life support parts available, add them to the new manufacturer
                List <AvailablePart> parts = PartLoader.Instance.parts.FindAll(ap => (ap.category == PartCategories.Utility && ap.name.StartsWith("KKAOSS.LS")));
                if (parts.Count > 0)
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(manufacturerFilter, manufacturer3, filterIconKLife, p => filterManufacturer(p, manufacturer3));
                }
            }
            //----------------end manufacturer--------------

            //-----------------own category-----------------

            if ((KPBSConfiguration.Instance().ShowModFilter) && (!KPBSConfiguration.Instance().ShowSeparateFunctionCategory))
            {
                Debug.Log("[KPBS] category");

                //create the icon for the filter
                RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_surface_structures, icon_surface_structures, true);

                //icons for KPSS's own category
                RUI.Icons.Selectable.Icon ic_pods        = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("RDicon_commandmodules");
                RUI.Icons.Selectable.Icon ic_fuels       = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("RDicon_fuelSystems-advanced");
                RUI.Icons.Selectable.Icon ic_engine      = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generalrocketry");
                RUI.Icons.Selectable.Icon ic_structural  = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generalconstruction");
                RUI.Icons.Selectable.Icon ic_aero        = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_stability");
                RUI.Icons.Selectable.Icon ic_utility     = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generic");
                RUI.Icons.Selectable.Icon ic_science     = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_advsciencetech");
                RUI.Icons.Selectable.Icon ic_lifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                if (ic_pods == null)
                {
                    Debug.Log("[KPBS] ERROR ic_pods cannot be loaded");
                    return;
                }
                if (ic_fuels == null)
                {
                    Debug.Log("[KPBS] ERROR ic_fuels cannot be loaded");
                    return;
                }
                if (ic_engine == null)
                {
                    Debug.Log("[KPBS] ERROR ic_engine cannot be loaded");
                    return;
                }
                if (ic_structural == null)
                {
                    Debug.Log("[KPBS] ERROR ic_structural cannot be loaded");
                    return;
                }
                if (ic_aero == null)
                {
                    Debug.Log("[KPBS] ERROR ic_aero cannot be loaded");
                    return;
                }
                if (ic_utility == null)
                {
                    Debug.Log("[KPBS] ERROR ic_utility cannot be loaded");
                    return;
                }
                if (ic_science == null)
                {
                    Debug.Log("[KPBS] ERROR ic_science cannot be loaded");
                    return;
                }
                if (ic_lifeSupport == null)
                {
                    Debug.Log("[KPBS] ERROR ic_lifeSupport cannot be loaded");
                    return;
                }

                //add KPSS to the categories
                KSP.UI.Screens.PartCategorizer.Category surfaceStructureFilter = KSP.UI.Screens.PartCategorizer.AddCustomFilter("Planetary Surface Structures", filterIconSurfaceStructures, new Color(0.63f, 0.85f, 0.63f));

                //add subcategories to the KPSS category you just added
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Pods", ic_pods, p => filterCategories(p, PartCategories.Pods));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Fuel Tank", ic_fuels, p => filterCategories(p, PartCategories.FuelTank));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Engines", ic_engine, p => filterCategories(p, PartCategories.Propulsion));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Structural", ic_structural, p => filterCategories(p, PartCategories.Structural));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Aerodynamics", ic_aero, p => filterCategories(p, PartCategories.Aero));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Science", ic_science, p => filterCategories(p, PartCategories.Science));

                if (LS_parts.Count > 0)
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Life Support", ic_lifeSupport, p => filter_KKAOSS_LS(p));
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", ic_utility, p => (filterCategories(p, PartCategories.Utility) && !filter_KKAOSS_LS(p)));
                }
                else
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", ic_utility, p => (filterCategories(p, PartCategories.Utility)));
                }
            }
            //-----------------end own category-----------------

            //------------subcategory in function filter---------

            if (KPBSConfiguration.Instance().ShowSeparateFunctionCategory)
            {
                Debug.Log("[KPBS] subcategory");

                RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_lifeSupport", icon_surface_structures, icon_surface_structures, true);

                if (filterIconSurfaceStructures == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconSurfaceStructures cannot be loaded");
                    return;
                }


                //Find the function filter
                KSP.UI.Screens.PartCategorizer.Category functionFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");

                //Add a new subcategory to the function filter
                if ((KPBSConfiguration.Instance().SeparateLifeSupport) && (LS_parts.Count > 0))
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Planetary Surface Structures", filterIconSurfaceStructures, p => filter_KKAOSS_NO_LS(p));
                }
                else
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Planetary Surface Structures", filterIconSurfaceStructures, p => filter_KKAOSS(p));
                }

                //Force the icon to show (>_<)
                //RUIToggleButtonTyped button = functionFilter.button.activeButton;
                //button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
                //button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);

                List <AvailablePart> parts = PartLoader.Instance.parts.FindAll(ap => ap.name.StartsWith("KKAOSS"));

                //iterate over all categories and remove them from the list
                //set all the categories to none to prevent this part to be added
                foreach (AvailablePart part in parts)
                {
                    part.category = PartCategories.none;
                }
            }

            //---------end subcategory in function filter-------

            //------------subcategory for life support---------

            //when life support should be separated
            if (KPBSConfiguration.Instance().SeparateLifeSupport)
            {
                Debug.Log("[KPBS] life support");

                Debug.Log("[KPBS] Life Support Modules found: " + LS_parts.Count());

                //only continue when there are parts for life support
                if (LS_parts.Count() > 0)
                {
                    RUI.Icons.Selectable.Icon filterIconLifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                    if (filterIconLifeSupport == null)
                    {
                        Debug.Log("[KPBS] ERROR filterIconLifeSupport cannot be loaded");
                        return;
                    }

                    //Find the function filter
                    KSP.UI.Screens.PartCategorizer.Category functionFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Life Support", filterIconLifeSupport, p => filter_KKAOSS_LS(p));

                    //set all the categories to none to prevent this part to be added
                    foreach (AvailablePart part in LS_parts)
                    {
                        part.category = PartCategories.none;
                    }

                    //add the greenhouse the the LS mods when other ls mods were found
                    List <AvailablePart> greenhouses = PartLoader.Instance.parts.FindAll(ap => ap.name.Equals("KKAOSS.Greenhouse.g"));
                    foreach (AvailablePart part in greenhouses)
                    {
                        part.category = PartCategories.none;
                    }

                    //Force the icon to show (>_<)
                    //RUIToggleButtonTyped button = functionFilter.button.activeButton;
                    //button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
                    //button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
                }
            }

            //---------end subcategory for life support-------
        }
        /*/// <summary>
         * /// Add the function filter to the filter
         * /// </summary>
         * private void KerbetrotterFunctionFilter()
         * {
         *  if (!isValid)
         *  {
         *      Debug.LogError("[KerbetrotterTools] invalid");
         *      return;
         *  }
         *
         *  RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_lifeSupport", icon_surface_structures, icon_surface_structures, true);
         *
         *  if (filterIconSurfaceStructures == null)
         *  {
         *      Debug.LogError("[KerbetrotterTools] ERROR filterIconSurfaceStructures cannot be loaded");
         *      return;
         *  }
         *
         *  //Find the function filter
         *  PartCategorizer.Category functionFilter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == filterName);
         *
         *  //Add a new subcategory to the function filter
         *  PartCategorizer.AddCustomSubcategoryFilter(functionFilter, functionFilterName, filterIconSurfaceStructures, p => filter_KKAOSS(p));
         * }*/


        /**
         * The function to add the modules of this mod to a separate category
         */
        private void KerbetrotterFilter()
        {
            if (!isValid)
            {
                Debug.Log("[KerbetrotterTools] invalid");
                return;
            }

            //if the configuration is null
            if (KerbetrotterConfiguration.Instance() == null)
            {
                Debug.Log("[] ERROR Configuration Instance is null");
                return;
            }

            //get the filterSetings for the kerbetrotter tools
            KerbetrotterFilterSettings[] filterSettings = KerbetrotterConfiguration.Instance().FilterSettings;

            //icons for KPSS's own category
            RUI.Icons.Selectable.Icon ic_pods          = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_pods", icon_filter_pods, icon_filter_pods, true);
            RUI.Icons.Selectable.Icon ic_aero          = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_aero", icon_filter_pods, icon_filter_pods, true);
            RUI.Icons.Selectable.Icon ic_control       = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_control", icon_filter_pods, icon_filter_pods, true);
            RUI.Icons.Selectable.Icon ic_communication = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_comm", icon_filter_pods, icon_filter_pods, true);
            RUI.Icons.Selectable.Icon ic_fuels         = new RUI.Icons.Selectable.Icon("Kerbetrotter__filter_fuel", icon_filter_fuel, icon_filter_fuel, true);
            RUI.Icons.Selectable.Icon ic_engine        = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_engine", icon_filter_engine, icon_filter_engine, true);
            RUI.Icons.Selectable.Icon ic_structural    = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_structural", icon_filter_construction, icon_filter_construction, true);
            RUI.Icons.Selectable.Icon ic_payload       = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_payload", icon_filter_payload, icon_filter_payload, true);
            RUI.Icons.Selectable.Icon ic_utility       = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_utility", icon_filter_utility, icon_filter_utility, true);
            RUI.Icons.Selectable.Icon ic_coupling      = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_coupling", icon_filter_coupling, icon_filter_coupling, true);
            RUI.Icons.Selectable.Icon ic_ground        = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_ground", icon_filter_ground, icon_filter_ground, true);
            RUI.Icons.Selectable.Icon ic_thermal       = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_thermal", icon_filter_thermal, icon_filter_thermal, true);
            RUI.Icons.Selectable.Icon ic_electrical    = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_electrical", icon_filter_electrical, icon_filter_electrical, true);
            RUI.Icons.Selectable.Icon ic_science       = new RUI.Icons.Selectable.Icon("Kerbetrotter_filter_fuel", icon_filter_science, icon_filter_science, true);
            RUI.Icons.Selectable.Icon ic_lifeSupport   = new RUI.Icons.Selectable.Icon("Kerbetrotter_icon_life_support", icon_filter_lifesupport, icon_filter_lifesupport, true);


            int numFilter = filterSettings.Length;

            for (int i = 0; i < numFilter; i++)
            {
                //-----------------own category-----------------

                if (filterSettings[i].ShowModFilter)
                {
                    List <PartCategories> availableCategories = new List <PartCategories>(15);
                    availableCategories.Add(PartCategories.Aero);
                    availableCategories.Add(PartCategories.Communication);
                    availableCategories.Add(PartCategories.Control);
                    availableCategories.Add(PartCategories.Coupling);
                    availableCategories.Add(PartCategories.Electrical);
                    //availableCategories.Add(PartCategories.Engine);//NEEDED?
                    availableCategories.Add(PartCategories.FuelTank);
                    availableCategories.Add(PartCategories.Ground);
                    //leftCategories.Add(PartCategories.none);
                    availableCategories.Add(PartCategories.Payload);
                    availableCategories.Add(PartCategories.Pods);
                    availableCategories.Add(PartCategories.Propulsion);
                    availableCategories.Add(PartCategories.Science);
                    availableCategories.Add(PartCategories.Structural);
                    availableCategories.Add(PartCategories.Thermal);
                    availableCategories.Add(PartCategories.Utility);

                    List <PartCategories> usedCategories = new List <PartCategories>();

                    int numParts = partCategories[i].Count;
                    foreach (KeyValuePair <string, PartCategories> entry in partCategories[i])
                    {
                        if (availableCategories.Contains(entry.Value))
                        {
                            usedCategories.Add(entry.Value);
                            availableCategories.Remove(entry.Value);
                        }
                    }

                    if (usedCategories.Count > 0)
                    {
                        //create the icon for the filter
                        RUI.Icons.Selectable.Icon filterIcon = new RUI.Icons.Selectable.Icon(filterSettings[i].ModName + "_icon_mod", icon_filter[i], icon_filter[i], true);

                        //add the mod to the categories to the categories
                        Color color = filterSettings[i].Color;
                        PartCategorizer.Category modFilter = PartCategorizer.AddCustomFilter(filterSettings[i].ModName, filterSettings[i].ModName, filterIcon, new Color(color.r, color.g, color.b));

                        int index = i;

                        //add subcategories to the KPSS category you just added  #autoLOC_453549
                        if (usedCategories.Contains(PartCategories.Pods))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Pods", Localizer.GetStringByTag("#autoLOC_453549"), ic_pods, p => filterCategories(p, PartCategories.Pods, index));
                        }

                        if (usedCategories.Contains(PartCategories.FuelTank))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Fuel Tank", Localizer.GetStringByTag("#autoLOC_453552"), ic_fuels, p => filterCategories(p, PartCategories.FuelTank, index));
                        }

                        if (usedCategories.Contains(PartCategories.Propulsion))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Engines", Localizer.GetStringByTag("#autoLOC_453555"), ic_engine, p => filterCategories(p, PartCategories.Propulsion, index));
                        }

                        if (usedCategories.Contains(PartCategories.Control))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Control", Localizer.GetStringByTag("#autoLOC_453558"), ic_control, p => filterCategories(p, PartCategories.Control, index));
                        }

                        if (usedCategories.Contains(PartCategories.Structural))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Structural", Localizer.GetStringByTag("#autoLOC_453561"), ic_structural, p => filterCategories(p, PartCategories.Structural, index));
                        }

                        if (usedCategories.Contains(PartCategories.Coupling))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Coupling", Localizer.GetStringByTag("#autoLOC_453564"), ic_coupling, p => filterCategories(p, PartCategories.Coupling, index));
                        }

                        if (usedCategories.Contains(PartCategories.Payload))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Payload", Localizer.GetStringByTag("#autoLOC_453567"), ic_payload, p => filterCategories(p, PartCategories.Payload, index));
                        }

                        if (usedCategories.Contains(PartCategories.Aero))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Aerodynamics", Localizer.GetStringByTag("#autoLOC_453570"), ic_aero, p => filterCategories(p, PartCategories.Aero, index));
                        }

                        if (usedCategories.Contains(PartCategories.Ground))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Ground", Localizer.GetStringByTag("#autoLOC_453573"), ic_ground, p => filterCategories(p, PartCategories.Ground, index));
                        }

                        if (usedCategories.Contains(PartCategories.Thermal))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Thermal", Localizer.GetStringByTag("#autoLOC_453576"), ic_thermal, p => filterCategories(p, PartCategories.Thermal, index));
                        }

                        if (usedCategories.Contains(PartCategories.Electrical))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Electrical", Localizer.GetStringByTag("#autoLOC_453579"), ic_electrical, p => filterCategories(p, PartCategories.Electrical, index));
                        }

                        if (usedCategories.Contains(PartCategories.Communication))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Communication", Localizer.GetStringByTag("#autoLOC_453582"), ic_communication, p => filterCategories(p, PartCategories.Communication, index));
                        }

                        if (usedCategories.Contains(PartCategories.Science))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Science", Localizer.GetStringByTag("#autoLOC_453585"), ic_science, p => filterCategories(p, PartCategories.Science, index));
                        }

                        if (usedCategories.Contains(PartCategories.Utility))
                        {
                            PartCategorizer.AddCustomSubcategoryFilter(modFilter, "Utility", Localizer.GetStringByTag("#autoLOC_453588"), ic_utility, p => (filterCategories(p, PartCategories.Utility, index)));
                        }
                    }
                }
                //-----------------end own category-----------------

                //------------subcategory in function filter---------
                if (filterSettings [i].ShowFunctionFilter && (!CCKavailable || !filterSettings[i].DisableForCCK))
                {
                    RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("Kerbetrotter_function filter", icon_filter[i], icon_filter[i], true);

                    if (filterIconSurfaceStructures == null)
                    {
                        Debug.Log("[KerbetrotterTools] ERROR FilterIcon cannot be loaded for: " + filterSettings[i].ModName);
                        return;
                    }

                    //Find the function filter
                    PartCategorizer.Category functionFilter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by function");

                    int index = i;

                    //Add a new subcategory to the function filter
                    PartCategorizer.AddCustomSubcategoryFilter(functionFilter, filterSettings[i].ModName, filterSettings[i].ModName, filterIconSurfaceStructures, p => filterPart(p, index));

                    //Remove the parts from all other categories
                    if (filterSettings[i].ShowInOneFilterOnly)
                    {
                        List <AvailablePart> parts = PartLoader.Instance.loadedParts.FindAll(ap => filterPart(ap, index));

                        for (int j = 0; j < parts.Count; j++)
                        {
                            parts[j].category = PartCategories.none;
                        }
                    }
                }
                //hide the parts from other functions when CCK is installed
                else if (CCKavailable && filterSettings[i].ShowInOneFilterOnly)
                {
                    int index = i;

                    //Remove the parts from all other categories
                    if (filterSettings[i].ShowInOneFilterOnly)
                    {
                        List <AvailablePart> parts = PartLoader.Instance.loadedParts.FindAll(ap => filterPart(ap, index));

                        for (int j = 0; j < parts.Count; j++)
                        {
                            parts[j].category = PartCategories.none;
                        }
                    }
                }
                //---------end subcategory in function filter-------
            }
        }
        /**
         * The function to add the modules of this mod to a separate category
         */
        private void KKAOSS_Filter()
        {
            Debug.Log("[KPBS] KKAOSS_Filter");
            if (!isValid)
            {
                Debug.Log("[KPBS] invalid");
                return;
            }

            //if the configuration is null
            if (KPBSConfiguration.Instance() == null)
            {
                Debug.Log("[KPBS] ERROR Configuration Instance is null");
                return;
            }
            //when the textures could not be loaded
            List<AvailablePart> LS_parts = PartLoader.Instance.parts.FindAll(ap => ap.name.StartsWith("KKAOSS.LS"));

            //----------------manufacturer------------------

            if (KPBSConfiguration.Instance().ShowManufacturer)
            {
                Debug.Log("[KPBS] manufacturer icons");

                RUI.Icons.Selectable.Icon filterIconKandK = new RUI.Icons.Selectable.Icon("KKAOSS_icon_k_and_k", icon_k_and_k, icon_k_and_k, true);
                RUI.Icons.Selectable.Icon filterIconKLife = new RUI.Icons.Selectable.Icon("KKAOSS_icon_k_lifesupport", icon_k_lifesupport, icon_k_lifesupport, true);

                if (filterIconKandK == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconKandK cannot be loaded");
                    return;
                }

                if (filterIconKLife == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconKLife cannot be loaded");
                    return;
                }

                //get manufacturer filter
                KSP.UI.Screens.PartCategorizer.Category manufacturerFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Manufacturer");

                //add the manufacturers
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(manufacturerFilter, manufacturer1, filterIconKandK, p => filterManufacturer(p, manufacturer1));

                //when there are life support parts available, add them to the new manufacturer
                List<AvailablePart> parts = PartLoader.Instance.parts.FindAll(ap => (ap.category == PartCategories.Utility && ap.name.StartsWith("KKAOSS.LS")));
                if (parts.Count > 0)
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(manufacturerFilter, manufacturer3, filterIconKLife, p => filterManufacturer(p, manufacturer3));
                }
            }
            //----------------end manufacturer--------------

            //-----------------own category-----------------

            if ((KPBSConfiguration.Instance().ShowModFilter) && (!KPBSConfiguration.Instance().ShowSeparateFunctionCategory))
            {
                Debug.Log("[KPBS] category");

                //create the icon for the filter
                RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_surface_structures, icon_surface_structures, true);

                //icons for KPSS's own category
                RUI.Icons.Selectable.Icon ic_pods = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("RDicon_commandmodules");
                RUI.Icons.Selectable.Icon ic_fuels = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("RDicon_fuelSystems-advanced");
                RUI.Icons.Selectable.Icon ic_engine = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generalrocketry");
                RUI.Icons.Selectable.Icon ic_structural = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generalconstruction");
                RUI.Icons.Selectable.Icon ic_aero = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_stability");
                RUI.Icons.Selectable.Icon ic_utility = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_generic");
                RUI.Icons.Selectable.Icon ic_science = KSP.UI.Screens.PartCategorizer.Instance.iconLoader.GetIcon("R&D_node_icon_advsciencetech");
                RUI.Icons.Selectable.Icon ic_lifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                if (ic_pods == null)
                {
                    Debug.Log("[KPBS] ERROR ic_pods cannot be loaded");
                    return;
                }
                if (ic_fuels == null)
                {
                    Debug.Log("[KPBS] ERROR ic_fuels cannot be loaded");
                    return;
                }
                if (ic_engine == null)
                {
                    Debug.Log("[KPBS] ERROR ic_engine cannot be loaded");
                    return;
                }
                if (ic_structural == null)
                {
                    Debug.Log("[KPBS] ERROR ic_structural cannot be loaded");
                    return;
                }
                if (ic_aero == null)
                {
                    Debug.Log("[KPBS] ERROR ic_aero cannot be loaded");
                    return;
                }
                if (ic_utility == null)
                {
                    Debug.Log("[KPBS] ERROR ic_utility cannot be loaded");
                    return;
                }
                if (ic_science == null)
                {
                    Debug.Log("[KPBS] ERROR ic_science cannot be loaded");
                    return;
                }
                if (ic_lifeSupport == null)
                {
                    Debug.Log("[KPBS] ERROR ic_lifeSupport cannot be loaded");
                    return;
                }

                //add KPSS to the categories
                KSP.UI.Screens.PartCategorizer.Category surfaceStructureFilter = KSP.UI.Screens.PartCategorizer.AddCustomFilter("Planetary Surface Structures", filterIconSurfaceStructures, new Color(0.63f, 0.85f, 0.63f));

                //add subcategories to the KPSS category you just added
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Pods", ic_pods, p => filterCategories(p, PartCategories.Pods));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Fuel Tank", ic_fuels, p => filterCategories(p, PartCategories.FuelTank));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Engines", ic_engine, p => filterCategories(p, PartCategories.Propulsion));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Structural", ic_structural, p => filterCategories(p, PartCategories.Structural));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Aerodynamics", ic_aero, p => filterCategories(p, PartCategories.Aero));
                KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Science", ic_science, p => filterCategories(p, PartCategories.Science));

                if (LS_parts.Count > 0)
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Life Support", ic_lifeSupport, p => filter_KKAOSS_LS(p));
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", ic_utility, p => (filterCategories(p, PartCategories.Utility) && !filter_KKAOSS_LS(p)));
                }
                else
                {
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", ic_utility, p => (filterCategories(p, PartCategories.Utility)));
                }

            }
            //-----------------end own category-----------------

            //------------subcategory in function filter---------

            if (KPBSConfiguration.Instance().ShowSeparateFunctionCategory)
            {
                Debug.Log("[KPBS] subcategory");

                RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_lifeSupport", icon_surface_structures, icon_surface_structures, true);

                if (filterIconSurfaceStructures == null)
                {
                    Debug.Log("[KPBS] ERROR filterIconSurfaceStructures cannot be loaded");
                    return;
                }

                //Find the function filter
                KSP.UI.Screens.PartCategorizer.Category functionFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");

                //Add a new subcategory to the function filter
                if ((KPBSConfiguration.Instance().SeparateLifeSupport) && (LS_parts.Count > 0))
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Planetary Surface Structures", filterIconSurfaceStructures, p => filter_KKAOSS_NO_LS(p));
                else
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Planetary Surface Structures", filterIconSurfaceStructures, p => filter_KKAOSS(p));

                //Force the icon to show (>_<)
                //RUIToggleButtonTyped button = functionFilter.button.activeButton;
                //button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
                //button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);

                List<AvailablePart> parts = PartLoader.Instance.parts.FindAll(ap => ap.name.StartsWith("KKAOSS"));

                //iterate over all categories and remove them from the list
                //set all the categories to none to prevent this part to be added
                foreach (AvailablePart part in parts)
                {
                    part.category = PartCategories.none;
                }
            }

            //---------end subcategory in function filter-------

            //------------subcategory for life support---------

            //when life support should be separated
            if (KPBSConfiguration.Instance().SeparateLifeSupport)
            {
                Debug.Log("[KPBS] life support");

                Debug.Log("[KPBS] Life Support Modules found: " + LS_parts.Count());

                //only continue when there are parts for life support
                if (LS_parts.Count() > 0)
                {
                    RUI.Icons.Selectable.Icon filterIconLifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                    if (filterIconLifeSupport == null)
                    {
                        Debug.Log("[KPBS] ERROR filterIconLifeSupport cannot be loaded");
                        return;
                    }

                    //Find the function filter
                    KSP.UI.Screens.PartCategorizer.Category functionFilter = KSP.UI.Screens.PartCategorizer.Instance.filters.Find(f => f.button.categoryName == "Filter by Function");
                    KSP.UI.Screens.PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Life Support", filterIconLifeSupport, p => filter_KKAOSS_LS(p));

                    //set all the categories to none to prevent this part to be added
                    foreach (AvailablePart part in LS_parts)
                    {
                        part.category = PartCategories.none;
                    }

                    //add the greenhouse the the LS mods when other ls mods were found
                    List<AvailablePart> greenhouses = PartLoader.Instance.parts.FindAll(ap => ap.name.Equals("KKAOSS.Greenhouse.g"));
                    foreach (AvailablePart part in greenhouses)
                    {
                        part.category = PartCategories.none;
                    }

                    //Force the icon to show (>_<)
                    //RUIToggleButtonTyped button = functionFilter.button.activeButton;
                    //button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
                    //button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
                }
            }

            //---------end subcategory for life support-------
        }
Ejemplo n.º 28
0
        private void CreateBDAPartBar()
        {
            // Check if we need the special categories
            bool          foundLegacy     = false;
            bool          foundMisc       = false;
            List <string> foundCategories = new List <string>();

            using (var parts = PartLoader.LoadedPartsList.GetEnumerator())
                while (parts.MoveNext())
                {
                    if (parts.Current == null || !parts.Current.partPrefab || parts.Current.partConfig == null)
                    {
                        continue;
                    }
                    string cat = "";
                    if (parts.Current.partConfig.TryGetValue(BDArmorySettings.AUTOCATEGORIZE_PARTS ? AutoBDACategoryKey : BDACategoryKey, ref cat))
                    {
                        if (!Categories.Contains(cat))
                        {
                            foundMisc = true;
                        }
                        else if (!foundCategories.Contains(cat))
                        {
                            foundCategories.Add(cat);
                        }
                    }
                    // If part does not have a bdacategory but manufacturer is BDA.
                    else if (parts.Current.manufacturer == Misc.BDAEditorTools.Manufacturer)
                    {
                        foundLegacy = true;
                    }
                }
            Categories.RemoveAll(s => !foundCategories.Contains(s) && s != "All");
            if (foundMisc && !Categories.Contains("Misc"))
            {
                Categories.Add("Misc");
            }
            if (foundLegacy && !Categories.Contains("Legacy"))
            {
                Categories.Add("Legacy");
            }

            // BDA part category bar
            var BDAPartBarContainer = new GameObject();

            BDAPartBarContainer.name = "BDAPartBarContainer";
            BDAPartBar      = BDAPartBarContainer.AddComponent <RectTransform>();
            BDAPartBar.name = "BDAPartBar";
            BDAPartBarContainer.transform.SetParent(PartCategorizer.Instance.transform, false);
            BDAPartBar.anchoredPosition = EditorPanels.Instance.partsEditorModes.panelTransform.anchoredPosition + new Vector2(-212, -126);

            // BDA part category bar background
            // DOESN'T WORK, NOTHING WORKS. :(

            // BDA part category buttons
            PartCategorizer.Category filterByFunctionCategory = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == "#autoLOC_453547");
            Vector3 button_offset = filterByFunctionCategory.subcategories[1].button.transform.position - filterByFunctionCategory.subcategories[0].button.transform.position;

            using (var category = Categories.GetEnumerator())
                while (category.MoveNext())
                {
                    // Since I don't wanna deal with drawing pretty little buttons, we're making categories,
                    // stealing the buttons, and then removing the categories.
                    Texture2D iconTex = GameDatabase.Instance.GetTexture(GetTexturePath(category.Current), false);
                    RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon("BDArmory", iconTex, iconTex, false);
                    string name = category.Current;
                    var    categorizer_button = PartCategorizer.AddCustomSubcategoryFilter(
                        filterByFunctionCategory,
                        name,
                        name,
                        icon,
                        part => PartInCurrentCategory(part)
                        );
                    var button = categorizer_button.button;
                    button.btnToggleGeneric.onClick.RemoveAllListeners();
                    button.btnToggleGeneric.onFalse.RemoveAllListeners();
                    button.btnToggleGeneric.onFalseBtn.RemoveAllListeners();
                    button.btnToggleGeneric.onTrue.RemoveAllListeners();
                    button.btnToggleGeneric.onTrueBtn.RemoveAllListeners();
                    button.btnToggleGeneric.SetGroup(412440121);
                    button.transform.SetParent(BDAPartBar, false);
                    button.transform.position = new Vector3(BDACategory.button.transform.position.x + 34, 424, 750) + button_offset * SubcategoryButtons.Count;
                    categorizer_button.DeleteSubcategory();
                    SubcategoryButtons.Add(button);
                    // Gotta use a saved value, because the enumerator changes the value during the run
                    button.btnToggleGeneric.onTrue.AddListener((x, y) => SetCategory(name));
                }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// loads all textures between 25 and 40 px in dimensions into a dictionary using the filename as a key
        /// </summary>
        private static void loadIcons()
        {
            List<GameDatabase.TextureInfo> texList = GameDatabase.Instance.databaseTexture.Where(t => t.texture != null && t.texture.height <= 40 && t.texture.width <= 40 && t.texture.width >= 25 && t.texture.height >= 25).ToList();

            Dictionary<string, GameDatabase.TextureInfo> texDict = new Dictionary<string, GameDatabase.TextureInfo>();
            // using a dictionary for looking up _selected textures. Else the list has to be iterated over for every texture
            foreach(GameDatabase.TextureInfo t in texList)
            {
                if (!texDict.ContainsKey(t.name))
                    texDict.Add(t.name, t);
                else
                {
                    int i = 1;
                    while (texDict.ContainsKey(t.name + i.ToString()) && i < 1000)
                        i++;
                    if (i < 1000)
                    {
                        texDict.Add(t.name + i.ToString(), t);
                        Log(t.name + i.ToString());
                    }
                }
            }

            Texture2D selectedTex = null;
            foreach (GameDatabase.TextureInfo t in texList)
            {
                GameDatabase.TextureInfo texInfo;
                if (texDict.TryGetValue(t.name + "_selected", out texInfo))
                    selectedTex = texInfo.texture;
                else
                    selectedTex = t.texture;

                string name = t.name.Split(new char[] { '/', '\\' }).Last();
                if (Instance.iconDict.ContainsKey(name))
                {
                    int i = 1;
                    while (Instance.iconDict.ContainsKey(name + i.ToString()) && i < 1000)
                        i++;
                    if (i != 1000)
                        name = name + i.ToString();
                    if (instance.debug)
                        Log("Duplicated texture name \"" + t.name.Split(new char[] { '/', '\\' }).Last() + "\" at:\r\n" + t.name + "\r\n New reference is: " + name);
                }

                if (!Instance.iconDict.ContainsKey(name))
                {
                    RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon(name, t.texture, selectedTex, false);
                    Instance.iconDict.Add(icon.name, icon);
                }
            }
            Destroy(selectedTex);
        }
Ejemplo n.º 30
0
 private void SubCategories()
 {
     RUI.Icons.Selectable.Icon filterDeepFreeze = new RUI.Icons.Selectable.Icon("DeepFreezeEditor", icon_DeepFreeze_Editor, icon_DeepFreeze_Editor, true);
     PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
     PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, filterDeepFreeze, p => EditorItemsFilter(p));
     RUIToggleButtonTyped button = Filter.button.activeButton;
     button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
     button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
 }
Ejemplo n.º 31
0
        /// <summary>
        /// The function to add the modules of this mod to a separate category.
        /// </summary>
        private void KPBSMainFilter()
        {
            if (!isValid)
            {
                Debug.LogError("[KPBS] invalid");
                return;
            }

            //if the configuration is null
            if (KPBSConfiguration.Instance() == null)
            {
                Debug.LogError("[KPBS] ERROR Configuration Instance is null");
                return;
            }

            //-----------------own category-----------------
            if (KPBSConfiguration.Instance().ShowModFilter)
            {
                //create the icon for the filter
                RUI.Icons.Selectable.Icon filterIconSurfaceStructures = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_surface_structures, icon_surface_structures, true);

                //icons for KPSS's own category
                RUI.Icons.Selectable.Icon ic_pods        = new RUI.Icons.Selectable.Icon("KKAOSS_filter_pods", icon_filter_pods, icon_filter_pods, true);
                RUI.Icons.Selectable.Icon ic_fuels       = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_fuel, icon_filter_fuel, true);
                RUI.Icons.Selectable.Icon ic_engine      = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_engine, icon_filter_engine, true);
                RUI.Icons.Selectable.Icon ic_structural  = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_construction, icon_filter_construction, true);
                RUI.Icons.Selectable.Icon ic_payload     = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_payload, icon_filter_payload, true);
                RUI.Icons.Selectable.Icon ic_utility     = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_utility, icon_filter_utility, true);
                RUI.Icons.Selectable.Icon ic_coupling    = new RUI.Icons.Selectable.Icon("KKAOSS_filter_coupling", icon_filter_coupling, icon_filter_coupling, true);
                RUI.Icons.Selectable.Icon ic_ground      = new RUI.Icons.Selectable.Icon("KKAOSS_filter_ground", icon_filter_ground, icon_filter_ground, true);
                RUI.Icons.Selectable.Icon ic_thermal     = new RUI.Icons.Selectable.Icon("KKAOSS_filter_thermal", icon_filter_thermal, icon_filter_thermal, true);
                RUI.Icons.Selectable.Icon ic_electrical  = new RUI.Icons.Selectable.Icon("KKAOSS_filter_electrical", icon_filter_electrical, icon_filter_electrical, true);
                RUI.Icons.Selectable.Icon ic_science     = new RUI.Icons.Selectable.Icon("KKAOSS_filter_fuel", icon_filter_science, icon_filter_science, true);
                RUI.Icons.Selectable.Icon ic_lifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                //add KPBS to the categories
                PartCategorizer.Category surfaceStructureFilter = KSP.UI.Screens.PartCategorizer.AddCustomFilter("Planetary Surface Structures", functionFilterName, filterIconSurfaceStructures, new Color(0.63f, 0.85f, 0.63f));

                //add subcategories to the KPSS category you just added
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Pods", Localizer.GetStringByTag("#autoLOC_453549"), ic_pods, p => filterCategories(p, PartCategories.Pods));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Fuel Tank", Localizer.GetStringByTag("#autoLOC_453552"), ic_fuels, p => filterCategories(p, PartCategories.FuelTank));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Engines", Localizer.GetStringByTag("#autoLOC_453555"), ic_engine, p => filterCategories(p, PartCategories.Propulsion));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Structural", Localizer.GetStringByTag("#autoLOC_453561"), ic_structural, p => filterCategories(p, PartCategories.Structural));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Coupling", Localizer.GetStringByTag("#autoLOC_453564"), ic_coupling, p => filterCategories(p, PartCategories.Coupling));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Payload", Localizer.GetStringByTag("#autoLOC_453567"), ic_payload, p => filterCategories(p, PartCategories.Payload));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Ground", Localizer.GetStringByTag("#autoLOC_453573"), ic_ground, p => filterCategories(p, PartCategories.Ground));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Thermal", Localizer.GetStringByTag("#autoLOC_453576"), ic_thermal, p => filterCategories(p, PartCategories.Thermal));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Electrical", Localizer.GetStringByTag("#autoLOC_453579"), ic_electrical, p => filterCategories(p, PartCategories.Electrical));
                PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Science", Localizer.GetStringByTag("#autoLOC_453585"), ic_science, p => filterCategories(p, PartCategories.Science));

                if (lifeSupportAvailable)
                {
                    PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", Localizer.GetStringByTag("#autoLOC_453588"), ic_utility, p => (filterCategories(p, PartCategories.Utility) && !filter_KKAOSS_LS(p)));
                    PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Life Support", Localizer.GetStringByTag("#LOC_KPBS.categoryfilter.category.lifesupport"), ic_lifeSupport, p => filter_KKAOSS_LS(p));
                }
                else
                {
                    PartCategorizer.AddCustomSubcategoryFilter(surfaceStructureFilter, "Utility", Localizer.GetStringByTag("#autoLOC_453588"), ic_utility, p => (filterCategories(p, PartCategories.Utility)));
                }
            }
            //-----------------end own category-----------------

            //------------subcategory for life support---------

            //when the community category kit is not available, add own category for life support
            if (!CCKavailable)
            {
                //only continue when there are parts for life support
                if (lifeSupportAvailable)
                {
                    RUI.Icons.Selectable.Icon filterIconLifeSupport = new RUI.Icons.Selectable.Icon("KKAOSS_icon_KPSS", icon_category_ls, icon_category_ls, true);

                    if (filterIconLifeSupport == null)
                    {
                        Debug.Log("[KPBS] ERROR filterIconLifeSupport cannot be loaded");
                        return;
                    }

                    //Find the function filter
                    PartCategorizer.Category functionFilter = PartCategorizer.Instance.filters.Find(f => f.button.categorydisplayName == filterName);
                    PartCategorizer.AddCustomSubcategoryFilter(functionFilter, "Life Support", Localizer.GetStringByTag("#LOC_KPBS.categoryfilter.category.lifesupport"), filterIconLifeSupport, p => filter_KKAOSS_LS(p));

                    //add the greenhouse the the LS mods when other ls mods were found
                    List <AvailablePart> greenhouses = PartLoader.Instance.loadedParts.FindAll(ap => ap.name.Equals("KKAOSS.Greenhouse.g"));
                    for (int i = 0; i < greenhouses.Count; i++)
                    {
                        greenhouses[i].category = PartCategories.none;
                    }
                }
            }
            else if (lifeSupportAvailable)
            {
                List <AvailablePart> greenhouses = PartLoader.Instance.loadedParts.FindAll(ap => ap.name.Equals("KKAOSS.Greenhouse.g"));
                for (int i = 0; i < greenhouses.Count; i++)
                {
                    greenhouses[i].category = PartCategories.none;
                }
            }
            //---------end subcategory for life support-------
        }