Dialogs displaying now works on cg!

This commit is contained in:
mibi88 2023-07-12 12:42:28 +02:00
parent 4956d0de31
commit 4e06ddce10

View file

@ -10,9 +10,10 @@ extern font_t fontRPG;
void showtext(Game *game, bopti_image_t *face, char *text) { void showtext(Game *game, bopti_image_t *face, char *text) {
dfont(&FONT_USED); dfont(&FONT_USED);
unsigned int i, n, y = 1, l = 0; unsigned int i, n, y = PXSIZE, l = 0;
int line_max_chars; int line_max_chars;
unsigned int max_lines_amount = (BOX_HEIGHT-1)/FONT_USED.line_height; unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
(FONT_USED.line_height+PXSIZE);
const char *c; const char *c;
/* Run a little fancy animation. */ /* Run a little fancy animation. */
for(i=0;i<BOX_HEIGHT;i++){ for(i=0;i<BOX_HEIGHT;i++){
@ -41,10 +42,10 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
/* If we found a space, we can draw this line and do the same for /* If we found a space, we can draw this line and do the same for
* the next line. */ * the next line. */
if(text[i+n] == ' '){ if(text[i+n] == ' '){
dtext_opt(BOX_HEIGHT, y, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_TOP, dtext_opt(BOX_HEIGHT*PXSIZE, y, C_BLACK, C_NONE, DTEXT_LEFT,
text+i, n); /* Draw everything. */ DTEXT_TOP, text+i, n); /* Draw everything. */
/* Increment y by the line height. */ /* Increment y by the line height. */
y += FONT_USED.line_height; y += FONT_USED.line_height+PXSIZE;
i += n; /* We drew everything to i+n */ i += n; /* We drew everything to i+n */
l++; /* We drew one more line. */ l++; /* We drew one more line. */
break; break;
@ -55,31 +56,32 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
*/ */
/* Make a little animation :). */ /* Make a little animation :). */
dupdate(); dupdate();
while(game->frame_duration < 100) sleep(); while(game->frame_duration < 1000) sleep();
game->frame_duration = 0; game->frame_duration = 0;
/* Ask the user to press EXE to continue. */ /* Ask the user to press EXE to continue. */
dtext(BOX_HEIGHT, y, C_BLACK, "[EXE] to continue ..."); dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
} }
/* Make a little animation :). */ /* Make a little animation :). */
dupdate(); dupdate();
if(l>=max_lines_amount-1){ if(l>=max_lines_amount-1){
while(getkey().key != KEY_EXE) sleep(); while(getkey().key != KEY_EXE) sleep();
/* Clear the screen. */ /* Clear the screen. */
drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE, C_WHITE); drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-1,
C_WHITE);
/* Reset y and l. */ /* Reset y and l. */
y = 1; y = PXSIZE;
l = 0; l = 0;
} }
else{ else{
while(game->frame_duration < 100) sleep(); while(game->frame_duration < 1000) sleep();
game->frame_duration = 0;
} }
game->frame_duration = 0;
} }
if(l<max_lines_amount-1){ if(l<max_lines_amount-1){
/* If we have not filled everthing with text at the end. */ /* If we have not filled everthing with text at the end. */
/* Make a little animation :). */ /* Make a little animation :). */
dupdate(); dupdate();
while(game->frame_duration < 100) sleep(); while(game->frame_duration < 1000) sleep();
game->frame_duration = 0; game->frame_duration = 0;
/* Ask the user to press EXE to continue. */ /* Ask the user to press EXE to continue. */
dtext(1, y, C_BLACK, "[EXE] To continue ..."); dtext(1, y, C_BLACK, "[EXE] To continue ...");