Start of the interactive dialogs code

This commit is contained in:
mibi88 2023-07-13 12:06:48 +02:00
parent 90ddeabbf1
commit f71c185a8d
2 changed files with 36 additions and 2 deletions

View file

@ -8,10 +8,11 @@
extern font_t fontRPG;
#define FONT_USED fontRPG
void showtext(Game *game, bopti_image_t *face, char *text) {
int showtext_opt(Game *game, bopti_image_t *face, char *text,
int call_before_end(void), bool start_anim, bool end_anim) {
dfont(&FONT_USED);
unsigned int i, n, y = PXSIZE, l = 0;
int line_max_chars;
int line_max_chars, return_int = 0;
unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
(FONT_USED.line_height+PXSIZE);
const char *c;
@ -87,6 +88,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
dtext(1, y, C_BLACK, "[EXE] To continue ...");
while(getkey().key != KEY_EXE) sleep();
}
if(call_before_end) return_int = call_before_end();
/* Run another little fancy animation. */
for(i=40;i>0;i--){
draw(game);
@ -98,4 +100,27 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
while(game->frame_duration < 20) sleep();
game->frame_duration = 0;
}
return return_int;
}
void showtext(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, true, true);
}
void showtext_dialog_start(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, true, false);
}
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, false, false);
}
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text) {
showtext_opt(game, face, text, NULL, false, true);
}
char **choices;
void _choice_call_before_end(void) {
//
}

View file

@ -9,6 +9,15 @@
#define F_WIDTH (32*PXSIZE)
#define F_HEIGHT (32*PXSIZE)
int showtext_opt(Game *game, bopti_image_t *face, char *text,
int call_before_end(void), bool start_anim, bool end_anim);
void showtext(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_start(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text);
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text);
#endif