Randomize Main Menu Parallax (#43893)

* Random parallax

* Switch from enumerate to allow list

* Use ProtoId

* Validate

It's really been too long since I've done this kind of this, and it
shows...

* Update Content.Client/MainMenu/UI/MainMenuControl.xaml.cs

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
Thomas 2026-05-16 12:35:36 -05:00 • committed by GitHub
parent 779085781f
commit 0fc0362113
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 2 deletions

View file

@ -2,7 +2,7 @@
xmlns:pllax="clr-namespace:Content.Client.Parallax"
xmlns:clog="clr-namespace:Content.Client.Changelog">
<pllax:ParallaxControl
ParallaxPrototype="TrainStation"
Name="BackgroundParallax"
SpeedX="5"
SpeedY="20"
ScaleX="3"

View file

@ -1,21 +1,43 @@
using Robust.Client.AutoGenerated;
using Content.Client.Parallax.Data;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Client.MainMenu.UI;
[GenerateTypedNameReferences]
public sealed partial class MainMenuControl : Control
{
[Dependency] private IRobustRandom _random = default!;
public const string StyleIdentifierMainMenu = "mainMenu";
public const string StyleIdentifierMainMenuVBox = "mainMenuVBox";
private static readonly ProtoId<ParallaxPrototype>[] Parallaxes =
[
"Wizard",
"TrainStation",
"PlasmaStation",
"AmberStation",
"FastSpace",
"AspidParallax",
"OriginStation",
"Default",
"Sky",
"KettleStation",
"BagelStation",
"ExoStation",
];
public MainMenuControl(IResourceCache resCache, IConfigurationManager configMan)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
@ -25,6 +47,10 @@ public sealed partial class MainMenuControl : Control
LayoutContainer.SetMarginTop(VBox, 30);
LayoutContainer.SetGrowHorizontal(VBox, LayoutContainer.GrowDirection.Begin);
// I don't just enumerate them all as there's some hideous parallaxes, and it's easier
// to update an allowlist than to randomly get an ugly one to fix a blocklist.
BackgroundParallax.ParallaxPrototype = _random.Pick(Parallaxes).Id;
var logoTexture = resCache.GetResource<TextureResource>("/Textures/Logo/logo.png");
Logo.Texture = logoTexture;