Skip to content

Commit

Permalink
[Port] Ru Keycodes / Русские Ключи Радиоканалов (#67)
Browse files Browse the repository at this point in the history
add: Ru keycodes
  • Loading branch information
Spatison authored Sep 23, 2024
1 parent 9b8123b commit 43f1564
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Client.Chat.Managers;
using Content.Client.Message;
using Content.Shared.Chat;
Expand Down Expand Up @@ -75,7 +76,7 @@ public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
case SharedChatSystem.CommonChannel:
_chatManager.SendMessage($"{SharedChatSystem.RadioCommonPrefix} {lawIdentifier}: {lawDescription}", ChatSelectChannel.Radio); break;
default:
_chatManager.SendMessage($"{SharedChatSystem.RadioChannelPrefix}{radioChannelProto.KeyCode} {lawIdentifier}: {lawDescription}", ChatSelectChannel.Radio); break;
_chatManager.SendMessage($"{SharedChatSystem.RadioChannelPrefix}{radioChannelProto.KeyCodes.First()} {lawIdentifier}: {lawDescription}", ChatSelectChannel.Radio); break;
}
};

Expand Down
17 changes: 13 additions & 4 deletions Content.Shared/Chat/SharedChatSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Frozen;
using System.Linq;
using Content.Shared.Popups;
using Content.Shared.Radio;
using Content.Shared.Speech;
Expand Down Expand Up @@ -39,7 +39,7 @@ public abstract class SharedChatSystem : EntitySystem
/// <summary>
/// Cache of the keycodes for faster lookup.
/// </summary>
private FrozenDictionary<char, RadioChannelPrototype> _keyCodes = default!;
private readonly Dictionary<char, RadioChannelPrototype> _keyCodes = new(); // WD EDIT

public override void Initialize()
{
Expand All @@ -57,8 +57,17 @@ protected virtual void OnPrototypeReload(PrototypesReloadedEventArgs obj)

private void CacheRadios()
{
_keyCodes = _prototypeManager.EnumeratePrototypes<RadioChannelPrototype>()
.ToFrozenDictionary(x => x.KeyCode);
// WD EDIT START
_keyCodes.Clear();

foreach (var proto in _prototypeManager.EnumeratePrototypes<RadioChannelPrototype>())
{
foreach (var keycode in proto.KeyCodes.Where(keycode => !_keyCodes.ContainsKey(keycode)))
{
_keyCodes.Add(keycode, proto);
}
}
// WD EDIT END
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void AddChannelsExamine(HashSet<string> channels, string? defaultChannel,

var key = id == SharedChatSystem.CommonChannel
? SharedChatSystem.RadioCommonPrefix.ToString()
: $"{SharedChatSystem.RadioChannelPrefix}{proto.KeyCode}";
: $":{string.Join(", :", proto.KeyCodes.ToArray())}"; // WD EDIT

examineEvent.PushMarkup(Loc.GetString(channelFTLPattern,
("color", proto.Color),
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Radio/RadioChannelPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public sealed partial class RadioChannelPrototype : IPrototype
/// <summary>
/// Single-character prefix to determine what channel a message should be sent to.
/// </summary>
[DataField("keycode")]
public char KeyCode { get; private set; } = '\0';
[DataField("keycodes")]
public List<char> KeyCodes { get; private set; } = new() {'\0'}; // WD EDIT

[DataField("frequency")]
public int Frequency { get; private set; } = 0;
Expand Down
8 changes: 6 additions & 2 deletions Resources/Prototypes/DeltaV/radio_channels.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
- type: radioChannel
id: Justice
name: chat-radio-justice
keycode: "j"
keycodes: # WD EDIT
- 'j'
- 'ю'
frequency: 1420
color: "#701442"

- type: radioChannel
id: Prison
name: chat-radio-prison
keycode: 'p'
keycodes: # WD EDIT
- 'p'
- 'з'
frequency: 1601
color: "#FFA500"

Expand Down
47 changes: 35 additions & 12 deletions Resources/Prototypes/radio_channels.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,90 @@
- type: radioChannel
id: Common
name: chat-radio-common
keycode: ";"
keycodes: # WD EDIT
- ";"
frequency: 1459
color: "#32cd32"

- type: radioChannel
id: CentCom
name: chat-radio-centcom
keycode: 'y'
keycodes: # WD EDIT
- 'y'
- 'ц'
frequency: 1337
color: "#2681a5"
longRange: true

- type: radioChannel
id: Command
name: chat-radio-command
keycode: 'c'
keycodes: # WD EDIT
- 'c'
- 'к'
frequency: 1353
color: "#fcdf03"

- type: radioChannel
id: Engineering
name: chat-radio-engineering
keycode: 'e'
keycodes: # WD EDIT
- 'e'
- 'и'
frequency: 1357
color: "#f37746"

- type: radioChannel
id: Medical
name: chat-radio-medical
keycode: 'm'
keycodes: # WD EDIT
- 'm'
- 'м'
frequency: 1355
color: "#57b8f0"

- type: radioChannel
id: Science
name: chat-radio-science
keycode: 'n'
keycodes: # WD EDIT
- 'n'
- 'н'
frequency: 1351
color: "#c68cfa"

- type: radioChannel
id: Security
name: chat-radio-security
keycode: 's'
keycodes: # WD EDIT
- 's'
- 'о'
frequency: 1359
color: "#dd3535"

- type: radioChannel
id: Service
name: chat-radio-service
keycode: 'v'
keycodes: # WD EDIT
- 'v'
- 'в'
frequency: 1349
color: "#6ca729"

- type: radioChannel
id: Supply
name: chat-radio-supply
keycode: 'u'
keycodes:
- 'u' # WD EDIT
- 'с'
frequency: 1347
color: "#b88646"

- type: radioChannel
id: Syndicate
name: chat-radio-syndicate
keycode: 't'
keycodes: # WD EDIT
- 't'
- 'т'
frequency: 1213
color: "#8f4a4b"
longRange: true
Expand All @@ -81,7 +100,9 @@
- type: radioChannel
id: Binary
name: chat-radio-binary
keycode: 'b'
keycodes: # WD EDIT
- 'b'
- 'б'
frequency: 1001
color: "#2ed2fd"
# long range since otherwise it'd defeat the point of a handheld radio independent of telecomms
Expand All @@ -90,7 +111,9 @@
- type: radioChannel
id: Freelance
name: chat-radio-freelance
keycode: 'f'
keycodes: # WD EDIT
- 'f'
- 'ф'
frequency: 1984
color: "#f6ce64"
# long range since otherwise it'd defeat the point of a handheld radio independent of telecomms
Expand Down

0 comments on commit 43f1564

Please sign in to comment.