]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Ion law visuals (#22908)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 24 Dec 2023 06:58:02 +0000 (01:58 -0500)
committerGitHub <noreply@github.com>
Sun, 24 Dec 2023 06:58:02 +0000 (23:58 -0700)
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Content.Client/Stylesheets/StyleNano.cs
Content.Client/UserInterface/RichText/ScrambleTag.cs [new file with mode: 0644]
Content.Server/StationEvents/Events/IonStormRule.cs
Resources/Locale/en-US/station-events/events/ion-storm.ftl
Resources/Prototypes/fonts.yml

index 5a0aeab36682fd95e1dbae06ed61c2b315df5d11..d8abaf6e996ccbe8c740e54e0bf5e147135512c9 100644 (file)
@@ -6,7 +6,7 @@
                       HorizontalExpand="True"
                       VerticalExpand="True"
                       Margin="5 5 5 5">
-            <Label Name="LawNumberLabel" StyleClasses="StatusFieldTitle"/>
+            <RichTextLabel Name="LawNumberLabel" StyleClasses="LabelKeyText"/>
             <customControls:HSeparator Margin="0 5 0 5"/>
             <RichTextLabel Name="LawLabel"/>
             <BoxContainer Name="LawAnnouncementButtons" Orientation="Horizontal" HorizontalExpand="True" Margin="0 5 0 0">
index 47545f17e1b71b8eee8be9c04bd414f8350722c7..565c3b8e43ca77e8973a2b8212859389cfccc6c9 100644 (file)
@@ -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...
index 9f656297c82845ad8f6a188544e8343c16343a29..220e9a926566fb919729aff84cd00ff16cf3e45b 100644 (file)
@@ -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 (file)
index 0000000..77b7b25
--- /dev/null
@@ -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;
+
+/// <summary>
+/// Adds a specified length of random characters that scramble at a set rate.
+/// </summary>
+[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();
+    }
+}
index e5b68c4d842a9c4dfbcad08adb767ca326e46ddd..409a152a056672b1997a07813cbe3e5ddd865776 100644 (file)
@@ -137,11 +137,11 @@ public sealed class IonStormRule : StationEventSystem<IonStormRuleComponent>
             }
             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)))
                 });
             }
 
index d32fb6c2d86759f7025ad3fa3409bf6bb80230ad..8687a31d70dd9dbe36b8f2b9e544bde77bf140c6 100644 (file)
@@ -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
index c883df514cf2ee358ec889ec798313d1ea5a8b33..b1ca1fba965aacdb4ef233b68b9e01791feaeac5 100644 (file)
@@ -37,3 +37,7 @@
 - type: font
   id: AnimalSilence
   path: /Fonts/Animal Silence.otf
+
+- type: font
+  id: Monospace
+  path: /EngineFonts/NotoSans/NotoSansMono-Regular.ttf