Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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;
            RUIToggleButtonTyped 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.IsPartInMod(p));

                categoryButton = categoryFilter.button.activeButton;
                categoryButton.SetFalse(categoryButton, RUIToggleButtonTyped.ClickType.FORCED);
                categoryButton.SetTrue(categoryButton, RUIToggleButtonTyped.ClickType.FORCED);
            }
        }