Пример #1
0
        public override void Click(UIMouseEvent evt)
        {
            if (Main.keyState.IsKeyDown(Main.FavoriteKey))
            {
                if (Main.drawingPlayerChat)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var item in Main.recipe[index].requiredItem)
                    {
                        if (!item.IsAir)
                        {
                            sb.Append(ItemTagHandler.GenerateTag(item));
                        }
                    }
                    sb.Append("-->");
                    sb.Append(ItemTagHandler.GenerateTag(Main.recipe[index].createItem));
                    if (ChatManager.AddChatText(Main.fontMouseText, sb.ToString(), Vector2.One))
                    {
                        Main.PlaySound(SoundID.MenuTick);
                    }
                }
                else
                {
                    RecipeBrowserUI.instance.FavoriteChange(this.index, !favorited);
                }
            }
            else
            {
                RecipeCatalogueUI.instance.SetRecipe(index);
                RecipeCatalogueUI.instance.queryLootItem = Main.recipe[index].createItem;
                RecipeCatalogueUI.instance.updateNeeded  = true;
            }

            for (int n = 0; n < Main.numAvailableRecipes; n++)
            {
                if (index == Main.availableRecipe[n])
                {
                    Main.playerInventory = true;
                    Main.focusRecipe     = n;
                    Main.recFastScroll   = true;
                    break;
                }
            }

            // Idea: Glint the CraftUI tab if extended craft available?
        }
Пример #2
0
        private bool ItemSlot_OverrideLeftClick(On.Terraria.UI.ItemSlot.orig_OverrideLeftClick orig, Item[] inv, int context, int slot)
        {
            Item item = inv[slot];

            //Check if the slot has no item in it and the favorite key is down and if the item in the slot can actually be favorited
            if (item.IsAir && Main.keyState.IsKeyDown(Main.FavoriteKey) && CanFavoriteAt[context])
            {
                //If true, add lock to inventory slot
                item.SetDefaults(ModContent.ItemType <ItemLock>());
                //Favorite lock item
                item.favorited = true;
                //Play sound
                Main.PlaySound(SoundID.Unlock);
                return(true);
            }

            if (Main.cursorOverride == 2)
            {
                if (ChatManager.AddChatText(Main.fontMouseText, ItemTagHandler.GenerateTag(item), Vector2.One))
                {
                    Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                }

                return(true);
            }

            if (Main.cursorOverride == 3)
            {
                if (!CanFavoriteAt[context])
                {
                    return(false);
                }

                item.favorited = !item.favorited;
                Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                return(true);
            }
            else
            {
                if (Main.cursorOverride == 7)
                {
                    inv[slot] = Main.player[Main.myPlayer].GetItem(Main.myPlayer, inv[slot], false, true);
                    Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                    return(true);
                }

                if (Main.cursorOverride == 8)
                {
                    inv[slot] = Main.player[Main.myPlayer].GetItem(Main.myPlayer, inv[slot], false, true);

                    if (Main.player[Main.myPlayer].chest > -1)
                    {
                        NetMessage.SendData(32, -1, -1, null, Main.player[Main.myPlayer].chest, slot, 0f, 0f, 0, 0, 0);
                    }

                    return(true);
                }

                if (Main.cursorOverride == 9)
                {
                    ChestUI.TryPlacingInChest(inv[slot], false);
                    return(true);
                }

                return(false);
            }
        }