From 26dd84dae8fab02aa50ad1a5d28e668a95d49afc Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Fri, 12 Jun 2020 15:18:11 +0930 Subject: make loss/win message boxes modal and blocking --- MainWindow.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'MainWindow.cpp') diff --git a/MainWindow.cpp b/MainWindow.cpp index 61cbac9..ca632b6 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -14,6 +14,7 @@ */ #include "MainWindow.h" +#include "FXMessageBox.h" #include "fxdefs.h" #include // rand #include @@ -235,24 +236,20 @@ MainWindow::on_Tile_Click(FXObject *sender, FXSelector sel, void *data) if (!board->is_game_running() && !board->is_game_won()) { /* lost */ + draw_buttons(); app->removeTimeout(this, UI_Timer_Tick); puts("you lose the game"); - std::string message = "You lost in: " + std::to_string(seconds) + " seconds"; - FXMessageBox *msgbox = new FXMessageBox(app, "Game Over", FXString(message.c_str()), nullptr, FX::MBOX_OK); - msgbox->create(); - msgbox->show(); + FXMessageBox::information(app, FX::MBOX_OK, "Game Over", "You lost in %ld seconds.", seconds); game_over = true; ticking = false; } else if (!board->is_game_running() && board->is_game_won()) { /* won */ + draw_buttons(); app->removeTimeout(this, UI_Timer_Tick); puts("you won the game"); - std::string message = "You won in: " + std::to_string(seconds) + " seconds"; - FXMessageBox *msgbox = new FXMessageBox(app, "Game Over", FXString(message.c_str()), nullptr, FX::MBOX_OK); - msgbox->create(); - msgbox->show(); + FXMessageBox::information(app, FX::MBOX_OK, "Game Over", "You lost in %ld seconds.", seconds); game_over = true; ticking = false; } -- cgit v1.2.3