diff --git a/Content.Client/ADT/Language/LanguageMenuUIController.cs b/Content.Client/ADT/Language/LanguageMenuUIController.cs deleted file mode 100644 index 791b616bb3d..00000000000 --- a/Content.Client/ADT/Language/LanguageMenuUIController.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Content.Client.ADT.Language; -using Content.Client.Gameplay; -using Content.Shared.Language; -using Robust.Client.UserInterface.Controllers; -using Robust.Client.UserInterface.Controls; -using static Content.Shared.Language.Systems.SharedLanguageSystem; - -namespace Content.Client.ADT.Language; - -public sealed class LanguageMenuUIController : UIController, IOnStateEntered, IOnStateExited -{ - public LanguageMenuWindow? _languageWindow; - - public override void Initialize() - { - EntityManager.EventBus.SubscribeLocalEvent(OnActionMenu); - EntityManager.EventBus.SubscribeEvent(EventSource.Network, this, OnStateUpdate); - } - - private void OnStateUpdate(LanguageMenuStateMessage ev) - { - if (_languageWindow == null) - return; - - _languageWindow.UpdateState(ev); - } - - private void OnActionMenu(EntityUid uid, LanguageSpeakerComponent component, LanguageMenuActionEvent args) - { - if (_languageWindow == null) - return; - - if (!_languageWindow.IsOpen) - { - _languageWindow.Open(); - EntityManager.EntityNetManager?.SendSystemNetworkMessage(new RequestLanguageMenuStateMessage()); - } - } - - public void OnStateEntered(GameplayState state) - { - _languageWindow = UIManager.CreateWindow(); - LayoutContainer.SetAnchorPreset(_languageWindow, LayoutContainer.LayoutPreset.Center); - } - - public void OnStateExited(GameplayState state) - { - _languageWindow?.Dispose(); - _languageWindow = null; - } -} diff --git a/Content.Client/ADT/Language/LanguageMenuWindow.xaml.cs b/Content.Client/ADT/Language/LanguageMenuWindow.xaml.cs deleted file mode 100644 index 0a795aebbd1..00000000000 --- a/Content.Client/ADT/Language/LanguageMenuWindow.xaml.cs +++ /dev/null @@ -1,124 +0,0 @@ -using Content.Client.Language.Systems; -using Content.Shared.Language; -using Content.Shared.Language.Systems; -using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; -using Robust.Client.UserInterface.XAML; -using Robust.Shared.Console; -using Robust.Shared.Utility; -using static Content.Shared.Language.Systems.SharedLanguageSystem; - -namespace Content.Client.ADT.Language; // This EXACT class must have the _NF part because of xaml linking - -[GenerateTypedNameReferences] -public sealed partial class LanguageMenuWindow : DefaultWindow -{ - [Dependency] private readonly IConsoleHost _consoleHost = default!; - private readonly LanguageSystem _language; - - private readonly List _entries = new(); - - public LanguageMenuWindow() - { - RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); - _language = IoCManager.Resolve().GetEntitySystem(); - - Title = Loc.GetString("language-menu-window-title"); - } - - public void UpdateState(LanguageMenuStateMessage state) - { - var clanguage = _language.GetLanguage(state.CurrentLanguage); - CurrentLanguageLabel.Text = Loc.GetString("language-menu-current-language", ("language", clanguage?.LocalizedName ?? "")); - - OptionsList.RemoveAllChildren(); - _entries.Clear(); - - foreach (var language in state.Options) - { - AddLanguageEntry(language); - } - - // Disable the button for the currently chosen language - foreach (var entry in _entries) - { - if (entry.button != null) - entry.button.Disabled = entry.language == state.CurrentLanguage; - } - } - - private void AddLanguageEntry(string language) - { - var proto = _language.GetLanguage(language); - var state = new EntryState { language = language }; - - var container = new BoxContainer(); - container.Orientation = BoxContainer.LayoutOrientation.Vertical; - - // Create and add a header with the name and the button to select the language - { - var header = new BoxContainer(); - header.Orientation = BoxContainer.LayoutOrientation.Horizontal; - - header.Orientation = BoxContainer.LayoutOrientation.Horizontal; - header.HorizontalExpand = true; - header.SeparationOverride = 2; - - var name = new Label(); - name.Text = proto?.LocalizedName ?? ""; - name.MinWidth = 50; - name.HorizontalExpand = true; - - var button = new Button(); - button.Text = "Выбрать"; - button.OnPressed += _ => OnLanguageChosen(language); - state.button = button; - - header.AddChild(name); - header.AddChild(button); - - container.AddChild(header); - } - - // Create and add a collapsible description - { - var body = new CollapsibleBody(); - body.HorizontalExpand = true; - body.Margin = new Thickness(4f, 4f); - - var description = new RichTextLabel(); - description.SetMessage(proto?.LocalizedDescription ?? ""); - description.HorizontalExpand = true; - - body.AddChild(description); - - var collapser = new Collapsible(Loc.GetString("language-menu-description-header"), body); - collapser.Orientation = BoxContainer.LayoutOrientation.Vertical; - collapser.HorizontalExpand = true; - - container.AddChild(collapser); - } - - // Before adding, wrap the new container in a PanelContainer to give it a distinct look - var wrapper = new PanelContainer(); - wrapper.StyleClasses.Add("PdaBorderRect"); - - wrapper.AddChild(container); - OptionsList.AddChild(wrapper); - - _entries.Add(state); - } - - private void OnLanguageChosen(string id) - { - _consoleHost.ExecuteCommand("lsselectlang " + id); - } - - private struct EntryState - { - public string language; - public Button? button; - } -} diff --git a/Content.Client/ADT/Language/LanguageSystem.cs b/Content.Client/ADT/Language/LanguageSystem.cs new file mode 100644 index 00000000000..a56216ecfbb --- /dev/null +++ b/Content.Client/ADT/Language/LanguageSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.ADT.Language; + +namespace Content.Client.ADT.Language; + +public sealed partial class LanguageSystem : SharedLanguageSystem +{ +} diff --git a/Content.Client/ADT/Language/Systems/LanguageSystem.cs b/Content.Client/ADT/Language/Systems/LanguageSystem.cs deleted file mode 100644 index 4d603a700a9..00000000000 --- a/Content.Client/ADT/Language/Systems/LanguageSystem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Content.Shared.Language.Systems; - -namespace Content.Client.Language.Systems; - -public sealed class LanguageSystem : SharedLanguageSystem -{ - -} diff --git a/Content.Client/ADT/Language/Systems/TranslatorImplanterSystem.cs b/Content.Client/ADT/Language/Systems/TranslatorImplanterSystem.cs deleted file mode 100644 index bbe28d24f5d..00000000000 --- a/Content.Client/ADT/Language/Systems/TranslatorImplanterSystem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Content.Shared.Language.Systems; - -namespace Content.Client.Language.Systems; - -public sealed class TranslatorImplanterSystem : SharedTranslatorImplanterSystem -{ - -} diff --git a/Content.Client/ADT/Language/TranslatorImplantSystem.cs b/Content.Client/ADT/Language/TranslatorImplantSystem.cs new file mode 100644 index 00000000000..83067d0669e --- /dev/null +++ b/Content.Client/ADT/Language/TranslatorImplantSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared.Implants; + +namespace Content.Client.ADT.Implants; + +public sealed class TranslatorImplantSystem : SharedTranslatorImplantSystem +{ + +} diff --git a/Content.Client/ADT/Language/LanguageMenuWindow.xaml b/Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml similarity index 83% rename from Content.Client/ADT/Language/LanguageMenuWindow.xaml rename to Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml index 188b3bc3b54..bb8ec706658 100644 --- a/Content.Client/ADT/Language/LanguageMenuWindow.xaml +++ b/Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml @@ -1,7 +1,8 @@ - + + SetSize="400 450"> diff --git a/Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml.cs b/Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml.cs new file mode 100644 index 00000000000..095e5148ff9 --- /dev/null +++ b/Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml.cs @@ -0,0 +1,207 @@ +using Content.Shared.ADT.Language; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Player; +using System.Linq; + +namespace Content.Client.ADT.Language.UI; + +[GenerateTypedNameReferences] +public sealed partial class LanguageMenuWindow : DefaultWindow +{ + [Dependency] private readonly EntityManager _entManager = default!; + + [Dependency] private readonly ISharedPlayerManager _playerManager = default!; + + private readonly SharedLanguageSystem _language; + + private readonly List _entries = new(); + private readonly List