diff --git a/Content.Client/UserInterface/Systems/MenuBar/GameTopMenuBarUIController.cs b/Content.Client/UserInterface/Systems/MenuBar/GameTopMenuBarUIController.cs index 6f0d5a8c47..6f9545288f 100644 --- a/Content.Client/UserInterface/Systems/MenuBar/GameTopMenuBarUIController.cs +++ b/Content.Client/UserInterface/Systems/MenuBar/GameTopMenuBarUIController.cs @@ -1,4 +1,3 @@ -using Content.Client._White.UI.Emotions; using Content.Client.UserInterface.Systems.Actions; using Content.Client.UserInterface.Systems.Admin; using Content.Client.UserInterface.Systems.Bwoink; @@ -27,7 +26,6 @@ public sealed class GameTopMenuBarUIController : UIController [Dependency] private readonly GuidebookUIController _guidebook = default!; [Dependency] private readonly EmotesUIController _emotes = default!; [Dependency] private readonly LanguageMenuUIController _language = default!; - [Dependency] private readonly EmotionsUIController _emotions = default!; // WD EDIT private GameTopMenuBar? GameTopMenuBar => UIManager.GetActiveUIWidgetOrNull(); @@ -52,7 +50,6 @@ public void UnloadButtons() _sandbox.UnloadButton(); _emotes.UnloadButton(); _language.UnloadButton(); - _emotions.UnloadButton(); // WD EDIT } public void LoadButtons() @@ -67,6 +64,5 @@ public void LoadButtons() _sandbox.LoadButton(); _emotes.LoadButton(); _language.LoadButton(); - _emotions.LoadButton(); // WD EDIT } } diff --git a/Content.Client/_White/UI/Emotions/EmotionsUIController.cs b/Content.Client/_White/UI/Emotions/EmotionsUIController.cs index 0151c6b44c..16be667290 100644 --- a/Content.Client/_White/UI/Emotions/EmotionsUIController.cs +++ b/Content.Client/_White/UI/Emotions/EmotionsUIController.cs @@ -1,162 +1,166 @@ -using System.Linq; -using Content.Client.Chat.Managers; -using Content.Client.Gameplay; -using Content.Client.UserInterface.Controls; -using Content.Shared.Chat; -using Content.Shared.Chat.Prototypes; -using Content.Shared.Input; -using Robust.Client.UserInterface.Controllers; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; -using Robust.Shared.Input.Binding; -using Robust.Shared.Prototypes; -using Robust.Shared.Random; - -namespace Content.Client._White.UI.Emotions; - -public sealed class EmotionsUIController : UIController, IOnStateChanged -{ - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IRobustRandom _random = default!; - [Dependency] private readonly IChatManager _chatManager = default!; - - private DefaultWindow? _window; - private MenuButton? EmotionsButton => UIManager.GetActiveUIWidgetOrNull()?.EmotionsButton; - - private DateTime _lastEmotionTimeUse = DateTime.Now; - private const float EmoteCooldown = 1.5f; - - public void OnStateEntered(GameplayState state) - { - _window = FormMenu(); - - _window.OnOpen += OnWindowOpened; - _window.OnClose += OnWindowClosed; - - CommandBinds.Builder - .Bind(ContentKeyFunctions.OpenEmotionsMenu, - InputCmdHandler.FromDelegate(_ => ToggleWindow())) - .Register(); - } - - public void OnStateExited(GameplayState state) - { - if (_window != null) - { - _window.OnOpen -= OnWindowOpened; - _window.OnClose -= OnWindowClosed; - - _window.Dispose(); - _window = null; - } - - CommandBinds.Unregister(); - } - - public void LoadButton() - { - if (EmotionsButton == null) - return; - - EmotionsButton.OnPressed += EmotionsButtonPressed; - } - - public void UnloadButton() - { - if (EmotionsButton == null) - return; - - EmotionsButton.OnPressed -= EmotionsButtonPressed; - } - - private void OnWindowOpened() - { - if (EmotionsButton != null) - EmotionsButton.Pressed = true; - } - - private void OnWindowClosed() - { - if (EmotionsButton != null) - EmotionsButton.Pressed = false; - } - - private void EmotionsButtonPressed(BaseButton.ButtonEventArgs args) - { - ToggleWindow(); - } - - private void ToggleWindow() - { - if (_window == null) - return; - - if (_window.IsOpen) - { - _window.Close(); - return; - } - - _window.Open(); - } - - private void UseEmote(string emote) - { - var time = (DateTime.Now - _lastEmotionTimeUse).TotalSeconds; - if (time < EmoteCooldown) - return; - - _lastEmotionTimeUse = DateTime.Now; - _chatManager.SendMessage(emote, ChatSelectChannel.Emotes); - } - - private Button CreateEmoteButton(EmotePrototype emote) - { - var control = new Button - { - ClipText = true, - HorizontalExpand = true, - VerticalExpand = true, - MinWidth = 120, - MaxWidth = 250, - MaxHeight = 35, - TextAlign = Label.AlignMode.Left, - Text = Loc.GetString(emote.ButtonText) - }; - - control.OnPressed += _ => UseEmote(Loc.GetString(_random.Pick(emote.ChatMessages))); - return control; - } - - private DefaultWindow FormMenu() - { - var window = new DefaultWindow - { - Title = Loc.GetString("emotions-menu-title"), - VerticalExpand = true, - HorizontalExpand = true, - MinHeight = 250, - MinWidth = 300 - }; - - var grid = new GridContainer - { - Columns = 3 - }; - - var emotions = _prototypeManager.EnumeratePrototypes().ToList(); - emotions.Sort((a,b) => string.Compare(Loc.GetString(a.ButtonText), Loc.GetString(b.ButtonText.ToString()), StringComparison.Ordinal)); - - foreach (var emote in emotions) - { - if (!emote.AllowToEmotionsMenu) - continue; - - var button = CreateEmoteButton(emote); - grid.AddChild(button); - } - - window.Contents.AddChild(grid); - return window; - } -} +/* + * DISABLED IN FAVOR OF EMOTES RADIAL MENU + */ + + +// using System.Linq; +// using Content.Client.Chat.Managers; +// using Content.Client.Gameplay; +// using Content.Client.UserInterface.Controls; +// using Content.Shared.Chat; +// using Content.Shared.Chat.Prototypes; +// using Content.Shared.Input; +// using Robust.Client.UserInterface.Controllers; +// using Robust.Client.UserInterface.Controls; +// using Robust.Client.UserInterface.CustomControls; +// using Robust.Shared.Input.Binding; +// using Robust.Shared.Prototypes; +// using Robust.Shared.Random; +// +// namespace Content.Client._White.UI.Emotions; +// +// public sealed class EmotionsUIController : UIController, IOnStateChanged +// { +// [Dependency] private readonly IPrototypeManager _prototypeManager = default!; +// [Dependency] private readonly IRobustRandom _random = default!; +// [Dependency] private readonly IChatManager _chatManager = default!; +// +// private DefaultWindow? _window; +// private MenuButton? EmotionsButton => UIManager.GetActiveUIWidgetOrNull()?.EmotionsButton; +// +// private DateTime _lastEmotionTimeUse = DateTime.Now; +// private const float EmoteCooldown = 1.5f; +// +// public void OnStateEntered(GameplayState state) +// { +// _window = FormMenu(); +// +// _window.OnOpen += OnWindowOpened; +// _window.OnClose += OnWindowClosed; +// +// CommandBinds.Builder +// .Bind(ContentKeyFunctions.OpenEmotesMenu, InputCmdHandler.FromDelegate(_ => ToggleWindow())) +// .Register(); +// } +// +// public void OnStateExited(GameplayState state) +// { +// if (_window != null) +// { +// _window.OnOpen -= OnWindowOpened; +// _window.OnClose -= OnWindowClosed; +// +// _window.Dispose(); +// _window = null; +// } +// +// CommandBinds.Unregister(); +// } +// +// public void LoadButton() +// { +// if (EmotionsButton == null) +// return; +// +// EmotionsButton.OnPressed += EmotionsButtonPressed; +// } +// +// public void UnloadButton() +// { +// if (EmotionsButton == null) +// return; +// +// EmotionsButton.OnPressed -= EmotionsButtonPressed; +// } +// +// private void OnWindowOpened() +// { +// if (EmotionsButton != null) +// EmotionsButton.Pressed = true; +// } +// +// private void OnWindowClosed() +// { +// if (EmotionsButton != null) +// EmotionsButton.Pressed = false; +// } +// +// private void EmotionsButtonPressed(BaseButton.ButtonEventArgs args) +// { +// ToggleWindow(); +// } +// +// private void ToggleWindow() +// { +// if (_window == null) +// return; +// +// if (_window.IsOpen) +// { +// _window.Close(); +// return; +// } +// +// _window.Open(); +// } +// +// private void UseEmote(string emote) +// { +// var time = (DateTime.Now - _lastEmotionTimeUse).TotalSeconds; +// if (time < EmoteCooldown) +// return; +// +// _lastEmotionTimeUse = DateTime.Now; +// _chatManager.SendMessage(emote, ChatSelectChannel.Emotes); +// } +// +// private Button CreateEmoteButton(EmotePrototype emote) +// { +// var control = new Button +// { +// ClipText = true, +// HorizontalExpand = true, +// VerticalExpand = true, +// MinWidth = 120, +// MaxWidth = 250, +// MaxHeight = 35, +// TextAlign = Label.AlignMode.Left, +// Text = Loc.GetString(emote.ButtonText) +// }; +// +// control.OnPressed += _ => UseEmote(Loc.GetString(_random.Pick(emote.ChatMessages))); +// return control; +// } +// +// private DefaultWindow FormMenu() +// { +// var window = new DefaultWindow +// { +// Title = Loc.GetString("emotions-menu-title"), +// VerticalExpand = true, +// HorizontalExpand = true, +// MinHeight = 250, +// MinWidth = 300 +// }; +// +// var grid = new GridContainer +// { +// Columns = 3 +// }; +// +// var emotions = _prototypeManager.EnumeratePrototypes().ToList(); +// emotions.Sort((a,b) => string.Compare(Loc.GetString(a.ButtonText), Loc.GetString(b.ButtonText.ToString()), StringComparison.Ordinal)); +// +// foreach (var emote in emotions) +// { +// if (!emote.AllowToEmotionsMenu) +// continue; +// +// var button = CreateEmoteButton(emote); +// grid.AddChild(button); +// } +// +// window.Contents.AddChild(grid); +// return window; +// } +// } diff --git a/Content.Shared/Chat/Prototypes/EmotePrototype.cs b/Content.Shared/Chat/Prototypes/EmotePrototype.cs index af8cb05128..7ee958ee6a 100644 --- a/Content.Shared/Chat/Prototypes/EmotePrototype.cs +++ b/Content.Shared/Chat/Prototypes/EmotePrototype.cs @@ -68,14 +68,6 @@ public sealed partial class EmotePrototype : IPrototype /// [DataField] public HashSet ChatTriggers = new(); - - // WD EDIT START - [DataField] - public string ButtonText = "Unknown"; - - [DataField("allowMenu")] - public bool AllowToEmotionsMenu; - // WD EDIT END } ///