back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index d1646e1..389056c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -9,12 +9,28 @@
#include "gameplay.hpp"
#include "menu_callbacks.hpp"
+class MainWindow : public Fl_Window {
+public:
+ MainWindow(int w, int h, const char *title) : Fl_Window(w, h, title) {}
+ /*
+ * Ending program by esc key while the computer is solving a puzzle
+ */
+ int handle(int event) override {
+ if(event == FL_KEYDOWN && Fl::event_length() != 0 &&
+ Fl::event_key() == FL_Escape)
+ {
+ exit(0);
+ }
+ return Fl_Window::handle(event);
+ }
+};
+
int main()
{
srand(time(nullptr));
- Fl_Window *win = new Fl_Window(320, 355, "Picture puzzle");
+ MainWindow *win = new MainWindow(320, 340, "Picture puzzle");
GameParams *params = GameParams::SetUpParams(win);
- Fl_Sys_Menu_Bar *sys_bar = new Fl_Sys_Menu_Bar(0, 0, 355, 20, nullptr);
+ Fl_Sys_Menu_Bar *sys_bar = new Fl_Sys_Menu_Bar(0, 0, 320, 20, nullptr);
sys_bar->add("&File/&New game", nullptr, new_game_callback, params);
sys_bar->add("&File/&Load file", nullptr, load_file_callback);
sys_bar->add("&File/&Exit", nullptr, exit_callback);
@@ -24,5 +40,4 @@ int main()
PuzzleGame::StartGame(params);
win->show();
return Fl::run();
- return 0;
}