Files
tbd-station-14/Content.Client/Voting/VoteCallMenuButton.cs
Pieter-Jan Briers 245f276f35 Restart vote improvements, voting localization.
Restart votes now need 80% majority to succeed.
Restart votes now have a 3 minute cooldown on the caller.
Voting stuff has been localized.
2021-02-28 22:11:53 +01:00

50 lines
1.3 KiB
C#

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("ui-vote-menu-button");
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;
}
}
}