This commit is contained in:
parent
7808363a07
commit
4179143fdb
15 changed files with 192 additions and 183 deletions
|
@ -62,6 +62,7 @@ namespace Sledgemapper.UI
|
|||
BtnToolbarLine.Click += OnBtnToolbarLinClicked;
|
||||
BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||
BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||
|
||||
_messenger.Subscribe<LoginSuccesfulMessage>(OnLoginSuccesfulMessage);
|
||||
_messenger.Subscribe<SignalrConnectionUpdateMessage>(OnSignalrConnectionUpdateMessage);
|
||||
_messenger.Subscribe<MapOpenedMessage>(OnMapOpenedMessage);
|
||||
|
@ -107,7 +108,7 @@ namespace Sledgemapper.UI
|
|||
MenuCampaignOpen.Enabled = true;
|
||||
MenuCampaingNew.Enabled = true;
|
||||
|
||||
lblUsername.Text = $"{obj.UserName} - {obj.Initials}";
|
||||
lblUsername.Text = $"{obj.Initials}";
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
|
@ -292,16 +293,7 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Join mapping session"
|
||||
};
|
||||
|
||||
var content = new SessionWindow(CommunicationManager, _messenger);
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
new SessionWindow(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "Join mapping session");
|
||||
}
|
||||
|
||||
private void OnMenuViewShowCellNUmbersSelected(object sender, EventArgs e)
|
||||
|
@ -321,10 +313,7 @@ namespace Sledgemapper.UI
|
|||
Title = "Notes"
|
||||
};
|
||||
|
||||
var content = new NoteList(CommunicationManager, _messenger);
|
||||
|
||||
window.Content = content;
|
||||
window.ShowModal(Desktop);
|
||||
new NoteList(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "Notes");
|
||||
}
|
||||
|
||||
private void CenterOnSelectedTile()
|
||||
|
@ -339,7 +328,6 @@ namespace Sledgemapper.UI
|
|||
var dx = center.X - x * State.Instance.TileSize - State.Instance.ViewportCenter.X;
|
||||
var dy = center.Y - y * State.Instance.TileSize - State.Instance.ViewportCenter.Y;
|
||||
State.Instance.ViewportCenter = new Vector3(State.Instance.ViewportCenter.X + dx, State.Instance.ViewportCenter.Y + dy, State.Instance.ViewportCenter.Z);
|
||||
|
||||
}
|
||||
|
||||
private void OnMenuCampaignNew(object sender, EventArgs e)
|
||||
|
@ -349,13 +337,7 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "New campaign"
|
||||
};
|
||||
var content = new CampaignWindow(CommunicationManager, _messenger);
|
||||
window.Content = content;
|
||||
window.ShowModal(Desktop);
|
||||
new CampaignWindow(CommunicationManager, _messenger).ShowInModalWindow(Desktop, "New campaign"); ;
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignOpen(object sender, EventArgs e)
|
||||
|
@ -365,31 +347,9 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Campaigns"
|
||||
};
|
||||
|
||||
var content = new CampaignList(CommunicationManager, _messenger);
|
||||
await content.LoadCampaigns();
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
}
|
||||
|
||||
private void OnMapSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as ListItem;
|
||||
var localContent = item.GetParentContentInWindow<Widget>();
|
||||
|
||||
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.Instance.OverlayTintColor);
|
||||
content.ShowInModalWindow(Desktop, "Campaigns");
|
||||
}
|
||||
|
||||
private async void OnMenuCampaignPlayersSelected(object sender, EventArgs e)
|
||||
|
@ -399,18 +359,11 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Players"
|
||||
};
|
||||
|
||||
var content = new PlayerList(CommunicationManager);
|
||||
await content.LoadPlayers();
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
content.ShowInModalWindow(Desktop, "Players");
|
||||
}
|
||||
|
||||
private async void OnMenuMapOpen(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
|
@ -418,34 +371,11 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "Maps"
|
||||
};
|
||||
|
||||
var content = new MapList();
|
||||
var campaigns = await CommunicationManager.Api.GetMaps(State.Instance.CampaignName);
|
||||
foreach (var campaign in campaigns)
|
||||
{
|
||||
var item = new ListItem();
|
||||
item.ItemName.Text = campaign.SessionName;
|
||||
item.TouchUp += OnMapSelected;
|
||||
content.StackCampaignsList.AddChild(item);
|
||||
}
|
||||
|
||||
content.BtnNewCampaign.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
OnMenuMapNew(s, e);
|
||||
};
|
||||
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
var content = new MapList(CommunicationManager);
|
||||
await content.LoadMaps();
|
||||
content.ShowInModalWindow(Desktop, "Maps");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async void OnButtonJoinSessionClicked(object sender, EventArgs e)
|
||||
{
|
||||
var localContent = ((TextButton)sender).GetParentContentInWindow<SessionWindow>();
|
||||
|
@ -496,9 +426,6 @@ namespace Sledgemapper.UI
|
|||
localContent.Window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
|
||||
{
|
||||
State.Instance.InsertMode = InsertMode.NewRoom;
|
||||
|
@ -532,61 +459,14 @@ namespace Sledgemapper.UI
|
|||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "New map"
|
||||
};
|
||||
|
||||
var content = new MapWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonNewMapClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private async void OnButtonNewMapClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
while (!(container is Window))
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as MapWindow;
|
||||
var isValid = localContent.TxtCampaign.ValidateTextbox();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await CommunicationManager.Api.NewSession(State.Instance.CampaignName, localContent.TxtCampaign.Text);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
|
||||
localWindow.Close();
|
||||
new MapWindow(CommunicationManager).ShowInModalWindow(Desktop, "New map");
|
||||
}
|
||||
|
||||
//TODO Refactor
|
||||
private void EditNote(Note note)
|
||||
{
|
||||
State.Instance.SelectedNote = new Note { X = note.X, Y = note.Y, Text = note.Text };
|
||||
Window window = new()
|
||||
{
|
||||
Title = $" Note on {note.X}:{note.Y}"
|
||||
};
|
||||
var noteWindow = new NoteWindow(CommunicationManager, note);
|
||||
|
||||
window.Content = noteWindow;
|
||||
window.ShowModal(Desktop);
|
||||
new NoteWindow(CommunicationManager, note).ShowInModalWindow(Desktop, $" Note on {note.X}:{note.Y}");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue