From f71c185a8dec63831edd690f8e87959d0e34dbcb Mon Sep 17 00:00:00 2001 From: mibi88 Date: Thu, 13 Jul 2023 12:06:48 +0200 Subject: [PATCH] Start of the interactive dialogs code --- src/dialogs.c | 29 +++++++++++++++++++++++++++-- src/dialogs.h | 9 +++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/dialogs.c b/src/dialogs.c index cb11bbc..bc97b7c 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -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) { + // } diff --git a/src/dialogs.h b/src/dialogs.h index 92cc96c..62c9a6e 100644 --- a/src/dialogs.h +++ b/src/dialogs.h @@ -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