Skip to content

Commit

Permalink
Remove calls to FormattedMessage obsolete methods (space-wizards#31706)
Browse files Browse the repository at this point in the history
* Remove FormattedMessage obsolete methods

* Oops
  • Loading branch information
Winkarst-cpu authored Sep 1, 2024
1 parent ff4c347 commit 88dcc83
Show file tree
Hide file tree
Showing 40 changed files with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Administration.Notes;
using Content.Shared.Administration.Notes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
Expand All @@ -13,7 +13,7 @@ public AdminMessagePopupMessage(AdminMessageEuiState.Message message)
{
RobustXamlLoader.Load(this);

Admin.SetMessage(FormattedMessage.FromMarkup(Loc.GetString(
Admin.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString(
"admin-notes-message-admin",
("admin", message.AdminName),
("date", message.AddedOn.ToLocalTime()))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void SetState(AdminMessageEuiState state)
MessageContainer.AddChild(new AdminMessagePopupMessage(message));
}

Description.SetMessage(FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
Description.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
}

private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message)
Unread++;

var formatted = new FormattedMessage(1);
formatted.AddMarkup($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}");
formatted.AddMarkupOrThrow($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}");
TextOutput.AddMessage(formatted);
LastMessage = message.SentAt;
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Changelog/ChangelogTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ public void PopulateChangelog(ChangelogManager.Changelog changelog)
Margin = new Thickness(6, 0, 0, 0),
};
authorLabel.SetMessage(
FormattedMessage.FromMarkup(Loc.GetString("changelog-author-changed", ("author", author))));
FormattedMessage.FromMarkupOrThrow(Loc.GetString("changelog-author-changed", ("author", author))));
ChangelogBody.AddChild(authorLabel);

foreach (var change in groupedEntry.SelectMany(c => c.Changes))
{
var text = new RichTextLabel();
text.SetMessage(FormattedMessage.FromMarkup(change.Message));
text.SetMessage(FormattedMessage.FromMarkupOrThrow(change.Message));
ChangelogBody.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected FormattedMessage FormatSpeech(string message, Color? fontColor = null)
var msg = new FormattedMessage();
if (fontColor != null)
msg.PushColor(fontColor.Value);
msg.AddMarkup(message);
msg.AddMarkupOrThrow(message);
return msg;
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Credits/CreditsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void AddSection(string title, string path, bool markup = false)
var text = _resourceManager.ContentFileReadAllText($"/Credits/{path}");
if (markup)
{
label.SetMessage(FormattedMessage.FromMarkup(text.Trim()));
label.SetMessage(FormattedMessage.FromMarkupOrThrow(text.Trim()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void PopulateRecordContainer(GeneralStationRecord stationRecord, Crimina
StatusOptionButton.SelectId((int) criminalRecord.Status);
if (criminalRecord.Reason is {} reason)
{
var message = FormattedMessage.FromMarkup(Loc.GetString("criminal-records-console-wanted-reason"));
var message = FormattedMessage.FromMarkupOrThrow(Loc.GetString("criminal-records-console-wanted-reason"));
message.AddText($": {reason}");
WantedReason.SetMessage(message);
WantedReason.Visible = true;
Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void GenerateControl(ReagentPrototype reagent)
var i = 0;
foreach (var effectString in effect.EffectDescriptions)
{
descMsg.AddMarkup(effectString);
descMsg.AddMarkupOrThrow(effectString);
i++;
if (i < descriptionsCount)
descMsg.PushNewline();
Expand Down Expand Up @@ -174,7 +174,7 @@ private void GenerateControl(ReagentPrototype reagent)
var i = 0;
foreach (var effectString in guideEntryRegistryPlant.PlantMetabolisms)
{
descMsg.AddMarkup(effectString);
descMsg.AddMarkupOrThrow(effectString);
i++;
if (i < descriptionsCount)
descMsg.PushNewline();
Expand All @@ -195,7 +195,7 @@ private void GenerateControl(ReagentPrototype reagent)
FormattedMessage description = new();
description.AddText(reagent.LocalizedDescription);
description.PushNewline();
description.AddMarkup(Loc.GetString("guidebook-reagent-physical-description",
description.AddMarkupOrThrow(Loc.GetString("guidebook-reagent-physical-description",
("description", reagent.LocalizedPhysicalDescription)));
ReagentDescription.SetMessage(description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void SetReagents(Dictionary<string, FixedPoint2> reagents, ref RichTextL
var i = 0;
foreach (var (product, amount) in reagents.OrderByDescending(p => p.Value))
{
msg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display",
msg.AddMarkupOrThrow(Loc.GetString("guidebook-reagent-recipes-reagent-display",
("reagent", protoMan.Index<ReagentPrototype>(product).LocalizedName), ("ratio", amount)));
i++;
if (i < reagentCount)
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Info/InfoSection.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Client.AutoGenerated;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
Expand All @@ -18,7 +18,7 @@ public void SetText(string title, string text, bool markup = false)
{
TitleLabel.Text = title;
if (markup)
Content.SetMessage(FormattedMessage.FromMarkup(text.Trim()));
Content.SetMessage(FormattedMessage.FromMarkupOrThrow(text.Trim()));
else
Content.SetMessage(text);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Info/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ServerInfo()
}
public void SetInfoBlob(string markup)
{
_richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup));
_richTextLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(markup));
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Message/RichTextLabelExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class RichTextLabelExt
/// </remarks>
public static RichTextLabel SetMarkup(this RichTextLabel label, string markup)
{
label.SetMessage(FormattedMessage.FromMarkup(markup));
label.SetMessage(FormattedMessage.FromMarkupOrThrow(markup));
return label;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Client.Lobby;
using Content.Shared.CCVar;
using Content.Shared.Players;
Expand Down Expand Up @@ -133,7 +133,7 @@ public bool CheckRoleRequirements(HashSet<JobRequirement>? requirements, Humanoi
reasons.Add(jobReason.ToMarkup());
}

reason = reasons.Count == 0 ? null : FormattedMessage.FromMarkup(string.Join('\n', reasons));
reason = reasons.Count == 0 ? null : FormattedMessage.FromMarkupOrThrow(string.Join('\n', reasons));
return reason == null;
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Power/PowerMonitoringWindow.xaml.Widgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void UpdateWarningLabel(PowerMonitoringFlags flags)
BorderThickness = new Thickness(2),
};

msg.AddMarkup(Loc.GetString("power-monitoring-window-rogue-power-consumer"));
msg.AddMarkupOrThrow(Loc.GetString("power-monitoring-window-rogue-power-consumer"));
SystemWarningPanel.Visible = true;
}

Expand All @@ -322,7 +322,7 @@ private void UpdateWarningLabel(PowerMonitoringFlags flags)
BorderThickness = new Thickness(2),
};

msg.AddMarkup(Loc.GetString("power-monitoring-window-power-net-abnormalities"));
msg.AddMarkupOrThrow(Loc.GetString("power-monitoring-window-power-net-abnormalities"));
SystemWarningPanel.Visible = true;
}

Expand Down
10 changes: 5 additions & 5 deletions Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ private void PopulateData()
};

var text = new FormattedMessage();
text.PushMarkup(Loc.GetString("robotics-console-model", ("name", model)));
text.AddMarkup(Loc.GetString("robotics-console-designation"));
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-model", ("name", model))}\n");
text.AddMarkupOrThrow(Loc.GetString("robotics-console-designation"));
text.AddText($" {data.Name}\n"); // prevent players trolling by naming borg [color=red]satan[/color]
text.PushMarkup(Loc.GetString("robotics-console-battery", ("charge", (int) (data.Charge * 100f)), ("color", batteryColor)));
text.PushMarkup(Loc.GetString("robotics-console-brain", ("brain", data.HasBrain)));
text.AddMarkup(Loc.GetString("robotics-console-modules", ("count", data.ModuleCount)));
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-battery", ("charge", (int)(data.Charge * 100f)), ("color", batteryColor))}\n");
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-brain", ("brain", data.HasBrain))}\n");
text.AddMarkupOrThrow(Loc.GetString("robotics-console-modules", ("count", data.ModuleCount)));
BorgInfo.SetMessage(text);

// how the turntables
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/RoundEnd/RoundEndSummaryWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ private BoxContainer MakeRoundEndSummaryTab(string gamemode, string roundEnd, Ti
//Gamemode Name
var gamemodeLabel = new RichTextLabel();
var gamemodeMessage = new FormattedMessage();
gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-round-id-label", ("roundId", roundId)));
gamemodeMessage.AddMarkupOrThrow(Loc.GetString("round-end-summary-window-round-id-label", ("roundId", roundId)));
gamemodeMessage.AddText(" ");
gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode)));
gamemodeMessage.AddMarkupOrThrow(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode)));
gamemodeLabel.SetMessage(gamemodeMessage);
roundEndSummaryContainer.AddChild(gamemodeLabel);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Client.Actions.UI;
using Content.Client.Cooldown;
using Content.Shared.Alert;
Expand Down Expand Up @@ -69,8 +69,8 @@ public AlertControl(AlertPrototype alert, short? severity)

private Control SupplyTooltip(Control? sender)
{
var msg = FormattedMessage.FromMarkup(Loc.GetString(Alert.Name));
var desc = FormattedMessage.FromMarkup(Loc.GetString(Alert.Description));
var msg = FormattedMessage.FromMarkupOrThrow(Loc.GetString(Alert.Name));
var desc = FormattedMessage.FromMarkupOrThrow(Loc.GetString(Alert.Description));
return new ActionAlertTooltip(msg, desc) {Cooldown = Cooldown};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void AddLine(string message, Color color)
{
var formatted = new FormattedMessage(3);
formatted.PushColor(color);
formatted.AddMarkup(message);
formatted.AddMarkupOrThrow(message);
formatted.Pop();
Contents.AddMessage(formatted);
}
Expand Down
10 changes: 5 additions & 5 deletions Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public void UpdateInformationDisplay(AnalysisConsoleUpdateState state)
{
if (state.Paused)
{
message.AddMarkup(Loc.GetString("analysis-console-info-scanner-paused"));
message.AddMarkupOrThrow(Loc.GetString("analysis-console-info-scanner-paused"));
}
else
{
message.AddMarkup(Loc.GetString("analysis-console-info-scanner"));
message.AddMarkupOrThrow(Loc.GetString("analysis-console-info-scanner"));
}
Information.SetMessage(message);
UpdateArtifactIcon(null); //set it to blank
Expand All @@ -155,11 +155,11 @@ public void UpdateInformationDisplay(AnalysisConsoleUpdateState state)
if (state.ScanReport == null)
{
if (!state.AnalyzerConnected) //no analyzer connected
message.AddMarkup(Loc.GetString("analysis-console-info-no-scanner"));
message.AddMarkupOrThrow(Loc.GetString("analysis-console-info-no-scanner"));
else if (!state.CanScan) //no artifact
message.AddMarkup(Loc.GetString("analysis-console-info-no-artifact"));
message.AddMarkupOrThrow(Loc.GetString("analysis-console-info-no-artifact"));
else if (state.Artifact == null) //ready to go
message.AddMarkup(Loc.GetString("analysis-console-info-ready"));
message.AddMarkupOrThrow(Loc.GetString("analysis-console-info-ready"));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public record struct CommandPermissionsUnassignedError(CommandSpec Command) : IC
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup($"The command {Command.FullName()} is missing permission flags and cannot be executed.");
return FormattedMessage.FromMarkupOrThrow($"The command {Command.FullName()} is missing permission flags and cannot be executed.");
}

public string? Expression { get; set; }
Expand All @@ -671,7 +671,7 @@ public record struct NoPermissionError(CommandSpec Command) : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup($"You do not have permission to execute {Command.FullName()}");
return FormattedMessage.FromMarkupOrThrow($"You do not have permission to execute {Command.FullName()}");
}

public string? Expression { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Cargo/Systems/CargoSystem.Bounty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData
msg.PushNewline();
foreach (var entry in prototype.Entries)
{
msg.AddMarkup($"- {Loc.GetString("bounty-console-manifest-entry",
msg.AddMarkupOrThrow($"- {Loc.GetString("bounty-console-manifest-entry",
("amount", entry.Amount),
("item", Loc.GetString(entry.Name)))}");
msg.PushNewline();
}
msg.AddMarkup(Loc.GetString("bounty-console-manifest-reward", ("reward", prototype.Reward)));
msg.AddMarkupOrThrow(Loc.GetString("bounty-console-manifest-reward", ("reward", prototype.Reward)));
_paperSystem.SetContent((uid, paper), msg.ToMarkup());
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ private void SendEntityWhisper(
if (!_actionBlocker.CanSpeak(source) && !ignoreActionBlocker)
return;

var message = TransformSpeech(source, FormattedMessage.RemoveMarkup(originalMessage));
var message = TransformSpeech(source, FormattedMessage.RemoveMarkupOrThrow(originalMessage));
if (message.Length == 0)
return;

Expand Down Expand Up @@ -593,7 +593,7 @@ private void SendEntityEmote(
var wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message",
("entityName", name),
("entity", ent),
("message", FormattedMessage.RemoveMarkup(action)));
("message", FormattedMessage.RemoveMarkupOrThrow(action)));

if (checkEmote)
TryEmoteChatInput(source, action);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/DetailExaminable/DetailExaminableystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Examine;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
Expand Down Expand Up @@ -28,7 +28,7 @@ private void OnGetExamineVerbs(EntityUid uid, DetailExaminableComponent componen
Act = () =>
{
var markup = new FormattedMessage();
markup.AddMarkup(component.Content);
markup.AddMarkupOrThrow(component.Content);
_examineSystem.SendExamineTooltip(args.User, uid, markup, false, false);
},
Text = Loc.GetString("detail-examinable-verb-text"),
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override void Update(float frameTime)
Dirty(uid, comp);

var msg = Loc.GetString("carp-rift-warning",
("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, xform)))));
("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, xform)))));
_chat.DispatchGlobalAnnouncement(msg, playSound: false, colorOverride: Color.Red);
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true);
_navMap.SetBeaconEnabled(uid, true);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void HandleRattleTrigger(EntityUid uid, RattleComponent component, Trigg
return;

// Gets location of the implant
var posText = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString(uid));
var posText = FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(uid));
var critMessage = Loc.GetString(component.CritMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
var deathMessage = Loc.GetString(component.DeathMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Gateway/Systems/GatewayGeneratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void GenerateDestination(EntityUid uid, GatewayGeneratorComponent? gener
// Create the gateway.
var gatewayUid = SpawnAtPosition(generator.Proto, originCoords);
var gatewayComp = Comp<GatewayComponent>(gatewayUid);
_gateway.SetDestinationName(gatewayUid, FormattedMessage.FromMarkup($"[color=#D381C996]{gatewayName}[/color]"), gatewayComp);
_gateway.SetDestinationName(gatewayUid, FormattedMessage.FromMarkupOrThrow($"[color=#D381C996]{gatewayName}[/color]"), gatewayComp);
_gateway.SetEnabled(gatewayUid, true, gatewayComp);
generator.Generated.Add(mapUid);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Nuke/NukeCodePaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private bool TryGetRelativeNukeCode(
}

codesMessage.PushNewline();
codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nukeUid).EntityName), ("code", nuke.Code)));
codesMessage.AddMarkupOrThrow(Loc.GetString("nuke-codes-list", ("name", MetaData(nukeUid).EntityName), ("code", nuke.Code)));
break;
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Nuke/NukeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null)
// warn a crew
var announcement = Loc.GetString("nuke-component-announcement-armed",
("time", (int) component.RemainingTime),
("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, nukeXform)))));
("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, nukeXform)))));
var sender = Loc.GetString("nuke-component-announcement-sender");
_chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, false, null, Color.Red);

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Points/PointSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Shared.FixedPoint;
using Content.Shared.Points;
using JetBrains.Annotations;
Expand Down Expand Up @@ -76,7 +76,7 @@ public override FormattedMessage GetScoreboard(EntityUid uid, PointManagerCompon
if (!_player.TryGetPlayerData(id, out var data))
continue;

msg.AddMarkup(Loc.GetString("point-scoreboard-list",
msg.AddMarkupOrThrow(Loc.GetString("point-scoreboard-list",
("place", place),
("name", data.UserName),
("points", points.Int())));
Expand Down
Loading

0 comments on commit 88dcc83

Please sign in to comment.