diff --git a/Content.Client/Construction/ConstructionButton.cs b/Content.Client/Construction/ConstructionButton.cs new file mode 100644 index 0000000000..4b064aa1bb --- /dev/null +++ b/Content.Client/Construction/ConstructionButton.cs @@ -0,0 +1,56 @@ +using Content.Client.GameObjects.Components.Construction; +using SS14.Client.UserInterface; +using SS14.Client.UserInterface.Controls; +using SS14.Shared.Utility; + +namespace Content.Client.Construction +{ + public class ConstructionButton : Button + { + protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionButton.tscn"); + + public ConstructorComponent Owner + { + get => Menu.Owner; + set => Menu.Owner = value; + } + ConstructionMenu Menu; + + protected override void Initialize() + { + base.Initialize(); + + OnPressed += IWasPressed; + Menu = new ConstructionMenu(); + Menu.AddToScreen(); + } + + void IWasPressed(ButtonEventArgs args) + { + Menu.Open(); + } + + public void AddToScreen() + { + UserInterfaceManager.StateRoot.AddChild(this); + } + + public void RemoveFromScreen() + { + if (Parent != null) + { + Parent.RemoveChild(this); + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + Menu.Dispose(); + } + + base.Dispose(disposing); + } + } +} diff --git a/Content.Client/Construction/ConstructionMenu.cs b/Content.Client/Construction/ConstructionMenu.cs new file mode 100644 index 0000000000..d2ea12bbce --- /dev/null +++ b/Content.Client/Construction/ConstructionMenu.cs @@ -0,0 +1,344 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Content.Client.GameObjects.Components.Construction; +using Content.Shared.Construction; +using SS14.Client.GameObjects; +using SS14.Client.Graphics; +using SS14.Client.Interfaces.GameObjects; +using SS14.Client.Interfaces.Placement; +using SS14.Client.Interfaces.ResourceManagement; +using SS14.Client.Placement; +using SS14.Client.ResourceManagement; +using SS14.Client.UserInterface; +using SS14.Client.UserInterface.Controls; +using SS14.Client.UserInterface.CustomControls; +using SS14.Client.Utility; +using SS14.Shared.Enums; +using SS14.Shared.Interfaces.GameObjects.Components; +using SS14.Shared.IoC; +using SS14.Shared.Log; +using SS14.Shared.Maths; +using SS14.Shared.Prototypes; +using SS14.Shared.Utility; + +namespace Content.Client.Construction +{ + public class ConstructionMenu : SS14Window + { + protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionMenu.tscn"); + +#pragma warning disable CS0649 + [Dependency] + readonly IPrototypeManager PrototypeManager; + [Dependency] + readonly IResourceCache ResourceCache; +#pragma warning restore + + public ConstructorComponent Owner { get; set; } + Button BuildButton; + Button EraseButton; + LineEdit SearchBar; + Tree RecipeList; + TextureRect InfoIcon; + Label InfoLabel; + ItemList StepList; + + CategoryNode RootCategory; + // This list is flattened in such a way that the top most deepest category is first. + List FlattenedCategories; + PlacementManager Placement; + + protected override void Initialize() + { + base.Initialize(); + IoCManager.InjectDependencies(this); + Placement = (PlacementManager)IoCManager.Resolve(); + Placement.PlacementCanceled += OnPlacementCanceled; + + HideOnClose = true; + Title = "Construction"; + Visible = false; + var split = Contents.GetChild("HSplitContainer"); + var rightSide = split.GetChild("Guide"); + var info = rightSide.GetChild("Info"); + InfoIcon = info.GetChild("TextureRect"); + InfoLabel = info.GetChild