Misc hand ui fixes (#12048)
This commit is contained in:
parent
ac2131b44e
commit
46f707a719
|
|
@ -1,4 +1,4 @@
|
|||
using Content.Client.Gameplay;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.Hands;
|
||||
using Content.Client.Hands.Systems;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
|
|
@ -146,7 +146,6 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
|||
|
||||
private void OnItemAdded(string name, EntityUid entity)
|
||||
{
|
||||
HandsGui?.UpdatePanelEntity(entity);
|
||||
var hand = GetHand(name);
|
||||
if (hand == null)
|
||||
return;
|
||||
|
|
@ -154,15 +153,20 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
|||
{
|
||||
hand.SpriteView.Sprite = sprite;
|
||||
}
|
||||
|
||||
if (_playerHandsComponent?.ActiveHand?.Name == name)
|
||||
HandsGui?.UpdatePanelEntity(entity);
|
||||
}
|
||||
|
||||
private void OnItemRemoved(string name, EntityUid entity)
|
||||
{
|
||||
HandsGui?.UpdatePanelEntity(null);
|
||||
var hand = GetHand(name);
|
||||
if (hand == null)
|
||||
return;
|
||||
|
||||
hand.SpriteView.Sprite = null;
|
||||
if (_playerHandsComponent?.ActiveHand?.Name == name)
|
||||
HandsGui?.UpdatePanelEntity(null);
|
||||
}
|
||||
|
||||
private HandsContainer GetFirstAvailableContainer()
|
||||
|
|
@ -364,17 +368,14 @@ public sealed class HandsUIController : UIController, IOnStateEntered<GameplaySt
|
|||
{
|
||||
foreach (var hand in container.GetButtons())
|
||||
{
|
||||
if (hand.Entity is not { } entity)
|
||||
return;
|
||||
|
||||
if (_entities.Deleted(entity) ||
|
||||
!_entities.TryGetComponent(entity, out ItemCooldownComponent? cooldown) ||
|
||||
if (!_entities.TryGetComponent(hand.Entity, out ItemCooldownComponent? cooldown) ||
|
||||
cooldown is not { CooldownStart: { } start, CooldownEnd: { } end})
|
||||
{
|
||||
hand.CooldownDisplay.Visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
hand.CooldownDisplay.Visible = true;
|
||||
hand.CooldownDisplay.FromTime(start, end);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Content.Client.Gameplay;
|
||||
using Content.Client.Hands;
|
||||
using Content.Client.Hands.Systems;
|
||||
using Content.Client.Inventory;
|
||||
using Content.Client.Storage;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
|
|
@ -20,11 +21,12 @@ using static Robust.Client.UserInterface.Controls.BaseButton;
|
|||
namespace Content.Client.UserInterface.Systems.Inventory;
|
||||
|
||||
public sealed class InventoryUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>,
|
||||
IOnSystemChanged<ClientInventorySystem>
|
||||
IOnSystemChanged<ClientInventorySystem>, IOnSystemChanged<HandsSystem>
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[UISystemDependency] private readonly ClientInventorySystem _inventorySystem = default!;
|
||||
[UISystemDependency] private readonly HandsSystem _handsSystem = default!;
|
||||
|
||||
private ClientInventoryComponent? _playerInventory;
|
||||
private readonly Dictionary<string, ItemSlotButtonContainer> _slotGroups = new();
|
||||
|
|
@ -33,6 +35,8 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
|||
private ItemSlotButtonContainer? _inventoryHotbar;
|
||||
private MenuButton? InventoryButton => UIManager.ActiveScreen?.GetWidget<MenuBar.Widgets.GameTopMenuBar>()?.InventoryButton;
|
||||
|
||||
private SlotControl? _lastHovered = null;
|
||||
|
||||
public void OnStateEntered(GameplayState state)
|
||||
{
|
||||
DebugTools.Assert(_strippingWindow == null);
|
||||
|
|
@ -247,6 +251,12 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
|||
}
|
||||
|
||||
private void SlotButtonHovered(GUIMouseHoverEventArgs args, SlotControl control)
|
||||
{
|
||||
UpdateHover(control);
|
||||
_lastHovered = control;
|
||||
}
|
||||
|
||||
public void UpdateHover(SlotControl control)
|
||||
{
|
||||
var player = _playerInventory?.Owner;
|
||||
|
||||
|
|
@ -345,4 +355,40 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
|||
{
|
||||
_slotGroups.Remove(slotGroupName);
|
||||
}
|
||||
|
||||
// Monkey Sees Action
|
||||
// Neuron Activation
|
||||
// Monkey copies code
|
||||
public void OnSystemLoaded(HandsSystem system)
|
||||
{
|
||||
_handsSystem.OnPlayerItemAdded += OnItemAdded;
|
||||
_handsSystem.OnPlayerItemRemoved += OnItemRemoved;
|
||||
_handsSystem.OnPlayerSetActiveHand += SetActiveHand;
|
||||
}
|
||||
|
||||
public void OnSystemUnloaded(HandsSystem system)
|
||||
{
|
||||
_handsSystem.OnPlayerItemAdded -= OnItemAdded;
|
||||
_handsSystem.OnPlayerItemRemoved -= OnItemRemoved;
|
||||
_handsSystem.OnPlayerSetActiveHand -= SetActiveHand;
|
||||
}
|
||||
|
||||
|
||||
private void OnItemAdded(string name, EntityUid entity)
|
||||
{
|
||||
if (_lastHovered != null)
|
||||
UpdateHover(_lastHovered);
|
||||
}
|
||||
|
||||
private void OnItemRemoved(string name, EntityUid entity)
|
||||
{
|
||||
if (_lastHovered != null)
|
||||
UpdateHover(_lastHovered);
|
||||
}
|
||||
|
||||
private void SetActiveHand(string? handName)
|
||||
{
|
||||
if (_lastHovered != null)
|
||||
UpdateHover(_lastHovered);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue