From f2b5d17c3163dd6870e6c6a3753912be6ffb60e2 Mon Sep 17 00:00:00 2001 From: Winkarst <74284083+winkarst-cpu@users.noreply.github.com> Date: Sat, 13 Jul 2024 07:05:51 +0300 Subject: [PATCH] Update ActionAlertTooltip.cs to use TryFromMarkup (#29975) (cherry picked from commit e11f1e6cf64bda214f17e95e3eb1c58f46d4675b) --- .../Actions/UI/ActionAlertTooltip.cs | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Content.Client/Actions/UI/ActionAlertTooltip.cs b/Content.Client/Actions/UI/ActionAlertTooltip.cs index c126c27ce7..f805f6643d 100644 --- a/Content.Client/Actions/UI/ActionAlertTooltip.cs +++ b/Content.Client/Actions/UI/ActionAlertTooltip.cs @@ -77,14 +77,12 @@ namespace Content.Client.Actions.UI MaxWidth = TooltipTextMaxWidth, StyleClasses = {StyleNano.StyleClassTooltipActionRequirements} }; - try - { - requiresLabel.SetMessage(FormattedMessage.FromMarkupOrThrow("[color=#635c5c]" + requires + "[/color]")); - } - catch(Exception e) - { - requiresLabel.SetMessage(e.Message); - } + + if (!FormattedMessage.TryFromMarkup("[color=#635c5c]" + requires + "[/color]", out var markup)) + return; + + requiresLabel.SetMessage(markup); + vbox.AddChild(requiresLabel); } } @@ -102,16 +100,11 @@ namespace Content.Client.Actions.UI if (timeLeft > TimeSpan.Zero) { var duration = Cooldown.Value.End - Cooldown.Value.Start; - try - { - _cooldownLabel.SetMessage(FormattedMessage.FromMarkupOrThrow( - $"[color=#a10505]{(int) duration.TotalSeconds} sec cooldown ({(int) timeLeft.TotalSeconds + 1} sec remaining)[/color]")); - } - catch(Exception e) - { - _cooldownLabel.SetMessage(e.Message); - } + if (!FormattedMessage.TryFromMarkup($"[color=#a10505]{(int) duration.TotalSeconds} sec cooldown ({(int) timeLeft.TotalSeconds + 1} sec remaining)[/color]", out var markup)) + return; + + _cooldownLabel.SetMessage(markup); _cooldownLabel.Visible = true; } else