From af1f8be4fa7337cf5b666bc71944100a134fbf6f Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 29 Mar 2019 17:23:33 +0200 Subject: [PATCH] (ad3954bd2) Moved item HUD closing logic to Character.ControlLocal and removed it from ItemInventory. The deselection in ItemInventory was not synced with the server, causing the item to be immediately reselected after the HUD has been closed (and the logic was redundant anyway because it's also handled in Character). --- .../BarotraumaClient/Source/Characters/Character.cs | 7 +++++++ .../BarotraumaClient/Source/Items/ItemInventory.cs | 6 ------ .../BarotraumaShared/Source/Characters/Character.cs | 11 +---------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index 87d29a9e2..7fab0116d 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -224,6 +224,13 @@ namespace Barotrauma } } + if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect))) + { + //emulate a Select input to get the character to deselect the item server-side + keys[(int)InputType.Select].Hit = true; + SelectedConstruction = null; + } + DoInteractionUpdate(deltaTime, mouseSimPos); } diff --git a/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs index 8c126470f..8f2aa6359 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/ItemInventory.cs @@ -10,12 +10,6 @@ namespace Barotrauma protected override void ControlInput(Camera cam) { - if (draggingItem == null && HUD.CloseHUD(BackgroundFrame)) - { - // TODO: fix so that works with the server side - Character.Controlled.SelectedConstruction = null; - return; - } base.ControlInput(cam); if (BackgroundFrame.Contains(PlayerInput.MousePosition)) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index abe389538..8993574a8 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1269,15 +1269,7 @@ namespace Barotrauma if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); } } - -#if CLIENT - if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect))) - { - //emulate a Select input to get the character to deselect the item server-side - keys[(int)InputType.Select].Hit = true; - SelectedConstruction = null; - } -#endif + if (SelectedConstruction != null) { if (IsKeyDown(InputType.Use)) SelectedConstruction.Use(deltaTime, this); @@ -1291,7 +1283,6 @@ namespace Barotrauma DeselectCharacter(); } } - if (IsRemotePlayer && keys!=null) {