mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-29 13:03:43 +01:00
I'll merge that, if newline support and/or support for words that don't fit in the screen is needed, I'll make another PR.
Reviewed-on: https://gitea.planet-casio.com/Slyvtt/Collab_RPG/pulls/25
This commit is contained in:
commit
6f4ff02f51
8 changed files with 316 additions and 86 deletions
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 875 B |
|
@ -6,6 +6,6 @@
|
||||||
#define GRAYMODEOK 1
|
#define GRAYMODEOK 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_FEATURE 1
|
#define USB_FEATURE 0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
241
src/dialogs.c
241
src/dialogs.c
|
@ -13,7 +13,7 @@
|
||||||
extern font_t fontRPG;
|
extern font_t fontRPG;
|
||||||
#define FONT_USED fontRPG
|
#define FONT_USED fontRPG
|
||||||
|
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
#include <gint/gray.h>
|
#include <gint/gray.h>
|
||||||
uint32_t *lightVRAMnext, *darkVRAMnext;
|
uint32_t *lightVRAMnext, *darkVRAMnext;
|
||||||
uint32_t *lightVRAMcurrent, *darkVRAMcurrent;
|
uint32_t *lightVRAMcurrent, *darkVRAMcurrent;
|
||||||
|
@ -24,7 +24,7 @@ void blit()
|
||||||
{
|
{
|
||||||
dupdate();
|
dupdate();
|
||||||
|
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
dgray_getvram( &lightVRAMnext, &darkVRAMnext );
|
dgray_getvram( &lightVRAMnext, &darkVRAMnext );
|
||||||
dgray_getscreen( &lightVRAMcurrent, &darkVRAMcurrent );
|
dgray_getscreen( &lightVRAMcurrent, &darkVRAMcurrent );
|
||||||
|
|
||||||
|
@ -35,42 +35,71 @@ void blit()
|
||||||
|
|
||||||
|
|
||||||
int showtext_opt(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) {
|
int call_before_end(Game *game, unsigned int i),
|
||||||
|
bool start_anim,
|
||||||
|
bool end_anim,
|
||||||
|
void for_each_screen(Game *game, unsigned int i),
|
||||||
|
int line_duration, bool update_screen, unsigned int start_i,
|
||||||
|
bool wait_continue) {
|
||||||
dfont(&FONT_USED);
|
dfont(&FONT_USED);
|
||||||
unsigned int i, n, y = PXSIZE, l = 0;
|
unsigned int i, n, y = PXSIZE, l = 0;
|
||||||
int line_max_chars, return_int = 0;
|
int line_max_chars, return_int = 0;
|
||||||
unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
|
unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
|
||||||
(FONT_USED.line_height+PXSIZE);
|
(FONT_USED.line_height+PXSIZE);
|
||||||
const char *c;
|
const char *c;
|
||||||
|
if(start_anim){
|
||||||
/* Run a little fancy animation. */
|
/* Run a little fancy animation. */
|
||||||
for(i=0;i<BOX_HEIGHT;i++){
|
for(i=0;i<=BOX_HEIGHT;i++){
|
||||||
|
/* Redrawing the entire screen, because maybe there was no dialog
|
||||||
|
displayed before. */
|
||||||
draw(game);
|
draw(game);
|
||||||
|
|
||||||
|
/* Fill the dialog box with white */
|
||||||
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
||||||
|
/* Draw a thick black line on the bottom of the dialog. */
|
||||||
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
||||||
|
|
||||||
|
/* Draw the part of the face of the player that can fit correctly in
|
||||||
|
* the dialog drawn. */
|
||||||
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
|
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
|
||||||
DIMAGE_NONE);
|
DIMAGE_NONE);
|
||||||
|
|
||||||
dupdate();
|
blit();
|
||||||
|
|
||||||
while(game->frame_duration < 20) sleep();
|
while(game->frame_duration < 20) sleep();
|
||||||
game->frame_duration = 0;
|
game->frame_duration = 0;
|
||||||
}
|
}
|
||||||
/* We should start to drawint the text on the x axis at BOX_HEIGHT to avoid
|
}else{
|
||||||
|
/* Here I'm drawing the same as if start_anim is true, but whitout
|
||||||
|
* making an animation. */
|
||||||
|
draw(game);
|
||||||
|
drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
|
||||||
|
drect(0, BOX_HEIGHT*PXSIZE, DWIDTH, (BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
|
dimage(4*PXSIZE, 2*PXSIZE, face);
|
||||||
|
|
||||||
|
if(update_screen){
|
||||||
|
blit();
|
||||||
|
|
||||||
|
while(game->frame_duration < 20) sleep();
|
||||||
|
game->frame_duration = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* We should start to drawing the text on the x axis at BOX_HEIGHT to avoid
|
||||||
* drawing on the face. */
|
* drawing on the face. */
|
||||||
/* Show a little message that showing text in dialogs is not implemented
|
for(i=start_i;i<strlen(text);i++){
|
||||||
* yet. */
|
if(!l && for_each_screen) for_each_screen(game, i);
|
||||||
for(i=0;i<strlen(text);i++){
|
|
||||||
/* Get how many chars we can draw on screen with a padding on the left
|
/* Get how many chars we can draw on screen with a padding on the left
|
||||||
* of BOX_HEIGHT px and on the right of 1 px. */
|
* of BOX_HEIGHT px and on the right of 1 px. */
|
||||||
c = drsize(text+i, &FONT_USED, DWIDTH-(BOX_HEIGHT*PXSIZE+PXSIZE), NULL);
|
c = drsize(text+i, &FONT_USED, DWIDTH-(BOX_HEIGHT*PXSIZE+PXSIZE), NULL);
|
||||||
/* c is a pointer to the last char that can be drawn. So: */
|
/* c is a pointer to the last char that can be drawn. So: */
|
||||||
line_max_chars = c-(text+i);
|
line_max_chars = c-(text+i);
|
||||||
/* TODO: Handle lines that are longer than what I can draw. */
|
/* TODO: Handle lines that are longer than what I can draw and '\n'. */
|
||||||
/* Loop from the end to the start for word wrap. */
|
/* Loop from the end to the start for word wrap. */
|
||||||
|
if(*c){
|
||||||
|
/* If we are not drawing the end of the text. */
|
||||||
for(n=line_max_chars; n>0; n--) {
|
for(n=line_max_chars; n>0; n--) {
|
||||||
/* 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
|
||||||
* the next line. */
|
* for the next line. */
|
||||||
if(text[i+n] == ' '){
|
if(text[i+n] == ' '){
|
||||||
dtext_opt(BOX_HEIGHT*PXSIZE, y, C_BLACK, C_NONE, DTEXT_LEFT,
|
dtext_opt(BOX_HEIGHT*PXSIZE, y, C_BLACK, C_NONE, DTEXT_LEFT,
|
||||||
DTEXT_TOP, text+i, n); /* Draw everything. */
|
DTEXT_TOP, text+i, n); /* Draw everything. */
|
||||||
|
@ -81,46 +110,60 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}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;
|
||||||
|
i += line_max_chars;
|
||||||
|
l++;
|
||||||
|
}
|
||||||
if(l>=max_lines_amount-1){
|
if(l>=max_lines_amount-1){
|
||||||
/* We drew one entire screen, reset everything to draw the next one.
|
/* We drew one entire screen, reset everything to draw the next one.
|
||||||
*/
|
*/
|
||||||
/* Make a little animation :). */
|
/* Make a little animation :). */
|
||||||
blit();
|
if(update_screen) blit();
|
||||||
while(game->frame_duration < 1000) sleep();
|
while(game->frame_duration < line_duration) 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*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
|
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
|
||||||
}
|
}
|
||||||
/* Make a little animation :). */
|
/* Make a little animation :). */
|
||||||
blit();
|
if(update_screen) blit();
|
||||||
if(l>=max_lines_amount-1){
|
if(l>=max_lines_amount-1){
|
||||||
while(getkey().key != KEY_EXE) sleep();
|
/* If we drew one entire screen. */
|
||||||
/* Clear the screen. */
|
/* Wait that the EXE key is pressed if we should. */
|
||||||
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);
|
C_WHITE);
|
||||||
/* Reset y and l. */
|
/* Reset y and l. */
|
||||||
y = PXSIZE;
|
y = PXSIZE;
|
||||||
l = 0;
|
l = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
while(game->frame_duration < 1000) sleep();
|
/* Else, wait a bit for the animation. */
|
||||||
|
while(game->frame_duration < line_duration) 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 :). */
|
||||||
blit();
|
if(update_screen) blit();
|
||||||
while(game->frame_duration < 1000) sleep();
|
while(game->frame_duration < line_duration) 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*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
|
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
|
||||||
blit();
|
/* Update the screen and wait for EXE being pressed, if needed. */
|
||||||
while(getkey().key != KEY_EXE) sleep();
|
if(update_screen) blit();
|
||||||
|
if(wait_continue) while(getkey().key != KEY_EXE) sleep();
|
||||||
}
|
}
|
||||||
if(call_before_end) return_int = call_before_end();
|
if(call_before_end) return_int = call_before_end(game, i);
|
||||||
/* Run another little fancy animation. */
|
if(end_anim){
|
||||||
for(i=40;i>0;i--){
|
/* Run another little fancy animation if we should. */
|
||||||
|
for(i=BOX_HEIGHT;i>0;i--){
|
||||||
|
/* It is the same as the start animation. */
|
||||||
draw(game);
|
draw(game);
|
||||||
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
|
||||||
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
|
||||||
|
@ -132,27 +175,145 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
|
||||||
while(game->frame_duration < 20) sleep();
|
while(game->frame_duration < 20) sleep();
|
||||||
game->frame_duration = 0;
|
game->frame_duration = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return return_int;
|
return return_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showtext(Game *game, bopti_image_t *face, char *text) {
|
void showtext_dialog(Game *game, bopti_image_t *face, char *text,
|
||||||
showtext_opt(game, face, text, NULL, true, true);
|
bool dialog_start, bool dialog_end) {
|
||||||
|
/* Run showtext_opt with some default values. It makes it easier to use in
|
||||||
|
* simple dialogs. */
|
||||||
|
showtext_opt(game, face, text, NULL, dialog_start, dialog_end, NULL, 100,
|
||||||
|
true, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showtext_dialog_start(Game *game, bopti_image_t *face, char *text) {
|
#define CHOICE_BOX_HEIGHT 10
|
||||||
showtext_opt(game, face, text, NULL, true, false);
|
#define CHOICE_BOX_PADDING_TOP 3
|
||||||
|
|
||||||
|
/* Some variables and pointers used to get some arguments passed in
|
||||||
|
* showtext_dialog_ask in _choice_call_before_end. */
|
||||||
|
char *_choices, *_text;
|
||||||
|
int _choices_amount, _default_choice;
|
||||||
|
bopti_image_t *_face;
|
||||||
|
unsigned int _i;
|
||||||
|
|
||||||
|
/* Get where I started drawing a dialog page, to be able to redraw the last page
|
||||||
|
* for the end animation in _choice_call_before_end. */
|
||||||
|
void _choice_screen_call(Game *game, unsigned int i) {
|
||||||
|
_i = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text) {
|
int _choice_call_before_end(Game *game, unsigned int org_i) {
|
||||||
showtext_opt(game, face, text, NULL, false, false);
|
int i, key;
|
||||||
|
/* Make a little animation because we looove little animations ;) */
|
||||||
|
for(i=0;i<DWIDTH/8+1;i++){
|
||||||
|
/* Fill the interaction box with white */
|
||||||
|
drect(0, (BOX_HEIGHT+1)*PXSIZE+1, i*(DWIDTH/8),
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
|
||||||
|
/* Draw a thick border on the right of the box. */
|
||||||
|
drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE-1,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
|
/* Draw a thick border on the bottom of the box. */
|
||||||
|
drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, i*(DWIDTH/8),
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
|
/* Show everyting on screen. */
|
||||||
|
blit();
|
||||||
|
/* Wait some ms so that the animation isn't too fast. */
|
||||||
|
while(game->frame_duration < 20) sleep();
|
||||||
|
game->frame_duration = 0;
|
||||||
|
}
|
||||||
|
/* Calculate the maximal size of a choice. */
|
||||||
|
const int choice_size = DWIDTH/_choices_amount;
|
||||||
|
/* arrow_width: The space taken by the arrow that shows the selected item.
|
||||||
|
* arrow_height: The height of the arrow used to show which item is choosen.
|
||||||
|
* Used to calculate the size of the rectangle used to remove
|
||||||
|
* him.
|
||||||
|
* selected: The selected item.
|
||||||
|
* pos: The position of the item we're drawing in the choice
|
||||||
|
* string. The choice string is not really a string, it is
|
||||||
|
* made of multiple '\0' terminated strings, that are in
|
||||||
|
* memory one after the other.
|
||||||
|
*/
|
||||||
|
int arrow_width, arrow_height, selected = _default_choice, pos = 0;
|
||||||
|
/* Calculate the size of the arrow. */
|
||||||
|
dsize(">", &FONT_USED, &arrow_width, &arrow_height);
|
||||||
|
/* Add the character spacing of the font to it. */
|
||||||
|
arrow_width += FONT_USED.char_spacing;
|
||||||
|
do{
|
||||||
|
/* Display the diffrent choices. */
|
||||||
|
for(i=0;i<_choices_amount;i++){
|
||||||
|
if(i == selected) dtext(i*choice_size+PXSIZE,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
|
||||||
|
C_BLACK, ">");
|
||||||
|
dtext(i*choice_size+arrow_width+PXSIZE,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, C_BLACK,
|
||||||
|
_choices+pos+i);
|
||||||
|
pos += strlen(_choices+pos);
|
||||||
|
}
|
||||||
|
blit();
|
||||||
|
key = getkey().key;
|
||||||
|
/* If the player pressed the left arrow key and has not already selected
|
||||||
|
* the first possible choice. */
|
||||||
|
if(key == KEY_LEFT && selected > 0){
|
||||||
|
/* Remove the old arrow. */
|
||||||
|
drect(selected*choice_size+PXSIZE,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
|
||||||
|
selected*choice_size+PXSIZE+arrow_width,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
|
||||||
|
C_WHITE);
|
||||||
|
|
||||||
|
/* Move the selection arrow and update the selected item. */
|
||||||
|
selected--;
|
||||||
|
}
|
||||||
|
/* If the player pressed the right arrow key and has not already
|
||||||
|
* selected the last possible choice. */
|
||||||
|
else if(key == KEY_RIGHT && selected < _choices_amount-1){
|
||||||
|
/* Remove the old arrow. */
|
||||||
|
drect(selected*choice_size+PXSIZE,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
|
||||||
|
selected*choice_size+PXSIZE+arrow_width,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
|
||||||
|
C_WHITE);
|
||||||
|
|
||||||
|
/* Move the selection arrow and update the selected item. */
|
||||||
|
selected++;
|
||||||
|
}
|
||||||
|
/* If the user has not validated his choice by pressing EXE, we loop one
|
||||||
|
* more time. */
|
||||||
|
}while(key != KEY_EXE);
|
||||||
|
/* Make a little animation because we looove little animations ;) */
|
||||||
|
for(i=DWIDTH/8+1;i>0;i--){
|
||||||
|
/* I'm drawing the same box as on the start animation */
|
||||||
|
draw(game);
|
||||||
|
showtext_opt(game, _face, _text, NULL, false, false, NULL, 0, false,
|
||||||
|
_i, false);
|
||||||
|
drect(0, (BOX_HEIGHT+1)*PXSIZE+1, i*(DWIDTH/8),
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, C_WHITE);
|
||||||
|
drect(i*(DWIDTH/8), BOX_HEIGHT*PXSIZE, i*(DWIDTH/8)+PXSIZE-1,
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
|
drect(0, (BOX_HEIGHT+CHOICE_BOX_HEIGHT)*PXSIZE, i*(DWIDTH/8),
|
||||||
|
(BOX_HEIGHT+CHOICE_BOX_HEIGHT+1)*PXSIZE, C_BLACK);
|
||||||
|
dupdate();
|
||||||
|
while(game->frame_duration < 20) sleep();
|
||||||
|
game->frame_duration = 0;
|
||||||
|
}
|
||||||
|
/* Return the selected item because he'll also be returned by showtext_opt.
|
||||||
|
*/
|
||||||
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text) {
|
int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
||||||
showtext_opt(game, face, text, NULL, false, true);
|
bool end, char *choices, int choices_amount,
|
||||||
}
|
int default_choice) {
|
||||||
|
/* Put some arguments in global pointers and variables to make them
|
||||||
char **choices;
|
* accessible by _choice_call_before_end. */
|
||||||
|
_choices = choices;
|
||||||
void _choice_call_before_end(void) {
|
_choices_amount = choices_amount;
|
||||||
//
|
_default_choice = default_choice;
|
||||||
|
_face = face;
|
||||||
|
_text = text;
|
||||||
|
/* Run showtext_opt and return his return value (the return value of
|
||||||
|
*_choice_call_before_end) */
|
||||||
|
return showtext_opt(game, face, text, _choice_call_before_end, start, end,
|
||||||
|
_choice_screen_call, 100, true, 0, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,84 @@
|
||||||
#define F_WIDTH (32*PXSIZE)
|
#define F_WIDTH (32*PXSIZE)
|
||||||
#define F_HEIGHT (32*PXSIZE)
|
#define F_HEIGHT (32*PXSIZE)
|
||||||
|
|
||||||
|
/* showtext_opt()
|
||||||
|
*
|
||||||
|
* Show some text in a box with word wrap for dialogs.
|
||||||
|
*
|
||||||
|
* game: The game struct of the current game.
|
||||||
|
* face: A bopti_image_t of the face of the person who's saying this
|
||||||
|
* text. This bopti_image_t should have a width of F_WIDTH and
|
||||||
|
* a height of F_HEIGHT.
|
||||||
|
* text: The text to display.
|
||||||
|
* call_before_end: A function called when the end of the text was displayed and
|
||||||
|
* the user pressed EXE (or wait_continue was true). His
|
||||||
|
* parameter game is the game struct passed to showtext_opt,
|
||||||
|
* and i is the current position in text.
|
||||||
|
* start_anim: A boolean, that, if he's true, makes that a little animation
|
||||||
|
* is shown at the start of showtext_opt.
|
||||||
|
* end_anim: A boolean, that, if he's true, makes that a little animation
|
||||||
|
* is shown at the end of showtext_opt.
|
||||||
|
* for_each_screen: A function called before a page of the dialog gets drawn.
|
||||||
|
* His parameter game is the game struct passed to
|
||||||
|
* showtext_opt, and i is the current position in text.
|
||||||
|
* line_duration: How many ms showtext_opt will wait after a line has been
|
||||||
|
* drawn.
|
||||||
|
* update_screen: When he's true showtext_opt will update the screen after
|
||||||
|
* drawing a line etc.
|
||||||
|
* start_i: At which position I start displaying the text.
|
||||||
|
* wait_continue: If I should wait that EXE is pressed after drawing a page.
|
||||||
|
*/
|
||||||
|
|
||||||
int showtext_opt(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);
|
int call_before_end(Game *game, unsigned int i),
|
||||||
|
bool start_anim,
|
||||||
|
bool end_anim,
|
||||||
|
void for_each_screen(Game *game, unsigned int i),
|
||||||
|
int line_duration, bool update_screen, unsigned int start_i,
|
||||||
|
bool wait_continue);
|
||||||
|
|
||||||
void showtext(Game *game, bopti_image_t *face, char *text);
|
/* showtext_dialog()
|
||||||
|
*
|
||||||
|
* Calls showtext_opt with default parameters.
|
||||||
|
*
|
||||||
|
* game: The game struct of the current game.
|
||||||
|
* face: A bopti_image_t of the face of the person who's saying this
|
||||||
|
* text. This bopti_image_t should have a width of F_WIDTH and a
|
||||||
|
* height of F_HEIGHT.
|
||||||
|
* text: The text to display.
|
||||||
|
* dialog_start: A boolean, that, if he's true, makes that a little animation is
|
||||||
|
* shown at the start of showtext_opt.
|
||||||
|
* dialog_end: A boolean, that, if he's true, makes that a little animation is
|
||||||
|
* shown at the end of showtext_opt.
|
||||||
|
*/
|
||||||
|
|
||||||
void showtext_dialog_start(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);
|
||||||
|
|
||||||
void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text);
|
/* showtext_dialog_ask()
|
||||||
|
*
|
||||||
|
* Like showtext_dialog, but lets the user choose between multiple possible
|
||||||
|
* choices after displaying the text.
|
||||||
|
*
|
||||||
|
* game: The game struct of the current game.
|
||||||
|
* face: A bopti_image_t of the face of the person who's saying this
|
||||||
|
* text. This bopti_image_t should have a width of F_WIDTH and a
|
||||||
|
* height of F_HEIGHT.
|
||||||
|
* text: The text to display.
|
||||||
|
* start: A boolean, that, if he's true, makes that a little animation
|
||||||
|
* is shown at the start of showtext_opt.
|
||||||
|
* end: A boolean, that, if he's true, makes that a little animation
|
||||||
|
* is shown at the end of showtext_opt.
|
||||||
|
* choices: A pointer to null-terminated strings that are one after the
|
||||||
|
* other in memory. They should be one null-terminated string
|
||||||
|
* for each possible choice.
|
||||||
|
* choice_amount: The amount of possible choices in the choices zero-terminated
|
||||||
|
* strings.
|
||||||
|
* default_choice: The choice choosen by default when the dialog just opened.
|
||||||
|
*/
|
||||||
|
|
||||||
void showtext_dialog_end(Game *game, bopti_image_t *face, char *text);
|
int showtext_dialog_ask(Game *game, bopti_image_t *face, char *text, bool start,
|
||||||
|
bool end, char *choices, int choices_amount,
|
||||||
|
int default_choice);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,7 @@ void get_inputs(Game *game) {
|
||||||
|
|
||||||
/* if USB is enabled - keybinding for screencapture */
|
/* if USB is enabled - keybinding for screencapture */
|
||||||
|
|
||||||
#if USB_FEATURE==1
|
#if USB_FEATURE
|
||||||
|
|
||||||
if(keydown(KEY_7)) game->screenshot = true;
|
if(keydown(KEY_7)) game->screenshot = true;
|
||||||
if(keydown(KEY_8)) game->record = !game->record;
|
if(keydown(KEY_8)) game->record = !game->record;
|
||||||
|
|
23
src/main.c
23
src/main.c
|
@ -12,7 +12,7 @@
|
||||||
#endif //USB_FEATURE
|
#endif //USB_FEATURE
|
||||||
|
|
||||||
|
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
#include <gint/gray.h>
|
#include <gint/gray.h>
|
||||||
#endif //GRAYMODEOK
|
#endif //GRAYMODEOK
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ Game game = {
|
||||||
|
|
||||||
/* screen capture management code */
|
/* screen capture management code */
|
||||||
|
|
||||||
#if USB_FEATURE==1
|
#if USB_FEATURE
|
||||||
|
|
||||||
void USB_feature( void )
|
void USB_feature( void )
|
||||||
{
|
{
|
||||||
if (game.screenshot && usb_is_open()) {
|
if (game.screenshot && usb_is_open()) {
|
||||||
|
|
||||||
#if GRAYMODEOK==1 // This is a trick, if GRAYMODEOK is defined then
|
#if GRAYMODEOK // This is a trick, if GRAYMODEOK is defined then
|
||||||
// we make the code accessible
|
// we make the code accessible
|
||||||
|
|
||||||
if (dgray_enabled())
|
if (dgray_enabled())
|
||||||
|
@ -58,7 +58,7 @@ Game game = {
|
||||||
|
|
||||||
if (game.record && usb_is_open()) {
|
if (game.record && usb_is_open()) {
|
||||||
|
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
|
|
||||||
if (dgray_enabled())
|
if (dgray_enabled())
|
||||||
usb_fxlink_videocapture_gray(false);
|
usb_fxlink_videocapture_gray(false);
|
||||||
|
@ -87,7 +87,7 @@ int main(void) {
|
||||||
}
|
}
|
||||||
timer_start(timer);
|
timer_start(timer);
|
||||||
|
|
||||||
#if USB_FEATURE==1
|
#if USB_FEATURE
|
||||||
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
|
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
|
||||||
usb_open(interfaces, GINT_CALL_NULL);
|
usb_open(interfaces, GINT_CALL_NULL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,11 +95,14 @@ int main(void) {
|
||||||
|
|
||||||
/* start grayscale engine */
|
/* start grayscale engine */
|
||||||
|
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
dgray(DGRAY_ON);
|
dgray(DGRAY_ON);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.");
|
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);
|
||||||
do{
|
do{
|
||||||
/* clear screen */
|
/* clear screen */
|
||||||
dclear(C_WHITE);
|
dclear(C_WHITE);
|
||||||
|
@ -114,7 +117,7 @@ int main(void) {
|
||||||
dupdate();
|
dupdate();
|
||||||
|
|
||||||
/* Screen capture feature if enabled */
|
/* Screen capture feature if enabled */
|
||||||
#if USB_FEATURE==1
|
#if USB_FEATURE
|
||||||
USB_feature();
|
USB_feature();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -129,13 +132,13 @@ int main(void) {
|
||||||
|
|
||||||
|
|
||||||
/* shutdown grayengine*/
|
/* shutdown grayengine*/
|
||||||
#if GRAYMODEOK==1
|
#if GRAYMODEOK
|
||||||
dgray(DGRAY_OFF);
|
dgray(DGRAY_OFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* close USB */
|
/* close USB */
|
||||||
#if USB_FEATURE==1
|
#if USB_FEATURE
|
||||||
usb_close();
|
usb_close();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -180,9 +180,6 @@ void render_map_by_layer(Player *player, Map *map_level, int layer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
short int get_tile(Map *map_level, int x, int y, int l) {
|
short int get_tile(Map *map_level, int x, int y, int l) {
|
||||||
/* Get the tile at (x, y) on layer l. Returns the tile ID or MAP_OUTSIDE if
|
/* Get the tile at (x, y) on layer l. Returns the tile ID or MAP_OUTSIDE if
|
||||||
* she's not found. */
|
* she's not found. */
|
||||||
|
|
Loading…
Reference in a new issue