small campaign progress
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9f9be13215
commit
96657989c8
18 changed files with 439 additions and 89 deletions
|
@ -221,6 +221,7 @@ namespace Sledgemapper
|
|||
_mainWidget.BtnToolbarLine.Click += OnBtnToolbarLinClicked;
|
||||
_mainWidget.BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||
_mainWidget.BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||
_mainWidget.MenuCampaignPlayers.Selected += OnMenuCampaignPlayersSelected;
|
||||
|
||||
|
||||
_wallsContent = Content.LoadContentFolder<Texture2D>("walls");
|
||||
|
@ -255,6 +256,68 @@ namespace Sledgemapper
|
|||
_whiteRectangle.SetData(new[] { Color.White });
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignPlayersSelected(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Players"
|
||||
};
|
||||
|
||||
var content = new PlayerList();
|
||||
var players = await _communicationManager.Api.GetPlayers(_state.CampaignName);
|
||||
foreach (var player in players)
|
||||
{
|
||||
var item = new PlayerListItem();
|
||||
item.TxtPlayerName.Text = player.UserName;
|
||||
item.Background = new NinePatchRegion(
|
||||
Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 25),
|
||||
new Myra.Graphics2D.Thickness
|
||||
{
|
||||
Left = 11,
|
||||
Right = 11,
|
||||
Top = 11,
|
||||
Bottom = 11
|
||||
});
|
||||
|
||||
content.StackCampaignsList.AddChild(item);
|
||||
}
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
|
||||
|
||||
|
||||
content.BtnInvitePlayer.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
ShowAddPLayerWindow();
|
||||
};
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
// content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private void ShowAddPLayerWindow()
|
||||
{
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Invite player"
|
||||
};
|
||||
|
||||
var content = new PlayerWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonInvitePlayerClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private void OnTxtOverlaySearchChange(object sender, ValueChangedEventArgs<string> e)
|
||||
{
|
||||
AddItemToToolGrid(_mainWidget.GridOverlays, OnOverlayButtonClicked, _spriteSheet, e.NewValue);
|
||||
|
@ -304,7 +367,7 @@ namespace Sledgemapper
|
|||
|
||||
private void OnMenuCampaignNew(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
if (sender is MenuItem && !((MenuItem)sender).Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -316,14 +379,14 @@ namespace Sledgemapper
|
|||
|
||||
var content = new CampaignWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
content.BtnNewCampaign.Click += OnButtonInvitePlayerClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
{
|
||||
|
@ -337,25 +400,42 @@ namespace Sledgemapper
|
|||
|
||||
var content = new CampaignList();
|
||||
var campaigns = await _communicationManager.Api.GetCampaigns();
|
||||
foreach(var campaign in campaigns)
|
||||
foreach (var campaign in campaigns)
|
||||
{
|
||||
var item = new CampaignListItem();
|
||||
item.TxtCampaignName.Text=campaign.Name;
|
||||
item.Background= new NinePatchRegion(
|
||||
Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 98),
|
||||
new Myra.Graphics2D.Thickness {Left = 11, Right = 11,
|
||||
Top = 11, Bottom = 11});
|
||||
content.StackNotesList.AddChild(item);
|
||||
item.TxtCampaignName.Text = campaign.Name;
|
||||
item.Background = new NinePatchRegion(
|
||||
Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 25),
|
||||
new Myra.Graphics2D.Thickness
|
||||
{
|
||||
Left = 11,
|
||||
Right = 11,
|
||||
Top = 11,
|
||||
Bottom = 11
|
||||
});
|
||||
item.TouchUp += OnCampaignSelected;
|
||||
content.StackCampaignsList.AddChild(item);
|
||||
}
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
|
||||
|
||||
|
||||
// content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
|
||||
content.BtnNewCampaign.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
OnMenuCampaignNew(s, e);
|
||||
};
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
// content.TxtCampaign.SetKeyboardFocus();
|
||||
// content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private void OnCampaignSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as CampaignListItem;
|
||||
_state.CampaignName = item.TxtCampaignName.Text;
|
||||
}
|
||||
|
||||
private void OneMenuFileSettingsSelected(object sender, EventArgs e)
|
||||
|
@ -1962,7 +2042,7 @@ item.Background= new NinePatchRegion(
|
|||
}
|
||||
}
|
||||
|
||||
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||
private async void OnButtonInvitePlayerClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
while (!(container is Window))
|
||||
|
@ -1970,24 +2050,24 @@ item.Background= new NinePatchRegion(
|
|||
container = container.Parent;
|
||||
}
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as CampaignWindow;
|
||||
var localContent = localWindow.Content as PlayerWindow;
|
||||
var isValid = ValidateTextbox(localContent.TxtCampaign);
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_communicationManager.Connection.State != HubConnectionState.Connected)
|
||||
{
|
||||
_mainWidget.lblConnectionStatus.Text = "Connecting";
|
||||
await _communicationManager.Connection.StartAsync();
|
||||
UpdateConnectionState(_communicationManager.Connection);
|
||||
}
|
||||
//if (_communicationManager.Connection.State != HubConnectionState.Connected)
|
||||
//{
|
||||
// _mainWidget.lblConnectionStatus.Text = "Connecting";
|
||||
// await _communicationManager.Connection.StartAsync();
|
||||
// UpdateConnectionState(_communicationManager.Connection);
|
||||
//}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await _communicationManager.Api.NewCampaign(localContent.TxtCampaign.Text);
|
||||
await _communicationManager.Api.InvitePlayer(_state.CampaignName, localContent.TxtCampaign.Text);
|
||||
|
||||
//if (result)
|
||||
//{
|
||||
|
@ -2007,17 +2087,20 @@ item.Background= new NinePatchRegion(
|
|||
ExceptionlessClient.Default.SubmitException(ex);
|
||||
}
|
||||
|
||||
if (successful)
|
||||
{
|
||||
//_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
//_communicationManager.SessionData.Map = _sessionData.Map;
|
||||
//_communicationManager.SessionData.Overlays = _sessionData.Overlays;
|
||||
//_communicationManager.SessionData.Walls = _sessionData.Walls;
|
||||
//_mainWidget.lblSessionName.Text = _sessionData.SessionName;
|
||||
//_mainWidget.MenuConnectSync.Enabled = true;
|
||||
//_mainWidget.MenuConnectUpload.Enabled = true;
|
||||
localWindow.Close();
|
||||
}
|
||||
//if (successful)
|
||||
//{
|
||||
// //_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
// //_communicationManager.SessionData.Map = _sessionData.Map;
|
||||
// //_communicationManager.SessionData.Overlays = _sessionData.Overlays;
|
||||
// //_communicationManager.SessionData.Walls = _sessionData.Walls;
|
||||
// //_mainWidget.lblSessionName.Text = _sessionData.SessionName;
|
||||
// //_mainWidget.MenuConnectSync.Enabled = true;
|
||||
// //_mainWidget.MenuConnectUpload.Enabled = true;
|
||||
// localWindow.Close();
|
||||
//}
|
||||
|
||||
localWindow.Close();
|
||||
|
||||
}
|
||||
|
||||
private async void OnButtonNewSessionClicked(object sender, EventArgs e)
|
||||
|
@ -2376,8 +2459,8 @@ item.Background= new NinePatchRegion(
|
|||
var content = new LoginRegisterWindow();
|
||||
|
||||
#if DEBUG
|
||||
content.TxtEmail.Text="michele.scandura@outlook.com";
|
||||
content.TxtPassword.Text="slePharland!79";
|
||||
content.TxtEmail.Text = "michele.scandura@outlook.com";
|
||||
content.TxtPassword.Text = "slePharland!79";
|
||||
#endif
|
||||
|
||||
content.RdoLogin.IsPressed = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue