Exemplo n.º 1
0
        public bool OpenDetailPageFor(string pageCode)
        {
            capi.Gui.PlaySound("menubutton_press");

            int num;

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

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

            return(false);
        }
Exemplo n.º 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>();

            shownEssencePages.Clear();

            for (int i = 0; i < allEssencePages.Count; i++)
            {
                GuiHandbookPage page = allEssencePages[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))
            {
                shownEssencePages.Add(val.Page);
            }

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

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