Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Graphics;
- using Terraria;
- using Terraria.ModLoader;
- using Terraria.GameContent.UI.Elements;
- using Terraria.UI;
- using Terraria.GameInput;
- using Terraria.ID;
- using Terraria.Localization;
- using Terraria.UI.Chat;
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.IO;
- using System.Reflection;
- using MusicMadness.UI;
- using Terraria.Utilities;
- namespace MusicMadness.UI
- {
- public class AccessoryUI : UIState
- {
- public UIPanel AccessoryUIPanel;
- public static bool visible = false;
- public static bool ItemInAccessoryUI = false;
- public static int Meme;
- public static Item ITEMZ;
- public override void OnInitialize()
- {
- Item ITEMZ = new Item();
- VanillaItemSlotWrapperONE AccessoryUIPanel = new VanillaItemSlotWrapperONE(Terraria.UI.ItemSlot.Context.ChestItem, 1f);
- AccessoryUIPanel.SetPadding(0);
- AccessoryUIPanel.Left.Set(20f, 0f);
- AccessoryUIPanel.Top.Set(300f, 0f);
- AccessoryUIPanel.Width.Set(50f, 0f);
- AccessoryUIPanel.Height.Set(50f, 0f);
- AccessoryUIPanel.OnClick += Clicked;
- base.Append(AccessoryUIPanel);
- }
- public virtual void Clicked(UIMouseEvent evt, UIElement listeningelement)
- {
- if (!VanillaItemSlotWrapperONE.item.IsAir && !MusicMadness.itemToMusicReference.ContainsKey(VanillaItemSlotWrapperONE.item.type) && VanillaItemSlotWrapperONE.item.accessory)
- {
- if (MusicMadness.Melon != -1)
- {
- Main.PlaySound(SoundID.Tink);
- VanillaItemSlotWrapperONE.item.TurnToAir();
- Meme = VanillaItemSlotWrapperONE.item.type;
- ITEMZ = VanillaItemSlotWrapperONE.item;
- Player player = Main.LocalPlayer;
- Mod mod = ModLoader.GetMod("MusicMadness");
- player.QuickSpawnItem(mod.ItemType("MusicEmblem"), 1);
- }
- }
- }
- protected override void DrawSelf(SpriteBatch spriteBatch)
- {
- CalculatedStyle innerDimensions = base.GetInnerDimensions();
- Vector2 drawPos = new Vector2(innerDimensions.X + 5f, innerDimensions.Y + 30f);
- float BoxX = innerDimensions.X;
- float BoxY = innerDimensions.Y;
- Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, "Accessory", BoxX + (float)(20 * 4), BoxY + 308f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
- }
- }
- public class VanillaItemSlotWrapperONE : UIElement
- {
- public static Item item = new Item();
- int context;
- float scale;
- public VanillaItemSlotWrapperONE(int context = Terraria.UI.ItemSlot.Context.ChestItem, float scale = 1f)
- {
- this.context = context;
- this.scale = scale;
- this.Width.Set(Main.inventoryBack9Texture.Width * scale, 0f);
- this.Height.Set(Main.inventoryBack9Texture.Height * scale, 0f);
- }
- protected override void DrawSelf(SpriteBatch spriteBatch)
- {
- float oldScale = Main.inventoryScale;
- Main.inventoryScale = scale;
- Rectangle rectangle = base.GetDimensions().ToRectangle();
- bool canSwap = Main.mouseItem.IsAir || (!MusicMadness.itemToMusicReference.ContainsKey(Main.mouseItem.type) && Main.mouseItem.accessory);
- if (Main.mouseItem.type == 1610)
- {
- Main.musicBox2 = 27;
- }
- if (Main.mouseItem.type == 1963)
- {
- Main.musicBox2 = 28;
- }
- if (Main.mouseItem.type == 1964)
- {
- Main.musicBox2 = 29;
- }
- if (Main.mouseItem.type == 1965)
- {
- Main.musicBox2 = 30;
- }
- if (Main.mouseItem.type == 2742)
- {
- Main.musicBox2 = 31;
- }
- if (Main.mouseItem.type == 3044)
- {
- Main.musicBox2 = 32;
- }
- if (Main.mouseItem.type == 3235)
- {
- Main.musicBox2 = 33;
- }
- if (Main.mouseItem.type == 3236)
- {
- Main.musicBox2 = 34;
- }
- if (Main.mouseItem.type == 3237)
- {
- Main.musicBox2 = 35;
- }
- if (Main.mouseItem.type == 3370)
- {
- Main.musicBox2 = 36;
- }
- if (Main.mouseItem.type == 3371)
- {
- Main.musicBox2 = 37;
- }
- if (Main.mouseItem.type == 3796)
- {
- Main.musicBox2 = 38;
- }
- if (Main.mouseItem.type == 3869)
- {
- Main.musicBox2 = 39;
- }
- if (Main.mouseItem.type >= 562 && Main.mouseItem.type <= 574)
- {
- Main.musicBox2 = Main.mouseItem.type - 562;
- }
- if (Main.mouseItem.type >= 1596 && Main.mouseItem.type <= 1609)
- {
- Main.musicBox2 = Main.mouseItem.type - 1596 + 13;
- }
- if (ContainsPoint(Main.MouseScreen) && !PlayerInput.IgnoreMouseInterface && (canSwap && Main.musicBox2 == -1))
- {
- Main.LocalPlayer.mouseInterface = true;
- Terraria.UI.ItemSlot.Handle(ref item, context);
- }
- Terraria.UI.ItemSlot.Draw(spriteBatch, ref item, context, rectangle.TopLeft());
- Main.inventoryScale = oldScale;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement