mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
# Description
4 fixes:
- Fixed translators stopping to provide a language for a fraction of a
tick, causing the provided language to get de-selected when moving a
translator within your inventory (from hands to pocket or otherwise)
- Fixed translators not updating your languages when running out of
power (literally forgot to call UpdateEntityLanguages)
- Fixed language menu breaking after you reconnect to the server (the
issue is tricky, apparently all subscriptions made by ui controllers are
invalidated when the client switches from gameplay state to menu state
(the "you are disconnected" one), but never calls Initialize() for them
again, which means they can never re-create the same subscriptions...
Which explains why the ahelp menu was breaking for me after
reconnecting. All UI controllers that make event subscriptions are
affected by this bug)
- Fixed the language menu button not updating when you close the menu
manually.
# Changelog
🆑
- fix: Fixed a couple issues with the language menu UI and translators.
88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using Content.Client.Language;
|
|
using Content.Client.Gameplay;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Input;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Input.Binding;
|
|
using Robust.Shared.Utility;
|
|
using static Robust.Client.UserInterface.Controls.BaseButton;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Language;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class LanguageMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>
|
|
{
|
|
public LanguageMenuWindow? LanguageWindow;
|
|
private MenuButton? LanguageButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.LanguageButton;
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
DebugTools.Assert(LanguageWindow == null);
|
|
|
|
LanguageWindow = UIManager.CreateWindow<LanguageMenuWindow>();
|
|
LayoutContainer.SetAnchorPreset(LanguageWindow, LayoutContainer.LayoutPreset.CenterTop);
|
|
|
|
LanguageWindow.OnClose += () =>
|
|
{
|
|
if (LanguageButton != null)
|
|
LanguageButton.Pressed = false;
|
|
};
|
|
LanguageWindow.OnOpen += () =>
|
|
{
|
|
if (LanguageButton != null)
|
|
LanguageButton.Pressed = true;
|
|
};
|
|
|
|
CommandBinds.Builder.Bind(ContentKeyFunctions.OpenLanguageMenu,
|
|
InputCmdHandler.FromDelegate(_ => ToggleWindow())).Register<LanguageMenuUIController>();
|
|
}
|
|
|
|
public void OnStateExited(GameplayState state)
|
|
{
|
|
if (LanguageWindow != null)
|
|
{
|
|
LanguageWindow.Dispose();
|
|
LanguageWindow = null;
|
|
}
|
|
|
|
CommandBinds.Unregister<LanguageMenuUIController>();
|
|
}
|
|
|
|
public void UnloadButton()
|
|
{
|
|
if (LanguageButton == null)
|
|
return;
|
|
|
|
LanguageButton.OnPressed -= LanguageButtonPressed;
|
|
}
|
|
|
|
public void LoadButton()
|
|
{
|
|
if (LanguageButton == null)
|
|
return;
|
|
|
|
LanguageButton.OnPressed += LanguageButtonPressed;
|
|
}
|
|
|
|
private void LanguageButtonPressed(ButtonEventArgs args)
|
|
{
|
|
ToggleWindow();
|
|
}
|
|
|
|
private void ToggleWindow()
|
|
{
|
|
if (LanguageWindow == null)
|
|
return;
|
|
|
|
if (LanguageButton != null)
|
|
LanguageButton.SetClickPressed(!LanguageWindow.IsOpen);
|
|
|
|
if (LanguageWindow.IsOpen)
|
|
LanguageWindow.Close();
|
|
else
|
|
LanguageWindow.Open();
|
|
}
|
|
}
|