Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Languages update #671

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
3975678
Fix erase verb not removing chat messages in some cases (#21355)
DrSmugleaf Nov 6, 2023
2285037
Removing vulp speak as a temp fix
dvir001 Dec 1, 2023
4693f3c
Update HeadsetSystem.cs
dvir001 Dec 1, 2023
d06fe5a
Update RadioSystem.cs
dvir001 Dec 1, 2023
4ee3c4e
Update ListeningSystem.cs
dvir001 Dec 1, 2023
e66adbc
Feat/languages: Initial commit (something works now)
Mnemotechnician Dec 5, 2023
7503978
Rework everything, adding support for spoken/understood langs, as wel…
Mnemotechnician Dec 5, 2023
0a61515
Minor fixes
Mnemotechnician Dec 5, 2023
60632e2
Fix language checks in ChatSystem not accounting for language overrides
Mnemotechnician Dec 5, 2023
57ffd0d
Outdated comments
Mnemotechnician Dec 5, 2023
547a149
Oops. Missed a semicolon before pushing...
Mnemotechnician Dec 5, 2023
648ae24
Remove obsolete API
Mnemotechnician Dec 5, 2023
eefa226
Split langsys into common and server systems
Mnemotechnician Dec 6, 2023
9625489
Move stuff over to Content.Server.Language instead of Speech
Mnemotechnician Dec 6, 2023
4832df8
Added commands related to languages
Mnemotechnician Dec 7, 2023
98c8c34
Implement translators
Mnemotechnician Dec 7, 2023
f65f7e4
Remove entity system dependencies from commands, and do not listen on…
Mnemotechnician Dec 7, 2023
266c838
I spent... 30 minutes... debugging this... only to change 1 line
Mnemotechnician Dec 7, 2023
b9ce39c
New obfuscation system. Still quite broken.
Mnemotechnician Dec 7, 2023
53cc5ad
Hopefully fixed phrase obfuscation
Mnemotechnician Dec 7, 2023
40284c3
fix the damn LANGUAGE PROTOTYPES!!!!!
Mnemotechnician Dec 7, 2023
6d0b4ad
Make obfuscation different in each round
Mnemotechnician Dec 7, 2023
e714418
Merge remote-tracking branch 'newfrontiers/master' into feat/languages
Mnemotechnician Dec 7, 2023
1858182
SolCommon (And test commit)
FoxxoTrystan Dec 7, 2023
fde54d9
Language Select Command
FoxxoTrystan Dec 8, 2023
c1185e3
MORE LANGUAGES!
FoxxoTrystan Dec 8, 2023
cec0d7f
Fixes
FoxxoTrystan Dec 8, 2023
31bf9c3
Remove unused files
Mnemotechnician Dec 8, 2023
50c97e5
Rework translators in a way that *seems* to work
Mnemotechnician Dec 8, 2023
22c561a
Menu (WIP)
FoxxoTrystan Dec 9, 2023
660e512
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 9, 2023
7306795
Translator File
FoxxoTrystan Dec 9, 2023
9a9a842
Some template ui code for the language switcher
Mnemotechnician Dec 9, 2023
286c025
Trystan why did you break this?..
Mnemotechnician Dec 9, 2023
889c1f1
Split LanguageSystem in partials, fix some ui things
Mnemotechnician Dec 9, 2023
1570cc2
New UI controller for the language menu action
Mnemotechnician Dec 9, 2023
eacfcc6
SCIENCE!
FoxxoTrystan Dec 9, 2023
844559e
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 9, 2023
4e0fdda
Language update event
Mnemotechnician Dec 9, 2023
c7ac216
Moved stuff to more relevant packages
Mnemotechnician Dec 9, 2023
f7be705
First implementatiton of translator implanters
Mnemotechnician Dec 9, 2023
a16d9e5
Oops. Quick fix
Mnemotechnician Dec 9, 2023
c385f09
Update vending_machines.yml
FoxxoTrystan Dec 9, 2023
d736fcb
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 9, 2023
3c1057c
Finished Science / Translators
FoxxoTrystan Dec 9, 2023
e4e6e1d
Gives (Mostly) all NPC LangaugeSpeaker Component
FoxxoTrystan Dec 10, 2023
51edfe9
CodeSpeak
FoxxoTrystan Dec 10, 2023
c11be22
Fix and finish implanters
Mnemotechnician Dec 10, 2023
5d9b40a
Rename translator data fields
Mnemotechnician Dec 10, 2023
6e5d9fa
Implemented visuals
Mnemotechnician Dec 10, 2023
f3d527b
Add missing stuff to the components
Mnemotechnician Dec 10, 2023
1b2f57e
Woring Language Menu
FoxxoTrystan Dec 11, 2023
76ae4cb
Update LanguageMenuWindow.xaml.cs
FoxxoTrystan Dec 11, 2023
72156ea
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Dec 11, 2023
4272d8b
Broken mess, just to show, please dont use it AAA
FoxxoTrystan Dec 11, 2023
574f459
Added language names and descriptions.
Mnemotechnician Dec 11, 2023
5474fc5
Merge remote-tracking branch 'origin/feat/languages' into feat/languages
Mnemotechnician Dec 11, 2023
45dde77
Fix what I just did
Mnemotechnician Dec 11, 2023
3fefa62
Send LanguagesUpdateEvent upon successful implantation
Mnemotechnician Dec 11, 2023
70d450e
Language menu improvements
Mnemotechnician Dec 11, 2023
5fc308f
Made "make sentient" and cognizine give out a LanguageSpeakerComponent
Mnemotechnician Dec 11, 2023
1b583cc
UI Nightmare
FoxxoTrystan Dec 11, 2023
d28fe81
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 11, 2023
926fd49
Update guardian.yml
FoxxoTrystan Dec 11, 2023
c2af6eb
Actually finished the language menu
Mnemotechnician Dec 11, 2023
bcac627
Translator Uses Power, KINDA...
FoxxoTrystan Dec 12, 2023
c1c0368
Update languages.ftl
FoxxoTrystan Dec 12, 2023
edd14b6
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 12, 2023
271a24d
Contravand CodeSpeak / Fixes
FoxxoTrystan Dec 12, 2023
991dc0c
Fixes... again.
FoxxoTrystan Dec 12, 2023
1c2632d
Hmm Drawrate fix
FoxxoTrystan Dec 12, 2023
8f48707
Change the default language window size and margins
Mnemotechnician Dec 12, 2023
149cd28
Refactor some yml files
Mnemotechnician Dec 12, 2023
646a2a9
Fixed translator implant appearence
Mnemotechnician Dec 12, 2023
73a7e15
Oops
Mnemotechnician Dec 12, 2023
573cbe5
Finish Translator Power.
FoxxoTrystan Dec 12, 2023
78854ec
Linter HAPPY!
FoxxoTrystan Dec 12, 2023
e98e663
Update Translator Sprite.
FoxxoTrystan Dec 12, 2023
42078ca
Update languages.ftl
FoxxoTrystan Dec 12, 2023
782c766
Update languages.ftl
FoxxoTrystan Dec 12, 2023
49ee4b2
Adds Moffic Language
FoxxoTrystan Dec 13, 2023
5464483
Update translator_implants.yml
FoxxoTrystan Dec 13, 2023
e8d4ce5
Added frontier comments
Mnemotechnician Dec 13, 2023
81a8087
Revert "Update translator_implants.yml"
FoxxoTrystan Dec 13, 2023
893ca83
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 13, 2023
6fad295
Missed a couple changes with my previous commit.
Mnemotechnician Dec 13, 2023
731f3ee
Minor refactor
Mnemotechnician Dec 14, 2023
5c4eff7
Pets can now understand GalacticCommon
FoxxoTrystan Dec 18, 2023
1f2aa4c
Merge branch 'feat/languages' of https://github.com/Mnemotechnician/f…
FoxxoTrystan Dec 18, 2023
3514e54
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Dec 18, 2023
a8b91ea
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Dec 24, 2023
0094be3
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Dec 30, 2023
216159f
Shuffle files around
Mnemotechnician Jan 7, 2024
b7a5f90
Delete refrences to the long gone hardcoded vulp language
Mnemotechnician Jan 7, 2024
d6c88f7
Move the ui controller as well
Mnemotechnician Jan 7, 2024
c9ace81
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Jan 8, 2024
5052677
Merge remote-tracking branch 'newfrontiers/master' into feat/languages
Mnemotechnician Feb 14, 2024
014b76d
Wa
Mnemotechnician Feb 14, 2024
571b560
Merge remote-tracking branch 'origin/feat/languages' into feat/languages
Mnemotechnician Feb 14, 2024
1f5dc56
Fix window flickering and increase the default window size
Mnemotechnician Feb 14, 2024
cd7e250
Added a language selector to the chat ui (kmp)
Mnemotechnician Feb 23, 2024
800b7fa
Merge remote-tracking branch 'upstream/master' into feat/languages
FoxxoTrystan Mar 14, 2024
6287ead
QOL - Language Menu
FoxxoTrystan Mar 14, 2024
1750226
OnStateUpdate Update now LanguageSelector
FoxxoTrystan Mar 15, 2024
2282345
Revert "OnStateUpdate Update now LanguageSelector"
FoxxoTrystan Mar 18, 2024
6fc0831
Merge remote-tracking branch 'upstream/master' into pr/671
FoxxoTrystan Mar 18, 2024
10bca44
Total refactor of the client-server interactions and client-side logic
Mnemotechnician Mar 20, 2024
34de3a6
Typo
Mnemotechnician Mar 20, 2024
e91f7e1
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Content.Shared.Chat;
using Content.Client._NF.Language.Systems.Chat.Controls;
using Content.Client.UserInterface.Systems.Language;
using Content.Shared.Chat;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be using Content.Client._NF.Language;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, namespaces are fucked up here, _NF should be gone except in cases where it's absolutely needed (like .xaml.cs files)

using Content.Shared.Input;
using Content.Shared.Language;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;

namespace Content.Client.UserInterface.Systems.Chat.Controls;
Expand All @@ -8,6 +12,7 @@ namespace Content.Client.UserInterface.Systems.Chat.Controls;
public class ChatInputBox : PanelContainer
{
public readonly ChannelSelectorButton ChannelSelector;
public readonly LanguageSelectorButton LanguageSelector; // Frontier
public readonly HistoryLineEdit Input;
public readonly ChannelFilterButton FilterButton;
protected readonly BoxContainer Container;
Expand All @@ -30,6 +35,17 @@ public ChatInputBox()
MinWidth = 75
};
Container.AddChild(ChannelSelector);
// frontier block - begin
LanguageSelector = new LanguageSelectorButton
{
Name = "LanguageSelector",
ToggleMode = true,
StyleClasses = { "chatSelectorOptionButton" },
MinWidth = 75
};
Container.AddChild(LanguageSelector);
LanguageSelector.OnLanguageSelect += SelectLanguage;
// frontier block - end
Input = new HistoryLineEdit
{
Name = "Input",
Expand All @@ -52,6 +68,13 @@ private void UpdateActiveChannel(ChatSelectChannel selectedChannel)
ActiveChannel = (ChatChannel) selectedChannel;
}

// Frontier
private void SelectLanguage(LanguagePrototype language)
{
// This sucks a lot
IoCManager.Resolve<IUserInterfaceManager>().GetUIController<LanguageMenuUIController>().SetLanguage(language.ID);
}

private static string GetChatboxInfoPlaceholder()
{
return (BoundKeyHelper.IsBound(ContentKeyFunctions.FocusChat), BoundKeyHelper.IsBound(ContentKeyFunctions.CycleChatChannelForward)) switch
Expand Down
7 changes: 3 additions & 4 deletions Content.Client/_NF/Language/LanguageMenuWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ namespace Content.Client._NF.Language; // This EXACT class must have the _NF par
[GenerateTypedNameReferences]
public sealed partial class LanguageMenuWindow : DefaultWindow
{
[Dependency] private readonly IConsoleHost _consoleHost = default!;
private readonly LanguageSystem _language;

private readonly List<EntryState> _entries = new();

public Action<string>? OnLanguageSelected;

public LanguageMenuWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_language = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<LanguageSystem>();

Title = Loc.GetString("language-menu-window-title");
Expand Down Expand Up @@ -113,7 +112,7 @@ private void AddLanguageEntry(string language)

private void OnLanguageChosen(string id)
{
_consoleHost.ExecuteCommand("lsselectlang " + id);
OnLanguageSelected?.Invoke(id);
}

private struct EntryState
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System.Linq;
using System.Numerics;
using Content.Client.UserInterface.Systems.Chat.Controls;
using Content.Shared.Language;
using Robust.Shared.Utility;

namespace Content.Client._NF.Language.Systems.Chat.Controls;

// Mostly copied from ChannelSelectorButton
public sealed class LanguageSelectorButton : ChatPopupButton<LanguageSelectorPopup>
{
public event Action<LanguagePrototype>? OnLanguageSelect;

public LanguagePrototype? SelectedLanguage { get; private set; }

private const int SelectorDropdownOffset = 38;

public LanguageSelectorButton()
{
Name = "LanguageSelector";

Popup.Selected += OnLanguageSelected;

if (Popup.FirstLanguage is { } firstSelector)
{
Select(firstSelector);
}
}

protected override UIBox2 GetPopupPosition()
{
var globalLeft = GlobalPosition.X;
var globalBot = GlobalPosition.Y + Height;
return UIBox2.FromDimensions(
new Vector2(globalLeft, globalBot),
new Vector2(SizeBox.Width, SelectorDropdownOffset));
}

private void OnLanguageSelected(LanguagePrototype channel)
{
Select(channel);
}

public void Select(LanguagePrototype language)
{
if (Popup.Visible)
{
Popup.Close();
}

if (SelectedLanguage == language)
return;
SelectedLanguage = language;
OnLanguageSelect?.Invoke(language);

Text = LanguageSelectorName(language);
}

public static string LanguageSelectorName(LanguagePrototype language, bool full = false)
{
var name = language.LocalizedName;

// if the language name is short enough, just return it
if (full || name.Length < 5)
return name;

// If the language name is multi-word, collect first letters and capitalize them
if (name.Contains(' '))
{
var result = name
.Split(" ")
.Select(it => it.FirstOrNull())
.Where(it => it != null)
.Select(it => char.ToUpper(it!.Value));

return new string(result.ToArray());
}

// Alternatively, take the first 5 letters
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
// };
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Chat;
using Content.Client.UserInterface.Systems.Chat.Controls;
using Content.Shared.Chat;
using Content.Shared.Language;
using Robust.Client.UserInterface.Controls;

namespace Content.Client._NF.Language.Systems.Chat.Controls;

// Mostly copied from ChannelSelectorItemButton
public sealed class LanguageSelectorItemButton : Button
{
public readonly LanguagePrototype Language;

public bool IsHidden => Parent == null;

public LanguageSelectorItemButton(LanguagePrototype language)
{
Language = language;
AddStyleClass(StyleNano.StyleClassChatChannelSelectorButton);

Text = LanguageSelectorButton.LanguageSelectorName(language, full: true);

// var prefix = ChatUIController.ChannelPrefixes[selector];
// if (prefix != default)
// Text = Loc.GetString("hud-chatbox-select-name-prefixed", ("name", Text), ("prefix", prefix));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System.Reflection.Metadata.Ecma335;
using Content.Client.Language.Systems;
using Content.Client.UserInterface.Systems.Chat.Controls;
using Content.Client.UserInterface.Systems.Language;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid namespace? Should this not be using Content.Client._NF.UserInterface.Systems.Language; however in my testing Rider can't seem to find that directory either.

using Content.Shared.Chat;
using Content.Shared.Language;
using Content.Shared.Language.Systems;
using Robust.Client.UserInterface.Controls;
using static Robust.Client.UserInterface.Controls.BaseButton;

namespace Content.Client._NF.Language.Systems.Chat.Controls;

// Mostly copied from LanguageSelectorPopup
public sealed class LanguageSelectorPopup : Popup
{
private readonly BoxContainer _channelSelectorHBox;
private readonly Dictionary<string, LanguageSelectorItemButton> _selectorStates = new();
private readonly LanguageMenuUIController _languageMenuController;

public event Action<LanguagePrototype>? Selected;

public LanguageSelectorPopup()
{
_channelSelectorHBox = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Horizontal,
SeparationOverride = 1
};

_languageMenuController = UserInterfaceManager.GetUIController<LanguageMenuUIController>();
_languageMenuController.LanguagesChanged += SetLanguages;

AddChild(_channelSelectorHBox);
}

public LanguagePrototype? FirstLanguage
{
get
{
foreach (var selector in _selectorStates.Values)
{
if (!selector.IsHidden)
return selector.Language;
}

return null;
}
}

private bool IsPreferredAvailable()
{
var preferred = _languageMenuController.LastPreferredLanguage;
return preferred != null && _selectorStates.TryGetValue(preferred, out var selector) && !selector.IsHidden;
}

public void SetLanguages(List<string> languages)
{
var languageSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<LanguageSystem>();
_channelSelectorHBox.RemoveAllChildren();

foreach (var language in languages)
{
if (!_selectorStates.TryGetValue(language, out var selector))
{
var proto = languageSystem.GetLanguage(language);
if (proto == null)
continue;

selector = new LanguageSelectorItemButton(proto);
_selectorStates[language] = selector;
selector.OnPressed += OnSelectorPressed;
}

if (selector.IsHidden)
{
_channelSelectorHBox.AddChild(selector);
}
}

var isPreferredAvailable = IsPreferredAvailable();
if (!isPreferredAvailable)
{
var first = FirstLanguage;
if (first != null)
Select(first);
}
}

private void OnSelectorPressed(ButtonEventArgs args)
{
var button = (LanguageSelectorItemButton) args.Button;
Select(button.Language);
}

private void Select(LanguagePrototype language)
{
Selected?.Invoke(language);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (!disposing)
return;

_languageMenuController.LanguagesChanged -= SetLanguages;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Content.Client._NF.Language;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Systems.Chat;
using Content.Shared.Language;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Console;
using Robust.Shared.Timing;
using static Content.Shared.Language.Systems.SharedLanguageSystem;

Expand All @@ -13,7 +15,11 @@ public sealed class LanguageMenuUIController : UIController, IOnStateEntered<Gam
public LanguageMenuWindow? _languageWindow;
private TimeSpan _lastToggle = TimeSpan.Zero;

public string? LastPreferredLanguage;
public Action<List<string>>? LanguagesChanged;

[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;

public override void Initialize()
{
Expand All @@ -28,6 +34,7 @@ private void OnStateUpdate(LanguageMenuStateMessage ev)
return;

_languageWindow.UpdateState(ev);
LanguagesChanged?.Invoke(ev.Options);
}

private void OnActionMenu(EntityUid uid, LanguageSpeakerComponent component, LanguageMenuActionEvent args)
Expand All @@ -43,16 +50,29 @@ private void OnActionMenu(EntityUid uid, LanguageSpeakerComponent component, Lan
else
{
_languageWindow!.Open();
EntityManager.EntityNetManager?.SendSystemNetworkMessage(new RequestLanguageMenuStateMessage());
RequestUpdate();
}

args.Handled = true;
}

public void RequestUpdate()
{
EntityManager.EntityNetManager?.SendSystemNetworkMessage(new RequestLanguageMenuStateMessage());
}

public void SetLanguage(string id)
{
_consoleHost.ExecuteCommand("lsselectlang " + id);
LastPreferredLanguage = id;
}

public void OnStateEntered(GameplayState state)
{
_languageWindow = UIManager.CreateWindow<LanguageMenuWindow>();
_languageWindow.OnLanguageSelected += SetLanguage;
LayoutContainer.SetAnchorPreset(_languageWindow, LayoutContainer.LayoutPreset.Center);
RequestUpdate();
}

public void OnStateExited(GameplayState state)
Expand Down
Loading