Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

superdom: check range of input in get_number(). stop scrolling text when leave the screen. don't exit start menu by pressing Left.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24522 a1c6a512-1295-4272-9138-f99709370657

+26 -22
+26 -22
apps/plugins/superdom.c
··· 559 559 560 560 static int superdom_help(void) { 561 561 int button; 562 - #define WORDS (sizeof help_text / sizeof (char*)) 563 562 static char* help_text[] = { 564 563 "Super", "domination", "is", "a", "turn", "based", "strategy", "game,", 565 564 "where", "the", "aim", "is", "to", "overpower", "the", "computer", ··· 573 572 "and", "number", "of", "troops", "on", "them.", 574 573 }; 575 574 576 - if (display_text(WORDS, help_text, NULL, NULL)) 575 + if (display_text(ARRAYLEN(help_text), help_text, NULL, NULL)) 577 576 return RET_VAL_USB; 578 577 do { 579 578 button = rb->button_get(true); ··· 609 608 if(playback_control(NULL)) 610 609 return RET_VAL_USB; 611 610 break; 612 - default: 611 + case 4: 613 612 return RET_VAL_QUIT_ERR; 614 613 break; 615 614 } ··· 700 699 return RET_VAL_OK; 701 700 } 702 701 703 - int get_number(char* param, int* value) { 702 + int get_number(char* param, int* value, int max) { 704 703 static const char *button_labels[4][3] = { 705 704 { "1", "2", "3" }, 706 705 { "4", "5", "6" }, ··· 709 708 }; 710 709 int i,j,x=0,y=0; 711 710 int height, width; 712 - int button = 0; 711 + int button = 0, ret = RET_VAL_OK; 712 + bool done = false; 713 713 rb->lcd_clear_display(); 714 714 rb->lcd_getstringsize("CLR", &width, &height); 715 715 if(width > NUM_BOX_WIDTH || height > NUM_BOX_HEIGHT) ··· 745 745 NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); 746 746 rb->lcd_set_drawmode(DRMODE_SOLID); 747 747 rb->lcd_update(); 748 - while(1) { 748 + while(!done) { 749 749 button = rb->button_get(true); 750 750 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 751 751 rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), ··· 762 762 } else if(x==1) { 763 763 *value *= 10; 764 764 } else if(x==2) { 765 - rb->lcd_setfont(FONT_UI); 766 - return RET_VAL_OK; 765 + done = true; 766 + break; 767 767 } 768 + if ((unsigned) *value > (unsigned) max) 769 + *value = max; 768 770 rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); 769 771 rb->lcd_fillrect(0, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, 770 772 LCD_WIDTH, 30); ··· 775 777 break; 776 778 case SUPERDOM_CANCEL: 777 779 *value = 0; 778 - rb->lcd_setfont(FONT_UI); 779 - rb->splash(HZ, "Cancelled"); 780 - return RET_VAL_QUIT_ERR; 780 + done = true; 781 + ret = RET_VAL_QUIT_ERR; 781 782 break; 782 783 #if CONFIG_KEYPAD != IRIVER_H10_PAD 783 784 case SUPERDOM_LEFT: ··· 838 839 default: 839 840 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) 840 841 { 841 - rb->lcd_setfont(FONT_UI); 842 - return RET_VAL_USB; 842 + done = true; 843 + ret = RET_VAL_USB; 843 844 } 844 845 break; 845 846 } ··· 851 852 rb->lcd_update(); 852 853 } 853 854 rb->lcd_setfont(FONT_UI); 854 - return RET_VAL_OK; 855 + rb->lcd_stop_scroll(); 856 + if (ret == RET_VAL_QUIT_ERR) 857 + rb->splash(HZ, "Cancelled"); 858 + return ret; 855 859 } 856 860 857 861 bool tile_has_item(int type, int x, int y) { ··· 1003 1007 switch(rb->do_menu(&menu, &selection, NULL, false)) { 1004 1008 case 0: 1005 1009 nummen = 0; 1006 - if(get_number("How many men would you like?", &nummen) 1007 - == RET_VAL_USB) 1010 + if(get_number("How many men would you like?", &nummen, 1011 + humanres.cash) == RET_VAL_USB) 1008 1012 return RET_VAL_USB; 1009 1013 if(!nummen) 1010 1014 break; ··· 1073 1077 if(type == 0) { 1074 1078 if(human) { 1075 1079 nummen = board[fromx][fromy].men; 1076 - if((temp = get_number("How many men do you want to move?", &nummen)) 1077 - != RET_VAL_OK) 1080 + if((temp = get_number("How many men do you want to move?", &nummen, 1081 + nummen)) != RET_VAL_OK) 1078 1082 return temp; 1079 1083 } 1080 1084 if(nummen > board[fromx][fromy].men) { ··· 1332 1336 break; 1333 1337 case 3: 1334 1338 temp = humanres.cash; 1335 - if(get_number("How much do you want to invest?", &temp) 1336 - == RET_VAL_USB) 1339 + if(get_number("How much do you want to invest?", &temp, 1340 + humanres.cash) == RET_VAL_USB) 1337 1341 return RET_VAL_USB; 1338 1342 if(temp > humanres.cash) { 1339 1343 rb->splash(HZ, "You don't have that much cash to invest"); ··· 1344 1348 break; 1345 1349 case 4: 1346 1350 temp = humanres.bank; 1347 - if(get_number("How much do you want to withdraw?", &temp) 1348 - == RET_VAL_USB) 1351 + if(get_number("How much do you want to withdraw?", &temp, 1352 + humanres.bank) == RET_VAL_USB) 1349 1353 return RET_VAL_USB; 1350 1354 if(temp > humanres.bank) { 1351 1355 rb->splash(HZ, "You don't have that much cash to withdraw");