diff --git a/assets-cg/font.png b/assets-cg/font.png index e661cc4..1b1622c 100644 Binary files a/assets-cg/font.png and b/assets-cg/font.png differ diff --git a/assets-fx/font.png b/assets-fx/font.png index f7b376a..b89f3dd 100644 Binary files a/assets-fx/font.png and b/assets-fx/font.png differ diff --git a/src/dialogs.c b/src/dialogs.c index 0d98047..090ecf1 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -8,7 +8,7 @@ #include "config.h" -#define BOX_HEIGHT (F_HEIGHT/PXSIZE+8) +#define BOX_HEIGHT (F_HEIGHT/PXSIZE+9) extern font_t fontRPG; #define FONT_USED fontRPG @@ -39,32 +39,37 @@ 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 line_anim, unsigned int start_i, + bool wait_continue) { dfont(&FONT_USED); unsigned int i, n, y = PXSIZE, l = 0; int line_max_chars, return_int = 0; unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/ (FONT_USED.line_height+PXSIZE); const char *c; - draw(game); if(start_anim){ /* Run a little fancy animation. */ for(i=0;iframe_duration < 20) sleep(); game->frame_duration = 0; } }else{ + draw(game); drect(0, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE, C_WHITE); drect(0, (BOX_HEIGHT-1)*PXSIZE, DWIDTH, BOX_HEIGHT*PXSIZE, C_BLACK); dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (BOX_HEIGHT-7)*PXSIZE, DIMAGE_NONE); - if(line_anim) dupdate(); + if(line_anim) blit(); while(game->frame_duration < 20) sleep(); game->frame_duration = 0; @@ -72,15 +77,16 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, /* We should start to drawing the text on the x axis at BOX_HEIGHT to avoid * drawing on the face. */ for(i=start_i;i0; n--) { /* If we found a space, we can draw this line and do the same * for the next line. */ @@ -95,6 +101,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, } } }else{ + /* If it is the last line of the text. */ dtext_opt(BOX_HEIGHT*PXSIZE, y, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_TOP, text+i, line_max_chars); y += FONT_USED.line_height+PXSIZE; @@ -114,9 +121,9 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, /* Make a little animation :). */ if(line_anim) blit(); if(l>=max_lines_amount-1){ - while(getkey().key != KEY_EXE) sleep(); - /* Clear the screen. */ - drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-1, + if(wait_continue) while(getkey().key != KEY_EXE) sleep(); + /* Clear the text area. */ + drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2, C_WHITE); /* Reset y and l. */ y = PXSIZE; @@ -136,7 +143,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, /* Ask the user to press EXE to continue. */ dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ..."); if(line_anim) blit(); - while(getkey().key != KEY_EXE) sleep(); + if(wait_continue) while(getkey().key != KEY_EXE) sleep(); } if(call_before_end) return_int = call_before_end(game, i); if(end_anim){ @@ -160,7 +167,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text, void showtext_dialog(Game *game, bopti_image_t *face, char *text, bool dialog_start, bool dialog_end) { showtext_opt(game, face, text, NULL, dialog_start, dialog_end, NULL, 100, - true, 0); + true, 0, true); } #define CHOICE_BOX_HEIGHT 10 @@ -229,7 +236,7 @@ int _choice_call_before_end(Game *game, unsigned int org_i) { for(i=DWIDTH/8+1;i>0;i--){ draw(game); showtext_opt(game, _face, _text, NULL, false, false, NULL, 0, false, - _i); + _i, false); drect(0, BOX_HEIGHT*PXSIZE, i*(DWIDTH/8), (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE); drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE-1, @@ -252,5 +259,5 @@ int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start, _face = face; _text = text; return showtext_opt(game, face, text, _choice_call_before_end, start, end, - _choice_screen_call, 100, true, 0); + _choice_screen_call, 100, true, 0, true); } diff --git a/src/dialogs.h b/src/dialogs.h index 099ef7f..1f0199f 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -14,7 +14,8 @@ 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 line_anim, unsigned int start_i, + bool wait_continue); void showtext_dialog(Game *game, bopti_image_t *face, char *text, bool dialog_start, bool dialog_end); diff --git a/src/main.c b/src/main.c index ca1ac26..cc72975 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,7 @@ int main(void) { dgray(DGRAY_ON); #endif - showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, true); + 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", 2, 0); if(in) showtext_dialog(&game, &player_face_img, "You choosed ipsum", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true);