Bugfixes and improvements

This commit is contained in:
2016-01-19 21:32:16 +01:00
parent b0cf690c0e
commit e59aad59ed
5 changed files with 25 additions and 17 deletions
+3 -1
View File
@@ -225,7 +225,9 @@ namespace YJMPD_UWP
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
App.Network.Disconnect();
deferral.Complete();
}
}
+2 -14
View File
@@ -13,8 +13,6 @@ namespace YJMPD_UWP.Model
{
public class ApiHandler
{
public delegate void OnGameFoundHandler(object sender, EventArgs e);
public event OnGameFoundHandler OnGameFound;
public enum Command
{
@@ -22,7 +20,6 @@ namespace YJMPD_UWP.Model
Name,
Picture,
Msg,
GameFound,
PlayerJoined,
PlayerRemoved
}
@@ -39,9 +36,6 @@ namespace YJMPD_UWP.Model
switch (c)
{
case Command.GameFound:
GameFound();
break;
case Command.PlayerJoined:
Debug.WriteLine("Played joined");
PlayerJoined(o[Command.PlayerJoined.ToString()].ToString());
@@ -59,6 +53,8 @@ namespace YJMPD_UWP.Model
}
else
App.Navigate(typeof(WaitingView));
App.Game.MoveToWaiting();
break;
default:
//Do nothing
@@ -79,14 +75,6 @@ namespace YJMPD_UWP.Model
App.Game.RemovePlayer(username);
}
private void GameFound()
{
throw new NotImplementedException();
if (OnGameFound == null) return;
OnGameFound(this, new EventArgs());
}
public JObject Message(Command c, string msg)
{
return JObject.FromObject(new
+11 -1
View File
@@ -54,6 +54,11 @@ namespace YJMPD_UWP.Model
UpdateGamePlayers(p);
}
public void MoveToWaiting()
{
UpdateGameStatus(GameStatus.WAITING);
}
public void RemovePlayer(string username)
{
for(int i=Players.Count-1; i>=0; i--)
@@ -69,6 +74,8 @@ namespace YJMPD_UWP.Model
public void Reset()
{
App.Photo.Reset();
Selected = false;
Players.Clear();
UpdateGamePlayers(null);
}
@@ -126,7 +133,10 @@ namespace YJMPD_UWP.Model
App.Navigate(typeof(MatchView));
break;
case GameStatus.WAITING:
App.Navigate(typeof(WaitingView));
if (Selected)
App.Navigate(typeof(PhotoView));
else
App.Navigate(typeof(WaitingView));
break;
case GameStatus.STARTED:
if (Selected && App.Photo.Photo == null)
+4 -1
View File
@@ -95,8 +95,11 @@ namespace YJMPD_UWP.Model
return true;
}
private async Task<bool> Disconnect()
public async Task<bool> Disconnect()
{
if(App.Game.Status != GameHandler.GameStatus.STOPPED)
App.Api.LeaveGame();
UpdateNetworkStatus(NetworkStatus.DISCONNECTED);
if (BackgroundReader != null)
+5
View File
@@ -21,6 +21,11 @@ namespace YJMPD_UWP.Model
}
public void Reset()
{
Photo = null;
}
private void UpdatePhotoTaken(SoftwareBitmapSource photo)
{
Photo = photo;