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.
This commit is contained in:
committed by
GitHub
parent
db290fd91e
commit
cea87d6985
49
Content.Client/Voting/VoteCallMenuButton.cs
Normal file
49
Content.Client/Voting/VoteCallMenuButton.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Client.Voting
|
||||
{
|
||||
/// <summary>
|
||||
/// LITERALLY just a button that opens the vote call menu.
|
||||
/// Automatically disables itself if the client cannot call votes.
|
||||
/// </summary>
|
||||
public sealed class VoteCallMenuButton : Button
|
||||
{
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
|
||||
public VoteCallMenuButton()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Text = Loc.GetString("Call vote");
|
||||
OnPressed += OnOnPressed;
|
||||
}
|
||||
|
||||
private void OnOnPressed(ButtonEventArgs obj)
|
||||
{
|
||||
var menu = new VoteCallMenu();
|
||||
menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
base.EnteredTree();
|
||||
|
||||
UpdateCanCall(_voteManager.CanCallVote);
|
||||
_voteManager.CanCallVoteChanged += UpdateCanCall;
|
||||
}
|
||||
|
||||
protected override void ExitedTree()
|
||||
{
|
||||
base.ExitedTree();
|
||||
|
||||
_voteManager.CanCallVoteChanged += UpdateCanCall;
|
||||
}
|
||||
|
||||
private void UpdateCanCall(bool canCall)
|
||||
{
|
||||
Disabled = !canCall;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user