more cleanup
This commit is contained in:
parent
af441e772b
commit
77832db39d
28 changed files with 45 additions and 105 deletions
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
@ -7,16 +7,13 @@ using Myra.Graphics2D.Brushes;
|
|||
using Myra.Graphics2D.TextureAtlases;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Myra.Graphics2D.UI.File;
|
||||
using Myra.Graphics2D.UI.Properties;
|
||||
using Newtonsoft.Json;
|
||||
using Refit;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using Sledgemapper.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
|
@ -29,9 +26,9 @@ namespace Sledgemapper
|
|||
private readonly Desktop _desktop;
|
||||
private KeyboardState oldState;
|
||||
private MouseState oldMouseState;
|
||||
private Vector3 _viewportCenter = new Vector3(0, 0, 0);
|
||||
private Vector3 _viewportCenter = new(0, 0, 0);
|
||||
private Dictionary<string, SpriteFont> _fonts;
|
||||
private Session _sessionData;
|
||||
private readonly Session _sessionData;
|
||||
private AuthenticateResponse _authResponse;
|
||||
private MainWidget _mainWidget;
|
||||
|
||||
|
@ -41,7 +38,6 @@ namespace Sledgemapper
|
|||
|
||||
_graphics.GraphicsProfile = GraphicsProfile.Reach;
|
||||
_graphics.PreferMultiSampling = false;
|
||||
//GraphicsDevice?.PresentationParameters.MultiSampleCount = 8;
|
||||
|
||||
Content.RootDirectory = "Content";
|
||||
_desktop = new Desktop();
|
||||
|
@ -114,7 +110,7 @@ namespace Sledgemapper
|
|||
{
|
||||
var mouseState = Mouse.GetState();
|
||||
|
||||
var screenPosition = new Point((mouseState.Position.X - (int)_viewportCenter.X), (mouseState.Position.Y - (int)_viewportCenter.Y));
|
||||
var screenPosition = new Point(mouseState.Position.X - (int)_viewportCenter.X, mouseState.Position.Y - (int)_viewportCenter.Y);
|
||||
|
||||
_state._hoveredTile.X = screenPosition.X / _state._tileSize;
|
||||
_state._hoveredTile.Y = screenPosition.Y / _state._tileSize;
|
||||
|
@ -245,7 +241,6 @@ namespace Sledgemapper
|
|||
{
|
||||
return;
|
||||
}
|
||||
//GraphicsDevice.Clear(new Color(24,118,157));
|
||||
GraphicsDevice.Clear(Color.LightGray);
|
||||
|
||||
var visibleTilesX = GraphicsDevice.Viewport.Width / _state._tileSize + 1;
|
||||
|
@ -481,19 +476,13 @@ namespace Sledgemapper
|
|||
{
|
||||
var result = await _communicationManager.Api.NewSession(localContent.TxtSession.Text);
|
||||
|
||||
// var session = await _communicationManager.Connection?.InvokeAsync<Session>("NewSession", localContent.TxtSession.Text, _authResponse.Initials);
|
||||
if (result)
|
||||
{
|
||||
//_sessionData;
|
||||
|
||||
_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
|
||||
_sessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
_sessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
_sessionData.MapEntityAdded += OnMapEntityAdded;
|
||||
_sessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||
// _sessionData.Players = session.Players;
|
||||
|
||||
}
|
||||
successful = result;
|
||||
var result2 = await _communicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||
|
@ -508,7 +497,10 @@ namespace Sledgemapper
|
|||
if (successful)
|
||||
{
|
||||
_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
_communicationManager.SessionData = _sessionData;
|
||||
_communicationManager.SessionData.Map = _sessionData.Map;
|
||||
_communicationManager.SessionData.Overlays = _sessionData.Overlays;
|
||||
_communicationManager.SessionData.Walls = _sessionData.Walls;
|
||||
|
||||
localWindow.Close();
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +634,7 @@ namespace Sledgemapper
|
|||
|
||||
private void OnMenuConnectJoinSelected(object sender, EventArgs e)
|
||||
{
|
||||
Window window = new Window
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Join mapping session"
|
||||
};
|
||||
|
@ -657,7 +649,7 @@ namespace Sledgemapper
|
|||
|
||||
private void OnMenuConnectLoginSelected(object sender, EventArgs e)
|
||||
{
|
||||
Window window = new Window
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Login"
|
||||
};
|
||||
|
@ -699,7 +691,6 @@ namespace Sledgemapper
|
|||
|
||||
private async void OnMenuConnectSyncSelected(object sender, EventArgs e)
|
||||
{
|
||||
// await _communicationManager.Connection?.InvokeAsync("Sync", _sessionData.SessionName, _sessionData);
|
||||
var serverMap = await _communicationManager.Api.Session(_sessionData.SessionName);
|
||||
_sessionData.Overlays = serverMap.Overlays;
|
||||
_sessionData.Map = serverMap.Map;
|
||||
|
@ -709,14 +700,11 @@ namespace Sledgemapper
|
|||
private async void OnMenuConnectUploadSelected(object sender, EventArgs e)
|
||||
{
|
||||
await _communicationManager.Api.SaveSnapshot(_sessionData, _sessionData.SessionName);
|
||||
// _sessionData.Overlays = serverMap.Overlays;
|
||||
// _sessionData.Map = serverMap.Map;
|
||||
// _sessionData.Walls = serverMap.Walls;
|
||||
}
|
||||
|
||||
private void OnMenuConnectNewSelected(object sender, EventArgs e)
|
||||
{
|
||||
Window window = new Window
|
||||
Window window = new()
|
||||
{
|
||||
Title = "New mapping session"
|
||||
};
|
||||
|
@ -731,7 +719,7 @@ namespace Sledgemapper
|
|||
|
||||
private void OnMenuFileSaveSelected(object sender, EventArgs e)
|
||||
{
|
||||
FileDialog dialog = new FileDialog(FileDialogMode.SaveFile)
|
||||
FileDialog dialog = new(FileDialogMode.SaveFile)
|
||||
{
|
||||
Filter = "*.map"
|
||||
};
|
||||
|
@ -744,7 +732,7 @@ namespace Sledgemapper
|
|||
}
|
||||
|
||||
using StreamWriter file = File.CreateText(dialog.FilePath);
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
JsonSerializer serializer = new();
|
||||
serializer.Serialize(file, _sessionData);
|
||||
};
|
||||
|
||||
|
@ -765,7 +753,7 @@ namespace Sledgemapper
|
|||
return;
|
||||
}
|
||||
using StreamReader file = File.OpenText(dialog.FilePath);
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
JsonSerializer serializer = new();
|
||||
var loadData = (Session)serializer.Deserialize(file, typeof(Session));
|
||||
_sessionData.Map=loadData.Map;
|
||||
_sessionData.Overlays=loadData.Overlays;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue