diff options
author | scratko <m@scratko.xyz> | 2024-11-18 02:45:54 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-11-18 15:32:49 +0300 |
commit | 7fea2267e78de935af6010d5ac7300e51f471601 (patch) | |
tree | 42a417b778c6f826b84bcc6515c292bd862dcd99 /menu_callbacks.cpp | |
parent | 22d4fdabf17aebebfcb73c7d86b5bbc81b6530f4 (diff) | |
download | picture-puzzle-7fea2267e78de935af6010d5ac7300e51f471601.tar.gz picture-puzzle-7fea2267e78de935af6010d5ac7300e51f471601.tar.bz2 picture-puzzle-7fea2267e78de935af6010d5ac7300e51f471601.zip |
Uploading custom images
Diffstat (limited to 'menu_callbacks.cpp')
-rw-r--r-- | menu_callbacks.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/menu_callbacks.cpp b/menu_callbacks.cpp index d43d848..a48b899 100644 --- a/menu_callbacks.cpp +++ b/menu_callbacks.cpp @@ -5,9 +5,12 @@ #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)"); @@ -19,7 +22,11 @@ void load_file_callback(Fl_Widget *sender, void*) dialog.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::NEW_FOLDER); if (dialog.show() == 0) - printf("%s\n", dialog.filename()); + path = dialog.filename(); + ImageHandler ih(path); + ih.load_img(); + ih.resize_img(); + ih.save_img(); } void exit_callback(Fl_Widget *w, void*) @@ -29,10 +36,16 @@ void exit_callback(Fl_Widget *w, void*) void solve_problem_callback(Fl_Widget *w, void *gp) { - std::unique_ptr<ASearch> algorithm = - ASearch::Start(reinterpret_cast<GameParams*>(gp)); + GameParams *game = reinterpret_cast<GameParams*>(gp); + std::unique_ptr<ASearch> 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*) |