From 90bd5ca05bea4dbeaaeff5cbe13b5671da420c82 Mon Sep 17 00:00:00 2001 From: scratko Date: Fri, 25 Jul 2025 17:04:21 +0300 Subject: July update Added const qualifiers is_next_to_empty_box() became visible to other files(). The size of the main window has been changed. Checking whether the A* algorithm has been launched before starting a new game or the same A* algorithm. Fixed indentation in lambda expressions. The initial node is added to open_queue without additional creation of dynamic memory (the address of the object field is taken). Fixed PQ_cont.erase(). IsNearEmptyBox was removed(). EqualNode moved to the Node class. --- menu_callbacks.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'menu_callbacks.cpp') 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(gp)); + if(!reinterpret_cast(gp)->GetAStarActive()) + PuzzleGame::StartGame(reinterpret_cast(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(gp); + if(game->GetAStarActive()) + return; + game->SetAStarActive(); std::unique_ptr 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); -- cgit v1.2.3