cleanup and sentry integration
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michele Scandura 2021-09-16 10:30:44 +01:00
parent 98e5f6bc89
commit b671c661a7
21 changed files with 89 additions and 88 deletions

View File

@ -3,9 +3,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Sledgemapper.Api.Commands;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Shared.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

View File

@ -9,7 +9,6 @@ using System;
using Sledgemapper.Api.Infrastructure.Data;
using Microsoft.AspNetCore.Authorization;
using Sledgemapper.Api.Models;
using Sledgemapper.Helpers;
namespace Sledgemapper.Api.Hubs
{

View File

@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Sledgemapper.Api.Migrations
{

View File

@ -7,7 +7,6 @@ using Sledgemapper.Api.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
using MediatR;
using Microsoft.IdentityModel.Tokens;
using Sledgemapper.Helpers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System.Text;
using Sledgemapper.Api.Hubs;

View File

@ -1,5 +1,4 @@
using System;
using System.Security.Cryptography;
namespace Sledgemapper.Shared.Entities
{

View File

@ -1,9 +1,4 @@
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sledgemapper
{

View File

@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Threading.Channels;
using Sentry;
namespace Sledgemapper
{
@ -28,7 +28,7 @@ namespace Sledgemapper
}
catch (Exception ex)
{
//ExceptionlessClient.Default.SubmitException(ex);
SentrySdk.CaptureException(ex);
throw;
}
}

View File

@ -1,11 +1,9 @@
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Configuration;
using Polly;
using Refit;
using Sledgemapper.Shared.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;

View File

@ -1,7 +1,6 @@
using Refit;
using Sledgemapper.Shared.Entities;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace Sledgemapper

View File

@ -0,0 +1,12 @@
namespace Sledgemapper.Messages
{
public class CenterOnTileMessage : TinyMessenger.TinyMessageBase
{
public CenterOnTileMessage(object sender) : base(sender)
{
}
public int X { get; internal set; }
public int Y { get; internal set; }
}
}

View File

@ -1,26 +1,12 @@
public class LoginSuccesfulMessage : TinyMessenger.TinyMessageBase
namespace Sledgemapper.Messages
{
public LoginSuccesfulMessage(object sender) : base(sender)
public class LoginSuccesfulMessage : TinyMessenger.TinyMessageBase
{
public LoginSuccesfulMessage(object sender) : base(sender)
{
}
public string UserName { get; internal set; }
public string Initials { get; internal set; }
}
public string UserName { get; internal set; }
public string Initials { get; internal set; }
}
public class MapOpenedMessage : TinyMessenger.TinyMessageBase
{
public MapOpenedMessage(object sender) : base(sender)
{
}
}
public class CenterOnTileMessage : TinyMessenger.TinyMessageBase
{
public CenterOnTileMessage(object sender) : base(sender)
{
}
public int X { get; internal set; }
public int Y { get; internal set; }
}

View File

@ -0,0 +1,9 @@
namespace Sledgemapper.Messages
{
public class MapOpenedMessage : TinyMessenger.TinyMessageBase
{
public MapOpenedMessage(object sender) : base(sender)
{
}
}
}

View File

@ -1,10 +1,9 @@
public class SignalrConnectionUpdateMessage: TinyMessenger.TinyMessageBase
namespace Sledgemapper.Messages
{
public SignalrConnectionUpdateMessage(object sender) : base(sender)
public class SignalrConnectionUpdateMessage : TinyMessenger.TinyMessageBase
{
public SignalrConnectionUpdateMessage(object sender) : base(sender)
{
}
}
}

View File

@ -1,5 +1,6 @@
using System;
using Microsoft.Xna.Framework;
using Sentry;
namespace Sledgemapper
{
@ -13,7 +14,15 @@ namespace Sledgemapper
public int TileDeleteDivider { get; set; }
public int PingDuration {get;set;}
public Settings()
private static readonly Settings instance = new Settings();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Settings()
{
}
private Settings()
{
BackgroundColor = Color.LightGray;
GridColor = Color.Black;
@ -27,9 +36,17 @@ namespace Sledgemapper
}
catch (Exception ex)
{
//ExceptionlessClient.Default.SubmitException(ex);
SentrySdk.CaptureException(ex);
MachineName = "n/a";
}
}
public static Settings Instance
{
get
{
return instance;
}
}
}
}

View File

@ -3,24 +3,17 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using MonoGame.Extended.VectorDraw;
using Myra;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.UI.File;
using Myra.Graphics2D.UI.Properties;
using Myra.Utility;
using Newtonsoft.Json;
using Sledgemapper.Shared.Entities;
using Sledgemapper.UI;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using TinyMessenger;
@ -43,7 +36,6 @@ namespace Sledgemapper
private readonly Session _sessionData;
private RenderTarget2D rendertarget;
private MainWidget _mainWidget;
private readonly Settings _settings;
private readonly TinyMessengerHub _messenger;
public Sledgemapper()
@ -66,7 +58,7 @@ namespace Sledgemapper
_communicationManager.Connection.Reconnecting += OnHubReconnecting;
_communicationManager.Connection.Closed += OnHubDisconnected;
_state = State.Instance;
_settings = new Settings();
_vector2Pool = ArrayPool<Vector2>.Create();
_messenger = new TinyMessengerHub();
}
@ -196,7 +188,7 @@ namespace Sledgemapper
ResetRenderTarget();
_mainWidget = new MainWidget(_communicationManager, _settings, _messenger, Window);
_mainWidget = new MainWidget(_communicationManager, _messenger, Window);
@ -689,7 +681,7 @@ namespace Sledgemapper
continue;
}
if ((gameTime.TotalGameTime.TotalMilliseconds - ping.StartTime) > _settings.PingDuration)
if ((gameTime.TotalGameTime.TotalMilliseconds - ping.StartTime) > Settings.Instance.PingDuration)
{
_sessionData.Pings.TryRemove(guid, out var _);
}
@ -732,7 +724,7 @@ namespace Sledgemapper
var endposY = _state.SelectedSnapPoint.Y * _state.TileSize;
if (_state.InsertMode == InsertMode.NewDelete)
{
var ww = _state.TileSize / _settings.TileDeleteDivider;
var ww = _state.TileSize / Settings.Instance.TileDeleteDivider;
if (posX == endposX) { endposX += ww; posX -= ww; }
if (posY == endposY) { endposY += ww; posY -= ww; }
}
@ -985,11 +977,11 @@ namespace Sledgemapper
outlineShader.Parameters["ImageSize"].SetValue(texelSize);
outlineShader.Parameters["BorderSize"].SetValue((int)(_state.TileSize / 100f * 10f));
outlineShader.Parameters["R"].SetValue(_settings.OverlayTintColor.R / 255.0f);
outlineShader.Parameters["G"].SetValue(_settings.OverlayTintColor.G / 255.0f);
outlineShader.Parameters["B"].SetValue(_settings.OverlayTintColor.B / 255.0f);
outlineShader.Parameters["R"].SetValue(Settings.Instance.OverlayTintColor.R / 255.0f);
outlineShader.Parameters["G"].SetValue(Settings.Instance.OverlayTintColor.G / 255.0f);
outlineShader.Parameters["B"].SetValue(Settings.Instance.OverlayTintColor.B / 255.0f);
GraphicsDevice.Clear(_settings.BackgroundColor);
GraphicsDevice.Clear(Settings.Instance.BackgroundColor);
_spriteBatch.Begin(
effect: outlineShader,
@ -1093,7 +1085,7 @@ namespace Sledgemapper
posX1, posY1,
posX2,
posY2,
_settings.GridColor);
Settings.Instance.GridColor);
}
for (var i = -1; i < visibleTilesY + 2; i++)
@ -1110,7 +1102,7 @@ namespace Sledgemapper
_spriteBatch.DrawLine(posX1, posY1,
posX2,
posY2,
_settings.GridColor);
Settings.Instance.GridColor);
}
@ -1170,7 +1162,7 @@ namespace Sledgemapper
note.X * _state.TileSize + _state.TileSize - (int)(_state.TileSize / 2),
note.Y * _state.TileSize + _state.TileSize / 8,
(int)(_state.TileSize / 2.5), (int)(_state.TileSize / 2.5 / 1.136)
), _settings.NoteColor
), Settings.Instance.NoteColor
);
}
}
@ -1191,7 +1183,7 @@ namespace Sledgemapper
posY = tile.Y * _state.TileSize;
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX + _state.TileSize / 25, posY + _state.TileSize / 25), spriteRec, Color.Black * .2f, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX, posY), spriteRec, _settings.OverlayTintColor, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX, posY), spriteRec, Settings.Instance.OverlayTintColor, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
}
else
{
@ -1200,7 +1192,7 @@ namespace Sledgemapper
}
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX + _state.TileSize / 25, posY + _state.TileSize / 25), spriteRec, Color.Black * .2f, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX, posY), spriteRec, _settings.OverlayTintColor, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
_spriteBatch.Draw(_spriteSheet.Texture, new Vector2(posX, posY), spriteRec, Settings.Instance.OverlayTintColor, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(spriteRec.Value.Width / 2, spriteRec.Value.Height / 2), ((float)_state.TileSize - 10) / spriteRec.Value.Width, SpriteEffects.None, 0);
}
}
@ -1642,7 +1634,7 @@ namespace Sledgemapper
var endposY = tile.End.Y * _state.TileSize;
var ww = _state.TileSize / _settings.TileDeleteDivider;
var ww = _state.TileSize / Settings.Instance.TileDeleteDivider;
if (posX == endposX) { endposX += ww; posX -= ww; }
if (posY == endposY) { endposY += ww; posY -= ww; }
switch (tile.Start.Index)

View File

@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using System;
using Sledgemapper.Shared.Entities;
using System.Collections.Generic;
namespace Sledgemapper
{

View File

@ -1,11 +1,11 @@
using Myra.Graphics2D.UI;
using Sentry;
using System;
using System.Threading.Tasks;
using TinyMessenger;
namespace Sledgemapper.UI
{
public partial class CampaignWindow
public partial class CampaignWindow
{
private readonly CommunicationManager CommunicationManager;
private readonly Window Window;
@ -58,6 +58,7 @@ namespace Sledgemapper.UI
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
//ExceptionlessClient.Default.SubmitException(ex);
}

View File

@ -1,15 +1,14 @@
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.Xna.Framework;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.UI;
using Sledgemapper.Messages;
using Sledgemapper.Shared.Entities;
using TinyMessenger;
namespace Sledgemapper.UI
{
public partial class LoginRegisterWindow
public partial class LoginRegisterWindow
{
private AuthenticateResponse _authResponse;
private readonly CommunicationManager CommunicationManager;

View File

@ -1,19 +1,19 @@
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
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 Sentry;
using Sledgemapper.Messages;
using Sledgemapper.Shared.Entities;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using TinyMessenger;
using Session = Sledgemapper.Shared.Entities.Session;
namespace Sledgemapper.UI
{
@ -21,18 +21,15 @@ namespace Sledgemapper.UI
{
private readonly CommunicationManager CommunicationManager;
private Settings _settings;
private readonly TinyMessengerHub _messenger;
private readonly GameWindow Window;
public MainWidget(CommunicationManager communicationManager, Settings settings, TinyMessengerHub messenger, GameWindow window)
public MainWidget(CommunicationManager communicationManager, TinyMessengerHub messenger, GameWindow window)
{
BuildUI();
CommunicationManager = communicationManager;
_settings = settings;
Window = window;
_messenger = messenger;
MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
@ -271,7 +268,7 @@ namespace Sledgemapper.UI
{
var propertyGrid = new PropertyGrid
{
Object = _settings,
Object = Settings.Instance,
Width = 350
};
@ -379,7 +376,7 @@ namespace Sledgemapper.UI
Title = "Campaigns"
};
var content = new CampaignList(CommunicationManager, window, _messenger, _settings, Desktop);
var content = new CampaignList(CommunicationManager, window, _messenger, Settings.Instance, Desktop);
await content.LoadCampaigns();
window.Content = content;
@ -398,7 +395,7 @@ namespace Sledgemapper.UI
var currentItem = list.GetChild(i) as HorizontalStackPanel;// UI.ListItem;
currentItem.Background = new SolidBrush("#D9D9D9FF");
}
item.Background = new SolidBrush(_settings.OverlayTintColor);
item.Background = new SolidBrush(Settings.Instance.OverlayTintColor);
}
private async void OnMenuCampaignPlayersSelected(object sender, EventArgs e)
@ -550,7 +547,7 @@ namespace Sledgemapper.UI
}
catch (Exception ex)
{
Sentry.SentrySdk.CaptureException(ex);
SentrySdk.CaptureException(ex);
}
localContent.Window.Close();
@ -626,7 +623,7 @@ namespace Sledgemapper.UI
}
catch (Exception ex)
{
//ExceptionlessClient.Default.SubmitException(ex);
SentrySdk.CaptureException(ex);
}
localWindow.Close();

View File

@ -2,6 +2,7 @@
using System.Linq;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Sledgemapper.Messages;
using Sledgemapper.Shared.Entities;
using TinyMessenger;

View File

@ -2,8 +2,11 @@
using System;
using Microsoft.AspNetCore.SignalR.Client;
using Myra.Graphics2D.UI;
using Sentry;
using Sledgemapper.Messages;
using Sledgemapper.Shared.Entities;
using TinyMessenger;
using Session = Sledgemapper.Shared.Entities.Session;
namespace Sledgemapper.UI
{
@ -57,7 +60,7 @@ namespace Sledgemapper.UI
}
catch (Exception ex)
{
//ExceptionlessClient.Default.SubmitException(ex);
SentrySdk.CaptureException(ex);
}
if (successful)