63 lines
1.3 KiB
C
63 lines
1.3 KiB
C
#include <string.h>
|
|
#include "SDL.h"
|
|
|
|
#include "toolkit.h"
|
|
#include "log.h"
|
|
#include "main.h"
|
|
#include "pause.h"
|
|
#include "menu.h"
|
|
|
|
#define MENU_WIDTH 120
|
|
#define MENU_HEIGHT 200
|
|
|
|
#define BUTTON_WIDTH 80
|
|
#define BUTTON_HEIGHT 30
|
|
|
|
static int menu_open = 0;
|
|
|
|
static void menu_small_close(char* str);
|
|
static void edit_options(void);
|
|
static void exit_game(void);
|
|
|
|
// Small ingame menu.
|
|
void menu_small(void) {
|
|
if(menu_open) return; // It's already open..
|
|
|
|
unsigned int wid;
|
|
|
|
wid = window_create("Menu", -1, -1, MENU_WIDTH, MENU_HEIGHT);
|
|
|
|
window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
|
|
"btnExit", "Exit", (void(*)(char*))exit_game);
|
|
window_addButton(wid, 20, 20 + BUTTON_HEIGHT + 20,
|
|
BUTTON_WIDTH, BUTTON_HEIGHT,
|
|
"btnOptions", "Options", (void(*)(char*))edit_options);
|
|
window_addButton(wid, 20, 20 + BUTTON_HEIGHT*2 + 20*2,
|
|
BUTTON_WIDTH, BUTTON_HEIGHT,
|
|
"btnResume", "Resume", menu_small_close);
|
|
|
|
pause();
|
|
menu_open = 1;
|
|
}
|
|
|
|
void menu_small_close(char* str) {
|
|
if(strcmp(str, "btnResume")==0)
|
|
window_destroy(window_get("Menu"));
|
|
|
|
unpause();
|
|
menu_open = 0;
|
|
}
|
|
|
|
// Edit the options.
|
|
static void edit_options(void) {
|
|
// TODO
|
|
}
|
|
|
|
// Exit the game.
|
|
static void exit_game(void) {
|
|
SDL_Event quit;
|
|
quit.type = SDL_QUIT;
|
|
SDL_PushEvent(&quit);
|
|
}
|
|
|