Advertisement
Guest User

Hastebin Down

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.66 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Graphics;
  4. using Terraria;
  5. using Terraria.ModLoader;
  6. using Terraria.GameContent.UI.Elements;
  7. using Terraria.UI;
  8. using Terraria.GameInput;
  9. using Terraria.ID;
  10. using Terraria.Localization;
  11. using Terraria.UI.Chat;
  12. using System;
  13. using System.Linq;
  14. using System.Collections.Generic;
  15. using System.Diagnostics.CodeAnalysis;
  16. using System.IO;
  17. using System.Reflection;
  18. using MusicMadness.UI;
  19. using Terraria.Utilities;
  20.  
  21. namespace MusicMadness.UI
  22. {
  23.     public class AccessoryUI : UIState
  24.     {
  25.         public UIPanel AccessoryUIPanel;
  26.         public static bool visible = false;
  27.         public static bool ItemInAccessoryUI = false;
  28.         public static int Meme;
  29.         public static Item ITEMZ;
  30.  
  31.         public override void OnInitialize()
  32.         {
  33.             Item ITEMZ = new Item();
  34.             VanillaItemSlotWrapperONE AccessoryUIPanel = new VanillaItemSlotWrapperONE(Terraria.UI.ItemSlot.Context.ChestItem, 1f);
  35.             AccessoryUIPanel.SetPadding(0);
  36.             AccessoryUIPanel.Left.Set(20f, 0f);
  37.             AccessoryUIPanel.Top.Set(300f, 0f);
  38.             AccessoryUIPanel.Width.Set(50f, 0f);
  39.             AccessoryUIPanel.Height.Set(50f, 0f);
  40.             AccessoryUIPanel.OnClick += Clicked;
  41.             base.Append(AccessoryUIPanel);
  42.         }
  43.         public virtual void Clicked(UIMouseEvent evt, UIElement listeningelement)
  44.         {
  45.             if (!VanillaItemSlotWrapperONE.item.IsAir && !MusicMadness.itemToMusicReference.ContainsKey(VanillaItemSlotWrapperONE.item.type) && VanillaItemSlotWrapperONE.item.accessory)
  46.             {
  47.                 if (MusicMadness.Melon != -1)
  48.                 {
  49.                     Main.PlaySound(SoundID.Tink);
  50.                     VanillaItemSlotWrapperONE.item.TurnToAir();
  51.                     Meme = VanillaItemSlotWrapperONE.item.type;
  52.                     ITEMZ = VanillaItemSlotWrapperONE.item;
  53.                     Player player = Main.LocalPlayer;
  54.                     Mod mod = ModLoader.GetMod("MusicMadness");
  55.                     player.QuickSpawnItem(mod.ItemType("MusicEmblem"), 1);
  56.                 }
  57.             }
  58.         }
  59.         protected override void DrawSelf(SpriteBatch spriteBatch)
  60.         {
  61.             CalculatedStyle innerDimensions = base.GetInnerDimensions();
  62.             Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 30f);
  63.  
  64.             float BoxX = innerDimensions.X;
  65.             float BoxY = innerDimensions.Y;
  66.            
  67.             Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, "Accessory", BoxX + (float)(20 * 4), BoxY + 308f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
  68.         }
  69.     }
  70.     public class VanillaItemSlotWrapperONE : UIElement
  71.     {
  72.         public static Item item = new Item();
  73.         int context;
  74.         float scale;
  75.         public VanillaItemSlotWrapperONE(int context = Terraria.UI.ItemSlot.Context.ChestItem, float scale = 1f)
  76.         {
  77.             this.context = context;
  78.             this.scale = scale;
  79.  
  80.             this.Width.Set(Main.inventoryBack9Texture.Width * scale, 0f);
  81.             this.Height.Set(Main.inventoryBack9Texture.Height * scale, 0f);
  82.         }
  83.         protected override void DrawSelf(SpriteBatch spriteBatch)
  84.         {
  85.             float oldScale = Main.inventoryScale;
  86.             Main.inventoryScale = scale;
  87.             Rectangle rectangle = base.GetDimensions().ToRectangle();
  88.             bool canSwap = Main.mouseItem.IsAir || (!MusicMadness.itemToMusicReference.ContainsKey(Main.mouseItem.type) && Main.mouseItem.accessory);
  89.            
  90.             if (Main.mouseItem.type == 1610)
  91.             {
  92.                 Main.musicBox2 = 27;
  93.             }
  94.             if (Main.mouseItem.type == 1963)
  95.             {
  96.                 Main.musicBox2 = 28;
  97.             }
  98.             if (Main.mouseItem.type == 1964)
  99.             {
  100.                 Main.musicBox2 = 29;
  101.             }
  102.             if (Main.mouseItem.type == 1965)
  103.             {
  104.                 Main.musicBox2 = 30;
  105.             }
  106.             if (Main.mouseItem.type == 2742)
  107.             {
  108.                 Main.musicBox2 = 31;
  109.             }
  110.             if (Main.mouseItem.type == 3044)
  111.             {
  112.                 Main.musicBox2 = 32;
  113.             }
  114.             if (Main.mouseItem.type == 3235)
  115.             {
  116.                 Main.musicBox2 = 33;
  117.             }
  118.             if (Main.mouseItem.type == 3236)
  119.             {
  120.                 Main.musicBox2 = 34;
  121.             }
  122.             if (Main.mouseItem.type == 3237)
  123.             {
  124.                 Main.musicBox2 = 35;
  125.             }
  126.             if (Main.mouseItem.type == 3370)
  127.             {
  128.                 Main.musicBox2 = 36;
  129.             }
  130.             if (Main.mouseItem.type == 3371)
  131.             {
  132.                 Main.musicBox2 = 37;
  133.             }
  134.             if (Main.mouseItem.type == 3796)
  135.             {
  136.                 Main.musicBox2 = 38;
  137.             }
  138.             if (Main.mouseItem.type == 3869)
  139.             {
  140.                 Main.musicBox2 = 39;
  141.             }
  142.             if (Main.mouseItem.type >= 562 && Main.mouseItem.type <= 574)
  143.             {
  144.                 Main.musicBox2 = Main.mouseItem.type - 562;
  145.             }
  146.             if (Main.mouseItem.type >= 1596 && Main.mouseItem.type <= 1609)
  147.             {
  148.                 Main.musicBox2 = Main.mouseItem.type - 1596 + 13;
  149.             }
  150.            
  151.             if (ContainsPoint(Main.MouseScreen) && !PlayerInput.IgnoreMouseInterface && (canSwap && Main.musicBox2 == -1))
  152.             {
  153.                 Main.LocalPlayer.mouseInterface = true;
  154.                 Terraria.UI.ItemSlot.Handle(ref item, context);
  155.             }
  156.             Terraria.UI.ItemSlot.Draw(spriteBatch, ref item, context, rectangle.TopLeft());
  157.             Main.inventoryScale = oldScale;
  158.         }
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement