From ecceb4f7eebc8204836e164c4ff655e9abbc2636 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 19 Mar 2021 14:29:17 -0400 Subject: src/defs.h: New macro definitions file --- (limited to 'src/main-menu.c') diff --git a/src/main-menu.c b/src/main-menu.c index 919b047..0bd135d 100644 --- a/src/main-menu.c +++ b/src/main-menu.c @@ -21,6 +21,7 @@ #include #include #include "collision.h" +#include "defs.h" #include "game.h" #include "help.h" #include "main-menu.h" @@ -121,18 +122,18 @@ db_main_menu(void) renderer = db_get_renderer(); - text_color.r = 0x00; - text_color.g = 0x00; - text_color.b = 0xFF; - text_color.a = 0xFF; + text_color.r = DB_COLOR_FORE_R; + text_color.g = DB_COLOR_FORE_G; + text_color.b = DB_COLOR_FORE_B; + text_color.a = DB_COLOR_FORE_A; - over_color.r = 0xFF; - over_color.g = 0xFF; - over_color.b = 0xFF; - over_color.a = 0xFF; + over_color.r = DB_COLOR_ACTV_R; + over_color.g = DB_COLOR_ACTV_G; + over_color.b = DB_COLOR_ACTV_B; + over_color.a = DB_COLOR_ACTV_A; /* Render title text */ - font = TTF_OpenFont(font_path, 48); + font = TTF_OpenFont(font_path, DB_FONT_TITLE_SIZE); if (font == NULL) { db_err("Failed to open font (%s)", TTF_GetError()); free(font_path); @@ -143,11 +144,11 @@ db_main_menu(void) if (texture_title == NULL) { goto err; } - dest_rect.x = 16; - dest_rect.y = 16; + dest_rect.x = DB_WINDOW_P; + dest_rect.y = DB_WINDOW_P; TTF_CloseFont(font); - font = TTF_OpenFont(font_path, 16); + font = TTF_OpenFont(font_path, DB_FONT_TEXT_SIZE); if (font == NULL) { db_err("Failed to open font (%s)", TTF_GetError()); free(font_path); @@ -179,8 +180,8 @@ db_main_menu(void) if (buttons[0]->texture_over == NULL) { goto err; } - buttons[0]->rect.x = 640 - 16 - buttons[0]->rect.w; - buttons[0]->rect.y = 16; + buttons[0]->rect.x = DB_WINDOW_W - DB_WINDOW_P - buttons[0]->rect.w; + buttons[0]->rect.y = DB_WINDOW_P; buttons[0]->action = &_db_main_menu_action_help; buttons[0]->user_data = NULL; @@ -200,8 +201,8 @@ db_main_menu(void) if (buttons[1]->texture_over == NULL) { goto err; } - buttons[1]->rect.x = 640 - 16 - buttons[1]->rect.w; - buttons[1]->rect.y = 48; + buttons[1]->rect.x = DB_WINDOW_W - DB_WINDOW_P - buttons[1]->rect.w; + buttons[1]->rect.y = DB_WINDOW_P + DB_FONT_TEXT_SIZE + DB_MARGIN; buttons[1]->action = &_db_main_menu_action_quit; buttons[1]->user_data = NULL; @@ -222,17 +223,20 @@ db_main_menu(void) } sprintf(name_desc, "%s\n%s", db_game_get_name(games[i]), db_game_get_desc(games[i])); - buttons[i + 2]->rect.x = 16; - buttons[i + 2]->rect.y = 80 + 48 * i + 2; + buttons[i + 2]->rect.x = DB_WINDOW_P; + buttons[i + 2]->rect.y = DB_WINDOW_P + DB_FONT_TITLE_SIZE + + DB_MARGIN + (DB_FONT_TEXT_SIZE * 2 + DB_MARGIN) * i; buttons[i + 2]->texture_text = _db_main_menu_text(font, - name_desc, &text_color, 608, renderer, + name_desc, &text_color, + DB_WINDOW_W - DB_WINDOW_P * 2, renderer, &buttons[i + 2]->rect); if (buttons[i + 2]->texture_text == NULL) { free(name_desc); goto err; } buttons[i + 2]->texture_over = _db_main_menu_text(font, - name_desc, &over_color, 608, renderer, + name_desc, &over_color, + DB_WINDOW_W - DB_WINDOW_P * 2, renderer, &buttons[i + 2]->rect); free(name_desc); if (buttons[i + 2]->texture_over == NULL) { @@ -372,7 +376,9 @@ db_main_menu(void) if (_db_main_menu_quit > 0) { break; } - SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF); + SDL_SetRenderDrawColor(renderer, + DB_COLOR_BACK_R, DB_COLOR_BACK_G, + DB_COLOR_BACK_B, DB_COLOR_BACK_A); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture_title, NULL, &dest_rect); for (i = 0; i < n + 2; ++i) { -- cgit v0.9.1