From cea87d69856bd32eb7e865d1a4af7ce7ae918336 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 16 Feb 2021 15:07:17 +0100 Subject: [PATCH] Voting (#3185) * Basic voting * Rewrite lobby in XAML. Working lobby voting. * Escape menu is now XAML. * Vote menu works, custom votes, gamemode votes. * Vote timeouts & administration. Basically done now. * I will now pretend I was never planning to code voting hotkeys. * Make vote call UI a bit... funny. * Fix exception on round restart. * Fix some vote command definitions. --- Content.Client/ClientContentIoC.cs | 2 + Content.Client/EntryPoint.cs | 2 + Content.Client/State/GameScreen.cs | 3 + Content.Client/State/LauncherConnecting.cs | 13 +- Content.Client/State/LobbyState.cs | 6 +- Content.Client/UserInterface/EscapeMenu.xaml | 12 + .../{EscapeMenu.cs => EscapeMenu.xaml.cs} | 36 +- Content.Client/UserInterface/GameHud.cs | 57 ++- Content.Client/UserInterface/LobbyGui.cs | 330 -------------- Content.Client/UserInterface/LobbyGui.xaml | 88 ++++ Content.Client/UserInterface/LobbyGui.xaml.cs | 124 +++++ .../UserInterface/Stylesheets/StyleBase.cs | 41 ++ .../UserInterface/Stylesheets/StyleNano.cs | 33 +- .../UserInterface/Stylesheets/StyleSpace.cs | 54 +++ .../UserInterface/TopNotification.cs | 9 + Content.Client/Voting/VoteCallMenu.xaml | 39 ++ Content.Client/Voting/VoteCallMenu.xaml.cs | 111 +++++ Content.Client/Voting/VoteCallMenuButton.cs | 49 ++ Content.Client/Voting/VoteManager.cs | 196 ++++++++ Content.Client/Voting/VotePopup.xaml | 19 + Content.Client/Voting/VotePopup.xaml.cs | 83 ++++ Content.Server/EntryPoint.cs | 5 + Content.Server/ServerContentIoC.cs | 2 + Content.Server/Voting/IVoteHandle.cs | 18 + Content.Server/Voting/IVoteManager.cs | 22 + Content.Server/Voting/VoteCommands.cs | 210 +++++++++ .../Voting/VoteFinishedEventArgs.cs | 26 ++ .../Voting/VoteFinishedEventHandler.cs | 7 + .../Voting/VoteManager.DefaultVotes.cs | 114 +++++ Content.Server/Voting/VoteManager.cs | 428 ++++++++++++++++++ Content.Server/Voting/VoteOptions.cs | 68 +++ Content.Shared/Input/ContentKeyFunctions.cs | 10 + .../Network/NetMessages/MsgVoteCanCall.cs | 32 ++ .../Network/NetMessages/MsgVoteData.cs | 89 ++++ Content.Shared/Utility/RemList.cs | 76 ++++ 35 files changed, 2001 insertions(+), 413 deletions(-) create mode 100644 Content.Client/UserInterface/EscapeMenu.xaml rename Content.Client/UserInterface/{EscapeMenu.cs => EscapeMenu.xaml.cs} (58%) delete mode 100644 Content.Client/UserInterface/LobbyGui.cs create mode 100644 Content.Client/UserInterface/LobbyGui.xaml create mode 100644 Content.Client/UserInterface/LobbyGui.xaml.cs create mode 100644 Content.Client/UserInterface/TopNotification.cs create mode 100644 Content.Client/Voting/VoteCallMenu.xaml create mode 100644 Content.Client/Voting/VoteCallMenu.xaml.cs create mode 100644 Content.Client/Voting/VoteCallMenuButton.cs create mode 100644 Content.Client/Voting/VoteManager.cs create mode 100644 Content.Client/Voting/VotePopup.xaml create mode 100644 Content.Client/Voting/VotePopup.xaml.cs create mode 100644 Content.Server/Voting/IVoteHandle.cs create mode 100644 Content.Server/Voting/IVoteManager.cs create mode 100644 Content.Server/Voting/VoteCommands.cs create mode 100644 Content.Server/Voting/VoteFinishedEventArgs.cs create mode 100644 Content.Server/Voting/VoteFinishedEventHandler.cs create mode 100644 Content.Server/Voting/VoteManager.DefaultVotes.cs create mode 100644 Content.Server/Voting/VoteManager.cs create mode 100644 Content.Server/Voting/VoteOptions.cs create mode 100644 Content.Shared/Network/NetMessages/MsgVoteCanCall.cs create mode 100644 Content.Shared/Network/NetMessages/MsgVoteData.cs create mode 100644 Content.Shared/Utility/RemList.cs diff --git a/Content.Client/ClientContentIoC.cs b/Content.Client/ClientContentIoC.cs index 0faab676a3..f80e61b2e3 100644 --- a/Content.Client/ClientContentIoC.cs +++ b/Content.Client/ClientContentIoC.cs @@ -12,6 +12,7 @@ using Content.Client.UserInterface; using Content.Client.UserInterface.AdminMenu; using Content.Client.UserInterface.Stylesheets; using Content.Client.Utility; +using Content.Client.Voting; using Content.Shared.Actions; using Content.Shared.Interfaces; using Content.Shared.Alert; @@ -43,6 +44,7 @@ namespace Content.Client IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); + IoCManager.Register(); } } } diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index b3e07f7416..edcf4ed4f1 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -14,6 +14,7 @@ using Content.Client.UserInterface; using Content.Client.UserInterface.AdminMenu; using Content.Client.UserInterface.Stylesheets; using Content.Client.Graphics.Overlays; +using Content.Client.Voting; using Content.Shared.Actions; using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components.Cargo; @@ -161,6 +162,7 @@ namespace Content.Client IoCManager.Resolve().Initialize(); IoCManager.Resolve().Initialize(); IoCManager.Resolve().Initialize(); + IoCManager.Resolve().Initialize(); _baseClient.RunLevelChanged += (sender, args) => { diff --git a/Content.Client/State/GameScreen.cs b/Content.Client/State/GameScreen.cs index ce0fd30c0b..eaeaa3fcff 100644 --- a/Content.Client/State/GameScreen.cs +++ b/Content.Client/State/GameScreen.cs @@ -1,6 +1,7 @@ using Content.Client.Chat; using Content.Client.Interfaces.Chat; using Content.Client.UserInterface; +using Content.Client.Voting; using Content.Shared.Input; using Robust.Client.Input; using Robust.Client.UserInterface; @@ -18,6 +19,7 @@ namespace Content.Client.State [Dependency] private readonly IGameHud _gameHud = default!; [Dependency] private readonly IInputManager _inputManager = default!; [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly IVoteManager _voteManager = default!; [ViewVariables] private ChatBox _gameChat; @@ -35,6 +37,7 @@ namespace Content.Client.State _userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl); _chatManager.SetChatBox(_gameChat); + _voteManager.SetPopupContainer(_gameHud.VoteContainer); _gameChat.DefaultChatFormat = "say \"{0}\""; _gameChat.Input.PlaceHolder = Loc.GetString("Say something! [ for OOC"); diff --git a/Content.Client/State/LauncherConnecting.cs b/Content.Client/State/LauncherConnecting.cs index 463d531783..cffb9ca35f 100644 --- a/Content.Client/State/LauncherConnecting.cs +++ b/Content.Client/State/LauncherConnecting.cs @@ -31,14 +31,6 @@ namespace Content.Client.State public override void Startup() { - var panelTex = ResC.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png"); - var back = new StyleBoxTexture - { - Texture = panelTex, - Modulate = new Color(32, 32, 48), - }; - back.SetPatchMargin(StyleBox.Margin.All, 10); - Button exitButton; Button reconnectButton; Button retryButton; @@ -50,10 +42,7 @@ namespace Content.Client.State Stylesheet = _stylesheetManager.SheetSpace, Children = { - new PanelContainer - { - PanelOverride = back - }, + new PanelContainer {StyleClasses = {StyleBase.ClassAngleRect}}, new VBoxContainer { SeparationOverride = 0, diff --git a/Content.Client/State/LobbyState.cs b/Content.Client/State/LobbyState.cs index fd03cc18ee..231a48576c 100644 --- a/Content.Client/State/LobbyState.cs +++ b/Content.Client/State/LobbyState.cs @@ -3,6 +3,7 @@ using System.Linq; using Content.Client.Interfaces; using Content.Client.Interfaces.Chat; using Content.Client.UserInterface; +using Content.Client.Voting; using Content.Shared.Input; using Robust.Client; using Robust.Client.Console; @@ -36,6 +37,7 @@ namespace Content.Client.State [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; [Dependency] private readonly IClientPreferencesManager _preferencesManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IVoteManager _voteManager = default!; [ViewVariables] private CharacterSetupGui _characterSetup; [ViewVariables] private LobbyGui _lobby; @@ -58,12 +60,14 @@ namespace Content.Client.State _lobby.CharacterPreview.UpdateUI(); }; - _lobby = new LobbyGui(_entityManager, _resourceCache, _preferencesManager); + _lobby = new LobbyGui(_entityManager, _preferencesManager); _userInterfaceManager.StateRoot.AddChild(_lobby); LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide); _chatManager.SetChatBox(_lobby.Chat); + _voteManager.SetPopupContainer(_lobby.VoteContainer); + _lobby.Chat.DefaultChatFormat = "ooc \"{0}\""; _lobby.ServerName.Text = _baseClient.GameInfo.ServerName; diff --git a/Content.Client/UserInterface/EscapeMenu.xaml b/Content.Client/UserInterface/EscapeMenu.xaml new file mode 100644 index 0000000000..c91152c105 --- /dev/null +++ b/Content.Client/UserInterface/EscapeMenu.xaml @@ -0,0 +1,12 @@ + + + + +