From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Sun, 24 Dec 2023 06:58:02 +0000 (-0500)
Subject: Ion law visuals (#22908)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=681f9a2c852033949f0b984f9f3b711c52e4cfdf;p=space-station-14.git
Ion law visuals (#22908)
---
diff --git a/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml b/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
index 5a0aeab366..d8abaf6e99 100644
--- a/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
+++ b/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
@@ -6,7 +6,7 @@
HorizontalExpand="True"
VerticalExpand="True"
Margin="5 5 5 5">
-
+
diff --git a/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs b/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
index 47545f17e1..565c3b8e43 100644
--- a/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
+++ b/Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
@@ -1,4 +1,5 @@
using Content.Client.Chat.Managers;
+using Content.Client.Message;
using Content.Shared.Chat;
using Content.Shared.Radio;
using Content.Shared.Silicons.Laws;
@@ -29,7 +30,7 @@ public sealed partial class LawDisplay : Control
var lawIdentifier = Loc.GetString("laws-ui-law-header", ("id", identifier));
var lawDescription = Loc.GetString(law.LawString);
- LawNumberLabel.Text = lawIdentifier;
+ LawNumberLabel.SetMarkup(lawIdentifier);
LawLabel.SetMessage(lawDescription);
// If you can't talk, you can't state your laws...
diff --git a/Content.Client/Stylesheets/StyleNano.cs b/Content.Client/Stylesheets/StyleNano.cs
index 9f656297c8..220e9a9265 100644
--- a/Content.Client/Stylesheets/StyleNano.cs
+++ b/Content.Client/Stylesheets/StyleNano.cs
@@ -910,6 +910,12 @@ namespace Content.Client.Stylesheets
new StyleProperty("font", notoSansItalic12),
}),
+ new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassLabelKeyText}, null, null), new[]
+ {
+ new StyleProperty(Label.StylePropertyFont, notoSansBold12),
+ new StyleProperty( Control.StylePropertyModulateSelf, NanoGold)
+ }),
+
// alert tooltip
new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertTitle}, null, null), new[]
{
diff --git a/Content.Client/UserInterface/RichText/ScrambleTag.cs b/Content.Client/UserInterface/RichText/ScrambleTag.cs
new file mode 100644
index 0000000000..77b7b25145
--- /dev/null
+++ b/Content.Client/UserInterface/RichText/ScrambleTag.cs
@@ -0,0 +1,41 @@
+using System.Text;
+using JetBrains.Annotations;
+using Robust.Client.UserInterface.RichText;
+using Robust.Shared.Timing;
+using Robust.Shared.Utility;
+
+namespace Content.Client.UserInterface.RichText;
+
+///
+/// Adds a specified length of random characters that scramble at a set rate.
+///
+[UsedImplicitly]
+public sealed class ScrambleTag : IMarkupTag
+{
+ [Dependency] private readonly IGameTiming _timing = default!;
+
+ public string Name => "scramble";
+
+ public string TextBefore(MarkupNode node)
+ {
+ if (!node.Attributes.TryGetValue("rate", out var rateParam) ||
+ !rateParam.TryGetLong(out var rate) ||
+ !node.Attributes.TryGetValue("length", out var lengthParam) ||
+ !lengthParam.TryGetLong(out var length) ||
+ !node.Attributes.TryGetValue("chars", out var charsParam) ||
+ !charsParam.TryGetString(out var chars))
+ return string.Empty;
+
+ var seed = (int) (_timing.CurTime.TotalMilliseconds / rate);
+ var rand = new Random(seed + node.GetHashCode());
+ var charOptions = chars.ToCharArray();
+ var sb = new StringBuilder();
+ for (var i = 0; i < length; i++)
+ {
+ var index = rand.Next() % charOptions.Length;
+ sb.Append(charOptions[index]);
+ }
+
+ return sb.ToString();
+ }
+}
diff --git a/Content.Server/StationEvents/Events/IonStormRule.cs b/Content.Server/StationEvents/Events/IonStormRule.cs
index e5b68c4d84..409a152a05 100644
--- a/Content.Server/StationEvents/Events/IonStormRule.cs
+++ b/Content.Server/StationEvents/Events/IonStormRule.cs
@@ -137,11 +137,11 @@ public sealed class IonStormRule : StationEventSystem
}
else
{
- laws.Laws.Insert(0, new SiliconLaw()
+ laws.Laws.Insert(0, new SiliconLaw
{
LawString = newLaw,
Order = -1,
- LawIdentifierOverride = "#"
+ LawIdentifierOverride = Loc.GetString("ion-storm-law-scrambled-number", ("length", RobustRandom.Next(5, 10)))
});
}
diff --git a/Resources/Locale/en-US/station-events/events/ion-storm.ftl b/Resources/Locale/en-US/station-events/events/ion-storm.ftl
index d32fb6c2d8..8687a31d70 100644
--- a/Resources/Locale/en-US/station-events/events/ion-storm.ftl
+++ b/Resources/Locale/en-US/station-events/events/ion-storm.ftl
@@ -1,5 +1,7 @@
station-event-ion-storm-start-announcement = Ion storm detected near the station. Please check all AI-controlled equipment for errors.
+ion-storm-law-scrambled-number = [font="Monospace"][scramble rate=250 length={$length} chars="@@###$$&%!01"/][/font]
+
ion-storm-you = YOU
ion-storm-the-station = THE STATION
ion-storm-the-crew = THE CREW
diff --git a/Resources/Prototypes/fonts.yml b/Resources/Prototypes/fonts.yml
index c883df514c..b1ca1fba96 100644
--- a/Resources/Prototypes/fonts.yml
+++ b/Resources/Prototypes/fonts.yml
@@ -37,3 +37,7 @@
- type: font
id: AnimalSilence
path: /Fonts/Animal Silence.otf
+
+- type: font
+ id: Monospace
+ path: /EngineFonts/NotoSans/NotoSansMono-Regular.ttf