Fixed a bug when displaying 3 choices.

This commit is contained in:
mibi88 2023-08-11 12:23:07 +02:00
parent e012e5a428
commit d4fc8db489
3 changed files with 19 additions and 14 deletions

View file

@ -247,8 +247,8 @@ int _choice_call_before_end(Game *game, unsigned int org_i) {
C_BLACK, ">"); C_BLACK, ">");
dtext(i*choice_size+arrow_width+PXSIZE, dtext(i*choice_size+arrow_width+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, C_BLACK, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, C_BLACK,
_choices+pos+i); _choices+pos);
pos += strlen(_choices+pos); pos += strlen(_choices+pos)+1;
} }
blit(); blit();
key = getkey().key; key = getkey().key;
@ -257,10 +257,10 @@ int _choice_call_before_end(Game *game, unsigned int org_i) {
if(key == KEY_LEFT && selected > 0){ if(key == KEY_LEFT && selected > 0){
/* Remove the old arrow. */ /* Remove the old arrow. */
drect(selected*choice_size+PXSIZE, drect(selected*choice_size+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
selected*choice_size+PXSIZE+arrow_width, selected*choice_size+PXSIZE+arrow_width,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
C_WHITE); C_WHITE);
/* Move the selection arrow and update the selected item. */ /* Move the selection arrow and update the selected item. */
selected--; selected--;
@ -270,10 +270,10 @@ int _choice_call_before_end(Game *game, unsigned int org_i) {
else if(key == KEY_RIGHT && selected < _choices_amount-1){ else if(key == KEY_RIGHT && selected < _choices_amount-1){
/* Remove the old arrow. */ /* Remove the old arrow. */
drect(selected*choice_size+PXSIZE, drect(selected*choice_size+PXSIZE,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE,
selected*choice_size+PXSIZE+arrow_width, selected*choice_size+PXSIZE+arrow_width,
(BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height, (BOX_HEIGHT+CHOICE_BOX_PADDING_TOP)*PXSIZE+arrow_height,
C_WHITE); C_WHITE);
/* Move the selection arrow and update the selected item. */ /* Move the selection arrow and update the selected item. */
selected++; selected++;

View file

@ -5,6 +5,7 @@
#include "config.h" #include "config.h"
#include <gint/keyboard.h> #include <gint/keyboard.h>
#include <gint/cpu.h>
void game_logic(Game *game) { void game_logic(Game *game) {
// to be done // to be done
@ -40,8 +41,12 @@ void get_inputs(Game *game) {
/* Display Debug Information on screen */ /* Display Debug Information on screen */
#if DEBUGMODE #if DEBUGMODE
if(keydown(KEY_F1)) game->debug_map = !game->debug_map; if(keydown(KEY_F1)) {
if(keydown(KEY_F2)) game->debug_player = !game->debug_player; game->debug_map = !game->debug_map;
}
if(keydown(KEY_F2)) {
game->debug_player = !game->debug_player;
}
#endif #endif

View file

@ -108,13 +108,13 @@ int main(void) {
dgray(DGRAY_ON); dgray(DGRAY_ON);
#endif #endif
/*
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); 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\0Dolor", 3, 0); 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\0Dolor", 3, 0);
if(in==2) showtext_dialog(&game, &player_face_img, "You choosed Dolor", false, true); if(in==2) showtext_dialog(&game, &player_face_img, "You choosed Dolor", false, true);
else if(in==1) showtext_dialog(&game, &player_face_img, "You choosed Ipsum", false, true); else if(in==1) showtext_dialog(&game, &player_face_img, "You choosed Ipsum", false, true);
else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true);
*/
do{ do{
/* clear screen */ /* clear screen */