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 0000000000..783e3524eb Binary files /dev/null and b/Resources/Textures/UserInterface/sandbox.svg.96dpi.png differ 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