Ejemplo n.º 1
0
        private bool RowIncludedInFiltering(CommandOption commandOption)
        {
            bool included = true;

            if (currentCategory != "All")
            {
                switch (currentCategory)
                {
                default:
                    if (commandOption.Action().Category != currentCategory.ToString())
                    {
                        return(false);
                    }
                    break;
                }
            }

            if (searchQuery != "")
            {
                // Does CommandOption fit search query

                // Minify CommandOptionName
                string commandOptionNameMinified = commandOption.Action().Name.Replace(" ", "").ToLower();

                // Get each section of text separated by spaces
                List <string> searchQueryMatches = new List <string>();
                if (searchQuery.Contains(" "))
                {
                    searchQueryMatches = searchQuery.Split(' ').OfType <string>().ToList();
                }
                else
                {
                    searchQueryMatches.Add(searchQuery);
                }

                foreach (string searchText in searchQueryMatches)
                {
                    // If either one of the search text sections contains or is equal to a command option name, stop checking and include in list
                    if (searchText.ToLower() == commandOptionNameMinified || commandOptionNameMinified.Contains(searchText.ToLower()))
                    {
                        return(true);
                    }
                }

                // If no searching matched and there search query is not blank do not include
                included = false;
            }

            return(included);
        }
Ejemplo n.º 2
0
        private void DrawItemRow(Rect rect, CommandOption commandOption, int index)
        {
            // Highlight every other row

            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }

            Text.Font = GameFont.Small;
            GUI.BeginGroup(rect);
            float num = rect.width;

            Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height);

            rect1 = rect1.Rounded();

            // TextAnchor Fix

            rect1.xMax -= 5f;
            rect1.xMin += 5f;

            if (Text.Anchor == TextAnchor.MiddleLeft)
            {
                rect1.xMax += 300f;
            }
            if (Text.Anchor == TextAnchor.MiddleRight)
            {
                rect1.xMin -= 300f;
            }

            Rect rect2 = new Rect(num - 560f, 0f, 75f, rect.height);

            // Store value for reference
            int    newPrice   = commandOption.costSilverStore;
            string priceLabel = newPrice.ToString();

            int    newLocalCooldown   = commandOption.localCooldownMs / 1000;
            string localCooldownLabel = newLocalCooldown.ToString();

            int    newGlobalCooldown   = commandOption.globalCooldownMs / 1000;
            string globalCooldownLabel = newGlobalCooldown.ToString();

            // Silver Cost
            Widgets.TextFieldNumeric(rect2, ref newPrice, ref priceLabel, -1f);
            filteredRows[index].costSilverStore = newPrice;

            // Local Cooldown

            rect2.x += rect2.width + 75f;

            Widgets.TextFieldNumeric(rect2, ref newLocalCooldown, ref localCooldownLabel, 0f);
            filteredRows[index].localCooldownMs = newLocalCooldown * 1000;

            // Global Cooldown

            rect2.x += rect2.width + 100f;

            Widgets.TextFieldNumeric(rect2, ref newGlobalCooldown, ref globalCooldownLabel, 0f);
            filteredRows[index].globalCooldownMs = newGlobalCooldown * 1000;

            // Icons for ItemDefs
            Rect rect3 = new Rect(0f, 0f, 27f, 27f);

            if (commandOption.Action() is ItemAction)
            {
                ItemAction itemAction = (ItemAction)commandOption.Action();
                ThingDef   thingDef   = itemAction.thingDef;
                Widgets.ThingIcon(rect3, thingDef);
                Widgets.InfoCardButton(40f, 0f, thingDef);
            }

            // Label for item/event

            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height);

            Text.WordWrap = false;
            GUI.color     = Color.white;
            Widgets.Label(rect4, commandOption.Action().Name.CapitalizeFirst());
            Text.WordWrap = true;

            GenUI.ResetLabelAlign();
            GUI.EndGroup();
        }