Manageme the UI for the purchase of mutations

This commit is contained in:
Shadow15510 2021-05-29 17:02:07 +02:00
parent f93811fdf5
commit 35b2b2435f
4 changed files with 36 additions and 12 deletions

View File

@ -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
}
}
}

View File

@ -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 */

View File

@ -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();

View File

@ -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 */