From 17502269b033fb463fe8534bab46c0c45d63c76a Mon Sep 17 00:00:00 2001 From: FoxxoTrystan Date: Fri, 15 Mar 2024 10:08:49 +0100 Subject: [PATCH] OnStateUpdate Update now LanguageSelector --- .../Chat/Controls/LanguageSelectorButton.cs | 18 ++++++------------ .../Language/LanguageMenuUIController.cs | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Content.Client/_NF/Language/Systems/Chat/Controls/LanguageSelectorButton.cs b/Content.Client/_NF/Language/Systems/Chat/Controls/LanguageSelectorButton.cs index a26f1dd9776..2bb44de18c9 100644 --- a/Content.Client/_NF/Language/Systems/Chat/Controls/LanguageSelectorButton.cs +++ b/Content.Client/_NF/Language/Systems/Chat/Controls/LanguageSelectorButton.cs @@ -3,6 +3,8 @@ using Content.Client.UserInterface.Systems.Chat.Controls; using Content.Shared.Language; using Robust.Shared.Utility; +using Content.Client._NF.Language; +using static Content.Shared.Language.Systems.SharedLanguageSystem; namespace Content.Client._NF.Language.Systems.Chat.Controls; @@ -80,16 +82,8 @@ public static string LanguageSelectorName(LanguagePrototype language, bool full return name[..5]; } - // public Color ChannelSelectColor(ChatSelectChannel channel) - // { - // return channel switch - // { - // ChatSelectChannel.Radio => Color.LimeGreen, - // ChatSelectChannel.LOOC => Color.MediumTurquoise, - // ChatSelectChannel.OOC => Color.LightSkyBlue, - // ChatSelectChannel.Dead => Color.MediumPurple, - // ChatSelectChannel.Admin => Color.HotPink, - // _ => Color.DarkGray - // }; - // } + public void UpdateLanguageSelectButton(LanguagePrototype language) + { + Text = LanguageSelectorName(language); + } } diff --git a/Content.Client/_NF/UserInterface/Systems/Language/LanguageMenuUIController.cs b/Content.Client/_NF/UserInterface/Systems/Language/LanguageMenuUIController.cs index e1f8f5f79b5..745f1f277e3 100644 --- a/Content.Client/_NF/UserInterface/Systems/Language/LanguageMenuUIController.cs +++ b/Content.Client/_NF/UserInterface/Systems/Language/LanguageMenuUIController.cs @@ -10,6 +10,10 @@ using Robust.Shared.Input.Binding; using Robust.Shared.Utility; using static Robust.Client.UserInterface.Controls.BaseButton; +using Content.Client.UserInterface.Systems.Chat.Widgets; +using Content.Client.Language.Systems; +using Content.Shared.Language; +using Content.Shared.Language.Systems; namespace Content.Client.UserInterface.Systems.Language; @@ -18,10 +22,10 @@ public sealed class LanguageMenuUIController : UIController, IOnStateEntered UIManager.GetActiveUIWidgetOrNull()?.LanguageButton; - public string? LastPreferredLanguage; public Action>? LanguagesChanged; [Dependency] private readonly IConsoleHost _consoleHost = default!; + [Dependency] private readonly LanguageSystem _language = default!; public override void Initialize() { @@ -115,16 +119,28 @@ private void ToggleWindow() private void OnStateUpdate(LanguageMenuStateMessage ev) { + var chatBox = UIManager.ActiveScreen?.GetWidget() ?? UIManager.ActiveScreen?.GetWidget(); + if (chatBox != null) + { + var clangauge = _language.GetLanguage(ev.CurrentLanguage); + if (clangauge != null) + { + chatBox.ChatInput.LanguageSelector.UpdateLanguageSelectButton(clangauge); + } + } + if (_languageWindow == null) return; _languageWindow.UpdateState(ev); LanguagesChanged?.Invoke(ev.Options); } + public void RequestUpdate() { EntityManager.EntityNetManager?.SendSystemNetworkMessage(new RequestLanguageMenuStateMessage()); } + public void SetLanguage(string id) { _consoleHost.ExecuteCommand("lsselectlang " + id);