Skip to content

Commit

Permalink
OnStateUpdate Update now LanguageSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed Mar 15, 2024
1 parent 6287ead commit 1750226
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,10 +22,10 @@ public sealed class LanguageMenuUIController : UIController, IOnStateEntered<Gam
{
public LanguageMenuWindow? _languageWindow;
private MenuButton? LanguageButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.LanguageButton;

public string? LastPreferredLanguage;
public Action<List<string>>? LanguagesChanged;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
[Dependency] private readonly LanguageSystem _language = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -115,16 +119,28 @@ private void ToggleWindow()

private void OnStateUpdate(LanguageMenuStateMessage ev)
{
var chatBox = UIManager.ActiveScreen?.GetWidget<ChatBox>() ?? UIManager.ActiveScreen?.GetWidget<ResizableChatBox>();
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);
Expand Down

0 comments on commit 1750226

Please sign in to comment.