Ejemplo n.º 1
0
 public override void Click(UIMouseEvent evt)
 {
     if (Parent is LootUI)
     {
         LootUI parent = Parent as LootUI;
         if (parent.Selections[0] == null)
         {
             parent.Selections[0] = Item;
         }
         else if (parent.Selections[0] == Item)
         {
             parent.Selections[0] = null;
         }
         else
         {
             parent.Selections[1] = Item;
         }
     }
 }
Ejemplo n.º 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (IsMouseHovering)
            {
                Main.LocalPlayer.mouseInterface = true;
            }

            if (Parent is LootUI)
            {
                LootUI    parent  = Parent as LootUI;
                Texture2D tex     = parent.Selections.Any(n => n == Item) ? GetTexture("StarlightRiver/Assets/GUI/LootSlotOn") : GetTexture("StarlightRiver/Assets/GUI/LootSlot");
                float     opacity = IsMouseHovering ? 1 : 0.6f;

                spriteBatch.Draw(tex, GetDimensions().Position(), tex.Frame(), Color.White * opacity, 0, Vector2.Zero, 1, 0, 0);
                if (!Item.IsAir)
                {
                    Texture2D tex2  = Item.type > ItemID.Count ? GetTexture(Item.modItem.Texture) : GetTexture("Terraria/Item_" + Item.type);
                    float     scale = tex2.Frame().Size().Length() < 52 ? 1 : 52f / tex2.Frame().Size().Length();

                    spriteBatch.Draw(tex2, GetDimensions().Center(), tex2.Frame(), Color.White, 0, tex2.Frame().Size() / 2, 1, 0, 0);
                    if (Item.stack > 1)
                    {
                        Utils.DrawBorderString(spriteBatch, Item.stack.ToString(), GetDimensions().Position() + Vector2.One * 36, Color.White, 0.75f);
                    }
                }
                if (IsMouseHovering)
                {
                    float   offY = 40 - Item.ToolTip.Lines * 14;
                    Vector2 pos  = new Vector2(Main.screenWidth / 2, Main.screenHeight / 2) + new Vector2(60, offY);
                    for (int k = 0; k <= Item.ToolTip.Lines; k++)
                    {
                        if (k == 0)
                        {
                            Utils.DrawBorderString(spriteBatch, Item.Name, pos + new Vector2(0, k * 14), ItemRarity.GetColor(Item.rare), 0.75f);
                        }
                        else
                        {
                            Utils.DrawBorderString(spriteBatch, Item.ToolTip.GetLine(k - 1), pos + new Vector2(0, k * 14), Color.White, 0.75f);
                        }
                    }
                }
            }
        }