Skip to content

Commit

Permalink
Show Language Names In Chat (#1165)
Browse files Browse the repository at this point in the history
# Description

Port of Lost-Paradise-Project/Lost-Paradise#288
from Lost Paradise. This feature makes it so that the language you are
speaking is shown in chat, preventing any confusion for players about
what it is being spoken.

<details><summary><h1>Media</h1></summary>
<p>


![image](https://github.com/user-attachments/assets/25fa3e17-30bb-4ae7-8fbe-2114839c498d)

</p>
</details>

# Changelog

:cl:
- add: Languages are now shown in chat alongside character names.

---------

Signed-off-by: VMSolidus <[email protected]>
Co-authored-by: Remuchi <[email protected]>
  • Loading branch information
VMSolidus and Remuchi authored Nov 8, 2024
1 parent 9e85b73 commit 3209838
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 18 deletions.
6 changes: 5 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,18 @@ public string WrapMessage(LocId wrapId, InGameICChatType chatType, EntityUid sou
var color = DefaultSpeakColor;
if (language.SpeechOverride.Color is { } colorOverride)
color = Color.InterpolateBetween(color, colorOverride, colorOverride.A);
var languageDisplay = language.IsVisibleLanguage
? $"{language.ChatName} | "
: "";

return Loc.GetString(wrapId,
("color", color),
("entityName", entityName),
("verb", Loc.GetString(verbId)),
("fontType", language.SpeechOverride.FontId ?? speech.FontId),
("fontSize", language.SpeechOverride.FontSize ?? speech.FontSize),
("message", message));
("message", message),
("language", languageDisplay));
}

/// <summary>
Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel,
var languageColor = channel.Color;
if (language.SpeechOverride.Color is { } colorOverride)
languageColor = Color.InterpolateBetween(languageColor, colorOverride, colorOverride.A);
var languageDisplay = language.IsVisibleLanguage
? $"{language.ChatName} | "
: "";

return Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
("color", channel.Color),
Expand All @@ -175,7 +178,8 @@ private string WrapRadioMessage(EntityUid source, RadioChannelPrototype channel,
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", name),
("message", message));
("message", message),
("language", languageDisplay));
}

/// <inheritdoc cref="TelecomServerComponent"/>
Expand Down
13 changes: 12 additions & 1 deletion Content.Shared/Language/LanguagePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ namespace Content.Shared.Language;
public sealed partial class LanguagePrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
public string ID { get; private set; } = default!;

/// <summary>
/// Whether this language will display its name in chat behind a player's name.
/// </summary>
[DataField]
public bool IsVisibleLanguage { get; set; }

/// <summary>
/// Obfuscation method used by this language. By default, uses <see cref="ObfuscationMethod.Default"/>
Expand All @@ -27,6 +33,11 @@ public sealed partial class LanguagePrototype : IPrototype
/// </summary>
public string Name => Loc.GetString($"language-{ID}-name");

/// <summary>
/// The in-world chat abbreviation of this language, localized.
/// </summary>
public string ChatName => Loc.GetString($"chat-language-{ID}-name");

/// <summary>
/// The in-world description of this language, localized.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions Resources/Locale/en-US/chat/managers/chat-language.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
chat-language-Universal-name = Universal
chat-language-Bubblish-name = Bubblish
chat-language-RootSpeak-name = Rootspeak
chat-language-Nekomimetic-name = Neko
chat-language-Draconic-name = Sinta'Unathi
chat-language-Azaziba-name = Sinta'Azaziba
chat-language-SolCommon-name = Sol Common
chat-language-TauCetiBasic-name = Basic
chat-language-Tradeband-name = Tradeband
chat-language-Freespeak-name = Freespeak
chat-language-Elyran-name = Elyran
chat-language-Canilunzt-name = Canilunzt
chat-language-Moffic-name = Moffic
chat-language-RobotTalk-name = Binary
chat-language-ValyrianStandard-name = Valyrian
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,10 +21,10 @@ 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}, "[BubbleContent][font="{$fontType}" size={$fontSize}][color={$color}]{$message}[/color][/font][/BubbleContent]"
chat-manager-entity-say-bold-wrap-message = [BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] {$verb}, "[BubbleContent][font="{$fontType}" size={$fontSize}][color={$color}][bold]{$message}[/bold][/color][/font][/BubbleContent]"
chat-manager-entity-say-wrap-message = [BubbleHeader][bold][Name]{ $language }{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize } ]"[BubbleContent]{ $message }[/BubbleContent]"[/font]
chat-manager-entity-say-bold-wrap-message = [BubbleHeader][bold][Name]{ $language }{ $entityName }[/Name][/bold][/BubbleHeader] { $verb }, [font={ $fontType } size={ $fontSize }]"[BubbleContent][bold]{ $message }[/bold][/BubbleContent]"[/font]
chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{$entityName}[/Name][/BubbleHeader] whispers, "[BubbleContent][font="{$fontType}"][color={$color}]{$message}[/color][/font][/BubbleContent]"[/italic][/font]
chat-manager-entity-whisper-wrap-message = [font size=11][italic][BubbleHeader][Name]{ $language }{ $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][font="{$fontType}"][color={$color}]{$message}[/color][/font][/BubbleContent]"[/italic][/font]
# THE() is not used here because the entity and its name can technically be disconnected if a nameOverride is passed...
Expand Down Expand Up @@ -159,4 +159,4 @@ chat-speech-verb-electricity-1 = crackles
chat-speech-verb-electricity-2 = buzzes
chat-speech-verb-electricity-3 = screeches
chat-speech-verb-marish = Mars
chat-speech-verb-marish = Mars
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}]"[/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]
chat-radio-message-wrap = [color={ $color }]{ $channel } [bold]{ $language }{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }]"{ $message }"[/font][/color]
chat-radio-message-wrap-bold = [color={ $color }]{ $channel } [bold]{ $language }{ $name }[/bold] { $verb }, [font={ $fontType } size={ $fontSize }][bold]"{ $message }"[/bold][/font][/color]
examine-headset-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]).
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Species-Specific/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Replace this with a much better language.
- type: language
id: RootSpeak
isVisibleLanguage: true
speech:
color: "#ce5e14dd"
fontId: Noganas
Expand All @@ -14,4 +15,4 @@
- zt
- kr
- st
- sh
- sh
1 change: 1 addition & 0 deletions Resources/Prototypes/Language/Species-Specific/harpy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: language
id: ValyrianStandard
isVisibleLanguage: true
speech:
fontId: Cambria
color: "#008ecc"
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Species-Specific/marish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Spoken by shadowkins.
- type: language
id: Marish
isVisibleLanguage: true
speech:
color: "#be3cc5"
fontId: Lymphatic
Expand All @@ -17,4 +18,4 @@
- maaAr
- aarrr
- wrurrl
- mmar
- mmar
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Species-Specific/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Replace this with a much better language.
- type: language
id: Moffic
isVisibleLanguage: true
speech:
color: "#c7df2edd"
fontId: Copperplate
Expand Down Expand Up @@ -66,4 +67,4 @@
- uhr
- kön
- we
- hön
- hön
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Replace this with a much better language.
- type: language
id: Nekomimetic
isVisibleLanguage: true
speech:
color: "#df57aaee"
fontId: Manga
Expand Down Expand Up @@ -57,4 +58,4 @@
- puru
- ira
- heto
- etto
- etto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Spoken by Unathi.
- type: language
id: Draconic
isVisibleLanguage: true
speech:
color: "#2aca2add"
obfuscation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Replace this with a much better language.
- type: language
id: Bubblish
isVisibleLanguage: true
speech:
color: "#00a3e2dd"
fontId: RubikBubbles
Expand All @@ -14,4 +15,4 @@
- plop
- pop
- bop
- boop
- boop
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Species-Specific/vulpkanin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Replace this with a much better language.
- type: language
id: Canilunzt
isVisibleLanguage: true
speech:
color: "#d69b3dcc"
obfuscation:
Expand Down Expand Up @@ -65,4 +66,4 @@
- einech
- cresthz
- azunein
- ghzth
- ghzth
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Standard/elyran.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: language
id: Elyran
isVisibleLanguage: true
speech:
color: "#8282fbaa"
obfuscation:
Expand Down Expand Up @@ -83,4 +84,4 @@
- an'
- e'
- a'
- em'
- em'
1 change: 1 addition & 0 deletions Resources/Prototypes/Language/Standard/freespeak.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: language
id: Freespeak
isVisibleLanguage: true
speech:
color: "#597d35"
obfuscation:
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/Language/Standard/solcommon.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: language
id: SolCommon
isVisibleLanguage: true
speech:
color: "#8282fbaa"
obfuscation:
Expand Down Expand Up @@ -255,4 +256,4 @@
- zo
- zu
- zun
- zuo
- zuo
2 changes: 1 addition & 1 deletion Resources/Prototypes/Language/Standard/taucetibasic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@
- zem
- zo
- zoj
- zon
- zon
1 change: 1 addition & 0 deletions Resources/Prototypes/Language/Standard/tradeband.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- type: language
id: Tradeband
isVisibleLanguage: true
speech:
color: "#597d35"
obfuscation:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Language/genericlanguages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# TODO: Replace this with much better languages. Yes, robots can have languages.
- type: language
id: RobotTalk
isVisibleLanguage: true
speech:
fontId: Monospace
obfuscation:
Expand Down

0 comments on commit 3209838

Please sign in to comment.