int user_select_string(char **strings, int n) { int cursor = 0; int display_start = 0; int n_display = 20; while (1) { if (cursor>=display_start+n_display) display_start = cursor-n_display+1; if (cursor<display_start) display_start = cursor; int x = 10; int y = 5; clear_screen(); clear_text_area(x,y,60-2*x,n_display+4); y+=2; pgPrintCenter(29,red,"X = Select"); pgPrintCenter(30,red,"O = Abort"); draw_strings(strings, n, x, 7, display_start, n_display, cursor); int key = get_buttons(); if (key & PSP_CTRL_DOWN) cursor ++; if (key & PSP_CTRL_UP) cursor --; if (key & PSP_CTRL_RIGHT) cursor += n_display; if (key & PSP_CTRL_LEFT) cursor -= n_display; if (key & PSP_CTRL_CIRCLE) return -1; if (key & PSP_CTRL_CROSS) return cursor; if (cursor>=n) cursor = n-1; if (cursor<0) cursor = 0; } }
//////////////////////////////////////////////////////////////////////////////////////// // Message box //////////////////////////////////////////////////////////////////////////////////////// void msgBox(const char *msg,int delay_vblank) { int len; char str[60]; pgCopyScreen(); memcpy(str,msg,50); str[50]=0; len=strlen(msg); if (len>=50) { str[50-3]=str[50-2]=str[50-1]='.'; len=49; } len*=8; pgFillBox(240-len/2-20-1,136-12-1,240+len/2+20+1,136+18+1,BOX_COLOR); pgDrawFrame(240-len/2-20,136-12,240+len/2+20,136+18,FRAME_COLOR); pgPrintCenter(17,TEXT_COLOR,str); pgScreenFlipV(); if (delay_vblank<=0) delay_vblank=1; pgWaitVn(delay_vblank); }