Exemple #1
0
 //get the instance of this config file
 public static KPBSConfiguration Instance()
 {
     if (kPBSConfig == null)
     {
         kPBSConfig = new KPBSConfiguration();
     }
     return(kPBSConfig);
 }
Exemple #2
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-------
        }
Exemple #3
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-------
        }
 //get the instance of this config file
 public static KPBSConfiguration Instance()
 {
     if (kPBSConfig == null)
         kPBSConfig = new KPBSConfiguration();
     return kPBSConfig;
 }