-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathRecipeItem.cs
More file actions
108 lines (86 loc) · 2.5 KB
/
Copy pathRecipeItem.cs
File metadata and controls
108 lines (86 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.Framework.Gwen.Input;
using Intersect.Client.Framework.Input;
using Intersect.Client.General;
using Intersect.Framework.Core.GameObjects.Crafting;
using Intersect.Framework.Core.GameObjects.Items;
namespace Intersect.Client.Interface.Game.Crafting;
public partial class RecipeItem
{
public ImagePanel? Container;
//Dragging
private bool mCanDrag;
//References
private CraftingWindow mCraftingWindow;
private Draggable? mDragIcon;
//Slot info
CraftingRecipeIngredient mIngredient;
//Mouse Event Variables
private bool mMouseOver;
private int mMouseX = -1;
private int mMouseY = -1;
public ImagePanel? Pnl;
public RecipeItem(CraftingWindow craftingWindow, CraftingRecipeIngredient ingredient)
{
mCraftingWindow = craftingWindow;
mIngredient = ingredient;
}
public void Setup(string name)
{
Pnl = new ImagePanel(Container, name);
Pnl.HoverEnter += pnl_HoverEnter;
Pnl.HoverLeave += pnl_HoverLeave;
}
public void LoadItem()
{
var item = ItemDescriptor.Get(mIngredient.ItemId);
if (item != null)
{
var itemTex = Globals.ContentManager.GetTexture(Framework.Content.TextureType.Item, item.Icon);
if (itemTex != null)
{
Pnl.Texture = itemTex;
Pnl.RenderColor = item.Color;
}
else
{
if (Pnl.Texture != null)
{
Pnl.Texture = null;
}
}
}
else
{
if (Pnl.Texture != null)
{
Pnl.Texture = null;
}
}
}
void pnl_HoverLeave(Base sender, EventArgs arguments)
{
mMouseOver = false;
mMouseX = -1;
mMouseY = -1;
Interface.GameUi.ItemDescriptionWindow?.Hide();
}
void pnl_HoverEnter(Base sender, EventArgs arguments)
{
if (InputHandler.MouseFocus != null)
{
return;
}
mMouseOver = true;
mCanDrag = true;
if (Globals.InputManager.IsMouseButtonDown(MouseButton.Left))
{
mCanDrag = false;
return;
}
if (mIngredient != null && ItemDescriptor.TryGet(mIngredient.ItemId, out var itemDescriptor))
{
Interface.GameUi.ItemDescriptionWindow?.Show(itemDescriptor, mIngredient.Quantity);
}
}
}