#include #include #include #include #include "menu_callbacks.hpp" #include "solution_algorithm.hpp" #include "gameplay.hpp" #include "img_handler.hpp" void load_file_callback(Fl_Widget *sender, void*) { const char *path = nullptr; auto dialog = Fl_Native_File_Chooser{}; dialog.type(Fl_Native_File_Chooser::BROWSE_FILE); dialog.filter("JPEG Files (*.jpg)\tPNG Files (*.png)"); #if defined(_WIN32) dialog.directory((string {getenv("HOMEPATH")} + "\\Desktop").c_str()); #else dialog.directory((std::string {getenv("HOME")} + "/Desktop").c_str()); #endif dialog.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::NEW_FOLDER); if (dialog.show() == 0) path = dialog.filename(); ImageHandler ih(path); ih.load_img(); ih.resize_img(); ih.save_img(); } void exit_callback(Fl_Widget *w, void*) { w->parent()->hide(); } void solve_problem_callback(Fl_Widget *w, void *gp) { GameParams *game = reinterpret_cast(gp); std::unique_ptr algorithm = ASearch::Start(game); Node *goal = algorithm->FindSolution(); algorithm->ShowSolution(goal); int answer = fl_choice("Play again?", "No", "Yes", nullptr); if(answer) PuzzleGame::StartGame(game); else game->win->hide(); } void about_callback(Fl_Widget *w, void*) { }