From 8813c9288b643f749548be4d1b416a3aaf9d51be Mon Sep 17 00:00:00 2001 From: FaDeOkno <143940725+FaDeOkno@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:55:28 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=A2=D0=BE=D1=82=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D1=80=D0=B5=D0=B2=D0=BE=D1=80=D0=BA=20=D1=8F?= =?UTF-8?q?=D0=B7=D1=8B=D0=BA=D0=BE=D0=B2=20(#165)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Описание PR Полный реворк системы языков. Улучшение, оптимизация и доведение до более-менее презентабельного вида. **Медиа** ![image](https://github.com/user-attachments/assets/7d9ab38d-ba16-4eab-9529-fc36ebb25e79) ![image](https://github.com/user-attachments/assets/0389984b-46a4-4386-9e62-ffd64967aade) **Проверки** - [x] PR полностью завершён и мне не нужна помощь чтобы его закончить. - [x] Я внимательно просмотрел все свои изменения и багов в них не нашёл. - [x] Я запускал локальный сервер со своими изменениями и всё протестировал. - [x] Я добавил скриншот/видео демонстрации PR в игре, **или** этот PR этого не требует. **Изменения** :cl: - tweak: Полный реворк системы языков. - tweak: Языки теперь выделяются не названием, а цветом текста. - tweak: Упрощена система языков. - tweak: Языковые импланты теперь можно извлечь. - add: Меню языков теперь открывается при нажатии на кнопку L и имеет кнопку в верхнем меню. --------- Co-authored-by: Schrödinger <132720404+Schrodinger71@users.noreply.github.com> --- .../ADT/Language/LanguageMenuUIController.cs | 51 -- .../ADT/Language/LanguageMenuWindow.xaml.cs | 124 ----- Content.Client/ADT/Language/LanguageSystem.cs | 7 + .../ADT/Language/Systems/LanguageSystem.cs | 8 - .../Systems/TranslatorImplanterSystem.cs | 8 - .../ADT/Language/TranslatorImplantSystem.cs | 8 + .../Language/{ => UI}/LanguageMenuWindow.xaml | 5 +- .../Language/UI/LanguageMenuWindow.xaml.cs | 207 ++++++++ Content.Client/Corvax/TTS/TTSSystem.cs | 20 +- Content.Client/Input/ContentContexts.cs | 1 + .../Options/UI/Tabs/KeyRebindTab.xaml.cs | 1 + .../Languages/LanguageMenuUIController.cs | 115 +++++ .../MenuBar/GameTopMenuBarUIController.cs | 4 + .../MenuBar/Widgets/GameTopMenuBar.xaml | 14 +- .../Language/Commands/ListLanguagesCommand.cs | 39 -- .../Language/Commands/SayLanguageCommand.cs | 53 --- .../Commands/SelectLanguageCommand.cs | 48 -- .../ADT/Language/LanguageSystem.Windows.cs | 40 -- Content.Server/ADT/Language/LanguageSystem.cs | 268 ++--------- .../ADT/Language/TranslatorImplantSystem.cs | 8 + .../ADT/Language/TranslatorImplanterSystem.cs | 79 --- .../ADT/Language/TranslatorSystem.cs | 247 +++------- Content.Server/Chat/Systems/ChatSystem.cs | 286 ++++++----- Content.Server/Corvax/TTS/TTSSystem.cs | 38 +- .../EntityEffects/Effects/MakeSentient.cs | 14 + .../Mind/Commands/MakeSentientCommand.cs | 13 + .../Radio/EntitySystems/HeadsetSystem.cs | 11 +- .../Radio/EntitySystems/RadioDeviceSystem.cs | 4 +- .../Radio/EntitySystems/RadioSystem.cs | 51 +- Content.Server/Radio/RadioEvent.cs | 3 +- .../Language/Components/CommonLangUnknown.cs | 14 - .../Components/HandheldTranslatorComponent.cs | 36 ++ .../Components/LanguageSpeakerComponent.cs | 54 +-- .../Components/TranslatorComponent.cs | 93 ---- .../Components/TranslatorImplantComponent.cs | 40 ++ .../TranslatorImplanterComponent.cs | 34 -- .../UniversalLanguageSpeacerComponent.cs | 11 - .../ADT/Language/LanguagePrototype.cs | 20 +- .../Language/Systems/SharedLanguageSystem.cs | 267 +++++++++-- .../Systems/SharedTranslatorImplantSystem.cs | 112 +++++ .../SharedTranslatorImplanterSystem.cs | 36 -- .../Systems/SharedTranslatorSystem.cs | 5 +- Content.Shared/Corvax/TTS/PlayTTSEvent.cs | 10 +- Content.Shared/Input/ContentKeyFunctions.cs | 1 + Content.Shared/Radio/RadioChannelPrototype.cs | 7 +- .../Locale/ru-RU/ADT/Languages/languages.ftl | 48 +- .../ADT/prototypes/Actions/language-menu.ftl | 10 +- .../Entities/Objects/Device/translators.ftl | 14 +- .../Entities/Objects/Misc/implanters.ftl | 11 +- Resources/Prototypes/ADT/Actions/language.yml | 12 - .../ADT/Entities/Objects/Device/handheld.yml | 449 ++++++++++++++++++ .../Entities/Objects/Devices/translators.yml | 388 --------------- .../ADT/Entities/Objects/Misc/implanters.yml | 333 +++++-------- .../Objects/Misc/subdermal_implants.yml | 324 +++++++++++++ .../Prototypes/ADT/Languages/languages.yml | 45 +- .../ADT/Recipes/Lathes/translators.yml | 116 +++-- .../Prototypes/ADT/Research/translators.yml | 20 +- .../Entities/Mobs/Player/observer.yml | 6 +- .../Entities/Structures/Machines/lathe.yml | 18 +- .../Objects/Devices/translator.rsi/icon.png | Bin .../translator.rsi/inhand-left-translator.png | Bin .../Devices/translator.rsi/inhand-left.png | Bin .../inhand-right-translator.png | Bin .../Devices/translator.rsi/inhand-right.png | Bin .../Objects/Devices/translator.rsi/meta.json | 0 .../Devices/translator.rsi/translator.png | Bin .../Textures/Interface/languages-menu.svg | 7 + .../Interface/languages-menu.svg.192dpi.png | Bin 0 -> 804 bytes .../languages-menu.svg.192dpi.png.yml | 2 + Resources/keybinds.yml | 8 +- 70 files changed, 2321 insertions(+), 2005 deletions(-) delete mode 100644 Content.Client/ADT/Language/LanguageMenuUIController.cs delete mode 100644 Content.Client/ADT/Language/LanguageMenuWindow.xaml.cs create mode 100644 Content.Client/ADT/Language/LanguageSystem.cs delete mode 100644 Content.Client/ADT/Language/Systems/LanguageSystem.cs delete mode 100644 Content.Client/ADT/Language/Systems/TranslatorImplanterSystem.cs create mode 100644 Content.Client/ADT/Language/TranslatorImplantSystem.cs rename Content.Client/ADT/Language/{ => UI}/LanguageMenuWindow.xaml (83%) create mode 100644 Content.Client/ADT/Language/UI/LanguageMenuWindow.xaml.cs create mode 100644 Content.Client/UserInterface/Systems/Languages/LanguageMenuUIController.cs delete mode 100644 Content.Server/ADT/Language/Commands/ListLanguagesCommand.cs delete mode 100644 Content.Server/ADT/Language/Commands/SayLanguageCommand.cs delete mode 100644 Content.Server/ADT/Language/Commands/SelectLanguageCommand.cs delete mode 100644 Content.Server/ADT/Language/LanguageSystem.Windows.cs create mode 100644 Content.Server/ADT/Language/TranslatorImplantSystem.cs delete mode 100644 Content.Server/ADT/Language/TranslatorImplanterSystem.cs delete mode 100644 Content.Shared/ADT/Language/Components/CommonLangUnknown.cs create mode 100644 Content.Shared/ADT/Language/Components/HandheldTranslatorComponent.cs delete mode 100644 Content.Shared/ADT/Language/Components/TranslatorComponent.cs create mode 100644 Content.Shared/ADT/Language/Components/TranslatorImplantComponent.cs delete mode 100644 Content.Shared/ADT/Language/Components/TranslatorImplanterComponent.cs delete mode 100644 Content.Shared/ADT/Language/Components/UniversalLanguageSpeacerComponent.cs create mode 100644 Content.Shared/ADT/Language/Systems/SharedTranslatorImplantSystem.cs delete mode 100644 Content.Shared/ADT/Language/Systems/SharedTranslatorImplanterSystem.cs delete mode 100644 Resources/Prototypes/ADT/Actions/language.yml create mode 100644 Resources/Prototypes/ADT/Entities/Objects/Device/handheld.yml delete mode 100644 Resources/Prototypes/ADT/Entities/Objects/Devices/translators.yml create mode 100644 Resources/Prototypes/ADT/Entities/Objects/Misc/subdermal_implants.yml rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/icon.png (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/inhand-left-translator.png (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/inhand-left.png (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/inhand-right-translator.png (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/inhand-right.png (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/meta.json (100%) rename Resources/Textures/{_NF => ADT}/Objects/Devices/translator.rsi/translator.png (100%) create mode 100644 Resources/Textures/Interface/languages-menu.svg create mode 100644 Resources/Textures/Interface/languages-menu.svg.192dpi.png create mode 100644 Resources/Textures/Interface/languages-menu.svg.192dpi.png.yml diff --git a/Content.Client/ADT/Language/LanguageMenuUIController.cs b/Content.Client/ADT/Language/LanguageMenuUIController.cs deleted file mode 100644 index 791b616bb3..0000000000 --- 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 0a795aebbd..0000000000 --- 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 0000000000..a56216ecfb --- /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 4d603a700a..0000000000 --- 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 bbe28d24f5..0000000000 --- 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 0000000000..83067d0669 --- /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 188b3bc3b5..bb8ec70665 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 0000000000..095e5148ff --- /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