Slightly improve action ui performance (#20799)

This commit is contained in:
Leon Friedrich
2023-10-09 07:37:09 +11:00
committed by GitHub
parent 35f41742a7
commit 1a5cf370e7
6 changed files with 120 additions and 78 deletions

View File

@@ -3,16 +3,18 @@ using Content.Shared.Input;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
namespace Content.Client.UserInterface.Systems.Actions.Widgets;
[GenerateTypedNameReferences]
public sealed partial class ActionsBar : UIWidget
{
[Dependency] private readonly IEntityManager _entity = default!;
public ActionsBar()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
var keys = ContentKeyFunctions.GetHotbarBoundKeys();
for (var index = 1; index < keys.Length; index++)
@@ -24,7 +26,7 @@ public sealed partial class ActionsBar : UIWidget
ActionButton MakeButton(int index)
{
var boundKey = keys[index];
var button = new ActionButton();
var button = new ActionButton(_entity);
button.KeyBind = boundKey;
button.Label.Text = index.ToString();
return button;