Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обнова лобби #171

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public sealed class ClientGameTicker : SharedGameTicker
[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 @@ -123,6 +124,7 @@ private void LobbyStatus(TickerLobbyStatusEvent message)
IsGameStarted = message.IsRoundStarted;
AreWeReady = message.YouAreReady;
// Sunrise-Start
LobbyBackground = message.LobbyBackground;
LobbyParalax = message.LobbyParalax;
LobbyImage = message.LobbyImage;
// Sunrise-End
Expand Down
15 changes: 15 additions & 0 deletions Content.Client/Info/DevInfoBanner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Client.Changelog;
using Content.Client.Credits;
using Content.Client.UserInterface.Systems.EscapeMenu;
using Content.Shared.CCVar;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
Expand Down Expand Up @@ -30,9 +31,23 @@ public DevInfoBanner() {
buttons.AddChild(reportButton);
}

// Sunrise-Start
var github = cfg.GetCVar(CCVars.InfoLinksGithub);
if (bugReport != "")
{
var githubButton = new Button {Text = Loc.GetString("server-info-github-button")};
githubButton.OnPressed += _ => uriOpener.OpenUri(github);
buttons.AddChild(githubButton);
}
// Sunrise-End

var creditsButton = new Button {Text = Loc.GetString("server-info-credits-button")};
creditsButton.OnPressed += args => new CreditsWindow().Open();
buttons.AddChild(creditsButton);

var changelogButton = new ChangelogButton();
changelogButton.OnPressed += args => UserInterfaceManager.GetUIController<ChangelogUIController>().ToggleWindow();
buttons.AddChild(changelogButton);
}
}
}
11 changes: 0 additions & 11 deletions Content.Client/Info/LinkBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public LinkBanner()
AddInfoButton("server-info-wiki-button", CCVars.InfoLinksWiki);
AddInfoButton("server-info-forum-button", CCVars.InfoLinksForum);

// Sunrise-Start
AddInfoButton("server-info-github-button", CCVars.InfoLinksGithub);
var creditsButton = new Button {Text = Loc.GetString("server-info-credits-button")};
creditsButton.OnPressed += _ => new CreditsWindow().Open();
buttons.AddChild(creditsButton);
// Sunrise-End

var guidebookController = UserInterfaceManager.GetUIController<GuidebookUIController>();
var guidebookButton = new Button() { Text = Loc.GetString("server-info-guidebook-button") };
guidebookButton.OnPressed += _ =>
Expand All @@ -51,10 +44,6 @@ public LinkBanner()
};
buttons.AddChild(guidebookButton);

var changelogButton = new ChangelogButton();
changelogButton.OnPressed += args => UserInterfaceManager.GetUIController<ChangelogUIController>().ToggleWindow();
buttons.AddChild(changelogButton);

void AddInfoButton(string loc, CVarDef<string> cVar)
{
var button = new Button { Text = Loc.GetString(loc) };
Expand Down
21 changes: 21 additions & 0 deletions Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public override void FrameUpdate(FrameEventArgs e)
Lobby!.StartTime.Text = string.Empty;
var roundTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-time", ("hours", roundTime.Hours), ("minutes", roundTime.Minutes));
Lobby!.StartTime.Text = Loc.GetString("lobby-state-player-status-round-time", ("hours", roundTime.Hours), ("minutes", roundTime.Minutes));
return;
}

Expand Down Expand Up @@ -175,6 +176,7 @@ private void LobbyStatusUpdated()
UpdateLobbyaralax();
UpdateLobbyImage();
// Sunrise-End
UpdateLobbyBackground();
UpdateLobbyUi();
}

Expand Down Expand Up @@ -261,6 +263,19 @@ private void UpdateLobbyImage()
}
// Sunrise-end

private void UpdateLobbyBackground()
{
if (_gameTicker.LobbyBackground != null)
{
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
}
else
{
Lobby!.Background.Texture = null;
}

}

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

public enum LobbyBackgroundType
{
Paralax,
Art
}
2 changes: 1 addition & 1 deletion Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void SaveProfile()

_profileEditor.OnOpenGuidebook += _guide.OpenHelp;

_characterSetup = new CharacterSetupGui(EntityManager, _prototypeManager, _resourceCache, _preferencesManager, _profileEditor);
_characterSetup = new CharacterSetupGui(EntityManager, _prototypeManager, _resourceCache, _preferencesManager, _profileEditor, _configurationManager);

_characterSetup.CloseButton.OnPressed += _ =>
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/CharacterSetupGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:style="clr-namespace:Content.Client.Stylesheets"
VerticalExpand="True">
<Control>
<PanelContainer Name="BackgroundPanel" />
<PanelContainer Name="BackgroundPanel" StyleClasses="AngleRect"/>
<BoxContainer Orientation="Vertical" SeparationOverride="0">
<BoxContainer Orientation="Horizontal" MinSize="0 40">
<Label Text="{Loc 'character-setup-gui-character-setup-label'}"
Expand Down
28 changes: 24 additions & 4 deletions Content.Client/Lobby/UI/CharacterSetupGui.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using Content.Client.Info;
using Content.Client.Info.PlaytimeStats;
using Content.Client.Resources;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.Preferences;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;

namespace Content.Client.Lobby.UI
Expand All @@ -27,27 +29,33 @@ public sealed partial class CharacterSetupGui : Control
public event Action<int>? SelectCharacter;
public event Action<int>? DeleteCharacter;

private readonly StyleBoxTexture _back;

public CharacterSetupGui(
IEntityManager entManager,
IPrototypeManager protoManager,
IResourceCache resourceCache,
IClientPreferencesManager preferencesManager,
HumanoidProfileEditor profileEditor)
HumanoidProfileEditor profileEditor,
IConfigurationManager configurationManager)
{
RobustXamlLoader.Load(this);
_preferencesManager = preferencesManager;
_entManager = entManager;
_protomanager = protoManager;
var configurationManager1 = configurationManager;

var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
var back = new StyleBoxTexture
_back = new StyleBoxTexture
{
Texture = panelTex,
Modulate = new Color(37, 37, 42)
};
back.SetPatchMargin(StyleBox.Margin.All, 10);
_back.SetPatchMargin(StyleBox.Margin.All, 10);

SetLobbyOpacity(configurationManager1.GetCVar(SunriseCCVars.LobbyOpacity));

BackgroundPanel.PanelOverride = back;
BackgroundPanel.PanelOverride = _back;

_createNewCharacterButton = new Button
{
Expand All @@ -65,6 +73,18 @@ public CharacterSetupGui(
RulesButton.OnPressed += _ => new RulesAndInfoWindow().Open();

StatsButton.OnPressed += _ => new PlaytimeStatsWindow().OpenCentered();

configurationManager1.OnValueChanged(SunriseCCVars.LobbyOpacity, OnLobbyOpacityChanged);
}

private void OnLobbyOpacityChanged(float opacity)
{
SetLobbyOpacity(opacity);
}

private void SetLobbyOpacity(float opacity)
{
_back.Modulate = new Color(37, 37, 42).WithAlpha(opacity);
}

/// <summary>
Expand Down
Loading
Loading