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 Markers #510

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
45c1bf0
Discover polymorphism
Mnemotechnician Jun 13, 2024
3df0c63
Apply polymorphism + fix some obfuscation phrases
Mnemotechnician Jun 13, 2024
f0af64c
Oops
Mnemotechnician Jun 14, 2024
86eaa73
Cleaned up imports
Mnemotechnician Jun 14, 2024
6770f30
Refactored and localized commands; made them more user-friendly.
Mnemotechnician Jun 14, 2024
e4f5917
Added HandheldTranslatorComponent.SetLanguageOnInteract for convenience
Mnemotechnician Jun 14, 2024
ad56d53
Refactor everything and pray it works:
Mnemotechnician Jun 15, 2024
0e63714
Update yaml prototypes accordingly
Mnemotechnician Jun 15, 2024
44b625f
Move LanguagePrototype.Replacement to ObfuscationMethod and remove Ob…
Mnemotechnician Jun 15, 2024
2f05074
Do not log missing LanguageSpeakerComponents
Mnemotechnician Jun 18, 2024
5a2dc13
Rewrite translator implants to use the existing implant infrastructure
Mnemotechnician Jun 18, 2024
b3545d0
Update the language menu when choosing a new language
Mnemotechnician Jun 18, 2024
734e764
Fix handheld translators adjusting your current language
Mnemotechnician Jun 18, 2024
31d82fb
I fixes
Mnemotechnician Jun 18, 2024
fe43060
Merge branch 'master' into refactor/languages
Mnemotechnician Jun 21, 2024
19667eb
Merge branch 'master' into refactor/languages
Mnemotechnician Jun 23, 2024
6adc50d
Merge branch 'Simple-Station:master' into refactor/languages
Mnemotechnician Jun 27, 2024
d9d74de
Minor improvements
Mnemotechnician Jun 27, 2024
cc4e86d
Markers
FoxxoTrystan Jul 4, 2024
37d95ce
The fonts!
FoxxoTrystan Jul 4, 2024
afe5bcb
Merge branch 'Languages/Markers' into Languages_Markers
FoxxoTrystan Jul 4, 2024
d73d983
Merge branch 'master' into Languages_Markers
FoxxoTrystan Jul 4, 2024
2e1ff7d
Merge branch 'master' into Languages_Markers
FoxxoTrystan Jul 6, 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
20 changes: 12 additions & 8 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ private void SendEntitySpeak(

name = FormattedMessage.EscapeText(name);
// The chat message wrapped in a "x says y" string
var wrappedMessage = WrapPublicMessage(source, name, message);
var wrappedMessage = WrapPublicMessage(source, name, message, languageOverride: language);
// The chat message obfuscated via language obfuscation
var obfuscated = SanitizeInGameICMessage(source, _language.ObfuscateSpeech(message, language), out var emoteStr, true, _configurationManager.GetCVar(CCVars.ChatPunctuation), (!CultureInfo.CurrentCulture.IsNeutralCulture && CultureInfo.CurrentCulture.Parent.Name == "en") || (CultureInfo.CurrentCulture.IsNeutralCulture && CultureInfo.CurrentCulture.Name == "en"));
// The language-obfuscated message wrapped in a "x says y" string
var wrappedObfuscated = WrapPublicMessage(source, name, obfuscated);
var wrappedObfuscated = WrapPublicMessage(source, name, obfuscated, languageOverride: language);

SendInVoiceRange(ChatChannel.Local, name, message, wrappedMessage, obfuscated, wrappedObfuscated, source, range, languageOverride: language);

Expand Down Expand Up @@ -514,6 +514,7 @@ private void SendEntityWhisper(
// Scenario 1: the listener can clearly understand the message
result = perceivedMessage;
wrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("color", language.Color ?? Color.Gray),
("entityName", name),
("message", FormattedMessage.EscapeText(result)));
}
Expand All @@ -523,20 +524,22 @@ private void SendEntityWhisper(
// Collisiongroup.Opaque is not ideal for this use. Preferably, there should be a check specifically with "Can Ent1 see Ent2" in mind
result = ObfuscateMessageReadability(perceivedMessage);
wrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("entityName", nameIdentity), ("message", FormattedMessage.EscapeText(result)));
("entityName", nameIdentity), ("color", language.Color ?? Color.Gray), ("message", FormattedMessage.EscapeText(result)));
}
else
{
// Scenario 3: If listener is too far and has no line of sight, they can't identify the whisperer's identity
result = ObfuscateMessageReadability(perceivedMessage);
wrappedMessage = Loc.GetString("chat-manager-entity-whisper-unknown-wrap-message",
("color", language.Color ?? Color.Gray),
("message", FormattedMessage.EscapeText(result)));
}

_chatManager.ChatMessageToOne(ChatChannel.Whisper, result, wrappedMessage, source, false, session.Channel);
}

var replayWrap = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("color", language.Color ?? Color.Gray),
("entityName", name),
("message", FormattedMessage.EscapeText(message)));
_replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, replayWrap, GetNetEntity(source), null, MessageRangeHideChatForReplay(range)));
Expand Down Expand Up @@ -837,15 +840,16 @@ public string SanitizeMessageReplaceWords(string message)
/// <summary>
/// Wraps a message sent by the specified entity into an "x says y" string.
/// </summary>
public string WrapPublicMessage(EntityUid source, string name, string message)
public string WrapPublicMessage(EntityUid source, string name, string message, LanguagePrototype? languageOverride = null)
{
var language = languageOverride ?? _language.GetLanguage(source);
var speech = GetSpeechVerb(source, message);
var verbName = Loc.GetString(_random.Pick(speech.SpeechVerbStrings));
return Loc.GetString(speech.Bold ? "chat-manager-entity-say-bold-wrap-message" : "chat-manager-entity-say-wrap-message",
("color", language.Color ?? Color.White),
("entityName", name),
("verb", verbName),
("fontType", speech.FontId),
("fontSize", speech.FontSize),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("fontType", language.FontId ?? speech.FontId),
("fontSize", language.FontSize ?? speech.FontSize),
("message", message));
}

Expand Down
11 changes: 6 additions & 5 deletions Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
? FormattedMessage.EscapeText(message)
: message;

var wrappedMessage = WrapRadioMessage(messageSource, channel, name, content);
var wrappedMessage = WrapRadioMessage(messageSource, channel, name, content, language);
var msg = new ChatMessage(ChatChannel.Radio, content, wrappedMessage, NetEntity.Invalid, null);

// ... you guess it
var obfuscated = _language.ObfuscateSpeech(content, language);
var obfuscatedWrapped = WrapRadioMessage(messageSource, channel, name, obfuscated);
var obfuscatedWrapped = WrapRadioMessage(messageSource, channel, name, obfuscated, language);
var notUdsMsg = new ChatMessage(ChatChannel.Radio, obfuscated, obfuscatedWrapped, NetEntity.Invalid, null);

var ev = new RadioReceiveEvent(messageSource, channel, msg, notUdsMsg, language);
Expand Down Expand Up @@ -173,13 +173,14 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
_messages.Remove(message);
}

private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel, string name, string message)
private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel, string name, string message, LanguagePrototype language)
{
var speech = _chat.GetSpeechVerb(source, message);
return Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
("color", channel.Color),
("fontType", speech.FontId),
("fontSize", speech.FontSize),
("languageColor", language.Color ?? channel.Color),
("fontType", language.FontId ?? speech.FontId),
("fontSize", language.FontSize ?? speech.FontSize),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", name),
Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Language/LanguagePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ public sealed class LanguagePrototype : IPrototype
[IdDataField]
public string ID { get; private set; } = default!;

[DataField("color")]
public Color? Color;

[DataField("fontId")]
public string? FontId;

[DataField("fontSize")]
public int? FontSize;

/// <summary>
/// Obfuscation method used by this language. By default, uses <see cref="ObfuscationMethod.Default"/>
/// </summary>
Expand Down
Binary file added Resources/Fonts/Copperplate.otf
Binary file not shown.
Binary file added Resources/Fonts/Mangat.ttf
Binary file not shown.
Binary file added Resources/Fonts/Noganas.ttf
Binary file not shown.
Binary file added Resources/Fonts/RubikBubbles.ttf
Binary file not shown.
8 changes: 4 additions & 4 deletions Resources/Locale/en-US/chat/managers/chat-manager.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ chat-manager-whisper-headset-on-message = You can't whisper on the radio!
chat-manager-server-wrap-message = [bold]{$message}[/bold]
chat-manager-sender-announcement-wrap-message = [font size=14][bold]{$sender} Announcement:[/font][font size=12]
{$message}[/bold][/font]
chat-manager-entity-say-wrap-message = [BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent]{$message}[/BubbleContent]"[/font]
chat-manager-entity-say-bold-wrap-message = [BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] {$verb}, [font={$fontType} size={$fontSize}]"[BubbleContent][bold]{$message}[/bold][/BubbleContent]"[/font]
chat-manager-entity-say-wrap-message = [BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] {$verb}, [font="{$fontType}" size={$fontSize}]"[color={$color}][BubbleContent]{$message}[/BubbleContent][/color]"[/font]
chat-manager-entity-say-bold-wrap-message = [BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] {$verb}, [font="{$fontType}" size={$fontSize}]"[color={$color}][BubbleContent][bold]{$message}[/bold][/BubbleContent][/color]"[/font]

chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] whispers,"[BubbleContent]{$message}[/BubbleContent]"[/italic][/font]
chat-manager-entity-whisper-unknown-wrap-message = [font size=11][italic][BubbleHeader]Someone[/BubbleHeader] whispers, "[BubbleContent]{$message}[/BubbleContent]"[/italic][/font]
chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] whispers,"[color={$color}][BubbleContent]{$message}[/BubbleContent][/color]"[/italic][/font]
chat-manager-entity-whisper-unknown-wrap-message = [font size=11][italic][BubbleHeader]Someone[/BubbleHeader] whispers, "[color={$color}][BubbleContent]{$message}[/BubbleContent][/color]"[/italic][/font]

# THE() is not used here because the entity and its name can technically be disconnected if a nameOverride is passed...
chat-manager-entity-me-wrap-message = [italic]{ PROPER($entity) ->
Expand Down
4 changes: 2 additions & 2 deletions Resources/Locale/en-US/headset/headset-component.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chat window radio wrap (prefix and postfix)
chat-radio-message-wrap = [color={$color}]{$channel} {$name} {$verb}, [font={$fontType} size={$fontSize}]"{$message}"[/font][/color]
chat-radio-message-wrap-bold = [color={$color}]{$channel} {$name} {$verb}, [font={$fontType} size={$fontSize}][bold]"{$message}"[/bold][/font][/color]
chat-radio-message-wrap = [color={$color}]{$channel} {$name} {$verb}, [font="{$fontType}" size={$fontSize}]"[/color][color={$languageColor}]{$message}[/color][color={$color}]"[/font][/color]
chat-radio-message-wrap-bold = [color={$color}]{$channel} {$name} {$verb}, [font="{$fontType}" size={$fontSize}][bold]"[/color][color={$languageColor}]{$message}[/color][color={$color}]"[/bold][/font][/color]

examine-headset-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]).

Expand Down
13 changes: 12 additions & 1 deletion Resources/Prototypes/Language/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
# Spoken by slimes.
- type: language
id: Bubblish
color: "#0077aa"
fontId: RubikBubbles
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand All @@ -52,6 +54,8 @@
# Spoken by moths.
- type: language
id: Moffic
color: "#869b29"
fontId: Copperplate
obfuscation:
!type:SyllableObfuscation
minSyllables: 2 # Replacements are really short
Expand Down Expand Up @@ -118,6 +122,8 @@
# Spoken by dionas.
- type: language
id: RootSpeak
color: "#804000"
fontId: Noganas
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand All @@ -132,6 +138,8 @@
# A mess of broken Japanese, spoken by Felinds and Oni
- type: language
id: Nekomimetic
color: "#803B56"
fontId: Manga
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand Down Expand Up @@ -189,6 +197,7 @@
# Spoken by the Lizard race.
- type: language
id: Draconic
color: "#228b22"
obfuscation:
!type:SyllableObfuscation
minSyllables: 2
Expand Down Expand Up @@ -282,6 +291,7 @@
# Spoken by the Vulpkanin race.
- type: language
id: Canilunzt
color: "#b97a57"
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand Down Expand Up @@ -314,7 +324,6 @@
- vor
- nic
- gro
# - lll
- enem
- zandt
- tzch
Expand Down Expand Up @@ -349,6 +358,7 @@
# The common language of the Sol system.
- type: language
id: SolCommon
color: "#8282fb"
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand All @@ -374,6 +384,7 @@

- type: language
id: RobotTalk
fontId: Monospace
obfuscation:
!type:SyllableObfuscation
minSyllables: 1
Expand Down
16 changes: 16 additions & 0 deletions Resources/Prototypes/fonts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@
- type: font
id: Emoji
path: /Fonts/NotoEmoji.ttf

- type: font
id: RubikBubbles
path: /Fonts/RubikBubbles.ttf

- type: font
id: Copperplate
path: /Fonts/Copperplate.otf

- type: font
id: Manga
path: /Fonts/Mangat.ttf

- type: font
id: Noganas
path: /Fonts/Noganas.ttf
Loading