This commit is contained in:
parent
09c32c605e
commit
9033151006
6 changed files with 375 additions and 166 deletions
|
@ -67,7 +67,7 @@ namespace Sledgemapper
|
||||||
_communicationManager.Connection.Reconnected += OnHubReconnected;
|
_communicationManager.Connection.Reconnected += OnHubReconnected;
|
||||||
_communicationManager.Connection.Reconnecting += OnHubReconnecting;
|
_communicationManager.Connection.Reconnecting += OnHubReconnecting;
|
||||||
_communicationManager.Connection.Closed += OnHubDisconnected;
|
_communicationManager.Connection.Closed += OnHubDisconnected;
|
||||||
_state = new State();
|
_state = State.Instance;
|
||||||
_settings = new Settings();
|
_settings = new Settings();
|
||||||
_vector2Pool = ArrayPool<Vector2>.Create();
|
_vector2Pool = ArrayPool<Vector2>.Create();
|
||||||
_messenger = new TinyMessengerHub();
|
_messenger = new TinyMessengerHub();
|
||||||
|
@ -198,7 +198,7 @@ namespace Sledgemapper
|
||||||
ResetRenderTarget();
|
ResetRenderTarget();
|
||||||
|
|
||||||
|
|
||||||
_mainWidget = new MainWidget(_communicationManager, _state, _settings, _cachedContent, _messenger, Window);
|
_mainWidget = new MainWidget(_communicationManager, _settings, _cachedContent, _messenger, Window);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,44 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Sledgemapper
|
namespace Sledgemapper
|
||||||
{
|
{
|
||||||
public class State
|
public sealed class State
|
||||||
{
|
{
|
||||||
|
private static readonly State instance = new State();
|
||||||
|
|
||||||
|
// Explicit static constructor to tell C# compiler
|
||||||
|
// not to mark type as beforefieldinit
|
||||||
|
static State()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private State()
|
||||||
|
{
|
||||||
|
CurrentTileId = "";
|
||||||
|
CurrentWallId = "";
|
||||||
|
CurrentOverlayId = "";
|
||||||
|
SelectedTile = new() { X = 1, Y = 1 };
|
||||||
|
HoveredTile = new() { X = 1, Y = 1 };
|
||||||
|
SelectedWall = new() { X = 1, Y = 1 };
|
||||||
|
SelectedOverlay = new() { X = 1, Y = 1 };
|
||||||
|
SelectedNote = new() { X = 1, Y = 1 };
|
||||||
|
TileSize = 30;
|
||||||
|
LineWidth = 1;
|
||||||
|
ViewportCenter = new(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static State Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Tile SelectedTile { get; set; }
|
public Tile SelectedTile { get; set; }
|
||||||
public Tile HoveredTile { get; set; }
|
public Tile HoveredTile { get; set; }
|
||||||
public Wall SelectedWall { get; set; }
|
public Wall SelectedWall { get; set; }
|
||||||
|
@ -25,20 +61,20 @@ namespace Sledgemapper
|
||||||
public bool ShowCellNumbers { get; set; }
|
public bool ShowCellNumbers { get; set; }
|
||||||
public Vector3 ViewportCenter { get; set; }
|
public Vector3 ViewportCenter { get; set; }
|
||||||
|
|
||||||
public State()
|
//public State()
|
||||||
{
|
//{
|
||||||
CurrentTileId = "";
|
// CurrentTileId = "";
|
||||||
CurrentWallId = "";
|
// CurrentWallId = "";
|
||||||
CurrentOverlayId = "";
|
// CurrentOverlayId = "";
|
||||||
SelectedTile = new() { X = 1, Y = 1 };
|
// SelectedTile = new() { X = 1, Y = 1 };
|
||||||
HoveredTile = new() { X = 1, Y = 1 };
|
// HoveredTile = new() { X = 1, Y = 1 };
|
||||||
SelectedWall = new() { X = 1, Y = 1 };
|
// SelectedWall = new() { X = 1, Y = 1 };
|
||||||
SelectedOverlay = new() { X = 1, Y = 1 };
|
// SelectedOverlay = new() { X = 1, Y = 1 };
|
||||||
SelectedNote = new() { X = 1, Y = 1 };
|
// SelectedNote = new() { X = 1, Y = 1 };
|
||||||
TileSize = 30;
|
// TileSize = 30;
|
||||||
LineWidth=1;
|
// LineWidth=1;
|
||||||
ViewportCenter = new(0, 0, 0);
|
// ViewportCenter = new(0, 0, 0);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public void SelectClosestWall(Point mousePosition)
|
public void SelectClosestWall(Point mousePosition)
|
||||||
{
|
{
|
||||||
|
|
158
Sledgemapper/UI/CampaignList.Custom.cs
Normal file
158
Sledgemapper/UI/CampaignList.Custom.cs
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
using Exceptionless;
|
||||||
|
using Myra.Graphics2D.Brushes;
|
||||||
|
using Myra.Graphics2D.UI;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TinyMessenger;
|
||||||
|
|
||||||
|
namespace Sledgemapper.UI
|
||||||
|
{
|
||||||
|
public partial class CampaignList
|
||||||
|
{
|
||||||
|
private readonly CommunicationManager CommunicationManager;
|
||||||
|
private readonly Window Window;
|
||||||
|
private readonly TinyMessengerHub Messenger;
|
||||||
|
|
||||||
|
private Settings _settings;
|
||||||
|
|
||||||
|
public CampaignList(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger, Settings settings)
|
||||||
|
{
|
||||||
|
BuildUI();
|
||||||
|
CommunicationManager = communicationManager;
|
||||||
|
Window = window;
|
||||||
|
Messenger = messenger;
|
||||||
|
|
||||||
|
_settings = settings;
|
||||||
|
BtnNewCampaign.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
window.Close();
|
||||||
|
OnMenuCampaignNew(s, e);
|
||||||
|
};
|
||||||
|
|
||||||
|
BtnLoadCampaign.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
if (campaignSelected)
|
||||||
|
{
|
||||||
|
campaignSelected = false;
|
||||||
|
window.Close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BtnCancelCampaign.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
Window.Close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMenuCampaignNew(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is MenuItem && !((MenuItem)sender).Enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Window window = new()
|
||||||
|
{
|
||||||
|
Title = "New campaign"
|
||||||
|
};
|
||||||
|
|
||||||
|
var content = new CampaignWindow();
|
||||||
|
//content.BtnNewCampaign.Text = "N";
|
||||||
|
content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||||
|
window.Content = content;
|
||||||
|
|
||||||
|
window.ShowModal(Desktop);
|
||||||
|
content.TxtCampaign.SetKeyboardFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private bool campaignSelected;
|
||||||
|
|
||||||
|
|
||||||
|
private void OnCampaignSelected(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var item = sender as UI.ListItem;
|
||||||
|
var localContent = item.GetParentContentInWindow<Widget>();
|
||||||
|
State.Instance.CampaignName = item.ItemName.Text;
|
||||||
|
var list = item.Parent as Myra.Graphics2D.UI.Grid;
|
||||||
|
for (var i = 0; i < list.ChildrenCount; i++)
|
||||||
|
{
|
||||||
|
var currentItem = list.GetChild(i) as HorizontalStackPanel;// UI.ListItem;
|
||||||
|
currentItem.Background = new SolidBrush("#D9D9D9FF");
|
||||||
|
}
|
||||||
|
item.Background = new SolidBrush(_settings.OverlayTintColor);
|
||||||
|
campaignSelected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var localContent = ((TextButton)sender).GetParentContentInWindow<CampaignWindow>();// localWindow.Content as PlayerWindow;
|
||||||
|
|
||||||
|
var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (CommunicationManager.Connection.State != HubConnectionState.Connected)
|
||||||
|
//{
|
||||||
|
// lblConnectionStatus.Text = "Connecting";
|
||||||
|
// await CommunicationManager.Connection.StartAsync();
|
||||||
|
// UpdateConnectionState(CommunicationManager.Connection);
|
||||||
|
//}
|
||||||
|
|
||||||
|
var successful = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await CommunicationManager.Api.NewCampaign(localContent.Content.TxtCampaign.Text);
|
||||||
|
|
||||||
|
//if (result)
|
||||||
|
//{
|
||||||
|
// CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
|
// CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||||
|
// CommunicationManager.SessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||||
|
// CommunicationManager.SessionData.MapEntityAdded += OnMapEntityAdded;
|
||||||
|
// CommunicationManager.SessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||||
|
//}
|
||||||
|
//successful = result;
|
||||||
|
//var result2 = await CommunicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||||
|
//CommunicationManager.SessionData.SessionId = result2.SessionId;
|
||||||
|
//CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExceptionlessClient.Default.SubmitException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (successful)
|
||||||
|
//{
|
||||||
|
// //CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
|
// //CommunicationManager.SessionData.Map = CommunicationManager.SessionData.Map;
|
||||||
|
// //CommunicationManager.SessionData.Overlays = CommunicationManager.SessionData.Overlays;
|
||||||
|
// //CommunicationManager.SessionData.Walls = CommunicationManager.SessionData.Walls;
|
||||||
|
// //lblSessionName.Text = CommunicationManager.SessionData.SessionName;
|
||||||
|
// //MenuConnectSync.Enabled = true;
|
||||||
|
// //MenuConnectUpload.Enabled = true;
|
||||||
|
// localWindow.Close();
|
||||||
|
//}
|
||||||
|
|
||||||
|
localContent.Window.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadCampaigns()
|
||||||
|
{
|
||||||
|
var campaigns = await CommunicationManager.Api.GetCampaigns();
|
||||||
|
foreach (var campaign in campaigns)
|
||||||
|
{
|
||||||
|
var item = new UI.ListItem();
|
||||||
|
item.ItemName.Text = campaign.Name;
|
||||||
|
|
||||||
|
item.TouchUp += OnCampaignSelected;
|
||||||
|
StackCampaignsList.AddChild(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
Sledgemapper/UI/CampaignWindow.Custom.cs
Normal file
25
Sledgemapper/UI/CampaignWindow.Custom.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using Myra.Graphics2D.UI;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TinyMessenger;
|
||||||
|
|
||||||
|
namespace Sledgemapper.UI
|
||||||
|
{
|
||||||
|
public partial class CampaignWindow
|
||||||
|
{
|
||||||
|
private readonly CommunicationManager CommunicationManager;
|
||||||
|
private readonly Window Window;
|
||||||
|
private readonly TinyMessengerHub Messenger;
|
||||||
|
|
||||||
|
public CampaignWindow(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger)
|
||||||
|
{
|
||||||
|
BuildUI();
|
||||||
|
CommunicationManager = communicationManager;
|
||||||
|
Window = window;
|
||||||
|
Messenger = messenger;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,24 +20,23 @@ namespace Sledgemapper.UI
|
||||||
{
|
{
|
||||||
public partial class MainWidget
|
public partial class MainWidget
|
||||||
{
|
{
|
||||||
private AuthenticateResponse _authResponse;
|
|
||||||
private readonly CommunicationManager CommunicationManager;
|
private readonly CommunicationManager CommunicationManager;
|
||||||
private State _state;
|
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private readonly TinyMessengerHub _messenger;
|
private readonly TinyMessengerHub _messenger;
|
||||||
|
|
||||||
private readonly CachedContent _cachedContent;
|
private readonly CachedContent _cachedContent;
|
||||||
private readonly GameWindow Window;
|
private readonly GameWindow Window;
|
||||||
|
|
||||||
public MainWidget(CommunicationManager communicationManager, State state, Settings settings, CachedContent cachedContent, TinyMessengerHub messenger, GameWindow window)
|
public MainWidget(CommunicationManager communicationManager, Settings settings, CachedContent cachedContent, TinyMessengerHub messenger, GameWindow window)
|
||||||
{
|
{
|
||||||
BuildUI();
|
BuildUI();
|
||||||
|
|
||||||
CommunicationManager = communicationManager;
|
CommunicationManager = communicationManager;
|
||||||
_state = state;
|
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
_cachedContent = cachedContent;
|
_cachedContent = cachedContent;
|
||||||
|
Window = window;
|
||||||
_messenger = messenger;
|
_messenger = messenger;
|
||||||
MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
|
MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
|
||||||
MenuConnectSync.Selected += OnMenuConnectSyncSelected;
|
MenuConnectSync.Selected += OnMenuConnectSyncSelected;
|
||||||
|
@ -63,6 +62,11 @@ namespace Sledgemapper.UI
|
||||||
MenuConnectJoin.Enabled = false;
|
MenuConnectJoin.Enabled = false;
|
||||||
MenuConnectSync.Enabled = false;
|
MenuConnectSync.Enabled = false;
|
||||||
MenuConnectUpload.Enabled = false;
|
MenuConnectUpload.Enabled = false;
|
||||||
|
MenuCampaignOpen.Enabled = false;
|
||||||
|
MenuCampaignPlayers.Enabled = false;
|
||||||
|
MenuCampaingNew.Enabled = false;
|
||||||
|
MenuMapNew.Enabled = false;
|
||||||
|
MenuMapOpen.Enabled = false;
|
||||||
BtnToolbarLine.Click += OnBtnToolbarLinClicked;
|
BtnToolbarLine.Click += OnBtnToolbarLinClicked;
|
||||||
BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||||
BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||||
|
@ -93,8 +97,11 @@ namespace Sledgemapper.UI
|
||||||
{
|
{
|
||||||
MenuConnectNew.Enabled = true;
|
MenuConnectNew.Enabled = true;
|
||||||
MenuConnectJoin.Enabled = true;
|
MenuConnectJoin.Enabled = true;
|
||||||
|
MenuCampaignOpen.Enabled = true;
|
||||||
|
MenuCampaignPlayers.Enabled = true;
|
||||||
|
MenuCampaingNew.Enabled = true;
|
||||||
|
|
||||||
lblUsername.Text = $"{_authResponse.Username} - {_authResponse.Initials}";
|
lblUsername.Text = $"{obj.UserName} - {obj.Initials}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearSelection()
|
public void ClearSelection()
|
||||||
|
@ -145,7 +152,7 @@ namespace Sledgemapper.UI
|
||||||
Title = "New mapping session"
|
Title = "New mapping session"
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new SessionWindow(CommunicationManager,_messenger,window, _state);
|
var content = new SessionWindow(CommunicationManager, _messenger, window);
|
||||||
window.Content = content;
|
window.Content = content;
|
||||||
|
|
||||||
window.ShowModal(Desktop);
|
window.ShowModal(Desktop);
|
||||||
|
@ -296,7 +303,7 @@ namespace Sledgemapper.UI
|
||||||
|
|
||||||
private void OnMenuViewShowCellNUmbersSelected(object sender, EventArgs e)
|
private void OnMenuViewShowCellNUmbersSelected(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_state.ShowCellNumbers = !_state.ShowCellNumbers;
|
State.Instance.ShowCellNumbers = !State.Instance.ShowCellNumbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMenuViewCenterOnSelectionSelected(object sender, EventArgs e)
|
private void OnMenuViewCenterOnSelectionSelected(object sender, EventArgs e)
|
||||||
|
@ -331,16 +338,16 @@ namespace Sledgemapper.UI
|
||||||
|
|
||||||
private void CenterOnSelectedTile()
|
private void CenterOnSelectedTile()
|
||||||
{
|
{
|
||||||
CenterOnTile(_state.SelectedTile.X, _state.SelectedTile.Y);
|
CenterOnTile(State.Instance.SelectedTile.X, State.Instance.SelectedTile.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CenterOnTile(int x, int y)
|
private void CenterOnTile(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
||||||
var center = new Point((Window.ClientBounds.Width + 200) / 2 - _state.TileSize / 2, Window.ClientBounds.Height / 2 - _state.TileSize / 2);
|
var center = new Point((Window.ClientBounds.Width + 200) / 2 - State.Instance.TileSize / 2, Window.ClientBounds.Height / 2 - State.Instance.TileSize / 2);
|
||||||
var dx = center.X - x * _state.TileSize - _state.ViewportCenter.X;
|
var dx = center.X - x * State.Instance.TileSize - State.Instance.ViewportCenter.X;
|
||||||
var dy = center.Y - y * _state.TileSize - _state.ViewportCenter.Y;
|
var dy = center.Y - y * State.Instance.TileSize - State.Instance.ViewportCenter.Y;
|
||||||
_state.ViewportCenter = new Vector3(_state.ViewportCenter.X + dx, _state.ViewportCenter.Y + dy, _state.ViewportCenter.Z);
|
State.Instance.ViewportCenter = new Vector3(State.Instance.ViewportCenter.X + dx, State.Instance.ViewportCenter.Y + dy, State.Instance.ViewportCenter.Z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,12 +364,12 @@ namespace Sledgemapper.UI
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new CampaignWindow();
|
var content = new CampaignWindow();
|
||||||
//content.BtnNewCampaign.Text = "N";
|
////content.BtnNewCampaign.Text = "N";
|
||||||
content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
//content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||||
window.Content = content;
|
//window.Content = content;
|
||||||
|
|
||||||
window.ShowModal(Desktop);
|
//window.ShowModal(Desktop);
|
||||||
content.TxtCampaign.SetKeyboardFocus();
|
//content.TxtCampaign.SetKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||||
|
@ -377,40 +384,41 @@ namespace Sledgemapper.UI
|
||||||
Title = "Campaigns"
|
Title = "Campaigns"
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new CampaignList();
|
var content = new CampaignList(CommunicationManager, window, _messenger, _settings);
|
||||||
var campaigns = await CommunicationManager.Api.GetCampaigns();
|
await content.LoadCampaigns();
|
||||||
foreach (var campaign in campaigns)
|
//var campaigns = await CommunicationManager.Api.GetCampaigns();
|
||||||
{
|
//foreach (var campaign in campaigns)
|
||||||
var item = new UI.ListItem();
|
//{
|
||||||
item.ItemName.Text = campaign.Name;
|
// var item = new UI.ListItem();
|
||||||
|
// item.ItemName.Text = campaign.Name;
|
||||||
|
|
||||||
item.TouchUp += OnCampaignSelected;
|
// item.TouchUp += OnCampaignSelected;
|
||||||
content.StackCampaignsList.AddChild(item);
|
// content.StackCampaignsList.AddChild(item);
|
||||||
}
|
//}
|
||||||
//content.BtnNewCampaign.Text = "N";
|
//content.BtnNewCampaign.Text = "N";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
content.BtnNewCampaign.Click += (s, e) =>
|
//content.BtnNewCampaign.Click += (s, e) =>
|
||||||
{
|
//{
|
||||||
window.Close();
|
// window.Close();
|
||||||
OnMenuCampaignNew(s, e);
|
// OnMenuCampaignNew(s, e);
|
||||||
};
|
//};
|
||||||
|
|
||||||
content.BtnLoadCampaign.Click += (s, e) =>
|
//content.BtnLoadCampaign.Click += (s, e) =>
|
||||||
{
|
//{
|
||||||
if (campaignSelected)
|
// if (campaignSelected)
|
||||||
{
|
// {
|
||||||
campaignSelected = false;
|
// campaignSelected = false;
|
||||||
window.Close();
|
// window.Close();
|
||||||
}
|
// }
|
||||||
};
|
//};
|
||||||
|
|
||||||
content.BtnCancelCampaign.Click += (s, e) =>
|
//content.BtnCancelCampaign.Click += (s, e) =>
|
||||||
{
|
//{
|
||||||
|
|
||||||
window.Close();
|
// window.Close();
|
||||||
};
|
//};
|
||||||
|
|
||||||
window.Content = content;
|
window.Content = content;
|
||||||
|
|
||||||
|
@ -418,24 +426,6 @@ namespace Sledgemapper.UI
|
||||||
// content.TxtCampaign.SetKeyboardFocus();
|
// content.TxtCampaign.SetKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool campaignSelected;
|
|
||||||
|
|
||||||
|
|
||||||
private void OnCampaignSelected(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var item = sender as UI.ListItem;
|
|
||||||
var localContent = item.GetParentContentInWindow<Widget>();
|
|
||||||
_state.CampaignName = item.ItemName.Text;
|
|
||||||
var list = item.Parent as Myra.Graphics2D.UI.Grid;
|
|
||||||
for (var i = 0; i < list.ChildrenCount; i++)
|
|
||||||
{
|
|
||||||
var currentItem = list.GetChild(i) as HorizontalStackPanel;// UI.ListItem;
|
|
||||||
currentItem.Background = new SolidBrush("#D9D9D9FF");
|
|
||||||
}
|
|
||||||
item.Background = new SolidBrush(_settings.OverlayTintColor);
|
|
||||||
campaignSelected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMapSelected(object sender, EventArgs e)
|
private void OnMapSelected(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var item = sender as UI.ListItem;
|
var item = sender as UI.ListItem;
|
||||||
|
@ -463,7 +453,7 @@ namespace Sledgemapper.UI
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new PlayerList();
|
var content = new PlayerList();
|
||||||
var players = await CommunicationManager.Api.GetPlayers(_state.CampaignName);
|
var players = await CommunicationManager.Api.GetPlayers(State.Instance.CampaignName);
|
||||||
foreach (var player in players)
|
foreach (var player in players)
|
||||||
{
|
{
|
||||||
var item = new UI.ListItem();
|
var item = new UI.ListItem();
|
||||||
|
@ -500,7 +490,7 @@ namespace Sledgemapper.UI
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = new MapList();
|
var content = new MapList();
|
||||||
var campaigns = await CommunicationManager.Api.GetMaps(_state.CampaignName);
|
var campaigns = await CommunicationManager.Api.GetMaps(State.Instance.CampaignName);
|
||||||
foreach (var campaign in campaigns)
|
foreach (var campaign in campaigns)
|
||||||
{
|
{
|
||||||
var item = new UI.ListItem();
|
var item = new UI.ListItem();
|
||||||
|
@ -610,7 +600,7 @@ namespace Sledgemapper.UI
|
||||||
var successful = false;
|
var successful = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await CommunicationManager.Api.InvitePlayer(_state.CampaignName, localContent.Content.TxtCampaign.Text);
|
await CommunicationManager.Api.InvitePlayer(State.Instance.CampaignName, localContent.Content.TxtCampaign.Text);
|
||||||
|
|
||||||
//if (result)
|
//if (result)
|
||||||
//{
|
//{
|
||||||
|
@ -646,64 +636,64 @@ namespace Sledgemapper.UI
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
//private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||||
{
|
|
||||||
var localContent = ((TextButton)sender).GetParentContentInWindow<CampaignWindow>();// localWindow.Content as PlayerWindow;
|
|
||||||
|
|
||||||
var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
|
|
||||||
if (!isValid)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (CommunicationManager.Connection.State != HubConnectionState.Connected)
|
|
||||||
//{
|
//{
|
||||||
// lblConnectionStatus.Text = "Connecting";
|
// var localContent = ((TextButton)sender).GetParentContentInWindow<CampaignWindow>();// localWindow.Content as PlayerWindow;
|
||||||
// await CommunicationManager.Connection.StartAsync();
|
|
||||||
// UpdateConnectionState(CommunicationManager.Connection);
|
// var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
|
||||||
|
// if (!isValid)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var successful = false;
|
// //if (CommunicationManager.Connection.State != HubConnectionState.Connected)
|
||||||
try
|
// //{
|
||||||
{
|
// // lblConnectionStatus.Text = "Connecting";
|
||||||
await CommunicationManager.Api.NewCampaign(localContent.Content.TxtCampaign.Text);
|
// // await CommunicationManager.Connection.StartAsync();
|
||||||
|
// // UpdateConnectionState(CommunicationManager.Connection);
|
||||||
|
// //}
|
||||||
|
|
||||||
//if (result)
|
// var successful = false;
|
||||||
|
// try
|
||||||
// {
|
// {
|
||||||
// CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
// await CommunicationManager.Api.NewCampaign(localContent.Content.TxtCampaign.Text);
|
||||||
// CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
|
||||||
// CommunicationManager.SessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
|
||||||
// CommunicationManager.SessionData.MapEntityAdded += OnMapEntityAdded;
|
|
||||||
// CommunicationManager.SessionData.MapEntityDeleted += OnMapEntityDeleted;
|
|
||||||
//}
|
|
||||||
//successful = result;
|
|
||||||
//var result2 = await CommunicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
|
||||||
//CommunicationManager.SessionData.SessionId = result2.SessionId;
|
|
||||||
//CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ExceptionlessClient.Default.SubmitException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (successful)
|
// //if (result)
|
||||||
//{
|
// //{
|
||||||
// // CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
// // CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
// //CommunicationManager.SessionData.Map = CommunicationManager.SessionData.Map;
|
// // CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||||
// //CommunicationManager.SessionData.Overlays = CommunicationManager.SessionData.Overlays;
|
// // CommunicationManager.SessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||||
// //CommunicationManager.SessionData.Walls = CommunicationManager.SessionData.Walls;
|
// // CommunicationManager.SessionData.MapEntityAdded += OnMapEntityAdded;
|
||||||
// //lblSessionName.Text = CommunicationManager.SessionData.SessionName;
|
// // CommunicationManager.SessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||||
// //MenuConnectSync.Enabled = true;
|
// //}
|
||||||
// //MenuConnectUpload.Enabled = true;
|
// //successful = result;
|
||||||
// localWindow.Close();
|
// //var result2 = await CommunicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||||
|
// //CommunicationManager.SessionData.SessionId = result2.SessionId;
|
||||||
|
// //CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// ExceptionlessClient.Default.SubmitException(ex);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
localContent.Window.Close();
|
// //if (successful)
|
||||||
|
// //{
|
||||||
|
// // //CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
||||||
|
// // //CommunicationManager.SessionData.Map = CommunicationManager.SessionData.Map;
|
||||||
|
// // //CommunicationManager.SessionData.Overlays = CommunicationManager.SessionData.Overlays;
|
||||||
|
// // //CommunicationManager.SessionData.Walls = CommunicationManager.SessionData.Walls;
|
||||||
|
// // //lblSessionName.Text = CommunicationManager.SessionData.SessionName;
|
||||||
|
// // //MenuConnectSync.Enabled = true;
|
||||||
|
// // //MenuConnectUpload.Enabled = true;
|
||||||
|
// // localWindow.Close();
|
||||||
|
// //}
|
||||||
|
|
||||||
}
|
// localContent.Window.Close();
|
||||||
|
|
||||||
|
//}
|
||||||
private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
|
private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_state.InsertMode = InsertMode.NewRoom;
|
State.Instance.InsertMode = InsertMode.NewRoom;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||||
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||||
|
@ -712,7 +702,7 @@ namespace Sledgemapper.UI
|
||||||
|
|
||||||
private void OnBtnToolbarLinClicked(object sender, EventArgs e)
|
private void OnBtnToolbarLinClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_state.InsertMode = InsertMode.NewLine;
|
State.Instance.InsertMode = InsertMode.NewLine;
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||||
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||||
|
@ -720,7 +710,7 @@ namespace Sledgemapper.UI
|
||||||
|
|
||||||
private void OnBtnToolbarDeleteClicked(object sender, EventArgs e)
|
private void OnBtnToolbarDeleteClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_state.InsertMode = InsertMode.NewDelete;
|
State.Instance.InsertMode = InsertMode.NewDelete;
|
||||||
|
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||||
|
@ -773,7 +763,7 @@ namespace Sledgemapper.UI
|
||||||
var successful = false;
|
var successful = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await CommunicationManager.Api.NewSession(_state.CampaignName, localContent.TxtCampaign.Text);
|
await CommunicationManager.Api.NewSession(State.Instance.CampaignName, localContent.TxtCampaign.Text);
|
||||||
|
|
||||||
//if (result)
|
//if (result)
|
||||||
//{
|
//{
|
||||||
|
@ -811,7 +801,7 @@ namespace Sledgemapper.UI
|
||||||
//TODO Refactor
|
//TODO Refactor
|
||||||
private void EditNote(Note note)
|
private void EditNote(Note note)
|
||||||
{
|
{
|
||||||
_state.SelectedNote = new Note { X = note.X, Y = note.Y, Text = note.Text };
|
State.Instance.SelectedNote = new Note { X = note.X, Y = note.Y, Text = note.Text };
|
||||||
var noteWindow = new NoteWindow();
|
var noteWindow = new NoteWindow();
|
||||||
|
|
||||||
Window window = new()
|
Window window = new()
|
||||||
|
@ -833,8 +823,8 @@ namespace Sledgemapper.UI
|
||||||
var localContent = button.GetParentContentInWindow<NoteWindow>();
|
var localContent = button.GetParentContentInWindow<NoteWindow>();
|
||||||
var note = new Note
|
var note = new Note
|
||||||
{
|
{
|
||||||
X = _state.SelectedNote.X,
|
X = State.Instance.SelectedNote.X,
|
||||||
Y = _state.SelectedNote.Y,
|
Y = State.Instance.SelectedNote.Y,
|
||||||
Text = localContent.Content.NoteText.Text
|
Text = localContent.Content.NoteText.Text
|
||||||
};
|
};
|
||||||
CommunicationManager.SessionData.NewNote(note);
|
CommunicationManager.SessionData.NewNote(note);
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace Sledgemapper.UI
|
||||||
private readonly CommunicationManager CommunicationManager;
|
private readonly CommunicationManager CommunicationManager;
|
||||||
private readonly Window Window;
|
private readonly Window Window;
|
||||||
private readonly TinyMessengerHub Messenger;
|
private readonly TinyMessengerHub Messenger;
|
||||||
private readonly State State;
|
|
||||||
|
|
||||||
public SessionWindow(CommunicationManager communicationManager, TinyMessengerHub messenger, Window window, State state)
|
|
||||||
|
public SessionWindow(CommunicationManager communicationManager, TinyMessengerHub messenger, Window window)
|
||||||
{
|
{
|
||||||
BuildUI();
|
BuildUI();
|
||||||
CommunicationManager = communicationManager;
|
CommunicationManager = communicationManager;
|
||||||
Messenger = messenger;
|
Messenger = messenger;
|
||||||
State=state;
|
Window = window;
|
||||||
BtnLogin.Text = "Join";
|
BtnLogin.Text = "Join";
|
||||||
BtnLogin.Click += OnButtonNewSessionClicked;
|
BtnLogin.Click += OnButtonNewSessionClicked;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace Sledgemapper.UI
|
||||||
var successful = false;
|
var successful = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await CommunicationManager.Api.NewSession(State.CampaignName, localContent.Content.TxtSession.Text);
|
var result = await CommunicationManager.Api.NewSession(State.Instance.CampaignName, localContent.Content.TxtSession.Text);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue