sledgemapper/Sledgemapper/UI/PlayerList.Custom.cs
Michele Scandura f15f1c8857
All checks were successful
continuous-integration/drone/push Build is passing
cleanup, refactoring, usual stuff
2021-09-16 11:11:07 +01:00

48 lines
No EOL
1.3 KiB
C#

/* Generated by MyraPad at 28/08/2021 19:49:08 */
using Myra.Graphics2D.UI;
using System.Threading.Tasks;
namespace Sledgemapper.UI
{
public partial class PlayerList
{
protected readonly Window Window;
protected readonly CommunicationManager CommunicationManager;
public PlayerList(CommunicationManager communicationManager, Window window)
{
BuildUI();
Window = window;
CommunicationManager = communicationManager;
BtnInvitePlayer.Click += (s, e) =>
{
Window.Close();
ShowAddPLayerWindow();
};
}
public async Task LoadPlayers()
{
var players = await CommunicationManager.Api.GetPlayers(State.Instance.CampaignName);
foreach (var player in players)
{
var item = new ListItem();
item.ItemName.Text = player.UserName;
StackCampaignsList.AddChild(item);
}
}
private void ShowAddPLayerWindow()
{
Window window = new()
{
Title = "Invite player",
Content = new PlayerWindow(CommunicationManager, Window)
};
window.ShowModal(Window.Desktop);
}
}
}