Fix inventory GUI for non-inventory entities (#31306)
Default to invisible and only set visible if itemslots gets initialised.
This commit is contained in:
@@ -21,6 +21,7 @@ using Robust.Client.UserInterface.Controls;
|
|||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using static Content.Client.Inventory.ClientInventorySystem;
|
using static Content.Client.Inventory.ClientInventorySystem;
|
||||||
|
|
||||||
@@ -399,6 +400,9 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
foreach (var slotData in clientInv.SlotData.Values)
|
foreach (var slotData in clientInv.SlotData.Values)
|
||||||
{
|
{
|
||||||
AddSlot(slotData);
|
AddSlot(slotData);
|
||||||
|
|
||||||
|
if (_inventoryButton != null)
|
||||||
|
_inventoryButton.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateInventoryHotbar(_playerInventory);
|
UpdateInventoryHotbar(_playerInventory);
|
||||||
@@ -406,6 +410,9 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
|||||||
|
|
||||||
private void UnloadSlots()
|
private void UnloadSlots()
|
||||||
{
|
{
|
||||||
|
if (_inventoryButton != null)
|
||||||
|
_inventoryButton.Visible = false;
|
||||||
|
|
||||||
_playerUid = null;
|
_playerUid = null;
|
||||||
_playerInventory = null;
|
_playerInventory = null;
|
||||||
foreach (var slotGroup in _slotGroups.Values)
|
foreach (var slotGroup in _slotGroups.Values)
|
||||||
|
|||||||
@@ -9,9 +9,11 @@
|
|||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center">
|
HorizontalAlignment="Center">
|
||||||
<Control HorizontalAlignment="Center">
|
<Control HorizontalAlignment="Center">
|
||||||
|
<!-- Needs to default to invisible because if we attach to a non-slots entity this will never get unset -->
|
||||||
<controls:SlotButton
|
<controls:SlotButton
|
||||||
Name="InventoryButton"
|
Name="InventoryButton"
|
||||||
Access="Public"
|
Access="Public"
|
||||||
|
Visible="False"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
HorizontalExpand="False"
|
HorizontalExpand="False"
|
||||||
VerticalExpand="False"
|
VerticalExpand="False"
|
||||||
|
|||||||
Reference in New Issue
Block a user