From 3678fc96f919148491d48f59bf591326684bb037 Mon Sep 17 00:00:00 2001 From: "jeremy.mouyon" Date: Thu, 6 Jun 2024 16:43:02 +0200 Subject: [PATCH] exit button bb --- Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs | 30 ++++++++++++++------ Qwirkle/QwirkleViews/Pages/Gameboard.xaml | 8 ++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs index 0ed74ae..152e22b 100644 --- a/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs +++ b/Qwirkle/QwirkleViews/Pages/GameBoard.xaml.cs @@ -41,15 +41,15 @@ public partial class Gameboard : ContentPage } - private void Game_EndOfGameNotified(object? sender, EndOfGameNotifiedEventArgs e) + private async void Game_EndOfGameNotified(object? sender, EndOfGameNotifiedEventArgs e) { - PopUpEnd(); - Navigation.PushAsync(new MainPage()); + await PopUpEnd(); + await Navigation.PushAsync(new MainPage()); } - private async void PopUpEnd() + private Task PopUpEnd() { - await this.ShowPopupAsync(new PopUpEndGame()); + return this.ShowPopupAsync(new PopUpEndGame()); } private void OnDragStarting(object sender, DragStartingEventArgs e) @@ -186,13 +186,13 @@ public partial class Gameboard : ContentPage if (game.CellsUsed.Count == 0 && !game.PlayerSwapping) { - AnswerSwap(); + _ = AnswerSwap(); } game.PlaceTileNotified -= Game_PlaceTileNotified; } - private async void AnswerSwap() + private async Task AnswerSwap() { bool answer = await DisplayAlert("Swap System", "Etes vous sur de vouloir swap vos tuiles ? Attention, si vous swapez vous ne pouvez pu jouer", "Yes", "No"); @@ -215,4 +215,18 @@ public partial class Gameboard : ContentPage tilesSwap.Add(tiledrag!); } } -} \ No newline at end of file + + private async void OnButtonExitClicked(object sender, EventArgs e) + { + bool answer = await DisplayAlert("System information", "Are you sure you want to quit? You can resume your game at any time from the home screen.", "Yes", "No"); + + if (answer) + { + await Navigation.PushAsync(new MainPage()); + + + } + } + + +} diff --git a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml index 68ebe8e..01602c0 100644 --- a/Qwirkle/QwirkleViews/Pages/Gameboard.xaml +++ b/Qwirkle/QwirkleViews/Pages/Gameboard.xaml @@ -61,6 +61,14 @@ ToolTipProperties.Text="Click to check your settings -_-" Style="{StaticResource GameButton}"/> +