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.zip
rockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.tar.gz
rockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.tar.bz2
rockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.tar.xz
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 f3210f2..a69b3bb 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -298,7 +298,6 @@ static int chessclock_set_int(char* string,
#define FLAGS_SET_INT_SECONDS 1
static char * show_time(int secs);
-static int simple_menu(int nr, unsigned char **strarr);
static bool pause;
@@ -514,53 +513,57 @@ static int run_timer(int nr)
/* MENU */
case CHC_MENU:
{
- int ret;
- char *menu[]={"Delete player", "Restart round",
- "Set round time", "Set total time"};
- ret=simple_menu(4, (unsigned char **)menu);
- if (ret==-1) {
- retval = 3;
- done=true;
- } else if (ret==-2) {
- } else if (ret==0) {
- /* delete timer */
- timer_holder[nr].hidden=true;
- retval=1;
- done=true;
- break;
- } else if (ret==1) {
- /* restart */
- ticks=0;
- break;
- } else if (ret==2) {
- /* set round time */
- int res;
- int val=(max_ticks-ticks)/HZ;
- res=chessclock_set_int("Round time",
- &val,
- 10, 0, MAX_TIME,
- FLAGS_SET_INT_SECONDS);
- if (res==-1) { /*usb*/
- retval = 3;
+ MENUITEM_STRINGLIST(menu, "Menu", NULL,
+ "Delete player", "Restart round",
+ "Set round time", "Set total time");
+
+ int val, res;
+ switch(rb->do_menu(&menu, NULL, NULL, false))
+ {
+ case 0:
+ /* delete timer */
+ timer_holder[nr].hidden=true;
+ retval=1;
done=true;
- } else if (res==1) {
- ticks=max_ticks-val*HZ;
- }
- } else if (ret==3) {
- /* set total time */
- int res;
- int val=timer_holder[nr].total_time;
- res=chessclock_set_int("Total time",
- &val,
- 10, 0, MAX_TIME,
- FLAGS_SET_INT_SECONDS);
- if (res==-1) { /*usb*/
+ break;
+ case 1:
+ /* restart */
+ ticks=0;
+ break;
+ case 2:
+ /* set round time */
+ val=(max_ticks-ticks)/HZ;
+ res=chessclock_set_int("Round time",
+ &val,
+ 10, 0, MAX_TIME,
+ FLAGS_SET_INT_SECONDS);
+ if (res==-1) { /*usb*/
+ retval = 3;
+ done=true;
+ } else if (res==1) {
+ ticks=max_ticks-val*HZ;
+ }
+ break;
+ case 3:
+ /* set total time */
+ val=timer_holder[nr].total_time;
+ res=chessclock_set_int("Total time",
+ &val,
+ 10, 0, MAX_TIME,
+ FLAGS_SET_INT_SECONDS);
+ if (res==-1) { /*usb*/
+ retval = 3;
+ done=true;
+ } else if (res==1) {
+ timer_holder[nr].total_time=val;
+ }
+ break;
+ case MENU_ATTACHED_USB:
retval = 3;
done=true;
- } else if (res==1) {
- timer_holder[nr].total_time=val;
- }
+ break;
}
+ rb->lcd_clear_display();
}
break;
@@ -664,55 +667,3 @@ static char * show_time(int seconds)
return buf;
}
-/* -1 = USB
- -2 = cancel
-*/
-static int simple_menu(int nr, unsigned char **strarr)
-{
- int show=0;
- int button;
- rb->lcd_clear_display();
-
- while (1) {
- if (show>=nr)
- show=0;
- if (show<0)
- show=nr-1;
- rb->lcd_puts_scroll(0, FIRST_LINE, strarr[show]);
- rb->lcd_update();
-
- button = rb->button_get(true);
- switch(button) {
- case CHC_SETTINGS_INC:
- case CHC_SETTINGS_INC | BUTTON_REPEAT:
- show++;
- break;
-
- case CHC_SETTINGS_DEC:
- case CHC_SETTINGS_DEC | BUTTON_REPEAT:
- show--;
- break;
-
- case CHC_SETTINGS_OK:
-#ifdef CHC_SETTINGS_OK2
- case CHC_SETTINGS_OK2:
-#endif
- return show;
- break;
-
- case CHC_SETTINGS_CANCEL:
-#ifdef CHC_SETTINGS_CANCEL2
- case CHC_SETTINGS_CANCEL2:
-#endif
- return -2; /* cancel */
- break;
-
- default:
- if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
- return -1; /* been in usb mode */
- break;
- }
- }
-}
-
-