almost completed map load flow
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
8c6df57fb1
commit
e18cbb157c
@ -76,6 +76,10 @@ namespace Sledgemapper
|
||||
[Get("/campaign/{campaignName}/maps")]
|
||||
Task<List<Session>> GetMaps(string campaignName);
|
||||
|
||||
[Get("/map/{campaignName}/{mapName}")]
|
||||
Task<Session> GetMap(string campaignName, string mapName);
|
||||
|
||||
|
||||
[Post("/campaign/{campaignName}/players/{email}")]
|
||||
Task InvitePlayer(string campaignName, string email);
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ namespace Sledgemapper.Messages
|
||||
{
|
||||
public class MapOpenedMessage : TinyMessenger.TinyMessageBase
|
||||
{
|
||||
public string MapName { get; set; }
|
||||
public MapOpenedMessage(object sender) : base(sender)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -59,6 +59,7 @@ namespace Sledgemapper
|
||||
public string CampaignName { get; set; }
|
||||
public bool ShowCellNumbers { get; set; }
|
||||
public Vector3 ViewportCenter { get; set; }
|
||||
public string MapName { get; internal set; }
|
||||
|
||||
//public State()
|
||||
//{
|
||||
|
@ -17,11 +17,11 @@ namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class MainWidget
|
||||
{
|
||||
private readonly CommunicationManager CommunicationManager;
|
||||
private CommunicationManager CommunicationManager { get; }
|
||||
|
||||
private readonly TinyMessengerHub _messenger;
|
||||
private TinyMessengerHub Messenger { get; }
|
||||
|
||||
private readonly GameWindow Window;
|
||||
private GameWindow Window { get; }
|
||||
|
||||
public MainWidget(CommunicationManager communicationManager, TinyMessengerHub messenger, GameWindow window)
|
||||
{
|
||||
@ -29,7 +29,7 @@ namespace Sledgemapper.UI
|
||||
|
||||
CommunicationManager = communicationManager;
|
||||
Window = window;
|
||||
_messenger = messenger;
|
||||
Messenger = messenger;
|
||||
MenuConnectLogin.Selected += OnMenuConnectLoginSelected;
|
||||
MenuConnectSync.Selected += OnMenuConnectSyncSelected;
|
||||
MenuFileLoad.Selected += OnMenuFileLoadSelected;
|
||||
@ -63,11 +63,11 @@ namespace Sledgemapper.UI
|
||||
BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||
BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||
|
||||
_messenger.Subscribe<LoginSuccesfulMessage>(OnLoginSuccesfulMessage);
|
||||
_messenger.Subscribe<SignalrConnectionUpdateMessage>(OnSignalrConnectionUpdateMessage);
|
||||
_messenger.Subscribe<MapOpenedMessage>(OnMapOpenedMessage);
|
||||
_messenger.Subscribe<CenterOnTileMessage>(OnCenterOnTileMessage);
|
||||
_messenger.Subscribe<CampaignSelectedMessage>(OnCampaignSelectedMessage);
|
||||
Messenger.Subscribe<LoginSuccesfulMessage>(OnLoginSuccesfulMessage);
|
||||
Messenger.Subscribe<SignalrConnectionUpdateMessage>(OnSignalrConnectionUpdateMessage);
|
||||
Messenger.Subscribe<MapOpenedMessage>(OnMapOpenedMessage);
|
||||
Messenger.Subscribe<CenterOnTileMessage>(OnCenterOnTileMessage);
|
||||
Messenger.Subscribe<CampaignSelectedMessage>(OnCampaignSelectedMessage);
|
||||
}
|
||||
|
||||
private void OnCampaignSelectedMessage(CampaignSelectedMessage obj)
|
||||
@ -85,7 +85,7 @@ namespace Sledgemapper.UI
|
||||
|
||||
private void OnMapOpenedMessage(MapOpenedMessage obj)
|
||||
{
|
||||
lblMap.Text = CommunicationManager.SessionData.SessionName;
|
||||
lblMap.Text = obj.MapName;
|
||||
MenuConnectSync.Enabled = true;
|
||||
MenuConnectUpload.Enabled = true;
|
||||
CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
@ -141,7 +141,7 @@ namespace Sledgemapper.UI
|
||||
Title = "Login"
|
||||
};
|
||||
|
||||
var content = new LoginRegisterWindow(CommunicationManager, _messenger);
|
||||
var content = new LoginRegisterWindow(CommunicationManager, Messenger);
|
||||
window.Content = content;
|
||||
window.ShowModal(Desktop);
|
||||
}
|
||||
@ -159,7 +159,7 @@ namespace Sledgemapper.UI
|
||||
Title = "New mapping session"
|
||||
};
|
||||
|
||||
var content = new SessionWindow(CommunicationManager, _messenger);
|
||||
var content = new SessionWindow(CommunicationManager, Messenger);
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
@ -293,7 +293,7 @@ namespace Sledgemapper.UI
|
||||
return;
|
||||
}
|
||||
|
||||
new SessionWindow(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "Join mapping session");
|
||||
new SessionWindow(CommunicationManager, Messenger).ShowInModalWindow(Desktop, "Join mapping session");
|
||||
}
|
||||
|
||||
private void OnMenuViewShowCellNUmbersSelected(object sender, EventArgs e)
|
||||
@ -313,7 +313,7 @@ namespace Sledgemapper.UI
|
||||
Title = "Notes"
|
||||
};
|
||||
|
||||
new NoteList(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "Notes");
|
||||
new NoteList(CommunicationManager, Messenger).ShowInModalWindow(Desktop, "Notes");
|
||||
}
|
||||
|
||||
private void CenterOnSelectedTile()
|
||||
@ -337,7 +337,7 @@ namespace Sledgemapper.UI
|
||||
return;
|
||||
}
|
||||
|
||||
new CampaignWindow(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "New campaign"); ;
|
||||
new CampaignWindow(CommunicationManager, Messenger).ShowInModalWindow(Desktop, "New campaign"); ;
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
@ -347,7 +347,7 @@ namespace Sledgemapper.UI
|
||||
return;
|
||||
}
|
||||
|
||||
var content = new CampaignList(CommunicationManager, _messenger);
|
||||
var content = new CampaignList(CommunicationManager, Messenger);
|
||||
await content.LoadCampaigns();
|
||||
content.ShowInModalWindow(Desktop, "Campaigns");
|
||||
}
|
||||
@ -371,7 +371,7 @@ namespace Sledgemapper.UI
|
||||
return;
|
||||
}
|
||||
|
||||
var content = new MapList(CommunicationManager);
|
||||
var content = new MapList(CommunicationManager, Messenger);
|
||||
await content.LoadMaps();
|
||||
content.ShowInModalWindow(Desktop, "Maps");
|
||||
}
|
||||
|
@ -1,24 +1,40 @@
|
||||
/* Generated by MyraPad at 03/09/2021 17:13:57 */
|
||||
using Myra.Graphics2D.Brushes;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Sledgemapper.Messages;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TinyMessenger;
|
||||
|
||||
namespace Sledgemapper.UI
|
||||
{
|
||||
public partial class MapList
|
||||
{
|
||||
public CommunicationManager CommunicationManager { get; }
|
||||
public partial class MapList
|
||||
{
|
||||
private CommunicationManager CommunicationManager { get; }
|
||||
private TinyMessengerHub Messenger { get; }
|
||||
|
||||
public MapList(CommunicationManager communicationManager)
|
||||
{
|
||||
CommunicationManager= communicationManager;
|
||||
BuildUI();
|
||||
private string _selectedMap;
|
||||
public MapList(CommunicationManager communicationManager, TinyMessengerHub messenger)
|
||||
{
|
||||
CommunicationManager = communicationManager;
|
||||
Messenger = messenger;
|
||||
|
||||
BuildUI();
|
||||
BtnNewCampaign.Click += (s, e) =>
|
||||
{
|
||||
OnMenuMapNew(s, e);
|
||||
this.GetContainingWindow().Close();
|
||||
};
|
||||
|
||||
BtnLoadCampaign.Click += BtnLoadCampaign_Click;
|
||||
}
|
||||
|
||||
private void BtnLoadCampaign_Click(object sender, EventArgs e)
|
||||
{
|
||||
State.Instance.MapName = _selectedMap;
|
||||
var map = CommunicationManager.Api.GetMap(State.Instance.CampaignName, State.Instance.MapName);
|
||||
Messenger.Publish(new MapOpenedMessage(this) { MapName = State.Instance.MapName });
|
||||
this.GetContainingWindow().Close();
|
||||
}
|
||||
|
||||
public async Task LoadMaps()
|
||||
@ -45,6 +61,7 @@ namespace Sledgemapper.UI
|
||||
currentItem.Background = new SolidBrush("#D9D9D9FF");
|
||||
}
|
||||
item.Background = new SolidBrush(Settings.Instance.OverlayTintColor);
|
||||
_selectedMap = item.ItemName.Text;
|
||||
}
|
||||
|
||||
private void OnMenuMapNew(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user