summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f42eb9b)
raw | patch | inline | side by side (parent: f42eb9b)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 29 Apr 2020 06:34:52 +0000 (10:34 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 29 Apr 2020 06:34:52 +0000 (10:34 +0400) |
src/gl/render.c | patch | blob | history | |
src/menu.c | patch | blob | history | |
src/menu.h | patch | blob | history | |
src/openal/sound.c | patch | blob | history | |
src/sdlmixer/sound.c | patch | blob | history | |
src/soft/render.c | patch | blob | history |
diff --git a/src/gl/render.c b/src/gl/render.c
index 0dc1ac30144082ebe1a292f9bf0e419cfd42fe25..22667f7542880b709f7a543e38cff9aee566428c 100644 (file)
--- a/src/gl/render.c
+++ b/src/gl/render.c
R_reload_textures();
}
-static int video_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int video_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
static int w, h, fullscreen;
static char buf[16];
@@ -1935,12 +1935,9 @@ static int video_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t video_menu = {
- NULL, &video_menu_handler
-};
-
const menu_t *R_menu (void) {
- return &video_menu;
+ static const menu_t m = { video_menu_handler };
+ return &m;
}
const cfg_t *R_args (void) {
diff --git a/src/menu.c b/src/menu.c
index 7286a45375a11e4a271996357ad3b9150b93f9d6..ddbf0b4deb8a35a4e8735d9fec8d060bcdb457cd 100644 (file)
--- a/src/menu.c
+++ b/src/menu.c
return GM_popall();
}
-static int new_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int new_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
enum { ONEPLAYER, TWOPLAYERS, DEATHMATCH, __NUM__ };
static const simple_menu_t sm = {
@@ -184,11 +184,7 @@ static int new_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data,
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t new_game_menu = {
- NULL, &new_game_menu_handler
-};
-
-static int load_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int load_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
const int max_slots = 7;
assert(i >= 0 && i < max_slots);
@@ -206,11 +202,7 @@ static int load_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data,
return basic_menu_handler(msg, GM_BIG, "Load game", "_OLDGAME", max_slots, &cur);
}
-static const menu_t load_game_menu = {
- NULL, &load_game_menu_handler
-};
-
-static int save_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int save_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
const int max_slots = 7;
assert(i >= 0 && i < max_slots);
@@ -234,11 +226,7 @@ static int save_game_menu_handler (menu_msg_t *msg, const menu_t *m, void *data,
return basic_menu_handler(msg, GM_BIG, "Save game", "_SAVGAME", max_slots, &cur);
}
-static const menu_t save_game_menu = {
- NULL, &save_game_menu_handler
-};
-
-static int options_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int options_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
const menu_t *mm;
enum { VIDEO, SOUND, MUSIC, __NUM__ };
@@ -264,11 +252,7 @@ static int options_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, i
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t options_menu = {
- NULL, &options_menu_handler
-};
-
-static int exit_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int exit_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
enum { YES, NO, __NUM__ };
static const simple_menu_t sm = {
@@ -296,30 +280,31 @@ static int exit_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t exit_menu = {
- NULL, &exit_menu_handler
-};
-
-static int main_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
- static int cur;
+static int main_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
enum { NEWGAME, OLDGAME, SAVEGAME, OPTIONS, EXIT, __NUM__ };
assert(i >= 0 && i < __NUM__);
+ static int cur;
+ static const menu_t hm[__NUM__] = {
+ { new_game_menu_handler },
+ { load_game_menu_handler },
+ { save_game_menu_handler },
+ { options_menu_handler},
+ { exit_menu_handler }
+ };
static const simple_menu_t sm = {
GM_BIG, "Menu", NULL,
{
- { "New Game", &new_game_menu },
- { "Load Game", &load_game_menu },
- { "Save Game", &save_game_menu },
- { "Options", &options_menu },
- { "Exit", &exit_menu },
+ { "New Game", &hm[NEWGAME] },
+ { "Load Game", &hm[OLDGAME] },
+ { "Save Game", &hm[SAVEGAME] },
+ { "Options", &hm[OPTIONS] },
+ { "Exit", &hm[EXIT] }
}
};
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t main_menu = {
- NULL, &main_menu_handler
-};
+static const menu_t main_menu = { &main_menu_handler };
int GM_push (const menu_t *m) {
assert(m != NULL);
assert(msg != NULL);
if (m->handler != NULL) {
GM_normalize_message(msg);
- return m->handler(msg, m, m->data, 0);
+ return m->handler(msg, m, 0);
}
return 0;
}
assert(msg != NULL);
if (m->handler != NULL) {
GM_normalize_message(msg);
- return m->handler(msg, m, m->data, i);
+ return m->handler(msg, m, i);
}
return 0;
}
diff --git a/src/menu.h b/src/menu.h
index 39f064a61e74931daa291cd20bbb92fc8db51e51..daee0d78d871520bc6dcf4dc4ba2cbf13cb0eda6 100644 (file)
--- a/src/menu.h
+++ b/src/menu.h
typedef struct menu_t menu_t;
struct menu_t {
- void *data;
- int (*handler)(menu_msg_t *msg, const menu_t *m, void *data, int i);
+ int (*handler)(menu_msg_t *msg, const menu_t *m, int i);
};
typedef struct simple_menu_t {
diff --git a/src/openal/sound.c b/src/openal/sound.c
index ef9afdab2b09c6d8fb26bda6d4f74b09947f55c0..f4f07b9b6e91112d15b1b154dad7e8b4bcfa4df3 100644 (file)
--- a/src/openal/sound.c
+++ b/src/openal/sound.c
@@ -115,9 +115,7 @@ static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
}
const menu_t *S_menu (void) {
- static const menu_t m = {
- NULL, &sound_menu_handler
- };
+ static const menu_t m = { sound_menu_handler };
return &m;
}
diff --git a/src/sdlmixer/sound.c b/src/sdlmixer/sound.c
index ddacddf2497ff55556609a01a2303242de686649..638ec34d3e5ffd0929b197622ba334f3bb32ec0b 100644 (file)
--- a/src/sdlmixer/sound.c
+++ b/src/sdlmixer/sound.c
@@ -105,9 +105,7 @@ static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
}
const menu_t *S_menu (void) {
- static const menu_t m = {
- NULL, &sound_menu_handler
- };
+ static const menu_t m = { sound_menu_handler };
return &m;
}
diff --git a/src/soft/render.c b/src/soft/render.c
index 705de17f30725cecf1d45697c402b164ef706e6a..bf0ca079c2684f103e47f176c067e43f2be97d4f 100644 (file)
--- a/src/soft/render.c
+++ b/src/soft/render.c
@@ -1566,12 +1566,9 @@ static int video_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
return simple_menu_handler(msg, i, __NUM__, &sm, &cur);
}
-static const menu_t video_menu = {
- NULL, &video_menu_handler
-};
-
const menu_t *R_menu (void) {
- return &video_menu;
+ static const menu_t m = { video_menu_handler };
+ return &m;
}
const cfg_t *R_args (void) {