From 18efec647201d99d5921ed292d7d50f90e5c2bbf Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 19 Jul 2019 14:21:36 +0200 Subject: [PATCH] Game HUD improvements: Added sandbox button, needs implementation. Tutorial bound to F1. Improved color of buttons. --- Content.Client/Input/ContentContexts.cs | 1 + Content.Client/UserInterface/GameHud.cs | 46 ++++++++++++++++-- Content.Shared/Input/ContentKeyFunctions.cs | 1 + Resources/Textures/UserInterface/sandbox.svg | 44 +++++++++++++++++ .../UserInterface/sandbox.svg.96dpi.png | Bin 0 -> 731 bytes Resources/keybinds.yml | 3 ++ 6 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 Resources/Textures/UserInterface/sandbox.svg create mode 100644 Resources/Textures/UserInterface/sandbox.svg.96dpi.png diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 2f3d773eef..ced9f97555 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -14,6 +14,7 @@ namespace Content.Client.Input var common = contexts.GetContext("common"); common.AddFunction(ContentKeyFunctions.FocusChat); common.AddFunction(ContentKeyFunctions.ExamineEntity); + common.AddFunction(ContentKeyFunctions.OpenTutorial); var human = contexts.GetContext("human"); human.AddFunction(ContentKeyFunctions.SwapHands); diff --git a/Content.Client/UserInterface/GameHud.cs b/Content.Client/UserInterface/GameHud.cs index 44e425b0da..7be4e207e1 100644 --- a/Content.Client/UserInterface/GameHud.cs +++ b/Content.Client/UserInterface/GameHud.cs @@ -1,10 +1,13 @@ using System; using Content.Client.Utility; +using Content.Shared.Input; using Robust.Client.Graphics; using Robust.Client.Graphics.Drawing; +using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; +using Robust.Shared.Input; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -31,6 +34,9 @@ namespace Content.Client.UserInterface bool CraftingButtonDown { get; set; } bool CraftingButtonVisible { get; set; } Action CraftingButtonToggled { get; set; } + bool SandboxButtonDown { get; set; } + bool SandboxButtonVisible { get; set; } + Action SandboxButtonToggled { get; set; } // Init logic. void Initialize(); @@ -43,11 +49,13 @@ namespace Content.Client.UserInterface private TopButton _buttonTutorial; private TopButton _buttonCharacterMenu; private TopButton _buttonCraftingMenu; + private TopButton _buttonSandboxMenu; private TutorialWindow _tutorialWindow; #pragma warning disable 649 [Dependency] private readonly IResourceCache _resourceCache; [Dependency] private readonly ILocalizationManager _localizationManager; + [Dependency] private readonly IInputManager _inputManager; #pragma warning restore 649 public void Initialize() @@ -60,6 +68,7 @@ namespace Content.Client.UserInterface var characterTexture = _resourceCache.GetTexture("/Textures/UserInterface/character.svg.96dpi.png"); var craftingTexture = _resourceCache.GetTexture("/Textures/UserInterface/hammer.svg.96dpi.png"); var tutorialTexture = _resourceCache.GetTexture("/Textures/UserInterface/students-cap.svg.96dpi.png"); + var sandboxTexture = _resourceCache.GetTexture("/Textures/UserInterface/sandbox.svg.96dpi.png"); _topButtonsContainer = new HBoxContainer { @@ -81,14 +90,14 @@ namespace Content.Client.UserInterface _buttonEscapeMenu.OnToggled += args => EscapeButtonToggled?.Invoke(args.Pressed); // Tutorial - _buttonTutorial = new TopButton(tutorialTexture, " ") + _buttonTutorial = new TopButton(tutorialTexture, "F1") { ToolTip = _localizationManager.GetString("Open tutorial.") }; _topButtonsContainer.AddChild(_buttonTutorial); - _buttonTutorial.OnToggled += ButtonTutorialOnOnToggled; + _buttonTutorial.OnToggled += a => ButtonTutorialOnOnToggled(); // Inventory _buttonCharacterMenu = new TopButton(characterTexture, "C") @@ -112,22 +121,37 @@ namespace Content.Client.UserInterface _buttonCraftingMenu.OnToggled += args => CraftingButtonToggled?.Invoke(args.Pressed); + // Sandbox + _buttonSandboxMenu = new TopButton(sandboxTexture, "B") + { + ToolTip = _localizationManager.GetString("Open sandbox menu."), + Visible = true + }; + + _topButtonsContainer.AddChild(_buttonSandboxMenu); + + _buttonSandboxMenu.OnToggled += args => SandboxButtonToggled?.Invoke(args.Pressed); + _tutorialWindow = new TutorialWindow(); _tutorialWindow.OnClose += () => _buttonTutorial.Pressed = false; + + _inputManager.SetInputCommand(ContentKeyFunctions.OpenTutorial, InputCmdHandler.FromDelegate(s => ButtonTutorialOnOnToggled())); } - private void ButtonTutorialOnOnToggled(BaseButton.ButtonToggledEventArgs obj) + private void ButtonTutorialOnOnToggled() { if (_tutorialWindow.IsOpen) { if (!_tutorialWindow.IsAtFront()) { _tutorialWindow.MoveToFront(); + _buttonTutorial.Pressed = true; } else { _tutorialWindow.Close(); + _buttonTutorial.Pressed = false; } } else @@ -175,13 +199,27 @@ namespace Content.Client.UserInterface public Action CraftingButtonToggled { get; set; } + public bool SandboxButtonDown + { + get => _buttonSandboxMenu.Pressed; + set => _buttonSandboxMenu.Pressed = value; + } + + public bool SandboxButtonVisible + { + get => _buttonSandboxMenu.Visible; + set => _buttonSandboxMenu.Visible = value; + } + + public Action SandboxButtonToggled { get; set; } + public sealed class TopButton : BaseButton { public const string StyleClassLabelTopButton = "topButtonLabel"; private static readonly Color ColorNormal = Color.FromHex("#7b7e9e"); private static readonly Color ColorHovered = Color.FromHex("#9699bb"); - private static readonly Color ColorPressed = Color.FromHex("#00b061"); + private static readonly Color ColorPressed = Color.FromHex("#789B8C"); private readonly VBoxContainer _container; private readonly TextureRect _textureRect; diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs index 18e5248f06..f80c0063aa 100644 --- a/Content.Shared/Input/ContentKeyFunctions.cs +++ b/Content.Shared/Input/ContentKeyFunctions.cs @@ -17,5 +17,6 @@ namespace Content.Shared.Input public static readonly BoundKeyFunction OpenContextMenu = "OpenContextMenu"; public static readonly BoundKeyFunction FocusChat = "FocusChatWindow"; public static readonly BoundKeyFunction ToggleCombatMode = "ToggleCombatMode"; + public static readonly BoundKeyFunction OpenTutorial = "OpenTutorial"; } } diff --git a/Resources/Textures/UserInterface/sandbox.svg b/Resources/Textures/UserInterface/sandbox.svg new file mode 100644 index 0000000000..a1c9154343 --- /dev/null +++ b/Resources/Textures/UserInterface/sandbox.svg @@ -0,0 +1,44 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/Resources/Textures/UserInterface/sandbox.svg.96dpi.png b/Resources/Textures/UserInterface/sandbox.svg.96dpi.png new file mode 100644 index 0000000000000000000000000000000000000000..783e3524ebd311658c61e2a0dbc3b439f995a272 GIT binary patch literal 731 zcmV<10wn#3P))~Xvi9}2qS{5q_(C)w}OhA zq8eJNrAa6iiCSuCXy^}4Mb;86As2$smV!d#Rt_aZMGhAgUA+AozW2iE)9*Xy8dn#e z<>j37yzldT?|1%4RRnMim;eTWZs0Jmrka{b1LuHA{>4D0MQVVJKyHyHT1~hB+yjn= zCLRQy1GA3%F`%mwGr(EP?F&tafIdfb0vG~DfRbZmdtkl$meUz(;EE%B0;qA;nt=gZ z{|Yn))GGjgfTj@fP1f=$pf!aP0sUs;j;CIOiGT8nTSAu=zUtwvx7|IJb*z96tM?#{ zvnnw@VDV{|fhdZKk_IK^B<;$ewp$!dBh)6w^%g$>Ssq+81Q-}fBP2Ue3{`dT+Z_OP z7HcK7Nt%@OG1S243dKv3Moq8<$V-|A<|K_M{zc=GwggoJE>IcXTi!b0hll$H*zM~; zYO7N4*5WBi8$8^7l3ph71D^pTeK( zfgYeav9=kw2~1mC+iiY75GA-d;4<@H!ycc3N5BqeyazZ2?8UBS;@7dayyI=I2{;X0 zB7XPFr(qlL#W8T+XJEC(4&r;<#Tanh{aT<7xB<*0xZ}VPJOUn9NxY0<68C_+ znYKzg<89ObqYy>W!zIuOLj+u3ZUey&e>LDg8Y>1?3@m|x{4(n2{{oQi0C|7hkb(dJ N002ovPDHLkV1g-JIx+wN literal 0 HcmV?d00001 diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index c8b223be53..46afc74b07 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -79,3 +79,6 @@ binds: - function: OpenCraftingMenu type: state key: G +- function: OpenTutorial + type: state + key: F1