add new map to campaign
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
4d40add598
commit
12080cf6da
5 changed files with 261 additions and 22 deletions
|
@ -217,7 +217,8 @@ namespace Sledgemapper
|
|||
_mainWidget.MenuCampaignPlayers.Selected += OnMenuCampaignPlayersSelected;
|
||||
|
||||
_mainWidget.MenuMapOpen.Selected += OnMenuMapOpen;
|
||||
|
||||
_mainWidget.MenuMapNew.Selected += OnMenuMapNew;
|
||||
|
||||
_mainWidget.MenuConnectNew.Enabled = false;
|
||||
_mainWidget.MenuConnectJoin.Enabled = false;
|
||||
_mainWidget.MenuConnectSync.Enabled = false;
|
||||
|
@ -259,6 +260,87 @@ namespace Sledgemapper
|
|||
_whiteRectangle.SetData(new[] { Color.White });
|
||||
}
|
||||
|
||||
private void OnMenuMapNew(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is MenuItem && !((MenuItem)sender).Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "New map"
|
||||
};
|
||||
|
||||
var content = new MapWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonNewMapClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private async void OnButtonNewMapClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
while (!(container is Window))
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as MapWindow;
|
||||
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);
|
||||
//}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await _communicationManager.Api.NewSession(_state.CampaignName, localContent.TxtCampaign.Text);
|
||||
|
||||
//if (result)
|
||||
//{
|
||||
// _sessionData.SessionName = localContent.TxtSession.Text;
|
||||
// _sessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
// _sessionData.MapEntityAdded += OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||
//}
|
||||
//successful = result;
|
||||
//var result2 = await _communicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||
//_sessionData.SessionId = result2.SessionId;
|
||||
//_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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();
|
||||
//}
|
||||
|
||||
localWindow.Close();
|
||||
}
|
||||
|
||||
private async void OnMenuMapOpen(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
|
@ -272,23 +354,23 @@ namespace Sledgemapper
|
|||
};
|
||||
|
||||
var content = new CampaignList();
|
||||
//var campaigns = await _communicationManager.Api.GetMaps();
|
||||
//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, 25),
|
||||
// new Myra.Graphics2D.Thickness
|
||||
// {
|
||||
// Left = 11,
|
||||
// Right = 11,
|
||||
// Top = 11,
|
||||
// Bottom = 11
|
||||
// });
|
||||
// item.TouchUp += OnCampaignSelected;
|
||||
// content.StackCampaignsList.AddChild(item);
|
||||
//}
|
||||
var campaigns = await _communicationManager.Api.GetMaps(_state.CampaignName);
|
||||
foreach (var campaign in campaigns)
|
||||
{
|
||||
var item = new CampaignListItem();
|
||||
item.TxtCampaignName.Text = campaign.SessionName;
|
||||
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";
|
||||
|
||||
|
||||
|
@ -428,7 +510,7 @@ namespace Sledgemapper
|
|||
|
||||
var content = new CampaignWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonInvitePlayerClicked;
|
||||
content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
|
@ -2152,6 +2234,67 @@ namespace Sledgemapper
|
|||
|
||||
}
|
||||
|
||||
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
while (!(container is Window))
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as CampaignWindow;
|
||||
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);
|
||||
//}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await _communicationManager.Api.NewCampaign(localContent.TxtCampaign.Text);
|
||||
|
||||
//if (result)
|
||||
//{
|
||||
// _sessionData.SessionName = localContent.TxtSession.Text;
|
||||
// _sessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
// _sessionData.MapEntityAdded += OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||
//}
|
||||
//successful = result;
|
||||
//var result2 = await _communicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||
//_sessionData.SessionId = result2.SessionId;
|
||||
//_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
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();
|
||||
//}
|
||||
|
||||
localWindow.Close();
|
||||
|
||||
}
|
||||
|
||||
private async void OnButtonNewSessionClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
|
@ -2177,7 +2320,7 @@ namespace Sledgemapper
|
|||
var successful = false;
|
||||
try
|
||||
{
|
||||
var result = await _communicationManager.Api.NewSession(localContent.TxtSession.Text);
|
||||
var result = await _communicationManager.Api.NewSession(_state.CampaignName, localContent.TxtSession.Text);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue