summaryrefslogtreecommitdiff
path: root/apps/plugins/chessclock.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-06-16 04:25:21 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-06-16 04:25:21 +0000
commitaf9f4056510f248c4c9c1335167853bb455e8cc0 (patch)
treeeff7ad7726083ee605d753bd9aa9e22213b1acf0 /apps/plugins/chessclock.c
parentcb57a568e8dc9def607dc9ab27f515309bd13841 (diff)
downloadrockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.tar.gz
rockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.zip
Accept FS#10094 by Teruaki Kawashima:
Replace the old menu API with the "new" one (a very long time overdue so huge thanks for the work.) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/chessclock.c')
-rw-r--r--apps/plugins/chessclock.c143
1 files changed, 47 insertions, 96 deletions
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index f3210f29c8..a69b3bb582 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -298,7 +298,6 @@ static int chessclock_set_int(char* string,
298#define FLAGS_SET_INT_SECONDS 1 298#define FLAGS_SET_INT_SECONDS 1
299 299
300static char * show_time(int secs); 300static char * show_time(int secs);
301static int simple_menu(int nr, unsigned char **strarr);
302 301
303static bool pause; 302static bool pause;
304 303
@@ -514,53 +513,57 @@ static int run_timer(int nr)
514 /* MENU */ 513 /* MENU */
515 case CHC_MENU: 514 case CHC_MENU:
516 { 515 {
517 int ret; 516 MENUITEM_STRINGLIST(menu, "Menu", NULL,
518 char *menu[]={"Delete player", "Restart round", 517 "Delete player", "Restart round",
519 "Set round time", "Set total time"}; 518 "Set round time", "Set total time");
520 ret=simple_menu(4, (unsigned char **)menu); 519
521 if (ret==-1) { 520 int val, res;
522 retval = 3; 521 switch(rb->do_menu(&menu, NULL, NULL, false))
523 done=true; 522 {
524 } else if (ret==-2) { 523 case 0:
525 } else if (ret==0) { 524 /* delete timer */
526 /* delete timer */ 525 timer_holder[nr].hidden=true;
527 timer_holder[nr].hidden=true; 526 retval=1;
528 retval=1;
529 done=true;
530 break;
531 } else if (ret==1) {
532 /* restart */
533 ticks=0;
534 break;
535 } else if (ret==2) {
536 /* set round time */
537 int res;
538 int val=(max_ticks-ticks)/HZ;
539 res=chessclock_set_int("Round time",
540 &val,
541 10, 0, MAX_TIME,
542 FLAGS_SET_INT_SECONDS);
543 if (res==-1) { /*usb*/
544 retval = 3;
545 done=true; 527 done=true;
546 } else if (res==1) { 528 break;
547 ticks=max_ticks-val*HZ; 529 case 1:
548 } 530 /* restart */
549 } else if (ret==3) { 531 ticks=0;
550 /* set total time */ 532 break;
551 int res; 533 case 2:
552 int val=timer_holder[nr].total_time; 534 /* set round time */
553 res=chessclock_set_int("Total time", 535 val=(max_ticks-ticks)/HZ;
554 &val, 536 res=chessclock_set_int("Round time",
555 10, 0, MAX_TIME, 537 &val,
556 FLAGS_SET_INT_SECONDS); 538 10, 0, MAX_TIME,
557 if (res==-1) { /*usb*/ 539 FLAGS_SET_INT_SECONDS);
540 if (res==-1) { /*usb*/
541 retval = 3;
542 done=true;
543 } else if (res==1) {
544 ticks=max_ticks-val*HZ;
545 }
546 break;
547 case 3:
548 /* set total time */
549 val=timer_holder[nr].total_time;
550 res=chessclock_set_int("Total time",
551 &val,
552 10, 0, MAX_TIME,
553 FLAGS_SET_INT_SECONDS);
554 if (res==-1) { /*usb*/
555 retval = 3;
556 done=true;
557 } else if (res==1) {
558 timer_holder[nr].total_time=val;
559 }
560 break;
561 case MENU_ATTACHED_USB:
558 retval = 3; 562 retval = 3;
559 done=true; 563 done=true;
560 } else if (res==1) { 564 break;
561 timer_holder[nr].total_time=val;
562 }
563 } 565 }
566 rb->lcd_clear_display();
564 } 567 }
565 break; 568 break;
566 569
@@ -664,55 +667,3 @@ static char * show_time(int seconds)
664 return buf; 667 return buf;
665} 668}
666 669
667/* -1 = USB
668 -2 = cancel
669*/
670static int simple_menu(int nr, unsigned char **strarr)
671{
672 int show=0;
673 int button;
674 rb->lcd_clear_display();
675
676 while (1) {
677 if (show>=nr)
678 show=0;
679 if (show<0)
680 show=nr-1;
681 rb->lcd_puts_scroll(0, FIRST_LINE, strarr[show]);
682 rb->lcd_update();
683
684 button = rb->button_get(true);
685 switch(button) {
686 case CHC_SETTINGS_INC:
687 case CHC_SETTINGS_INC | BUTTON_REPEAT:
688 show++;
689 break;
690
691 case CHC_SETTINGS_DEC:
692 case CHC_SETTINGS_DEC | BUTTON_REPEAT:
693 show--;
694 break;
695
696 case CHC_SETTINGS_OK:
697#ifdef CHC_SETTINGS_OK2
698 case CHC_SETTINGS_OK2:
699#endif
700 return show;
701 break;
702
703 case CHC_SETTINGS_CANCEL:
704#ifdef CHC_SETTINGS_CANCEL2
705 case CHC_SETTINGS_CANCEL2:
706#endif
707 return -2; /* cancel */
708 break;
709
710 default:
711 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
712 return -1; /* been in usb mode */
713 break;
714 }
715 }
716}
717
718