Skip to content

Commit

Permalink
Ion law visuals (space-wizards#22908)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoGarbage404 authored Dec 24, 2023
1 parent ba4b03f commit 681f9a2
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -29,7 +30,7 @@ public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
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...
Expand Down
6 changes: 6 additions & 0 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,12 @@ public StyleNano(IResourceCache resCache) : base(resCache)
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[]
{
Expand Down
41 changes: 41 additions & 0 deletions Content.Client/UserInterface/RichText/ScrambleTag.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
4 changes: 2 additions & 2 deletions Content.Server/StationEvents/Events/IonStormRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ protected override void Started(EntityUid uid, IonStormRuleComponent comp, GameR
}
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)))
});
}

Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/station-events/events/ion-storm.ftl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/fonts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
- type: font
id: AnimalSilence
path: /Fonts/Animal Silence.otf

- type: font
id: Monospace
path: /EngineFonts/NotoSans/NotoSansMono-Regular.ttf

0 comments on commit 681f9a2

Please sign in to comment.