Fixed horizontally scrolling menu for tape browser

This commit is contained in:
fabio.olimpieri 2015-02-02 23:26:27 +00:00
parent 61cfd4d4f5
commit 87cbfeefa7
2 changed files with 40 additions and 14 deletions

View File

@ -579,6 +579,7 @@ struct
const char *msg; const char *msg;
int font_type; int font_type;
int max_string; int max_string;
int browser;
} thread_struct; } thread_struct;
@ -587,11 +588,17 @@ int menu_thread(void * data)
int i , a; int i , a;
SDL_Delay(30);
while( quit_thread == 0 ) while( quit_thread == 0 )
{ {
for (i=0; i<=(strlen(thread_struct.msg)-thread_struct.max_string);i++) for (i=0; i<=(strlen(thread_struct.msg)-thread_struct.max_string);i++)
{ {
SDL_FillRect(screen, &thread_struct.r, SDL_MapRGB(screen->format, 0, 255, 255)); SDL_FillRect(screen, &thread_struct.r, SDL_MapRGB(screen->format, 0, 255, 255));
if (thread_struct.browser)
menu_print_font(thread_struct.screen, 255, 0, 0, thread_struct.x, thread_struct.y, //Selected menu entry begining with ']' (tape browser)
thread_struct.msg+i, thread_struct.font_type, thread_struct.max_string);
else
menu_print_font(thread_struct.screen, 0, 0, 0, thread_struct.x, thread_struct.y, menu_print_font(thread_struct.screen, 0, 0, 0, thread_struct.x, thread_struct.y,
thread_struct.msg+i, thread_struct.font_type, thread_struct.max_string); thread_struct.msg+i, thread_struct.font_type, thread_struct.max_string);
SDL_UpdateRect(thread_struct.screen, thread_struct.r.x, SDL_UpdateRect(thread_struct.screen, thread_struct.r.x,
@ -689,14 +696,32 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_typ
else if (p_menu->cur_sel == i) /* Selected - color */ else if (p_menu->cur_sel == i) /* Selected - color */
{ {
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 255, 255)); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 255, 255));
if (msg[0] == ']') if (msg[0] == ']') //Tape browser
{
menu_print_font(screen, 255,0,0, //Selected menu entry begining with ']' (tape browser) menu_print_font(screen, 255,0,0, //Selected menu entry begining with ']' (tape browser)
x_start, y_start + y, msg+1, font_type,max_string ); //do not show ']' x_start, y_start + y, msg+1, font_type,max_string ); //do not show ']'
if (strlen(msg)-1>max_string)
{
if (thread) SDL_WaitThread(thread, NULL);
thread_struct.screen=screen;
thread_struct.x=x_start;
thread_struct.y=y_start + y;
thread_struct.msg=msg+1; //do not show ']'
thread_struct.font_type=font_type;
thread_struct.max_string=max_string;
thread_struct.r=r;
thread_struct.browser=1;
quit_thread=0;
thread = SDL_CreateThread(menu_thread, NULL );
}
}
else else
{ {
if (strlen(msg)<=max_string) menu_print_font(screen, 0,0,0, //Selected menu entry menu_print_font(screen, 0,0,0, //Selected menu entry
x_start, y_start + y, msg, font_type,max_string); x_start, y_start + y, msg, font_type,max_string);
else
if (strlen(msg)>max_string)
{ {
if (thread) SDL_WaitThread(thread, NULL); if (thread) SDL_WaitThread(thread, NULL);
thread_struct.screen=screen; thread_struct.screen=screen;
@ -706,6 +731,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_typ
thread_struct.font_type=font_type; thread_struct.font_type=font_type;
thread_struct.max_string=max_string; thread_struct.max_string=max_string;
thread_struct.r=r; thread_struct.r=r;
thread_struct.browser=0;
quit_thread=0; quit_thread=0;
thread = SDL_CreateThread(menu_thread, NULL ); thread = SDL_CreateThread(menu_thread, NULL );
} }

View File

@ -91,7 +91,7 @@ void create_browser_tzx (FILE * fichero) {
case 0x00: //header case 0x00: //header
if (longitud!=19) if (longitud!=19)
{ {
sprintf(browser_list[block_number]->info,"Custom Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Custom Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);
@ -125,7 +125,7 @@ void create_browser_tzx (FILE * fichero) {
} }
break; break;
case 0xFF: //data case 0xFF: //data
sprintf(browser_list[block_number]->info,"Standard Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Standard Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);
@ -133,7 +133,7 @@ void create_browser_tzx (FILE * fichero) {
} }
break; break;
default: //Custom data default: //Custom data
sprintf(browser_list[block_number]->info,"Custom Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Custom Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);
@ -356,7 +356,7 @@ void create_browser_tap (FILE * fichero) {
case 0x00: //header case 0x00: //header
if (longitud!=19) if (longitud!=19)
{ {
sprintf(browser_list[block_number]->info,"Custom Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Custom Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);
@ -390,7 +390,7 @@ void create_browser_tap (FILE * fichero) {
} }
break; break;
case 0xFF: //data case 0xFF: //data
sprintf(browser_list[block_number]->info,"Standard Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Standard Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);
@ -398,7 +398,7 @@ void create_browser_tap (FILE * fichero) {
} }
break; break;
default: //Custom data default: //Custom data
sprintf(browser_list[block_number]->info,"Custom Data: %d bytes", longitud); sprintf(browser_list[block_number]->info,"Custom Data %d bytes", longitud);
if (longitud>1) if (longitud>1)
{ {
retval=fread (value, 1, longitud-1, fichero); retval=fread (value, 1, longitud-1, fichero);