-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathBankWindow.cs
More file actions
97 lines (83 loc) · 2.53 KB
/
Copy pathBankWindow.cs
File metadata and controls
97 lines (83 loc) · 2.53 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
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.Bank;
public partial class BankWindow : Window
{
public List<SlotItem> Items = [];
private readonly ScrollControl _slotContainer;
private readonly ContextMenu _contextMenu;
//Init
public BankWindow(Canvas gameCanvas) : base(
gameCanvas,
Globals.IsGuildBank
? Strings.Guilds.Bank.ToString(Globals.Me?.Guild)
: Strings.Bank.Title.ToString(),
false,
nameof(BankWindow)
)
{
DisableResizing();
Interface.InputBlockingComponents.Add(this);
Alignment = [Alignments.Center];
MinimumSize = new Point(x: 436, y: 454);
IsResizable = false;
IsClosable = true;
TitleLabel.FontSize = 14;
TitleLabel.TextColorOverride = Color.White;
Closed += (b, s) =>
{
_contextMenu?.Close();
Interface.GameUi.NotifyCloseBank();
};
_slotContainer = new ScrollControl(this, "ItemContainer")
{
Dock = Pos.Fill,
OverflowX = OverflowBehavior.Auto,
OverflowY = OverflowBehavior.Scroll,
};
_contextMenu = new ContextMenu(gameCanvas, "BankContextMenu")
{
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()
{
for (var slotIndex = 0; slotIndex < Globals.BankSlotCount; slotIndex++)
{
Items.Add(new BankItem(_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 BankItem bankItem)
{
bankItem.Update();
}
}
}
public override void Hide()
{
_contextMenu?.Close();
base.Hide();
}
}