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 revive #2628

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d7ff965
init
Jopaglazik Nov 12, 2024
2a1ce2f
whitespaces remove
Jopaglazik Nov 12, 2024
e24388a
more
Jopaglazik Nov 12, 2024
da2b043
fixes
Jopaglazik Nov 14, 2024
e2c3558
Merge branch 'master' into languages
Bomjojuk Feb 23, 2025
9ea1cec
try on fixing conflicts
Bomjojuk Feb 23, 2025
077d8e2
Merge branch 'master' into languages_revive
Bomjojuk Feb 23, 2025
d62e652
Update RobustToolbox
Bomjojuk Feb 23, 2025
853df29
submodulte update
UrPrice Feb 24, 2025
804273e
test
Kirus59 Feb 24, 2025
961a084
Revert "test"
Kirus59 Feb 24, 2025
71520be
some fixes
Kirus59 Feb 24, 2025
9cc5ff1
some fixes 2
Kirus59 Feb 24, 2025
d93e199
add encryption methods API
Kirus59 Feb 24, 2025
a21a5e9
Encrypt -> Scramble
Kirus59 Feb 24, 2025
b115ea4
moving to the server
Kirus59 Feb 26, 2025
fb0b71c
add manager
Kirus59 Feb 26, 2025
14257ad
add multilanguage messages
Kirus59 Feb 26, 2025
81e7d9f
add const prefix in regex pattern
Kirus59 Feb 26, 2025
66e412a
add seeded scramble
Kirus59 Feb 27, 2025
d134b23
rename comp fields & radio sys fixes
Kirus59 Feb 27, 2025
59d0686
return 'Remember, no English' & other fixes
Kirus59 Feb 28, 2025
d381c57
remove 'RemoveColorTags'
Kirus59 Feb 28, 2025
dc00d4b
some fixes, cleaning & optimization
Kirus59 Feb 28, 2025
a60beab
add ui button
Kirus59 Mar 2, 2025
03bd577
some fixes
Kirus59 Mar 2, 2025
e5cf715
try fix tts
Kirus59 Mar 2, 2025
30799f1
fix tts & add seeded scrambled words
Kirus59 Mar 2, 2025
a65833c
fix tts color
Kirus59 Mar 2, 2025
7448ee0
RandomSyllablesMethod fixes
Kirus59 Mar 2, 2025
a24839b
change icon
Kirus59 Mar 2, 2025
5a375d6
syllables method changes
Kirus59 Mar 4, 2025
2063f24
change buttons text
Kirus59 Mar 4, 2025
a1c629c
add canSpeak param
Kirus59 Mar 4, 2025
458d39f
add ScrambledLengthCoefficient
Kirus59 Mar 4, 2025
9c1f9e0
Pets languages, shorter keys
Bomjojuk Mar 4, 2025
c096c1b
Codespeak, dwarf desc
Bomjojuk Mar 5, 2025
fe6b7ec
Fix scramble codespeak
Bomjojuk Mar 5, 2025
75d9595
codespeak, pets fix
Bomjojuk Mar 6, 2025
c6e28cd
logs fixes & tweaks
Kirus59 Mar 7, 2025
a3bfec2
commands fix
Kirus59 Mar 7, 2025
a610e60
Borgs languages
Bomjojuk Mar 8, 2025
e2196e1
Add comments
Bomjojuk Mar 8, 2025
272c998
fix traits
Kirus59 Mar 9, 2025
78d8bc7
add languages limit
Kirus59 Mar 9, 2025
d46d396
fix yaml linter
Kirus59 Mar 9, 2025
e088e16
fix yaml linter 2
Kirus59 Mar 9, 2025
cb38b25
try fix
Kirus59 Mar 9, 2025
762c6cf
binary opt
Bomjojuk Mar 9, 2025
f694fda
comment codespeak
Bomjojuk Mar 10, 2025
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
19 changes: 19 additions & 0 deletions Content.Client/SS220/Languages/LanguageSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.SS220.Language;
using Content.Shared.SS220.Language.Systems;
using Robust.Shared.Network;

namespace Content.Client.SS220.Languages;

public sealed partial class LanguageSystem : SharedLanguageSystem
{
[Dependency] private readonly INetManager _net = default!;

public override void Initialize()
{
base.Initialize();

_net.RegisterNetMessage<ClientSelectlanguageMessage>();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Client.Resources;
using Content.Client.UserInterface.Systems.Chat.Controls;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using System.Numerics;

namespace Content.Client.SS220.UserInterface.System.Chat.Controls.LanguageSettings;

public sealed class LanguageSettingsButton : ChatPopupButton<LanguageSettingsPopup>
{
public LanguageSettingsButton()
{
IoCManager.InjectDependencies(this);

var texture = IoCManager.Resolve<IResourceCache>()
.GetTexture("/Textures/SS220/Interface/Nano/language_settings-button.png");

AddChild(new TextureRect
{
Texture = texture,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
});

OnPressed += _ => Popup.Update();
}

protected override UIBox2 GetPopupPosition()
{
var globalPos = GlobalPosition;
var (minX, minY) = Popup.MinSize;
return UIBox2.FromDimensions(
globalPos,
new Vector2(Math.Max(minX, Popup.MinWidth), minY));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<controls:LanguageSettingsPopup
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.SS220.UserInterface.System.Chat.Controls.LanguageSettings">
<PanelContainer StyleClasses="BorderedWindowPanel">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Name="LanguageLabel" Access="Public" HorizontalAlignment="Left" StyleClasses="LabelSubText"/>
<BoxContainer Name="LanguageContainer" Orientation="Vertical" HorizontalExpand="True"/>
</BoxContainer>
</PanelContainer>
</controls:LanguageSettingsPopup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.SS220.Language;
using Content.Shared.SS220.Language.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Network;
using Robust.Shared.Utility;

namespace Content.Client.SS220.UserInterface.System.Chat.Controls.LanguageSettings;

[GenerateTypedNameReferences]
public sealed partial class LanguageSettingsPopup : Popup
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly LanguageManager _language = default!;

private Dictionary<LanguagePrototype, Button> _buttonsDict = new();
private Button? _selectedLanguage;

public LanguageSettingsPopup()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
Update();
}

public void Update()
{
var uid = _player.LocalEntity;
if (uid == null ||
!_entityManager.TryGetComponent<LanguageComponent>(uid, out var comp))
{
UpdateLanguageContainer(null);
UpdateSelectedLanguage(null);
return;
}

var availableLanguages = new List<LanguagePrototype>();
foreach (var def in comp.AvailableLanguages)
{
if (!def.CanSpeak ||
!_language.TryGetLanguageById(def.Id, out var language))
continue;

availableLanguages.Add(language);
}
UpdateLanguageContainer(availableLanguages);

if (comp.SelectedLanguage is { } selectedLanguageId)
{
_language.TryGetLanguageById(selectedLanguageId, out var selectedLanguage);
UpdateSelectedLanguage(selectedLanguage);
}
else
UpdateSelectedLanguage(null);
}

private void UpdateLanguageContainer(List<LanguagePrototype>? availableLanguages)
{
LanguageContainer.DisposeAllChildren();
_buttonsDict.Clear();

if (availableLanguages == null ||
availableLanguages.Count <= 0)
{
LanguageLabel.Text = Loc.GetString("language-settings-ui-no-languages");
return;
}

LanguageLabel.Text = Loc.GetString("language-settings-ui-select-default");
foreach (var language in availableLanguages)
{
var languageKey = $"{_language.KeyPrefix}{language.Key}";
var text = Loc.GetString("language-settings-ui-field-name",
("name", Loc.GetString(language.Name)), ("key", languageKey));
var button = new Button() { Text = text };

if (language.Description is { } desc)
{
var tooltip = new Tooltip();
tooltip.SetMessage(FormattedMessage.FromMarkupPermissive(Loc.GetString(language.Description)));
button.TooltipSupplier = _ => tooltip;
}

_buttonsDict.Add(language, button);
button.OnPressed += _ =>
{
UpdateSelectedLanguage(language);
var msg = new ClientSelectlanguageMessage
{
LanguageId = language.ID
};
_net.ClientSendMessage(msg);
};
LanguageContainer.AddChild(button);
}
}

private void UpdateSelectedLanguage(LanguagePrototype? language)
{
if (language == null)
{
if (_selectedLanguage != null)
_selectedLanguage.Disabled = false;

_selectedLanguage = null;
return;
}

if (_buttonsDict.TryGetValue(language, out var button))
{
if (_selectedLanguage != null)
_selectedLanguage.Disabled = false;

button.Disabled = true;
_selectedLanguage = button;
}
}
}


Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Content.Client.Stylesheets;
using Content.Client.Stylesheets;
using Content.Client.SS220.UserInterface.System.Chat.Controls;
using Content.Shared.Chat;
using Content.Shared.Input;
using Robust.Client.UserInterface.Controls;
using Content.Client.SS220.UserInterface.System.Chat.Controls.LanguageSettings;

namespace Content.Client.UserInterface.Systems.Chat.Controls;

Expand All @@ -13,6 +14,7 @@ public class ChatInputBox : PanelContainer
public readonly HistoryLineEdit Input;
public readonly ChannelFilterButton FilterButton;
public readonly HighlightButton HighlightButton; //ss220 highlight words
public readonly LanguageSettingsButton LanguageSettings; // SS220 languages
protected readonly BoxContainer Container;
protected ChatChannel ActiveChannel { get; private set; } = ChatChannel.Local;

Expand Down Expand Up @@ -53,8 +55,16 @@ public ChatInputBox()
StyleClasses = {"chatFilterOptionButton"}
};
//ss220 highlight words end
// SS220 languages begin
LanguageSettings = new LanguageSettingsButton()
{
Name = "LanguageSettings",
StyleClasses = { "chatFilterOptionButton" }
};
// SS220 languages end
Container.AddChild(FilterButton);
Container.AddChild(HighlightButton); //ss220 highlight words
Container.AddChild(LanguageSettings); // SS220 languages
AddStyleClass(StyleNano.StyleClassChatSubPanel);
ChannelSelector.OnChannelSelect += UpdateActiveChannel;
}
Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.RegularExpressions;
using Content.Server.SS220.Language;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

Expand Down Expand Up @@ -113,6 +114,7 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager

[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly ILocalizationManager _loc = default!;
[Dependency] private readonly IEntityManager _entityManager = default!; // SS220 languages

private bool _doSanitize;

Expand Down Expand Up @@ -175,7 +177,9 @@ public bool TrySanitizeEmoteShorthands(string message,
}

// SS220 no English begin
var ntAllowed = sanitized.Replace("NanoTrasen", string.Empty, StringComparison.OrdinalIgnoreCase);
var language = _entityManager.System<LanguageSystem>();
var checkMessage = language.SanitizeMessage(speaker, speaker, sanitized, out _);
var ntAllowed = checkMessage.Replace("NanoTrasen", string.Empty, StringComparison.OrdinalIgnoreCase);
ntAllowed = ntAllowed.Replace("nt", string.Empty, StringComparison.OrdinalIgnoreCase);

// Remember, no English
Expand Down
Loading
Loading