Correctly clear inventory UI when HumanInventoryInterfaceController detaches.

Fixes #405
This commit is contained in:
Pieter-Jan Briers
2019-10-25 11:48:41 +02:00
parent 8a6751711a
commit 3a0856505d

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Content.Client.GameObjects.Components.Storage; using Content.Client.GameObjects.Components.Storage;
using Content.Client.Utility; using Content.Client.Utility;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -114,12 +115,17 @@ namespace Content.Client.GameObjects
foreach (var button in buttons) foreach (var button in buttons)
{ {
button.SpriteView.Sprite = null; ClearButton(button);
button.OnPressed = AddToInventory;
button.StorageButton.Visible = false;
} }
} }
private void ClearButton(InventoryButton button)
{
button.SpriteView.Sprite = null;
button.OnPressed = AddToInventory;
button.StorageButton.Visible = false;
}
public override void PlayerAttached() public override void PlayerAttached()
{ {
base.PlayerAttached(); base.PlayerAttached();
@@ -132,6 +138,11 @@ namespace Content.Client.GameObjects
base.PlayerDetached(); base.PlayerDetached();
GameHud.InventoryQuickButtonContainer.RemoveChild(_quickButtonsContainer); GameHud.InventoryQuickButtonContainer.RemoveChild(_quickButtonsContainer);
foreach (var button in _inventoryButtons.Values.SelectMany(l => l))
{
ClearButton(button);
}
} }
private class HumanInventoryWindow : SS14Window private class HumanInventoryWindow : SS14Window