From 65ed14fc37d79e9d3b125991c3f1bf5226eace3e Mon Sep 17 00:00:00 2001 From: mibi88 Date: Wed, 19 Jul 2023 20:06:28 +0200 Subject: [PATCH] Everything is working now. --- assets-cg/font.png | Bin 1269 -> 1205 bytes assets-fx/font.png | Bin 956 -> 875 bytes src/dialogs.c | 35 +++++++++++++++++++++-------------- src/dialogs.h | 3 ++- src/main.c | 2 +- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/assets-cg/font.png b/assets-cg/font.png index e661cc425bae1f6621dc548bd6b6137aa979a55d..1b1622c91839afc5568547605878ec71630b0220 100644 GIT binary patch delta 1185 zcmZWnZB)`{9M!o-I@6Y7*)cukdeJP~)EP4*P4gv5qr{>YGer(kUjQDQ^ms?a%ty^X)mm``qXL?!885k@L;3fwF{{ zs6!=nI_4mHY=>(s^+?&qvXKuA+K*lm-UiK|x6xO`=_jG%hrfBr^JtmrS~?!1pdc%T zYyx~EEJjaR1NpE@J%bo&@we#zt+|`(q?}(B?IF!W`go##cewg?$L{rEt|{>=oIbhg zMZXvVgh1n+OCZy356IQG{1=5H%j!@e=URC*VW#NSR(VguB1Vc0F#1uh6Gj_u(mVAl zFD~a21w<(ldIn^5bMb%`%4#X#Y^{&yrc;`ROHdy62smHKf*d5C@Wokz2JoED!|5SnCui&?->V)cCD38 z2AFbmOW(tH(*ADrv=*+PEk!400r`fl)dP_@*S|m)B#x?c6va9Bes(5hzU;Mxd?G@j zgcql$)si|Ry#}|tx$vB4rCErB^EwWtU_KDYB2nk)okfV0$VqC|E+)ELO$}W-EP~Ds ztplW}%^v{LQ5b?~PfVSJZ&LgL>KLg{AP8jxPiUALqyRV&YE;$Zk(Df*_XDe#&5G}n zHKX;Su{fRi3YgW9BL*l`n5IK8@;B{M)XD=bI}rtNF$82Bb9;53#Zd;E_?BLF?{h5| z&w>+km8L`Btms>a91t$Bvl zb0M|M7q&-sgO6Cz8drK=QhMfd?88Ji>;zmFcy{^o^wVfHV6SbGUqee&PgUIUIg8xq zc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SgC~hpacWN zgAk8#oEh%N&6!>T5cpbwPWclg(tDPT`7=#slequ@T=*B)1OS=0rDAY0Tg-1TF%&bQ zgE1327&D=Ru>frQYlWn=O=g>!0A5ac{MXC{UQcaM{}_kEbw~D<29MTe%}?oV5V7Z8p|}RO#qdN3;^kU z|4`(H%|x3iB>>omO=l)D?haG+o-<(goHJE3k9KY|=i-ss+|2Gzv~!qu+GxdTzIx`I zb5=%RGm}yhtAB;^(+1&@9y^v- zhez4htTtiMq-1q#(jX_US5W?9t}lBud0OL;gNW&7*uo`{+Ocv4-8?V;7?;_RN5bnuUwQHUHVfA1Xk z!4i7t$yI&lA2o+iOj(+-QchO)ZtvZwXQ&#eAJfyOLtJ3}t89WJo2>OK(Udqc5!GCa zuMB@#bbrJ)9OY1=dSb_wzJntare0q0)l9GMk>o@A%!qR&b5@%MGriw7m69ru0`>Xl z30b%Gew116xe%qoNSOd|`&b>DSl>OL-jKO{TuHt1k^zW?kF|KG-O)R%8SioWOzORg z)2!HIh`_H@!c$)b%`OL_LgS0HpibGxv+yYr9jARTLwp~AtS9v>rQ!%L_dy*lrB7tfy>jT54LBqz2e@XoS(`paos z!Aqzby);LC&>5=EW!^oM$L6eex?AH%2c8Ys2ctz|tKyue{9xv+HVtMjz}3uSeO$meYO1$dHtg&FAitbNWEhK&wTk@ z&@l#0-K)w=GOc|*0yRyRcU8DpYG#O-J&JmUR*>45{s>L>?Nc-Hj%+dpn0>)~1*UAG z%0o&{syyoC>Nix(X2p~_QWr9ED%~SdydRLjo|oBq$`5A#0dA@c`WGXekpKVy07*qo IM6N<$f^A3EAOHXW 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);