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

@@ -7,7 +7,6 @@ using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.Research
@@ -24,11 +23,11 @@ namespace Content.Client.Research
public Button ServerConnectButton;
public Button ServerSyncButton;
public LatheBoundUserInterface Owner { get; set; }
public LatheBoundUserInterface Owner { get; }
private readonly List<LatheRecipePrototype> _shownRecipes = new();
public LatheMenu(LatheBoundUserInterface owner = null)
public LatheMenu(LatheBoundUserInterface owner)
{
SetSize = MinSize = (300, 450);
IoCManager.InjectDependencies(this);
@@ -126,7 +125,7 @@ namespace Content.Client.Research
};
hBoxButtons.AddChild(spacer);
if (Owner?.Database is ProtolatheDatabaseComponent database)
if (Owner.Database is ProtolatheDatabaseComponent database)
{
hBoxButtons.AddChild(ServerConnectButton);
hBoxButtons.AddChild(ServerSyncButton);
@@ -157,9 +156,11 @@ namespace Content.Client.Research
{
_materials.Clear();
if (Owner.Storage == null) return;
foreach (var (id, amount) in Owner.Storage)
{
if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
if (!_prototypeManager.TryIndex(id, out MaterialPrototype? materialPrototype)) continue;
var material = materialPrototype;
_materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false);
}
@@ -175,7 +176,7 @@ namespace Content.Client.Research
for (var i = 0; i < _shownRecipes.Count; i++)
{
var prototype = _shownRecipes[i];
_items[i].Disabled = !Owner.Lathe.CanProduce(prototype, quantity);
_items[i].Disabled = !Owner.Lathe?.CanProduce(prototype, quantity) ?? true;
}
}
@@ -206,6 +207,8 @@ namespace Content.Client.Research
{
_shownRecipes.Clear();
if (Owner.Database == null) return;
foreach (var prototype in Owner.Database)
{
if (_searchBar.Text.Trim().Length != 0)

View File

@@ -19,8 +19,9 @@ namespace Content.Client.Research
private readonly Label _description;
private readonly TextureRect _icon;
public LatheQueueMenu()
public LatheQueueMenu(LatheBoundUserInterface owner)
{
Owner = owner;
SetSize = MinSize = (300, 450);
Title = Loc.GetString("Lathe Queue");

View File

@@ -7,14 +7,13 @@ using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.Research
{
public class ResearchConsoleMenu : SS14Window
{
public ResearchConsoleBoundUserInterface Owner { get; set; }
public ResearchConsoleBoundUserInterface Owner { get; }
private readonly List<TechnologyPrototype> _unlockedTechnologyPrototypes = new();
private readonly List<TechnologyPrototype> _unlockableTechnologyPrototypes = new();
@@ -34,9 +33,9 @@ namespace Content.Client.Research
public Button ServerSelectionButton { get; private set; }
public Button ServerSyncButton { get; private set; }
public TechnologyPrototype TechnologySelected;
public TechnologyPrototype? TechnologySelected;
public ResearchConsoleMenu(ResearchConsoleBoundUserInterface owner = null)
public ResearchConsoleMenu(ResearchConsoleBoundUserInterface owner)
{
SetSize = MinSize = (800, 400);
@@ -274,7 +273,7 @@ namespace Content.Client.Research
for (var i = 0; i < TechnologySelected.RequiredTechnologies.Count; i++)
{
var requiredId = TechnologySelected.RequiredTechnologies[i];
if (!prototypeMan.TryIndex(requiredId, out TechnologyPrototype prototype)) continue;
if (!prototypeMan.TryIndex(requiredId, out TechnologyPrototype? prototype)) continue;
if (i == 0)
_technologyRequirements.Text = Loc.GetString("Requires") + $": {prototype.Name}";
else