2021-02-16 15:07:17 +01:00
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Voting.UI
|
2021-02-16 15:07:17 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <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);
|
|
|
|
|
|
|
2021-02-28 22:11:45 +01:00
|
|
|
|
Text = Loc.GetString("ui-vote-menu-button");
|
2021-02-16 15:07:17 +01:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|