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:
@@ -13,7 +13,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.PDA
|
||||
{
|
||||
@@ -23,12 +23,11 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
|
||||
private PDAMenu _menu;
|
||||
private PDAMenuPopup _failPopup;
|
||||
private PDAMenu? _menu;
|
||||
private PDAMenuPopup? _failPopup;
|
||||
|
||||
public PDABoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
@@ -38,17 +37,17 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
_menu = new PDAMenu(this, _prototypeManager);
|
||||
_menu.OpenToLeft();
|
||||
_menu.OnClose += Close;
|
||||
_menu.FlashLightToggleButton.OnToggled += args =>
|
||||
_menu.FlashLightToggleButton.OnToggled += _ =>
|
||||
{
|
||||
SendMessage(new PDAToggleFlashlightMessage());
|
||||
};
|
||||
|
||||
_menu.EjectIDButton.OnPressed += args =>
|
||||
_menu.EjectIDButton.OnPressed += _ =>
|
||||
{
|
||||
SendMessage(new PDAEjectIDMessage());
|
||||
};
|
||||
|
||||
_menu.EjectPenButton.OnPressed += args =>
|
||||
_menu.EjectPenButton.OnPressed += _ =>
|
||||
{
|
||||
SendMessage(new PDAEjectPenMessage());
|
||||
};
|
||||
@@ -62,9 +61,9 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
}
|
||||
};
|
||||
|
||||
_menu.OnListingButtonPressed += (args, listing) =>
|
||||
_menu.OnListingButtonPressed += (_, listing) =>
|
||||
{
|
||||
if (_menu.CurrentLoggedInAccount.DataBalance < listing.Price)
|
||||
if (_menu.CurrentLoggedInAccount?.DataBalance < listing.Price)
|
||||
{
|
||||
_failPopup = new PDAMenuPopup(Loc.GetString("Insufficient funds!"));
|
||||
_userInterfaceManager.ModalRoot.AddChild(_failPopup);
|
||||
@@ -78,7 +77,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
SendMessage(new PDAUplinkBuyListingMessage(listing.ItemId));
|
||||
};
|
||||
|
||||
_menu.OnCategoryButtonPressed += (args, category) =>
|
||||
_menu.OnCategoryButtonPressed += (_, category) =>
|
||||
{
|
||||
_menu.CurrentFilterCategory = category;
|
||||
SendMessage(new PDARequestUpdateInterfaceMessage());
|
||||
@@ -89,15 +88,23 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
DebugTools.Assert(state is PDAUBoundUserInterfaceState);
|
||||
|
||||
if (_menu == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case PDAUpdateState msg:
|
||||
{
|
||||
_menu.FlashLightToggleButton.Pressed = msg.FlashlightEnabled;
|
||||
_menu.PDAOwnerLabel.SetMarkup(Loc.GetString("Owner: [color=white]{0}[/color]",
|
||||
msg.PDAOwnerInfo.ActualOwnerName));
|
||||
|
||||
if (msg.PDAOwnerInfo.ActualOwnerName != null)
|
||||
{
|
||||
_menu.PDAOwnerLabel.SetMarkup(Loc.GetString("Owner: [color=white]{0}[/color]",
|
||||
msg.PDAOwnerInfo.ActualOwnerName));
|
||||
}
|
||||
|
||||
if (msg.PDAOwnerInfo.JobTitle == null || msg.PDAOwnerInfo.IdOwner == null)
|
||||
{
|
||||
@@ -113,6 +120,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
|
||||
_menu.EjectIDButton.Visible = msg.PDAOwnerInfo.IdOwner != null;
|
||||
_menu.EjectPenButton.Visible = msg.HasPen;
|
||||
|
||||
if (msg.Account != null)
|
||||
{
|
||||
_menu.CurrentLoggedInAccount = msg.Account;
|
||||
@@ -130,6 +138,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
_menu.AddListingGui(item);
|
||||
}
|
||||
}
|
||||
|
||||
_menu.MasterTabContainer.SetTabVisible(1, msg.Account != null);
|
||||
break;
|
||||
}
|
||||
@@ -243,8 +252,8 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
|
||||
public readonly VBoxContainer CategoryListContainer;
|
||||
public readonly RichTextLabel BalanceInfo;
|
||||
public event Action<BaseButton.ButtonEventArgs, UplinkListingData> OnListingButtonPressed;
|
||||
public event Action<BaseButton.ButtonEventArgs, UplinkCategory> OnCategoryButtonPressed;
|
||||
public event Action<ButtonEventArgs, UplinkListingData>? OnListingButtonPressed;
|
||||
public event Action<ButtonEventArgs, UplinkCategory>? OnCategoryButtonPressed;
|
||||
|
||||
public UplinkCategory CurrentFilterCategory
|
||||
{
|
||||
@@ -260,16 +269,14 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
}
|
||||
}
|
||||
|
||||
public UplinkAccountData CurrentLoggedInAccount
|
||||
public UplinkAccountData? CurrentLoggedInAccount
|
||||
{
|
||||
get => _loggedInUplinkAccount;
|
||||
set => _loggedInUplinkAccount = value;
|
||||
}
|
||||
|
||||
|
||||
private UplinkCategory _currentFilter;
|
||||
private UplinkAccountData _loggedInUplinkAccount;
|
||||
|
||||
private UplinkAccountData? _loggedInUplinkAccount;
|
||||
|
||||
public PDAMenu(PDABoundUserInterface owner, IPrototypeManager prototypeManager)
|
||||
{
|
||||
@@ -462,7 +469,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
|
||||
public void AddListingGui(UplinkListingData listing)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(listing.ItemId, out EntityPrototype prototype) || listing.Category != CurrentFilterCategory)
|
||||
if (!_prototypeManager.TryIndex(listing.ItemId, out EntityPrototype? prototype) || listing.Category != CurrentFilterCategory)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -472,7 +479,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
Text = listing.ListingName == string.Empty ? prototype.Name : listing.ListingName,
|
||||
ToolTip = listing.Description == string.Empty ? prototype.Description : listing.Description,
|
||||
HorizontalExpand = true,
|
||||
Modulate = _loggedInUplinkAccount.DataBalance >= listing.Price
|
||||
Modulate = _loggedInUplinkAccount?.DataBalance >= listing.Price
|
||||
? Color.White
|
||||
: Color.Gray.WithAlpha(0.30f)
|
||||
};
|
||||
@@ -481,7 +488,7 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
{
|
||||
Text = $"{listing.Price} TC",
|
||||
HorizontalAlignment = HAlignment.Right,
|
||||
Modulate = _loggedInUplinkAccount.DataBalance >= listing.Price
|
||||
Modulate = _loggedInUplinkAccount?.DataBalance >= listing.Price
|
||||
? weightedColor
|
||||
: Color.Gray.WithAlpha(0.30f)
|
||||
};
|
||||
@@ -511,9 +518,8 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
}
|
||||
};
|
||||
|
||||
var pdaUplinkListingButton = new PDAUplinkItemButton
|
||||
var pdaUplinkListingButton = new PDAUplinkItemButton(listing)
|
||||
{
|
||||
ButtonListing = listing,
|
||||
Children =
|
||||
{
|
||||
listingButtonPanelContainer
|
||||
@@ -531,7 +537,12 @@ namespace Content.Client.GameObjects.Components.PDA
|
||||
|
||||
private sealed class PDAUplinkItemButton : ContainerButton
|
||||
{
|
||||
public UplinkListingData ButtonListing;
|
||||
public PDAUplinkItemButton(UplinkListingData data)
|
||||
{
|
||||
ButtonListing = data;
|
||||
}
|
||||
|
||||
public UplinkListingData ButtonListing { get; }
|
||||
}
|
||||
|
||||
private sealed class PDAUplinkCategoryButton : Button
|
||||
|
||||
Reference in New Issue
Block a user