From c5341462e730960d5f82154d9f13db431b4609e8 Mon Sep 17 00:00:00 2001 From: "tanguy.cavagna" <tanguy.cavagna@etu.hesge.ch> Date: Wed, 18 May 2022 11:04:24 +0200 Subject: [PATCH] Added window too small clause for gameboard --- ui/ui.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/ui.c b/ui/ui.c index 995b115..1dbf5ec 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -96,6 +96,9 @@ void hide_help() { void printw_center(char *foo, int line) { mvaddstr(line, TERM_MID_COLS - (strlen(foo) / 2), foo); } void draw_title(int id) { + if (window_too_small()) + return; + for (int i = 0; i < TITLES_LINE_COUNT; i++) { switch (id) { case MAIN_TITLE_ID: @@ -240,7 +243,7 @@ void show_gameboard(int tries_count, int word_length, char **tries, int **valida for (int j = 0; j < word_length; j++) { // Placeholder if (tries[i][j] == '\0') { - mvaddch(GAMEBOARD_Y_OFFSET + i, TERM_MID_COLS - word_length + (j * 2), '_'); + mvaddch(GAMEBOARD_Y_OFFSET + i - menu_offset_modifer() + 5, TERM_MID_COLS - word_length + (j * 2), '_'); continue; } @@ -250,13 +253,13 @@ void show_gameboard(int tries_count, int word_length, char **tries, int **valida if (validations[i][j] == 2) attron(COLOR_PAIR(GREEN_PAIR)); - mvaddch(GAMEBOARD_Y_OFFSET + i, TERM_MID_COLS - word_length + (j * 2), tries[i][j]); + mvaddch(GAMEBOARD_Y_OFFSET + i - menu_offset_modifer() + 5, TERM_MID_COLS - word_length + (j * 2), tries[i][j]); attroff(COLOR_PAIR(GREEN_PAIR)); attroff(COLOR_PAIR(ORANGE_PAIR)); } } - move(GAMEBOARD_Y_OFFSET - 2, TERM_MID_COLS - word_length - 3); + move(GAMEBOARD_Y_OFFSET - 2 - menu_offset_modifer() + 5, TERM_MID_COLS - word_length - 3); printw("Score: %d", score); refresh(); -- GitLab