1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <stdlib.h>
#include <time.h>
#include "puzzle.hpp"
#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) {
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));
MainWindow *win = new MainWindow(320, 355, "Picture puzzle");
GameParams *params = GameParams::SetUpParams(win);
Fl_Sys_Menu_Bar *sys_bar = new Fl_Sys_Menu_Bar(0, 0, 355, 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);
sys_bar->add("&Options/&Show solution", nullptr, solve_problem_callback,
params);
sys_bar->add("&About", nullptr, about_callback);
PuzzleGame::StartGame(params);
win->show();
return Fl::run();
return 0;
}
|