From d4fc8db4894d9681db85ef422c7af79277c17f48 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Aug 2023 12:23:07 +0200 Subject: [PATCH] Fixed a bug when displaying 3 choices. --- src/dialogs.c | 20 ++++++++++---------- src/game.c | 9 +++++++-- src/main.c | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/dialogs.c b/src/dialogs.c index e6c313e..c6ce40f 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -247,8 +247,8 @@ int _choice_call_before_end(Game *game, unsigned int org_i) { C_BLACK, ">"); dtext(i*choice_size+arrow_width+PXSIZE, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, C_BLACK, - _choices+pos+i); - pos += strlen(_choices+pos); + _choices+pos); + pos += strlen(_choices+pos)+1; } blit(); key = getkey().key; @@ -257,10 +257,10 @@ int _choice_call_before_end(Game *game, unsigned int org_i) { if(key == KEY_LEFT && selected > 0){ /* Remove the old arrow. */ drect(selected*choice_size+PXSIZE, - (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, - selected*choice_size+PXSIZE+arrow_width, - (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, - C_WHITE); + (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, + selected*choice_size+PXSIZE+arrow_width, + (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, + C_WHITE); /* Move the selection arrow and update the selected item. */ selected--; @@ -270,10 +270,10 @@ int _choice_call_before_end(Game *game, unsigned int org_i) { else if(key == KEY_RIGHT && selected < _choices_amount-1){ /* Remove the old arrow. */ drect(selected*choice_size+PXSIZE, - (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, - selected*choice_size+PXSIZE+arrow_width, - (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, - C_WHITE); + (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, + selected*choice_size+PXSIZE+arrow_width, + (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, + C_WHITE); /* Move the selection arrow and update the selected item. */ selected++; diff --git a/src/game.c b/src/game.c index e65ec70..64d3765 100644 --- a/src/game.c +++ b/src/game.c @@ -5,6 +5,7 @@ #include "config.h" #include +#include void game_logic(Game *game) { // to be done @@ -40,8 +41,12 @@ void get_inputs(Game *game) { /* Display Debug Information on screen */ #if DEBUGMODE - if(keydown(KEY_F1)) game->debug_map = !game->debug_map; - if(keydown(KEY_F2)) game->debug_player = !game->debug_player; + if(keydown(KEY_F1)) { + game->debug_map = !game->debug_map; + } + if(keydown(KEY_F2)) { + game->debug_player = !game->debug_player; + } #endif diff --git a/src/main.c b/src/main.c index deadd41..69509da 100644 --- a/src/main.c +++ b/src/main.c @@ -108,13 +108,13 @@ int main(void) { dgray(DGRAY_ON); #endif -/* + showtext_dialog(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, true); int in = showtext_dialog_ask(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, false, "Lorem\0Ipsum\0Dolor", 3, 0); if(in==2) showtext_dialog(&game, &player_face_img, "You choosed Dolor", false, true); else if(in==1) showtext_dialog(&game, &player_face_img, "You choosed Ipsum", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true); -*/ + do{ /* clear screen */