cleanup, refactoring, usual stuff
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b671c661a7
commit
f15f1c8857
26 changed files with 183 additions and 209 deletions
|
@ -34,7 +34,7 @@ namespace Sledgemapper.Api.Controllers
|
|||
|
||||
[HttpPost]
|
||||
[Route("Register")]
|
||||
public async Task<IActionResult> Register([FromBody] Sledgemapper.Models.Users.RegisterModel user)
|
||||
public async Task<IActionResult> Register([FromBody] RegisterModel user)
|
||||
{
|
||||
// Check if the incoming request is valid
|
||||
if (ModelState.IsValid)
|
||||
|
@ -44,7 +44,7 @@ namespace Sledgemapper.Api.Controllers
|
|||
|
||||
if (existingUser != null)
|
||||
{
|
||||
return BadRequest(new Sledgemapper.Models.Users.RegistrationResponse()
|
||||
return BadRequest(new RegistrationResponse()
|
||||
{
|
||||
Result = false,
|
||||
Errors = new List<string>(){
|
||||
|
@ -60,14 +60,14 @@ namespace Sledgemapper.Api.Controllers
|
|||
{
|
||||
var jwtToken = GenerateJwtToken(newUser);
|
||||
|
||||
return Ok(new Sledgemapper.Models.Users.RegistrationResponse()
|
||||
return Ok(new RegistrationResponse()
|
||||
{
|
||||
Result = true,
|
||||
Token = jwtToken
|
||||
});
|
||||
}
|
||||
|
||||
return new JsonResult(new Sledgemapper.Models.Users.RegistrationResponse()
|
||||
return new JsonResult(new RegistrationResponse()
|
||||
{
|
||||
Result = false,
|
||||
Errors = isCreated.Errors.Select(x => x.Description).ToList()
|
||||
|
@ -76,7 +76,7 @@ namespace Sledgemapper.Api.Controllers
|
|||
{ StatusCode = 500 };
|
||||
}
|
||||
|
||||
return BadRequest(new Sledgemapper.Models.Users.RegistrationResponse()
|
||||
return BadRequest(new RegistrationResponse()
|
||||
{
|
||||
Result = false,
|
||||
Errors = new List<string>(){
|
||||
|
|
|
@ -13,6 +13,6 @@ namespace Sledgemapper.Entities
|
|||
public string Initials { get; set; }
|
||||
// public byte[] PasswordHash { get; set; }
|
||||
public byte[] PasswordSalt { get; set; }
|
||||
public ICollection<Sledgemapper.Api.Core.Entities.Campaign> Campaigns {get;set;}
|
||||
public ICollection<Api.Core.Entities.Campaign> Campaigns {get;set;}
|
||||
}
|
||||
}
|
|
@ -22,10 +22,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteNoteCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Note>(notification.Note);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Note);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteOverlayCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Overlay);
|
||||
var session = _dbcontext.Sessions.First(m=>m.SessionName== notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteTileCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Tile);
|
||||
var session = _dbcontext.Sessions.First(m=>m.SessionName== notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteWallCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Wall);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Sledgemapper.Api.Handlers
|
|||
var campaigns = _dbcontext.Campaigns.Include(c => c.InvitedUsers).Include(c => c.Maps).Include(c => c.Owner).Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user));
|
||||
|
||||
return campaigns.
|
||||
Select(c => new Shared.Entities.Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Shared.Entities.Map { SessionName = m.SessionName }).ToList() })
|
||||
Select(c => new Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Map { SessionName = m.SessionName }).ToList() })
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -9,17 +9,17 @@ using Sledgemapper.Api.Models;
|
|||
|
||||
namespace Sledgemapper.Api.Commands
|
||||
{
|
||||
public class GetMapSnapshotCommandHandler : IRequestHandler<GetMapSnapshotCommand, Sledgemapper.Shared.Entities.Session>
|
||||
public class GetMapSnapshotCommandHandler : IRequestHandler<GetMapSnapshotCommand, Shared.Entities.Session>
|
||||
{
|
||||
private readonly SledgemapperDbContext _dbcontext;
|
||||
|
||||
public GetMapSnapshotCommandHandler(SledgemapperDbContext dbcontext) { _dbcontext = dbcontext; }
|
||||
|
||||
public async Task<Sledgemapper.Shared.Entities.Session> Handle(GetMapSnapshotCommand notification, CancellationToken cancellationToken)
|
||||
public async Task<Shared.Entities.Session> Handle(GetMapSnapshotCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
Snapshot snapshot;
|
||||
double timestamp;
|
||||
Sledgemapper.Shared.Entities.Session mapSession;
|
||||
Shared.Entities.Session mapSession;
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
snapshot = _dbcontext.Snapshots.OrderByDescending(s => s.Timestamp).FirstOrDefault(m => m.SessionId == session.SessionId);
|
||||
if (snapshot is null)
|
||||
|
@ -30,7 +30,7 @@ namespace Sledgemapper.Api.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
mapSession = JsonSerializer.Deserialize<Sledgemapper.Shared.Entities.Session>(snapshot.Object);
|
||||
mapSession = JsonSerializer.Deserialize<Shared.Entities.Session>(snapshot.Object);
|
||||
timestamp = snapshot.Timestamp;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace Sledgemapper.Api.Commands
|
|||
{
|
||||
SessionId = session.SessionId,
|
||||
Timestamp = mapUpdates.Max(mapSession => mapSession.Timestamp),
|
||||
Object = JsonSerializer.Serialize<Sledgemapper.Shared.Entities.Session>(mapSession)
|
||||
Object = JsonSerializer.Serialize(mapSession)
|
||||
};
|
||||
await _dbcontext.Snapshots.AddAsync(newSnapshot);
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewLineCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Line>(notification.Line);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Line);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewNoteCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Note>(notification.Note);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Note);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewOverlayCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Overlay);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewRoomCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Room>(notification.Room);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Room);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Commands
|
|||
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
var newSnapshot = new Sledgemapper.Api.Models.Snapshot{
|
||||
var newSnapshot = new Models.Snapshot{
|
||||
SessionId=session.SessionId,
|
||||
Timestamp=notification.Timestamp,
|
||||
Object = JsonSerializer.Serialize<Sledgemapper.Shared.Entities.Session>(notification.Session)
|
||||
Object = JsonSerializer.Serialize(notification.Session)
|
||||
|
||||
};
|
||||
await _dbcontext.Snapshots.AddAsync(newSnapshot);
|
||||
|
|
|
@ -19,10 +19,10 @@ namespace Sledgemapper.Api.Commands
|
|||
|
||||
public async Task<bool> Handle(NewTileCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Tile);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewWallCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Wall);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace Sledgemapper.Api.Hubs
|
|||
await Clients.Group(sessionName).Ping(new Ping{X=location.X, Y=location.Y, Player=player});
|
||||
}
|
||||
|
||||
public async Task<Sledgemapper.Shared.Entities.Session> JoinSession(string sessionName)
|
||||
public async Task<Shared.Entities.Session> JoinSession(string sessionName)
|
||||
{
|
||||
var session = _dbContext.Sessions.FirstOrDefault(s => s.SessionName == sessionName);
|
||||
var userId = int.Parse(Context.User.Identity.Name);
|
||||
|
@ -112,7 +112,7 @@ namespace Sledgemapper.Api.Hubs
|
|||
await Clients.Group(session.SessionName).NewPlayer(player);
|
||||
await Clients.Group(session.SessionName).RefreshPlayers();
|
||||
|
||||
var newSession = new Sledgemapper.Shared.Entities.Session
|
||||
var newSession = new Shared.Entities.Session
|
||||
{
|
||||
SessionName = session.SessionName,
|
||||
SessionId = session.SessionId
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Sledgemapper.Api.Infrastructure.Data
|
|||
|
||||
public class SledgemapperDbContext : IdentityDbContext
|
||||
{
|
||||
public DbSet<Sledgemapper.Api.Core.Entities.Campaign> Campaigns { get; set; }
|
||||
public DbSet<Campaign> Campaigns { get; set; }
|
||||
public DbSet<MapLog> MapLogs { get; set; }
|
||||
public DbSet<Map> Maps { get; set; }
|
||||
public DbSet<Session> Sessions { get; set; }
|
||||
|
@ -46,9 +46,9 @@ namespace Sledgemapper.Api.Infrastructure.Data
|
|||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Core.Entities.Campaign>().HasOne<User>(e=>e.Owner);
|
||||
modelBuilder.Entity<Campaign>().HasOne(e=>e.Owner);
|
||||
|
||||
modelBuilder.Entity<Core.Entities.Campaign>().HasMany<User>(e=>e.InvitedUsers).WithMany(e=>e.Campaigns);
|
||||
modelBuilder.Entity<Campaign>().HasMany(e=>e.InvitedUsers).WithMany(e=>e.Campaigns);
|
||||
|
||||
modelBuilder.Entity<User>() //Use your application user class here
|
||||
.ToTable( "Users" ); //Set the table name here
|
||||
|
|
9
Sledgemapper/Messages/CampaignSelectedMessage.cs
Normal file
9
Sledgemapper/Messages/CampaignSelectedMessage.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Sledgemapper.Messages
|
||||
{
|
||||
public class CampaignSelectedMessage : TinyMessenger.TinyMessageBase
|
||||
{
|
||||
public CampaignSelectedMessage(object sender) : base(sender)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using Myra.Graphics2D.Brushes;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Sledgemapper.Messages;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TinyMessenger;
|
||||
|
@ -11,17 +12,15 @@ namespace Sledgemapper.UI
|
|||
private readonly CommunicationManager CommunicationManager;
|
||||
private readonly Window Window;
|
||||
private readonly TinyMessengerHub Messenger;
|
||||
private readonly Desktop Desktop;
|
||||
private Settings _settings;
|
||||
private bool campaignSelected;
|
||||
|
||||
public CampaignList(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger, Settings settings, Desktop desktop)
|
||||
public CampaignList(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger)
|
||||
{
|
||||
BuildUI();
|
||||
CommunicationManager = communicationManager;
|
||||
Window = window;
|
||||
Messenger = messenger;
|
||||
Desktop = desktop;
|
||||
_settings = settings;
|
||||
|
||||
BtnNewCampaign.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
|
@ -33,6 +32,7 @@ namespace Sledgemapper.UI
|
|||
if (campaignSelected)
|
||||
{
|
||||
campaignSelected = false;
|
||||
Messenger.Publish(new CampaignSelectedMessage(this));
|
||||
window.Close();
|
||||
}
|
||||
};
|
||||
|
@ -57,96 +57,31 @@ namespace Sledgemapper.UI
|
|||
};
|
||||
|
||||
var content = new CampaignWindow(CommunicationManager, window, Messenger);
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
//content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
//content.TxtCampaign.SetKeyboardFocus();
|
||||
window.ShowModal(Window.Desktop);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool campaignSelected;
|
||||
|
||||
|
||||
private void OnCampaignSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as UI.ListItem;
|
||||
var localContent = item.GetParentContentInWindow<Widget>();
|
||||
var item = sender as ListItem;
|
||||
|
||||
State.Instance.CampaignName = item.ItemName.Text;
|
||||
var list = item.Parent as Myra.Graphics2D.UI.Grid;
|
||||
var list = item.Parent as 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);
|
||||
item.Background = new SolidBrush(Settings.Instance.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();
|
||||
var item = new ListItem();
|
||||
item.ItemName.Text = campaign.Name;
|
||||
|
||||
item.TouchUp += OnCampaignSelected;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Myra.Graphics2D.Brushes;
|
||||
using Myra.Graphics2D.TextureAtlases;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Myra.Graphics2D.UI.File;
|
||||
using Myra.Graphics2D.UI.Properties;
|
||||
|
@ -11,7 +10,6 @@ using Sledgemapper.Messages;
|
|||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TinyMessenger;
|
||||
using Session = Sledgemapper.Shared.Entities.Session;
|
||||
|
||||
|
@ -68,12 +66,17 @@ namespace Sledgemapper.UI
|
|||
_messenger.Subscribe<SignalrConnectionUpdateMessage>(OnSignalrConnectionUpdateMessage);
|
||||
_messenger.Subscribe<MapOpenedMessage>(OnMapOpenedMessage);
|
||||
_messenger.Subscribe<CenterOnTileMessage>(OnCenterOnTileMessage);
|
||||
_messenger.Subscribe<CampaignSelectedMessage>(OnCampaignSelectedMessage);
|
||||
}
|
||||
|
||||
private void OnCampaignSelectedMessage(CampaignSelectedMessage obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnCenterOnTileMessage(CenterOnTileMessage obj)
|
||||
{
|
||||
CenterOnTile(obj.X, obj.Y);
|
||||
|
||||
}
|
||||
|
||||
private void OnMapOpenedMessage(MapOpenedMessage obj)
|
||||
|
@ -318,18 +321,6 @@ namespace Sledgemapper.UI
|
|||
|
||||
var content = new NoteList(CommunicationManager, _messenger, window);
|
||||
|
||||
for (var i = 0; i < CommunicationManager.SessionData.Notes.Values.Count; i++)
|
||||
{
|
||||
var note = CommunicationManager.SessionData.Notes.Values.ElementAt(i);
|
||||
var item = new NoteListItem();
|
||||
item.LblNoteText.Text = $"{note.ToString()} - {note.Text}";
|
||||
item.BtnNoteCenter.Image = new TextureRegion(CachedContent.Instance.Location);
|
||||
item.BtnNoteView.Image = new TextureRegion(CachedContent.Instance.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);
|
||||
}
|
||||
|
@ -360,8 +351,9 @@ namespace Sledgemapper.UI
|
|||
{
|
||||
Title = "New campaign"
|
||||
};
|
||||
|
||||
var content = new CampaignWindow();
|
||||
var content = new CampaignWindow(CommunicationManager, window, _messenger);
|
||||
window.Content = content;
|
||||
window.ShowModal(Desktop);
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
|
@ -376,7 +368,7 @@ namespace Sledgemapper.UI
|
|||
Title = "Campaigns"
|
||||
};
|
||||
|
||||
var content = new CampaignList(CommunicationManager, window, _messenger, Settings.Instance, Desktop);
|
||||
var content = new CampaignList(CommunicationManager, window, _messenger);
|
||||
await content.LoadCampaigns();
|
||||
|
||||
window.Content = content;
|
||||
|
@ -386,10 +378,10 @@ namespace Sledgemapper.UI
|
|||
|
||||
private void OnMapSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as UI.ListItem;
|
||||
var item = sender as ListItem;
|
||||
var localContent = item.GetParentContentInWindow<Widget>();
|
||||
|
||||
var list = item.Parent as Myra.Graphics2D.UI.Grid;
|
||||
var list = item.Parent as Grid;
|
||||
for (var i = 0; i < list.ChildrenCount; i++)
|
||||
{
|
||||
var currentItem = list.GetChild(i) as HorizontalStackPanel;// UI.ListItem;
|
||||
|
@ -410,22 +402,8 @@ namespace Sledgemapper.UI
|
|||
Title = "Players"
|
||||
};
|
||||
|
||||
var content = new PlayerList();
|
||||
var players = await CommunicationManager.Api.GetPlayers(State.Instance.CampaignName);
|
||||
foreach (var player in players)
|
||||
{
|
||||
var item = new UI.ListItem();
|
||||
item.ItemName.Text = player.UserName;
|
||||
|
||||
|
||||
content.StackCampaignsList.AddChild(item);
|
||||
}
|
||||
|
||||
content.BtnInvitePlayer.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
ShowAddPLayerWindow();
|
||||
};
|
||||
var content = new PlayerList(CommunicationManager, window);
|
||||
await content.LoadPlayers();
|
||||
|
||||
window.Content = content;
|
||||
|
||||
|
@ -447,7 +425,7 @@ namespace Sledgemapper.UI
|
|||
var campaigns = await CommunicationManager.Api.GetMaps(State.Instance.CampaignName);
|
||||
foreach (var campaign in campaigns)
|
||||
{
|
||||
var item = new UI.ListItem();
|
||||
var item = new ListItem();
|
||||
item.ItemName.Text = campaign.SessionName;
|
||||
item.TouchUp += OnMapSelected;
|
||||
content.StackCampaignsList.AddChild(item);
|
||||
|
@ -464,21 +442,7 @@ namespace Sledgemapper.UI
|
|||
window.ShowModal(Desktop);
|
||||
}
|
||||
|
||||
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 async void OnButtonJoinSessionClicked(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -531,27 +495,7 @@ namespace Sledgemapper.UI
|
|||
}
|
||||
}
|
||||
|
||||
private async void OnButtonInvitePlayerClicked(object sender, EventArgs e)
|
||||
{
|
||||
var localContent = ((TextButton)sender).GetParentContentInWindow<PlayerWindow>();// localWindow.Content as PlayerWindow;
|
||||
var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await CommunicationManager.Api.InvitePlayer(State.Instance.CampaignName, localContent.Content.TxtCampaign.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
localContent.Window.Close();
|
||||
|
||||
}
|
||||
|
||||
private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -46,12 +46,9 @@ namespace Sledgemapper.UI
|
|||
};
|
||||
var noteWindow = new NoteWindow(CommunicationManager, window, note);
|
||||
|
||||
|
||||
|
||||
|
||||
window.Content = noteWindow;
|
||||
window.ShowModal(Desktop);
|
||||
//noteWindow.NoteText.SetKeyboardFocus();
|
||||
window.ShowModal(Window.Desktop);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
8
Sledgemapper/UI/NoteListItem.Custom.cs
Normal file
8
Sledgemapper/UI/NoteListItem.Custom.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Generated by MyraPad at 01/12/2020 14:29:43 */
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class NoteListItem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
48
Sledgemapper/UI/PlayerList.Custom.cs
Normal file
48
Sledgemapper/UI/PlayerList.Custom.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Generated by MyraPad at 28/08/2021 19:49:08 */
|
||||
using Myra.Graphics2D.UI;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class PlayerList
|
||||
{
|
||||
protected readonly Window Window;
|
||||
protected readonly CommunicationManager CommunicationManager;
|
||||
|
||||
public PlayerList(CommunicationManager communicationManager, Window window)
|
||||
{
|
||||
BuildUI();
|
||||
Window = window;
|
||||
CommunicationManager = communicationManager;
|
||||
BtnInvitePlayer.Click += (s, e) =>
|
||||
{
|
||||
Window.Close();
|
||||
ShowAddPLayerWindow();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public async Task LoadPlayers()
|
||||
{
|
||||
var players = await CommunicationManager.Api.GetPlayers(State.Instance.CampaignName);
|
||||
foreach (var player in players)
|
||||
{
|
||||
var item = new ListItem();
|
||||
item.ItemName.Text = player.UserName;
|
||||
StackCampaignsList.AddChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAddPLayerWindow()
|
||||
{
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Invite player",
|
||||
Content = new PlayerWindow(CommunicationManager, Window)
|
||||
};
|
||||
|
||||
window.ShowModal(Window.Desktop);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
/* Generated by MyraPad at 28/08/2021 19:49:08 */
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class PlayerList
|
||||
{
|
||||
public PlayerList()
|
||||
{
|
||||
BuildUI();
|
||||
}
|
||||
}
|
||||
public partial class PlayerList
|
||||
{
|
||||
public PlayerList()
|
||||
{
|
||||
BuildUI();
|
||||
}
|
||||
}
|
||||
}
|
44
Sledgemapper/UI/PlayerWindow.Custom.cs
Normal file
44
Sledgemapper/UI/PlayerWindow.Custom.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* Generated by MyraPad at 28/08/2021 22:04:11 */
|
||||
using Myra.Graphics2D.UI;
|
||||
using Sentry;
|
||||
using System;
|
||||
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class PlayerWindow
|
||||
{
|
||||
protected readonly Window Window;
|
||||
protected readonly CommunicationManager CommunicationManager;
|
||||
|
||||
public PlayerWindow(CommunicationManager communicationManager, Window window)
|
||||
{
|
||||
Window = window;
|
||||
CommunicationManager = communicationManager;
|
||||
|
||||
BuildUI();
|
||||
BtnNewCampaign.Click += OnButtonInvitePlayerClicked;
|
||||
}
|
||||
|
||||
private async void OnButtonInvitePlayerClicked(object sender, EventArgs e)
|
||||
{
|
||||
var localContent = ((TextButton)sender).GetParentContentInWindow<PlayerWindow>();// localWindow.Content as PlayerWindow;
|
||||
var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await CommunicationManager.Api.InvitePlayer(State.Instance.CampaignName, localContent.Content.TxtCampaign.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
localContent.Window.Close();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/* Generated by MyraPad at 28/08/2021 22:04:11 */
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class PlayerWindow
|
||||
{
|
||||
public PlayerWindow()
|
||||
{
|
||||
BuildUI();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue