diff options
-rw-r--r-- | src/menu.c | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -140,20 +140,13 @@ _mf_menu_play(void *user_data) static struct mftk_widget * _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font, - SDL_Color *text_color, struct _mf_menu *menu) + SDL_Color *text_color, SDL_Color *butn_color, + SDL_Color *chkb_color, SDL_Color *chkm_color, + struct _mf_menu *menu) { - SDL_Color butn_color; - SDL_Color chkb_color; - SDL_Color chkm_color; double rand_max_len; struct mftk_widget *grid; - 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; - chkb_color.r = MF_COLOR_CHKB_R, chkb_color.g = MF_COLOR_CHKB_G; - chkb_color.b = MF_COLOR_CHKB_B, chkb_color.a = MF_COLOR_CHKB_A; - chkm_color.r = MF_COLOR_CHKM_R, chkm_color.g = MF_COLOR_CHKM_G; - chkm_color.b = MF_COLOR_CHKM_B, chkm_color.a = MF_COLOR_CHKM_A; rand_max_len = ceil(log10(RAND_MAX)); menu->seed_buf = calloc(rand_max_len + 1, sizeof(*menu->seed_buf)); @@ -188,8 +181,8 @@ _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font, 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_CHK_BTN_W, MF_CHK_BTN_P, &chkb_color, - &chkm_color, MF_CHK_LBL_P, MF_CHK_ITM_P, + mftk_radio_new(MF_CHK_BTN_W, MF_CHK_BTN_P, chkb_color, + chkm_color, MF_CHK_LBL_P, MF_CHK_ITM_P, text_font, text_color, &_mf_menu_size, &_mf_menu_play, menu, renderer, 0, 3, "15x15", "20x20", "30x30"), @@ -202,15 +195,15 @@ _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font, mftk_label_new(text_font, "Fog of war", text_color, renderer), MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T, - mftk_check_new(MF_CHK_BTN_W, MF_CHK_BTN_P, &chkb_color, - &chkm_color, SDL_TRUE, 0, NULL, NULL, NULL, + mftk_check_new(MF_CHK_BTN_W, MF_CHK_BTN_P, chkb_color, + chkm_color, SDL_TRUE, 0, NULL, NULL, NULL, &_mf_menu_fow, &_mf_menu_play, 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_CHK_BTN_W, MF_CHK_BTN_P, &chkb_color, - &chkm_color, SDL_FALSE, 0, NULL, NULL, NULL, + mftk_check_new(MF_CHK_BTN_W, MF_CHK_BTN_P, chkb_color, + chkm_color, SDL_FALSE, 0, NULL, NULL, NULL, &_mf_menu_reveal, &_mf_menu_play, menu, renderer), MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T, @@ -218,11 +211,11 @@ _mf_menu_form(SDL_Renderer *renderer, TTF_Font *text_font, MFTK_GRID_HALIGN_R|MFTK_GRID_VALIGN_T, mftk_grid_new(1, 2, 0, MF_BTN_M, mftk_button_new(text_font, "Quit", text_color, - &butn_color, MF_BTN_P, &_mf_menu_quit, + butn_color, MF_BTN_P, &_mf_menu_quit, NULL, renderer), MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T, mftk_button_new(text_font, "Play", text_color, - &butn_color, MF_BTN_P, &_mf_menu_play, + butn_color, MF_BTN_P, &_mf_menu_play, menu, renderer), MFTK_GRID_HALIGN_L|MFTK_GRID_VALIGN_T ), @@ -243,6 +236,9 @@ mf_menu(SDL_Renderer *renderer) TTF_Font *text_font = NULL; SDL_Color form_color; SDL_Color text_color; + SDL_Color butn_color; + SDL_Color chkb_color; + SDL_Color chkm_color; struct mftk_window *win = NULL; SDL_Event event; @@ -289,6 +285,12 @@ mf_menu(SDL_Renderer *renderer) form_color.b = MF_COLOR_FORM_B, form_color.a = MF_COLOR_FORM_A; text_color.r = MF_COLOR_FORE_R, 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; + chkb_color.r = MF_COLOR_CHKB_R, chkb_color.g = MF_COLOR_CHKB_G; + chkb_color.b = MF_COLOR_CHKB_B, chkb_color.a = MF_COLOR_CHKB_A; + chkm_color.r = MF_COLOR_CHKM_R, chkm_color.g = MF_COLOR_CHKM_G; + chkm_color.b = MF_COLOR_CHKM_B, chkm_color.a = MF_COLOR_CHKM_A; win = mftk_window_new(0, 0, mftk_box_new(MF_WINDOW_W, MF_WINDOW_H, 0, 0, MF_FORM_P, &form_color, @@ -297,7 +299,9 @@ mf_menu(SDL_Renderer *renderer) &text_color, renderer), MFTK_GRID_HALIGN_C|MFTK_GRID_VALIGN_T, _mf_menu_form(renderer, text_font, - &text_color, &menu), + &text_color, &butn_color, + &chkb_color, &chkm_color, + &menu), MFTK_GRID_HALIGN_C|MFTK_GRID_VALIGN_T ) ) |