예제 #1
0
        private void OnNewScrollbarvalueOverviewPage(float value)
        {
            GuiElementFlatList stacklist = overviewGui.GetFlatList("stacklist");

            stacklist.insideBounds.fixedY = 3 - value;
            stacklist.insideBounds.CalcWorldBounds();
        }
예제 #2
0
        public void FilterItems()
        {
            string text = currentSearchText?.ToLowerInvariant();

            string[] texts = text == null ? new string[0] : text.Split(new string[] { " or " }, StringSplitOptions.RemoveEmptyEntries).OrderBy(str => str.Length).ToArray();

            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;
                }
                if (page.IsDuplicate)
                {
                    continue;
                }

                float weight = 1;
                bool  skip   = texts.Length > 0;

                for (int j = 0; j < texts.Length; j++)
                {
                    weight = page.TextMatchWeight(texts[j]);
                    if (weight > 0)
                    {
                        skip = false; break;
                    }
                }
                if (skip)
                {
                    continue;
                }

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

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

            GuiElementFlatList stacklist = overviewGui.GetFlatList("stacklist");

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