예제 #1
0
            public override string ToString()
            {
                int count = listOfItems.Sum(x => x.Item2);

                return($"{ItemHoverFixTagHandler.GenerateTag(recipeGroup.ValidItems[recipeGroup.IconicItemIndex], count, recipeGroup.GetText(), false)} ({string.Concat(listOfItems.Select(x => ItemHoverFixTagHandler.GenerateTag(x.Item1, x.Item2, null, true)))})");
                // return $"Haves: {string.Join(", ", listOfItems.Select(x => $"{Lang.GetItemNameValue(x.Item1)} ({x.Item2})"))}";
            }
예제 #2
0
        // Using Chat Tags is cool, but I can't assign individual code to them.
        // They are first and foremost just Text, made to look like things.
        // Word Wrap is possible with UIMessageBox code, but scrollbar is needed? With UIGrid, I could probably do this better
        public UIRecipePath(CraftPath path)
        {
            this.path = path;

            SetPadding(6);
            Width.Set(0, 1f);
            int top = 0;
            // Craftable
            // Total Money Cost
            var totalItemCost = new Dictionary <int, int>();
            // Does all the other lines.
            int count = Traverse(path.root, 0, ref top, totalItemCost);

            var neededTiles = new HashSet <int>(path.root.GetAllChildrenPreOrder().OfType <CraftPath.RecipeNode>().SelectMany(x => x.recipe.requiredTile));

            neededTiles.Remove(-1);
            var needWater = path.root.GetAllChildrenPreOrder().OfType <CraftPath.RecipeNode>().Any(x => x.recipe.needWater);
            var needHoney = path.root.GetAllChildrenPreOrder().OfType <CraftPath.RecipeNode>().Any(x => x.recipe.needHoney);
            var needLava  = path.root.GetAllChildrenPreOrder().OfType <CraftPath.RecipeNode>().Any(x => x.recipe.needLava);

            var missingTiles = neededTiles.Where(x => !Main.LocalPlayer.adjTile[x]);

            StringBuilder sb = new StringBuilder();

            sb.Append("Cost: ");
            foreach (var data in totalItemCost)
            {
                sb.Append(ItemHoverFixTagHandler.GenerateTag(data.Key, data.Value));
            }

            // Maybe have a summary tiles needed if Full Craft implemented

            var drawTextSnippets = UIMessageBox.WordwrapStringSmart(sb.ToString(), Color.White, Main.fontMouseText, 300, -1);

            foreach (var textSnippet in drawTextSnippets)
            {
                string        s       = string.Concat(textSnippet.Select(x => x.TextOriginal));
                UITextSnippet snippet = new UITextSnippet(s);
                snippet.Top.Set(top, 0);
                snippet.Left.Set(0, 0);
                Append(snippet);
                top += verticalSpace;
                count++;
            }

            Height.Set(count * verticalSpace + PaddingBottom + PaddingTop, 0f);

            // TODO: Full Craft Button
            //var craftButton = new UITextPanel<string>("Craft");
            //craftButton.Top.Set(-38, 1f);
            //craftButton.Left.Set(-63, 1f);
            //craftButton.OnClick += CraftButton_OnClick;
            //Append(craftButton);
        }
예제 #3
0
            public override string ToUITextString()
            {
                var        npcs        = RecipePath.loots[itemid];   // Only checks 1 item in Group. Fix later.
                List <int> encountered = new List <int>();

                foreach (var npc in npcs)
                {
                    int bannerID = Item.NPCtoBanner(npc);
                    if (bannerID > 0)
                    {
                        if (NPC.killCount[bannerID] > 0)
                        {
                            encountered.Add(npc);
                        }
                    }
                }
                return($"[image/s0.8,v2,tFarm:RecipeBrowser/Images/sortDamage] {ItemHoverFixTagHandler.GenerateTag(itemid, stack)} from {string.Concat(encountered.Select(x => $"[npc:{x}]"))}");

                //[image/tMissing Tiles[i;{ItemID.MythrilAnvil}]:
                //return $"[image/tFarm:RecipeBrowser/Images/sortDamage] {ItemHoverFixTagHandler.GenerateTag(itemid, stack)} from {string.Concat(RecipePath.loots[itemid].Select(x => $"[npc:{x}]"))}";
                //return $"Farm: {ItemHoverFixTagHandler.GenerateTag(itemid, stack)} from {string.Concat(RecipePath.loots[itemid].Select(x => $"[npc:{x}]"))}";
            }
예제 #4
0
 public override string ToUITextString()
 {
     return($"[image:RecipeBrowser/Images/sortValue]: {ItemHoverFixTagHandler.GenerateTag(itemid, stack)} from {string.Concat(RecipePath.purchasable[itemid].Select(x => $"[npc/head:{x}]"))} for {ItemHoverFixTagHandler.GenerateTag(ItemID.SilverCoin, 3)}");                // TODO: TownNPC Head instead of
 }
예제 #5
0
 public override string ToUITextString()
 {
     return($"Have: {ItemHoverFixTagHandler.GenerateTag(itemid, stack, null, true)}");
 }
예제 #6
0
        private int Traverse(CraftPath.CraftPathNode node, int left, ref int top, Dictionary <int, int> totalItemCost)
        {
            int count = 1;

            StringBuilder sb         = new StringBuilder();
            var           recipeNode = node as CraftPath.RecipeNode;

            if (recipeNode != null)
            {
                sb.Append(ItemHoverFixTagHandler.GenerateTag(recipeNode.recipe.createItem.type, recipeNode.recipe.createItem.stack * recipeNode.multiplier));
                sb.Append("<");
                for (int i = 0; i < recipeNode.recipe.requiredItem.Length; i++)
                {
                    Item item = recipeNode.recipe.requiredItem[i];
                    if (!item.IsAir)
                    {
                        bool check = false;
                        var  child = recipeNode.children[i];
                        if (child is CraftPath.HaveItemNode)
                        {
                            check = true;
                        }
                        string nameOverride = RecipeCatalogueUI.OverrideForGroups(recipeNode.recipe, item.type);
                        sb.Append(ItemHoverFixTagHandler.GenerateTag(item.type, item.stack * recipeNode.multiplier, nameOverride, check));
                    }
                }
            }
            else
            {
                if (node is CraftPath.HaveItemNode)
                {
                    count--;
                }
                else
                {
                    sb.Append(node.ToUITextString());
                }
            }

            var haveItemNode = node as CraftPath.HaveItemNode;

            if (haveItemNode != null)
            {
                totalItemCost.Adjust(haveItemNode.itemid, haveItemNode.stack);
            }
            var haveItemsNode = node as CraftPath.HaveItemsNode;

            if (haveItemsNode != null)
            {
                foreach (var item in haveItemsNode.listOfItems)
                {
                    totalItemCost.Adjust(item.Item1, item.Item2);
                }
            }

            if (sb.Length > 0)
            {
                var snippet = new UITextSnippet(sb.ToString());
                snippet.Top.Set(top, 0);
                snippet.Left.Set(left, 0);
                Append(snippet);

                if (recipeNode != null)
                {
                    var neededTiles = new HashSet <int>(recipeNode.recipe.requiredTile);
                    neededTiles.Remove(-1);
                    var needWater = recipeNode.recipe.needWater;
                    var needHoney = recipeNode.recipe.needHoney;
                    var needLava  = recipeNode.recipe.needLava;

                    UIRecipeInfoRightAligned simpleRecipeInfo = new UIRecipeInfoRightAligned(neededTiles.ToList(), needWater, needHoney, needLava);
                    simpleRecipeInfo.Top.Set(top, 0);
                    simpleRecipeInfo.Left.Set(-30, 1f);
                    Append(simpleRecipeInfo);

                    UICraftButton craftButton = new UICraftButton(recipeNode, recipeNode.recipe);
                    craftButton.Top.Set(top, 0);
                    craftButton.Left.Set(-26, 1f);
                    Append(craftButton);
                }
                top += verticalSpace;
            }

            if (node.children != null)
            {
                foreach (var child in node.children)
                {
                    if (child != null)
                    {
                        count += Traverse(child, left + HorizontalTab, ref top, totalItemCost);
                    }
                }
            }
            return(count);
        }