From 4e1067d91213c8e13d652e64b42db9363bae69b3 Mon Sep 17 00:00:00 2001 From: chavonadelal Date: Sat, 21 Sep 2024 00:30:47 +0300 Subject: [PATCH] Job title localization --- Content.Server/Access/Systems/AgentIDCardSystem.cs | 2 +- Content.Server/Access/Systems/IdCardConsoleSystem.cs | 2 +- Content.Server/IdentityManagement/IdentitySystem.cs | 2 +- Content.Server/Medical/SuitSensors/SuitSensorSystem.cs | 4 ++-- Content.Server/PDA/PdaSystem.cs | 2 +- Content.Shared/Access/Components/IdCardComponent.cs | 5 ++++- Content.Shared/Access/Systems/IdExaminableSystem.cs | 2 +- Content.Shared/Access/Systems/SharedIdCardSystem.cs | 9 +++++---- Resources/Locale/en-US/job/job-names.ftl | 5 +++++ .../Entities/Objects/Misc/identification_cards.yml | 6 +++--- 10 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 8f1d0d4f820a2c..a98cda0725aa1f 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -67,7 +67,7 @@ private void AfterUIOpen(EntityUid uid, AgentIDCardComponent component, AfterAct if (!TryComp(uid, out var idCard)) return; - var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", idCard.JobIcon); + var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.LocalizedJobTitle ?? "", idCard.JobIcon); _uiSystem.SetUiState(uid, AgentIDCardUiKey.Key, state); } diff --git a/Content.Server/Access/Systems/IdCardConsoleSystem.cs b/Content.Server/Access/Systems/IdCardConsoleSystem.cs index e02664f2bbdfb9..a9e5d9a6d3ef2c 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -96,7 +96,7 @@ private void UpdateUserInterface(EntityUid uid, IdCardConsoleComponent component PrivilegedIdIsAuthorized(uid, component), true, targetIdComponent.FullName, - targetIdComponent.JobTitle, + targetIdComponent.LocalizedJobTitle, targetAccessComponent.Tags.ToList(), possibleAccess, jobProto, diff --git a/Content.Server/IdentityManagement/IdentitySystem.cs b/Content.Server/IdentityManagement/IdentitySystem.cs index e110a42483456a..ff6901f5a92e10 100644 --- a/Content.Server/IdentityManagement/IdentitySystem.cs +++ b/Content.Server/IdentityManagement/IdentitySystem.cs @@ -166,7 +166,7 @@ private IdentityRepresentation GetIdentityRepresentation(EntityUid target, if (_idCard.TryFindIdCard(target, out var id)) { presumedName = string.IsNullOrWhiteSpace(id.Comp.FullName) ? null : id.Comp.FullName; - presumedJob = id.Comp.JobTitle?.ToLowerInvariant(); + presumedJob = id.Comp.LocalizedJobTitle?.ToLowerInvariant(); } // If it didn't find a job, that's fine. diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs index b1b87ae981d561..f56b16432e1723 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs @@ -363,8 +363,8 @@ public void SetSensor(Entity sensors, SuitSensorMode mode, { if (card.Comp.FullName != null) userName = card.Comp.FullName; - if (card.Comp.JobTitle != null) - userJob = card.Comp.JobTitle; + if (card.Comp.LocalizedJobTitle != null) + userJob = card.Comp.LocalizedJobTitle; userJobIcon = card.Comp.JobIcon; foreach (var department in card.Comp.JobDepartments) diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index cdcdbc02e5fb28..7f17b97d0adc73 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -192,7 +192,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null) { ActualOwnerName = pda.OwnerName, IdOwner = id?.FullName, - JobTitle = id?.JobTitle, + JobTitle = id?.LocalizedJobTitle, StationAlertLevel = pda.StationAlertLevel, StationAlertColor = pda.StationAlertColor }, diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index ccd4cccbe7b5a5..e4642ab6bbd4f3 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -20,7 +20,10 @@ public sealed partial class IdCardComponent : Component [DataField] [AutoNetworkedField] [Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)] - public string? JobTitle; + public LocId? JobTitle; + + [Access(typeof(SharedIdCardSystem), typeof(SharedPdaSystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWriteExecute)] + public string? LocalizedJobTitle = Loc.GetString(JobTitle); //FIXME /// /// The state of the job icon rsi. diff --git a/Content.Shared/Access/Systems/IdExaminableSystem.cs b/Content.Shared/Access/Systems/IdExaminableSystem.cs index 13359adcba2dd7..807ccc6616d4aa 100644 --- a/Content.Shared/Access/Systems/IdExaminableSystem.cs +++ b/Content.Shared/Access/Systems/IdExaminableSystem.cs @@ -67,7 +67,7 @@ public string GetMessage(EntityUid uid) private string GetNameAndJob(IdCardComponent id) { - var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})"; + var jobSuffix = string.IsNullOrWhiteSpace(id.LocalizedJobTitle) ? string.Empty : $" ({id.LocalizedJobTitle})"; var val = string.IsNullOrWhiteSpace(id.FullName) ? Loc.GetString(id.NameLocId, diff --git a/Content.Shared/Access/Systems/SharedIdCardSystem.cs b/Content.Shared/Access/Systems/SharedIdCardSystem.cs index 8bdc548e353a88..a5a37eecbd07ea 100644 --- a/Content.Shared/Access/Systems/SharedIdCardSystem.cs +++ b/Content.Shared/Access/Systems/SharedIdCardSystem.cs @@ -116,6 +116,7 @@ public bool TryGetIdCard(EntityUid uid, out Entity idCard) /// /// /// If provided with a player's EntityUid to the player parameter, adds the change to the admin logs. + /// Actually works with the LocalizedJobTitle DataField and not with JobTitle. /// public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? id = null, EntityUid? player = null) { @@ -134,9 +135,9 @@ public bool TryChangeJobTitle(EntityUid uid, string? jobTitle, IdCardComponent? jobTitle = null; } - if (id.JobTitle == jobTitle) + if (id.LocalizedJobTitle == jobTitle) return true; - id.JobTitle = jobTitle; + id.LocalizedJobTitle = jobTitle; Dirty(uid, id); UpdateEntityName(uid, id); @@ -238,7 +239,7 @@ private void UpdateEntityName(EntityUid uid, IdCardComponent? id = null) if (!Resolve(uid, ref id)) return; - var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})"; + var jobSuffix = string.IsNullOrWhiteSpace(id.LocalizedJobTitle) ? string.Empty : $" ({id.LocalizedJobTitle})"; var val = string.IsNullOrWhiteSpace(id.FullName) ? Loc.GetString(id.NameLocId, @@ -251,7 +252,7 @@ private void UpdateEntityName(EntityUid uid, IdCardComponent? id = null) private static string ExtractFullTitle(IdCardComponent idCardComponent) { - return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.JobTitle ?? string.Empty)})" + return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.LocalizedJobTitle ?? string.Empty)})" .Trim(); } } diff --git a/Resources/Locale/en-US/job/job-names.ftl b/Resources/Locale/en-US/job/job-names.ftl index 0140adf8a2d711..de63e09d8e7746 100644 --- a/Resources/Locale/en-US/job/job-names.ftl +++ b/Resources/Locale/en-US/job/job-names.ftl @@ -62,6 +62,11 @@ job-name-unknown = Unknown job-name-virologist = Virologist job-name-zombie = Zombie +#Job titles +job-title-visitor = Visitor +job-title-cluwne = Cluwne +job-title-universal = Universal + # Role timers - Make these alphabetical or I cut you JobAtmosphericTechnician = Atmospheric Technician JobBartender = Bartender diff --git a/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml b/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml index a08afa127e05e4..ccb83b6aaa373c 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml @@ -443,7 +443,7 @@ - state: default - state: idvisitor - type: IdCard - jobTitle: Visitor + jobTitle: job-title-visitor jobIcon: JobIconVisitor - type: PresetIdCard job: Visitor @@ -741,7 +741,7 @@ - state: default - state: idcluwne - type: IdCard - jobTitle: Cluwne + jobTitle: job-title-cluwne - type: Unremoveable - type: entity @@ -801,7 +801,7 @@ - type: Item heldPrefix: green - type: IdCard - jobTitle: Universal + jobTitle: job-title-universal jobIcon: JobIconAdmin - type: Access groups: