diff options
Diffstat (limited to 'menu_callbacks.cpp')
-rw-r--r-- | menu_callbacks.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/menu_callbacks.cpp b/menu_callbacks.cpp index 5668c67..d6b35dc 100644 --- a/menu_callbacks.cpp +++ b/menu_callbacks.cpp @@ -12,8 +12,8 @@ void new_game_callback(Fl_Widget*, void *gp) { - Fl::check(); - PuzzleGame::StartGame(reinterpret_cast<GameParams*>(gp)); + if(!reinterpret_cast<GameParams*>(gp)->GetAStarActive()) + PuzzleGame::StartGame(reinterpret_cast<GameParams*>(gp)); } static bool check_correct_path_to_img(const char *path) @@ -52,15 +52,19 @@ void load_file_callback(Fl_Widget *sender, void*) void exit_callback(Fl_Widget *w, void*) { - w->parent()->hide(); + exit(0); } void solve_problem_callback(Fl_Widget *w, void *gp) { GameParams *game = reinterpret_cast<GameParams*>(gp); + if(game->GetAStarActive()) + return; + game->SetAStarActive(); std::unique_ptr<ASearch> algorithm = ASearch::Start(game); Node *goal = algorithm->FindSolution(); algorithm->ShowSolution(goal); + game->ResetAStarActive(); int answer = fl_choice("Play again?", "No", "Yes", nullptr); if(answer) PuzzleGame::StartGame(game); |