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
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue