diff --git a/src/dialogs.c b/src/dialogs.c index 27f4620..34c8bc0 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -39,7 +39,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, bool start_anim, bool end_anim, void for_each_screen(Game *game, unsigned int i), - int line_duration, bool line_anim, unsigned int start_i, + int line_duration, bool update_screen, unsigned int start_i, bool wait_continue) { dfont(&FONT_USED); unsigned int i, n, y = PXSIZE, l = 0; @@ -50,10 +50,17 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, if(start_anim){ /* Run a little fancy animation. */ for(i=0;i<=BOX_HEIGHT;i++){ + /* Redrawing the entire screen, because maybe there was no dialog + displayed before. */ draw(game); + /* Fill the dialog box with white */ drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE); + /* Draw a thick black line on the bottom of the dialog. */ drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK); + + /* Draw the part of the face of the player that can fit correctly in + * the dialog drawn. */ dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE, DIMAGE_NONE); @@ -63,15 +70,19 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, game->frame_duration = 0; } }else{ + /* Here I'm drawing the same as if start_anim is true, but whitout + * making an animation. */ draw(game); drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE); drect(0, BOX_HEIGHT*PXSIZE, DWIDTH, (BOX_HEIGHT+1)*PXSIZE, C_BLACK); dimage(4*PXSIZE, 2*PXSIZE, face); - if(line_anim) blit(); + if(update_screen){ + blit(); - while(game->frame_duration < 20) sleep(); - game->frame_duration = 0; + while(game->frame_duration < 20) sleep(); + game->frame_duration = 0; + } } /* We should start to drawing the text on the x axis at BOX_HEIGHT to avoid * drawing on the face. */ @@ -111,15 +122,17 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, /* We drew one entire screen, reset everything to draw the next one. */ /* Make a little animation :). */ - if(line_anim) blit(); + if(update_screen) blit(); while(game->frame_duration < line_duration) sleep(); game->frame_duration = 0; /* Ask the user to press EXE to continue. */ dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ..."); } /* Make a little animation :). */ - if(line_anim) blit(); + if(update_screen) blit(); if(l>=max_lines_amount-1){ + /* If we drew one entire screen. */ + /* Wait that the EXE key is pressed if we should. */ if(wait_continue) while(getkey().key != KEY_EXE) sleep(); /* Clear the text area. */ drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2, @@ -129,6 +142,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, l = 0; } else{ + /* Else, wait a bit for the animation. */ while(game->frame_duration < line_duration) sleep(); game->frame_duration = 0; } @@ -136,12 +150,13 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, if(lframe_duration < line_duration) sleep(); game->frame_duration = 0; /* Ask the user to press EXE to continue. */ dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ..."); - if(line_anim) blit(); + /* Update the screen and wait for EXE being pressed, if needed. */ + if(update_screen) blit(); if(wait_continue) while(getkey().key != KEY_EXE) sleep(); } if(call_before_end) return_int = call_before_end(game, i); diff --git a/src/dialogs.h b/src/dialogs.h index 1f0199f..4c6ad99 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -14,7 +14,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, bool start_anim, bool end_anim, void for_each_screen(Game *game, unsigned int i), - int line_duration, bool line_anim, unsigned int start_i, + int line_duration, bool update_screen, unsigned int start_i, bool wait_continue); void showtext_dialog(Game *game, bopti_image_t *face, char *text,