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

Replace string data fields with LocId where relevant #20883

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,52 +1,45 @@
using System;
using Content.Shared.Chemistry;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;

namespace Content.Client.Chemistry.Visualizers
{
[RegisterComponent]
public sealed partial class SolutionContainerVisualsComponent : Component
{
[DataField("maxFillLevels")]
[DataField]
public int MaxFillLevels = 0;
[DataField("fillBaseName")]
[DataField]
public string? FillBaseName = null;
[DataField("layer")]
public SolutionContainerLayers FillLayer = SolutionContainerLayers.Fill;
[DataField("baseLayer")]
[DataField]
public SolutionContainerLayers Layer = SolutionContainerLayers.Fill;
[DataField]
public SolutionContainerLayers BaseLayer = SolutionContainerLayers.Base;
[DataField("overlayLayer")]
[DataField]
public SolutionContainerLayers OverlayLayer = SolutionContainerLayers.Overlay;
[DataField("changeColor")]
[DataField]
public bool ChangeColor = true;
[DataField("emptySpriteName")]
[DataField]
public string? EmptySpriteName = null;
[DataField("emptySpriteColor")]
[DataField]
public Color EmptySpriteColor = Color.White;
[DataField("metamorphic")]
[DataField]
public bool Metamorphic = false;
[DataField("metamorphicDefaultSprite")]
[DataField]
public SpriteSpecifier? MetamorphicDefaultSprite;
[DataField("metamorphicNameFull")]
public string MetamorphicNameFull = "transformable-container-component-glass";
[DataField]
public LocId MetamorphicNameFull = "transformable-container-component-glass";

/// <summary>
/// Which solution of the SolutionContainerManagerComponent to represent.
/// If not set, will work as default.
/// </summary>
[DataField("solutionName")]
[DataField]
public string? SolutionName;

[DataField("initialName")]
[DataField]
public string InitialName = string.Empty;

[DataField("initialDescription")]
[DataField]
public string InitialDescription = string.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override void OnAppearanceChange(EntityUid uid, SolutionContainerVisua
if (args.Sprite == null)
return;

if (!args.Sprite.LayerMapTryGet(component.FillLayer, out var fillLayer))
if (!args.Sprite.LayerMapTryGet(component.Layer, out var fillLayer))
return;

// Currently some solution methods such as overflowing will try to update appearance with a
Expand Down
15 changes: 7 additions & 8 deletions Content.IntegrationTests/Tests/VendingMachineRestockTest.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#nullable enable
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Content.Server.Storage.Components;
using Content.Server.VendingMachines;
using Content.Server.Wires;
using Content.Shared.Cargo.Prototypes;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.VendingMachines;
using Content.Shared.Wires;
using Content.Server.Wires;
using Content.Shared.Prototypes;
using Content.Shared.Storage.Components;
using Content.Shared.VendingMachines;
using Content.Shared.Wires;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests
{
Expand Down Expand Up @@ -96,7 +95,7 @@ public sealed class VendingMachineRestockTest : EntitySystem
name: Test Ramen
components:
- type: Wires
LayoutId: Vending
layoutId: Vending
- type: VendingMachine
pack: TestInventory
- type: Sprite
Expand Down
12 changes: 6 additions & 6 deletions Content.Server/Chemistry/Components/SolutionSpikerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ public sealed partial class SolutionSpikerComponent : Component
/// The source solution to take the reagents from in order
/// to spike the other solution container.
/// </summary>
[DataField("sourceSolution")]
[DataField]
public string SourceSolution { get; private set; } = string.Empty;

/// <summary>
/// If spiking with this entity should ignore empty containers or not.
/// </summary>
[DataField("ignoreEmpty")]
[DataField]
public bool IgnoreEmpty { get; private set; }

/// <summary>
/// What should pop up when spiking with this entity.
/// </summary>
[DataField("popup")]
public string Popup { get; private set; } = "spike-solution-generic";
[DataField]
public LocId Popup { get; private set; } = "spike-solution-generic";

/// <summary>
/// What should pop up when spiking fails because the container was empty.
/// </summary>
[DataField("popupEmpty")]
public string PopupEmpty { get; private set; } = "spike-solution-empty-generic";
[DataField]
public LocId PopupEmpty { get; private set; } = "spike-solution-empty-generic";
}
25 changes: 12 additions & 13 deletions Content.Server/Communications/CommunicationsConsoleComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Server.UserInterface;
using Content.Shared.Communications;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;

namespace Content.Server.Communications
Expand All @@ -21,41 +20,41 @@ public sealed partial class CommunicationsConsoleComponent : SharedCommunication
/// If a Fluent ID isn't found, just uses the raw string
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("title", required: true)]
public string AnnouncementDisplayName = "comms-console-announcement-title-station";
[DataField(required: true)]
public LocId Title = "comms-console-announcement-title-station";

/// <summary>
/// Announcement color
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("color")]
public Color AnnouncementColor = Color.Gold;
[DataField]
public Color Color = Color.Gold;

/// <summary>
/// Time in seconds between announcement delays on a per-console basis
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("delay")]
public int DelayBetweenAnnouncements = 90;
[DataField]
public int Delay = 90;

/// <summary>
/// Can call or recall the shuttle
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canShuttle")]
public bool CanCallShuttle = true;
[DataField]
public bool CanShuttle = true;

/// <summary>
/// Announce on all grids (for nukies)
/// </summary>
[DataField("global")]
public bool AnnounceGlobal = false;
[DataField]
public bool Global = false;

/// <summary>
/// Announce sound file path
/// </summary>
[DataField("sound")]
public SoundSpecifier AnnouncementSound = new SoundPathSpecifier("/Audio/Announcements/announce.ogg");
[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Announcements/announce.ogg");

public PlayerBoundUserInterface? UserInterface => Owner.GetUIOrNull(CommunicationsConsoleUiKey.Key);
}
Expand Down
14 changes: 7 additions & 7 deletions Content.Server/Communications/CommunicationsConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private bool CanCallOrRecall(CommunicationsConsoleComponent comp)

// Calling shuttle checks
if (_roundEndSystem.ExpectedCountdownEnd is null)
return comp.CanCallShuttle;
return comp.CanShuttle;

// Recalling shuttle checks
var recallThreshold = _cfg.GetCVar(CCVars.EmergencyRecallTurningPoint);
Expand Down Expand Up @@ -256,27 +256,27 @@ private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent com
}
}

comp.AnnouncementCooldownRemaining = comp.DelayBetweenAnnouncements;
comp.AnnouncementCooldownRemaining = comp.Delay;
UpdateCommsConsoleInterface(uid, comp);

var ev = new CommunicationConsoleAnnouncementEvent(uid, comp, msg, message.Session.AttachedEntity);
RaiseLocalEvent(ref ev);

// allow admemes with vv
Loc.TryGetString(comp.AnnouncementDisplayName, out var title);
title ??= comp.AnnouncementDisplayName;
Loc.TryGetString(comp.Title, out var title);
title ??= comp.Title;

msg += "\n" + Loc.GetString("comms-console-announcement-sent-by") + " " + author;
if (comp.AnnounceGlobal)
if (comp.Global)
{
_chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.AnnouncementSound, colorOverride: comp.AnnouncementColor);
_chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.Sound, colorOverride: comp.Color);

if (message.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following global announcement: {msg}");

return;
}
_chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.AnnouncementColor);
_chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.Color);

if (message.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following station announcement: {msg}");
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Forensics/Components/FiberComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace Content.Server.Forensics
[RegisterComponent]
public sealed partial class FiberComponent : Component
{
[DataField("fiberMaterial")]
public string FiberMaterial = "fibers-synthetic";
[DataField]
public LocId FiberMaterial = "fibers-synthetic";

[DataField("fiberColor")]
[DataField]
public string? FiberColor;
}
}
4 changes: 2 additions & 2 deletions Content.Server/Nuke/NukeLabelComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ namespace Content.Server.Nuke;
[RegisterComponent]
public sealed partial class NukeLabelComponent : Component
{
[DataField("prefix")] public string NukeLabel = "nuke-label-nanotrasen";
[DataField("serialLength")] public int SerialLength = 6;
[DataField] public LocId Prefix = "nuke-label-nanotrasen";
[DataField] public int SerialLength = 6;
}
2 changes: 1 addition & 1 deletion Content.Server/Nuke/NukeLabelSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override void Initialize()

private void OnMapInit(EntityUid uid, NukeLabelComponent nuke, MapInitEvent args)
{
var label = Loc.GetString(nuke.NukeLabel, ("serial", _nuke.GenerateRandomNumberString(nuke.SerialLength)));
var label = Loc.GetString(nuke.Prefix, ("serial", _nuke.GenerateRandomNumberString(nuke.SerialLength)));
var meta = MetaData(uid);
_metaData.SetEntityName(uid, $"{meta.EntityName} ({label})", meta);
}
Expand Down
18 changes: 9 additions & 9 deletions Content.Server/NukeOps/WarDeclaratorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ public sealed partial class WarDeclaratorComponent : Component
/// Custom war declaration message. If empty, use default.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("message")]
[DataField]
public string Message;

/// <summary>
/// Permission to customize message text
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("allowEditingMessage")]
[DataField]
public bool AllowEditingMessage = true;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("maxMessageLength")]
[DataField]
public int MaxMessageLength = 512;

/// <summary>
/// War declarement text color
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("color")]
public Color DeclarementColor = Color.Red;
[DataField]
public Color Color = Color.Red;

/// <summary>
/// War declarement sound file path
/// </summary>
[DataField("sound")]
public SoundSpecifier DeclarementSound = new SoundPathSpecifier("/Audio/Announcements/war.ogg");
[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Announcements/war.ogg");

/// <summary>
/// Fluent ID for the declarement title
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("title")]
public string DeclarementTitle = "comms-console-announcement-title-nukie";
[DataField]
public LocId Title = "comms-console-announcement-title-nukie";
}
4 changes: 2 additions & 2 deletions Content.Server/NukeOps/WarDeclaratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ private void OnActivated(EntityUid uid, WarDeclaratorComponent component, WarDec
{
message = Loc.GetString("war-declarator-default-message");
}
var title = Loc.GetString(component.DeclarementTitle);
var title = Loc.GetString(component.Title);

_nukeopsRuleSystem.DeclareWar(args.Session.AttachedEntity.Value, message, title, component.DeclarementSound, component.DeclarementColor);
_nukeopsRuleSystem.DeclareWar(args.Session.AttachedEntity.Value, message, title, component.Sound, component.Color);

if (args.Session.AttachedEntity != null)
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(args.Session.AttachedEntity.Value):player} has declared war with this text: {message}");
Expand Down
8 changes: 3 additions & 5 deletions Content.Server/Nutrition/Components/FoodComponent.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Content.Server.Body.Components;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.FixedPoint;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Nutrition.Components;

Expand All @@ -17,8 +15,8 @@ public sealed partial class FoodComponent : Component
[DataField]
public SoundSpecifier UseSound = new SoundPathSpecifier("/Audio/Items/eatfood.ogg");

[DataField("trash")]
public EntProtoId? TrashPrototype;
[DataField]
public EntProtoId? Trash;

[DataField]
public FixedPoint2? TransferAmount = FixedPoint2.New(5);
Expand Down Expand Up @@ -55,7 +53,7 @@ public sealed partial class FoodComponent : Component
/// The localization identifier for the eat message. Needs a "food" entity argument passed to it.
/// </summary>
[DataField]
public string EatMessage = "food-nom";
public LocId EatMessage = "food-nom";

/// <summary>
/// How long it takes to eat the food personally.
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Nutrition/Components/OpenableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public sealed partial class OpenableComponent : Component
/// Text shown when examining and its open.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string ExamineText = "drink-component-on-examine-is-opened";
public LocId ExamineText = "drink-component-on-examine-is-opened";

/// <summary>
/// The locale id for the popup shown when IsClosed is called and closed. Needs a "owner" entity argument passed to it.
/// Defaults to the popup drink uses since its "correct".
/// It's still generic enough that you should change it if you make openable non-drinks, i.e. unwrap it first, peel it first.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string ClosedPopup = "drink-component-try-use-drink-not-open";
public LocId ClosedPopup = "drink-component-try-use-drink-not-open";

/// <summary>
/// Sound played when opening.
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamP
{
_puddle.TrySpillAt(uid, solution, out _, false);
}
if (!string.IsNullOrEmpty(foodComp.TrashPrototype))
if (!string.IsNullOrEmpty(foodComp.Trash))
{
EntityManager.SpawnEntity(foodComp.TrashPrototype, Transform(uid).Coordinates);
EntityManager.SpawnEntity(foodComp.Trash, Transform(uid).Coordinates);
}
}
ActivatePayload(uid);
Expand Down
Loading