-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathBagWindow.cs
More file actions
88 lines (74 loc) · 2.33 KB
/
Copy pathBagWindow.cs
File metadata and controls
88 lines (74 loc) · 2.33 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
using Intersect.Client.Core;
using Intersect.Client.Framework.File_Management;
using Intersect.Client.Framework.Gwen;
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.General;
using Intersect.Client.Localization;
using Intersect.Client.Utilities;
namespace Intersect.Client.Interface.Game.Bag;
public partial class BagWindow : Window
{
public List<SlotItem> Items = [];
private readonly ScrollControl _slotContainer;
private readonly ContextMenu _contextMenu;
public BagWindow(Canvas gameCanvas) : base(gameCanvas, Strings.Bags.Title, false, nameof(BagWindow))
{
DisableResizing();
Interface.InputBlockingComponents.Add(this);
Alignment = [Alignments.Center];
MinimumSize = new Point(x: 192, y: 254);
IsResizable = false;
IsClosable = true;
TitleLabel.FontSize = 14;
TitleLabel.TextColorOverride = Color.White;
_slotContainer = new ScrollControl(this, "ItemContainer")
{
Dock = Pos.Fill,
OverflowX = OverflowBehavior.Auto,
OverflowY = OverflowBehavior.Scroll,
};
_contextMenu = new ContextMenu(gameCanvas, "BagContextMenu")
{
IsVisibleInParent = false,
IconMarginDisabled = true,
ItemFont = GameContentManager.Current.GetFont(name: "sourcesansproblack"),
ItemFontSize = 10,
};
}
protected override void EnsureInitialized()
{
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
InitItemContainer();
}
private void InitItemContainer()
{
if (Globals.BagSlots is not { Length: > 0 } bagSlots)
{
return;
}
for (var slotIndex = 0; slotIndex < bagSlots.Length; slotIndex++)
{
Items.Add(new BagItem(_slotContainer, slotIndex, _contextMenu));
}
PopulateSlotContainer.Populate(_slotContainer, Items);
}
public void Update()
{
if (IsVisibleInTree == false)
{
return;
}
for (var i = 0; i < Items.Count; i++)
{
if (Items[i] is BagItem bagItem)
{
bagItem.Update();
}
}
}
public override void Hide()
{
_contextMenu?.Close();
base.Hide();
}
}