public override void Draw(SpriteBatch spriteBatch) { LightPlayer lightPlayer = Main.LocalPlayer.GetModPlayer <LightPlayer>(); Color color = lightPlayer.lightColor; Color offColor = color * 0.75f; Main.inventoryScale = 0.85f; float slotSize = 56 * Main.inventoryScale; float xPos = 20; float yPos = 258 + (slotSize * 2); float xOff = 0; float slotWidth = Main.inventoryBackTexture.Width * Main.inventoryScale; float slotHeight = Main.inventoryBackTexture.Height * Main.inventoryScale; bool interact = !Terraria.GameInput.PlayerInput.IgnoreMouseInterface; Texture2D backTexture = Main.inventoryBack13Texture; float x; Item item; Item upItem; Item downItem; float extraHeight = oldHovered?slotHeight:0; oldHovered = false; for (int i = 0; i < 10; i++) { x = xPos + xOff; item = lightPlayer.forgeItems[i]; if (interact && Main.mouseX >= x && Main.mouseX <= x + slotWidth && Main.mouseY >= yPos - extraHeight && Main.mouseY <= yPos + slotHeight + extraHeight) { Main.LocalPlayer.mouseInterface = true; oldHovered = true; Main.inventoryScale = 0.65f; upItem = Tools.ItemFromID(lightPlayer.GetOffsetForgeableItemType(item.type, -1)); UITools.DrawColoredItemSlot(spriteBatch, ref upItem, new Vector2(x + slotSize * 0.1f, yPos - slotSize * 0.8f), backTexture, offColor, new Color(255, 255, 255, 150)); downItem = Tools.ItemFromID(lightPlayer.GetOffsetForgeableItemType(item.type, 1)); UITools.DrawColoredItemSlot(spriteBatch, ref downItem, new Vector2(x + slotSize * 0.1f, yPos + slotSize * 1.01f), backTexture, offColor, new Color(255, 255, 255, 150)); Main.inventoryScale = 0.85f; if (Main.mouseLeftRelease && Main.mouseLeft) { if (Main.mouseY < yPos) { lightPlayer.ForgeHotbarItems[i] = upItem.type; lightPlayer.forgeItems[i] = upItem; } else if (Main.mouseY > yPos + slotHeight) { lightPlayer.ForgeHotbarItems[i] = downItem.type; lightPlayer.forgeItems[i] = downItem; } } if (Main.mouseY < yPos) { ItemSlot.MouseHover(ref upItem, ItemSlot.Context.InventoryItem); } else if (Main.mouseY > yPos + slotHeight) { ItemSlot.MouseHover(ref downItem, ItemSlot.Context.InventoryItem); } else { ItemSlot.MouseHover(ref item, ItemSlot.Context.InventoryItem); } } UITools.DrawColoredItemSlot(spriteBatch, ref item, new Vector2(x, yPos), backTexture, color, new Color(255, 255, 255, 150)); xOff += 56 * Main.inventoryScale; } }
public static void Draw() { if (Main.LocalPlayer.ghost) { return; } Player player = Main.LocalPlayer; LightPlayer lightPlayer = player.GetModPlayer <LightPlayer>(); Item forgeSelectedItem = lightPlayer.forgeItems[lightPlayer.forgeSelectedItem]; Texture2D backTexture = Main.inventoryBack13Texture; string text = ""; if (!string.IsNullOrEmpty(forgeSelectedItem.Name)) { text = forgeSelectedItem.AffixName(); } Vector2 vector = Main.fontMouseText.MeasureString(text) / 2f; Main.spriteBatch.DrawString(Main.fontMouseText, text, new Vector2(236f - vector.X, 0f), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); int posX = 20; for (int i = 0; i < 10; i++) { if (i == lightPlayer.forgeSelectedItem) { if (Main.hotbarScale[i] < 1f) { Main.hotbarScale[i] += 0.05f; } } else if (Main.hotbarScale[i] > 0.75) { Main.hotbarScale[i] -= 0.05f; } float hotbarScale = Main.hotbarScale[i]; int posY = (int)(20f + 22f * (1f - hotbarScale)); int a = (int)(75f + 150f * hotbarScale); Color lightColor = new Color(255, 255, 255, a); if (!player.hbLocked && !PlayerInput.IgnoreMouseInterface && Main.mouseX >= posX && (float)Main.mouseX <= (float)posX + (float)backTexture.Width * Main.hotbarScale[i] && Main.mouseY >= posY && (float)Main.mouseY <= (float)posY + (float)backTexture.Height * Main.hotbarScale[i] && !player.channel) { player.mouseInterface = true; player.showItemIcon = false; if (Main.mouseLeft && !player.hbLocked && !Main.blockMouse) { lightPlayer.forgeSelectedItem = i; } Main.hoverItemName = player.inventory[i].AffixName(); } float oldInventoryScale = Main.inventoryScale; Main.inventoryScale = hotbarScale; UITools.DrawColoredItemSlot( Main.spriteBatch, ref lightPlayer.forgeItems[i], new Vector2(posX, posY), backTexture, lightPlayer.lightColor, lightColor); Main.inventoryScale = oldInventoryScale; posX += (int)(backTexture.Width * Main.hotbarScale[i]) + 4; } }