コード例 #1
0
        public static void DrawSelf(SpriteBatch spriteBatch)
        {
            UIRepairWorkbench.DrawPanel(spriteBatch, UIRepairWorkbench._backgroundTexture, new Color(33, 43, 79) * 0.8f);
            UIRepairWorkbench.DrawPanel(spriteBatch, UIRepairWorkbench._borderTexture, new Color(89, 116, 213) * 0.7f);

            float oldScale = Main.inventoryScale;

            Main.inventoryScale = 0.75f;
            Point value = new Point(Main.mouseX, Main.mouseY);

            Main.spriteBatch.DrawString(Main.fontMouseText,
                                        "Repair Workbench", new Vector2(UIRepairWorkbench.X + 33, UIRepairWorkbench.Y + 10),
                                        Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);

            Rectangle hitbox = new Rectangle(UIRepairWorkbench.X + 66, UIRepairWorkbench.Y + 180, 50, 18);

            Main.spriteBatch.DrawString(Main.fontMouseText,
                                        "Repair", new Vector2(UIRepairWorkbench.X + 66, UIRepairWorkbench.Y + 180),
                                        Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);


            if (hitbox.Contains(value) && !PlayerInput.IgnoreMouseInterface && Main.mouseLeft && Main.mouseLeftRelease)
            {
                Main.player[Main.myPlayer].mouseInterface = true;

                if (DushyUpgrade.repairWorkbenchTE.brokenItem.IsAir)
                {
                    Main.NewText("You need an item to repair");
                }
                else if (DushyUpgrade.repairWorkbenchTE.repairScroll.IsAir)
                {
                    Main.NewText("You need a repair scroll to repair your " + DushyUpgrade.repairWorkbenchTE.brokenItem.Name);
                }
                else
                {
                    UpgradeInfo info = DushyUpgrade.repairWorkbenchTE.brokenItem.GetGlobalItem <UpgradeInfo>();
                    info.repairItem(DushyUpgrade.repairWorkbenchTE.brokenItem);
                    DushyUpgrade.repairWorkbenchTE.repairScroll.stack--;
                    ItemText.NewText(Main.player[Main.myPlayer], "Restored !", Color.Gold);
                }
            }
            for (int i = 0; i < 2; i++)
            {
                int       x    = UIRepairWorkbench.X;
                int       y    = 42 * i + UIRepairWorkbench.Y + 40;
                Rectangle r    = new Rectangle(x, y, (int)((float)Main.inventoryBackTexture.Width * Main.inventoryScale), (int)((float)Main.inventoryBackTexture.Height * Main.inventoryScale));
                Item      item = i == 0 ? DushyUpgrade.repairWorkbenchTE.brokenItem : DushyUpgrade.repairWorkbenchTE.repairScroll;

                if (r.Contains(value) && !PlayerInput.IgnoreMouseInterface)
                {
                    Main.player[Main.myPlayer].mouseInterface = true;
                    if (UIRepairWorkbench.CanGoInSlot(Main.mouseItem, i))
                    {
                        ItemSlot.Handle(ref item, 3);
                    }
                }
                ItemSlot.Draw(spriteBatch, ref item, 3, new Vector2(x, y));
                switch (i)
                {
                case 0:
                    DushyUpgrade.repairWorkbenchTE.brokenItem = item;
                    break;

                case 1:
                    DushyUpgrade.repairWorkbenchTE.repairScroll = item;
                    break;

                default:
                    break;
                }

                Main.spriteBatch.DrawString(Main.fontMouseText,
                                            UIRepairWorkbench.labels[i], new Vector2(x + 48, y + 10),
                                            Color.White, 0f, default(Vector2), Main.inventoryScale, SpriteEffects.None, 0f);
            }
            Main.inventoryScale = oldScale;
        }