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