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:
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -18,6 +18,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Timing;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace Content.Client.UserInterface
|
||||
public bool IsDragging => _dragDropHelper.IsDragging;
|
||||
|
||||
// parallel list of actions currently selectable in itemList
|
||||
private BaseActionPrototype[] _actionList;
|
||||
private BaseActionPrototype[] _actionList = new BaseActionPrototype[0];
|
||||
|
||||
private readonly ActionManager _actionManager;
|
||||
private readonly ClientActionsComponent _actionsComponent;
|
||||
@@ -87,7 +88,7 @@ namespace Content.Client.UserInterface
|
||||
(_filterButton = new MultiselectOptionButton<string>()
|
||||
{
|
||||
Label = Loc.GetString("Filter")
|
||||
}),
|
||||
})
|
||||
}
|
||||
},
|
||||
(_clearButton = new Button
|
||||
@@ -155,7 +156,7 @@ namespace Content.Client.UserInterface
|
||||
_gameHud.ActionsButtonDown = true;
|
||||
foreach (var actionMenuControl in _resultsGrid.Children)
|
||||
{
|
||||
var actionMenuItem = (actionMenuControl as ActionMenuItem);
|
||||
var actionMenuItem = (ActionMenuItem) actionMenuControl;
|
||||
actionMenuItem.OnButtonDown += OnItemButtonDown;
|
||||
actionMenuItem.OnButtonUp += OnItemButtonUp;
|
||||
actionMenuItem.OnPressed += OnItemPressed;
|
||||
@@ -172,7 +173,7 @@ namespace Content.Client.UserInterface
|
||||
_gameHud.ActionsButtonDown = false;
|
||||
foreach (var actionMenuControl in _resultsGrid.Children)
|
||||
{
|
||||
var actionMenuItem = (actionMenuControl as ActionMenuItem);
|
||||
var actionMenuItem = (ActionMenuItem) actionMenuControl;
|
||||
actionMenuItem.OnButtonDown -= OnItemButtonDown;
|
||||
actionMenuItem.OnButtonUp -= OnItemButtonUp;
|
||||
actionMenuItem.OnPressed -= OnItemPressed;
|
||||
@@ -195,7 +196,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private bool OnBeginActionDrag()
|
||||
{
|
||||
_dragShadow.Texture = _dragDropHelper.Dragged.Action.Icon.Frame0();
|
||||
_dragShadow.Texture = _dragDropHelper.Dragged!.Action.Icon.Frame0();
|
||||
// don't make visible until frameupdate, otherwise it'll flicker
|
||||
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
|
||||
return true;
|
||||
@@ -215,13 +216,18 @@ namespace Content.Client.UserInterface
|
||||
_dragShadow.Visible = false;
|
||||
}
|
||||
|
||||
private void OnItemButtonDown(BaseButton.ButtonEventArgs args)
|
||||
private void OnItemButtonDown(ButtonEventArgs args)
|
||||
{
|
||||
if (args.Event.Function != EngineKeyFunctions.UIClick) return;
|
||||
_dragDropHelper.MouseDown(args.Button as ActionMenuItem);
|
||||
if (args.Event.Function != EngineKeyFunctions.UIClick ||
|
||||
args.Button is not ActionMenuItem action)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dragDropHelper.MouseDown(action);
|
||||
}
|
||||
|
||||
private void OnItemButtonUp(BaseButton.ButtonEventArgs args)
|
||||
private void OnItemButtonUp(ButtonEventArgs args)
|
||||
{
|
||||
// note the buttonup only fires on the control that was originally
|
||||
// pressed to initiate the drag, NOT the one we are currently hovering
|
||||
@@ -288,7 +294,7 @@ namespace Content.Client.UserInterface
|
||||
_dragDropHelper.EndDrag();
|
||||
}
|
||||
|
||||
private void OnItemPressed(BaseButton.ButtonEventArgs args)
|
||||
private void OnItemPressed(ButtonEventArgs args)
|
||||
{
|
||||
if (args.Button is not ActionMenuItem actionMenuItem) return;
|
||||
switch (actionMenuItem.Action)
|
||||
@@ -307,7 +313,7 @@ namespace Content.Client.UserInterface
|
||||
_actionsUI.UpdateUI();
|
||||
}
|
||||
|
||||
private void OnClearButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
private void OnClearButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
_searchBar.Clear();
|
||||
_filterButton.DeselectAll();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Client.UserInterface;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.GameObjects.Components.Mobs.Actions;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
@@ -531,7 +530,7 @@ namespace Content.Client.UserInterface
|
||||
private bool OnBeginActionDrag()
|
||||
{
|
||||
// only initiate the drag if the slot has an action in it
|
||||
if (Locked || DragDropHelper.Dragged.Action == null) return false;
|
||||
if (Locked || DragDropHelper.Dragged?.Action == null) return false;
|
||||
|
||||
_dragShadow.Texture = DragDropHelper.Dragged.Action.Icon.Frame0();
|
||||
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
|
||||
@@ -542,7 +541,7 @@ namespace Content.Client.UserInterface
|
||||
private bool OnContinueActionDrag(float frameTime)
|
||||
{
|
||||
// stop if there's no action in the slot
|
||||
if (Locked || DragDropHelper.Dragged.Action == null) return false;
|
||||
if (Locked || DragDropHelper.Dragged?.Action == null) return false;
|
||||
|
||||
// keep dragged entity centered under mouse
|
||||
LayoutContainer.SetPosition(_dragShadow, UserInterfaceManager.MousePositionScaled - (32, 32));
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Content.Client.UserInterface.AdminMenu
|
||||
[Dependency] private readonly IClientAdminManager _clientAdminManager = default!;
|
||||
[Dependency] private readonly IClientConGroupController _clientConGroupController = default!;
|
||||
|
||||
private AdminMenuWindow _window;
|
||||
private List<SS14Window> _commandWindows;
|
||||
private AdminMenuWindow? _window;
|
||||
private List<SS14Window> _commandWindows = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@@ -29,10 +29,10 @@ namespace Content.Client.UserInterface.AdminMenu
|
||||
|
||||
_commandWindows = new List<SS14Window>();
|
||||
// Reset the AdminMenu Window on disconnect
|
||||
_netManager.Disconnect += (sender, channel) => ResetWindow();
|
||||
_netManager.Disconnect += (_, _) => ResetWindow();
|
||||
|
||||
_inputManager.SetInputCommand(ContentKeyFunctions.OpenAdminMenu,
|
||||
InputCmdHandler.FromDelegate(session => Toggle()));
|
||||
InputCmdHandler.FromDelegate(_ => Toggle()));
|
||||
|
||||
_clientAdminManager.AdminStatusUpdated += () =>
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace Content.Client.UserInterface.AdminMenu
|
||||
|
||||
private void HandlePlayerListMessage(AdminMenuPlayerListMessage msg)
|
||||
{
|
||||
_window.RefreshPlayerList(msg.NamesToPlayers);
|
||||
_window?.RefreshPlayerList(msg.NamesToPlayers);
|
||||
}
|
||||
|
||||
public void ResetWindow()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Client.UserInterface.Atmos.GasTank
|
||||
{
|
||||
}
|
||||
|
||||
private GasTankWindow _window;
|
||||
private GasTankWindow? _window;
|
||||
|
||||
public void SetOutputPressure(in float value)
|
||||
{
|
||||
@@ -37,14 +37,15 @@ namespace Content.Client.UserInterface.Atmos.GasTank
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
_window.UpdateState((GasTankBoundUserInterfaceState) state);
|
||||
|
||||
_window?.UpdateState((GasTankBoundUserInterfaceState) state);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_window.Close();
|
||||
_window?.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
@@ -17,9 +18,9 @@ namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
public CargoConsoleBoundUserInterface Owner { get; private set; }
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs> OnItemSelected;
|
||||
public event Action<BaseButton.ButtonEventArgs> OnOrderApproved;
|
||||
public event Action<BaseButton.ButtonEventArgs> OnOrderCanceled;
|
||||
public event Action<ButtonEventArgs>? OnItemSelected;
|
||||
public event Action<ButtonEventArgs>? OnOrderApproved;
|
||||
public event Action<ButtonEventArgs>? OnOrderCanceled;
|
||||
|
||||
private readonly List<string> _categoryStrings = new();
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace Content.Client.UserInterface.Cargo
|
||||
public Button CallShuttleButton { get; set; }
|
||||
public Button PermissionsButton { get; set; }
|
||||
|
||||
private string _category = null;
|
||||
private string? _category = null;
|
||||
|
||||
public CargoConsoleMenu(CargoConsoleBoundUserInterface owner)
|
||||
{
|
||||
@@ -197,7 +198,7 @@ namespace Content.Client.UserInterface.Cargo
|
||||
_categories.OnItemSelected += OnCategoryItemSelected;
|
||||
}
|
||||
|
||||
private void OnCallShuttleButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
private void OnCallShuttleButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -228,6 +229,11 @@ namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
Products.RemoveAllChildren();
|
||||
|
||||
if (Owner.Market == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var search = _searchBar.Text.Trim().ToLowerInvariant();
|
||||
foreach (var prototype in Owner.Market.Products)
|
||||
{
|
||||
@@ -260,6 +266,11 @@ namespace Content.Client.UserInterface.Cargo
|
||||
_categoryStrings.Clear();
|
||||
_categories.Clear();
|
||||
|
||||
if (Owner.Market == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_categoryStrings.Add(Loc.GetString("All"));
|
||||
|
||||
var search = _searchBar.Text.Trim().ToLowerInvariant();
|
||||
@@ -284,13 +295,25 @@ namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
_orders.RemoveAllChildren();
|
||||
_requests.RemoveAllChildren();
|
||||
|
||||
if (Owner.Orders == null || Owner.Market == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var order in Owner.Orders.Orders)
|
||||
{
|
||||
var row = new CargoOrderRow();
|
||||
row.Order = order;
|
||||
row.Icon.Texture = Owner.Market.GetProduct(order.ProductId).Icon.Frame0();
|
||||
row.ProductName.Text = $"{Owner.Market.GetProduct(order.ProductId).Name} (x{order.Amount}) by {order.Requester}";
|
||||
row.Description.Text = $"Reasons: {order.Reason}";
|
||||
var row = new CargoOrderRow
|
||||
{
|
||||
Order = order,
|
||||
Icon = {Texture = Owner.Market.GetProduct(order.ProductId)?.Icon.Frame0()},
|
||||
ProductName =
|
||||
{
|
||||
Text =
|
||||
$"{Owner.Market.GetProduct(order.ProductId)?.Name} (x{order.Amount}) by {order.Requester}"
|
||||
},
|
||||
Description = {Text = $"Reasons: {order.Reason}"}
|
||||
};
|
||||
row.Cancel.OnPressed += (args) => { OnOrderCanceled?.Invoke(args); };
|
||||
if (order.Approved)
|
||||
{
|
||||
@@ -342,7 +365,7 @@ namespace Content.Client.UserInterface.Cargo
|
||||
|
||||
internal class CargoProductRow : PanelContainer
|
||||
{
|
||||
public CargoProductPrototype Product { get; set; }
|
||||
public CargoProductPrototype? Product { get; set; }
|
||||
public TextureRect Icon { get; private set; }
|
||||
public Button MainButton { get; private set; }
|
||||
public Label ProductName { get; private set; }
|
||||
@@ -395,7 +418,7 @@ namespace Content.Client.UserInterface.Cargo
|
||||
|
||||
internal class CargoOrderRow : PanelContainer
|
||||
{
|
||||
public CargoOrderData Order { get; set; }
|
||||
public CargoOrderData? Order { get; set; }
|
||||
public TextureRect Icon { get; private set; }
|
||||
public Label ProductName { get; private set; }
|
||||
public Label Description { get; private set; }
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
|
||||
using Content.Client.GameObjects.Components.Cargo;
|
||||
using Content.Client.GameObjects.Components.Cargo;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
public class GalacticBankSelectionMenu : SS14Window
|
||||
{
|
||||
private readonly ItemList _accounts;
|
||||
private int _accountCount = 0;
|
||||
private int _accountCount;
|
||||
private string[] _accountNames = new string[] { };
|
||||
private int[] _accountIds = new int[] { };
|
||||
private int _selectedAccountId = -1;
|
||||
|
||||
public CargoConsoleBoundUserInterface Owner;
|
||||
|
||||
public GalacticBankSelectionMenu()
|
||||
public GalacticBankSelectionMenu(CargoConsoleBoundUserInterface owner)
|
||||
{
|
||||
MinSize = SetSize = (300, 300);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
@@ -173,9 +173,9 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
|
||||
_createNewCharacterButton.ToolTip =
|
||||
$"A maximum of {_preferencesManager.Settings.MaxCharacterSlots} characters are allowed.";
|
||||
$"A maximum of {_preferencesManager.Settings!.MaxCharacterSlots} characters are allowed.";
|
||||
|
||||
foreach (var (slot, character) in _preferencesManager.Preferences.Characters)
|
||||
foreach (var (slot, character) in _preferencesManager.Preferences!.Characters)
|
||||
{
|
||||
if (character is null)
|
||||
{
|
||||
@@ -228,7 +228,7 @@ namespace Content.Client.UserInterface
|
||||
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy, humanoid);
|
||||
}
|
||||
|
||||
var isSelectedCharacter = profile == preferencesManager.Preferences.SelectedCharacter;
|
||||
var isSelectedCharacter = profile == preferencesManager.Preferences?.SelectedCharacter;
|
||||
|
||||
if (isSelectedCharacter)
|
||||
Pressed = true;
|
||||
@@ -260,9 +260,9 @@ namespace Content.Client.UserInterface
|
||||
Text = "Delete",
|
||||
Visible = !isSelectedCharacter,
|
||||
};
|
||||
deleteButton.OnPressed += args =>
|
||||
deleteButton.OnPressed += _ =>
|
||||
{
|
||||
Parent.RemoveChild(this);
|
||||
Parent?.RemoveChild(this);
|
||||
preferencesManager.DeleteCharacter(profile);
|
||||
};
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace Content.Client.UserInterface
|
||||
return;
|
||||
|
||||
_previewDummy.Delete();
|
||||
_previewDummy = null;
|
||||
_previewDummy = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Shared.Actions;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System;
|
||||
using Content.Shared.Alert;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
private readonly IClientConsoleHost _consoleHost;
|
||||
|
||||
private OptionsMenu optionsMenu;
|
||||
private readonly OptionsMenu _optionsMenu;
|
||||
|
||||
public EscapeMenu(IClientConsoleHost consoleHost)
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
optionsMenu = new OptionsMenu();
|
||||
_optionsMenu = new OptionsMenu();
|
||||
|
||||
OptionsButton.OnPressed += OnOptionsButtonClicked;
|
||||
QuitButton.OnPressed += OnQuitButtonClicked;
|
||||
@@ -40,15 +40,16 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void OnOptionsButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
optionsMenu.OpenCentered();
|
||||
_optionsMenu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
optionsMenu.Dispose();
|
||||
_optionsMenu.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
@@ -6,6 +7,7 @@ using Content.Shared.Input;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
@@ -28,37 +30,37 @@ namespace Content.Client.UserInterface
|
||||
|
||||
// Escape top button.
|
||||
bool EscapeButtonDown { get; set; }
|
||||
Action<bool> EscapeButtonToggled { get; set; }
|
||||
Action<bool>? EscapeButtonToggled { get; set; }
|
||||
|
||||
// Character top button.
|
||||
bool CharacterButtonDown { get; set; }
|
||||
bool CharacterButtonVisible { get; set; }
|
||||
Action<bool> CharacterButtonToggled { get; set; }
|
||||
Action<bool>? CharacterButtonToggled { get; set; }
|
||||
|
||||
// Inventory top button.
|
||||
bool InventoryButtonDown { get; set; }
|
||||
bool InventoryButtonVisible { get; set; }
|
||||
Action<bool> InventoryButtonToggled { get; set; }
|
||||
Action<bool>? InventoryButtonToggled { get; set; }
|
||||
|
||||
// Crafting top button.
|
||||
bool CraftingButtonDown { get; set; }
|
||||
bool CraftingButtonVisible { get; set; }
|
||||
Action<bool> CraftingButtonToggled { get; set; }
|
||||
Action<bool>? CraftingButtonToggled { get; set; }
|
||||
|
||||
// Actions top button.
|
||||
bool ActionsButtonDown { get; set; }
|
||||
bool ActionsButtonVisible { get; set; }
|
||||
Action<bool> ActionsButtonToggled { get; set; }
|
||||
Action<bool>? ActionsButtonToggled { get; set; }
|
||||
|
||||
// Admin top button.
|
||||
bool AdminButtonDown { get; set; }
|
||||
bool AdminButtonVisible { get; set; }
|
||||
Action<bool> AdminButtonToggled { get; set; }
|
||||
Action<bool>? AdminButtonToggled { get; set; }
|
||||
|
||||
// Sandbox top button.
|
||||
bool SandboxButtonDown { get; set; }
|
||||
bool SandboxButtonVisible { get; set; }
|
||||
Action<bool> SandboxButtonToggled { get; set; }
|
||||
Action<bool>? SandboxButtonToggled { get; set; }
|
||||
|
||||
Control HandsContainer { get; }
|
||||
Control SuspicionContainer { get; }
|
||||
@@ -68,8 +70,8 @@ namespace Content.Client.UserInterface
|
||||
bool CombatPanelVisible { get; set; }
|
||||
bool CombatModeActive { get; set; }
|
||||
TargetingZone TargetingZone { get; set; }
|
||||
Action<bool> OnCombatModeChanged { get; set; }
|
||||
Action<TargetingZone> OnTargetingZoneChanged { get; set; }
|
||||
Action<bool>? OnCombatModeChanged { get; set; }
|
||||
Action<TargetingZone>? OnTargetingZoneChanged { get; set; }
|
||||
|
||||
Control VoteContainer { get; }
|
||||
|
||||
@@ -81,28 +83,28 @@ namespace Content.Client.UserInterface
|
||||
|
||||
internal sealed class GameHud : IGameHud
|
||||
{
|
||||
private HBoxContainer _topButtonsContainer;
|
||||
private TopButton _buttonEscapeMenu;
|
||||
private TopButton _buttonInfo;
|
||||
private TopButton _buttonCharacterMenu;
|
||||
private TopButton _buttonInventoryMenu;
|
||||
private TopButton _buttonCraftingMenu;
|
||||
private TopButton _buttonActionsMenu;
|
||||
private TopButton _buttonAdminMenu;
|
||||
private TopButton _buttonSandboxMenu;
|
||||
private InfoWindow _infoWindow;
|
||||
private TargetingDoll _targetingDoll;
|
||||
private Button _combatModeButton;
|
||||
private VBoxContainer _combatPanelContainer;
|
||||
private VBoxContainer _topNotificationContainer;
|
||||
private HBoxContainer _topButtonsContainer = default!;
|
||||
private TopButton _buttonEscapeMenu = default!;
|
||||
private TopButton _buttonInfo = default!;
|
||||
private TopButton _buttonCharacterMenu = default!;
|
||||
private TopButton _buttonInventoryMenu = default!;
|
||||
private TopButton _buttonCraftingMenu = default!;
|
||||
private TopButton _buttonActionsMenu = default!;
|
||||
private TopButton _buttonAdminMenu = default!;
|
||||
private TopButton _buttonSandboxMenu = default!;
|
||||
private InfoWindow _infoWindow = default!;
|
||||
private TargetingDoll _targetingDoll = default!;
|
||||
private Button _combatModeButton = default!;
|
||||
private VBoxContainer _combatPanelContainer = default!;
|
||||
private VBoxContainer _topNotificationContainer = default!;
|
||||
|
||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
|
||||
public Control HandsContainer { get; private set; }
|
||||
public Control SuspicionContainer { get; private set; }
|
||||
public Control RightInventoryQuickButtonContainer { get; private set; }
|
||||
public Control LeftInventoryQuickButtonContainer { get; private set; }
|
||||
public Control HandsContainer { get; private set; } = default!;
|
||||
public Control SuspicionContainer { get; private set; } = default!;
|
||||
public Control RightInventoryQuickButtonContainer { get; private set; } = default!;
|
||||
public Control LeftInventoryQuickButtonContainer { get; private set; } = default!;
|
||||
|
||||
public bool CombatPanelVisible
|
||||
{
|
||||
@@ -122,8 +124,8 @@ namespace Content.Client.UserInterface
|
||||
set => _targetingDoll.ActiveZone = value;
|
||||
}
|
||||
|
||||
public Action<bool> OnCombatModeChanged { get; set; }
|
||||
public Action<TargetingZone> OnTargetingZoneChanged { get; set; }
|
||||
public Action<bool>? OnCombatModeChanged { get; set; }
|
||||
public Action<TargetingZone>? OnTargetingZoneChanged { get; set; }
|
||||
|
||||
public void AddTopNotification(TopNotification notification)
|
||||
{
|
||||
@@ -369,7 +371,7 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public Control RootControl { get; private set; }
|
||||
public Control RootControl { get; private set; } = default!;
|
||||
|
||||
public bool EscapeButtonDown
|
||||
{
|
||||
@@ -377,7 +379,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonEscapeMenu.Pressed = value;
|
||||
}
|
||||
|
||||
public Action<bool> EscapeButtonToggled { get; set; }
|
||||
public Action<bool>? EscapeButtonToggled { get; set; }
|
||||
|
||||
public bool CharacterButtonDown
|
||||
{
|
||||
@@ -391,7 +393,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonCharacterMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> CharacterButtonToggled { get; set; }
|
||||
public Action<bool>? CharacterButtonToggled { get; set; }
|
||||
|
||||
public bool InventoryButtonDown
|
||||
{
|
||||
@@ -405,7 +407,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonInventoryMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> InventoryButtonToggled { get; set; }
|
||||
public Action<bool>? InventoryButtonToggled { get; set; }
|
||||
|
||||
public bool CraftingButtonDown
|
||||
{
|
||||
@@ -419,7 +421,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonCraftingMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> CraftingButtonToggled { get; set; }
|
||||
public Action<bool>? CraftingButtonToggled { get; set; }
|
||||
|
||||
public bool ActionsButtonDown
|
||||
{
|
||||
@@ -433,7 +435,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonActionsMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> ActionsButtonToggled { get; set; }
|
||||
public Action<bool>? ActionsButtonToggled { get; set; }
|
||||
|
||||
public bool AdminButtonDown
|
||||
{
|
||||
@@ -447,7 +449,7 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonAdminMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> AdminButtonToggled { get; set; }
|
||||
public Action<bool>? AdminButtonToggled { get; set; }
|
||||
|
||||
public bool SandboxButtonDown
|
||||
{
|
||||
@@ -461,9 +463,9 @@ namespace Content.Client.UserInterface
|
||||
set => _buttonSandboxMenu.Visible = value;
|
||||
}
|
||||
|
||||
public Action<bool> SandboxButtonToggled { get; set; }
|
||||
public Action<bool>? SandboxButtonToggled { get; set; }
|
||||
|
||||
public Control VoteContainer { get; private set; }
|
||||
public Control VoteContainer { get; private set; } = default!;
|
||||
|
||||
public sealed class TopButton : ContainerButton
|
||||
{
|
||||
@@ -547,7 +549,7 @@ namespace Content.Client.UserInterface
|
||||
return TryGetShortKeyName(keyFunction, out var name) ? Loc.GetString(name) : " ";
|
||||
}
|
||||
|
||||
private bool TryGetShortKeyName(BoundKeyFunction keyFunction, out string name)
|
||||
private bool TryGetShortKeyName(BoundKeyFunction keyFunction, [NotNullWhen(true)] out string? name)
|
||||
{
|
||||
if (_inputManager.TryGetKeyBinding(keyFunction, out var binding))
|
||||
{
|
||||
@@ -632,7 +634,7 @@ namespace Content.Client.UserInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
private string DefaultShortKeyName(BoundKeyFunction keyFunction)
|
||||
private string? DefaultShortKeyName(BoundKeyFunction keyFunction)
|
||||
{
|
||||
var name = FormattedMessage.EscapeText(_inputManager.GetKeyFunctionButtonString(keyFunction));
|
||||
return name.Length > 3 ? null : name;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components.Items;
|
||||
using Content.Client.Utility;
|
||||
@@ -125,7 +126,7 @@ namespace Content.Client.UserInterface
|
||||
/// </summary>
|
||||
/// <param name="hands"></param>
|
||||
/// <returns>true if successful and false if failure</returns>
|
||||
private bool TryGetHands(out HandsComponent hands)
|
||||
private bool TryGetHands([NotNullWhen(true)] out HandsComponent? hands)
|
||||
{
|
||||
hands = default;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void RandomizeName()
|
||||
{
|
||||
if (Profile == null) return;
|
||||
var firstName = _random.Pick(Profile.Sex.FirstNames(_prototypeManager).Values);
|
||||
var lastName = _random.Pick(_prototypeManager.Index<DatasetPrototype>("names_last"));
|
||||
SetName($"{firstName} {lastName}");
|
||||
|
||||
@@ -13,9 +13,9 @@ using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -61,8 +61,9 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private bool _isDirty;
|
||||
public int CharacterSlot;
|
||||
public HumanoidCharacterProfile Profile;
|
||||
public event Action<HumanoidCharacterProfile, int> OnProfileChanged;
|
||||
public HumanoidCharacterProfile? Profile;
|
||||
|
||||
public event Action<HumanoidCharacterProfile, int>? OnProfileChanged;
|
||||
|
||||
public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager,
|
||||
IEntityManager entityManager)
|
||||
@@ -175,7 +176,7 @@ namespace Content.Client.UserInterface
|
||||
_sexMaleButton.OnPressed += args =>
|
||||
{
|
||||
SetSex(Sex.Male);
|
||||
if (Profile.Gender == Gender.Female)
|
||||
if (Profile?.Gender == Gender.Female)
|
||||
{
|
||||
SetGender(Gender.Male);
|
||||
UpdateGenderControls();
|
||||
@@ -187,10 +188,11 @@ namespace Content.Client.UserInterface
|
||||
Text = Loc.GetString("Female"),
|
||||
Group = sexButtonGroup
|
||||
};
|
||||
_sexFemaleButton.OnPressed += args =>
|
||||
_sexFemaleButton.OnPressed += _ =>
|
||||
{
|
||||
SetSex(Sex.Female);
|
||||
if (Profile.Gender == Gender.Male)
|
||||
|
||||
if (Profile?.Gender == Gender.Male)
|
||||
{
|
||||
SetGender(Gender.Female);
|
||||
UpdateGenderControls();
|
||||
@@ -419,7 +421,7 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
_preferenceUnavailableButton.SelectId(args.Id);
|
||||
|
||||
Profile = Profile.WithPreferenceUnavailable((PreferenceUnavailableMode) args.Id);
|
||||
Profile = Profile?.WithPreferenceUnavailable((PreferenceUnavailableMode) args.Id);
|
||||
IsDirty = true;
|
||||
};
|
||||
|
||||
@@ -474,7 +476,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
selector.PriorityChanged += priority =>
|
||||
{
|
||||
Profile = Profile.WithJobPriority(job.ID, priority);
|
||||
Profile = Profile?.WithJobPriority(job.ID, priority);
|
||||
IsDirty = true;
|
||||
|
||||
foreach (var jobSelector in _jobPriorities)
|
||||
@@ -491,7 +493,7 @@ namespace Content.Client.UserInterface
|
||||
if (jobSelector.Job != selector.Job && jobSelector.Priority == JobPriority.High)
|
||||
{
|
||||
jobSelector.Priority = JobPriority.Medium;
|
||||
Profile = Profile.WithJobPriority(jobSelector.Job.ID, JobPriority.Medium);
|
||||
Profile = Profile?.WithJobPriority(jobSelector.Job.ID, JobPriority.Medium);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,7 +541,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
selector.PreferenceChanged += preference =>
|
||||
{
|
||||
Profile = Profile.WithAntagPreference(antag.ID, preference);
|
||||
Profile = Profile?.WithAntagPreference(antag.ID, preference);
|
||||
IsDirty = true;
|
||||
};
|
||||
}
|
||||
@@ -664,7 +666,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void LoadServerData()
|
||||
{
|
||||
Profile = (HumanoidCharacterProfile) _preferencesManager.Preferences.SelectedCharacter;
|
||||
Profile = (HumanoidCharacterProfile) _preferencesManager.Preferences!.SelectedCharacter;
|
||||
CharacterSlot = _preferencesManager.Preferences.SelectedCharacterIndex;
|
||||
UpdateControls();
|
||||
}
|
||||
@@ -708,8 +710,12 @@ namespace Content.Client.UserInterface
|
||||
public void Save()
|
||||
{
|
||||
IsDirty = false;
|
||||
_preferencesManager.UpdateCharacter(Profile, CharacterSlot);
|
||||
OnProfileChanged?.Invoke(Profile, CharacterSlot);
|
||||
|
||||
if (Profile != null)
|
||||
{
|
||||
_preferencesManager.UpdateCharacter(Profile, CharacterSlot);
|
||||
OnProfileChanged?.Invoke(Profile, CharacterSlot);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsDirty
|
||||
@@ -733,17 +739,17 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void UpdateNameEdit()
|
||||
{
|
||||
_nameEdit.Text = Profile.Name;
|
||||
_nameEdit.Text = Profile?.Name ?? "";
|
||||
}
|
||||
|
||||
private void UpdateAgeEdit()
|
||||
{
|
||||
_ageEdit.Text = Profile.Age.ToString();
|
||||
_ageEdit.Text = Profile?.Age.ToString() ?? "";
|
||||
}
|
||||
|
||||
private void UpdateSexControls()
|
||||
{
|
||||
if (Profile.Sex == Sex.Male)
|
||||
if (Profile?.Sex == Sex.Male)
|
||||
_sexMaleButton.Pressed = true;
|
||||
else
|
||||
_sexFemaleButton.Pressed = true;
|
||||
@@ -751,21 +757,41 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void UpdateGenderControls()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_genderButton.SelectId((int) Profile.Gender);
|
||||
}
|
||||
|
||||
private void UpdateClothingControls()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_clothingButton.SelectId((int) Profile.Clothing);
|
||||
}
|
||||
|
||||
private void UpdateBackpackControls()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_backpackButton.SelectId((int) Profile.Backpack);
|
||||
}
|
||||
|
||||
private void UpdateHairPickers()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_hairPicker.SetData(
|
||||
Profile.Appearance.HairColor,
|
||||
Profile.Appearance.HairStyleName);
|
||||
@@ -776,6 +802,11 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private void UpdateEyePickers()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eyesPicker.SetData(Profile.Appearance.EyeColor);
|
||||
}
|
||||
|
||||
@@ -819,7 +850,7 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
var jobId = prioritySelector.Job.ID;
|
||||
|
||||
var priority = Profile.JobPriorities.GetValueOrDefault(jobId, JobPriority.Never);
|
||||
var priority = Profile?.JobPriorities.GetValueOrDefault(jobId, JobPriority.Never) ?? JobPriority.Never;
|
||||
|
||||
prioritySelector.Priority = priority;
|
||||
}
|
||||
@@ -836,17 +867,18 @@ namespace Content.Client.UserInterface
|
||||
set => _optionButton.SelectByValue((int) value);
|
||||
}
|
||||
|
||||
public event Action<JobPriority> PriorityChanged;
|
||||
public event Action<JobPriority>? PriorityChanged;
|
||||
|
||||
public JobPrioritySelector(JobPrototype job)
|
||||
{
|
||||
Job = job;
|
||||
_optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal);
|
||||
|
||||
_optionButton.FirstButtonStyle = StyleBase.ButtonOpenRight;
|
||||
_optionButton.ButtonStyle = StyleBase.ButtonOpenBoth;
|
||||
_optionButton.LastButtonStyle = StyleBase.ButtonOpenLeft;
|
||||
|
||||
_optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal)
|
||||
{
|
||||
FirstButtonStyle = StyleBase.ButtonOpenRight,
|
||||
ButtonStyle = StyleBase.ButtonOpenBoth,
|
||||
LastButtonStyle = StyleBase.ButtonOpenLeft
|
||||
};
|
||||
|
||||
// Text, Value
|
||||
_optionButton.AddItem(Loc.GetString("High"), (int) JobPriority.High);
|
||||
@@ -890,8 +922,7 @@ namespace Content.Client.UserInterface
|
||||
foreach (var preferenceSelector in _antagPreferences)
|
||||
{
|
||||
var antagId = preferenceSelector.Antag.ID;
|
||||
|
||||
var preference = Profile.AntagPreferences.Contains(antagId);
|
||||
var preference = Profile?.AntagPreferences.Contains(antagId) ?? false;
|
||||
|
||||
preferenceSelector.Preference = preference;
|
||||
}
|
||||
@@ -908,7 +939,7 @@ namespace Content.Client.UserInterface
|
||||
set => _checkBox.Pressed = value;
|
||||
}
|
||||
|
||||
public event Action<bool> PreferenceChanged;
|
||||
public event Action<bool>? PreferenceChanged;
|
||||
|
||||
public AntagPreferenceSelector(AntagPrototype antag)
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
public interface IItemSlotManager
|
||||
{
|
||||
bool OnButtonPressed(GUIBoundKeyEventArgs args, IEntity item);
|
||||
void UpdateCooldown(ItemSlotButton cooldownTexture, IEntity entity);
|
||||
bool SetItemSlot(ItemSlotButton button, IEntity entity);
|
||||
void HoverInSlot(ItemSlotButton button, IEntity entity, bool fits);
|
||||
bool OnButtonPressed(GUIBoundKeyEventArgs args, IEntity? item);
|
||||
void UpdateCooldown(ItemSlotButton? cooldownTexture, IEntity? entity);
|
||||
bool SetItemSlot(ItemSlotButton button, IEntity? entity);
|
||||
void HoverInSlot(ItemSlotButton button, IEntity? entity, bool fits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Content.Client.UserInterface
|
||||
public BaseButton StorageButton { get; }
|
||||
public CooldownGraphic CooldownDisplay { get; }
|
||||
|
||||
public Action<GUIBoundKeyEventArgs> OnPressed { get; set; }
|
||||
public Action<GUIBoundKeyEventArgs> OnStoragePressed { get; set; }
|
||||
public Action<GUIMouseHoverEventArgs> OnHover { get; set; }
|
||||
public Action<GUIBoundKeyEventArgs>? OnPressed { get; set; }
|
||||
public Action<GUIBoundKeyEventArgs>? OnStoragePressed { get; set; }
|
||||
public Action<GUIMouseHoverEventArgs>? OnHover { get; set; }
|
||||
|
||||
public bool EntityHover => HoverSpriteView.Sprite != null;
|
||||
public bool MouseIsHovering = false;
|
||||
public bool MouseIsHovering;
|
||||
|
||||
private readonly PanelContainer _highlightRect;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.UserInterface
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public bool SetItemSlot(ItemSlotButton button, IEntity entity)
|
||||
public bool SetItemSlot(ItemSlotButton button, IEntity? entity)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!entity.TryGetComponent(out ISpriteComponent sprite))
|
||||
if (!entity.TryGetComponent(out ISpriteComponent? sprite))
|
||||
return false;
|
||||
|
||||
button.ClearHover();
|
||||
@@ -46,7 +46,7 @@ namespace Content.Client.UserInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnButtonPressed(GUIBoundKeyEventArgs args, IEntity item)
|
||||
public bool OnButtonPressed(GUIBoundKeyEventArgs args, IEntity? item)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
@@ -92,40 +92,36 @@ namespace Content.Client.UserInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateCooldown(ItemSlotButton button, IEntity entity)
|
||||
public void UpdateCooldown(ItemSlotButton? button, IEntity? entity)
|
||||
{
|
||||
var cooldownDisplay = button.CooldownDisplay;
|
||||
var cooldownDisplay = button?.CooldownDisplay;
|
||||
|
||||
if (entity != null
|
||||
&& entity.TryGetComponent(out ItemCooldownComponent cooldown)
|
||||
&& cooldown.CooldownStart.HasValue
|
||||
&& cooldown.CooldownEnd.HasValue)
|
||||
if (cooldownDisplay == null)
|
||||
{
|
||||
var start = cooldown.CooldownStart.Value;
|
||||
var end = cooldown.CooldownEnd.Value;
|
||||
|
||||
var length = (end - start).TotalSeconds;
|
||||
var progress = (_gameTiming.CurTime - start).TotalSeconds / length;
|
||||
var ratio = (progress <= 1 ? (1 - progress) : (_gameTiming.CurTime - end).TotalSeconds * -5);
|
||||
|
||||
cooldownDisplay.Progress = MathHelper.Clamp((float)ratio, -1, 1);
|
||||
|
||||
if (ratio > -1f)
|
||||
{
|
||||
cooldownDisplay.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cooldownDisplay.Visible = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (entity == null ||
|
||||
!entity.TryGetComponent(out ItemCooldownComponent? cooldown) ||
|
||||
!cooldown.CooldownStart.HasValue ||
|
||||
!cooldown.CooldownEnd.HasValue)
|
||||
{
|
||||
cooldownDisplay.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var start = cooldown.CooldownStart.Value;
|
||||
var end = cooldown.CooldownEnd.Value;
|
||||
|
||||
var length = (end - start).TotalSeconds;
|
||||
var progress = (_gameTiming.CurTime - start).TotalSeconds / length;
|
||||
var ratio = (progress <= 1 ? (1 - progress) : (_gameTiming.CurTime - end).TotalSeconds * -5);
|
||||
|
||||
cooldownDisplay.Progress = MathHelper.Clamp((float) ratio, -1, 1);
|
||||
cooldownDisplay.Visible = ratio > -1f;
|
||||
}
|
||||
|
||||
public void HoverInSlot(ItemSlotButton button, IEntity entity, bool fits)
|
||||
public void HoverInSlot(ItemSlotButton button, IEntity? entity, bool fits)
|
||||
{
|
||||
if (entity == null || !button.MouseIsHovering)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Client.UserInterface
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly IClientGameTicker _gameTicker = default!;
|
||||
|
||||
public event Action<string> SelectedId;
|
||||
public event Action<string>? SelectedId;
|
||||
|
||||
private readonly Dictionary<string, JobButton> _jobButtons = new();
|
||||
private readonly Dictionary<string, VBoxContainer> _jobCategories = new();
|
||||
@@ -96,10 +96,7 @@ namespace Content.Client.UserInterface
|
||||
jobList.AddChild(category);
|
||||
}
|
||||
|
||||
var jobButton = new JobButton
|
||||
{
|
||||
JobId = job.ID
|
||||
};
|
||||
var jobButton = new JobButton(job.ID);
|
||||
|
||||
var jobSelector = new HBoxContainer
|
||||
{
|
||||
@@ -176,9 +173,11 @@ namespace Content.Client.UserInterface
|
||||
|
||||
class JobButton : ContainerButton
|
||||
{
|
||||
public string JobId { get; set; }
|
||||
public JobButton()
|
||||
public string JobId { get; }
|
||||
|
||||
public JobButton(string jobId)
|
||||
{
|
||||
JobId = jobId;
|
||||
AddStyleClass(StyleClassButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Content.Shared.GameTicking;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Client.GameObjects;
|
||||
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -15,6 +14,7 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
if (!disposing) return;
|
||||
_previewDummy.Delete();
|
||||
_previewDummy = null;
|
||||
_previewDummy = null!;
|
||||
}
|
||||
|
||||
private static SpriteView MakeSpriteView(IEntity entity, Direction direction)
|
||||
@@ -111,7 +111,7 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
_loaded.Visible = true;
|
||||
_unloaded.Visible = false;
|
||||
if (_preferencesManager.Preferences.SelectedCharacter is not HumanoidCharacterProfile selectedCharacter)
|
||||
if (_preferencesManager.Preferences?.SelectedCharacter is not HumanoidCharacterProfile selectedCharacter)
|
||||
{
|
||||
_summaryLabel.Text = string.Empty;
|
||||
}
|
||||
@@ -129,25 +129,29 @@ namespace Content.Client.UserInterface
|
||||
public static void GiveDummyJobClothes(IEntity dummy, HumanoidCharacterProfile profile)
|
||||
{
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
var entityMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var inventory = dummy.GetComponent<ClientInventoryComponent>();
|
||||
|
||||
var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key;
|
||||
|
||||
var job = protoMan.Index<JobPrototype>(highPriorityJob ?? SharedGameTicker.OverflowJob);
|
||||
var gear = protoMan.Index<StartingGearPrototype>(job.StartingGear);
|
||||
|
||||
inventory.ClearAllSlotVisuals();
|
||||
|
||||
foreach (var slot in AllSlots)
|
||||
if (job.StartingGear != null)
|
||||
{
|
||||
var itemType = gear.GetGear(slot, profile);
|
||||
if (itemType != "")
|
||||
var entityMan = IoCManager.Resolve<IEntityManager>();
|
||||
var gear = protoMan.Index<StartingGearPrototype>(job.StartingGear);
|
||||
|
||||
foreach (var slot in AllSlots)
|
||||
{
|
||||
var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
|
||||
inventory.SetSlotVisuals(slot, item);
|
||||
item.Delete();
|
||||
var itemType = gear.GetGear(slot, profile);
|
||||
if (itemType != "")
|
||||
{
|
||||
var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
|
||||
inventory.SetSlotVisuals(slot, item);
|
||||
item.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Content.Client.UserInterface
|
||||
HorizontalAlignment = HAlignment.Left;
|
||||
}
|
||||
|
||||
public string Text
|
||||
public string? Text
|
||||
{
|
||||
get => _label.Text;
|
||||
set => _label.Text = value;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
});
|
||||
|
||||
contents.AddChild(new Placeholder(resourceCache)
|
||||
contents.AddChild(new Placeholder()
|
||||
{
|
||||
VerticalExpand = true,
|
||||
PlaceholderText = Loc.GetString("ui-options-placeholder-viewport")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Shared.Input;
|
||||
|
||||
@@ -6,8 +6,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public sealed partial class OptionsMenu : SS14Window
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.ParticleAccelerator
|
||||
namespace Content.Client.UserInterface.ParticleAccelerator
|
||||
{
|
||||
public class ParticleAcceleratorBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private ParticleAcceleratorControlMenu _menu;
|
||||
private ParticleAcceleratorControlMenu? _menu;
|
||||
|
||||
public ParticleAcceleratorBoundUserInterface([NotNull] ClientUserInterfaceComponent owner, [NotNull] object uiKey) : base(owner, uiKey)
|
||||
public ParticleAcceleratorBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,14 +38,14 @@ namespace Content.Client.ParticleAccelerator
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
_menu.DataUpdate((ParticleAcceleratorUIState) state);
|
||||
_menu?.DataUpdate((ParticleAcceleratorUIState) state);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_menu.Close();
|
||||
_menu?.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
@@ -16,7 +15,7 @@ using Robust.Shared.Noise;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.ParticleAccelerator
|
||||
namespace Content.Client.UserInterface.ParticleAccelerator
|
||||
{
|
||||
public sealed class ParticleAcceleratorControlMenu : BaseWindow
|
||||
{
|
||||
@@ -101,11 +100,7 @@ namespace Content.Client.ParticleAccelerator
|
||||
MouseFilter = MouseFilterMode.Pass
|
||||
});
|
||||
|
||||
_stateSpinBox = new SpinBox
|
||||
{
|
||||
Value = 0,
|
||||
};
|
||||
_stateSpinBox.IsValid = StrengthSpinBoxValid;
|
||||
_stateSpinBox = new SpinBox {Value = 0, IsValid = StrengthSpinBoxValid,};
|
||||
_stateSpinBox.InitDefaultButtons();
|
||||
_stateSpinBox.ValueChanged += PowerStateChanged;
|
||||
_stateSpinBox.LineEditDisabled = true;
|
||||
@@ -336,7 +331,7 @@ namespace Content.Client.ParticleAccelerator
|
||||
return (n >= 0 && n <= 4 && !_blockSpinBox);
|
||||
}
|
||||
|
||||
private void PowerStateChanged(object sender, ValueChangedEventArgs e)
|
||||
private void PowerStateChanged(object? sender, ValueChangedEventArgs e)
|
||||
{
|
||||
ParticleAcceleratorPowerState newState;
|
||||
switch (e.Value)
|
||||
|
||||
@@ -15,8 +15,6 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.Administration.PermissionsEuiMsg;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Client.UserInterface.Permissions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
@@ -9,13 +8,13 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private readonly Label _label;
|
||||
|
||||
public string PlaceholderText
|
||||
public string? PlaceholderText
|
||||
{
|
||||
get => _label.Text;
|
||||
set => _label.Text = value;
|
||||
}
|
||||
|
||||
public Placeholder(IResourceCache _resourceCache)
|
||||
public Placeholder()
|
||||
{
|
||||
_label = new Label
|
||||
{
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace Content.Client.UserInterface
|
||||
GetActualStyleBox()?.Draw(handle, centerBox);
|
||||
}
|
||||
|
||||
private StyleBox GetActualStyleBox()
|
||||
private StyleBox? GetActualStyleBox()
|
||||
{
|
||||
return TryGetStyleProperty(StylePropertyBackground, out StyleBox box) ? box : null;
|
||||
return TryGetStyleProperty(StylePropertyBackground, out StyleBox? box) ? box : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||
|
||||
public Stylesheet SheetNano { get; private set; }
|
||||
public Stylesheet SheetSpace { get; private set; }
|
||||
public Stylesheet SheetNano { get; private set; } = default!;
|
||||
public Stylesheet SheetSpace { get; private set; } = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
@@ -16,8 +16,6 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Client.UserInterface.Suspicion
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<TargetingZone> OnZoneChanged;
|
||||
public event Action<TargetingZone>? OnZoneChanged;
|
||||
|
||||
public TargetingDoll(IResourceCache resourceCache)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user