Skip to content
Snippets Groups Projects
Commit 723e7da2 authored by tanguy.cavagna's avatar tanguy.cavagna :desktop:
Browse files

Better menu and returning to menu handling

parent cffb3ddd
No related branches found
No related tags found
No related merge requests found
......@@ -9,17 +9,13 @@
int main(void) {
setlocale(LC_ALL, "");
init_term();
int menu_choice;
int menu_choice = show_menu();
if (menu_choice == MENU_QUIT) {
cleanup_term();
return EXIT_SUCCESS;
}
clear();
set_gamemode(menu_choice);
launch_game();
while ((menu_choice = show_menu()) != MENU_QUIT) {
clear();
set_gamemode(menu_choice);
launch_game();
};
cleanup_term();
......
......@@ -44,6 +44,17 @@ void draw_menu(int menu_item) {
}
}
/**
* @brief Hide the help subwindow
*/
void hide_help() {
wclear(ui_window);
delwin(help);
refresh();
help = NULL;
}
//==========================
// PUBLIC
//==========================
......@@ -80,6 +91,8 @@ void cleanup_term() {
}
int show_menu() {
hide_help();
char title[8][64] = {"$$\\ $$\\ $$$$$$\\ $$$$$$$\\ $$$$$$$\\ $$\\ $$$$$$$$\\ ",
"$$ | $\\ $$ |$$ __$$\\ $$ __$$\\ $$ __$$\\ $$ | $$ _____|",
"$$ |$$$\\ $$ |$$ / $$ |$$ | $$ |$$ | $$ |$$ | $$ | ",
......@@ -133,11 +146,7 @@ int show_menu() {
void toggle_help() {
// Delete existing instance of the subwindow
if (help != NULL) {
wclear(ui_window);
delwin(help);
refresh();
help = NULL;
hide_help();
return;
}
......
......@@ -15,6 +15,12 @@ int current_try_letter_id = 0;
* @brief Initialize the game
*/
void initialize_game() {
// Reset game variables
_game_finished = false;
current_try_id = 0;
current_try_letter_id = 0;
// Tries and answer setup
chosen_word = "SALUT"; // Must be randomly picked in a dictionary
tries = calloc(TRIES_COUNT, sizeof(char *));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment