72 lines
1.4 KiB
C
72 lines
1.4 KiB
C
#include <menu.h>
|
|
#include <camera.h>
|
|
#include <game.h>
|
|
#include <gfx.h>
|
|
#include <gui.h>
|
|
#include <gui/button.h>
|
|
#include <system.h>
|
|
#include <stdbool.h>
|
|
|
|
static void on_pressed(void *const arg)
|
|
{
|
|
*(bool *)arg = true;
|
|
}
|
|
|
|
int menu(void)
|
|
{
|
|
struct camera cam = {0};
|
|
struct gui_button play;
|
|
union peripheral p;
|
|
bool start = false;
|
|
|
|
if (game_resinit())
|
|
return -1;
|
|
|
|
cursor_init(&cam.cursor);
|
|
gui_button_init(&play);
|
|
play.on_pressed = on_pressed;
|
|
play.arg = &start;
|
|
play.w = 140;
|
|
play.common.hcentered = true;
|
|
play.common.vcentered = true;
|
|
play.label.text = "Play";
|
|
|
|
{
|
|
const struct peripheral_cfg cfg =
|
|
{
|
|
.type = PERIPHERAL_TYPE_KEYBOARD_MOUSE
|
|
};
|
|
|
|
peripheral_init(&cfg, &p);
|
|
}
|
|
|
|
while (!start)
|
|
{
|
|
system_loop();
|
|
peripheral_update(&p);
|
|
camera_update(&cam, &p);
|
|
|
|
play.label.common.x = play.w / 2 - 20;
|
|
play.label.common.y = 4;
|
|
|
|
if (gui_update(&play.common, &p, &cam))
|
|
return -1;
|
|
|
|
rect_get_or_ret(r, -1);
|
|
rect_init(r);
|
|
r->w = screen_w;
|
|
r->h = screen_h;
|
|
rect_sort(r);
|
|
|
|
if (p.common.exit)
|
|
return 0;
|
|
|
|
if (gui_render(&play.common)
|
|
|| cursor_render(&cam.cursor)
|
|
|| gfx_draw())
|
|
return -1;
|
|
}
|
|
|
|
return game(NULL);
|
|
}
|