Enable nullability in Content.Client (#3257)

* Enable nullability in Content.Client

* Remove #nullable enable

* Merge fixes

* Remove Debug.Assert

* Merge fixes

* Fix build

* Fix build
This commit is contained in:
DrSmugleaf
2021-03-10 14:48:29 +01:00
committed by GitHub
parent 4f9bd4e802
commit 902aa128c2
270 changed files with 1774 additions and 1550 deletions

View File

@@ -1,5 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Client.GameObjects.Components.Clothing;
@@ -268,7 +267,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
}
}
public bool TryGetSlot(Slots slot, out IEntity? item)
public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out IEntity? item)
{
return _slots.TryGetValue(slot, out item);
}

View File

@@ -25,13 +25,13 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
private readonly Dictionary<Slots, List<ItemSlotButton>> _inventoryButtons
= new();
private ItemSlotButton _hudButtonPocket1;
private ItemSlotButton _hudButtonPocket2;
private ItemSlotButton _hudButtonBelt;
private ItemSlotButton _hudButtonBack;
private ItemSlotButton _hudButtonId;
private Control _rightQuickButtonsContainer;
private Control _leftQuickButtonsContainer;
private ItemSlotButton _hudButtonPocket1 = default!;
private ItemSlotButton _hudButtonPocket2 = default!;
private ItemSlotButton _hudButtonBelt = default!;
private ItemSlotButton _hudButtonBack = default!;
private ItemSlotButton _hudButtonId = default!;
private Control _rightQuickButtonsContainer = default!;
private Control _leftQuickButtonsContainer = default!;
public HumanInventoryInterfaceController(ClientInventoryComponent owner) : base(owner)
{
@@ -47,7 +47,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
button.OnPressed = (e) => AddToInventory(e, slot);
button.OnStoragePressed = (e) => OpenStorage(e, slot);
button.OnHover = (e) => RequestItemHover(slot);
button.OnHover = (_) => RequestItemHover(slot);
_inventoryButtons.Add(slot, new List<ItemSlotButton> {button});
}
@@ -59,7 +59,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
OnPressed = (e) => AddToInventory(e, slot),
OnStoragePressed = (e) => OpenStorage(e, slot),
OnHover = (e) => RequestItemHover(slot)
OnHover = (_) => RequestItemHover(slot)
};
_inventoryButtons[slot].Add(variable);
}
@@ -93,8 +93,8 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
};
}
public override SS14Window Window => _window;
private HumanInventoryWindow _window;
public override SS14Window? Window => _window;
private HumanInventoryWindow? _window;
public override IEnumerable<ItemSlotButton> GetItemSlotButtons(Slots slot)
{
@@ -152,7 +152,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
protected override void HandleInventoryKeybind(GUIBoundKeyEventArgs args, Slots slot)
{
if (!_inventoryButtons.TryGetValue(slot, out var buttons))
if (!_inventoryButtons.ContainsKey(slot))
return;
if (!Owner.TryGetSlot(slot, out var item))
return;

View File

@@ -22,10 +22,9 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void Initialize()
{
}
public abstract SS14Window Window { get; }
public abstract SS14Window? Window { get; }
protected ClientInventoryComponent Owner { get; }
public virtual void PlayerAttached()
@@ -35,11 +34,11 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
{
if (b)
{
Window.Open();
Window?.Open();
}
else
{
Window.Close();
Window?.Close();
}
};
}
@@ -47,7 +46,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
public virtual void PlayerDetached()
{
GameHud.InventoryButtonVisible = false;
Window.Close();
Window?.Close();
}
public virtual void Dispose()

View File

@@ -13,12 +13,12 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
[UsedImplicitly]
public class StrippableBoundUserInterface : BoundUserInterface
{
public Dictionary<Slots, string> Inventory { get; private set; }
public Dictionary<string, string> Hands { get; private set; }
public Dictionary<EntityUid, string> Handcuffs { get; private set; }
public Dictionary<Slots, string>? Inventory { get; private set; }
public Dictionary<string, string>? Hands { get; private set; }
public Dictionary<EntityUid, string>? Handcuffs { get; private set; }
[ViewVariables]
private StrippingMenu _strippingMenu;
private StrippingMenu? _strippingMenu;
public StrippableBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
@@ -41,7 +41,7 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
if (!disposing)
return;
_strippingMenu.Dispose();
_strippingMenu?.Dispose();
}
private void UpdateMenu()