summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/local.mk4
-rw-r--r--src/main.c4
-rw-r--r--src/menu.c (renamed from src/splash.c)82
-rw-r--r--src/menu.h (renamed from src/splash.h)8
4 files changed, 48 insertions, 50 deletions
diff --git a/src/local.mk b/src/local.mk
index 8a8f951..caa664c 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -5,8 +5,8 @@ mazefight_SOURCES += \
%reldir%/main.c \
%reldir%/maze.c \
%reldir%/maze.h \
- %reldir%/splash.c \
- %reldir%/splash.h \
+ %reldir%/menu.c \
+ %reldir%/menu.h \
%reldir%/tk.h \
%reldir%/util.c \
%reldir%/util.h
diff --git a/src/main.c b/src/main.c
index ff248f1..d82aa41 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include "defs.h"
#include "dirs.h"
-#include "splash.h"
+#include "menu.h"
static SDL_Window *_mf_window;
static SDL_Renderer *_mf_renderer;
@@ -99,7 +99,7 @@ main(int argc __attribute__((__unused__)),
}
e = EXIT_SUCCESS;
- if (mf_splash(_mf_renderer) < 0) {
+ if (mf_menu(_mf_renderer) < 0) {
e = EXIT_FAILURE;
}
diff --git a/src/splash.c b/src/menu.c
index b76b0cc..9d4e55e 100644
--- a/src/splash.c
+++ b/src/menu.c
@@ -27,11 +27,11 @@
#include "defs.h"
#include "dirs.h"
#include "maze.h"
-#include "splash.h"
+#include "menu.h"
#include "tk.h"
#include "util.h"
-struct _mf_splash {
+struct _mf_menu {
long seed;
int size;
int fow;
@@ -40,29 +40,29 @@ struct _mf_splash {
};
static int
-_mf_splash_seed(void *user_data, const char *seed)
+_mf_menu_seed(void *user_data, const char *seed)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
- splash->seed = atol(seed);
+ menu->seed = atol(seed);
return 0;
}
static int
-_mf_splash_size(void *user_data, int state)
+_mf_menu_size(void *user_data, int state)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
switch (state) {
case 0:
- splash->size = 15;
+ menu->size = 15;
break;
case 1:
- splash->size = 20;
+ menu->size = 20;
break;
case 2:
- splash->size = 30;
+ menu->size = 30;
break;
default:
break;
@@ -71,39 +71,39 @@ _mf_splash_size(void *user_data, int state)
}
static int
-_mf_splash_fow(void *user_data, int state)
+_mf_menu_fow(void *user_data, int state)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
- splash->fow = state;
+ menu->fow = state;
return 0;
}
static int
-_mf_splash_reveal(void *user_data, int state)
+_mf_menu_reveal(void *user_data, int state)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
- splash->reveal = state;
+ menu->reveal = state;
return 0;
}
static int
-_mf_splash_quit(void *user_data)
+_mf_menu_quit(void *user_data)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
- splash->quit = SDL_TRUE;
+ menu->quit = SDL_TRUE;
return 0;
}
static int
-_mf_splash_play(void *user_data)
+_mf_menu_play(void *user_data)
{
- struct _mf_splash *splash = (struct _mf_splash *) user_data;
+ struct _mf_menu *menu = (struct _mf_menu *) user_data;
/* TODO */
@@ -111,8 +111,8 @@ _mf_splash_play(void *user_data)
}
static struct mftk_widget *
-_mf_splash_form(SDL_Renderer *renderer, TTF_Font *text_font,
- SDL_Color *text_color, struct _mf_splash *splash)
+_mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font,
+ SDL_Color *text_color, struct _mf_menu *menu)
{
SDL_Color butn_color;
SDL_Color chkb_color;
@@ -130,7 +130,7 @@ _mf_splash_form(SDL_Renderer *renderer, TTF_Font *text_font,
rand_max_len = ceil(log10(RAND_MAX));
seed_buf = calloc(rand_max_len + 1, sizeof(*seed_buf));
- if (seed_buf == NULL || sprintf(seed_buf, "%ld", splash->seed) < 0) {
+ if (seed_buf == NULL || sprintf(seed_buf, "%ld", menu->seed) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Couldn't allocate string: %s",
strerror(errno));
@@ -141,15 +141,14 @@ _mf_splash_form(SDL_Renderer *renderer, TTF_Font *text_font,
mftk_label_new(text_font, "Seed", text_color, renderer),
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
mftk_text_new('0', '9', rand_max_len, seed_buf,
- text_font, text_color,
- &_mf_splash_seed, splash),
+ text_font, text_color, &_mf_menu_seed, menu),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T,
mftk_label_new(text_font, "Size", text_color, renderer),
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
mftk_radio_new(MF_SPLASH_CHK_BTN_W, MF_SPLASH_CHK_BTN_P,
&chkb_color, &chkm_color, MF_SPLASH_CHK_LBL_P,
MF_SPLASH_CHK_ITM_P, text_font, text_color,
- &_mf_splash_size, splash, renderer, 0, 3,
+ &_mf_menu_size, menu, renderer, 0, 3,
"15x15", "20x20", "30x30"),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T,
mftk_label_new(text_font, "Fog of war", text_color,
@@ -157,26 +156,25 @@ _mf_splash_form(SDL_Renderer *renderer, TTF_Font *text_font,
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
mftk_check_new(MF_SPLASH_CHK_BTN_W, MF_SPLASH_CHK_BTN_P,
&chkb_color, &chkm_color, SDL_TRUE, 0, NULL,
- NULL, NULL, &_mf_splash_fow, splash, renderer),
+ NULL, NULL, &_mf_menu_fow, menu, renderer),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T,
mftk_label_new(text_font, "Reveal maze", text_color,
renderer),
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
mftk_check_new(MF_SPLASH_CHK_BTN_W, MF_SPLASH_CHK_BTN_P,
&chkb_color, &chkm_color, SDL_FALSE, 0, NULL,
- NULL, NULL, &_mf_splash_reveal, splash,
- renderer),
+ NULL, NULL, &_mf_menu_reveal, menu, renderer),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T,
mftk_blank_new(),
MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T,
mftk_grid_new(1, 2, 0, MF_SPLASH_BTN_M,
mftk_button_new(text_font, "Quit", text_color,
&butn_color, MF_SPLASH_BTN_P,
- &_mf_splash_quit, splash, renderer),
+ &_mf_menu_quit, menu, renderer),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T,
mftk_button_new(text_font, "Play", text_color,
&butn_color, MF_SPLASH_BTN_P,
- &_mf_splash_play, splash, renderer),
+ &_mf_menu_play, menu, renderer),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T
),
MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T
@@ -186,11 +184,11 @@ _mf_splash_form(SDL_Renderer *renderer, TTF_Font *text_font,
}
int
-mf_splash(SDL_Renderer *renderer)
+mf_menu(SDL_Renderer *renderer)
{
struct mf_maze *maze = NULL;
SDL_Color maze_color;
- struct _mf_splash splash;
+ struct _mf_menu menu;
char *font_path = NULL;
TTF_Font *title_font = NULL;
TTF_Font *text_font = NULL;
@@ -211,11 +209,11 @@ mf_splash(SDL_Renderer *renderer)
maze_color.b = MF_COLOR_MAZE_B;
maze_color.a = MF_COLOR_MAZE_A;
- splash.seed = rand();
- splash.size = 15;
- splash.fow = SDL_TRUE;
- splash.reveal = SDL_FALSE;
- splash.quit = SDL_FALSE;
+ menu.seed = rand();
+ menu.size = 15;
+ menu.fow = SDL_TRUE;
+ menu.reveal = SDL_FALSE;
+ menu.quit = SDL_FALSE;
font_path = mf_strcat(mf_get_fonts_dir(), "/FifteenTwenty-Regular.ttf");
title_font = TTF_OpenFont(font_path, MF_SPLASH_TITLE_FONT_S);
@@ -244,8 +242,8 @@ mf_splash(SDL_Renderer *renderer)
mftk_label_new(title_font, "Maze Fight",
&text_color, renderer),
MFTK_GRID_HALIGN_C|MFTK_GRID_VALIGN_T,
- _mf_splash_form(renderer, text_font,
- &text_color, &splash),
+ _mf_menu_form(renderer, text_font,
+ &text_color, &menu),
MFTK_GRID_HALIGN_C|MFTK_GRID_VALIGN_T
)
)
@@ -266,7 +264,7 @@ mf_splash(SDL_Renderer *renderer)
break;
}
mftk_window_event(win, &event);
- if (splash.quit) {
+ if (menu.quit) {
goto quit;
}
SDL_SetRenderDrawColor(renderer,
diff --git a/src/splash.h b/src/menu.h
index 9b76db5..448cf79 100644
--- a/src/splash.h
+++ b/src/menu.h
@@ -17,12 +17,12 @@
* along with Maze Fight. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MF_SPLASH_H_
-#define MF_SPLASH_H_
+#ifndef MF_MENU_H_
+#define MF_MENU_H_
#include <SDL.h>
int
-mf_splash(SDL_Renderer *renderer);
+mf_menu(SDL_Renderer *renderer);
-#endif /* MF_SPLASH_H_ */
+#endif /* MF_MENU_H_ */