summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-08-03 18:24:49 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-08-03 18:24:49 (EDT)
commitbe35760db2ebc72913f88b512b93d1c66c2f4ef5 (patch)
tree2d954c6a33735a730b3c5b1d317895b8db291067
parent69e7e111fb65cd3473e1aa3386d4607d95f34785 (diff)
downloadmazefight-be35760db2ebc72913f88b512b93d1c66c2f4ef5.zip
mazefight-be35760db2ebc72913f88b512b93d1c66c2f4ef5.tar.gz
mazefight-be35760db2ebc72913f88b512b93d1c66c2f4ef5.tar.bz2
splash: Add non-functional "Play" button
-rw-r--r--src/defs.h8
-rw-r--r--src/splash.c26
2 files changed, 32 insertions, 2 deletions
diff --git a/src/defs.h b/src/defs.h
index 0b7a47a..6f86aea 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -47,13 +47,17 @@
#define MF_COLOR_MAZE_G 0x00
#define MF_COLOR_MAZE_B 0x00
#define MF_COLOR_MAZE_A 0xFF
-#define MF_COLOR_FORM_R 0xDF /* Text/button color */
+#define MF_COLOR_FORM_R 0xDF /* Form background color */
#define MF_COLOR_FORM_G 0xDF
#define MF_COLOR_FORM_B 0xDF
#define MF_COLOR_FORM_A 0xDF
-#define MF_COLOR_FORE_R 0x00 /* Text/button color */
+#define MF_COLOR_FORE_R 0x00 /* Text color */
#define MF_COLOR_FORE_G 0x00
#define MF_COLOR_FORE_B 0x00
#define MF_COLOR_FORE_A 0xFF
+#define MF_COLOR_BUTN_R 0xAF /* Button fill color */
+#define MF_COLOR_BUTN_G 0xAF
+#define MF_COLOR_BUTN_B 0xAF
+#define MF_COLOR_BUTN_A 0xFF
#endif /* MF_DEFS_H_ */
diff --git a/src/splash.c b/src/splash.c
index a2d0f47..a12a8a0 100644
--- a/src/splash.c
+++ b/src/splash.c
@@ -36,6 +36,9 @@ mf_splash(SDL_Renderer *renderer)
TTF_Font *font;
SDL_Rect title_rect;
SDL_Texture *title_texture;
+ SDL_Color butn_color;
+ SDL_Rect play_btn_rect;
+ SDL_Texture *play_btn_texture;
SDL_Rect form_rect;
struct mf_maze *maze;
SDL_Color maze_color;
@@ -47,6 +50,10 @@ mf_splash(SDL_Renderer *renderer)
text_color.g = MF_COLOR_FORE_G;
text_color.b = MF_COLOR_FORE_B;
text_color.a = MF_COLOR_FORE_A;
+ butn_color.r = MF_COLOR_BUTN_R;
+ butn_color.g = MF_COLOR_BUTN_G;
+ butn_color.b = MF_COLOR_BUTN_B;
+ butn_color.a = MF_COLOR_BUTN_A;
/* Render title text */
font = TTF_OpenFont(font_path, MF_SPLASH_TITLE_FONT_S);
@@ -67,8 +74,26 @@ mf_splash(SDL_Renderer *renderer)
title_rect.x = (MF_WINDOW_W - title_rect.w) / 2;
title_rect.y += MF_SPLASH_WINDOW_P + MF_SPLASH_FORM_P;
+ font = TTF_OpenFont(font_path, MF_SPLASH_TEXT_FONT_S);
+ if (font == NULL) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "Couldn't open font: %s",
+ TTF_GetError());
+ free(font_path);
+ return -1;
+ }
+
/* TODO: Widgets */
+ /* Render play button */
+ play_btn_texture = mf_widget_button(font, "Play", &text_color,
+ &butn_color, 2, renderer, &play_btn_rect);
+ play_btn_rect.x = (MF_WINDOW_W - play_btn_rect.w) / 2;
+ play_btn_rect.y += title_rect.y + title_rect.h + MF_SPLASH_TITLE_M;
+
+ TTF_CloseFont(font);
+ font = NULL;
+
/* TODO: Size to widgets and center in window */
form_rect.x = MF_SPLASH_WINDOW_P;
form_rect.y = MF_SPLASH_WINDOW_P;
@@ -110,6 +135,7 @@ mf_splash(SDL_Renderer *renderer)
MF_COLOR_FORM_B, MF_COLOR_FORM_A);
SDL_RenderFillRect(renderer, &form_rect);
SDL_RenderCopy(renderer, title_texture, NULL, &title_rect);
+ SDL_RenderCopy(renderer, play_btn_texture, NULL,&play_btn_rect);
SDL_RenderPresent(renderer);
}