5 #include "goatkit/goatkit.h"
12 static void bn_handler(goatkit::Widget *w, const goatkit::Event &ev, void *cls);
14 extern GameScreen *scr_game;
16 static int virt_width = 800;
17 static int virt_height = 600;
18 static goatkit::Screen ui;
19 static goatkit::Button *bn_start, *bn_exit;
20 static bool start_pending, exit_pending;
23 bool MenuScreen::init()
30 int xpos = (virt_width - bnwidth) / 2;
34 bn_start = new goatkit::Button;
35 bn_start->set_position(xpos, ypos += vsep);
36 bn_start->set_size(bnwidth, bnheight);
37 bn_start->set_text("Don't Panic!");
38 bn_start->set_callback(goatkit::EV_CLICK, bn_handler, (void*)BN_START);
39 ui.add_widget(bn_start);
41 bn_exit = new goatkit::Button;
42 bn_exit->set_position(xpos, ypos += vsep);
43 bn_exit->set_size(bnwidth, bnheight);
44 bn_exit->set_text("Panic");
45 bn_exit->set_callback(goatkit::EV_CLICK, bn_handler, (void*)BN_EXIT);
46 ui.add_widget(bn_exit);
48 ui.set_visibility_transition(300);
50 if(!(goatkit::theme = goatkit::get_theme("simple"))) {
57 void MenuScreen::destroy()
62 void MenuScreen::start()
68 void MenuScreen::stop()
74 void MenuScreen::draw()
76 if(ui.get_visibility() == 0.0f) {
78 start_pending = false;
79 push_screen(scr_game);
94 glClearColor(0, 0, 0, 1);
95 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
97 glMatrixMode(GL_PROJECTION);
99 glOrtho(0, virt_width, virt_height, 0, -1, 1);
101 glMatrixMode(GL_MODELVIEW);
108 void MenuScreen::reshape(int x, int y)
110 ui.set_size(virt_width, virt_height);
114 void MenuScreen::keyboard(int key, bool pressed)
128 ui.sysev_keyboard(key, pressed);
131 void MenuScreen::mbutton(int bn, bool pressed, int x, int y)
133 x = x * virt_width / win_width;
134 y = y * virt_height / win_height;
135 ui.sysev_mouse_button(bn, pressed, x, y);
138 void MenuScreen::mmotion(int x, int y)
140 x = x * virt_width / win_width;
141 y = y * virt_height / win_height;
142 ui.sysev_mouse_motion(x, y);
145 static void bn_handler(goatkit::Widget *w, const goatkit::Event &ev, void *cls)
148 start_pending = true;
150 } else if(w == bn_exit) {