From 5edcd779e6fab6567005be157cf44e2a76e3b9d3 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Wed, 17 Jul 2024 08:47:50 +0300 Subject: [PATCH] Character menu issuer localization (#29840) * Update CharacterUIController.cs * TODO Burn this shit * huh? * huh! --------- Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> --- .../Systems/Character/CharacterUIController.cs | 16 ++++++++++++---- .../CharacterInfo/CharacterInfoSystem.cs | 2 +- Content.Server/Objectives/ObjectivesSystem.cs | 4 ++-- .../Objectives/Components/ObjectiveComponent.cs | 7 +++++-- Resources/Prototypes/Objectives/dragon.yml | 2 +- Resources/Prototypes/Objectives/ninja.yml | 2 +- Resources/Prototypes/Objectives/thief.yml | 2 +- Resources/Prototypes/Objectives/traitor.yml | 2 +- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs index 88edb6a4f12e..1e4d2f276579 100644 --- a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs +++ b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs @@ -1,11 +1,13 @@ using System.Linq; using Content.Client.CharacterInfo; using Content.Client.Gameplay; +using Content.Client.Stylesheets; using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Systems.Character.Controls; using Content.Client.UserInterface.Systems.Character.Windows; using Content.Client.UserInterface.Systems.Objectives.Controls; using Content.Shared.Input; +using Content.Shared.Objectives.Systems; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Client.Player; @@ -121,11 +123,17 @@ private void CharacterUpdated(CharacterData data) Modulate = Color.Gray }; - objectiveControl.AddChild(new Label + + var objectiveText = new FormattedMessage(); + objectiveText.TryAddMarkup(groupId, out _); + + var objectiveLabel = new RichTextLabel { - Text = groupId, - Modulate = Color.LightSkyBlue - }); + StyleClasses = {StyleNano.StyleClassTooltipActionTitle} + }; + objectiveLabel.SetMessage(objectiveText); + + objectiveControl.AddChild(objectiveLabel); foreach (var condition in conditions) { diff --git a/Content.Server/CharacterInfo/CharacterInfoSystem.cs b/Content.Server/CharacterInfo/CharacterInfoSystem.cs index cb2216b5e3b4..3099b2f90fc9 100644 --- a/Content.Server/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Server/CharacterInfo/CharacterInfoSystem.cs @@ -43,7 +43,7 @@ private void OnRequestCharacterInfoEvent(RequestCharacterInfoEvent msg, EntitySe continue; // group objectives by their issuer - var issuer = Comp(objective).Issuer; + var issuer = Comp(objective).LocIssuer; if (!objectives.ContainsKey(issuer)) objectives[issuer] = new List(); objectives[issuer].Add(info.Value); diff --git a/Content.Server/Objectives/ObjectivesSystem.cs b/Content.Server/Objectives/ObjectivesSystem.cs index c9cdf244e660..382cb1ab4419 100644 --- a/Content.Server/Objectives/ObjectivesSystem.cs +++ b/Content.Server/Objectives/ObjectivesSystem.cs @@ -129,12 +129,12 @@ private void AddSummary(StringBuilder result, string agent, List<(EntityUid, str var agentSummary = new StringBuilder(); agentSummary.AppendLine(Loc.GetString("objectives-with-objectives", ("custody", custody), ("title", title), ("agent", agent))); - foreach (var objectiveGroup in objectives.GroupBy(o => Comp(o).Issuer)) + foreach (var objectiveGroup in objectives.GroupBy(o => Comp(o).LocIssuer)) { //TO DO: //check for the right group here. Getting the target issuer is easy: objectiveGroup.Key //It should be compared to the type of the group's issuer. - agentSummary.AppendLine(Loc.GetString($"objective-issuer-{objectiveGroup.Key}")); + agentSummary.AppendLine(objectiveGroup.Key); foreach (var objective in objectiveGroup) { diff --git a/Content.Shared/Objectives/Components/ObjectiveComponent.cs b/Content.Shared/Objectives/Components/ObjectiveComponent.cs index 36d3fa0bded7..fb2e6ca0a686 100644 --- a/Content.Shared/Objectives/Components/ObjectiveComponent.cs +++ b/Content.Shared/Objectives/Components/ObjectiveComponent.cs @@ -22,8 +22,11 @@ public sealed partial class ObjectiveComponent : Component /// /// Organisation that issued this objective, used for grouping and as a header above common objectives. /// - [DataField(required: true)] - public string Issuer = string.Empty; + [DataField("issuer", required: true)] + private LocId Issuer { get; set; } + + [ViewVariables(VVAccess.ReadOnly)] + public string LocIssuer => Loc.GetString(Issuer); /// /// Unique objectives can only have 1 per prototype id. diff --git a/Resources/Prototypes/Objectives/dragon.yml b/Resources/Prototypes/Objectives/dragon.yml index 10ca942cb39a..bbdac8faa1a9 100644 --- a/Resources/Prototypes/Objectives/dragon.yml +++ b/Resources/Prototypes/Objectives/dragon.yml @@ -6,7 +6,7 @@ - type: Objective # difficulty isn't used at all since objective are fixed difficulty: 1.5 - issuer: dragon + issuer: objective-issuer-dragon - type: RoleRequirement roles: components: diff --git a/Resources/Prototypes/Objectives/ninja.yml b/Resources/Prototypes/Objectives/ninja.yml index 77628a68cf12..4d0cf6c17c83 100644 --- a/Resources/Prototypes/Objectives/ninja.yml +++ b/Resources/Prototypes/Objectives/ninja.yml @@ -6,7 +6,7 @@ - type: Objective # difficulty isn't used since all objectives are picked difficulty: 1.5 - issuer: spiderclan + issuer: objective-issuer-spiderclan - type: RoleRequirement roles: components: diff --git a/Resources/Prototypes/Objectives/thief.yml b/Resources/Prototypes/Objectives/thief.yml index 8b5307e9a093..cc94ab02b34f 100644 --- a/Resources/Prototypes/Objectives/thief.yml +++ b/Resources/Prototypes/Objectives/thief.yml @@ -4,7 +4,7 @@ id: BaseThiefObjective components: - type: Objective - issuer: thief + issuer: objective-issuer-thief - type: RoleRequirement roles: components: diff --git a/Resources/Prototypes/Objectives/traitor.yml b/Resources/Prototypes/Objectives/traitor.yml index ad5f56a443ea..edf191b420dd 100644 --- a/Resources/Prototypes/Objectives/traitor.yml +++ b/Resources/Prototypes/Objectives/traitor.yml @@ -4,7 +4,7 @@ id: BaseTraitorObjective components: - type: Objective - issuer: syndicate + issuer: objective-issuer-syndicate - type: RoleRequirement roles: components: