diff --git a/src/core.c b/src/core.c index f27576c..5dd3d55 100644 --- a/src/core.c +++ b/src/core.c @@ -141,12 +141,8 @@ void manage_mutation(struct game *current_game, const int mutation_menu) // Manage input if (key == KEY_EXIT) end = 1; - if (key == KEY_EXE && table[c.y][c.x] != 15 && table[c.y][c.x] != 0) - { - mutation_selected(c, mutation_menu, table); - getkey(); - } - + if (key == KEY_EXE && table[c.y][c.x] != 15 && table[c.y][c.x] != 0) mutation_buy(current_game, c, mutation_menu, table); + if (key == KEY_LEFT && c.x > 0) c.x--; if (key == KEY_RIGHT && c.x < 7) c.x++; if (key == KEY_UP && c.y > 0) c.y--; @@ -154,3 +150,25 @@ void manage_mutation(struct game *current_game, const int mutation_menu) } if (t >= 0) timer_stop(t); } + + +void mutation_buy(struct game *current_game, const struct cursor c, const int mutation_menu, const int table[4][8]) +{ + int button_selected = 0, end = 0; + int key = 0; + + while (!end) + { + mutation_selected(c, mutation_menu, table, button_selected); + key = getkey().key; + + if (key == KEY_DOWN || key == KEY_UP) button_selected = (button_selected + 1) % 2; + if (key == KEY_EXIT) end = 1; + if (key == KEY_EXE) + { + if (!button_selected) end = 1; + // else evolution + } + + } +} diff --git a/src/core.h b/src/core.h index b6e9545..71e66a8 100644 --- a/src/core.h +++ b/src/core.h @@ -76,7 +76,10 @@ int rtc_key(void); // callback_timer : basic timer int callback_tick(volatile int *tick); -// manage_mutation : an independant sub-programm which allow to select, buy and see the mutations. -void manage_mutation(struct game *current_game, const int mutation_menu); +// manage_mutation : an independant sub-programm which allow to select and see the mutations. +void mutation_select(struct game *current_game, const int mutation_menu); + +// mutation_buy : UI interface to buy mutations and see informations on them +void mutation_buy(struct game *current_game, const struct cursor c, const int mutation_menu, const int table[4][8]) #endif /* _PLAGUE_CORE_H */ \ No newline at end of file diff --git a/src/display_engine.c b/src/display_engine.c index 98e4cc9..7280944 100644 --- a/src/display_engine.c +++ b/src/display_engine.c @@ -99,7 +99,7 @@ void display_mutation(const int table[4][8], const struct cursor c, const int mu } -void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8]) +void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected) { extern const bopti_image_t img_mutations; const int id = table[c.y][c.x]; @@ -135,7 +135,10 @@ void mutation_selected(const struct cursor c, const int mutation_menu, const int dprint(81, 41, C_BLACK, "%d", mutation_data->contagion); dprint(81, 49, C_BLACK, "%d", mutation_data->lethality); dprint(81, 57, C_BLACK, "%d", mutation_data->severity); - + + if (button_selected) drect(81, 2, 123, 8, C_INVERT); + else drect(81, 12, 123, 18, C_INVERT); + dupdate(); diff --git a/src/display_engine.h b/src/display_engine.h index 23898a9..21670df 100644 --- a/src/display_engine.h +++ b/src/display_engine.h @@ -12,7 +12,7 @@ void display_foreground(const int background, const struct game *current_game); // display_mutation : display the mutation selection screen void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu); -// mutation_selected : display the mutation shop -void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8]); +// mutation_selected : display the mutation's informations screen +void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected); #endif /* _PLAGUE_DISPLAY_ENGINE_H */ \ No newline at end of file