Example #1
0
        public bool OpenDetailPageFor(string pageCode)
        {
            capi.Gui.PlaySound("menubutton_press");

            int num;

            if (pageNumberByPageCode.TryGetValue(pageCode, out num))
            {
                GuiHandbookPage elem = allHandbookPages[num];
                if (browseHistory.Count > 0 && elem == browseHistory.Peek().Page)
                {
                    return(true);
                }

                browseHistory.Push(new BrowseHistoryElement()
                {
                    Page = elem,
                    PosY = 0
                });
                initDetailGui();
                return(true);
            }

            return(false);
        }
Example #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
                );
        }
Example #3
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
                );
        }
Example #4
0
        public bool OpenDetailPageFor(string pageCode)
        {
            capi.Gui.PlaySound("menubutton_press");

            int num;

            if (pageNumberByPageCode.TryGetValue(pageCode, out num))
            {
                GuiHandbookPage elem = listElements[num];
                if (browseHistory.Count > 0 && elem == browseHistory.Peek())
                {
                    return(true);                                                        // stack.Equals(capi.World, browseHistory.Peek(), GlobalConstants.IgnoredStackAttributes)) return;
                }
                browseHistory.Push(elem);
                initDetailGui();
                return(true);
            }

            return(false);
        }