mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-21 23:48:15 +03:00
Resolves https://github.com/Simple-Station/Einstein-Engines/issues/37 # Description This PR adds languages. Every entity who can speak now speaks a specific language (or Universal, for entities that are not supposed to speak, which is understood by everyone). Other entities who do not understand this language will see gibberish (it's possible to learn how certain induvidual words are spelled. But the spelling changes between rounds). This means that certain creatures, like xenos, cats, vulps, can communicate within their species in their own languages. Similarly, it means that xenos, cats and other things cannot understand GalacticCommon speakers without a translator or cognization. An entity may be able to speak multiple languages, or understand a language but be unable to speak it. Thi PR was orignally made for Frontier but is now being ported and will be maintain here. Orignal PR: https://github.com/new-frontiers-14/frontier-station-14/pull/671 This PR was made orignally by Mnemotechnician and FoxxoTrystan. --- # TODO - [x] Language System. (Check Frontier PR for all the compleated todo list) - [x] Port PR from Frontier. - [x] QOL Changes. - [x] Missing Default Languages. (Missing default langauges for some roundstart species) - [x] Animals Languages. --- <details><summary><h1>Media</h1></summary> <p>    </p> </details> --- # Changelog 🆑 FoxxoTrystan / Mnemotechnician - add: All species can now bring their own cultures and languages --------- Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Signed-off-by: FoxxoTrystan <45297731+FoxxoTrystan@users.noreply.github.com> Co-authored-by: fox <daytimer253@gmail.com> Co-authored-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Co-authored-by: Pspritechologist <81725545+Pspritechologist@users.noreply.github.com> Co-authored-by: Lincoln McQueen <lincoln.mcqueen@gmail.com> Co-authored-by: Arkyfloof <Marvinlinke08@gmail.com> Co-authored-by: reese1243 <ber23027@byui.edu> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Eagle-0 <114363363+Eagle-0@users.noreply.github.com> Co-authored-by: BlitzDev <145472107+Reese1243@users.noreply.github.com> Co-authored-by: Arkyfloof <161242062+Arkyfloof@users.noreply.github.com> Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
135 lines
4.1 KiB
C#
135 lines
4.1 KiB
C#
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 Serilog;
|
|
using static Content.Shared.Language.Systems.SharedLanguageSystem;
|
|
|
|
namespace Content.Client.Language;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class LanguageMenuWindow : DefaultWindow
|
|
{
|
|
private readonly LanguageSystem _clientLanguageSystem;
|
|
private readonly List<EntryState> _entries = new();
|
|
|
|
|
|
public LanguageMenuWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
_clientLanguageSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<LanguageSystem>();
|
|
}
|
|
|
|
protected override void Opened()
|
|
{
|
|
// Refresh the window when it gets opened.
|
|
// This actually causes two refreshes: one immediately, and one after the server sends a state message.
|
|
UpdateState(_clientLanguageSystem.CurrentLanguage, _clientLanguageSystem.SpokenLanguages);
|
|
_clientLanguageSystem.RequestStateUpdate();
|
|
}
|
|
|
|
|
|
public void UpdateState(string currentLanguage, List<string> spokenLanguages)
|
|
{
|
|
var langName = Loc.GetString($"language-{currentLanguage}-name");
|
|
CurrentLanguageLabel.Text = Loc.GetString("language-menu-current-language", ("language", langName));
|
|
|
|
OptionsList.RemoveAllChildren();
|
|
_entries.Clear();
|
|
|
|
foreach (var language in spokenLanguages)
|
|
{
|
|
AddLanguageEntry(language);
|
|
}
|
|
|
|
// Disable the button for the currently chosen language
|
|
foreach (var entry in _entries)
|
|
{
|
|
if (entry.button != null)
|
|
entry.button.Disabled = entry.language == currentLanguage;
|
|
}
|
|
}
|
|
|
|
private void AddLanguageEntry(string language)
|
|
{
|
|
var proto = _clientLanguageSystem.GetLanguagePrototype(language);
|
|
var state = new EntryState { language = language };
|
|
|
|
var container = new BoxContainer { Orientation = BoxContainer.LayoutOrientation.Vertical };
|
|
|
|
#region Header
|
|
var header = new BoxContainer
|
|
{
|
|
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
|
HorizontalExpand = true,
|
|
SeparationOverride = 2
|
|
};
|
|
|
|
var name = new Label
|
|
{
|
|
Text = proto?.Name ?? Loc.GetString("generic-error"),
|
|
MinWidth = 50,
|
|
HorizontalExpand = true
|
|
};
|
|
|
|
var button = new Button { Text = "Choose" };
|
|
button.OnPressed += _ => OnLanguageChosen(language);
|
|
state.button = button;
|
|
|
|
header.AddChild(name);
|
|
header.AddChild(button);
|
|
|
|
container.AddChild(header);
|
|
#endregion
|
|
|
|
#region Collapsible description
|
|
var body = new CollapsibleBody
|
|
{
|
|
HorizontalExpand = true,
|
|
Margin = new Thickness(4f, 4f)
|
|
};
|
|
|
|
var description = new RichTextLabel { HorizontalExpand = true };
|
|
description.SetMessage(proto?.Description ?? Loc.GetString("generic-error"));
|
|
body.AddChild(description);
|
|
|
|
var collapser = new Collapsible(Loc.GetString("language-menu-description-header"), body)
|
|
{
|
|
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
|
HorizontalExpand = true
|
|
};
|
|
|
|
container.AddChild(collapser);
|
|
#endregion
|
|
|
|
// 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)
|
|
{
|
|
var proto = _clientLanguageSystem.GetLanguagePrototype(id);
|
|
if (proto != null)
|
|
_clientLanguageSystem.RequestSetLanguage(proto);
|
|
}
|
|
|
|
|
|
private struct EntryState
|
|
{
|
|
public string language;
|
|
public Button? button;
|
|
}
|
|
}
|