Skip to content

Commit

Permalink
Revert "Анимации в лобби. Кастомный выбор фона в лобби. (#562)"
Browse files Browse the repository at this point in the history
This reverts commit 4082ffc.
  • Loading branch information
rhailrake authored Oct 31, 2024
1 parent b9a24ac commit 59ce681
Show file tree
Hide file tree
Showing 213 changed files with 371 additions and 4,190 deletions.
3 changes: 1 addition & 2 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public override void Init()
_prototypeManager.RegisterIgnore("htnPrimitive");
_prototypeManager.RegisterIgnore("gameMap");
_prototypeManager.RegisterIgnore("gameMapPool");
// Sunrise-Edit
// _prototypeManager.RegisterIgnore("lobbyBackground");
_prototypeManager.RegisterIgnore("lobbyBackground");
_prototypeManager.RegisterIgnore("gamePreset");
_prototypeManager.RegisterIgnore("noiseChannel");
_prototypeManager.RegisterIgnore("playerConnectionWhitelist");
Expand Down
14 changes: 6 additions & 8 deletions Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ public sealed class ClientGameTicker : SharedGameTicker
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
// Sunrise-Start
[ViewVariables] public string? LobbyType { get; private set; }
[ViewVariables] public string? LobbyParallax { get; private set; }
[ViewVariables] public string? LobbyAnimation { get; private set; }
[ViewVariables] public string? LobbyArt { get; private set; }
[ViewVariables] public string? LobbyParalax { get; private set; }
[ViewVariables] public LobbyImage? LobbyImage { get; private set; }
// Sunrise-End
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; }
[ViewVariables] public TimeSpan StartTime { get; private set; }
Expand Down Expand Up @@ -125,10 +124,9 @@ private void LobbyStatus(TickerLobbyStatusEvent message)
IsGameStarted = message.IsRoundStarted;
AreWeReady = message.YouAreReady;
// Sunrise-Start
LobbyType = message.LobbyType;
LobbyArt = message.LobbyArt;
LobbyParallax = message.LobbyParallax;
LobbyAnimation = message.LobbyAnimation;
LobbyBackground = message.LobbyBackground;
LobbyParalax = message.LobbyParalax;
LobbyImage = message.LobbyImage;
// Sunrise-End
Paused = message.Paused;

Expand Down
2 changes: 0 additions & 2 deletions Content.Client/Info/LinkBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.EscapeMenu;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.CCVar;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
Expand Down Expand Up @@ -58,7 +57,6 @@ public LinkBanner()
};
roadmapButton.OnPressed += _ => UserInterfaceManager.GetUIController<RoadmapUIController>().ToggleRoadmap();
buttons.AddChild(roadmapButton);
AddInfoButton("server-info-telegram-button", SunriseCCVars.InfoLinksTelegram);
// Sunrise-End

void AddInfoButton(string loc, CVarDef<string> cVar)
Expand Down
155 changes: 29 additions & 126 deletions Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
using Content.Client._Sunrise.ServersHub;
using Content.Client.Audio;
using Content.Client.GameTicking.Managers;
using Content.Client.LateJoin;
using Content.Client.Lobby.UI;
using Content.Client.Message;
using Content.Client.UserInterface.Systems.Chat;
using Content.Client.Voting;
using Robust.Client;
using Robust.Client.Console;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
Expand All @@ -15,14 +17,11 @@
using Robust.Shared.Utility;
using Content.Client.Changelog;
using Content.Client.Parallax.Managers;
using Content.Server.GameTicking.Prototypes;
using Content.Shared._Sunrise.Lobby;
using Content.Shared._Sunrise.ServersHub;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.GameTicking;
using Robust.Shared.Configuration;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping;
Expand All @@ -44,7 +43,6 @@ public sealed class LobbyState : Robust.Client.State.State
[Dependency] private readonly ServersHubManager _serversHubManager = default!;
[Dependency] private readonly ChangelogManager _changelogManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

private ClientGameTicker _gameTicker = default!;
private ContentAudioSystem _contentAudioSystem = default!;
Expand Down Expand Up @@ -90,15 +88,7 @@ protected override void Startup()
var combinedChangelog = _changelogManager.MergeChangelogs(changelogs);

Lobby!.LocalChangelogBody.PopulateChangelog(combinedChangelog);
Lobby!.LobbyAnimation.DisplayRect.Stretch = TextureRect.StretchMode.KeepAspectCovered;
Lobby!.LobbyAnimation.DisplayRect.HorizontalExpand = true;
Lobby!.LobbyAnimation.DisplayRect.VerticalExpand = true;


_cfg.OnValueChanged(SunriseCCVars.LobbyBackgroundType, OnLobbyBackgroundTypeChanged, true);
_cfg.OnValueChanged(SunriseCCVars.LobbyArt, OnLobbyArtChanged, true);
_cfg.OnValueChanged(SunriseCCVars.LobbyAnimation, OnLobbyAnimationChanged, true);
_cfg.OnValueChanged(SunriseCCVars.LobbyParallax, OnLobbyParallaxChanged, true);
// Sunrise-end

Lobby.CharacterPreview.CharacterSetupButton.OnPressed += OnSetupPressed;
Expand Down Expand Up @@ -207,11 +197,10 @@ public override void FrameUpdate(FrameEventArgs e)
private void LobbyStatusUpdated()
{
// Sunrise-Start
UpdateLobbyType();
UpdateLobbyParallax();
UpdateLobbyAnimation();
UpdateLobbyArt();
UpdateLobbyaralax();
UpdateLobbyImage();
// Sunrise-End
UpdateLobbyBackground();
UpdateLobbyUi();
}

Expand Down Expand Up @@ -276,134 +265,42 @@ private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev)
}

// Sunrise-start

private void OnLobbyBackgroundTypeChanged(string lobbyBackgroundTypeString)
private void UpdateLobbyaralax()
{
if (lobbyBackgroundTypeString == "Random" && _gameTicker.LobbyType != null)
SetLobbyBackgroundType(_gameTicker.LobbyType);
else
if (_gameTicker.LobbyParalax != null)
{
SetLobbyBackgroundType(lobbyBackgroundTypeString);
_parallaxManager.LoadParallaxByName(_gameTicker.LobbyParalax);
Lobby!.LobbyParalax = _gameTicker.LobbyParalax;
}
}

public void SetLobbyBackgroundType(string lobbyBackgroundString)
{
if (!Enum.TryParse(lobbyBackgroundString, out LobbyBackgroundType lobbyBackgroundTypeString))
{
lobbyBackgroundTypeString = default;
}

switch (lobbyBackgroundTypeString)
else
{
case LobbyBackgroundType.Parallax:
Lobby!.LobbyAnimation.Visible = false;
Lobby!.LobbyArt.Visible = false;
Lobby!.ShowParallax = true;
break;
case LobbyBackgroundType.Art:
Lobby!.LobbyAnimation.Visible = false;
Lobby!.LobbyArt.Visible = true;
Lobby!.ShowParallax = false;
break;
case LobbyBackgroundType.Animation:
Lobby!.LobbyAnimation.Visible = true;
Lobby!.LobbyArt.Visible = false;
Lobby!.ShowParallax = false;
break;
Lobby!.LobbyParalax = "FastSpace";
}
}

private void OnLobbyArtChanged(string lobbyArt)
private void UpdateLobbyImage()
{
if (lobbyArt == "Random" && _gameTicker.LobbyArt != null)
SetLobbyArt(_gameTicker.LobbyArt);
else
{
SetLobbyArt(lobbyArt);
}
if (_gameTicker.LobbyImage == null)
return;

Lobby!.LobbyImage.SetFromSpriteSpecifier(new SpriteSpecifier.Rsi(new ResPath(_gameTicker.LobbyImage.Path), _gameTicker.LobbyImage.State));
Lobby!.LobbyImage.DisplayRect.TextureScale = _gameTicker.LobbyImage.Scale;
}
// Sunrise-end

private void OnLobbyAnimationChanged(string lobbyAnimation)
private void UpdateLobbyBackground()
{
if (lobbyAnimation == "Random" && _gameTicker.LobbyAnimation != null)
SetLobbyAnimation(_gameTicker.LobbyAnimation);
else
if (_gameTicker.LobbyBackground != null)
{
SetLobbyAnimation(lobbyAnimation);
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
}
}

private void OnLobbyParallaxChanged(string lobbyParallax)
{
if (lobbyParallax == "Random" && _gameTicker.LobbyParallax != null)
SetLobbyParallax(_gameTicker.LobbyParallax);
else
{
SetLobbyParallax(lobbyParallax);
Lobby!.Background.Texture = null;
}
}

private void SetLobbyAnimation(string lobbyAnimation)
{
if (!_prototypeManager.TryIndex<LobbyAnimationPrototype>(lobbyAnimation, out var lobbyAnimationPrototype))
return;

Lobby!.LobbyAnimation.SetFromSpriteSpecifier(new SpriteSpecifier.Rsi(lobbyAnimationPrototype.Animation, lobbyAnimationPrototype.State));
Lobby!.LobbyAnimation.DisplayRect.TextureScale = lobbyAnimationPrototype.Scale;
}

private void SetLobbyArt(string lobbyArt)
{
if (!_prototypeManager.TryIndex<LobbyBackgroundPrototype>(lobbyArt, out var lobbyArtPrototype))
return;

Lobby!.LobbyArt.Texture = _resourceCache.GetResource<TextureResource>(lobbyArtPrototype.Background);
}

private void SetLobbyParallax(string lobbyParallax)
{
if (!_prototypeManager.TryIndex<LobbyParallaxPrototype>(lobbyParallax, out var lobbyParallaxPrototype))
return;

_parallaxManager.LoadParallaxByName(lobbyParallaxPrototype.Parallax);
Lobby!.LobbyParallax = lobbyParallaxPrototype.Parallax;
}

private void UpdateLobbyType()
{
if (_cfg.GetCVar(SunriseCCVars.LobbyBackgroundType) != "Random")
return;

SetLobbyBackgroundType(_gameTicker.LobbyType!);
}

private void UpdateLobbyAnimation()
{
if (_cfg.GetCVar(SunriseCCVars.LobbyAnimation) != "Random")
return;

SetLobbyAnimation(_gameTicker.LobbyAnimation!);
}

private void UpdateLobbyArt()
{
if (_cfg.GetCVar(SunriseCCVars.LobbyArt) != "Random")
return;

SetLobbyArt(_gameTicker.LobbyArt!);
}

private void UpdateLobbyParallax()
{
if (_cfg.GetCVar(SunriseCCVars.LobbyParallax) != "Random")
return;

SetLobbyParallax(_gameTicker.LobbyParallax!);
}

// Sunrise-end

private void SetReady(bool newReady)
{
if (_gameTicker.IsGameStarted)
Expand All @@ -415,3 +312,9 @@ private void SetReady(bool newReady)
}
}
}

public enum LobbyBackgroundType
{
Paralax,
Art
}
7 changes: 4 additions & 3 deletions Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
xmlns:changelog="clr-namespace:Content.Client.Changelog"
xmlns:userProfile="clr-namespace:Content.Client._Sunrise.UserProfile">
<!-- Background -->
<TextureRect Name="LobbyArt" Access="Public" VerticalExpand="True" HorizontalExpand="True"
Stretch="KeepAspectCovered" />
<AnimatedTextureRect Name="LobbyAnimation" HorizontalExpand="True" VerticalExpand="True" Access="Public" />
<TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name="Background" Stretch="KeepAspectCovered" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<!-- LHS Controls -->
<Control Name="DefaultState" VerticalExpand="True" HorizontalExpand="True">
<BoxContainer Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" >
<AnimatedTextureRect Name="LobbyImage" VerticalAlignment="Center" HorizontalAlignment="Center" Access="Public" />
</BoxContainer>
<BoxContainer Orientation="Vertical" HorizontalAlignment="Left" HorizontalExpand="True">
<PanelContainer Name="LeftTopPanel" StyleClasses="AngleRect" >
<BoxContainer Orientation="Vertical" HorizontalExpand="True" HorizontalAlignment="Center" VerticalAlignment="Top">
Expand Down
41 changes: 33 additions & 8 deletions Content.Client/Lobby/UI/LobbyGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public sealed partial class LobbyGui : UIScreen
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;

public string LobbyParallax = "FastSpace"; // Sunrise-edit
public bool ShowParallax; // Sunrise-edit
public string LobbyParalax = "FastSpace"; // Sunrise-edit
[ViewVariables(VVAccess.ReadWrite)] public Vector2 Offset { get; set; } // Sunrise-edit
public const string DefaultIconExpanded = "/Textures/Interface/Nano/inverted_triangle.svg.png";
public const string DefaultIconCollapsed = "/Textures/Interface/Nano/top_triangle.svg.png";
Expand All @@ -46,7 +45,7 @@ public LobbyGui()
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
SetAnchorPreset(MainContainer, LayoutPreset.Wide);
SetAnchorPreset(LobbyArt, LayoutPreset.Wide); // Sunrise-Edit
SetAnchorPreset(Background, LayoutPreset.Wide);

LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text"));

Expand Down Expand Up @@ -109,6 +108,8 @@ public LobbyGui()
};

Offset = new Vector2(_random.Next(0, 1000), _random.Next(0, 1000));

_parallaxManager.LoadParallaxByName(LobbyParalax);
RectClipContent = true;

var panelTex = _resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
Expand All @@ -130,14 +131,16 @@ public LobbyGui()
LobbySongPanel.PanelOverride = _back;

_configurationManager.OnValueChanged(SunriseCCVars.LobbyOpacity, OnLobbyOpacityChanged);
_configurationManager.OnValueChanged(SunriseCCVars.LobbyBackground, OnLobbyBackgroundChanged);
_configurationManager.OnValueChanged(SunriseCCVars.ServersHubEnable, OnServersHubEnableChanged);

SetLobbyOpacity(_configurationManager.GetCVar(SunriseCCVars.LobbyOpacity));
SetLobbyBackgroundType(_configurationManager.GetCVar(SunriseCCVars.LobbyBackground));
SetServersHubEnable(_configurationManager.GetCVar(SunriseCCVars.ServersHubEnable));

Chat.SetChatOpacity();

ServerName.Text = Loc.GetString("ui-lobby-welcome", ("name", _configurationManager.GetCVar(SunriseCCVars.ServerName)));
ServerName.Text = Loc.GetString("ui-lobby-cfgwelcome", ("name", _configurationManager.GetCVar(SunriseCCVars.ServerName)));
LoadIcons();
// Sunrise-end
}
Expand Down Expand Up @@ -176,6 +179,31 @@ private void SetServersHubEnable(bool enable)
{
ServersHubBox.Visible = enable;
}

private void OnLobbyBackgroundChanged(string lobbyBackgroundString)
{
SetLobbyBackgroundType(lobbyBackgroundString);
}

private void SetLobbyBackgroundType(string lobbyBackgroundString)
{
if (!Enum.TryParse(lobbyBackgroundString, out LobbyBackgroundType lobbyBackgroundTypeString))
{
lobbyBackgroundTypeString = default;
}

switch (lobbyBackgroundTypeString)
{
case LobbyBackgroundType.Paralax:
LobbyImage.Visible = true;
Background.Visible = false;
break;
case LobbyBackgroundType.Art:
LobbyImage.Visible = false;
Background.Visible = true;
break;
}
}
// Sunrise-End

private void OnLobbyOpacityChanged(float opacity)
Expand Down Expand Up @@ -211,10 +239,7 @@ public void SwitchState(LobbyGuiState state)
// Sunrise-start
protected override void Draw(DrawingHandleScreen handle)
{
if (!ShowParallax)
return;

foreach (var layer in _parallaxManager.GetParallaxLayers(LobbyParallax))
foreach (var layer in _parallaxManager.GetParallaxLayers(LobbyParalax))
{
var tex = layer.Texture;
var texSize = new Vector2i(
Expand Down
Loading

0 comments on commit 59ce681

Please sign in to comment.