private void HandleFilteredMods(UIState _menuUi,
                                        bool isFiltered,
                                        IList <string> filteredModNameList,
                                        int onTagCount,
                                        int offTagCount)
        {
            string filterName = "Tags";

            if (onTagCount > 0 || offTagCount > 0)
            {
                filterName += " ";

                if (onTagCount > 0)
                {
                    filterName += "+" + onTagCount;
                    if (offTagCount > 0)
                    {
                        filterName += " ";
                    }
                }
                if (offTagCount > 0)
                {
                    filterName += "-" + offTagCount;
                }
            }

            if (ReflectionHelpers.Set(_menuUi, "UpdateFilterMode", (UpdateFilter)0))
            {
                ModMenuHelpers.ApplyModBrowserFilter(filterName, isFiltered, (List <string>)filteredModNameList);
            }
            else
            {
                LogHelpers.Alert("Could not set UpdateFilterMode for the mod browser");
            }
        }
Пример #2
0
        internal void FilterMods()
        {
            IList <string> modNames = new List <string>();
            UIState        myUI     = this.MyUI;

            object items;

            if (!ReflectionHelpers.Get(myUI, "items", out items))
            {
                throw new HamstarException("No 'items' field in ui " + myUI);
            }

            var itemsArr = (Array)items.GetType()
                           .GetMethod("ToArray")
                           .Invoke(items, new object[] { });

            for (int i = 0; i < itemsArr.Length; i++)
            {
                object item = itemsArr.GetValue(i);
                string modName;

                if (ReflectionHelpers.Get(item, "mod", out modName))
                {
                    modNames.Add(modName);
                }
            }

            this.FilterModsAsync(modNames, (isFiltered, filteredModNameList, onTagCount, offTagCount) => {
                string filterName = "Tags";
                if (onTagCount > 0 || offTagCount > 0)
                {
                    filterName += " ";

                    if (onTagCount > 0)
                    {
                        filterName += "+" + onTagCount;
                        if (offTagCount > 0)
                        {
                            filterName += " ";
                        }
                    }
                    if (offTagCount > 0)
                    {
                        filterName += "-" + offTagCount;
                    }
                }

                ReflectionHelpers.Set(myUI, "updateFilterMode", (UpdateFilter)0);
                ModMenuHelpers.ApplyModBrowserFilter(filterName, isFiltered, (List <string>)filteredModNameList);
            });
        }