Skip to content

Commit a5baa4b

Browse files
committed
make explicit context menu as possible null (bcuz hotbar) and not null where it exists
1 parent c02a304 commit a5baa4b

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Intersect.Client.Core/Interface/Game/Bag/BagItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public BagItem(BagWindow bagWindow, Base parent, int index, ContextMenu contextM
6060

6161
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
6262

63-
_contextMenu.ClearChildren();
63+
_contextMenu!.ClearChildren();
6464
_withdrawContextItem = _contextMenu.AddItem(Strings.BagContextMenu.Withdraw);
6565
_withdrawContextItem.Clicked += _withdrawMenuItem_Clicked;
6666
_contextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
@@ -81,7 +81,7 @@ public override void OpenContextMenu()
8181
}
8282

8383
// Clear the context menu and add the withdraw item with updated item name
84-
_contextMenu.ClearChildren();
84+
_contextMenu!.ClearChildren();
8585
_withdrawContextItem.SetText(Strings.BagContextMenu.Withdraw.ToString(item.Name));
8686
_contextMenu.AddChild(_withdrawContextItem);
8787
base.OpenContextMenu();

Intersect.Client.Core/Interface/Game/Bank/BankItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public BankItem(BankWindow bankWindow, Base parent, int index, ContextMenu conte
6363

6464
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
6565

66-
_contextMenu.ClearChildren();
66+
_contextMenu!.ClearChildren();
6767
_withdrawContextItem = _contextMenu.AddItem(Strings.BankContextMenu.Withdraw);
6868
_withdrawContextItem.Clicked += _withdrawMenuItem_Clicked;
6969
_contextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
@@ -82,7 +82,7 @@ public void OpenContextMenu()
8282
}
8383

8484
// Clear the context menu and add the withdraw item with updated item name
85-
_contextMenu.ClearChildren();
85+
_contextMenu!.ClearChildren();
8686
_withdrawContextItem.SetText(Strings.BankContextMenu.Withdraw.ToString(item.Name));
8787
_contextMenu.AddChild(_withdrawContextItem);
8888

Intersect.Client.Core/Interface/Game/Inventory/InventoryItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public InventoryItem(InventoryWindow inventoryWindow, Base parent, int index, Co
9797

9898
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
9999

100-
_contextMenu.ClearChildren();
100+
_contextMenu!.ClearChildren();
101101
_useItemMenuItem = _contextMenu.AddItem(Strings.ItemContextMenu.Use);
102102
_useItemMenuItem.Clicked += _useItemContextItem_Clicked;
103103
_dropItemMenuItem = _contextMenu.AddItem(Strings.ItemContextMenu.Drop);
@@ -117,7 +117,7 @@ public InventoryItem(InventoryWindow inventoryWindow, Base parent, int index, Co
117117
public override void OpenContextMenu()
118118
{
119119
// Clear out the old options since we might not show all of them
120-
_contextMenu.ClearChildren();
120+
_contextMenu!.ClearChildren();
121121

122122
if (Globals.Me?.Inventory[SlotIndex] is not { } inventorySlot)
123123
{

Intersect.Client.Core/Interface/Game/Shop/ShopItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ShopItem(ShopWindow shopWindow, Base parent, int index, ContextMenu conte
3434
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
3535

3636
//TODO: Is this a memory leak?
37-
_contextMenu.ClearChildren();
37+
_contextMenu!.ClearChildren();
3838
_buyMenuItem = _contextMenu.AddItem(Strings.ShopContextMenu.Buy);
3939
_buyMenuItem.Clicked += _buyMenuItem_Clicked;
4040
_contextMenu.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());

Intersect.Client.Core/Interface/Game/SlotItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ public partial class SlotItem : ImagePanel
77
{
88
public readonly int SlotIndex;
99
protected readonly ImagePanel _iconImage;
10-
protected readonly ContextMenu _contextMenu;
10+
protected readonly ContextMenu? _contextMenu;
1111

12-
public SlotItem(Base parent, string name, int index, ContextMenu contextMenu) : base(parent, name)
12+
public SlotItem(Base parent, string name, int index, ContextMenu? contextMenu) : base(parent, name)
1313
{
1414
SlotIndex = index;
1515

@@ -35,7 +35,7 @@ public virtual void Update()
3535
public virtual void OpenContextMenu()
3636
{
3737
// Display our menu... If we have anything to display.
38-
if (_contextMenu.Children.Count > 0)
38+
if (_contextMenu?.Children.Count > 0)
3939
{
4040
_contextMenu.Open(Pos.None);
4141
}

Intersect.Client.Core/Interface/Game/Spells/SpellItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public SpellItem(SpellsWindow spellWindow, Base parent, int index, ContextMenu c
6161

6262
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
6363

64-
_contextMenu.ClearChildren();
64+
_contextMenu!.ClearChildren();
6565
_useSpellMenuItem = _contextMenu.AddItem(Strings.SpellContextMenu.Cast.ToString());
6666
_useSpellMenuItem.Clicked += _useSpellMenuItem_Clicked;
6767
_forgetSpellMenuItem = _contextMenu.AddItem(Strings.SpellContextMenu.Forget.ToString());
@@ -74,7 +74,7 @@ public SpellItem(SpellsWindow spellWindow, Base parent, int index, ContextMenu c
7474
public void OpenContextMenu()
7575
{
7676
// Clear out the old options.
77-
_contextMenu.ClearChildren();
77+
_contextMenu!.ClearChildren();
7878

7979
if (Globals.Me?.Spells is not { Length: > 0 } spellSlots)
8080
{

0 commit comments

Comments
 (0)