Exemple #1
0
        public bool PassFilters(UIModsFilterResults filterResults)
        {
            if (Interface.modsMenu.filter.Length > 0)
            {
                if (Interface.modsMenu.searchFilterMode == SearchFilter.Author)
                {
                    if (_mod.properties.author.IndexOf(Interface.modsMenu.filter, StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        filterResults.filteredBySearch++;
                        return(false);
                    }
                }
                else
                {
                    if (DisplayNameClean.IndexOf(Interface.modsMenu.filter, StringComparison.OrdinalIgnoreCase) == -1 && ModName.IndexOf(Interface.modsMenu.filter, StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        filterResults.filteredBySearch++;
                        return(false);
                    }
                }
            }
            if (Interface.modsMenu.modSideFilterMode != ModSideFilter.All)
            {
                if ((int)_mod.properties.side != (int)Interface.modsMenu.modSideFilterMode - 1)
                {
                    filterResults.filteredByModSide++;
                    return(false);
                }
            }
            switch (Interface.modsMenu.enabledFilterMode)
            {
            default:
            case EnabledFilter.All:
                return(true);

            case EnabledFilter.EnabledOnly:
                if (!_mod.Enabled)
                {
                    filterResults.filteredByEnabled++;
                }
                return(_mod.Enabled);

            case EnabledFilter.DisabledOnly:
                if (_mod.Enabled)
                {
                    filterResults.filteredByEnabled++;
                }
                return(!_mod.Enabled);
            }
        }
Exemple #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (needToRemoveLoading)
            {
                needToRemoveLoading = false;
                uIPanel.RemoveChild(uiLoader);
            }
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;
            filter       = filterTextBox.Text;
            modList.Clear();
            var filterResults = new UIModsFilterResults();
            var visibleItems  = items.Where(item => item.PassFilters(filterResults)).ToList();

            if (filterResults.AnyFiltered)
            {
                var panel = new UIPanel();
                panel.Width.Set(0, 1f);
                modList.Add(panel);
                var filterMessages = new List <string>();
                if (filterResults.filteredByEnabled > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByEnabled", filterResults.filteredByEnabled));
                }
                if (filterResults.filteredByModSide > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByModSide", filterResults.filteredByModSide));
                }
                if (filterResults.filteredBySearch > 0)
                {
                    filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredBySearch", filterResults.filteredBySearch));
                }
                string filterMessage = string.Join("\n", filterMessages);
                var    text          = new UIText(filterMessage);
                text.Width.Set(0, 1f);
                text.IsWrapped = true;
                text.WrappedTextBottomPadding = 0;
                text.TextOriginX = 0f;
                text.Recalculate();
                panel.Append(text);
                panel.Height.Set(text.MinHeight.Pixels + panel.PaddingTop, 0f);
            }
            modList.AddRange(visibleItems);
            Recalculate();
            modList.ViewPosition = modListViewPosition;
        }