diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs index c30386797..e94fbda3f 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs @@ -90,10 +90,12 @@ namespace Barotrauma if (character.Oxygen < 10.0f) oxygenBar.Flash(); } if (healthBar != null) healthBar.Update(deltaTime); - - if (cprButton != null && cprButton.Visible) cprButton.Update(deltaTime); - - if (grabHoldButton != null && grabHoldButton.Visible) grabHoldButton.Update(deltaTime); + + if (Inventory.SelectedSlot == null) + { + if (cprButton != null && cprButton.Visible) cprButton.Update(deltaTime); + if (grabHoldButton != null && grabHoldButton.Visible) grabHoldButton.Update(deltaTime); + } if (suicideButton != null && suicideButton.Visible) suicideButton.Update(deltaTime); @@ -166,17 +168,8 @@ namespace Barotrauma if (!character.IsUnconscious && character.Stun <= 0.0f) { - if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f) - { - character.Inventory.DrawOffset = Vector2.Zero; - character.Inventory.DrawOwn(spriteBatch); - } - if (character.IsHumanoid && character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) { - character.SelectedCharacter.Inventory.DrawOffset = new Vector2(320.0f, 0.0f); - character.SelectedCharacter.Inventory.DrawOwn(spriteBatch); - if (cprButton == null) { cprButton = new GUIButton( @@ -229,13 +222,19 @@ namespace Barotrauma return true; }; } - - //cprButton.Visible = character.GetSkillLevel("Medical") > 20.0f; - + if (cprButton.Visible) cprButton.Draw(spriteBatch); if (grabHoldButton.Visible) grabHoldButton.Draw(spriteBatch); + + character.SelectedCharacter.Inventory.DrawOffset = new Vector2(320.0f, 0.0f); + character.SelectedCharacter.Inventory.DrawOwn(spriteBatch); } + if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f) + { + character.Inventory.DrawOffset = Vector2.Zero; + character.Inventory.DrawOwn(spriteBatch); + } if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f) { Inventory.DrawDragging(spriteBatch); diff --git a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs index e6b0c88b6..c6c9ceb61 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs @@ -169,7 +169,11 @@ namespace Barotrauma if (highlightedSubInventorySlot != null) { - UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex); + if (highlightedSubInventorySlot.Inventory == this) + { + UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex); + } + if (highlightedSubInventory.slots == null || (!highlightedSubInventorySlot.Slot.InteractRect.Contains(PlayerInput.MousePosition) && !highlightedSubInventory.slots.Any(s => s.InteractRect.Contains(PlayerInput.MousePosition)))) { @@ -186,6 +190,7 @@ namespace Barotrauma { highlightedSubInventory = subInventory; highlightedSubInventorySlot = selectedSlot; + UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex); } } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs index c3d1afe85..15b86415c 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs @@ -68,7 +68,7 @@ namespace Barotrauma partial class Inventory { - protected class SlotReference + public class SlotReference { public readonly Inventory Inventory; public readonly InventorySlot Slot; @@ -133,6 +133,10 @@ namespace Barotrauma } } + public static SlotReference SelectedSlot + { + get { return selectedSlot; } + } protected virtual void CreateSlots() {