save button beautiful
This commit is contained in:
1 parent
021d9031ad
commit
b8505b5a12
1 file changed
+23
-21
@@ -187,16 +187,20 @@ Env* init(SDL_Renderer* ren, int argc, char* argv[]) {
|
||||
} else {
|
||||
usage(argv);
|
||||
}
|
||||
void** env_tab[] = {(void**)&(env->zero), (void**)&(env->one), (void**)&(env->two), (void**)&(env->three),
|
||||
(void**)&(env->four), (void**)&(env->lightbulb), (void**)&(env->text_redo), (void**)&(env->text_restart),
|
||||
(void**)&(env->text_solve), (void**)&(env->text_undo), (void**)&(env->text_save), (void**)&(env->rec_game),
|
||||
(void**)&(env->rec_redo), (void**)&(env->rec_restart), (void**)&(env->rec_solve), (void**)&(env->rec_undo),
|
||||
uint sizeof_array[] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, 1}; // size of each element to allocate
|
||||
uint cpt = 0;
|
||||
void** env_tab[] = {(void**)&(env->zero), (void**)&(env->one), (void**)&(env->two), (void**)&(env->three),
|
||||
(void**)&(env->four), (void**)&(env->text_restart), (void**)&(env->text_undo), (void**)&(env->text_redo),
|
||||
(void**)&(env->text_solve), (void**)&(env->text_save), (void**)&(env->lightbulb), (void**)&(env->rec_game),
|
||||
(void**)&(env->rec_redo), (void**)&(env->rec_restart), (void**)&(env->rec_solve), (void**)&(env->rec_undo),
|
||||
(void**)&(env->rec_save)};
|
||||
unsigned long sizeof_env_tab[] = {sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2,
|
||||
sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2,
|
||||
sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Texture*) * 2, sizeof(SDL_Rect),
|
||||
sizeof(SDL_Rect), sizeof(SDL_Rect), sizeof(SDL_Rect), sizeof(SDL_Rect),
|
||||
sizeof(SDL_Rect)};
|
||||
unsigned long sizeof_env_tab[] = {
|
||||
sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++],
|
||||
sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++],
|
||||
sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++],
|
||||
sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Texture*) * sizeof_array[cpt++], sizeof(SDL_Rect) * sizeof_array[cpt++],
|
||||
sizeof(SDL_Rect) * sizeof_array[cpt++], sizeof(SDL_Rect) * sizeof_array[cpt++], sizeof(SDL_Rect) * sizeof_array[cpt++],
|
||||
sizeof(SDL_Rect) * sizeof_array[cpt++], sizeof(SDL_Rect) * sizeof_array[cpt++]};
|
||||
init_malloc(env_tab, sizeof_env_tab, sizeof(env_tab) / sizeof(env_tab[0]));
|
||||
// if the case has not error
|
||||
env->lightbulb[0] = IMG_LoadTexture(ren, LIGHTBULB_WHITE);
|
||||
@@ -224,22 +228,20 @@ Env* init(SDL_Renderer* ren, int argc, char* argv[]) {
|
||||
#endif
|
||||
|
||||
/*Creation of the differents textures and place them in env*/
|
||||
SDL_Color color_w = {255, 255, 255, 255}; // color of 0 in black wall with error
|
||||
SDL_Color color_r = {255, 50, 50, 255}; /* blue color in RGBA */
|
||||
SDL_Color color_b = {0, 0, 0, 255}; /* black color in RGBA*/
|
||||
SDL_Color color_w = {255, 255, 255, SDL_ALPHA_OPAQUE}; // color of 0 in black wall with error
|
||||
SDL_Color color_r = {255, 50, 50, SDL_ALPHA_OPAQUE}; /* blue color in RGBA */
|
||||
SDL_Color color_g = {0, 150, 0, SDL_ALPHA_OPAQUE}; /* green color in RGBA */
|
||||
SDL_Color color_b = {0, 0, 0, SDL_ALPHA_OPAQUE}; /* black color in RGBA*/
|
||||
|
||||
char* tab_texts_double[] = {"0", "1", "2", "3", "4", "Restart", "Undo", "Redo", "Solve", "Save"};
|
||||
|
||||
SDL_Color color_of_texts[] = {color_w, color_r, color_w, color_r, color_w, color_r, color_w, color_r, color_w, color_r, color_w,
|
||||
color_b, color_w, color_b, color_w, color_b, color_w, color_b, color_w, color_b, color_g};
|
||||
SDL_Texture** tab_textures_double[] = {env->zero, env->one, env->two, env->three, env->four,
|
||||
env->text_restart, env->text_undo, env->text_redo, env->text_solve, env->text_save};
|
||||
|
||||
SDL_Color color_tab[] = {color_w, color_r};
|
||||
cpt = 0;
|
||||
for (uint i = 0; i < sizeof(tab_textures_double) / sizeof(tab_textures_double[0]); i++) {
|
||||
if (i > 4) {
|
||||
color_tab[1] = color_b;
|
||||
}
|
||||
for (int j = 0; j < 2; j++) {
|
||||
tab_textures_double[i][j] = render_blended_text(ren, color_tab[j], tab_texts_double[i]);
|
||||
for (uint j = 0; j < sizeof_array[i]; j++) {
|
||||
tab_textures_double[i][j] = render_blended_text(ren, color_of_texts[cpt++], tab_texts_double[i]);
|
||||
}
|
||||
}
|
||||
return env;
|
||||
@@ -394,7 +396,7 @@ void render(SDL_Window* win, SDL_Renderer* ren, Env* env) {
|
||||
SDL_RenderCopy(ren, env->text_solve[env->pressed_solve ? 1 : 0], NULL, &buttons);
|
||||
buttons.x += buttons.w + (w / NB_BUTTONS - w / (NB_BUTTONS + 1));
|
||||
*(env->rec_save) = buttons;
|
||||
SDL_RenderCopy(ren, env->text_save[env->pressed_save ? 1 : 0], NULL, &buttons);
|
||||
SDL_RenderCopy(ren, env->text_save[env->pressed_savED ? 2 : env->pressed_save ? 1 : 0], NULL, &buttons);
|
||||
// render cases
|
||||
for (uint i = 0; i < game_nb_rows(env->g); i++) {
|
||||
for (uint j = 0; j < game_nb_cols(env->g); j++) {
|
||||
|
||||
Reference in new issue
Block a user