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,9 +1,9 @@
using Content.Shared.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using System.Linq;
using System.Linq;
using Content.Shared.GameObjects.Components;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.GameObjects.Components.Crayon
{
@@ -13,7 +13,7 @@ namespace Content.Client.GameObjects.Components.Crayon
{
}
private CrayonWindow _menu;
private CrayonWindow? _menu;
protected override void Open()
{
@@ -31,7 +31,8 @@ namespace Content.Client.GameObjects.Components.Crayon
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_menu.UpdateState((CrayonBoundUserInterfaceState) state);
_menu?.UpdateState((CrayonBoundUserInterfaceState) state);
}
public void Select(string state)
@@ -43,7 +44,10 @@ namespace Content.Client.GameObjects.Components.Crayon
{
base.Dispose(disposing);
_menu.Close();
if (disposing)
{
_menu?.Close();
}
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Content.Client.GameObjects.Components.Crayon
return new StatusControl(this);
}
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (curState is not CrayonComponentState state)
return;

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Stylesheets;
using System.Collections.Generic;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
@@ -7,7 +8,7 @@ using Robust.Client.Utility;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using System.Collections.Generic;
using static Robust.Client.UserInterface.Controls.BaseButton;
namespace Content.Client.GameObjects.Components.Crayon
{
@@ -16,8 +17,8 @@ namespace Content.Client.GameObjects.Components.Crayon
public CrayonBoundUserInterface Owner { get; }
private readonly LineEdit _search;
private readonly GridContainer _grid;
private Dictionary<string, Texture> _decals;
private string _selected;
private Dictionary<string, Texture>? _decals;
private string? _selected;
private Color _color;
public CrayonWindow(CrayonBoundUserInterface owner)
@@ -30,7 +31,7 @@ namespace Content.Client.GameObjects.Components.Crayon
Contents.AddChild(vbox);
_search = new LineEdit();
_search.OnTextChanged += (e) => RefreshList();
_search.OnTextChanged += (_) => RefreshList();
vbox.AddChild(_search);
_grid = new GridContainer()
@@ -68,7 +69,7 @@ namespace Content.Client.GameObjects.Components.Crayon
ToolTip = decal,
Modulate = _color
};
button.OnPressed += Button_OnPressed;
button.OnPressed += ButtonOnPressed;
if (_selected == decal)
{
var panelContainer = new PanelContainer()
@@ -91,11 +92,14 @@ namespace Content.Client.GameObjects.Components.Crayon
}
}
private void Button_OnPressed(BaseButton.ButtonEventArgs obj)
private void ButtonOnPressed(ButtonEventArgs obj)
{
Owner.Select(obj.Button.Name);
_selected = obj.Button.Name;
RefreshList();
if (obj.Button.Name != null)
{
Owner.Select(obj.Button.Name);
_selected = obj.Button.Name;
RefreshList();
}
}
public void UpdateState(CrayonBoundUserInterfaceState state)