From be35760db2ebc72913f88b512b93d1c66c2f4ef5 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 03 Aug 2021 18:24:49 -0400 Subject: splash: Add non-functional "Play" button --- (limited to 'src/splash.c') 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); } -- cgit v0.9.1