-
Notifications
You must be signed in to change notification settings - Fork 169
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
DangerRevolution
merged 92 commits into
Simple-Station:master
from
FoxxoTrystan:Languages
Jun 10, 2024
Merged
Languages #43
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 a95f105
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician 728e9b1
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician 113826b
Revert "Fixes for universal speakers (no more walls speaking GC)"
FoxxoTrystan 6bdc514
Fixes for universal speakers (no more walls speaking GC)
Mnemotechnician 3d86f02
Port
FoxxoTrystan bf80a15
Missing Default Langauges (Only Harpies duh)
FoxxoTrystan c65c1d3
Animals SPEAKS!
FoxxoTrystan c61e061
Apply suggestions from code review
Mnemotechnician 0b7dd07
Did what the review suggested
Mnemotechnician 54b15c1
Merge remote-tracking branch 'upstream/master' into Languages
FoxxoTrystan f3b2daa
abstract + yml changes
FoxxoTrystan 381eea1
Split translator comps into separate files and pray it compiles
Mnemotechnician 6f841fb
Refactor RadioReceiveEvent
Mnemotechnician cdb786c
Refactor ChatSystem & add comments
Mnemotechnician f9dcd71
Clean up using directives after jetbrains rider messed em up
Mnemotechnician 4bc2c46
Merge branch 'master' into Languages
FoxxoTrystan 076bfc3
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan 7dff567
Tiny Fixes/Requests
FoxxoTrystan a0d8c08
Added the most basic of syndicate flavor
Eagle-0 d14461e
Synths real
Eagle-0 55794de
Updated Door Sprites, syndicate Dropship, Saltern, Captains Cape
Arkyfloof 4c3724d
Fixed traitors, new synth sounds, Urist update
Eagle-0 e819a63
Mechs real, Synth balance, Terragov Preset
Eagle-0 ec92c56
Changed cargo gifts, no more centcomm, urist shuttles
Eagle-0 937a4d9
Resolved Test
FoxxoTrystan 21dd8dd
Update LanguageMenuUIController.cs
FoxxoTrystan f6d46f8
Added new Shuttle for the Terragov faction
Reese1243 1baab28
added a new shuttle for the TerraGov faction
Reese1243 c1287b8
Fixed some announcements, centcom name change, atmosia fake
Eagle-0 ba7d807
Delete TerraGovernor.yml
Reese1243 1618f20
SyndieSaltern
VMSolidus c10d283
Merge pull request #3 from Eagle-0/saltern-updates
Eagle-0 0983aa7
Update LanguageMenuUIController.cs
FoxxoTrystan b3ad259
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan 041ef46
Update LanguageMenuUIController.cs
FoxxoTrystan 7452487
Update LanguageMenuUIController.cs
FoxxoTrystan 2b3a807
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan a938832
Update LanguageMenuUIController.cs
FoxxoTrystan e66df36
Update LanguageMenuUIController.cs
FoxxoTrystan c507898
Added terragov shuttle
Reese1243 70987a9
Merge pull request #4 from Eagle-0/Blitz
Reese1243 5ce48b2
Reverting
FoxxoTrystan d5d51b6
Uhh, test, if this works accept it
Arkyfloof b47718d
Merge pull request #5 from Eagle-0/arky
Arkyfloof 52c4566
swapped the Shuttle Consoles and Communications consoles to the syndi…
Reese1243 d2ca520
Mons are real, Total Catgirl removal
Eagle-0 d873884
Edited Terragov shuttle
Reese1243 8af1830
Changed Antag role timers to match Wizards Den
Reese1243 5300226
Changed Antag role timers to match Wizards Den
Reese1243 93e7218
Merge branch 'Blitz' of https://github.com/Eagle-0/Syndicate-Station …
Reese1243 873ab05
Merge branch 'master' into Blitz
Reese1243 a7fefa4
New SOM guns, broken clothing :sob:
Eagle-0 b5a6013
Fixed LoneOps time requirement to be the same as NukeOps
Reese1243 a4ecd2b
Merge branch 'master' of https://github.com/Eagle-0/Syndicate-Station
Eagle-0 875cf7b
Update LanguageMenuUIController.cs
FoxxoTrystan 5201873
Merge branch 'master' into Languages
FoxxoTrystan 96e1c0a
Update LanguageMenuUIController.cs
FoxxoTrystan 7c2621b
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan 5023cc4
Update LanguageMenuUIController.cs
FoxxoTrystan 38060c9
Finally Fixing it
VMSolidus 9f6ee28
Update LanguageMenuUIController.cs
FoxxoTrystan 54dee4f
Update LanguageMenuUIController.cs
FoxxoTrystan b75939c
Fixed SOM gear
Eagle-0 87a0a87
Merge branch 'master' into Languages
FoxxoTrystan d935e80
Added HoP drip, new Terragov uplink items
Eagle-0 6234be8
UI Better and Test!
FoxxoTrystan ec9116a
Oops
FoxxoTrystan afdb7ce
Merge branch 'master' into Languages
FoxxoTrystan 932bc29
SPACE!
FoxxoTrystan 90f3588
Merge branch 'Languages' of https://github.com/FoxxoTrystan/Einstein-…
FoxxoTrystan f2adcee
Merge branch 'master' into Languages
FoxxoTrystan f5e8bca
Revert "Merge branch 'master' into Languages"
FoxxoTrystan c25d2ec
Update Resources/Prototypes/Entities/Objects/Devices/translator_impla…
FoxxoTrystan 566d861
Update Resources/Prototypes/Entities/Objects/Devices/translator_impla…
FoxxoTrystan 146c32f
Merge branch 'master' into Languages
FoxxoTrystan 9cb5950
Networking OnClientSetLanguage
FoxxoTrystan f526f0a
Move LanguageSpeaker from BaseMobSpeciesOrganic to BaseMobSpecies
FoxxoTrystan 0fa806c
Merge branch 'master' into Languages
FoxxoTrystan dea18f0
Merge branch 'master' into Languages
VMSolidus e0d65d4
Merge branch 'master' into Languages
VMSolidus a85ed4d
Parrots Moments
FoxxoTrystan e23dabe
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan f336f5a
Sanitize Messes!
FoxxoTrystan 5ebbbc0
Merge branch 'Simple-Station:master' into Languages
FoxxoTrystan b9850d8
Merge branch 'master' into Languages
FoxxoTrystan 19697bb
Merge branch 'master' into Languages
FoxxoTrystan 789cf4e
Apply (some) suggestions from code review
Mnemotechnician 1d7d5d2
Please, for the sake of god and all that's holy, never ever creature …
Mnemotechnician f6f6679
More refactoring & linter fixes
Mnemotechnician c4cec66
Lots of refactoring; partially fixed language menu desync
Mnemotechnician 7581981
Update Content.Server/Chat/Systems/ChatSystem.cs
FoxxoTrystan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Content.Client/UserInterface/Systems/Chat/Controls/ChatInputBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
Content.Client/UserInterface/Systems/Language/LanguageMenuUIController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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