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 #43

Merged
merged 92 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
da76123
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician Mar 20, 2024
a95f105
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician Mar 20, 2024
728e9b1
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician Mar 20, 2024
113826b
Revert "Fixes for universal speakers (no more walls speaking GC)"
FoxxoTrystan Mar 24, 2024
6bdc514
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician Mar 20, 2024
3d86f02
Port
FoxxoTrystan Mar 24, 2024
bf80a15
Missing Default Langauges (Only Harpies duh)
FoxxoTrystan Mar 25, 2024
c65c1d3
Animals SPEAKS!
FoxxoTrystan Mar 25, 2024
c61e061
Apply suggestions from code review
Mnemotechnician Mar 30, 2024
0b7dd07
Did what the review suggested
Mnemotechnician Mar 30, 2024
54b15c1
Merge remote-tracking branch 'upstream/master' into Languages
FoxxoTrystan Mar 31, 2024
f3b2daa
abstract + yml changes
FoxxoTrystan Mar 31, 2024
381eea1
Split translator comps into separate files and pray it compiles
Mnemotechnician Apr 7, 2024
6f841fb
Refactor RadioReceiveEvent
Mnemotechnician Apr 7, 2024
cdb786c
Refactor ChatSystem & add comments
Mnemotechnician Apr 7, 2024
f9dcd71
Clean up using directives after jetbrains rider messed em up
Mnemotechnician Apr 7, 2024
4bc2c46
Merge branch 'master' into Languages
FoxxoTrystan Apr 8, 2024
076bfc3
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan Apr 24, 2024
7dff567
Tiny Fixes/Requests
FoxxoTrystan Apr 24, 2024
a0d8c08
Added the most basic of syndicate flavor
Eagle-0 Apr 25, 2024
d14461e
Synths real
Eagle-0 Apr 25, 2024
55794de
Updated Door Sprites, syndicate Dropship, Saltern, Captains Cape
Arkyfloof Apr 26, 2024
4c3724d
Fixed traitors, new synth sounds, Urist update
Eagle-0 Apr 26, 2024
e819a63
Mechs real, Synth balance, Terragov Preset
Eagle-0 Apr 27, 2024
ec92c56
Changed cargo gifts, no more centcomm, urist shuttles
Eagle-0 Apr 28, 2024
937a4d9
Resolved Test
FoxxoTrystan Apr 29, 2024
21dd8dd
Update LanguageMenuUIController.cs
FoxxoTrystan Apr 29, 2024
f6d46f8
Added new Shuttle for the Terragov faction
Reese1243 Apr 29, 2024
1baab28
added a new shuttle for the TerraGov faction
Reese1243 Apr 29, 2024
c1287b8
Fixed some announcements, centcom name change, atmosia fake
Eagle-0 Apr 29, 2024
ba7d807
Delete TerraGovernor.yml
Reese1243 Apr 30, 2024
1618f20
SyndieSaltern
VMSolidus Apr 30, 2024
c10d283
Merge pull request #3 from Eagle-0/saltern-updates
Eagle-0 Apr 30, 2024
0983aa7
Update LanguageMenuUIController.cs
FoxxoTrystan May 1, 2024
b3ad259
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan May 1, 2024
041ef46
Update LanguageMenuUIController.cs
FoxxoTrystan May 1, 2024
7452487
Update LanguageMenuUIController.cs
FoxxoTrystan May 1, 2024
2b3a807
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan May 1, 2024
a938832
Update LanguageMenuUIController.cs
FoxxoTrystan May 1, 2024
e66df36
Update LanguageMenuUIController.cs
FoxxoTrystan May 1, 2024
c507898
Added terragov shuttle
Reese1243 May 1, 2024
70987a9
Merge pull request #4 from Eagle-0/Blitz
Reese1243 May 1, 2024
5ce48b2
Reverting
FoxxoTrystan May 1, 2024
d5d51b6
Uhh, test, if this works accept it
Arkyfloof May 1, 2024
b47718d
Merge pull request #5 from Eagle-0/arky
Arkyfloof May 1, 2024
52c4566
swapped the Shuttle Consoles and Communications consoles to the syndi…
Reese1243 May 1, 2024
d2ca520
Mons are real, Total Catgirl removal
Eagle-0 May 1, 2024
d873884
Edited Terragov shuttle
Reese1243 May 1, 2024
8af1830
Changed Antag role timers to match Wizards Den
Reese1243 May 1, 2024
5300226
Changed Antag role timers to match Wizards Den
Reese1243 May 1, 2024
93e7218
Merge branch 'Blitz' of https://github.com/Eagle-0/Syndicate-Station …
Reese1243 May 1, 2024
873ab05
Merge branch 'master' into Blitz
Reese1243 May 2, 2024
a7fefa4
New SOM guns, broken clothing :sob:
Eagle-0 May 2, 2024
b5a6013
Fixed LoneOps time requirement to be the same as NukeOps
Reese1243 May 3, 2024
a4ecd2b
Merge branch 'master' of https://github.com/Eagle-0/Syndicate-Station
Eagle-0 May 3, 2024
875cf7b
Update LanguageMenuUIController.cs
FoxxoTrystan May 3, 2024
5201873
Merge branch 'master' into Languages
FoxxoTrystan May 3, 2024
96e1c0a
Update LanguageMenuUIController.cs
FoxxoTrystan May 3, 2024
7c2621b
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan May 3, 2024
5023cc4
Update LanguageMenuUIController.cs
FoxxoTrystan May 3, 2024
38060c9
Finally Fixing it
VMSolidus May 3, 2024
9f6ee28
Update LanguageMenuUIController.cs
FoxxoTrystan May 3, 2024
54dee4f
Update LanguageMenuUIController.cs
FoxxoTrystan May 3, 2024
b75939c
Fixed SOM gear
Eagle-0 May 3, 2024
87a0a87
Merge branch 'master' into Languages
FoxxoTrystan May 5, 2024
d935e80
Added HoP drip, new Terragov uplink items
Eagle-0 May 5, 2024
6234be8
UI Better and Test!
FoxxoTrystan May 6, 2024
ec9116a
Oops
FoxxoTrystan May 6, 2024
afdb7ce
Merge branch 'master' into Languages
FoxxoTrystan May 6, 2024
932bc29
SPACE!
FoxxoTrystan May 6, 2024
90f3588
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan May 6, 2024
f2adcee
Merge branch 'master' into Languages
FoxxoTrystan May 6, 2024
f5e8bca
Revert "Merge branch 'master' into Languages"
FoxxoTrystan May 6, 2024
c25d2ec
Update Resources/Prototypes/Entities/Objects/Devices/translator_impla…
FoxxoTrystan May 7, 2024
566d861
Update Resources/Prototypes/Entities/Objects/Devices/translator_impla…
FoxxoTrystan May 7, 2024
146c32f
Merge branch 'master' into Languages
FoxxoTrystan May 7, 2024
9cb5950
Networking OnClientSetLanguage
FoxxoTrystan May 8, 2024
f526f0a
Move LanguageSpeaker from BaseMobSpeciesOrganic to BaseMobSpecies
FoxxoTrystan May 9, 2024
0fa806c
Merge branch 'master' into Languages
FoxxoTrystan May 9, 2024
dea18f0
Merge branch 'master' into Languages
VMSolidus May 12, 2024
e0d65d4
Merge branch 'master' into Languages
VMSolidus May 12, 2024
a85ed4d
Parrots Moments
FoxxoTrystan May 12, 2024
e23dabe
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan May 13, 2024
f336f5a
Sanitize Messes!
FoxxoTrystan May 13, 2024
5ebbbc0
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan May 13, 2024
b9850d8
Merge branch 'master' into Languages
FoxxoTrystan May 28, 2024
19697bb
Merge branch 'master' into Languages
FoxxoTrystan Jun 3, 2024
789cf4e
Apply (some) suggestions from code review
Mnemotechnician Jun 4, 2024
1d7d5d2
Please, for the sake of god and all that's holy, never ever creature …
Mnemotechnician Jun 4, 2024
f6f6679
More refactoring & linter fixes
Mnemotechnician Jun 4, 2024
c4cec66
Lots of refactoring; partially fixed language menu desync
Mnemotechnician Jun 4, 2024
7581981
Update Content.Server/Chat/Systems/ChatSystem.cs
FoxxoTrystan Jun 8, 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
1 change: 1 addition & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static void SetupContexts(IInputContextContainer contexts)
human.AddFunction(ContentKeyFunctions.UseItemInHand);
human.AddFunction(ContentKeyFunctions.AltUseItemInHand);
human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
human.AddFunction(ContentKeyFunctions.OpenLanguageMenu);
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
human.AddFunction(ContentKeyFunctions.AltActivateItemInWorld);
Expand Down
18 changes: 18 additions & 0 deletions Content.Client/Language/LanguageMenuWindow.xaml
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps see if you can get anyone experienced in UI involved to make something neat looking? A little slimmer would also probably be better for a utilitarian-menu.

Also this should probably be a FancyWindow

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc language-menu-window-title}"
SetSize="300 300">
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150">
<PanelContainer Name="CurrentLanguageContainer" Access="Public" StyleClasses="PdaBorderRect">
<Label Name="CurrentLanguageLabel" Access="Public" Text="Current Language:" HorizontalExpand="True"></Label>
</PanelContainer>

<ui:HLine></ui:HLine>

<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False" VScrollEnabled="True" MinHeight="50">
<BoxContainer Name="OptionsList" Access="Public" HorizontalExpand="True" SeparationOverride="2" Orientation="Vertical">
<!-- The rest here is generated programmatically -->
</BoxContainer>
</ScrollContainer>
</BoxContainer>
</DefaultWindow>
134 changes: 134 additions & 0 deletions Content.Client/Language/LanguageMenuWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
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>();
}

Mnemotechnician marked this conversation as resolved.
Show resolved Hide resolved
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);

FoxxoTrystan marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}
76 changes: 76 additions & 0 deletions Content.Client/Language/Systems/LanguageSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Content.Shared.Language;
using Content.Shared.Language.Events;
using Content.Shared.Language.Systems;
using Robust.Client;
using Robust.Shared.Console;

namespace Content.Client.Language.Systems;

/// <summary>
/// Client-side language system.
/// </summary>
/// <remarks>
/// Unlike the server, the client is not aware of other entities' languages; it's only notified about the entity that it posesses.
/// Due to that, this system stores such information in a static manner.
DangerRevolution marked this conversation as resolved.
Show resolved Hide resolved
/// </remarks>
public sealed class LanguageSystem : SharedLanguageSystem
{
[Dependency] private readonly IBaseClient _client = default!;

/// <summary>
/// The current language of the entity currently possessed by the player.
/// </summary>
public string CurrentLanguage { get; private set; } = default!;
/// <summary>
/// The list of languages the currently possessed entity can speak.
/// </summary>
public List<string> SpokenLanguages { get; private set; } = new();
/// <summary>
/// The list of languages the currently possessed entity can understand.
/// </summary>
public List<string> UnderstoodLanguages { get; private set; } = new();
FoxxoTrystan marked this conversation as resolved.
Show resolved Hide resolved

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

SubscribeNetworkEvent<LanguagesUpdatedMessage>(OnLanguagesUpdated);
_client.RunLevelChanged += OnRunLevelChanged;
}

private void OnLanguagesUpdated(LanguagesUpdatedMessage message)
{
CurrentLanguage = message.CurrentLanguage;
SpokenLanguages = message.Spoken;
UnderstoodLanguages = message.Understood;
}

private void OnRunLevelChanged(object? sender, RunLevelChangedEventArgs args)
{
// Request an update when entering a game
if (args.NewLevel == ClientRunLevel.InGame)
RequestStateUpdate();
}

/// <summary>
/// Sends a network request to the server to update this system's state.
/// The server may ignore the said request if the player is not possessing an entity.
/// </summary>
public void RequestStateUpdate()
{
RaiseNetworkEvent(new RequestLanguagesMessage());
}

public void RequestSetLanguage(LanguagePrototype language)
{
if (language.ID == CurrentLanguage)
return;

RaiseNetworkEvent(new LanguagesSetMessage(language.ID));

// May cause some minor desync...
// So to reduce the probability of desync, we replicate the change locally too
if (SpokenLanguages.Contains(language.ID))
CurrentLanguage = language.ID;
}
}
8 changes: 8 additions & 0 deletions Content.Client/Language/Systems/TranslatorImplanterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Language.Systems;

namespace Content.Client.Language.Systems;

public sealed class TranslatorImplanterSystem : SharedTranslatorImplanterSystem
{

}
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(ContentKeyFunctions.OpenCraftingMenu);
AddButton(ContentKeyFunctions.OpenGuidebook);
AddButton(ContentKeyFunctions.OpenInventoryMenu);
AddButton(ContentKeyFunctions.OpenLanguageMenu);
AddButton(ContentKeyFunctions.OpenAHelp);
AddButton(ContentKeyFunctions.OpenActionsMenu);
AddButton(ContentKeyFunctions.OpenEntitySpawnWindow);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Chat;
using Content.Shared.Input;
using Robust.Client.UserInterface;
FoxxoTrystan marked this conversation as resolved.
Show resolved Hide resolved
using Robust.Client.UserInterface.Controls;

namespace Content.Client.UserInterface.Systems.Chat.Controls;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Content.Client.Language;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Controls;
using Content.Shared.Input;
using Content.Shared.Language.Events;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BaseButton;
using JetBrains.Annotations;

namespace Content.Client.UserInterface.Systems.Language;

[UsedImplicitly]
public sealed class LanguageMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>
{
public LanguageMenuWindow? LanguageWindow;
private MenuButton? LanguageButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.LanguageButton;

public override void Initialize()
{
SubscribeNetworkEvent((LanguagesUpdatedMessage message, EntitySessionEventArgs _) =>
LanguageWindow?.UpdateState(message.CurrentLanguage, message.Spoken));
}

public void OnStateEntered(GameplayState state)
{
DebugTools.Assert(LanguageWindow == null);

LanguageWindow = UIManager.CreateWindow<LanguageMenuWindow>();
LayoutContainer.SetAnchorPreset(LanguageWindow, LayoutContainer.LayoutPreset.CenterTop);

CommandBinds.Builder.Bind(ContentKeyFunctions.OpenLanguageMenu,
InputCmdHandler.FromDelegate(_ => ToggleWindow())).Register<LanguageMenuUIController>();
}

public void OnStateExited(GameplayState state)
{
if (LanguageWindow != null)
{
LanguageWindow.Dispose();
LanguageWindow = null;
}

CommandBinds.Unregister<LanguageMenuUIController>();
}

public void UnloadButton()
{
if (LanguageButton == null)
return;

LanguageButton.OnPressed -= LanguageButtonPressed;
}

public void LoadButton()
{
if (LanguageButton == null)
return;

LanguageButton.OnPressed += LanguageButtonPressed;

if (LanguageWindow == null)
return;

LanguageWindow.OnClose += () => LanguageButton.Pressed = false;
LanguageWindow.OnOpen += () => LanguageButton.Pressed = true;
}

private void LanguageButtonPressed(ButtonEventArgs args)
{
ToggleWindow();
}

private void ToggleWindow()
{
if (LanguageWindow == null)
return;

if (LanguageButton != null)
LanguageButton.SetClickPressed(!LanguageWindow.IsOpen);

if (LanguageWindow.IsOpen)
LanguageWindow.Close();
else
LanguageWindow.Open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Client.UserInterface.Systems.Sandbox;
using Robust.Client.UserInterface.Controllers;
using Content.Client.UserInterface.Systems.Language;

namespace Content.Client.UserInterface.Systems.MenuBar;

Expand All @@ -22,6 +23,7 @@ public sealed class GameTopMenuBarUIController : UIController
[Dependency] private readonly ActionUIController _action = default!;
[Dependency] private readonly SandboxUIController _sandbox = default!;
[Dependency] private readonly GuidebookUIController _guidebook = default!;
[Dependency] private readonly LanguageMenuUIController _language = default!;

private GameTopMenuBar? GameTopMenuBar => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>();

Expand All @@ -44,6 +46,7 @@ public void UnloadButtons()
_ahelp.UnloadButton();
_action.UnloadButton();
_sandbox.UnloadButton();
_language.UnloadButton();
}

public void LoadButtons()
Expand All @@ -56,5 +59,6 @@ public void LoadButtons()
_ahelp.LoadButton();
_action.LoadButton();
_sandbox.LoadButton();
_language.LoadButton();
}
}
Loading
Loading