Пример #1
0
        private void FilterItems()
        {
            shownStacklistItems.Clear();
            foreach (GuiHandbookItemStackPage stacklistItem in allStacklistItems)
            {
                if (filterCategory != "")
                {
                    var stacklistItemClothesCategory = stacklistItem.Stack.ItemAttributes?["clothescategory"].AsString() ?? "";
                    if (stacklistItemClothesCategory != filterCategory.ToLowerInvariant())
                    {
                        // capi.Logger.Debug($"filtering by cat: {stacklistItemClothesCategory} != {filterCategory}");
                        continue;
                    }
                }
                if (filterSearch != "")
                {
                    var itemName = stacklistItem.Stack.GetName();
                    if (!itemName.ToLowerInvariant().Contains(filterSearch.ToLowerInvariant()))
                    {
                        continue;
                    }
                }
                shownStacklistItems.Add(stacklistItem);
            }
            GuiElementHandbookList stacklist = SingleComposer.GetHandbookStackList("stacklist");

            stacklist.CalcTotalHeight();
            UpdateStacklistScrollbar();
        }
Пример #2
0
        public void FilterItems()
        {
            string text = currentSearchText?.ToLowerInvariant();

            List <WeightedHandbookPage> foundPages = new List <WeightedHandbookPage>();

            shownHandbookPages.Clear();

            for (int i = 0; i < allHandbookPages.Count; i++)
            {
                GuiHandbookPage page = allHandbookPages[i];
                if (currentCatgoryCode != null && page.CategoryCode != currentCatgoryCode)
                {
                    continue;
                }

                float weight = 1;

                if (text != null && text.Length != 0)
                {
                    weight = page.TextMatchWeight(text);
                    if (weight <= 0)
                    {
                        continue;
                    }
                }

                foundPages.Add(new WeightedHandbookPage()
                {
                    Page = page, Weight = weight
                });
            }

            foreach (var val in foundPages.OrderByDescending(wpage => wpage.Weight))
            {
                shownHandbookPages.Add(val.Page);
            }

            GuiElementHandbookList stacklist = overviewGui.GetHandbookStackList("stacklist");

            stacklist.CalcTotalHeight();
            overviewGui.GetScrollbar("scrollbar").SetHeights(
                (float)listHeight, (float)stacklist.insideBounds.fixedHeight
                );
        }
Пример #3
0
        public void FilterItemsBySearchText(string text)
        {
            currentSearchText = text;

            text = text.ToLowerInvariant();

            for (int i = 0; i < listElements.Count; i++)
            {
                listElements[i].Visible = text.Length == 0 || listElements[i].MatchesText(text);
            }

            GuiElementHandbookList stacklist = overviewGui.GetHandbookStackList("stacklist");

            stacklist.CalcTotalHeight();
            overviewGui.GetScrollbar("scrollbar").SetHeights(
                (float)listHeight, (float)stacklist.insideBounds.fixedHeight
                );
        }