From cdf4e8dae022b43f696160529dd98bb09ea58106 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Fri, 5 Jul 2024 20:02:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9?= =?UTF-8?q?=D0=BD=20=D0=BB=D0=BE=D0=B1=D0=B1=D0=B8=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/Info/LinkBanner.cs | 39 ++--- Content.Client/Launcher/LauncherConnecting.cs | 4 +- .../Launcher/LauncherConnectingGui.xaml | 6 + .../Launcher/LauncherConnectingGui.xaml.cs | 15 +- Content.Client/Lobby/LobbyState.cs | 27 ++++ Content.Client/Lobby/UI/LobbyGui.xaml | 140 +++++++++++------- Content.Client/Lobby/UI/LobbyGui.xaml.cs | 24 ++- .../_Sunrise/ServersHub/ServersHub.xaml | 15 +- .../_Sunrise/ServersHub/ServersHub.xaml.cs | 5 - .../_Sunrise/ServersHub/ServersHubManager.cs | 8 + .../_Sunrise/ServersHub/ServersHubUi.xaml | 7 + .../_Sunrise/ServersHub/ServersHubUi.xaml.cs | 5 + Resources/Changelog/ChangelogSunrise.yml | 13 ++ 13 files changed, 213 insertions(+), 95 deletions(-) diff --git a/Content.Client/Info/LinkBanner.cs b/Content.Client/Info/LinkBanner.cs index afc1c7f9a2..819e901e2f 100644 --- a/Content.Client/Info/LinkBanner.cs +++ b/Content.Client/Info/LinkBanner.cs @@ -1,6 +1,7 @@ using Content.Client._Sunrise.ServersHub; using Content.Client.Changelog; using Content.Client.Credits; +using Content.Client.Stylesheets; using Content.Client.UserInterface.Systems.EscapeMenu; using Content.Client.UserInterface.Systems.Guidebook; using Content.Shared._Sunrise.SunriseCCVars; @@ -22,13 +23,12 @@ namespace Content.Client.Info { var buttons = new BoxContainer { - Orientation = LayoutOrientation.Vertical + Orientation = LayoutOrientation.Horizontal, }; AddChild(buttons); var uriOpener = IoCManager.Resolve(); _cfg = IoCManager.Resolve(); - var serversHubManager = IoCManager.Resolve(); var rulesButton = new Button() {Text = Loc.GetString("server-info-rules-button")}; rulesButton.OnPressed += args => new RulesAndInfoWindow().Open(); @@ -39,22 +39,6 @@ namespace Content.Client.Info AddInfoButton("server-info-wiki-button", CCVars.InfoLinksWiki); AddInfoButton("server-info-forum-button", CCVars.InfoLinksForum); - // Sunrise-Start - var roadmapButton = new Button - { - Disabled = true, - Text = Loc.GetString("server-info-roadmap-button"), - //StyleClasses = { StyleBase.ButtonCaution } - }; - //roadmapButton.OnPressed += _ => UserInterfaceManager.GetUIController().ToggleRoadmap(); - buttons.AddChild(roadmapButton); - - var serversHubButton = new Button() {Text = Loc.GetString("server-info-servers-hub-button")}; - serversHubButton.OnPressed += args => serversHubManager.OpenServersHub(); - buttons.AddChild(serversHubButton); - - // Sunrise-End - var guidebookController = UserInterfaceManager.GetUIController(); var guidebookButton = new Button() { Text = Loc.GetString("server-info-guidebook-button") }; guidebookButton.OnPressed += _ => @@ -67,6 +51,25 @@ namespace Content.Client.Info changelogButton.OnPressed += args => UserInterfaceManager.GetUIController().ToggleWindow(); buttons.AddChild(changelogButton); + var roadmapButton = new Button + { + Disabled = true, + Text = Loc.GetString("server-info-roadmap-button"), + StyleClasses = { StyleBase.ButtonCaution }, + }; + // Sunrise-Start + //roadmapButton.OnPressed += _ => UserInterfaceManager.GetUIController().ToggleRoadmap(); + buttons.AddChild(roadmapButton); + + var donateButton = new Button + { + Text = Loc.GetString("server-info-donate-button"), + Disabled = true, + }; + //donateButton.OnPressed += args => + buttons.AddChild(donateButton); + // Sunrise-End + void AddInfoButton(string loc, CVarDef cVar) { var button = new Button { Text = Loc.GetString(loc) }; diff --git a/Content.Client/Launcher/LauncherConnecting.cs b/Content.Client/Launcher/LauncherConnecting.cs index 29b241ae5d..3b45dc2d13 100644 --- a/Content.Client/Launcher/LauncherConnecting.cs +++ b/Content.Client/Launcher/LauncherConnecting.cs @@ -1,4 +1,5 @@ using System; +using Content.Client._Sunrise.ServersHub; using Robust.Client; using Robust.Client.UserInterface; using Robust.Shared.Configuration; @@ -19,6 +20,7 @@ namespace Content.Client.Launcher [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly ServersHubManager _serversHubManager = default!; private LauncherConnectingGui? _control; @@ -58,7 +60,7 @@ namespace Content.Client.Launcher protected override void Startup() { - _control = new LauncherConnectingGui(this, _random, _prototypeManager, _cfg); + _control = new LauncherConnectingGui(this, _random, _prototypeManager, _cfg, _serversHubManager); _userInterfaceManager.StateRoot.AddChild(_control); diff --git a/Content.Client/Launcher/LauncherConnectingGui.xaml b/Content.Client/Launcher/LauncherConnectingGui.xaml index f9cc949632..671b606f5f 100644 --- a/Content.Client/Launcher/LauncherConnectingGui.xaml +++ b/Content.Client/Launcher/LauncherConnectingGui.xaml @@ -54,6 +54,12 @@ + + + + diff --git a/Content.Client/Launcher/LauncherConnectingGui.xaml.cs b/Content.Client/Launcher/LauncherConnectingGui.xaml.cs index 8649416656..c5eb29ec33 100644 --- a/Content.Client/Launcher/LauncherConnectingGui.xaml.cs +++ b/Content.Client/Launcher/LauncherConnectingGui.xaml.cs @@ -1,5 +1,7 @@ using System.Linq; +using Content.Client._Sunrise.ServersHub; using Content.Client.Stylesheets; +using Content.Shared._Sunrise.ServersHub; using Content.Shared.CCVar; using Content.Shared.Dataset; using Robust.Client.AutoGenerated; @@ -28,14 +30,16 @@ namespace Content.Client.Launcher private readonly IRobustRandom _random; private readonly IPrototypeManager _prototype; private readonly IConfigurationManager _cfg; + private readonly ServersHubManager _serversHubManager; public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random, - IPrototypeManager prototype, IConfigurationManager config) + IPrototypeManager prototype, IConfigurationManager config, ServersHubManager serversHubManager) { _state = state; _random = random; _prototype = prototype; _cfg = config; + _serversHubManager = serversHubManager; RobustXamlLoader.Load(this); @@ -63,6 +67,15 @@ namespace Content.Client.Launcher var edim = IoCManager.Resolve(); edim.LastNetDisconnectedArgsChanged += LastNetDisconnectedArgsChanged; LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs); + + _serversHubManager.ServersDataListChanged += RefreshServersHubHeader; + } + + private void RefreshServersHubHeader(List servers) + { + var totalPlayers = servers.Sum(server => server.CurrentPlayers); + var maxPlayers = servers.Sum(server => server.MaxPlayers); + ServersHubHeaderLabel.Text = $"Сейчас играет: {totalPlayers}/{maxPlayers}"; } // Just button, there's only one at once anyways :) diff --git a/Content.Client/Lobby/LobbyState.cs b/Content.Client/Lobby/LobbyState.cs index 714c160528..3e88108184 100644 --- a/Content.Client/Lobby/LobbyState.cs +++ b/Content.Client/Lobby/LobbyState.cs @@ -1,4 +1,6 @@ +using System.Linq; using Content.Client._Sunrise.Latejoin; +using Content.Client._Sunrise.ServersHub; using Content.Client.Audio; using Content.Client.GameTicking.Managers; using Content.Client.LateJoin; @@ -15,6 +17,7 @@ using Robust.Shared.Timing; using Robust.Shared.Utility; using Content.Client.Changelog; using Content.Client.Parallax.Managers; +using Content.Shared._Sunrise.ServersHub; using Content.Shared._Sunrise.SunriseCCVars; using Robust.Shared.Configuration; using Robust.Shared.ContentPack; @@ -34,6 +37,9 @@ namespace Content.Client.Lobby [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IVoteManager _voteManager = default!; [Dependency] private readonly IParallaxManager _parallaxManager = default!; + [Dependency] private readonly ISerializationManager _serialization = default!; + [Dependency] private readonly IResourceManager _resource = default!; + [Dependency] private readonly ServersHubManager _serversHubManager = default!; private ClientGameTicker _gameTicker = default!; private ContentAudioSystem _contentAudioSystem = default!; @@ -63,6 +69,16 @@ namespace Content.Client.Lobby //Lobby.ServerName.Text = _baseClient.GameInfo?.ServerName; //The eye of refactor gazes upon you... UpdateLobbyUi(); + Lobby!.LocalChangelogBody.CleanChangelog(); + + var sunriseChangelog = new ResPath("/Changelog/ChangelogSunrise.yml"); + + var yamlData = _resource.ContentFileReadYaml(sunriseChangelog); + + var node = yamlData.Documents[0].RootNode.ToDataNodeCast(); + var changelog = _serialization.Read(node, notNullableOverride: true); + Lobby!.LocalChangelogBody.PopulateChangelog(changelog); + // Sunrise-end Lobby.CharacterPreview.CharacterSetupButton.OnPressed += OnSetupPressed; @@ -72,6 +88,8 @@ namespace Content.Client.Lobby _gameTicker.InfoBlobUpdated += UpdateLobbyUi; _gameTicker.LobbyStatusUpdated += LobbyStatusUpdated; _gameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated; + + _serversHubManager.ServersDataListChanged += RefreshServersHubHeader; } protected override void Shutdown() @@ -90,6 +108,15 @@ namespace Content.Client.Lobby Lobby!.ReadyButton.OnToggled -= OnReadyToggled; Lobby = null; + + _serversHubManager.ServersDataListChanged -= RefreshServersHubHeader; + } + + private void RefreshServersHubHeader(List servers) + { + var totalPlayers = _serversHubManager.ServersDataList.Sum(server => server.CurrentPlayers); + var maxPlayers = _serversHubManager.ServersDataList.Sum(server => server.MaxPlayers); + Lobby!.ServersHubHeaderLabel.Text = $"Сейчас играет: {totalPlayers}/{maxPlayers}"; } public void SwitchState(LobbyGui.LobbyGuiState state) diff --git a/Content.Client/Lobby/UI/LobbyGui.xaml b/Content.Client/Lobby/UI/LobbyGui.xaml index f88b42d8a5..602a28580d 100644 --- a/Content.Client/Lobby/UI/LobbyGui.xaml +++ b/Content.Client/Lobby/UI/LobbyGui.xaml @@ -8,25 +8,34 @@ xmlns:style="clr-namespace:Content.Client.Stylesheets" xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI" xmlns:info="clr-namespace:Content.Client.Info" - xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"> + xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets" + xmlns:serversHub="clr-namespace:Content.Client._Sunrise.ServersHub" + xmlns:changelog="clr-namespace:Content.Client.Changelog"> - - + + + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -