Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIItemSlot.cs
Go to the documentation of this file.
1
using
Microsoft.Xna.Framework
;
2
using
Microsoft.Xna.Framework.Graphics
;
3
using
Terraria.UI
;
4
5
namespace
Terraria.GameContent.UI.Elements
;
6
7
public
class
UIItemSlot
:
UIElement
8
{
9
private
Item
[]
_itemArray
;
10
11
private
int
_itemIndex
;
12
13
private
int
_itemSlotContext
;
14
15
public
UIItemSlot
(
Item
[] itemArray,
int
itemIndex,
int
itemSlotContext)
16
{
17
_itemArray
= itemArray;
18
_itemIndex
= itemIndex;
19
_itemSlotContext
= itemSlotContext;
20
Width
=
new
StyleDimension
(48f, 0f);
21
Height
=
new
StyleDimension
(48f, 0f);
22
}
23
24
private
void
HandleItemSlotLogic
()
25
{
26
if
(base.IsMouseHovering)
27
{
28
Main.LocalPlayer.mouseInterface =
true
;
29
Item
inv =
_itemArray
[
_itemIndex
];
30
ItemSlot
.
OverrideHover
(ref inv,
_itemSlotContext
);
31
ItemSlot
.
LeftClick
(ref inv,
_itemSlotContext
);
32
ItemSlot
.
RightClick
(ref inv,
_itemSlotContext
);
33
ItemSlot
.
MouseHover
(ref inv,
_itemSlotContext
);
34
_itemArray
[
_itemIndex
] = inv;
35
}
36
}
37
38
protected
override
void
DrawSelf
(
SpriteBatch
spriteBatch)
39
{
40
HandleItemSlotLogic
();
41
Item
inv =
_itemArray
[
_itemIndex
];
42
Vector2
position =
GetDimensions
().
Center
() +
new
Vector2
(52f, 52f) * -0.5f *
Main
.
inventoryScale
;
43
ItemSlot
.
Draw
(spriteBatch, ref inv,
_itemSlotContext
, position);
44
}
45
}
Microsoft.Xna.Framework.Graphics.SpriteBatch
Definition
SpriteBatch.cs:8
Terraria.GameContent.UI.Elements.UIItemSlot._itemIndex
int _itemIndex
Definition
UIItemSlot.cs:11
Terraria.GameContent.UI.Elements.UIItemSlot.DrawSelf
override void DrawSelf(SpriteBatch spriteBatch)
Definition
UIItemSlot.cs:38
Terraria.GameContent.UI.Elements.UIItemSlot.UIItemSlot
UIItemSlot(Item[] itemArray, int itemIndex, int itemSlotContext)
Definition
UIItemSlot.cs:15
Terraria.GameContent.UI.Elements.UIItemSlot._itemArray
Item[] _itemArray
Definition
UIItemSlot.cs:9
Terraria.GameContent.UI.Elements.UIItemSlot.HandleItemSlotLogic
void HandleItemSlotLogic()
Definition
UIItemSlot.cs:24
Terraria.GameContent.UI.Elements.UIItemSlot._itemSlotContext
int _itemSlotContext
Definition
UIItemSlot.cs:13
Terraria.GameContent.UI.Elements.UIItemSlot
Definition
UIItemSlot.cs:8
Terraria.Item
Definition
Item.cs:22
Terraria.Main.inventoryScale
static float inventoryScale
Definition
Main.cs:1779
Terraria.Main
Definition
Main.cs:79
Terraria.UI.ItemSlot.Draw
static void Draw(SpriteBatch spriteBatch, ref Item inv, int context, Vector2 position, Color lightColor=default(Color))
Definition
ItemSlot.cs:1777
Terraria.UI.ItemSlot.OverrideHover
static void OverrideHover(ref Item inv, int context=0)
Definition
ItemSlot.cs:322
Terraria.UI.ItemSlot.RightClick
static void RightClick(ref Item inv, int context=0)
Definition
ItemSlot.cs:1313
Terraria.UI.ItemSlot.LeftClick
static void LeftClick(ref Item inv, int context=0)
Definition
ItemSlot.cs:630
Terraria.UI.ItemSlot.MouseHover
static void MouseHover(int context=0)
Definition
ItemSlot.cs:2445
Terraria.UI.ItemSlot
Definition
ItemSlot.cs:19
Terraria.UI.UIElement.Height
StyleDimension Height
Definition
UIElement.cs:29
Terraria.UI.UIElement.Width
StyleDimension Width
Definition
UIElement.cs:27
Terraria.UI.UIElement.GetDimensions
CalculatedStyle GetDimensions()
Definition
UIElement.cs:382
Terraria.UI.UIElement
Definition
UIElement.cs:12
Microsoft.Xna.Framework.Graphics.SurfaceFormat.Vector2
@ Vector2
Microsoft.Xna.Framework.Graphics
Definition
AlphaTestEffect.cs:1
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
Terraria.GameContent.UI.Elements
Definition
AWorldListItem.cs:8
Terraria.UI
Definition
ChatLine.cs:3
Microsoft.Xna.Framework.Vector2
Definition
Vector2.cs:12
Terraria.UI.CalculatedStyle.Center
Vector2 Center()
Definition
CalculatedStyle.cs:33
Terraria.UI.StyleDimension
Definition
StyleDimension.cs:4
source
Terraria.GameContent.UI.Elements
UIItemSlot.cs
Generated by
1.10.0