diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index 3bb92d3a11..9027e22d6f 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -69,6 +69,7 @@ + diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index 4fa5e40b21..4a9ecf740c 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -1,4 +1,5 @@ using Content.Client.GameObjects; +using Content.Client.GameObjects.Components.Storage; using Content.Client.Interfaces.GameObjects; using SS14.Shared.ContentPack; using SS14.Shared.Interfaces.GameObjects; @@ -36,8 +37,11 @@ namespace Content.Client factory.RegisterIgnore("Projectile"); factory.RegisterIgnore("MeleeWeapon"); + factory.RegisterIgnore("Storeable"); + factory.Register(); factory.RegisterReference(); + factory.Register(); factory.Register(); } diff --git a/Content.Client/GameObjects/Components/Items/ClientHandsComponent.cs b/Content.Client/GameObjects/Components/Items/ClientHandsComponent.cs index e6aca6bea2..1762ea3e5b 100644 --- a/Content.Client/GameObjects/Components/Items/ClientHandsComponent.cs +++ b/Content.Client/GameObjects/Components/Items/ClientHandsComponent.cs @@ -57,5 +57,10 @@ namespace Content.Client.GameObjects { SendNetworkMessage(new ClientChangedHandMsg(index)); } + + public void UseActiveHand() + { + SendNetworkMessage(new ActivateInhandMsg()); + } } } diff --git a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs new file mode 100644 index 0000000000..ecebe16f24 --- /dev/null +++ b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs @@ -0,0 +1,200 @@ +using Content.Shared.GameObjects; +using Content.Shared.GameObjects.Components.Storage; +using SS14.Client.GameObjects; +using SS14.Client.UserInterface; +using SS14.Client.UserInterface.Controls; +using SS14.Client.UserInterface.CustomControls; +using SS14.Shared.GameObjects; +using SS14.Shared.Interfaces.GameObjects; +using SS14.Shared.Interfaces.Network; +using SS14.Shared.IoC; +using SS14.Shared.Log; +using SS14.Shared.Maths; +using SS14.Shared.Utility; +using System; +using System.Collections.Generic; + +namespace Content.Client.GameObjects.Components.Storage +{ + /// + /// Client version of item storage containers, contains a UI which displays stored entities and their size + /// + public class ClientStorageComponent : SharedStorageComponent + { + private Dictionary StoredEntities { get; set; } = new Dictionary(); + private int StorageSizeUsed; + private int StorageCapacityMax; + private StorageWindow Window; + + public override void OnAdd() + { + base.OnAdd(); + + Window = new StorageWindow() + { StorageEntity = this}; + } + + public override void OnRemove() + { + Window.Dispose(); + + base.OnRemove(); + } + + public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) + { + switch (message) + { + //Updates what we are storing for the UI + case StorageHeldItemsMessage msg: + HandleStorageMessage(msg); + break; + //Opens the UI + case OpenStorageUIMessage msg: + OpenUI(); + break; + } + } + + /// + /// Copies received values from server about contents of storage container + /// + /// + private void HandleStorageMessage(StorageHeldItemsMessage storagestate) + { + StoredEntities = new Dictionary(storagestate.StoredEntities); + StorageSizeUsed = storagestate.StorageSizeUsed; + StorageCapacityMax = storagestate.StorageSizeMax; + Window.BuildEntityList(); + } + + /// + /// Opens the storage UI + /// + private void OpenUI() + { + Window.AddToScreen(); + Window.Open(); + } + + /// + /// Function for clicking one of the stored entity buttons in the UI, tells server to remove that entity + /// + /// + private void Interact(EntityUid entityuid) + { + SendNetworkMessage(new RemoveEntityMessage(entityuid)); + } + + /// + /// GUI class for client storage component + /// + private class StorageWindow : SS14Window + { + private Control VSplitContainer; + private VBoxContainer EntityList; + private Label Information; + public ClientStorageComponent StorageEntity; + + protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Storage/Storage.tscn"); + + protected override void Initialize() + { + + base.Initialize(); + + HideOnClose = true; + + // Get all the controls. + VSplitContainer = Contents.GetChild("VSplitContainer"); + EntityList = VSplitContainer.GetChild("ListScrollContainer").GetChild("EntityList"); + Information = VSplitContainer.GetChild