This commit is contained in:
parent
9c688d363f
commit
3b505141e6
15
Sledgemapper/CachedContent.cs
Normal file
15
Sledgemapper/CachedContent.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
public class CachedContent
|
||||
{
|
||||
public Texture2D Eye { get; set; }
|
||||
public Texture2D Location { get; set; }
|
||||
}
|
||||
}
|
@ -35,19 +35,16 @@ namespace Sledgemapper
|
||||
private readonly State _state;
|
||||
private readonly GraphicsDeviceManager _graphics;
|
||||
private SpriteBatch _spriteBatch;
|
||||
private CachedContent _cachedContent;
|
||||
private readonly Desktop _desktop;
|
||||
private KeyboardState oldState;
|
||||
private MouseState oldMouseState;
|
||||
//private Vector3 _state.ViewportCenter = new(0, 0, 0);
|
||||
private bool _isDraggin;
|
||||
private Dictionary<string, SpriteFont> _fonts;
|
||||
//private Texture2D _eye;
|
||||
//private Texture2D _location;
|
||||
private Texture2D _comment;
|
||||
private readonly Session _sessionData;
|
||||
private RenderTarget2D rendertarget;
|
||||
private MainWidget _mainWidget;
|
||||
//private bool _state.ShowCellNumbers;
|
||||
private readonly Settings _settings;
|
||||
|
||||
public Sledgemapper()
|
||||
@ -193,40 +190,15 @@ namespace Sledgemapper
|
||||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
_cachedContent = new CachedContent();
|
||||
|
||||
outlineShader = Content.Load<Effect>("shaders/OutlineShader");
|
||||
MyraEnvironment.Game = this;
|
||||
ResetRenderTarget();
|
||||
|
||||
_mainWidget = new MainWidget(_communicationManager, _state, _settings);
|
||||
_mainWidget = new MainWidget(_communicationManager, _state, _settings, _cachedContent, Window);
|
||||
|
||||
//_mainWidget = new MainWidget();
|
||||
|
||||
//_mainWidget.MenuConnectSync.Selected += OnMenuConnectSyncSelected;
|
||||
//_mainWidget.MenuFileLoad.Selected += OnMenuFileLoadSelected;
|
||||
//_mainWidget.MenuFileSave.Selected += OnMenuFileSaveSelected;
|
||||
//_mainWidget.MenuFileSettings.Selected += OneMenuFileSettingsSelected;
|
||||
////_mainWidget.MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
|
||||
////_mainWidget.MenuConnectNew.Selected += OnMenuConnectNewSelected;
|
||||
//_mainWidget.MenuConnectJoin.Selected += OnMenuConnectJoinSelected;
|
||||
//_mainWidget.MenuConnectUpload.Selected += OnMenuConnectUploadSelected;
|
||||
//_mainWidget.MenuViewCenterOnSelection.Selected += OnMenuViewCenterOnSelectionSelected;
|
||||
//_mainWidget.MenuViewShowCellNUmbers.Selected += OnMenuViewShowCellNUmbersSelected;
|
||||
//_mainWidget.MenuViewShowNotes.Selected += OnMenuViewNotesSelected;
|
||||
|
||||
//_mainWidget.MenuCampaingNew.Selected += OnMenuCampaignNew;
|
||||
//_mainWidget.MenuCampaignOpen.Selected += OnMenuCampaignOpen;
|
||||
//_mainWidget.MenuCampaignPlayers.Selected += OnMenuCampaignPlayersSelected;
|
||||
|
||||
//_mainWidget.MenuMapOpen.Selected += OnMenuMapOpen;
|
||||
//_mainWidget.MenuMapNew.Selected += OnMenuMapNew;
|
||||
|
||||
//_mainWidget.MenuConnectNew.Enabled = false;
|
||||
//_mainWidget.MenuConnectJoin.Enabled = false;
|
||||
//_mainWidget.MenuConnectSync.Enabled = false;
|
||||
//_mainWidget.MenuConnectUpload.Enabled = false;
|
||||
//_mainWidget.BtnToolbarLine.Click += OnBtnToolbarLinClicked;
|
||||
//_mainWidget.BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||
//_mainWidget.BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||
|
||||
|
||||
_wallsContent = Content.LoadContentFolder<Texture2D>("walls");
|
||||
@ -244,8 +216,8 @@ namespace Sledgemapper
|
||||
AddItemToToolGrid(_mainWidget.GridOverlays, OnOverlayButtonClicked, _spriteSheet);
|
||||
|
||||
_fonts = Content.LoadContentFolder<SpriteFont>("fonts");
|
||||
//_eye = Content.Load<Texture2D>("eye");
|
||||
//_location = Content.Load<Texture2D>("location");
|
||||
_cachedContent.Eye = Content.Load<Texture2D>("eye");
|
||||
_cachedContent.Location = Content.Load<Texture2D>("location");
|
||||
_comment = Content.Load<Texture2D>("comment");
|
||||
_mainWidget.BtnToolbarLine.Image = new TextureRegion(Content.Load<Texture2D>("icon_line"));
|
||||
_mainWidget.BtnToolbarRoom.Image = new TextureRegion(Content.Load<Texture2D>("icon_room"));
|
||||
@ -261,379 +233,12 @@ 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)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "Maps"
|
||||
// };
|
||||
|
||||
// var content = new MapList();
|
||||
// var campaigns = await _communicationManager.Api.GetMaps(_state.CampaignName);
|
||||
// foreach (var campaign in campaigns)
|
||||
// {
|
||||
// var item = new UI.ListItem();
|
||||
// item.ItemName.Text = campaign.SessionName;
|
||||
// item.TouchUp += OnMapSelected;
|
||||
// content.StackCampaignsList.AddChild(item);
|
||||
// }
|
||||
// //content.BtnNewCampaign.Text = "N";
|
||||
|
||||
|
||||
|
||||
// content.BtnNewCampaign.Click += (s, e) =>
|
||||
// {
|
||||
// window.Close();
|
||||
// OnMenuMapNew(s, e);
|
||||
// };
|
||||
|
||||
// window.Content = content;
|
||||
|
||||
// window.ShowModal(_desktop);
|
||||
// // content.TxtCampaign.SetKeyboardFocus();
|
||||
//}
|
||||
|
||||
//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 UI.ListItem();
|
||||
// item.ItemName.Text = player.UserName;
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
//private void OnBtnToolbarDeleteClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.InsertMode = InsertMode.NewDelete;
|
||||
|
||||
// _mainWidget.ClearSelection();
|
||||
// ((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||
// ((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
//}
|
||||
|
||||
//private void OnBtnToolbarWallClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.InsertMode = InsertMode.NewWall;
|
||||
// _mainWidget.ClearSelection();
|
||||
// ((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||
// ((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
//}
|
||||
|
||||
//private void OnBtnToolbarTileClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.InsertMode = InsertMode.NewTile;
|
||||
// _mainWidget.ClearSelection();
|
||||
// ((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||
// ((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
//}
|
||||
|
||||
//private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.InsertMode = InsertMode.NewRoom;
|
||||
// _mainWidget.ClearSelection();
|
||||
// ((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||
// ((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
|
||||
//}
|
||||
|
||||
//private void OnBtnToolbarLinClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.InsertMode = InsertMode.NewLine;
|
||||
// _mainWidget.ClearSelection();
|
||||
// ((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
|
||||
// ((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
//}
|
||||
|
||||
//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 async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
//{
|
||||
// if (!((MenuItem)sender).Enabled)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "Campaigns"
|
||||
// };
|
||||
|
||||
// var content = new CampaignList();
|
||||
// var campaigns = await _communicationManager.Api.GetCampaigns();
|
||||
// foreach (var campaign in campaigns)
|
||||
// {
|
||||
// var item = new UI.ListItem();
|
||||
// item.ItemName.Text = campaign.Name;
|
||||
|
||||
// item.TouchUp += OnCampaignSelected;
|
||||
// content.StackCampaignsList.AddChild(item);
|
||||
// }
|
||||
// //content.BtnNewCampaign.Text = "N";
|
||||
|
||||
|
||||
|
||||
// content.BtnNewCampaign.Click += (s, e) =>
|
||||
// {
|
||||
// window.Close();
|
||||
// OnMenuCampaignNew(s, e);
|
||||
// };
|
||||
|
||||
// content.BtnLoadCampaign.Click += (s, e) =>
|
||||
// {
|
||||
// if (campaignSelected)
|
||||
// {
|
||||
// campaignSelected = false;
|
||||
// window.Close();
|
||||
// }
|
||||
// };
|
||||
|
||||
// content.BtnCancelCampaign.Click += (s, e) =>
|
||||
// {
|
||||
|
||||
// window.Close();
|
||||
// };
|
||||
|
||||
// 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 = GetParentContentInWindow<Widget>(item);
|
||||
// _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)
|
||||
//{
|
||||
// var item = sender as UI.ListItem;
|
||||
// var localContent = GetParentContentInWindow<Widget>(item);
|
||||
|
||||
// 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);
|
||||
//}
|
||||
|
||||
//private void OneMenuFileSettingsSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// var propertyGrid = new PropertyGrid
|
||||
// {
|
||||
// Object = _settings,
|
||||
// Width = 350
|
||||
// };
|
||||
|
||||
// var _windowEditor = new Window
|
||||
// {
|
||||
// Title = "Object Editor",
|
||||
// Content = propertyGrid
|
||||
// };
|
||||
// _windowEditor.ShowModal(_desktop);
|
||||
//}
|
||||
|
||||
//private void OnMenuViewShowCellNUmbersSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// _state.ShowCellNumbers = !_state.ShowCellNumbers;
|
||||
//}
|
||||
|
||||
//private void OnMenuViewCenterOnSelectionSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// CenterOnSelectedTile();
|
||||
//}
|
||||
|
||||
//private void OnMenuViewNotesSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "Notes"
|
||||
// };
|
||||
|
||||
// var content = new NoteList();
|
||||
|
||||
// for (var i = 0; i < _sessionData.Notes.Values.Count; i++)
|
||||
// {
|
||||
// var note = _sessionData.Notes.Values.ElementAt(i);
|
||||
// var item = new NoteListItem();
|
||||
// item.LblNoteText.Text = $"{note.ToString()} - {note.Text}";
|
||||
// item.BtnNoteCenter.Image = new TextureRegion(_location);
|
||||
// item.BtnNoteView.Image = new TextureRegion(_eye);
|
||||
// item.BtnNoteCenter.Click += (s, e) => { CenterOnTile(note.X, note.Y); };
|
||||
// item.BtnNoteView.Click += (s, e) => { EditNote(note); window.Close(); };
|
||||
// content.StackNotesList.AddChild(item);
|
||||
// }
|
||||
|
||||
// window.Content = content;
|
||||
// window.ShowModal(_desktop);
|
||||
//}
|
||||
|
||||
private void EditNote(Note note)
|
||||
{
|
||||
@ -951,8 +556,15 @@ namespace Sledgemapper
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
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 dx = center.X - x * _state.TileSize - _state.ViewportCenter.X;
|
||||
var dy = center.Y - y * _state.TileSize - _state.ViewportCenter.Y;
|
||||
_state.ViewportCenter = new Vector3(_state.ViewportCenter.X + dx, _state.ViewportCenter.Y + dy, _state.ViewportCenter.Z);
|
||||
}
|
||||
|
||||
|
||||
private void OnContextMenuPingClick(object sender, EventArgs e, Tile location)
|
||||
{
|
||||
_desktop.HideContextMenu();
|
||||
@ -2119,220 +1731,7 @@ namespace Sledgemapper
|
||||
}
|
||||
}
|
||||
|
||||
//private async void OnButtonJoinSessionClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// var localContent = GetParentContentInWindow<SessionWindow>(((TextButton)sender));
|
||||
|
||||
// var isValid = ValidateTextbox(localContent.Content.TxtSession);
|
||||
// if (!isValid)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (_communicationManager.Connection.State != HubConnectionState.Connected)
|
||||
// {
|
||||
// _mainWidget.lblConnectionStatus.Text = "Connecting";
|
||||
// await _communicationManager.Connection.StartAsync();
|
||||
// UpdateConnectionState(_communicationManager.Connection);
|
||||
// }
|
||||
|
||||
// var successful = false;
|
||||
// try
|
||||
// {
|
||||
// var result = await _communicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.Content.TxtSession.Text);
|
||||
// if (result != null)
|
||||
// {
|
||||
// _sessionData.Map = result.Map;
|
||||
// _sessionData.Walls = result.Walls;
|
||||
// _sessionData.Overlays = result.Overlays;
|
||||
|
||||
// _sessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
// _sessionData.MapEntityAdded += OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||
// _sessionData.SessionId = result.SessionId;
|
||||
// _sessionData.SessionName = result.SessionName;
|
||||
// }
|
||||
// successful = result != null;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message);
|
||||
// }
|
||||
|
||||
// if (successful)
|
||||
// {
|
||||
// _sessionData.SessionName = localContent.Content.TxtSession.Text;
|
||||
// _mainWidget.lblSessionName.Text = _sessionData.SessionName;
|
||||
// _mainWidget.MenuConnectSync.Enabled = true;
|
||||
// _mainWidget.MenuConnectUpload.Enabled = true;
|
||||
// localContent.Window.Close();
|
||||
// }
|
||||
//}
|
||||
|
||||
//private async void OnButtonInvitePlayerClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// var localContent = GetParentContentInWindow<PlayerWindow>(((TextButton)sender));// localWindow.Content as PlayerWindow;
|
||||
// var isValid = ValidateTextbox(localContent.Content.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.InvitePlayer(_state.CampaignName, localContent.Content.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();
|
||||
// //}
|
||||
|
||||
// localContent.Window.Close();
|
||||
|
||||
//}
|
||||
|
||||
//private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// var localContent = GetParentContentInWindow<CampaignWindow>(((TextButton)sender));// localWindow.Content as PlayerWindow;
|
||||
|
||||
// var isValid = ValidateTextbox(localContent.Content.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.Content.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();
|
||||
// //}
|
||||
|
||||
// localContent.Window.Close();
|
||||
|
||||
//}
|
||||
|
||||
//private async void OnButtonNewSessionClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// var localContent = GetParentContentInWindow<SessionWindow>(((TextButton)sender));// localWindow.Content as PlayerWindow;
|
||||
|
||||
// var isValid = ValidateTextbox(localContent.Content.TxtSession);
|
||||
// if (!isValid)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (_communicationManager.Connection.State != HubConnectionState.Connected)
|
||||
// {
|
||||
// _mainWidget.lblConnectionStatus.Text = "Connecting";
|
||||
// await _communicationManager.Connection.StartAsync();
|
||||
// UpdateConnectionState(_communicationManager.Connection);
|
||||
// }
|
||||
|
||||
// var successful = false;
|
||||
// try
|
||||
// {
|
||||
// var result = await _communicationManager.Api.NewSession(_state.CampaignName, localContent.Content.TxtSession.Text);
|
||||
|
||||
// if (result)
|
||||
// {
|
||||
// _sessionData.SessionName = localContent.Content.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.Content.TxtSession.Text);
|
||||
// _sessionData.SessionId = result2.SessionId;
|
||||
// _sessionData.SessionName = localContent.Content.TxtSession.Text;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// ExceptionlessClient.Default.SubmitException(ex);
|
||||
// }
|
||||
|
||||
// if (successful)
|
||||
// {
|
||||
// _sessionData.SessionName = localContent.Content.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;
|
||||
// localContent.Window.Close();
|
||||
// }
|
||||
//}
|
||||
|
||||
private void UpdateConnectionState(HubConnection connection)
|
||||
{
|
||||
@ -2388,161 +1787,7 @@ namespace Sledgemapper
|
||||
var content = GetParentContentInWindow<Widget>(button);
|
||||
content.Window.Close();
|
||||
}
|
||||
//private async void OnButtonLoginClick(object sender, EventArgs e)
|
||||
//{
|
||||
// var button = ((TextButton)sender);
|
||||
// Container container = button.Parent;
|
||||
// while (!(container is Window))
|
||||
// {
|
||||
// container = container.Parent;
|
||||
// }
|
||||
|
||||
// var localWindow = (Window)container;
|
||||
// var localContent = localWindow.Content as LoginRegisterWindow;
|
||||
|
||||
// if (!button.Enabled)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var isValid = true;
|
||||
// isValid &= ValidateTextbox(localContent.TxtEmail);
|
||||
// isValid &= ValidateTextbox(localContent.TxtPassword);
|
||||
|
||||
// if (!isValid)
|
||||
// {
|
||||
// localContent.LblLoginError.Text = "Username or password is not valid";
|
||||
// localContent.LblLoginError.Visible = true;
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var successful = false;
|
||||
// try
|
||||
// {
|
||||
// button.Text = "Wait...";
|
||||
// localContent.LblLoginError.Text = "";
|
||||
// localContent.LblLoginError.Visible = false;
|
||||
// _authResponse = await _communicationManager.Login(new AuthenticateModel
|
||||
// {
|
||||
// Username = localContent.TxtEmail.Text,
|
||||
// Email = localContent.TxtEmail.Text,
|
||||
// Password = localContent.TxtPassword.Text
|
||||
// });
|
||||
// successful = _authResponse != null;
|
||||
// }
|
||||
// catch (Refit.ApiException refitException)
|
||||
// {
|
||||
// ExceptionlessClient.Default.SubmitException(refitException);
|
||||
// localContent.LblLoginError.Text = refitException.Content;
|
||||
// localContent.LblLoginError.Visible = true;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// ExceptionlessClient.Default.SubmitException(ex);
|
||||
// localContent.LblLoginError.Text = "Can't connect to the server";
|
||||
// localContent.LblLoginError.Visible = true;
|
||||
// Debug.Write(ex);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// button.Enabled = true;
|
||||
// button.Text = "Login";
|
||||
// }
|
||||
|
||||
// if (successful)
|
||||
// {
|
||||
// _mainWidget.MenuConnectNew.Enabled = true;
|
||||
// _mainWidget.MenuConnectJoin.Enabled = true;
|
||||
// _mainWidget.lblUsername.Text = $"{_authResponse.Username} - {_authResponse.Initials}";
|
||||
// localWindow.Close();
|
||||
// }
|
||||
//}
|
||||
|
||||
//private async void OnButtonRegisterClick(object sender, EventArgs e)
|
||||
//{
|
||||
// var button = ((TextButton)sender);
|
||||
|
||||
// var localContent = GetParentContentInWindow<LoginRegisterWindow>(button);// localWindow.Content as PlayerWindow;
|
||||
|
||||
// if (!button.Enabled)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var isValid = true;
|
||||
// isValid &= ValidateTextbox(localContent.Content.TxtEmail);
|
||||
// isValid &= ValidateTextbox(localContent.Content.TxtPassword);
|
||||
// isValid &= ValidateTextbox(localContent.Content.TxtFirstname);
|
||||
// isValid &= ValidateTextbox(localContent.Content.TxtLastname);
|
||||
// isValid &= ValidateTextbox(localContent.Content.TxtInitials);
|
||||
|
||||
// if (!isValid)
|
||||
// {
|
||||
// localContent.Content.LblLoginError.Text = "Please complete all the fields";
|
||||
// localContent.Content.LblLoginError.Visible = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var successful = false;
|
||||
// try
|
||||
// {
|
||||
// button.Text = "Wait...";
|
||||
// localContent.Content.LblLoginError.Text = "";
|
||||
// localContent.Content.LblLoginError.Visible = false;
|
||||
|
||||
// var result = await _communicationManager.Register(new RegisterModel
|
||||
// {
|
||||
// Username = localContent.Content.TxtEmail.Text,
|
||||
// Email = localContent.Content.TxtEmail.Text,
|
||||
// Password = localContent.Content.TxtPassword.Text,
|
||||
// FirstName = localContent.Content.TxtFirstname.Text,
|
||||
// LastName = localContent.Content.TxtLastname.Text,
|
||||
// Initials = localContent.Content.TxtInitials.Text
|
||||
// });
|
||||
// if (result.Result)
|
||||
// {
|
||||
// _authResponse = await _communicationManager.Login(new AuthenticateModel
|
||||
// {
|
||||
// Username = localContent.Content.TxtEmail.Text,
|
||||
// Password = localContent.Content.TxtPassword.Text
|
||||
// });
|
||||
// successful = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// localContent.Content.LblLoginError.Text = result.Errors.FirstOrDefault();
|
||||
// localContent.Content.LblLoginError.Visible = true;
|
||||
// }
|
||||
// }
|
||||
// catch (Refit.ApiException refitException)
|
||||
// {
|
||||
// ExceptionlessClient.Default.SubmitException(refitException);
|
||||
// localContent.Content.LblLoginError.Text = refitException.Content;
|
||||
// localContent.Content.LblLoginError.Visible = true;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// ExceptionlessClient.Default.SubmitException(ex);
|
||||
// localContent.Content.LblLoginError.Text = "Can't connect to the server";
|
||||
// localContent.Content.LblLoginError.Visible = true;
|
||||
// Debug.Write(ex);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// button.Enabled = true;
|
||||
// button.Text = "Register";
|
||||
// }
|
||||
// if (successful)
|
||||
// {
|
||||
// _mainWidget.MenuConnectNew.Enabled = true;
|
||||
// _mainWidget.MenuConnectJoin.Enabled = true;
|
||||
|
||||
// _mainWidget.lblUsername.Text = $"{_authResponse.Username} - {_authResponse.Initials}";
|
||||
|
||||
// localContent.Window.Close();
|
||||
// }
|
||||
//}
|
||||
|
||||
private void OnContextMenuNewNoteClick(object sender, EventArgs e)
|
||||
{
|
||||
@ -2593,76 +1838,7 @@ namespace Sledgemapper
|
||||
_state.InsertMode = InsertMode.Wall;
|
||||
}
|
||||
|
||||
//private void OnMenuConnectJoinSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// if (!((MenuItem)sender).Enabled)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "Join mapping session"
|
||||
// };
|
||||
|
||||
// var content = new SessionWindow();
|
||||
// content.BtnLogin.Text = "Join";
|
||||
// content.BtnLogin.Click += OnButtonJoinSessionClicked;
|
||||
|
||||
// window.Content = content;
|
||||
|
||||
// window.ShowModal(_desktop);
|
||||
// content.TxtSession.SetKeyboardFocus();
|
||||
//}
|
||||
|
||||
// private void OnMenuConnectLoginSelected(object sender, EventArgs e)
|
||||
// {
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "Login"
|
||||
// };
|
||||
|
||||
// var content = new LoginRegisterWindow();
|
||||
|
||||
//#if DEBUG
|
||||
// content.TxtEmail.Text = "michele.scandura@outlook.com";
|
||||
// content.TxtPassword.Text = "slePharland!79";
|
||||
//#endif
|
||||
|
||||
// content.RdoLogin.IsPressed = true;
|
||||
// content.RdoLogin.Click += (s, e) =>
|
||||
// {
|
||||
// content.TxtFirstname.Visible = false;
|
||||
// content.TxtLastname.Visible = false;
|
||||
// content.TxtInitials.Visible = false;
|
||||
// content.LblFirstname.Visible = false;
|
||||
// content.LblLastname.Visible = false;
|
||||
// content.LblInitials.Visible = false;
|
||||
// content.BtnLogin.Visible = true;
|
||||
// content.BtnRegister.Visible = false;
|
||||
// window.Title = "Login";
|
||||
// };
|
||||
|
||||
// content.RdoRegister.Click += (s, e) =>
|
||||
// {
|
||||
// content.TxtFirstname.Visible = true;
|
||||
// content.TxtLastname.Visible = true;
|
||||
// content.TxtInitials.Visible = true;
|
||||
// content.LblFirstname.Visible = true;
|
||||
// content.LblLastname.Visible = true;
|
||||
// content.LblInitials.Visible = true;
|
||||
// content.BtnLogin.Visible = false;
|
||||
// content.BtnRegister.Visible = true;
|
||||
// window.Title = "Register";
|
||||
// };
|
||||
|
||||
// content.BtnRegister.Click += OnButtonRegisterClick;
|
||||
// content.BtnLogin.Click += OnButtonLoginClick;
|
||||
|
||||
// window.Content = content;
|
||||
// window.ShowModal(_desktop);
|
||||
// content.TxtEmail.SetKeyboardFocus();
|
||||
// }
|
||||
|
||||
private async void OnMenuConnectSyncSelected(object sender, EventArgs e)
|
||||
{
|
||||
@ -2690,74 +1866,7 @@ namespace Sledgemapper
|
||||
await _communicationManager.Api.SaveSnapshot(_sessionData, _sessionData.SessionName);
|
||||
}
|
||||
|
||||
//private void OnMenuConnectNewSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// if (!((MenuItem)sender).Enabled)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Window window = new()
|
||||
// {
|
||||
// Title = "New mapping session"
|
||||
// };
|
||||
|
||||
// var content = new SessionWindow();
|
||||
// content.BtnLogin.Text = "Join";
|
||||
// content.BtnLogin.Click += OnButtonNewSessionClicked;
|
||||
// window.Content = content;
|
||||
|
||||
// window.ShowModal(_desktop);
|
||||
// content.TxtSession.SetKeyboardFocus();
|
||||
//}
|
||||
|
||||
//private void OnMenuFileSaveSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// FileDialog dialog = new(FileDialogMode.SaveFile)
|
||||
// {
|
||||
// Filter = "*.map"
|
||||
// };
|
||||
|
||||
// dialog.Closed += (s, a) =>
|
||||
// {
|
||||
// if (!dialog.Result)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// using StreamWriter file = File.CreateText(dialog.FilePath);
|
||||
// JsonSerializer serializer = new();
|
||||
// serializer.Serialize(file, _sessionData);
|
||||
// };
|
||||
|
||||
// dialog.ShowModal(_desktop);
|
||||
//}
|
||||
|
||||
//private void OnMenuFileLoadSelected(object sender, EventArgs e)
|
||||
//{
|
||||
// var dialog = new FileDialog(FileDialogMode.OpenFile)
|
||||
// {
|
||||
// Filter = "*.map"
|
||||
// };
|
||||
|
||||
// dialog.Closed += (s, a) =>
|
||||
// {
|
||||
// if (!dialog.Result)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// using StreamReader file = File.OpenText(dialog.FilePath);
|
||||
// JsonSerializer serializer = new();
|
||||
// var loadData = (Session)serializer.Deserialize(file, typeof(Session));
|
||||
// _sessionData.Map = loadData.Map;
|
||||
// _sessionData.Overlays = loadData.Overlays;
|
||||
// _sessionData.Walls = loadData.Walls;
|
||||
// _sessionData.Rooms = loadData.Rooms;
|
||||
// _sessionData.Lines = loadData.Lines;
|
||||
// };
|
||||
|
||||
// dialog.ShowModal(_desktop);
|
||||
//}
|
||||
|
||||
private void OnMapEntityAdded(object sender, MapEntityAddedEventArgs e)
|
||||
{
|
||||
|
@ -21,18 +21,20 @@ namespace Sledgemapper.UI
|
||||
{
|
||||
private AuthenticateResponse _authResponse;
|
||||
private readonly CommunicationManager CommunicationManager;
|
||||
private readonly State _state;
|
||||
private readonly Settings _settings;
|
||||
private Texture2D _eye;
|
||||
private Texture2D _location;
|
||||
public MainWidget(CommunicationManager communicationManager, State state, Settings settings)
|
||||
private State _state;
|
||||
private Settings _settings;
|
||||
private GameWindow _window;
|
||||
|
||||
private readonly CachedContent _cachedContent;
|
||||
public MainWidget(CommunicationManager communicationManager, State state, Settings settings, CachedContent cachedContent, GameWindow window)
|
||||
{
|
||||
BuildUI();
|
||||
_eye = Content.Load<Texture2D>("eye");
|
||||
_location = Content.Load<Texture2D>("location");
|
||||
|
||||
CommunicationManager = communicationManager;
|
||||
_state = state;
|
||||
_settings = settings;
|
||||
_cachedContent = cachedContent;
|
||||
_window = window;
|
||||
MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
|
||||
MenuConnectSync.Selected += OnMenuConnectSyncSelected;
|
||||
MenuFileLoad.Selected += OnMenuFileLoadSelected;
|
||||
@ -564,8 +566,8 @@ namespace Sledgemapper.UI
|
||||
var note = CommunicationManager.SessionData.Notes.Values.ElementAt(i);
|
||||
var item = new NoteListItem();
|
||||
item.LblNoteText.Text = $"{note.ToString()} - {note.Text}";
|
||||
item.BtnNoteCenter.Image = new TextureRegion(_location);
|
||||
item.BtnNoteView.Image = new TextureRegion(_eye);
|
||||
item.BtnNoteCenter.Image = new TextureRegion(_cachedContent.Location);
|
||||
item.BtnNoteView.Image = new TextureRegion(_cachedContent.Eye);
|
||||
item.BtnNoteCenter.Click += (s, e) => { CenterOnTile(note.X, note.Y); };
|
||||
item.BtnNoteView.Click += (s, e) => { EditNote(note); window.Close(); };
|
||||
content.StackNotesList.AddChild(item);
|
||||
@ -582,12 +584,12 @@ namespace Sledgemapper.UI
|
||||
|
||||
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.TileSize / 2, _window.ClientBounds.Height / 2 - _state.TileSize / 2);
|
||||
var dx = center.X - x * _state.TileSize - _state.ViewportCenter.X;
|
||||
var dy = center.Y - y * _state.TileSize - _state.ViewportCenter.Y;
|
||||
_state.ViewportCenter = new Vector3(_state.ViewportCenter.X + dx, _state.ViewportCenter.Y + dy, _state.ViewportCenter.Z);
|
||||
|
||||
_state.ViewportCenter.X += dx;
|
||||
_state.ViewportCenter.Y += dy;
|
||||
}
|
||||
|
||||
private void OnMenuCampaignNew(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user