Le support aux utilisateurs et les demandes de création de comptes externes doivent être faites depuis les issues du projet GitLab HEFR (https://gitlab.forge.hefr.ch/forge-hefr/gitlab-hefr)

Commit 1b9f0ae3 authored by Arton Hoxha's avatar Arton Hoxha
Browse files

change reset to confirm for better ux and fixed bug when click on SW1 if no letters are chosen

parent 2143e0a5
Pipeline #15135 passed with stages
in 14 seconds
......@@ -37,7 +37,7 @@ static void s1_handler(void* param)
game* game = (struct game*)param;
printf("game state: %d", game->inSelection);
if (game->inSelection) {
if (game->inSelection && game->selected_word[0]) {
leds_set_state(LED_1, true);
msgq_post(game->events_msq, (void*)GAME_BTN_CLICK);
} else {
......
......@@ -23,20 +23,22 @@ char* players_str[2] = {
[1] = "Player 2 wins",
};
char* reset = "Reset word?";
char* reset = "Confirm ?";
// Current id of the menu item selected
unsigned current_choice = 1;
static void menu_display(game* game)
{
printf("choice display: %d\n", current_choice);
if (game->inMenu) {
lcd_draw_rect(0, 50, 0, 95, BLACK);
lcd_display_string(reset, 0, 0, false);
lcd_display_string(game->selected_word, 45, 0, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(RED);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
} else if (game->inEndMenu) {
if (game->hasWon) {
......@@ -45,41 +47,42 @@ static void menu_display(game* game)
lcd_display_string(players_str[0], 0, 0, false);
}
lcd_display_string("Replay ?", 48, 20, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(RED);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
}
}
static void change_option(game* game)
{
printf("choice: %d\n", current_choice);
if (current_choice == 1) {
if (game->inMenu) {
lcd_change_text_color(RED);
lcd_display_string(choices[1], 65, 65, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
} else if (game->inEndMenu) {
// Render menu end
lcd_change_text_color(RED);
lcd_display_string(choices[1], 65, 65, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
}
} else {
if (game->inMenu) {
lcd_change_text_color(RED);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
} else if (game->inEndMenu) {
// Render menu end
lcd_change_text_color(RED);
lcd_display_string(choices[0], 65, 35, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[1], 65, 65, false);
lcd_change_text_color(WHITE);
lcd_display_string(choices[0], 65, 35, false);
}
}
}
......@@ -91,20 +94,19 @@ static void menu_wheel_handler(game_menu menu_event, game* game)
} else if (menu_event == MENU_RESET) {
current_choice = 1;
} else if (menu_event == MENU_LEFT) {
current_choice = 0;
current_choice = 1;
change_option(game);
} else if (menu_event == MENU_RIGHT) {
current_choice = 1;
current_choice = 0;
change_option(game);
} else if (menu_event == MENU_CLICK) {
if (current_choice == 0) {
if (game->inMenu) { // reset
game->inMenu = false;
msgq_post(game->events_msq, (void*)GAME_RESET_SELECTION);
} else if (game->inEndMenu) { // play again
game->inEndMenu = false;
msgq_post(game->events_msq, (void*)GAME_RESET_SELECTION);
} else if (game->inEndMenu) { // end game
msgq_post(game->render_msq, (void*)RENDER_END);
}
} else if (current_choice == 1) {
......@@ -112,13 +114,13 @@ static void menu_wheel_handler(game_menu menu_event, game* game)
msgq_post(game->events_msq, (void*)GAME_START);
game->inMenu = false;
game->inGame = true;
} else if (game->inEndMenu) { // end the game
msgq_post(game->render_msq, (void*)RENDER_END);
} else if (game->inEndMenu) { // play again
game->inEndMenu = false;
msgq_post(game->events_msq, (void*)GAME_RESET_SELECTION);
}
}
current_choice = 1;
}
printf("Current CHOICE: %d", current_choice);
}
void thread_menu(void* param)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment