diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2009-06-16 04:25:21 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2009-06-16 04:25:21 +0000 |
commit | af9f4056510f248c4c9c1335167853bb455e8cc0 (patch) | |
tree | eff7ad7726083ee605d753bd9aa9e22213b1acf0 /apps | |
parent | cb57a568e8dc9def607dc9ab27f515309bd13841 (diff) | |
download | rockbox-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')
-rw-r--r-- | apps/plugins/chessclock.c | 143 | ||||
-rw-r--r-- | apps/plugins/doom/rockdoom.c | 144 | ||||
-rw-r--r-- | apps/plugins/fireworks.c | 25 | ||||
-rw-r--r-- | apps/plugins/jewels.c | 433 | ||||
-rw-r--r-- | apps/plugins/jpeg/jpeg.c | 55 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/oldmenuapi.c | 237 | ||||
-rw-r--r-- | apps/plugins/lib/oldmenuapi.h | 58 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 139 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.h | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 2 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox.c | 22 | ||||
-rw-r--r-- | apps/plugins/random_folder_advance_config.c | 53 | ||||
-rw-r--r-- | apps/plugins/reversi/reversi-gui.c | 23 | ||||
-rw-r--r-- | apps/plugins/rockboy/menu.c | 106 | ||||
-rw-r--r-- | apps/plugins/rockpaint.c | 541 | ||||
-rw-r--r-- | apps/plugins/solitaire.c | 55 | ||||
-rw-r--r-- | apps/plugins/sudoku/sudoku.c | 42 | ||||
-rw-r--r-- | apps/plugins/test_disk.c | 29 | ||||
-rw-r--r-- | apps/plugins/test_sampr.c | 22 | ||||
-rw-r--r-- | apps/plugins/viewer.c | 69 | ||||
-rw-r--r-- | apps/plugins/zxbox/spmain.c | 95 |
22 files changed, 728 insertions, 1568 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 | ||
300 | static char * show_time(int secs); | 300 | static char * show_time(int secs); |
301 | static int simple_menu(int nr, unsigned char **strarr); | ||
302 | 301 | ||
303 | static bool pause; | 302 | static 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 | */ | ||
670 | static 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 | |||
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 1e7c9fa13a..0220b984d8 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include "i_system.h" | 39 | #include "i_system.h" |
40 | #include "hu_stuff.h" | 40 | #include "hu_stuff.h" |
41 | #include "st_stuff.h" | 41 | #include "st_stuff.h" |
42 | #include "lib/oldmenuapi.h" | ||
43 | #include "lib/helper.h" | 42 | #include "lib/helper.h" |
44 | 43 | ||
45 | PLUGIN_HEADER | 44 | PLUGIN_HEADER |
@@ -217,8 +216,8 @@ const unsigned char wads_builtin[7][30] = | |||
217 | }; | 216 | }; |
218 | 217 | ||
219 | int namemap[7]; | 218 | int namemap[7]; |
220 | static struct menu_item *addons; | 219 | static char **addons; |
221 | static struct menu_item *demolmp; | 220 | static char **demolmp; |
222 | char addon[200]; | 221 | char addon[200]; |
223 | // This sets up the base game and builds up myargv/c | 222 | // This sets up the base game and builds up myargv/c |
224 | bool Dhandle_ver (int dver) | 223 | bool Dhandle_ver (int dver) |
@@ -274,14 +273,14 @@ bool Dhandle_ver (int dver) | |||
274 | 273 | ||
275 | if(argvlist.addonnum) | 274 | if(argvlist.addonnum) |
276 | { | 275 | { |
277 | snprintf(addon,sizeof(addon),"%s%s", GAMEBASE"addons/", addons[argvlist.addonnum].desc); | 276 | snprintf(addon,sizeof(addon),"%s%s", GAMEBASE"addons/", addons[argvlist.addonnum]); |
278 | D_AddFile(addon,source_pwad); | 277 | D_AddFile(addon,source_pwad); |
279 | modifiedgame = true; | 278 | modifiedgame = true; |
280 | } | 279 | } |
281 | 280 | ||
282 | if(argvlist.demonum) | 281 | if(argvlist.demonum) |
283 | { | 282 | { |
284 | snprintf(addon, sizeof(addon),"%s%s", GAMEBASE"demos/", demolmp[argvlist.demonum].desc); | 283 | snprintf(addon, sizeof(addon),"%s%s", GAMEBASE"demos/", demolmp[argvlist.demonum]); |
285 | D_AddFile(addon, source_lmp); | 284 | D_AddFile(addon, source_lmp); |
286 | G_DeferedPlayDemo(addon); | 285 | G_DeferedPlayDemo(addon); |
287 | singledemo = true; // quit after one demo | 286 | singledemo = true; // quit after one demo |
@@ -323,21 +322,20 @@ int Dbuild_base (struct opt_items *names) | |||
323 | 322 | ||
324 | // This is a general function that takes in a menu_item structure and makes a list | 323 | // This is a general function that takes in a menu_item structure and makes a list |
325 | // of files within it based on matching the string stringmatch to the files. | 324 | // of files within it based on matching the string stringmatch to the files. |
326 | int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory, char *stringmatch) | 325 | int Dbuild_filelistm(char ***names, char *firstentry, char *directory, char *stringmatch) |
327 | { | 326 | { |
328 | int i=0; | 327 | int i=0; |
329 | DIR *filedir; | 328 | DIR *filedir; |
330 | struct dirent *dptr; | 329 | struct dirent *dptr; |
331 | char *startpt; | 330 | char *startpt; |
332 | struct menu_item *temp; | 331 | char **temp; |
333 | 332 | ||
334 | filedir=rb->opendir(directory); | 333 | filedir=rb->opendir(directory); |
335 | 334 | ||
336 | if(filedir==NULL) | 335 | if(filedir==NULL) |
337 | { | 336 | { |
338 | temp=malloc(sizeof(struct menu_item)); | 337 | temp=malloc(sizeof(char *)); |
339 | temp[0].desc=firstentry; | 338 | temp[0]=firstentry; |
340 | temp[0].function=0; | ||
341 | *names=temp; | 339 | *names=temp; |
342 | return 1; | 340 | return 1; |
343 | } | 341 | } |
@@ -351,9 +349,8 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory | |||
351 | filedir=rb->opendir(directory); | 349 | filedir=rb->opendir(directory); |
352 | 350 | ||
353 | i++; | 351 | i++; |
354 | temp=malloc(i*sizeof(struct menu_item)); | 352 | temp=malloc(i*sizeof(char *)); |
355 | temp[0].desc=firstentry; | 353 | temp[0]=firstentry; |
356 | temp[0].function=0; | ||
357 | i=1; | 354 | i=1; |
358 | 355 | ||
359 | while((dptr=rb->readdir(filedir))) | 356 | while((dptr=rb->readdir(filedir))) |
@@ -362,8 +359,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory | |||
362 | { | 359 | { |
363 | startpt=malloc(strlen(dptr->d_name)*sizeof(char)); | 360 | startpt=malloc(strlen(dptr->d_name)*sizeof(char)); |
364 | strcpy(startpt,dptr->d_name); | 361 | strcpy(startpt,dptr->d_name); |
365 | temp[i].desc=startpt; | 362 | temp[i]=startpt; |
366 | temp[i].function=0; | ||
367 | i++; | 363 | i++; |
368 | } | 364 | } |
369 | } | 365 | } |
@@ -444,7 +440,7 @@ static int translatekey(int key) | |||
444 | 440 | ||
445 | int Oset_keys() | 441 | int Oset_keys() |
446 | { | 442 | { |
447 | int m, result; | 443 | int selected=0, result; |
448 | int menuquit=0; | 444 | int menuquit=0; |
449 | 445 | ||
450 | 446 | ||
@@ -483,36 +479,24 @@ int Oset_keys() | |||
483 | 479 | ||
484 | int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys); | 480 | int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys); |
485 | 481 | ||
486 | static const struct menu_item items[] = { | 482 | MENUITEM_STRINGLIST(menu, "Set Keys", NULL, |
487 | { "Game Right", NULL }, | 483 | "Game Right", "Game Left", "Game Up", "Game Down", |
488 | { "Game Left", NULL }, | 484 | "Game Shoot", "Game Open", "Game Strafe", |
489 | { "Game Up", NULL }, | 485 | "Game Weapon", "Game Automap"); |
490 | { "Game Down", NULL }, | ||
491 | { "Game Shoot", NULL }, | ||
492 | { "Game Open", NULL }, | ||
493 | { "Game Strafe", NULL }, | ||
494 | { "Game Weapon", NULL }, | ||
495 | { "Game Automap", NULL }, | ||
496 | }; | ||
497 | |||
498 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
499 | NULL, NULL, NULL, NULL); | ||
500 | 486 | ||
501 | while(!menuquit) | 487 | while(!menuquit) |
502 | { | 488 | { |
503 | result=menu_show(m); | 489 | result = rb->do_menu(&menu, &selected, NULL, false); |
504 | if(result<0) | 490 | if(result<0) |
505 | menuquit=1; | 491 | menuquit=1; |
506 | else | 492 | else |
507 | { | 493 | { |
508 | *keys[result]=translatekey(*keys[result]); | 494 | *keys[result]=translatekey(*keys[result]); |
509 | rb->set_option(items[result].desc, keys[result], INT, doomkeys, numdoomkeys, NULL ); | 495 | rb->set_option(menu_[result], keys[result], INT, doomkeys, numdoomkeys, NULL ); |
510 | *keys[result]=translatekey(*keys[result]); | 496 | *keys[result]=translatekey(*keys[result]); |
511 | } | 497 | } |
512 | } | 498 | } |
513 | 499 | ||
514 | menu_exit(m); | ||
515 | |||
516 | return (1); | 500 | return (1); |
517 | } | 501 | } |
518 | 502 | ||
@@ -525,24 +509,17 @@ static bool Doptions() | |||
525 | { "On", -1 }, | 509 | { "On", -1 }, |
526 | }; | 510 | }; |
527 | 511 | ||
528 | int m, result; | 512 | int selected=0, result; |
529 | int menuquit=0; | 513 | int menuquit=0; |
530 | 514 | ||
531 | static const struct menu_item items[] = { | 515 | MENUITEM_STRINGLIST(menu, "Options", NULL, |
532 | { "Set Keys", NULL }, | 516 | "Set Keys", "Sound", "Timedemo", "Player Bobbing", |
533 | { "Sound", NULL }, | 517 | "Weapon Recoil", "Translucency", "Fake Contrast", |
534 | { "Timedemo", NULL }, | 518 | "Always Run", "Headsup Display", "Statusbar Always Red", |
535 | { "Player Bobbing", NULL }, | ||
536 | { "Weapon Recoil", NULL }, | ||
537 | { "Translucency", NULL }, | ||
538 | { "Fake Contrast", NULL }, | ||
539 | { "Always Run", NULL }, | ||
540 | { "Headsup Display", NULL }, | ||
541 | { "Statusbar Always Red", NULL }, | ||
542 | #if(LCD_HEIGHT>LCD_WIDTH) | 519 | #if(LCD_HEIGHT>LCD_WIDTH) |
543 | { "Rotate Screen 90 deg", NULL }, | 520 | "Rotate Screen 90 deg", |
544 | #endif | 521 | #endif |
545 | }; | 522 | ); |
546 | 523 | ||
547 | void *options[]={ | 524 | void *options[]={ |
548 | &enable_sound, | 525 | &enable_sound, |
@@ -559,36 +536,48 @@ static bool Doptions() | |||
559 | #endif | 536 | #endif |
560 | }; | 537 | }; |
561 | 538 | ||
562 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
563 | NULL, NULL, NULL, NULL); | ||
564 | |||
565 | while(!menuquit) | 539 | while(!menuquit) |
566 | { | 540 | { |
567 | result=menu_show(m); | 541 | result = rb->do_menu(&menu, &selected, NULL, false); |
568 | if(result==0) | 542 | if(result==0) |
569 | Oset_keys(); | 543 | Oset_keys(); |
570 | else if (result > 0) | 544 | else if (result > 0) |
571 | rb->set_option(items[result].desc, options[result-1], INT, onoff, 2, NULL ); | 545 | rb->set_option(menu_[result], options[result-1], INT, onoff, 2, NULL ); |
572 | else | 546 | else |
573 | menuquit=1; | 547 | menuquit=1; |
574 | } | 548 | } |
575 | 549 | ||
576 | menu_exit(m); | ||
577 | |||
578 | return (1); | 550 | return (1); |
579 | } | 551 | } |
580 | 552 | ||
581 | int menuchoice(struct menu_item *menu, int items) | 553 | char* choice_get_name(int selected_item, void * data, |
554 | char * buffer, size_t buffer_len) | ||
582 | { | 555 | { |
583 | int m, result; | 556 | char **names = (char **) data; |
584 | 557 | (void) buffer; | |
585 | m = menu_init(menu, items,NULL, NULL, NULL, NULL); | 558 | (void) buffer_len; |
586 | 559 | return names[selected_item]; | |
587 | result= menu_show(m); | 560 | } |
588 | menu_exit(m); | 561 | int list_action_callback(int action, struct gui_synclist *lists) |
589 | if(result<items && result>=0) | 562 | { |
590 | return result; | 563 | (void) lists; |
591 | return 0; | 564 | if (action == ACTION_STD_OK) |
565 | return ACTION_STD_CANCEL; | ||
566 | return action; | ||
567 | } | ||
568 | bool menuchoice(char **names, int count, int *selected) | ||
569 | { | ||
570 | struct simplelist_info info; | ||
571 | rb->simplelist_info_init(&info, NULL, count, (void*)names); | ||
572 | info.selection = *selected; | ||
573 | info.get_name = choice_get_name; | ||
574 | info.action_callback = list_action_callback; | ||
575 | if(rb->simplelist_show_list(&info)) | ||
576 | return true; | ||
577 | |||
578 | if(info.selection<count && info.selection>=0) | ||
579 | *selected = info.selection; | ||
580 | return false; | ||
592 | } | 581 | } |
593 | 582 | ||
594 | // | 583 | // |
@@ -596,22 +585,16 @@ int menuchoice(struct menu_item *menu, int items) | |||
596 | // | 585 | // |
597 | int doom_menu() | 586 | int doom_menu() |
598 | { | 587 | { |
599 | int m; | 588 | int selected=0, result; |
600 | int result; | ||
601 | int status; | 589 | int status; |
602 | int gamever; | 590 | int gamever; |
603 | bool menuquit=0; | 591 | bool menuquit=0; |
604 | 592 | ||
605 | static struct opt_items names[7]; | 593 | static struct opt_items names[7]; |
606 | 594 | ||
607 | static const struct menu_item items[] = { | 595 | MENUITEM_STRINGLIST(menu, "Doom Menu", NULL, |
608 | { "Game", NULL }, | 596 | "Game", "Addons", "Demos", |
609 | { "Addons", NULL }, | 597 | "Options", "Play Game", "Quit"); |
610 | { "Demos", NULL }, | ||
611 | { "Options", NULL }, | ||
612 | { "Play Game", NULL }, | ||
613 | { "Quit", NULL }, | ||
614 | }; | ||
615 | 598 | ||
616 | if( (status=Dbuild_base(names)) == 0 ) // Build up the base wad files (select last added file) | 599 | if( (status=Dbuild_base(names)) == 0 ) // Build up the base wad files (select last added file) |
617 | { | 600 | { |
@@ -632,23 +615,20 @@ int doom_menu() | |||
632 | while (rb->button_get(false) != BUTTON_NONE) | 615 | while (rb->button_get(false) != BUTTON_NONE) |
633 | rb->yield(); | 616 | rb->yield(); |
634 | 617 | ||
635 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
636 | NULL, NULL, NULL, NULL); | ||
637 | |||
638 | while(!menuquit) | 618 | while(!menuquit) |
639 | { | 619 | { |
640 | result=menu_show(m); | 620 | result = rb->do_menu(&menu, &selected, NULL, false); |
641 | switch (result) { | 621 | switch (result) { |
642 | case 0: /* Game picker */ | 622 | case 0: /* Game picker */ |
643 | rb->set_option("Game WAD", &gamever, INT, names, status, NULL ); | 623 | rb->set_option("Game WAD", &gamever, INT, names, status, NULL ); |
644 | break; | 624 | break; |
645 | 625 | ||
646 | case 1: /* Addon picker */ | 626 | case 1: /* Addon picker */ |
647 | argvlist.addonnum=menuchoice(addons,numadd); | 627 | menuchoice(addons,numadd,&argvlist.addonnum); |
648 | break; | 628 | break; |
649 | 629 | ||
650 | case 2: /* Demos */ | 630 | case 2: /* Demos */ |
651 | argvlist.demonum=menuchoice(demolmp,numdemos); | 631 | menuchoice(demolmp,numdemos,&argvlist.demonum); |
652 | break; | 632 | break; |
653 | 633 | ||
654 | case 3: /* Options */ | 634 | case 3: /* Options */ |
@@ -669,8 +649,6 @@ int doom_menu() | |||
669 | } | 649 | } |
670 | } | 650 | } |
671 | 651 | ||
672 | menu_exit(m); | ||
673 | |||
674 | return (gamever); | 652 | return (gamever); |
675 | } | 653 | } |
676 | 654 | ||
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index 168a67baa9..d237007460 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/oldmenuapi.h" | ||
23 | #include "lib/helper.h" | 22 | #include "lib/helper.h" |
24 | #include "lib/playback_control.h" | 23 | #include "lib/playback_control.h" |
25 | 24 | ||
@@ -287,17 +286,10 @@ static const struct opt_items fps_settings[9] = { | |||
287 | int fps_values[9] = { | 286 | int fps_values[9] = { |
288 | 20, 25, 30, 35, 40, 45, 50, 55, 60 }; | 287 | 20, 25, 30, 35, 40, 45, 50, 55, 60 }; |
289 | 288 | ||
290 | static const struct menu_item items[] = { | 289 | MENUITEM_STRINGLIST(menu, "Fireworks Menu", NULL, |
291 | { "Start Demo", NULL }, | 290 | "Start Demo", "Auto-Fire", "Particles Per Firework", |
292 | { "Auto-Fire", NULL }, | 291 | "Particle Life", "Gravity", "Show Rockets", |
293 | { "Particles Per Firework", NULL }, | 292 | "FPS (Speed)", "Playback Control", "Quit"); |
294 | { "Particle Life", NULL }, | ||
295 | { "Gravity", NULL }, | ||
296 | { "Show Rockets", NULL }, | ||
297 | { "FPS (Speed)", NULL }, | ||
298 | { "Playback Control", NULL }, | ||
299 | { "Quit", NULL } | ||
300 | }; | ||
301 | 293 | ||
302 | /* called on startup. initializes all variables, etc */ | 294 | /* called on startup. initializes all variables, etc */ |
303 | void init_all(void) | 295 | void init_all(void) |
@@ -348,7 +340,7 @@ void init_rocket(int rocket) | |||
348 | /* startup/configuration menu. */ | 340 | /* startup/configuration menu. */ |
349 | void fireworks_menu(void) | 341 | void fireworks_menu(void) |
350 | { | 342 | { |
351 | int m, result; | 343 | int selected = 0, result; |
352 | bool menu_quit = false; | 344 | bool menu_quit = false; |
353 | 345 | ||
354 | rb->lcd_setfont(FONT_UI); | 346 | rb->lcd_setfont(FONT_UI); |
@@ -359,14 +351,11 @@ void fireworks_menu(void) | |||
359 | rb->lcd_clear_display(); | 351 | rb->lcd_clear_display(); |
360 | rb->lcd_update(); | 352 | rb->lcd_update(); |
361 | 353 | ||
362 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
363 | NULL, NULL, NULL, NULL); | ||
364 | |||
365 | rb->button_clear_queue(); | 354 | rb->button_clear_queue(); |
366 | 355 | ||
367 | while(!menu_quit) | 356 | while(!menu_quit) |
368 | { | 357 | { |
369 | result = menu_show(m); | 358 | result = rb->do_menu(&menu, &selected, NULL, false); |
370 | 359 | ||
371 | switch(result) | 360 | switch(result) |
372 | { | 361 | { |
@@ -419,8 +408,6 @@ void fireworks_menu(void) | |||
419 | break; | 408 | break; |
420 | } | 409 | } |
421 | } | 410 | } |
422 | |||
423 | menu_exit(m); | ||
424 | } | 411 | } |
425 | 412 | ||
426 | /* this is the plugin entry point */ | 413 | /* this is the plugin entry point */ |
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 6bf5fcf8ac..ae69e0ade5 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c | |||
@@ -330,59 +330,6 @@ enum game_type { | |||
330 | GAME_TYPE_PUZZLE | 330 | GAME_TYPE_PUZZLE |
331 | }; | 331 | }; |
332 | 332 | ||
333 | /* menu values */ | ||
334 | #define FONT_HEIGHT 8 | ||
335 | #define MAX_MITEMS 6 | ||
336 | #define MENU_WIDTH 100 | ||
337 | |||
338 | /* menu results */ | ||
339 | enum menu_result { | ||
340 | MRES_NONE, | ||
341 | MRES_NEW, | ||
342 | MRES_PUZZLE, | ||
343 | MRES_SAVE, | ||
344 | MRES_RESUME, | ||
345 | MRES_SCORES, | ||
346 | MRES_HELP, | ||
347 | MRES_QUIT, | ||
348 | MRES_PLAYBACK, | ||
349 | MRES_EXIT | ||
350 | }; | ||
351 | |||
352 | /* menu commands */ | ||
353 | enum menu_cmd { | ||
354 | MCMD_NONE, | ||
355 | MCMD_NEXT, | ||
356 | MCMD_PREV, | ||
357 | MCMD_SELECT | ||
358 | }; | ||
359 | |||
360 | /* menus */ | ||
361 | struct jewels_menu { | ||
362 | char *title; | ||
363 | bool hasframe; | ||
364 | int selected; | ||
365 | int itemcnt; | ||
366 | struct jewels_menuitem { | ||
367 | char *text; | ||
368 | enum menu_result res; | ||
369 | } items[MAX_MITEMS]; | ||
370 | } bjmenu[] = { | ||
371 | {"Jewels", false, 0, 6, | ||
372 | {{"New Game", MRES_NEW}, | ||
373 | {"Puzzle", MRES_PUZZLE}, | ||
374 | {"Resume Saved Game", MRES_RESUME}, | ||
375 | {"High Scores", MRES_SCORES}, | ||
376 | {"Help", MRES_HELP}, | ||
377 | {"Quit", MRES_QUIT}}}, | ||
378 | {"Menu", true, 0, 5, | ||
379 | {{"Audio Playback", MRES_PLAYBACK }, | ||
380 | {"Resume Game", MRES_RESUME}, | ||
381 | {"Save Game", MRES_SAVE}, | ||
382 | {"End Game", MRES_QUIT}, | ||
383 | {"Exit Jewels", MRES_EXIT}}} | ||
384 | }; | ||
385 | |||
386 | /* external bitmaps */ | 333 | /* external bitmaps */ |
387 | extern const fb_data jewels[]; | 334 | extern const fb_data jewels[]; |
388 | 335 | ||
@@ -677,73 +624,6 @@ static void jewels_drawboard(struct game_context* bj) { | |||
677 | } | 624 | } |
678 | 625 | ||
679 | /***************************************************************************** | 626 | /***************************************************************************** |
680 | * jewels_showmenu() displays the chosen menu after performing the chosen | ||
681 | * menu command. | ||
682 | ******************************************************************************/ | ||
683 | static enum menu_result jewels_showmenu(struct jewels_menu* menu, | ||
684 | enum menu_cmd cmd) { | ||
685 | int i; | ||
686 | int w, h; | ||
687 | int firstline; | ||
688 | int adj; | ||
689 | int extraline = LCD_HEIGHT <= ((menu->itemcnt+2)*FONT_HEIGHT) ? 0 : 1; | ||
690 | |||
691 | /* handle menu command */ | ||
692 | switch(cmd) { | ||
693 | case MCMD_NEXT: | ||
694 | menu->selected = (menu->selected+1)%menu->itemcnt; | ||
695 | break; | ||
696 | |||
697 | case MCMD_PREV: | ||
698 | menu->selected = (menu->selected-1+menu->itemcnt)%menu->itemcnt; | ||
699 | break; | ||
700 | |||
701 | case MCMD_SELECT: | ||
702 | return menu->items[menu->selected].res; | ||
703 | |||
704 | default: | ||
705 | break; | ||
706 | } | ||
707 | |||
708 | /* clear menu area */ | ||
709 | firstline = (LCD_HEIGHT/FONT_HEIGHT-(menu->itemcnt+3))/2; | ||
710 | |||
711 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
712 | rb->lcd_fillrect((LCD_WIDTH-MENU_WIDTH)/2, firstline*FONT_HEIGHT, | ||
713 | MENU_WIDTH, (menu->itemcnt+3)*FONT_HEIGHT); | ||
714 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
715 | |||
716 | if(menu->hasframe) { | ||
717 | rb->lcd_drawrect((LCD_WIDTH-MENU_WIDTH)/2-1, firstline*FONT_HEIGHT-1, | ||
718 | MENU_WIDTH+2, (menu->itemcnt+3)*FONT_HEIGHT+2); | ||
719 | rb->lcd_hline((LCD_WIDTH-MENU_WIDTH)/2-1, | ||
720 | (LCD_WIDTH-MENU_WIDTH)/2-1+MENU_WIDTH+2, | ||
721 | (firstline+1)*FONT_HEIGHT); | ||
722 | } | ||
723 | |||
724 | /* draw menu items */ | ||
725 | rb->lcd_getstringsize(menu->title, &w, &h); | ||
726 | rb->lcd_putsxy((LCD_WIDTH-w)/2, firstline*FONT_HEIGHT, menu->title); | ||
727 | |||
728 | for(i=0; i<menu->itemcnt; i++) { | ||
729 | if(i == menu->selected) { | ||
730 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
731 | } | ||
732 | rb->lcd_putsxy((LCD_WIDTH-MENU_WIDTH)/2, | ||
733 | (firstline+i+1+extraline)*FONT_HEIGHT, | ||
734 | menu->items[i].text); | ||
735 | if(i == menu->selected) { | ||
736 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
737 | } | ||
738 | } | ||
739 | |||
740 | adj = (firstline == 0 ? 0 : 1); | ||
741 | rb->lcd_update_rect((LCD_WIDTH-MENU_WIDTH)/2-1, firstline*FONT_HEIGHT-adj, | ||
742 | MENU_WIDTH+2, (menu->itemcnt+3)*FONT_HEIGHT+2*adj); | ||
743 | return MRES_NONE; | ||
744 | } | ||
745 | |||
746 | /***************************************************************************** | ||
747 | * jewels_putjewels() makes the jewels fall to fill empty spots and adds | 627 | * jewels_putjewels() makes the jewels fall to fill empty spots and adds |
748 | * new random jewels at the empty spots at the top of each row. | 628 | * new random jewels at the empty spots at the top of each row. |
749 | ******************************************************************************/ | 629 | ******************************************************************************/ |
@@ -1457,18 +1337,36 @@ static void jewels_callback(void* param) { | |||
1457 | } | 1337 | } |
1458 | 1338 | ||
1459 | /***************************************************************************** | 1339 | /***************************************************************************** |
1340 | * jewels_displayscores() displays the high scores | ||
1341 | ******************************************************************************/ | ||
1342 | static char * scores_get_name(int selected_item, void * data, | ||
1343 | char * buffer, size_t buffer_len) | ||
1344 | { | ||
1345 | struct game_context* bj = (struct game_context*)data; | ||
1346 | rb->snprintf(buffer, buffer_len, "#%02d: %d", | ||
1347 | selected_item+1, bj->highscores[selected_item]); | ||
1348 | return buffer; | ||
1349 | } | ||
1350 | static void jewels_displayscores(struct game_context* bj) | ||
1351 | { | ||
1352 | struct simplelist_info info; | ||
1353 | rb->simplelist_info_init(&info, "High Scores", NUM_SCORES, (void*)bj); | ||
1354 | info.hide_selection = true; | ||
1355 | info.get_name = scores_get_name; | ||
1356 | rb->simplelist_show_list(&info); | ||
1357 | } | ||
1358 | |||
1359 | |||
1360 | /***************************************************************************** | ||
1460 | * jewels_main() is the main game subroutine, it returns the final game status. | 1361 | * jewels_main() is the main game subroutine, it returns the final game status. |
1461 | ******************************************************************************/ | 1362 | ******************************************************************************/ |
1462 | static int jewels_main(struct game_context* bj) { | 1363 | static int jewels_main(struct game_context* bj) { |
1463 | int i, j; | ||
1464 | int w, h; | 1364 | int w, h; |
1465 | int button; | 1365 | int button; |
1366 | struct viewport vp[NB_SCREENS]; | ||
1466 | char str[18]; | 1367 | char str[18]; |
1467 | bool startgame = false; | 1368 | bool inmenu = true; |
1468 | bool inmenu = false; | ||
1469 | bool selected = false; | 1369 | bool selected = false; |
1470 | enum menu_cmd cmd = MCMD_NONE; | ||
1471 | enum menu_result res; | ||
1472 | 1370 | ||
1473 | /* the cursor coordinates */ | 1371 | /* the cursor coordinates */ |
1474 | int x=0, y=0; | 1372 | int x=0, y=0; |
@@ -1479,67 +1377,47 @@ static int jewels_main(struct game_context* bj) { | |||
1479 | /******************** | 1377 | /******************** |
1480 | * menu * | 1378 | * menu * |
1481 | ********************/ | 1379 | ********************/ |
1482 | rb->lcd_clear_display(); | 1380 | MENUITEM_STRINGLIST(main_menu,"Jewels",NULL, |
1483 | 1381 | "New Game", "Puzzle", "Resume Saved Game", | |
1484 | while(!startgame) { | 1382 | "High Scores", "Help", "Quit"); |
1485 | res = jewels_showmenu(&bjmenu[0], cmd); | 1383 | FOR_NB_SCREENS(h) |
1486 | cmd = MCMD_NONE; | 1384 | { |
1487 | 1385 | rb->viewport_set_defaults(&vp[h], h); | |
1488 | rb->snprintf(str, 18, "High Score: %d", bj->highscores[0]); | 1386 | #if (LCD_DEPTH >= 16) || defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH >= 16) |
1489 | rb->lcd_getstringsize(str, &w, &h); | 1387 | if (rb->screens[h]->depth >= 16) |
1490 | rb->lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT-8, str); | 1388 | { |
1491 | rb->lcd_update(); | 1389 | vp->bg_pattern = LCD_RGBPACK(49, 26, 26); |
1390 | vp->fg_pattern = LCD_RGBPACK(210, 181, 181); | ||
1391 | } | ||
1392 | #endif | ||
1393 | } | ||
1492 | 1394 | ||
1493 | rb->yield(); | 1395 | while(inmenu) { |
1494 | 1396 | ||
1495 | switch(res) { | 1397 | switch (rb->do_menu(&main_menu, NULL, vp, true)) { |
1496 | case MRES_NEW: | 1398 | case 0: |
1497 | startgame = true; | 1399 | inmenu = false; |
1498 | bj->type = GAME_TYPE_NORMAL; | 1400 | bj->type = GAME_TYPE_NORMAL; |
1499 | continue; | 1401 | break; |
1500 | 1402 | ||
1501 | case MRES_PUZZLE: | 1403 | case 1: |
1502 | startgame = true; | 1404 | inmenu = false; |
1503 | bj->type = GAME_TYPE_PUZZLE; | 1405 | bj->type = GAME_TYPE_PUZZLE; |
1504 | continue; | 1406 | break; |
1505 | 1407 | ||
1506 | case MRES_RESUME: | 1408 | case 2: |
1507 | if(!jewels_loadgame(bj)) { | 1409 | if(!jewels_loadgame(bj)) { |
1508 | rb->splash(HZ*2, "Nothing to resume"); | 1410 | rb->splash(HZ*2, "Nothing to resume"); |
1509 | rb->lcd_clear_display(); | ||
1510 | } else { | 1411 | } else { |
1511 | startgame = true; | 1412 | inmenu = false; |
1512 | } | ||
1513 | continue; | ||
1514 | |||
1515 | case MRES_SCORES: | ||
1516 | rb->lcd_clear_display(); | ||
1517 | |||
1518 | /* room for a title? */ | ||
1519 | j = 0; | ||
1520 | if(LCD_HEIGHT-NUM_SCORES*8 >= 8) { | ||
1521 | rb->snprintf(str, 12, "%s", "High Scores"); | ||
1522 | rb->lcd_getstringsize(str, &w, &h); | ||
1523 | rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str); | ||
1524 | j = 2; | ||
1525 | } | ||
1526 | |||
1527 | /* print high scores */ | ||
1528 | for(i=0; i<NUM_SCORES; i++) { | ||
1529 | rb->snprintf(str, 11, "#%02d: %d", i+1, bj->highscores[i]); | ||
1530 | rb->lcd_puts(0, i+j, str); | ||
1531 | } | 1413 | } |
1414 | break; | ||
1532 | 1415 | ||
1533 | rb->lcd_update(); | 1416 | case 3: |
1534 | while(true) { | 1417 | jewels_displayscores(bj); |
1535 | button = rb->button_get(true); | 1418 | break; |
1536 | if(button != BUTTON_NONE && !(button&BUTTON_REL)) break; | ||
1537 | rb->yield(); | ||
1538 | } | ||
1539 | rb->lcd_clear_display(); | ||
1540 | continue; | ||
1541 | 1419 | ||
1542 | case MRES_HELP: | 1420 | case 4: |
1543 | /* welcome screen to display key bindings */ | 1421 | /* welcome screen to display key bindings */ |
1544 | rb->lcd_clear_display(); | 1422 | rb->lcd_clear_display(); |
1545 | rb->snprintf(str, 5, "%s", "Help"); | 1423 | rb->snprintf(str, 5, "%s", "Help"); |
@@ -1694,54 +1572,17 @@ static int jewels_main(struct game_context* bj) { | |||
1694 | if(button != BUTTON_NONE && !(button&BUTTON_REL)) break; | 1572 | if(button != BUTTON_NONE && !(button&BUTTON_REL)) break; |
1695 | } | 1573 | } |
1696 | rb->lcd_clear_display(); | 1574 | rb->lcd_clear_display(); |
1697 | continue; | ||
1698 | |||
1699 | case MRES_QUIT: | ||
1700 | return BJ_QUIT; | ||
1701 | |||
1702 | default: | ||
1703 | break; | 1575 | break; |
1704 | } | ||
1705 | 1576 | ||
1706 | /* handle menu button presses */ | 1577 | case 5: |
1707 | button = rb->button_get(true); | ||
1708 | switch(button){ | ||
1709 | #ifdef JEWELS_SCROLLWHEEL | ||
1710 | case JEWELS_PREV: | ||
1711 | case (JEWELS_PREV|BUTTON_REPEAT): | ||
1712 | #endif | ||
1713 | case JEWELS_UP: | ||
1714 | case (JEWELS_UP|BUTTON_REPEAT): | ||
1715 | cmd = MCMD_PREV; | ||
1716 | break; | ||
1717 | |||
1718 | #ifdef JEWELS_SCROLLWHEEL | ||
1719 | case JEWELS_NEXT: | ||
1720 | case (JEWELS_NEXT|BUTTON_REPEAT): | ||
1721 | #endif | ||
1722 | case JEWELS_DOWN: | ||
1723 | case (JEWELS_DOWN|BUTTON_REPEAT): | ||
1724 | cmd = MCMD_NEXT; | ||
1725 | break; | ||
1726 | |||
1727 | case JEWELS_SELECT: | ||
1728 | case JEWELS_RIGHT: | ||
1729 | cmd = MCMD_SELECT; | ||
1730 | break; | ||
1731 | |||
1732 | #ifdef JEWELS_CANCEL | ||
1733 | #ifdef JEWELS_RC_CANCEL | ||
1734 | case JEWELS_RC_CANCEL: | ||
1735 | #endif | ||
1736 | case JEWELS_CANCEL: | ||
1737 | return BJ_QUIT; | 1578 | return BJ_QUIT; |
1738 | #endif | 1579 | |
1580 | case MENU_ATTACHED_USB: | ||
1581 | jewels_callback(bj); | ||
1582 | return BJ_USB; | ||
1739 | 1583 | ||
1740 | default: | 1584 | default: |
1741 | if(rb->default_event_handler_ex(button, jewels_callback, | 1585 | return BJ_QUIT; |
1742 | (void*) bj) == SYS_USB_CONNECTED) | ||
1743 | return BJ_USB; | ||
1744 | break; | ||
1745 | } | 1586 | } |
1746 | } | 1587 | } |
1747 | 1588 | ||
@@ -1771,162 +1612,142 @@ static int jewels_main(struct game_context* bj) { | |||
1771 | /********************** | 1612 | /********************** |
1772 | * play * | 1613 | * play * |
1773 | **********************/ | 1614 | **********************/ |
1615 | MENUITEM_STRINGLIST(ingame_menu,"Menu",NULL, | ||
1616 | "Audio Playback", "Resume Game", | ||
1617 | "Save Game", "End Game", "Exit Jewels"); | ||
1618 | |||
1619 | selected = false; | ||
1774 | while(true) { | 1620 | while(true) { |
1775 | int no_movesavail = false; | 1621 | bool no_movesavail = false; |
1776 | |||
1777 | if(!inmenu) { | ||
1778 | /* refresh the board */ | ||
1779 | jewels_drawboard(bj); | ||
1780 | |||
1781 | /* display the cursor */ | ||
1782 | if(selected) { | ||
1783 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | ||
1784 | rb->lcd_fillrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1785 | TILE_WIDTH, TILE_HEIGHT); | ||
1786 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
1787 | } else { | ||
1788 | rb->lcd_drawrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1789 | TILE_WIDTH, TILE_HEIGHT); | ||
1790 | } | ||
1791 | rb->lcd_update_rect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1792 | TILE_WIDTH, TILE_HEIGHT); | ||
1793 | } else { | ||
1794 | res = jewels_showmenu(&bjmenu[1], cmd); | ||
1795 | cmd = MCMD_NONE; | ||
1796 | switch(res) { | ||
1797 | case MRES_RESUME: | ||
1798 | inmenu = false; | ||
1799 | selected = false; | ||
1800 | continue; | ||
1801 | 1622 | ||
1802 | case MRES_PLAYBACK: | 1623 | while(inmenu) { |
1624 | switch (rb->do_menu(&ingame_menu, NULL, vp, true)) { | ||
1625 | case 0: | ||
1803 | playback_control(NULL); | 1626 | playback_control(NULL); |
1804 | rb->lcd_setfont(FONT_SYSFIXED); | ||
1805 | inmenu = false; | 1627 | inmenu = false; |
1806 | selected = false; | ||
1807 | break; | 1628 | break; |
1808 | 1629 | ||
1809 | case MRES_SAVE: | 1630 | case 1: |
1631 | inmenu = false; | ||
1632 | break; | ||
1633 | |||
1634 | case 2: | ||
1810 | rb->splash(HZ, "Saving game..."); | 1635 | rb->splash(HZ, "Saving game..."); |
1811 | jewels_savegame(bj); | 1636 | jewels_savegame(bj); |
1812 | return BJ_END; | 1637 | return BJ_END; |
1813 | 1638 | ||
1814 | case MRES_QUIT: | 1639 | case 3: |
1815 | return BJ_END; | 1640 | return BJ_END; |
1816 | 1641 | ||
1817 | case MRES_EXIT: | 1642 | case 4: |
1818 | return BJ_QUIT_FROM_GAME; | 1643 | return BJ_QUIT_FROM_GAME; |
1819 | 1644 | ||
1645 | case MENU_ATTACHED_USB: | ||
1646 | jewels_callback(bj); | ||
1647 | return BJ_USB; | ||
1648 | |||
1820 | default: | 1649 | default: |
1650 | inmenu = false; | ||
1821 | break; | 1651 | break; |
1822 | } | 1652 | } |
1823 | } | 1653 | } |
1824 | 1654 | ||
1655 | /* refresh the board */ | ||
1656 | jewels_drawboard(bj); | ||
1657 | |||
1658 | /* display the cursor */ | ||
1659 | if(selected) { | ||
1660 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | ||
1661 | rb->lcd_fillrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1662 | TILE_WIDTH, TILE_HEIGHT); | ||
1663 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
1664 | } else { | ||
1665 | rb->lcd_drawrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1666 | TILE_WIDTH, TILE_HEIGHT); | ||
1667 | } | ||
1668 | rb->lcd_update_rect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS, | ||
1669 | TILE_WIDTH, TILE_HEIGHT); | ||
1670 | |||
1825 | /* handle game button presses */ | 1671 | /* handle game button presses */ |
1826 | rb->yield(); | 1672 | rb->yield(); |
1827 | button = rb->button_get(true); | 1673 | button = rb->button_get(true); |
1828 | switch(button){ | 1674 | switch(button){ |
1829 | case JEWELS_LEFT: /* move cursor left */ | 1675 | case JEWELS_LEFT: /* move cursor left */ |
1830 | case (JEWELS_LEFT|BUTTON_REPEAT): | 1676 | case (JEWELS_LEFT|BUTTON_REPEAT): |
1831 | if(!inmenu) { | 1677 | if(selected) { |
1832 | if(selected) { | 1678 | bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT); |
1833 | bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT); | 1679 | selected = false; |
1834 | selected = false; | 1680 | if (!jewels_movesavail(bj)) no_movesavail = true; |
1835 | if (!jewels_movesavail(bj)) no_movesavail = true; | 1681 | } else { |
1836 | } else { | 1682 | x = (x+BJ_WIDTH-1)%BJ_WIDTH; |
1837 | x = (x+BJ_WIDTH-1)%BJ_WIDTH; | ||
1838 | } | ||
1839 | } | 1683 | } |
1840 | break; | 1684 | break; |
1841 | 1685 | ||
1842 | case JEWELS_RIGHT: /* move cursor right */ | 1686 | case JEWELS_RIGHT: /* move cursor right */ |
1843 | case (JEWELS_RIGHT|BUTTON_REPEAT): | 1687 | case (JEWELS_RIGHT|BUTTON_REPEAT): |
1844 | if(!inmenu) { | 1688 | if(selected) { |
1845 | if(selected) { | 1689 | bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT); |
1846 | bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT); | 1690 | selected = false; |
1847 | selected = false; | 1691 | if (!jewels_movesavail(bj)) no_movesavail = true; |
1848 | if (!jewels_movesavail(bj)) no_movesavail = true; | ||
1849 | } else { | ||
1850 | x = (x+1)%BJ_WIDTH; | ||
1851 | } | ||
1852 | } else { | 1692 | } else { |
1853 | cmd = MCMD_SELECT; | 1693 | x = (x+1)%BJ_WIDTH; |
1854 | } | 1694 | } |
1855 | break; | 1695 | break; |
1856 | 1696 | ||
1857 | case JEWELS_DOWN: /* move cursor down */ | 1697 | case JEWELS_DOWN: /* move cursor down */ |
1858 | case (JEWELS_DOWN|BUTTON_REPEAT): | 1698 | case (JEWELS_DOWN|BUTTON_REPEAT): |
1859 | if(!inmenu) { | 1699 | if(selected) { |
1860 | if(selected) { | 1700 | bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN); |
1861 | bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN); | 1701 | selected = false; |
1862 | selected = false; | 1702 | if (!jewels_movesavail(bj)) no_movesavail = true; |
1863 | if (!jewels_movesavail(bj)) no_movesavail = true; | ||
1864 | } else { | ||
1865 | y = (y+1)%(BJ_HEIGHT-1); | ||
1866 | } | ||
1867 | } else { | 1703 | } else { |
1868 | cmd = MCMD_NEXT; | 1704 | y = (y+1)%(BJ_HEIGHT-1); |
1869 | } | 1705 | } |
1870 | break; | 1706 | break; |
1871 | 1707 | ||
1872 | case JEWELS_UP: /* move cursor up */ | 1708 | case JEWELS_UP: /* move cursor up */ |
1873 | case (JEWELS_UP|BUTTON_REPEAT): | 1709 | case (JEWELS_UP|BUTTON_REPEAT): |
1874 | if(!inmenu) { | 1710 | if(selected) { |
1875 | if(selected) { | 1711 | bj->score += jewels_swapjewels(bj, x, y, SWAP_UP); |
1876 | bj->score += jewels_swapjewels(bj, x, y, SWAP_UP); | 1712 | selected = false; |
1877 | selected = false; | 1713 | if (!jewels_movesavail(bj)) no_movesavail = true; |
1878 | if (!jewels_movesavail(bj)) no_movesavail = true; | ||
1879 | } else { | ||
1880 | y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1); | ||
1881 | } | ||
1882 | } else { | 1714 | } else { |
1883 | cmd = MCMD_PREV; | 1715 | y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1); |
1884 | } | 1716 | } |
1885 | break; | 1717 | break; |
1886 | 1718 | ||
1887 | #ifdef JEWELS_SCROLLWHEEL | 1719 | #ifdef JEWELS_SCROLLWHEEL |
1888 | case JEWELS_PREV: /* scroll backwards */ | 1720 | case JEWELS_PREV: /* scroll backwards */ |
1889 | case (JEWELS_PREV|BUTTON_REPEAT): | 1721 | case (JEWELS_PREV|BUTTON_REPEAT): |
1890 | if(!inmenu) { | 1722 | if(!selected) { |
1891 | if(!selected) { | 1723 | if(x == 0) { |
1892 | if(x == 0) { | 1724 | y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1); |
1893 | y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1); | ||
1894 | } | ||
1895 | x = (x+BJ_WIDTH-1)%BJ_WIDTH; | ||
1896 | } | 1725 | } |
1897 | } else { | 1726 | x = (x+BJ_WIDTH-1)%BJ_WIDTH; |
1898 | cmd = MCMD_PREV; | ||
1899 | } | 1727 | } |
1900 | break; | 1728 | break; |
1901 | 1729 | ||
1902 | case JEWELS_NEXT: /* scroll forwards */ | 1730 | case JEWELS_NEXT: /* scroll forwards */ |
1903 | case (JEWELS_NEXT|BUTTON_REPEAT): | 1731 | case (JEWELS_NEXT|BUTTON_REPEAT): |
1904 | if(!inmenu) { | 1732 | if(!selected) { |
1905 | if(!selected) { | 1733 | if(x == BJ_WIDTH-1) { |
1906 | if(x == BJ_WIDTH-1) { | 1734 | y = (y+1)%(BJ_HEIGHT-1); |
1907 | y = (y+1)%(BJ_HEIGHT-1); | ||
1908 | } | ||
1909 | x = (x+1)%BJ_WIDTH; | ||
1910 | } | 1735 | } |
1911 | } else { | 1736 | x = (x+1)%BJ_WIDTH; |
1912 | cmd = MCMD_NEXT; | ||
1913 | } | 1737 | } |
1914 | break; | 1738 | break; |
1915 | #endif | 1739 | #endif |
1916 | 1740 | ||
1917 | case JEWELS_SELECT: /* toggle selected */ | 1741 | case JEWELS_SELECT: /* toggle selected */ |
1918 | if(!inmenu) { | 1742 | selected = !selected; |
1919 | selected = !selected; | ||
1920 | } else { | ||
1921 | cmd = MCMD_SELECT; | ||
1922 | } | ||
1923 | break; | 1743 | break; |
1924 | 1744 | ||
1925 | #ifdef JEWELS_MENU | 1745 | #ifdef JEWELS_MENU |
1926 | case JEWELS_MENU: | 1746 | case JEWELS_MENU: |
1927 | #endif | 1747 | #endif |
1928 | case (JEWELS_SELECT|BUTTON_REPEAT): /* show menu */ | 1748 | case (JEWELS_SELECT|BUTTON_REPEAT): /* show menu */ |
1929 | if(!inmenu) inmenu = true; | 1749 | inmenu = true; |
1750 | selected = false; | ||
1930 | break; | 1751 | break; |
1931 | 1752 | ||
1932 | #ifdef JEWELS_CANCEL | 1753 | #ifdef JEWELS_CANCEL |
diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index 5f9999ac3e..fc98834a7d 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include "plugin.h" | 28 | #include "plugin.h" |
29 | #include <lib/playback_control.h> | 29 | #include <lib/playback_control.h> |
30 | #include <lib/oldmenuapi.h> | ||
31 | #include <lib/helper.h> | 30 | #include <lib/helper.h> |
32 | #include <lib/configfile.h> | 31 | #include <lib/configfile.h> |
33 | 32 | ||
@@ -323,17 +322,16 @@ bool set_option_dithering(void) | |||
323 | return false; | 322 | return false; |
324 | } | 323 | } |
325 | 324 | ||
325 | MENUITEM_FUNCTION(grayscale_item, 0, "Greyscale", | ||
326 | set_option_grayscale, NULL, NULL, Icon_NOICON); | ||
327 | MENUITEM_FUNCTION(dithering_item, 0, "Dithering", | ||
328 | set_option_dithering, NULL, NULL, Icon_NOICON); | ||
329 | MAKE_MENU(display_menu, "Display Options", NULL, Icon_NOICON, | ||
330 | &grayscale_item, &dithering_item); | ||
331 | |||
326 | static void display_options(void) | 332 | static void display_options(void) |
327 | { | 333 | { |
328 | static const struct menu_item items[] = { | 334 | rb->do_menu(&display_menu, NULL, NULL, false); |
329 | { "Greyscale", set_option_grayscale }, | ||
330 | { "Dithering", set_option_dithering }, | ||
331 | }; | ||
332 | |||
333 | int m = menu_init(items, ARRAYLEN(items), | ||
334 | NULL, NULL, NULL, NULL); | ||
335 | menu_run(m); | ||
336 | menu_exit(m); | ||
337 | } | 335 | } |
338 | #endif /* HAVE_LCD_COLOR */ | 336 | #endif /* HAVE_LCD_COLOR */ |
339 | 337 | ||
@@ -349,12 +347,11 @@ int show_menu(void) /* return 1 to quit */ | |||
349 | rb->lcd_set_background(LCD_WHITE); | 347 | rb->lcd_set_background(LCD_WHITE); |
350 | #endif | 348 | #endif |
351 | #endif | 349 | #endif |
352 | int m; | ||
353 | int result; | 350 | int result; |
354 | 351 | ||
355 | enum menu_id | 352 | enum menu_id |
356 | { | 353 | { |
357 | MIID_QUIT = 0, | 354 | MIID_RETURN = 0, |
358 | MIID_TOGGLE_SS_MODE, | 355 | MIID_TOGGLE_SS_MODE, |
359 | MIID_CHANGE_SS_MODE, | 356 | MIID_CHANGE_SS_MODE, |
360 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 357 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM |
@@ -363,42 +360,30 @@ int show_menu(void) /* return 1 to quit */ | |||
363 | #ifdef HAVE_LCD_COLOR | 360 | #ifdef HAVE_LCD_COLOR |
364 | MIID_DISPLAY_OPTIONS, | 361 | MIID_DISPLAY_OPTIONS, |
365 | #endif | 362 | #endif |
366 | MIID_RETURN, | 363 | MIID_QUIT, |
367 | }; | 364 | }; |
368 | 365 | ||
369 | static const struct menu_item items[] = { | 366 | MENUITEM_STRINGLIST(menu, "Jpeg Menu", NULL, |
370 | [MIID_QUIT] = | 367 | "Return", "Toggle Slideshow Mode", |
371 | { "Quit", NULL }, | 368 | "Change Slideshow Time", |
372 | [MIID_TOGGLE_SS_MODE] = | ||
373 | { "Toggle Slideshow Mode", NULL }, | ||
374 | [MIID_CHANGE_SS_MODE] = | ||
375 | { "Change Slideshow Time", NULL }, | ||
376 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM | 369 | #if PLUGIN_BUFFER_SIZE >= MIN_MEM |
377 | [MIID_SHOW_PLAYBACK_MENU] = | 370 | "Show Playback Menu", |
378 | { "Show Playback Menu", NULL }, | ||
379 | #endif | 371 | #endif |
380 | #ifdef HAVE_LCD_COLOR | 372 | #ifdef HAVE_LCD_COLOR |
381 | [MIID_DISPLAY_OPTIONS] = | 373 | "Display Options", |
382 | { "Display Options", NULL }, | ||
383 | #endif | 374 | #endif |
384 | [MIID_RETURN] = | 375 | "Quit"); |
385 | { "Return", NULL }, | ||
386 | }; | ||
387 | 376 | ||
388 | static const struct opt_items slideshow[2] = { | 377 | static const struct opt_items slideshow[2] = { |
389 | { "Disable", -1 }, | 378 | { "Disable", -1 }, |
390 | { "Enable", -1 }, | 379 | { "Enable", -1 }, |
391 | }; | 380 | }; |
392 | 381 | ||
393 | m = menu_init(items, sizeof(items) / sizeof(*items), | 382 | result=rb->do_menu(&menu, NULL, NULL, false); |
394 | NULL, NULL, NULL, NULL); | ||
395 | result=menu_show(m); | ||
396 | 383 | ||
397 | switch (result) | 384 | switch (result) |
398 | { | 385 | { |
399 | case MIID_QUIT: | 386 | case MIID_RETURN: |
400 | menu_exit(m); | ||
401 | return 1; | ||
402 | break; | 387 | break; |
403 | case MIID_TOGGLE_SS_MODE: | 388 | case MIID_TOGGLE_SS_MODE: |
404 | rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, | 389 | rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, |
@@ -427,7 +412,8 @@ int show_menu(void) /* return 1 to quit */ | |||
427 | display_options(); | 412 | display_options(); |
428 | break; | 413 | break; |
429 | #endif | 414 | #endif |
430 | case MIID_RETURN: | 415 | case MIID_QUIT: |
416 | return 1; | ||
431 | break; | 417 | break; |
432 | } | 418 | } |
433 | 419 | ||
@@ -456,7 +442,6 @@ int show_menu(void) /* return 1 to quit */ | |||
456 | rb->lcd_set_background(LCD_BLACK); | 442 | rb->lcd_set_background(LCD_BLACK); |
457 | #endif | 443 | #endif |
458 | rb->lcd_clear_display(); | 444 | rb->lcd_clear_display(); |
459 | menu_exit(m); | ||
460 | return 0; | 445 | return 0; |
461 | } | 446 | } |
462 | 447 | ||
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 5a6abc7848..7211109271 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -1,6 +1,5 @@ | |||
1 | gcc-support.c | 1 | gcc-support.c |
2 | jhash.c | 2 | jhash.c |
3 | oldmenuapi.c | ||
4 | configfile.c | 3 | configfile.c |
5 | fixedpoint.c | 4 | fixedpoint.c |
6 | playback_control.c | 5 | playback_control.c |
diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c deleted file mode 100644 index f14edabd38..0000000000 --- a/apps/plugins/lib/oldmenuapi.c +++ /dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Robert E. Hak | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | /* | ||
22 | 2005 Kevin Ferrare : | ||
23 | - Multi screen support | ||
24 | - Rewrote/removed a lot of code now useless with the new gui API | ||
25 | */ | ||
26 | #include <stdbool.h> | ||
27 | #include <stdlib.h> | ||
28 | |||
29 | #include "plugin.h" | ||
30 | #include "oldmenuapi.h" | ||
31 | |||
32 | struct menu { | ||
33 | struct menu_item* items; | ||
34 | int (*callback)(int, int); | ||
35 | struct gui_synclist synclist; | ||
36 | }; | ||
37 | |||
38 | #define MAX_MENUS 6 | ||
39 | |||
40 | static struct menu menus[MAX_MENUS]; | ||
41 | static bool inuse[MAX_MENUS] = { false }; | ||
42 | |||
43 | static char * menu_get_itemname(int selected_item, void * data, | ||
44 | char *buffer, size_t buffer_len) | ||
45 | { | ||
46 | (void)buffer; (void)buffer_len; | ||
47 | struct menu *local_menus=(struct menu *)data; | ||
48 | return(local_menus->items[selected_item].desc); | ||
49 | } | ||
50 | |||
51 | static int menu_find_free(void) | ||
52 | { | ||
53 | int i; | ||
54 | /* Tries to find an unused slot to put the new menu */ | ||
55 | for ( i=0; i<MAX_MENUS; i++ ) { | ||
56 | if ( !inuse[i] ) { | ||
57 | inuse[i] = true; | ||
58 | break; | ||
59 | } | ||
60 | } | ||
61 | if ( i == MAX_MENUS ) { | ||
62 | DEBUGF("Out of menus!\n"); | ||
63 | return -1; | ||
64 | } | ||
65 | return(i); | ||
66 | } | ||
67 | |||
68 | int menu_init(const struct menu_item* mitems, | ||
69 | int count, int (*callback)(int, int), | ||
70 | const char *button1, const char *button2, const char *button3) | ||
71 | { | ||
72 | int menu=menu_find_free(); | ||
73 | if(menu==-1)/* Out of menus */ | ||
74 | return -1; | ||
75 | menus[menu].items = (struct menu_item*)mitems; /* de-const */ | ||
76 | rb->gui_synclist_init(&(menus[menu].synclist), | ||
77 | &menu_get_itemname, &menus[menu], false, 1, NULL); | ||
78 | rb->gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL); | ||
79 | rb->gui_synclist_set_nb_items(&(menus[menu].synclist), count); | ||
80 | menus[menu].callback = callback; | ||
81 | (void)button1; | ||
82 | (void)button2; | ||
83 | (void)button3; | ||
84 | return menu; | ||
85 | } | ||
86 | |||
87 | void menu_exit(int m) | ||
88 | { | ||
89 | inuse[m] = false; | ||
90 | } | ||
91 | |||
92 | int menu_show(int m) | ||
93 | { | ||
94 | bool exit = false; | ||
95 | int key; | ||
96 | |||
97 | int bars = rb->viewportmanager_set_statusbar(VP_SB_ALLSCREENS); | ||
98 | rb->gui_synclist_draw(&(menus[m].synclist)); | ||
99 | while (!exit) { | ||
100 | key = rb->get_action(CONTEXT_MAINMENU,HZ/2); | ||
101 | /* | ||
102 | * "short-circuit" the default keypresses by running the | ||
103 | * callback function | ||
104 | * The callback may return a new key value, often this will be | ||
105 | * BUTTON_NONE or the same key value, but it's perfectly legal | ||
106 | * to "simulate" key presses by returning another value. | ||
107 | */ | ||
108 | if( menus[m].callback != NULL ) | ||
109 | key = menus[m].callback(key, m); | ||
110 | rb->gui_synclist_do_button(&(menus[m].synclist), &key,LIST_WRAP_UNLESS_HELD); | ||
111 | switch( key ) { | ||
112 | case ACTION_STD_OK: | ||
113 | return rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); | ||
114 | |||
115 | case ACTION_STD_CANCEL: | ||
116 | case ACTION_STD_MENU: | ||
117 | case SYS_POWEROFF: | ||
118 | exit = true; | ||
119 | break; | ||
120 | |||
121 | default: | ||
122 | if(rb->default_event_handler(key) == SYS_USB_CONNECTED) | ||
123 | return MENU_ATTACHED_USB; | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | rb->viewportmanager_set_statusbar(bars); | ||
128 | return MENU_SELECTED_EXIT; | ||
129 | } | ||
130 | |||
131 | |||
132 | bool menu_run(int m) | ||
133 | { | ||
134 | int selected; | ||
135 | while (1) { | ||
136 | switch (selected=menu_show(m)) | ||
137 | { | ||
138 | case MENU_SELECTED_EXIT: | ||
139 | return false; | ||
140 | |||
141 | case MENU_ATTACHED_USB: | ||
142 | return true; | ||
143 | |||
144 | default: | ||
145 | { | ||
146 | if (menus[m].items[selected].function && | ||
147 | menus[m].items[selected].function()) | ||
148 | return true; | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | return false; | ||
153 | } | ||
154 | |||
155 | /* | ||
156 | * Property function - return the current cursor for "menu" | ||
157 | */ | ||
158 | |||
159 | int menu_cursor(int menu) | ||
160 | { | ||
161 | return rb->gui_synclist_get_sel_pos(&(menus[menu].synclist)); | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * Property function - return the "menu" description at "position" | ||
166 | */ | ||
167 | |||
168 | char* menu_description(int menu, int position) | ||
169 | { | ||
170 | return menus[menu].items[position].desc; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Delete the element "position" from the menu items in "menu" | ||
175 | */ | ||
176 | |||
177 | void menu_delete(int menu, int position) | ||
178 | { | ||
179 | int i; | ||
180 | int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
181 | /* copy the menu item from the one below */ | ||
182 | for( i = position; i < nb_items - 1; i++) | ||
183 | menus[menu].items[i] = menus[menu].items[i + 1]; | ||
184 | |||
185 | rb->gui_synclist_del_item(&(menus[menu].synclist)); | ||
186 | } | ||
187 | |||
188 | void menu_insert(int menu, int position, char *desc, bool (*function) (void)) | ||
189 | { | ||
190 | int i; | ||
191 | int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
192 | if(position < 0) | ||
193 | position = nb_items; | ||
194 | |||
195 | /* Move the items below one position forward */ | ||
196 | for( i = nb_items; i > position; i--) | ||
197 | menus[menu].items[i] = menus[menu].items[i - 1]; | ||
198 | |||
199 | /* Update the current item */ | ||
200 | menus[menu].items[position].desc = (unsigned char *)desc; | ||
201 | menus[menu].items[position].function = function; | ||
202 | rb->gui_synclist_add_item(&(menus[menu].synclist)); | ||
203 | } | ||
204 | |||
205 | /* | ||
206 | * Property function - return the "count" of menu items in "menu" | ||
207 | */ | ||
208 | |||
209 | int menu_count(int menu) | ||
210 | { | ||
211 | return rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
212 | } | ||
213 | |||
214 | /* | ||
215 | * Allows to set the cursor position. Doesn't redraw by itself. | ||
216 | */ | ||
217 | |||
218 | void menu_set_cursor(int menu, int position) | ||
219 | { | ||
220 | rb->gui_synclist_select_item(&(menus[menu].synclist), position); | ||
221 | } | ||
222 | #if 0 | ||
223 | void menu_talk_selected(int m) | ||
224 | { | ||
225 | if(rb->global_settings->talk_menu) | ||
226 | { | ||
227 | int selected=rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); | ||
228 | int voice_id = P2ID(menus[m].items[selected].desc); | ||
229 | if (voice_id >= 0) /* valid ID given? */ | ||
230 | talk_id(voice_id, false); /* say it */ | ||
231 | } | ||
232 | } | ||
233 | #endif | ||
234 | void menu_draw(int m) | ||
235 | { | ||
236 | rb->gui_synclist_draw(&(menus[m].synclist)); | ||
237 | } | ||
diff --git a/apps/plugins/lib/oldmenuapi.h b/apps/plugins/lib/oldmenuapi.h deleted file mode 100644 index 7f877997cf..0000000000 --- a/apps/plugins/lib/oldmenuapi.h +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Robert E. Hak | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | /* This API is for existing plugins and shouldn't be used by new ones. | ||
24 | This provides a simpler menu system for plugins, but does not allow for | ||
25 | translatable or talkable strings in the menus. */ | ||
26 | #ifndef __OLDMENUAPI_H__ | ||
27 | #define __OLDMENUAPI_H__ | ||
28 | |||
29 | #include <stdbool.h> | ||
30 | |||
31 | struct menu_item { | ||
32 | unsigned char *desc; /* string or ID */ | ||
33 | bool (*function) (void); /* return true if USB was connected */ | ||
34 | }; | ||
35 | |||
36 | int menu_init(const struct menu_item* mitems, | ||
37 | int count, int (*callback)(int, int), | ||
38 | const char *button1, const char *button2, const char *button3); | ||
39 | void menu_exit(int menu); | ||
40 | |||
41 | void put_cursorxy(int x, int y, bool on); | ||
42 | |||
43 | /* Returns below define, or number of selected menu item*/ | ||
44 | int menu_show(int m); | ||
45 | |||
46 | bool menu_run(int menu); | ||
47 | int menu_cursor(int menu); | ||
48 | char* menu_description(int menu, int position); | ||
49 | void menu_delete(int menu, int position); | ||
50 | int menu_count(int menu); | ||
51 | bool menu_moveup(int menu); | ||
52 | bool menu_movedown(int menu); | ||
53 | void menu_draw(int menu); | ||
54 | void menu_insert(int menu, int position, char *desc, bool (*function) (void)); | ||
55 | void menu_set_cursor(int menu, int position); | ||
56 | void menu_talk_selected(int m); | ||
57 | |||
58 | #endif /* End __OLDMENUAPI_H__ */ | ||
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 8aea93b8f1..7ec1157615 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include "plugin.h" | 1 | #include "plugin.h" |
2 | #include "lib/helper.h" | 2 | #include "lib/helper.h" |
3 | #include "lib/configfile.h" | 3 | #include "lib/configfile.h" |
4 | #include "lib/oldmenuapi.h" | ||
5 | 4 | ||
6 | #include "mpegplayer.h" | 5 | #include "mpegplayer.h" |
7 | #include "mpeg_settings.h" | 6 | #include "mpeg_settings.h" |
@@ -257,7 +256,7 @@ void mpeg_menu_sysevent_clear(void) | |||
257 | mpeg_menu_sysevent_id = 0; | 256 | mpeg_menu_sysevent_id = 0; |
258 | } | 257 | } |
259 | 258 | ||
260 | int mpeg_menu_sysevent_callback(int btn, int menu) | 259 | int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu) |
261 | { | 260 | { |
262 | switch (btn) | 261 | switch (btn) |
263 | { | 262 | { |
@@ -283,17 +282,6 @@ void mpeg_menu_sysevent_handle(void) | |||
283 | rb->default_event_handler(id); | 282 | rb->default_event_handler(id); |
284 | } | 283 | } |
285 | 284 | ||
286 | static void format_menu_item(struct menu_item *item, int bufsize, | ||
287 | const char *fmt, ...) | ||
288 | { | ||
289 | va_list ap; | ||
290 | va_start(ap, fmt); | ||
291 | |||
292 | rb->vsnprintf(item->desc, bufsize, fmt, ap); | ||
293 | |||
294 | va_end(ap); | ||
295 | } | ||
296 | |||
297 | static bool mpeg_set_option(const char* string, | 285 | static bool mpeg_set_option(const char* string, |
298 | void* variable, | 286 | void* variable, |
299 | enum optiontype type, | 287 | enum optiontype type, |
@@ -691,7 +679,7 @@ static int get_start_time(uint32_t duration) | |||
691 | button = tmo == TIMEOUT_BLOCK ? | 679 | button = tmo == TIMEOUT_BLOCK ? |
692 | rb->button_get(true) : rb->button_get_w_tmo(tmo); | 680 | rb->button_get(true) : rb->button_get_w_tmo(tmo); |
693 | 681 | ||
694 | button = mpeg_menu_sysevent_callback(button, -1); | 682 | button = mpeg_menu_sysevent_callback(button, NULL); |
695 | 683 | ||
696 | switch (button) | 684 | switch (button) |
697 | { | 685 | { |
@@ -822,43 +810,31 @@ static int get_start_time(uint32_t duration) | |||
822 | 810 | ||
823 | static int show_start_menu(uint32_t duration) | 811 | static int show_start_menu(uint32_t duration) |
824 | { | 812 | { |
825 | int menu_id; | 813 | int selected = 0; |
826 | int result = 0; | 814 | int result = 0; |
827 | bool menu_quit = false; | 815 | bool menu_quit = false; |
828 | 816 | ||
829 | /* add the resume time to the menu display */ | 817 | /* add the resume time to the menu display */ |
830 | char resume_str[32]; | 818 | static char resume_str[32]; |
831 | char hms_str[32]; | 819 | char hms_str[32]; |
832 | struct hms hms; | 820 | struct hms hms; |
833 | 821 | ||
834 | struct menu_item items[] = | 822 | MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback, |
835 | { | 823 | "Play from beginning", resume_str, |
836 | [MPEG_START_RESTART] = | 824 | "Set start time", "Settings", |
837 | { "Play from beginning", NULL }, | 825 | "Quit mpegplayer"); |
838 | [MPEG_START_RESUME] = | ||
839 | { resume_str, NULL }, | ||
840 | [MPEG_START_SEEK] = | ||
841 | { "Set start time", NULL }, | ||
842 | [MPEG_START_SETTINGS] = | ||
843 | { "Settings", NULL }, | ||
844 | [MPEG_START_QUIT] = | ||
845 | { "Quit mpegplayer", NULL }, | ||
846 | }; | ||
847 | 826 | ||
848 | ts_to_hms(settings.resume_time, &hms); | 827 | ts_to_hms(settings.resume_time, &hms); |
849 | hms_format(hms_str, sizeof(hms_str), &hms); | 828 | hms_format(hms_str, sizeof(hms_str), &hms); |
850 | format_menu_item(&items[MPEG_START_RESUME], sizeof (resume_str), | 829 | rb->snprintf(resume_str, sizeof (resume_str), |
851 | "Resume at: %s", hms_str); | 830 | "Resume at: %s", hms_str); |
852 | 831 | ||
853 | menu_id = menu_init(items, ARRAYLEN(items), | ||
854 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | ||
855 | |||
856 | rb->button_clear_queue(); | 832 | rb->button_clear_queue(); |
857 | 833 | ||
858 | while (!menu_quit) | 834 | while (!menu_quit) |
859 | { | 835 | { |
860 | mpeg_menu_sysevent_clear(); | 836 | mpeg_menu_sysevent_clear(); |
861 | result = menu_show(menu_id); | 837 | result = rb->do_menu(&menu, &selected, NULL, false); |
862 | 838 | ||
863 | switch (result) | 839 | switch (result) |
864 | { | 840 | { |
@@ -901,8 +877,6 @@ static int show_start_menu(uint32_t duration) | |||
901 | } | 877 | } |
902 | } | 878 | } |
903 | 879 | ||
904 | menu_exit(menu_id); | ||
905 | |||
906 | rb->lcd_clear_display(); | 880 | rb->lcd_clear_display(); |
907 | rb->lcd_update(); | 881 | rb->lcd_update(); |
908 | 882 | ||
@@ -934,36 +908,26 @@ int mpeg_start_menu(uint32_t duration) | |||
934 | /** MPEG Menu **/ | 908 | /** MPEG Menu **/ |
935 | static void display_options(void) | 909 | static void display_options(void) |
936 | { | 910 | { |
911 | int selected = 0; | ||
937 | int result; | 912 | int result; |
938 | int menu_id; | ||
939 | bool menu_quit = false; | 913 | bool menu_quit = false; |
940 | 914 | ||
941 | static const struct menu_item items[] = { | 915 | MENUITEM_STRINGLIST(menu, "Display Options", mpeg_menu_sysevent_callback, |
942 | #if MPEG_OPTION_DITHERING_ENABLED | 916 | #if MPEG_OPTION_DITHERING_ENABLED |
943 | [MPEG_OPTION_DITHERING] = | 917 | "Dithering", |
944 | { "Dithering", NULL }, | ||
945 | #endif | 918 | #endif |
946 | [MPEG_OPTION_DISPLAY_FPS] = | 919 | "Display FPS", "Limit FPS", "Skip frames", |
947 | { "Display FPS", NULL }, | ||
948 | [MPEG_OPTION_LIMIT_FPS] = | ||
949 | { "Limit FPS", NULL }, | ||
950 | [MPEG_OPTION_SKIP_FRAMES] = | ||
951 | { "Skip frames", NULL }, | ||
952 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | 920 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
953 | [MPEG_OPTION_BACKLIGHT_BRIGHTNESS] = | 921 | "Backlight brightness", |
954 | { "Backlight brightness", NULL }, | ||
955 | #endif | 922 | #endif |
956 | }; | 923 | ); |
957 | |||
958 | menu_id = menu_init(items, ARRAYLEN(items), | ||
959 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | ||
960 | 924 | ||
961 | rb->button_clear_queue(); | 925 | rb->button_clear_queue(); |
962 | 926 | ||
963 | while (!menu_quit) | 927 | while (!menu_quit) |
964 | { | 928 | { |
965 | mpeg_menu_sysevent_clear(); | 929 | mpeg_menu_sysevent_clear(); |
966 | result = menu_show(menu_id); | 930 | result = rb->do_menu(&menu, &selected, NULL, false); |
967 | 931 | ||
968 | switch (result) | 932 | switch (result) |
969 | { | 933 | { |
@@ -1014,38 +978,24 @@ static void display_options(void) | |||
1014 | if (mpeg_menu_sysevent() != 0) | 978 | if (mpeg_menu_sysevent() != 0) |
1015 | menu_quit = true; | 979 | menu_quit = true; |
1016 | } | 980 | } |
1017 | |||
1018 | menu_exit(menu_id); | ||
1019 | } | 981 | } |
1020 | 982 | ||
1021 | static void audio_options(void) | 983 | static void audio_options(void) |
1022 | { | 984 | { |
985 | int selected = 0; | ||
1023 | int result; | 986 | int result; |
1024 | int menu_id; | ||
1025 | bool menu_quit = false; | 987 | bool menu_quit = false; |
1026 | 988 | ||
1027 | static const struct menu_item items[] = { | 989 | MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_menu_sysevent_callback, |
1028 | [MPEG_AUDIO_TONE_CONTROLS] = | 990 | "Tone Controls", "Channel Modes", "Crossfeed", |
1029 | { "Tone Controls", NULL }, | 991 | "Equalizer", "Dithering"); |
1030 | [MPEG_AUDIO_CHANNEL_MODES] = | ||
1031 | { "Channel Modes", NULL }, | ||
1032 | [MPEG_AUDIO_CROSSFEED] = | ||
1033 | { "Crossfeed", NULL }, | ||
1034 | [MPEG_AUDIO_EQUALIZER] = | ||
1035 | { "Equalizer", NULL }, | ||
1036 | [MPEG_AUDIO_DITHERING] = | ||
1037 | { "Dithering", NULL }, | ||
1038 | }; | ||
1039 | |||
1040 | menu_id = menu_init(items, ARRAYLEN(items), | ||
1041 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | ||
1042 | 992 | ||
1043 | rb->button_clear_queue(); | 993 | rb->button_clear_queue(); |
1044 | 994 | ||
1045 | while (!menu_quit) | 995 | while (!menu_quit) |
1046 | { | 996 | { |
1047 | mpeg_menu_sysevent_clear(); | 997 | mpeg_menu_sysevent_clear(); |
1048 | result = menu_show(menu_id); | 998 | result = rb->do_menu(&menu, &selected, NULL, false); |
1049 | 999 | ||
1050 | switch (result) | 1000 | switch (result) |
1051 | { | 1001 | { |
@@ -1087,8 +1037,6 @@ static void audio_options(void) | |||
1087 | if (mpeg_menu_sysevent() != 0) | 1037 | if (mpeg_menu_sysevent() != 0) |
1088 | menu_quit = true; | 1038 | menu_quit = true; |
1089 | } | 1039 | } |
1090 | |||
1091 | menu_exit(menu_id); | ||
1092 | } | 1040 | } |
1093 | 1041 | ||
1094 | static void resume_options(void) | 1042 | static void resume_options(void) |
@@ -1121,32 +1069,23 @@ static void clear_resume_count(void) | |||
1121 | 1069 | ||
1122 | int mpeg_menu(unsigned flags) | 1070 | int mpeg_menu(unsigned flags) |
1123 | { | 1071 | { |
1124 | int menu_id; | 1072 | int selected = 0; |
1125 | int result; | 1073 | int result; |
1126 | bool menu_quit = false; | 1074 | bool menu_quit = false; |
1127 | int item_count; | 1075 | static char clear_str[32]; |
1128 | char clear_str[32]; | 1076 | |
1129 | 1077 | MENUITEM_STRINGLIST(menu_with_quit, "Mpegplayer Menu", | |
1130 | struct menu_item items[] = { | 1078 | mpeg_menu_sysevent_callback, |
1131 | [MPEG_MENU_DISPLAY_SETTINGS] = | 1079 | "Display Options", "Audio Options", |
1132 | { "Display Options", NULL }, | 1080 | "Resume Options", clear_str, "Quit mpegplayer"); |
1133 | [MPEG_MENU_AUDIO_SETTINGS] = | 1081 | MENUITEM_STRINGLIST(menu_without_quit, "Settings", |
1134 | { "Audio Options", NULL }, | 1082 | mpeg_menu_sysevent_callback, |
1135 | [MPEG_MENU_ENABLE_START_MENU] = | 1083 | "Display Options", "Audio Options", |
1136 | { "Resume Options", NULL }, | 1084 | "Resume Options", clear_str); |
1137 | [MPEG_MENU_CLEAR_RESUMES] = | 1085 | const struct menu_item_ex *menu = &menu_with_quit; |
1138 | { clear_str, NULL }, | ||
1139 | [MPEG_MENU_QUIT] = | ||
1140 | { "Quit mpegplayer", NULL }, | ||
1141 | }; | ||
1142 | |||
1143 | item_count = ARRAYLEN(items); | ||
1144 | 1086 | ||
1145 | if (flags & MPEG_MENU_HIDE_QUIT_ITEM) | 1087 | if (flags & MPEG_MENU_HIDE_QUIT_ITEM) |
1146 | item_count--; | 1088 | menu = &menu_without_quit; |
1147 | |||
1148 | menu_id = menu_init(items, item_count, | ||
1149 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | ||
1150 | 1089 | ||
1151 | rb->button_clear_queue(); | 1090 | rb->button_clear_queue(); |
1152 | 1091 | ||
@@ -1155,10 +1094,10 @@ int mpeg_menu(unsigned flags) | |||
1155 | mpeg_menu_sysevent_clear(); | 1094 | mpeg_menu_sysevent_clear(); |
1156 | 1095 | ||
1157 | /* Format and add resume option to the menu display */ | 1096 | /* Format and add resume option to the menu display */ |
1158 | format_menu_item(&items[MPEG_MENU_CLEAR_RESUMES], sizeof(clear_str), | 1097 | rb->snprintf(clear_str, sizeof(clear_str), |
1159 | "Clear all resumes: %u", settings.resume_count); | 1098 | "Clear all resumes: %u", settings.resume_count); |
1160 | 1099 | ||
1161 | result = menu_show(menu_id); | 1100 | result = rb->do_menu(menu, &selected, NULL, false); |
1162 | 1101 | ||
1163 | switch (result) | 1102 | switch (result) |
1164 | { | 1103 | { |
@@ -1191,8 +1130,6 @@ int mpeg_menu(unsigned flags) | |||
1191 | } | 1130 | } |
1192 | } | 1131 | } |
1193 | 1132 | ||
1194 | menu_exit(menu_id); | ||
1195 | |||
1196 | rb->lcd_clear_display(); | 1133 | rb->lcd_clear_display(); |
1197 | rb->lcd_update(); | 1134 | rb->lcd_update(); |
1198 | 1135 | ||
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h index fc43db036b..81a43fa2d7 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.h +++ b/apps/plugins/mpegplayer/mpeg_settings.h | |||
@@ -100,7 +100,7 @@ enum | |||
100 | int mpeg_menu(unsigned flags); | 100 | int mpeg_menu(unsigned flags); |
101 | void mpeg_menu_sysevent_clear(void); | 101 | void mpeg_menu_sysevent_clear(void); |
102 | long mpeg_menu_sysevent(void); | 102 | long mpeg_menu_sysevent(void); |
103 | int mpeg_menu_sysevent_callback(int btn, int menu); | 103 | int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu); |
104 | void mpeg_menu_sysevent_handle(void); | 104 | void mpeg_menu_sysevent_handle(void); |
105 | 105 | ||
106 | void init_settings(const char* filename); | 106 | void init_settings(const char* filename); |
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 0a12a78ceb..f71b7740f3 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -1498,7 +1498,7 @@ static void button_loop(void) | |||
1498 | mpeg_menu_sysevent_clear(); | 1498 | mpeg_menu_sysevent_clear(); |
1499 | button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL); | 1499 | button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL); |
1500 | 1500 | ||
1501 | button = mpeg_menu_sysevent_callback(button, -1); | 1501 | button = mpeg_menu_sysevent_callback(button, NULL); |
1502 | 1502 | ||
1503 | switch (button) | 1503 | switch (button) |
1504 | { | 1504 | { |
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index 560e185704..e7b92c38cf 100644 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "pacbox.h" | 29 | #include "pacbox.h" |
30 | #include "pacbox_lcd.h" | 30 | #include "pacbox_lcd.h" |
31 | #include "lib/configfile.h" | 31 | #include "lib/configfile.h" |
32 | #include "lib/oldmenuapi.h" | ||
33 | 32 | ||
34 | PLUGIN_HEADER | 33 | PLUGIN_HEADER |
35 | PLUGIN_IRAM_DECLARE | 34 | PLUGIN_IRAM_DECLARE |
@@ -138,7 +137,7 @@ static int settings_to_dip(struct pacman_settings settings) | |||
138 | 137 | ||
139 | static bool pacbox_menu(void) | 138 | static bool pacbox_menu(void) |
140 | { | 139 | { |
141 | int m; | 140 | int selected=0; |
142 | int result; | 141 | int result; |
143 | int menu_quit=0; | 142 | int menu_quit=0; |
144 | int new_setting; | 143 | int new_setting; |
@@ -173,23 +172,14 @@ static bool pacbox_menu(void) | |||
173 | { "Alternate", -1 }, | 172 | { "Alternate", -1 }, |
174 | }; | 173 | }; |
175 | 174 | ||
176 | static const struct menu_item items[] = { | 175 | MENUITEM_STRINGLIST(menu, "Pacbox Menu", NULL, |
177 | { "Difficulty", NULL }, | 176 | "Difficulty", "Pacmen Per Game", "Bonus Life", |
178 | { "Pacmen Per Game", NULL }, | 177 | "Ghost Names", "Display FPS", "Restart", "Quit"); |
179 | { "Bonus Life", NULL }, | ||
180 | { "Ghost Names", NULL }, | ||
181 | { "Display FPS", NULL }, | ||
182 | { "Restart", NULL }, | ||
183 | { "Quit", NULL }, | ||
184 | }; | ||
185 | |||
186 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
187 | NULL, NULL, NULL, NULL); | ||
188 | 178 | ||
189 | rb->button_clear_queue(); | 179 | rb->button_clear_queue(); |
190 | 180 | ||
191 | while (!menu_quit) { | 181 | while (!menu_quit) { |
192 | result=menu_show(m); | 182 | result=rb->do_menu(&menu, &selected, NULL, false); |
193 | 183 | ||
194 | switch(result) | 184 | switch(result) |
195 | { | 185 | { |
@@ -243,8 +233,6 @@ static bool pacbox_menu(void) | |||
243 | } | 233 | } |
244 | } | 234 | } |
245 | 235 | ||
246 | menu_exit(m); | ||
247 | |||
248 | if (need_restart) { | 236 | if (need_restart) { |
249 | init_PacmanMachine(settings_to_dip(settings)); | 237 | init_PacmanMachine(settings_to_dip(settings)); |
250 | } | 238 | } |
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 8d211aaa8f..d0a6a26800 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/oldmenuapi.h" | ||
23 | 22 | ||
24 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
25 | 24 | ||
@@ -321,15 +320,11 @@ int edit_list(void) | |||
321 | break; | 320 | break; |
322 | case ACTION_STD_CONTEXT: | 321 | case ACTION_STD_CONTEXT: |
323 | { | 322 | { |
324 | int m, len; | 323 | int len; |
325 | static const struct menu_item items[] = { | 324 | MENUITEM_STRINGLIST(menu, "Remove Menu", NULL, |
326 | { "Remove Folder", NULL }, | 325 | "Remove Folder", "Remove Folder Tree"); |
327 | { "Remove Folder Tree", NULL }, | 326 | |
328 | }; | 327 | switch (rb->do_menu(&menu, NULL, NULL, false)) |
329 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
330 | NULL, NULL, NULL, NULL); | ||
331 | |||
332 | switch (menu_show(m)) | ||
333 | { | 328 | { |
334 | case 0: | 329 | case 0: |
335 | list->folder[selection][0] = ' '; | 330 | list->folder[selection][0] = ' '; |
@@ -351,20 +346,14 @@ int edit_list(void) | |||
351 | } | 346 | } |
352 | break; | 347 | break; |
353 | } | 348 | } |
354 | menu_exit(m); | ||
355 | } | 349 | } |
356 | break; | 350 | break; |
357 | case ACTION_STD_CANCEL: | 351 | case ACTION_STD_CANCEL: |
358 | { | 352 | { |
359 | int m; | 353 | MENUITEM_STRINGLIST(menu, "Exit Menu", NULL, |
360 | static const struct menu_item items[] = { | 354 | "Save and Exit", "Ignore Changes and Exit"); |
361 | { "Save and Exit", NULL }, | 355 | |
362 | { "Ignore Changes and Exit", NULL }, | 356 | switch (rb->do_menu(&menu, NULL, NULL, false)) |
363 | }; | ||
364 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
365 | NULL, NULL, NULL, NULL); | ||
366 | |||
367 | switch (menu_show(m)) | ||
368 | { | 357 | { |
369 | case 0: | 358 | case 0: |
370 | save_list(); | 359 | save_list(); |
@@ -372,7 +361,6 @@ int edit_list(void) | |||
372 | exit = true; | 361 | exit = true; |
373 | ret = -2; | 362 | ret = -2; |
374 | } | 363 | } |
375 | menu_exit(m); | ||
376 | } | 364 | } |
377 | break; | 365 | break; |
378 | } | 366 | } |
@@ -474,19 +462,16 @@ int import_list_from_file_text(void) | |||
474 | 462 | ||
475 | int main_menu(void) | 463 | int main_menu(void) |
476 | { | 464 | { |
477 | int m; | ||
478 | bool exit = false; | 465 | bool exit = false; |
479 | static const struct menu_item items[] = { | 466 | |
480 | { "Generate Folder List", NULL }, | 467 | MENUITEM_STRINGLIST(menu, "Main Menu", NULL, |
481 | { "Edit Folder List", NULL }, | 468 | "Generate Folder List", |
482 | { "Export List To Textfile", NULL }, | 469 | "Edit Folder List", |
483 | { "Import List From Textfile", NULL }, | 470 | "Export List To Textfile", |
484 | { "Quit", NULL }, | 471 | "Import List From Textfile", |
485 | }; | 472 | "Quit"); |
486 | m = menu_init(items, sizeof(items) / sizeof(*items), | 473 | |
487 | NULL, NULL, NULL, NULL); | 474 | switch (rb->do_menu(&menu, NULL, NULL, false)) |
488 | |||
489 | switch (menu_show(m)) | ||
490 | { | 475 | { |
491 | case 0: /* generate */ | 476 | case 0: /* generate */ |
492 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 477 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -542,10 +527,8 @@ int main_menu(void) | |||
542 | rb->backlight_on(); | 527 | rb->backlight_on(); |
543 | break; | 528 | break; |
544 | case 4: | 529 | case 4: |
545 | menu_exit(m); | ||
546 | return 1; | 530 | return 1; |
547 | } | 531 | } |
548 | menu_exit(m); | ||
549 | return exit?1:0; | 532 | return exit?1:0; |
550 | } | 533 | } |
551 | 534 | ||
diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c index b6bbd5f3b1..2eb6f5bb79 100644 --- a/apps/plugins/reversi/reversi-gui.c +++ b/apps/plugins/reversi/reversi-gui.c | |||
@@ -47,7 +47,6 @@ further options: | |||
47 | #include "reversi-strategy.h" | 47 | #include "reversi-strategy.h" |
48 | #include "reversi-gui.h" | 48 | #include "reversi-gui.h" |
49 | 49 | ||
50 | #include "lib/oldmenuapi.h" | ||
51 | #include "lib/playback_control.h" | 50 | #include "lib/playback_control.h" |
52 | 51 | ||
53 | PLUGIN_HEADER | 52 | PLUGIN_HEADER |
@@ -375,23 +374,15 @@ static bool reversi_gui_choose_strategy( | |||
375 | 374 | ||
376 | /* Returns true iff USB ws connected while in the menu */ | 375 | /* Returns true iff USB ws connected while in the menu */ |
377 | static bool reversi_gui_menu(void) { | 376 | static bool reversi_gui_menu(void) { |
378 | int m, index, num_items, i; | 377 | int index, num_items, i; |
379 | int result; | 378 | int result; |
380 | 379 | ||
381 | static const struct menu_item items[] = { | 380 | MENUITEM_STRINGLIST(menu, "Reversi Menu", NULL, |
382 | { "Start new game", NULL }, | 381 | "Start new game", "Pass the move", |
383 | { "Pass the move", NULL }, | 382 | MENU_TEXT_STRAT_BLACK, MENU_TEXT_STRAT_WHITE, |
384 | { MENU_TEXT_STRAT_BLACK, NULL }, | 383 | MENU_TEXT_WRAP_MODE, "Playback Control", "Quit"); |
385 | { MENU_TEXT_STRAT_WHITE, NULL }, | ||
386 | { MENU_TEXT_WRAP_MODE, NULL }, | ||
387 | { "Playback Control", NULL }, | ||
388 | { "Quit", NULL }, | ||
389 | }; | ||
390 | 384 | ||
391 | m = menu_init(items, sizeof(items) / sizeof(*items), | 385 | result = rb->do_menu(&menu, NULL, NULL, false); |
392 | NULL, NULL, NULL, NULL); | ||
393 | |||
394 | result = menu_show(m); | ||
395 | 386 | ||
396 | switch (result) { | 387 | switch (result) { |
397 | case 0: /* Start a new game */ | 388 | case 0: /* Start a new game */ |
@@ -433,8 +424,6 @@ static bool reversi_gui_menu(void) { | |||
433 | break; | 424 | break; |
434 | } | 425 | } |
435 | 426 | ||
436 | menu_exit(m); | ||
437 | |||
438 | return (result == MENU_ATTACHED_USB); | 427 | return (result == MENU_ATTACHED_USB); |
439 | } | 428 | } |
440 | 429 | ||
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index d10e2b6e1a..9821ce9ba2 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include "rockmacros.h" | 8 | #include "rockmacros.h" |
9 | #include "mem.h" | 9 | #include "mem.h" |
10 | #include "save.h" | 10 | #include "save.h" |
11 | #include "lib/oldmenuapi.h" | ||
12 | #include "rtc-gb.h" | 11 | #include "rtc-gb.h" |
13 | #include "pcm.h" | 12 | #include "pcm.h" |
14 | 13 | ||
@@ -85,7 +84,7 @@ static void setupkeys(void) | |||
85 | */ | 84 | */ |
86 | int do_user_menu(void) { | 85 | int do_user_menu(void) { |
87 | bool done=false; | 86 | bool done=false; |
88 | int m, ret=0; | 87 | int selected=0, ret=0; |
89 | int result; | 88 | int result; |
90 | int time = 0; | 89 | int time = 0; |
91 | 90 | ||
@@ -97,20 +96,15 @@ int do_user_menu(void) { | |||
97 | while (rb->button_get(false) != BUTTON_NONE) | 96 | while (rb->button_get(false) != BUTTON_NONE) |
98 | rb->yield(); | 97 | rb->yield(); |
99 | 98 | ||
100 | static const struct menu_item items[] = { | 99 | MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL, |
101 | {"Load Game", NULL }, | 100 | "Load Game", "Save Game", |
102 | {"Save Game", NULL }, | 101 | "Options", "Quit"); |
103 | {"Options", NULL }, | ||
104 | {"Quit", NULL }, | ||
105 | }; | ||
106 | 102 | ||
107 | pcm_init(); | 103 | pcm_init(); |
108 | 104 | ||
109 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | ||
110 | |||
111 | while(!done) | 105 | while(!done) |
112 | { | 106 | { |
113 | result=menu_show(m); | 107 | result = rb->do_menu(&menu, &selected, NULL, false); |
114 | 108 | ||
115 | switch (result) | 109 | switch (result) |
116 | { | 110 | { |
@@ -133,8 +127,6 @@ int do_user_menu(void) { | |||
133 | } | 127 | } |
134 | } | 128 | } |
135 | 129 | ||
136 | menu_exit(m); | ||
137 | |||
138 | rb->lcd_setfont(0); /* Reset the font */ | 130 | rb->lcd_setfont(0); /* Reset the font */ |
139 | rb->lcd_clear_display(); /* Clear display for screen size changes */ | 131 | rb->lcd_clear_display(); /* Clear display for screen size changes */ |
140 | 132 | ||
@@ -288,50 +280,65 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) { | |||
288 | } | 280 | } |
289 | } | 281 | } |
290 | 282 | ||
283 | /* | ||
284 | * slot_get_name | ||
285 | */ | ||
286 | static char *slot_get_name(int selected_item, void * data, | ||
287 | char * buffer, size_t buffer_len) | ||
288 | { | ||
289 | char (*items)[20] = data; | ||
290 | (void) buffer; | ||
291 | (void) buffer_len; | ||
292 | return items[selected_item]; | ||
293 | } | ||
294 | |||
295 | /* | ||
296 | * list_action_callback | ||
297 | */ | ||
298 | static int list_action_callback(int action, struct gui_synclist *lists) | ||
299 | { | ||
300 | (void) lists; | ||
301 | if (action == ACTION_STD_OK) | ||
302 | return ACTION_STD_CANCEL; | ||
303 | return action; | ||
304 | } | ||
305 | |||
291 | /* | 306 | /* |
292 | * do_slot_menu - prompt the user for a load/save memory slot | 307 | * do_slot_menu - prompt the user for a load/save memory slot |
293 | */ | 308 | */ |
294 | static void do_slot_menu(bool is_load) { | 309 | static void do_slot_menu(bool is_load) { |
295 | bool done=false; | 310 | bool done=false; |
296 | 311 | char items[5][20]; | |
297 | char buf[5][20]; | ||
298 | |||
299 | int m; | ||
300 | int result; | 312 | int result; |
301 | int i; | 313 | int i; |
302 | |||
303 | struct menu_item items[] = { | ||
304 | { buf[0] , NULL }, | ||
305 | { buf[1] , NULL }, | ||
306 | { buf[2] , NULL }, | ||
307 | { buf[3] , NULL }, | ||
308 | { buf[4] , NULL }, | ||
309 | }; | ||
310 | |||
311 | int num_items = sizeof(items) / sizeof(*items); | 314 | int num_items = sizeof(items) / sizeof(*items); |
315 | struct simplelist_info info; | ||
312 | 316 | ||
313 | /* create menu items */ | 317 | /* create menu items */ |
314 | for (i = 0; i < num_items; i++) | 318 | for (i = 0; i < num_items; i++) |
315 | slot_info(buf[i], 20, i); | 319 | slot_info(items[i], 20, i); |
316 | 320 | ||
317 | m = menu_init(items, num_items, NULL, NULL, NULL, NULL); | 321 | rb->simplelist_info_init(&info, NULL, num_items, (void *)items); |
322 | info.get_name = slot_get_name; | ||
323 | info.action_callback = list_action_callback; | ||
318 | 324 | ||
319 | while(!done) | 325 | while(!done) |
320 | { | 326 | { |
321 | result=menu_show(m); | 327 | if(rb->simplelist_show_list(&info)) |
322 | 328 | break; | |
329 | |||
330 | result = info.selection; | ||
323 | if (result<num_items && result >= 0 ) | 331 | if (result<num_items && result >= 0 ) |
324 | done = do_slot(result, is_load); | 332 | done = do_slot(result, is_load); |
325 | else | 333 | else |
326 | done = true; | 334 | done = true; |
327 | } | 335 | } |
328 | menu_exit(m); | ||
329 | } | 336 | } |
330 | 337 | ||
331 | static void do_opt_menu(void) | 338 | static void do_opt_menu(void) |
332 | { | 339 | { |
333 | bool done=false; | 340 | bool done=false; |
334 | int m; | 341 | int selected=0; |
335 | int result; | 342 | int result; |
336 | 343 | ||
337 | static const struct opt_items onoff[2] = { | 344 | static const struct opt_items onoff[2] = { |
@@ -379,63 +386,54 @@ static void do_opt_menu(void) | |||
379 | }; | 386 | }; |
380 | #endif | 387 | #endif |
381 | 388 | ||
382 | static const struct menu_item items[] = { | 389 | MENUITEM_STRINGLIST(menu, "Options", NULL, |
383 | { "Max Frameskip", NULL }, | 390 | "Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)", |
384 | { "Sound" , NULL }, | ||
385 | { "Stats" , NULL }, | ||
386 | { "Set Keys (Buggy)", NULL }, | ||
387 | #ifdef HAVE_LCD_COLOR | 391 | #ifdef HAVE_LCD_COLOR |
388 | { "Screen Size" , NULL }, | 392 | "Screen Size", "Screen Rotate", "Set Palette", |
389 | { "Screen Rotate" , NULL }, | ||
390 | { "Set Palette" , NULL }, | ||
391 | #endif | 393 | #endif |
392 | }; | 394 | ); |
393 | |||
394 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | ||
395 | 395 | ||
396 | options.dirty=1; /* Assume that the settings have been changed */ | 396 | options.dirty=1; /* Assume that the settings have been changed */ |
397 | 397 | ||
398 | while(!done) | 398 | while(!done) |
399 | { | 399 | { |
400 | 400 | result = rb->do_menu(&menu, &selected, NULL, false); | |
401 | result=menu_show(m); | 401 | |
402 | |||
403 | switch (result) | 402 | switch (result) |
404 | { | 403 | { |
405 | case 0: /* Frameskip */ | 404 | case 0: /* Frameskip */ |
406 | rb->set_option(items[0].desc, &options.maxskip, INT, frameskip, | 405 | rb->set_option("Max Frameskip", &options.maxskip, INT, frameskip, |
407 | sizeof(frameskip)/sizeof(*frameskip), NULL ); | 406 | sizeof(frameskip)/sizeof(*frameskip), NULL ); |
408 | break; | 407 | break; |
409 | case 1: /* Sound */ | 408 | case 1: /* Sound */ |
410 | if(options.sound>1) options.sound=1; | 409 | if(options.sound>1) options.sound=1; |
411 | rb->set_option(items[1].desc, &options.sound, INT, onoff, 2, NULL ); | 410 | rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL ); |
412 | if(options.sound) sound_dirty(); | 411 | if(options.sound) sound_dirty(); |
413 | break; | 412 | break; |
414 | case 2: /* Stats */ | 413 | case 2: /* Stats */ |
415 | rb->set_option(items[2].desc, &options.showstats, INT, onoff, 2, NULL ); | 414 | rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL ); |
416 | break; | 415 | break; |
417 | case 3: /* Keys */ | 416 | case 3: /* Keys */ |
418 | setupkeys(); | 417 | setupkeys(); |
419 | break; | 418 | break; |
420 | #ifdef HAVE_LCD_COLOR | 419 | #ifdef HAVE_LCD_COLOR |
421 | case 4: /* Screen Size */ | 420 | case 4: /* Screen Size */ |
422 | rb->set_option(items[4].desc, &options.scaling, INT, scaling, | 421 | rb->set_option("Screen Size", &options.scaling, INT, scaling, |
423 | sizeof(scaling)/sizeof(*scaling), NULL ); | 422 | sizeof(scaling)/sizeof(*scaling), NULL ); |
424 | setvidmode(); | 423 | setvidmode(); |
425 | break; | 424 | break; |
426 | case 5: /* Screen rotate */ | 425 | case 5: /* Screen rotate */ |
427 | rb->set_option(items[5].desc, &options.rotate, INT, onoff, 2, NULL ); | 426 | rb->set_option("Screen Rotate", &options.rotate, INT, onoff, 2, NULL ); |
428 | setvidmode(); | 427 | setvidmode(); |
429 | break; | 428 | break; |
430 | case 6: /* Palette */ | 429 | case 6: /* Palette */ |
431 | rb->set_option(items[6].desc, &options.pal, INT, palette, 17, NULL ); | 430 | rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL ); |
432 | set_pal(); | 431 | set_pal(); |
433 | break; | 432 | break; |
434 | #endif | 433 | #endif |
435 | default: | 434 | default: |
436 | done=true; | 435 | done=true; |
437 | break; | 436 | break; |
438 | } | 437 | } |
439 | } | 438 | } |
440 | menu_exit(m); | ||
441 | } | 439 | } |
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index f92c616e07..5112931d9b 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -516,89 +516,46 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height, | |||
516 | /*********************************************************************** | 516 | /*********************************************************************** |
517 | * Menu handling | 517 | * Menu handling |
518 | ***********************************************************************/ | 518 | ***********************************************************************/ |
519 | struct menu_items | ||
520 | { | ||
521 | int value; | ||
522 | char label[16]; /* GRUIK ? */ | ||
523 | }; | ||
524 | |||
525 | #define MENU_ESC -1242 | ||
526 | enum { | 519 | enum { |
527 | /* Generic menu items */ | ||
528 | MENU_END = -42, MENU_TITLE = -12, | ||
529 | /* Main menu */ | 520 | /* Main menu */ |
530 | MAIN_MENU_RESUME, | 521 | MAIN_MENU_RESUME, |
531 | MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE, | 522 | MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE, |
532 | MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR, | 523 | MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR, |
533 | MAIN_MENU_GRID_SIZE, | 524 | MAIN_MENU_GRID_SIZE, |
534 | MAIN_MENU_EXIT, | 525 | MAIN_MENU_EXIT, |
526 | }; | ||
527 | enum { | ||
535 | /* Select action menu */ | 528 | /* Select action menu */ |
536 | SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT, | 529 | SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT, |
537 | SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90, | 530 | SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90, |
538 | SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270, | 531 | SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270, |
539 | SELECT_MENU_CANCEL, | 532 | SELECT_MENU_CANCEL, |
533 | }; | ||
534 | enum { | ||
540 | /* Text menu */ | 535 | /* Text menu */ |
541 | TEXT_MENU_TEXT, TEXT_MENU_FONT, | 536 | TEXT_MENU_TEXT, TEXT_MENU_FONT, |
542 | TEXT_MENU_PREVIEW, TEXT_MENU_APPLY, TEXT_MENU_CANCEL, | 537 | TEXT_MENU_PREVIEW, TEXT_MENU_APPLY, TEXT_MENU_CANCEL, |
543 | }; | 538 | }; |
544 | 539 | ||
545 | static struct menu_items main_menu[]= | 540 | MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL, |
546 | { { MENU_TITLE, "RockPaint" }, | 541 | "Resume", "New", "Load", "Save", |
547 | { MAIN_MENU_RESUME, "Resume" }, | 542 | "Brush Size", "Brush Speed", |
548 | { MAIN_MENU_NEW, "New" }, | 543 | "Choose Color", "Grid Size", "Exit"); |
549 | { MAIN_MENU_LOAD, "Load" }, | 544 | MENUITEM_STRINGLIST(size_menu, "Choose Size", NULL, |
550 | { MAIN_MENU_SAVE, "Save" }, | 545 | "1x", "2x","4x", "8x"); |
551 | { MAIN_MENU_BRUSH_SIZE, "Brush Size" }, | 546 | MENUITEM_STRINGLIST(speed_menu, "Choose Speed", NULL, |
552 | { MAIN_MENU_BRUSH_SPEED, "Brush Speed" }, | 547 | "1x", "2x","4x"); |
553 | { MAIN_MENU_COLOR, "Choose Color" }, | 548 | MENUITEM_STRINGLIST(gridsize_menu, "Grid Size", NULL, |
554 | { MAIN_MENU_GRID_SIZE, "Grid Size" }, | 549 | "No grid", "5px", "10px", "20px"); |
555 | { MAIN_MENU_EXIT, "Exit" }, | 550 | MENUITEM_STRINGLIST(select_menu, "Select...", NULL, |
556 | { MENU_END, "" } }; | 551 | "Cut", "Copy", "Invert", "Horizontal Flip" , |
557 | 552 | "Vertical Flip", "Rotate 90°", | |
558 | static struct menu_items size_menu[] = | 553 | "Rotate 180°", "Rotate 270°", "Cancel"); |
559 | { { MENU_TITLE, "Choose Size" }, | 554 | MENUITEM_STRINGLIST(text_menu, "Text", NULL, |
560 | { 1, "1x" }, | 555 | "Set Text", "Change Font", |
561 | { 2, "2x" }, | 556 | "Preview", "Apply", "Cancel"); |
562 | { 4, "4x" }, | 557 | static const int times_list[] = { 1, 2, 4, 8 }; |
563 | { 8, "8x" }, | 558 | static const int gridsize_list[] = { 0, 5, 10, 20 }; |
564 | { MENU_END, "" } }; | ||
565 | |||
566 | static struct menu_items speed_menu[] = | ||
567 | { { MENU_TITLE, "Choose Speed" }, | ||
568 | { 1, "1x" }, | ||
569 | { 2, "2x" }, | ||
570 | { 4, "4x" }, | ||
571 | { MENU_END, "" } }; | ||
572 | |||
573 | static struct menu_items gridsize_menu[] = | ||
574 | { { MENU_TITLE, "Grid Size" }, | ||
575 | { 0, "No grid" }, | ||
576 | { 5, "5px" }, | ||
577 | { 10, "10px" }, | ||
578 | { 20, "20px" }, | ||
579 | { MENU_END, "" } }; | ||
580 | |||
581 | static struct menu_items select_menu[] = | ||
582 | { { MENU_TITLE, "Select..." }, | ||
583 | { SELECT_MENU_CUT, "Cut" }, | ||
584 | { SELECT_MENU_COPY, "Copy" }, | ||
585 | { SELECT_MENU_INVERT, "Invert" }, | ||
586 | { SELECT_MENU_HFLIP, "Horizontal flip" }, | ||
587 | { SELECT_MENU_VFLIP, "Vertical flip" }, | ||
588 | // { SELECT_MENU_ROTATE90, "Rotate 90°" }, | ||
589 | { SELECT_MENU_ROTATE180, "Rotate 180°" }, | ||
590 | // { SELECT_MENU_ROTATE270, "Rotate 270°" }, | ||
591 | { SELECT_MENU_CANCEL, "Cancel" }, | ||
592 | { MENU_END, "" } }; | ||
593 | |||
594 | static struct menu_items text_menu[] = | ||
595 | { { MENU_TITLE, "Text" }, | ||
596 | { TEXT_MENU_TEXT, "Set text" }, | ||
597 | { TEXT_MENU_FONT, "Change font" }, | ||
598 | { TEXT_MENU_PREVIEW, "Preview" }, | ||
599 | { TEXT_MENU_APPLY, "Apply" }, | ||
600 | { TEXT_MENU_CANCEL, "Cancel" }, | ||
601 | { MENU_END, "" } }; | ||
602 | 559 | ||
603 | static int draw_window( int height, int width, | 560 | static int draw_window( int height, int width, |
604 | int *top, int *left, | 561 | int *top, int *left, |
@@ -624,143 +581,37 @@ static int draw_window( int height, int width, | |||
624 | return _top+fh+4; | 581 | return _top+fh+4; |
625 | } | 582 | } |
626 | 583 | ||
627 | static int menu_display( struct menu_items menu[], int prev_value ) | ||
628 | { | ||
629 | int i, | ||
630 | fh, /* font height */ | ||
631 | width, height, | ||
632 | a, b, | ||
633 | selection=1, | ||
634 | menu_length, | ||
635 | top, left; | ||
636 | int scroll = 0, onscreen = 0; | ||
637 | |||
638 | rb->lcd_getstringsize( menu[0].label, &width, &fh ); | ||
639 | for( i=1; menu[i].value != MENU_END; i++ ) | ||
640 | { | ||
641 | if( prev_value == menu[i].value ) | ||
642 | { | ||
643 | selection = i; | ||
644 | } | ||
645 | rb->lcd_getstringsize( menu[i].label, &a, &b ); | ||
646 | if( a > width ) width = a; | ||
647 | if( b > fh ) fh = b; | ||
648 | } | ||
649 | menu_length = i; | ||
650 | fh++; | ||
651 | width += 10; | ||
652 | |||
653 | height = menu_length * fh + 4 + 2 + 2; | ||
654 | if( height >= LCD_HEIGHT ) | ||
655 | { | ||
656 | scroll = 1; | ||
657 | onscreen = ( LCD_HEIGHT - 4 - 2 - 2 )/fh; | ||
658 | height = onscreen * fh + 4 + 2 + 2; | ||
659 | width += 5; | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | onscreen = menu_length; | ||
664 | } | ||
665 | |||
666 | draw_window( height, width, &top, &left, menu[0].label ); | ||
667 | |||
668 | while( 1 ) | ||
669 | { | ||
670 | for( i = (scroll == 0 ? 1 : scroll); | ||
671 | i < (scroll ? scroll + onscreen - 1:onscreen); | ||
672 | i++ ) | ||
673 | { | ||
674 | if( i == selection ) | ||
675 | { | ||
676 | rb->lcd_set_foreground( COLOR_WHITE ); | ||
677 | rb->lcd_set_background( COLOR_BLUE ); | ||
678 | } | ||
679 | else | ||
680 | { | ||
681 | rb->lcd_set_foreground( COLOR_BLACK ); | ||
682 | rb->lcd_set_background( COLOR_LIGHTGRAY ); | ||
683 | } | ||
684 | rb->lcd_putsxy( left+2, | ||
685 | top+6+fh*(i-(scroll == 0 ? 0 : scroll-1 )), | ||
686 | menu[i].label ); | ||
687 | } | ||
688 | if( scroll ) | ||
689 | { | ||
690 | int scroll_height = ((height-fh-4-2)*onscreen)/menu_length; | ||
691 | rb->lcd_set_foreground( COLOR_BLACK ); | ||
692 | rb->lcd_vline( left+width-5, top+fh+4, top+height-2 ); | ||
693 | rb->lcd_fillrect( left+width-4, | ||
694 | top+fh+4+((height-4-2-fh-scroll_height)*(scroll-1))/(menu_length-onscreen), | ||
695 | 3, scroll_height ); | ||
696 | } | ||
697 | rb->lcd_update(); | ||
698 | |||
699 | switch( rb->button_get(true) ) | ||
700 | { | ||
701 | case ROCKPAINT_UP: | ||
702 | case ROCKPAINT_UP|BUTTON_REPEAT: | ||
703 | selection = (selection + menu_length-1)%menu_length; | ||
704 | if( !selection ) selection = menu_length-1; | ||
705 | break; | ||
706 | |||
707 | case ROCKPAINT_DOWN: | ||
708 | case ROCKPAINT_DOWN|BUTTON_REPEAT: | ||
709 | selection = (selection + 1)%menu_length; | ||
710 | if( !selection ) selection++; | ||
711 | break; | ||
712 | |||
713 | case ROCKPAINT_LEFT: | ||
714 | restore_screen(); | ||
715 | return MENU_ESC; | ||
716 | |||
717 | case ROCKPAINT_RIGHT: | ||
718 | case ROCKPAINT_DRAW: | ||
719 | restore_screen(); | ||
720 | return menu[selection].value; | ||
721 | } | ||
722 | if( scroll ) | ||
723 | { | ||
724 | if( selection < scroll ) | ||
725 | { | ||
726 | scroll = selection; | ||
727 | draw_window( height, width, NULL, NULL, menu[0].label ); | ||
728 | } | ||
729 | if( selection >= scroll + onscreen - 1 ) | ||
730 | { | ||
731 | scroll++; | ||
732 | draw_window( height, width, NULL, NULL, menu[0].label ); | ||
733 | } | ||
734 | } | ||
735 | } | ||
736 | } | ||
737 | |||
738 | /*********************************************************************** | 584 | /*********************************************************************** |
739 | * File browser | 585 | * File browser |
740 | ***********************************************************************/ | 586 | ***********************************************************************/ |
741 | 587 | ||
742 | char bbuf[MAX_PATH+1]; /* used by file and font browsers */ | 588 | char bbuf[MAX_PATH+1]; /* used by file and font browsers */ |
743 | char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */ | 589 | char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */ |
590 | struct tree_context *tree = NULL; | ||
744 | 591 | ||
745 | static bool browse( char *dst, int dst_size, const char *start ) | 592 | static char * browse_get_name_cb( int selected_item, void *data, |
593 | char *buffer, size_t buffer_len ) | ||
746 | { | 594 | { |
747 | #define WIDTH ( LCD_WIDTH - 20 ) | 595 | int *indexes = (int *) data; |
748 | #define HEIGHT ( LCD_HEIGHT - 20 ) | 596 | struct entry* dc = tree->dircache; |
749 | #define LINE_SPACE 2 | 597 | struct entry* e = &dc[indexes[selected_item]]; |
750 | int top, top_inside, left; | 598 | (void) buffer; |
599 | (void) buffer_len; | ||
751 | 600 | ||
752 | DIR *d; | 601 | return (e->name); |
753 | struct dirent *de; | 602 | } |
754 | int fvi = 0; /* first visible item */ | ||
755 | int lvi = 0; /* last visible item */ | ||
756 | int si = 0; /* selected item */ | ||
757 | int li = 0; /* last item */ | ||
758 | int i; | ||
759 | 603 | ||
760 | int fh; | 604 | static bool browse( char *dst, int dst_size, const char *start ) |
761 | char *a; | 605 | { |
606 | struct gui_synclist browse_list; | ||
607 | int item_count, selected, button; | ||
608 | struct tree_context backup; | ||
609 | struct entry *dc; | ||
610 | bool reload = true; | ||
611 | int dirfilter = SHOW_ALL; | ||
612 | int *indexes = (int *) buffer.clipboard; | ||
762 | 613 | ||
763 | rb->lcd_getstringsize( "Ap", NULL, &fh ); | 614 | char *a; |
764 | 615 | ||
765 | rb->strcpy( bbuf, start ); | 616 | rb->strcpy( bbuf, start ); |
766 | a = bbuf+rb->strlen(bbuf)-1; | 617 | a = bbuf+rb->strlen(bbuf)-1; |
@@ -769,124 +620,106 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
769 | a[1] = '/'; | 620 | a[1] = '/'; |
770 | a[2] = '\0'; | 621 | a[2] = '\0'; |
771 | } | 622 | } |
623 | bbuf_s[0] = '\0'; | ||
624 | |||
625 | rb->gui_synclist_init( &browse_list, browse_get_name_cb, | ||
626 | (void*) indexes, false, 1, NULL ); | ||
772 | 627 | ||
628 | tree = rb->tree_get_context(); | ||
629 | backup = *tree; | ||
630 | dc = tree->dircache; | ||
631 | a = backup.currdir+rb->strlen(backup.currdir)-1; | ||
632 | if( *a != '/' ) | ||
633 | { | ||
634 | *++a = '/'; | ||
635 | *++a = '\0'; | ||
636 | } | ||
637 | rb->strcpy( a, dc[tree->selected_item].name ); | ||
638 | tree->dirfilter = &dirfilter; | ||
773 | while( 1 ) | 639 | while( 1 ) |
774 | { | 640 | { |
775 | d = rb->opendir( bbuf ); | 641 | if( reload ) |
776 | if( !d ) | ||
777 | { | 642 | { |
778 | /* | 643 | int i; |
779 | if( errno == ENOTDIR ) | 644 | rb->set_current_file(bbuf); |
780 | {*/ | 645 | item_count = 0; |
781 | /* this is a file */ | 646 | selected = 0; |
782 | bbuf[rb->strlen(bbuf)-1] = '\0'; | 647 | for( i = 0; i < tree->filesindir ; i++) |
783 | rb->strncpy( dst, bbuf, dst_size ); | ||
784 | return true; | ||
785 | /*} | ||
786 | else if( errno == EACCES || errno == ENOENT ) | ||
787 | { | 648 | { |
788 | bbuf[0] = '/'; bbuf[1] = '\0'; | 649 | /* only displayes directories and .bmp files */ |
789 | d = rb->opendir( "/" ); | 650 | if( ((dc[i].attr & ATTR_DIRECTORY ) && |
790 | } | 651 | rb->strcmp( dc[i].name, "." ) && |
791 | else | 652 | rb->strcmp( dc[i].name, ".." )) || |
792 | { | 653 | ( !(dc[i].attr & ATTR_DIRECTORY) && |
793 | return false; | 654 | (a = rb->strrchr( dc[i].name,'.' )) && |
794 | }*/ | 655 | !rb->strcmp( a, ".bmp" ) )) |
795 | } | 656 | { |
796 | top_inside = draw_window( HEIGHT, WIDTH, &top, &left, bbuf ); | 657 | if( !rb->strcmp( dc[i].name, bbuf_s ) ) |
797 | i = 0; | 658 | selected = item_count; |
798 | li = -1; | 659 | indexes[item_count++] = i; |
799 | while( i < fvi ) | 660 | } |
800 | { | ||
801 | rb->readdir( d ); | ||
802 | i++; | ||
803 | } | ||
804 | while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT ) | ||
805 | { | ||
806 | de = rb->readdir( d ); | ||
807 | if( !de ) | ||
808 | { | ||
809 | li = i-1; | ||
810 | break; | ||
811 | } | ||
812 | rb->lcd_set_foreground((si==i?COLOR_WHITE:COLOR_BLACK)); | ||
813 | rb->lcd_set_background((si==i?COLOR_BLUE:COLOR_LIGHTGRAY)); | ||
814 | rb->lcd_putsxy( left+10, | ||
815 | top_inside+(i-fvi)*(fh+LINE_SPACE), | ||
816 | de->d_name ); | ||
817 | if( si == i ) | ||
818 | rb->strcpy( bbuf_s, de->d_name ); | ||
819 | i++; | ||
820 | } | ||
821 | lvi = i-1; | ||
822 | if( li == -1 ) | ||
823 | { | ||
824 | if( !rb->readdir( d ) ) | ||
825 | { | ||
826 | li = lvi; | ||
827 | } | 661 | } |
828 | } | ||
829 | rb->closedir( d ); | ||
830 | |||
831 | rb->lcd_update(); | ||
832 | 662 | ||
833 | switch( rb->button_get(true) ) | 663 | rb->gui_synclist_set_nb_items(&browse_list,item_count); |
664 | rb->gui_synclist_select_item(&browse_list, selected); | ||
665 | rb->gui_synclist_set_title(&browse_list, bbuf, NOICON); | ||
666 | rb->gui_synclist_draw(&browse_list); | ||
667 | reload = false; | ||
668 | } | ||
669 | button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); | ||
670 | if (rb->gui_synclist_do_button(&browse_list,&button,LIST_WRAP_UNLESS_HELD)) | ||
671 | continue; | ||
672 | switch( button ) | ||
834 | { | 673 | { |
835 | case ROCKPAINT_UP: | 674 | case ACTION_STD_CANCEL: |
836 | case ROCKPAINT_UP|BUTTON_REPEAT: | 675 | if( !rb->strcmp( bbuf, "/" ) ) |
837 | if( si > 0 ) | ||
838 | { | 676 | { |
839 | si--; | 677 | *tree = backup; |
840 | if( si<fvi ) | 678 | rb->set_current_file( backup.currdir ); |
841 | { | 679 | return false; |
842 | fvi--; | ||
843 | } | ||
844 | } | 680 | } |
845 | break; | 681 | rb->strcpy( bbuf_s, ".." ); |
846 | 682 | case ACTION_STD_OK: | |
847 | case ROCKPAINT_DOWN: | 683 | if( button == ACTION_STD_OK ) |
848 | case ROCKPAINT_DOWN|BUTTON_REPEAT: | ||
849 | if( li == -1 || si < li ) | ||
850 | { | 684 | { |
851 | si++; | 685 | selected = rb->gui_synclist_get_sel_pos( &browse_list ); |
852 | if( si>lvi ) | 686 | if( selected < 0 || selected >= item_count ) |
687 | break; | ||
688 | struct entry* e = &dc[indexes[selected]]; | ||
689 | rb->strncpy( bbuf_s, e->name, sizeof( bbuf_s ) ); | ||
690 | if( !( e->attr & ATTR_DIRECTORY ) ) | ||
853 | { | 691 | { |
854 | fvi++; | 692 | *tree = backup; |
693 | rb->set_current_file( backup.currdir ); | ||
694 | rb->snprintf( dst, dst_size, "%s%s", bbuf, bbuf_s ); | ||
695 | return true; | ||
855 | } | 696 | } |
856 | } | 697 | } |
857 | break; | 698 | if( !rb->strcmp( bbuf_s, "." ) ) break; |
858 | 699 | a = bbuf+rb->strlen(bbuf); | |
859 | case ROCKPAINT_LEFT: | 700 | if( !rb->strcmp( bbuf_s, ".." ) ) |
860 | if( bbuf[0] == '/' && !bbuf[1] ) return false; | ||
861 | bbuf_s[0] = '.'; | ||
862 | bbuf_s[1] = '.'; | ||
863 | bbuf_s[2] = '\0'; | ||
864 | case ROCKPAINT_RIGHT: | ||
865 | case ROCKPAINT_DRAW: | ||
866 | if( *bbuf_s == '.' && !bbuf_s[1] ) break; | ||
867 | a = bbuf; | ||
868 | while( *a ) a++; | ||
869 | if( *bbuf_s == '.' && bbuf_s[1] == '.' && !bbuf_s[2] ) | ||
870 | { | 701 | { |
871 | a--; | 702 | a--; |
872 | if( a == bbuf ) break; | 703 | if( a == bbuf ) break; |
873 | if( *a == '/' ) a--; | 704 | if( *a == '/' ) a--; |
874 | while( *a != '/' ) a--; | 705 | while( *a != '/' ) a--; |
875 | *++a = '\0'; | 706 | rb->strcpy( bbuf_s, ++a ); |
707 | /* select parent directory */ | ||
708 | bbuf_s[rb->strlen(bbuf_s)-1] = '\0'; | ||
709 | *a = '\0'; | ||
710 | reload = true; | ||
876 | break; | 711 | break; |
877 | } | 712 | } |
878 | rb->strcpy( a, bbuf_s ); | 713 | rb->snprintf( a, bbuf+sizeof(bbuf)-a, "%s/", bbuf_s ); |
879 | while( *a ) a++; | 714 | reload = true; |
880 | *a++ = '/'; | ||
881 | *a = '\0'; | ||
882 | fvi = si = 0; | ||
883 | break; | 715 | break; |
716 | |||
717 | case ACTION_STD_MENU: | ||
718 | *tree = backup; | ||
719 | rb->set_current_file( backup.currdir ); | ||
720 | return false; | ||
884 | } | 721 | } |
885 | } | 722 | } |
886 | |||
887 | #undef WIDTH | ||
888 | #undef HEIGHT | ||
889 | #undef LINE_SPACE | ||
890 | } | 723 | } |
891 | 724 | ||
892 | /*********************************************************************** | 725 | /*********************************************************************** |
@@ -898,7 +731,6 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
898 | ***********************************************************************/ | 731 | ***********************************************************************/ |
899 | static bool browse_fonts( char *dst, int dst_size ) | 732 | static bool browse_fonts( char *dst, int dst_size ) |
900 | { | 733 | { |
901 | char old_font[MAX_PATH]; | ||
902 | #define WIDTH ( LCD_WIDTH - 20 ) | 734 | #define WIDTH ( LCD_WIDTH - 20 ) |
903 | #define HEIGHT ( LCD_HEIGHT - 20 ) | 735 | #define HEIGHT ( LCD_HEIGHT - 20 ) |
904 | #define LINE_SPACE 2 | 736 | #define LINE_SPACE 2 |
@@ -923,7 +755,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
923 | int fw; | 755 | int fw; |
924 | #define fontname_buf buffer.text.fontname_buf | 756 | #define fontname_buf buffer.text.fontname_buf |
925 | 757 | ||
926 | rb->snprintf( old_font, MAX_PATH, | 758 | rb->snprintf( buffer.text.old_font, MAX_PATH, |
927 | FONT_DIR "/%s.fnt", | 759 | FONT_DIR "/%s.fnt", |
928 | rb->global_settings->font_file ); | 760 | rb->global_settings->font_file ); |
929 | 761 | ||
@@ -1019,7 +851,7 @@ static bool browse_fonts( char *dst, int dst_size ) | |||
1019 | nvih = fh; | 851 | nvih = fh; |
1020 | } | 852 | } |
1021 | } | 853 | } |
1022 | rb->font_load( old_font ); | 854 | rb->font_load( buffer.text.old_font ); |
1023 | rb->closedir( d ); | 855 | rb->closedir( d ); |
1024 | } | 856 | } |
1025 | 857 | ||
@@ -1501,6 +1333,74 @@ static void draw_vflip( int x1, int y1, int x2, int y2 ) | |||
1501 | rb->lcd_update(); | 1333 | rb->lcd_update(); |
1502 | } | 1334 | } |
1503 | 1335 | ||
1336 | /* direction: -1 = left, 1 = right */ | ||
1337 | static void draw_rot_90_deg( int x1, int y1, int x2, int y2, int direction ) | ||
1338 | { | ||
1339 | int i, j; | ||
1340 | if( x1 > x2 ) | ||
1341 | { | ||
1342 | i = x1; | ||
1343 | x1 = x2; | ||
1344 | x2 = i; | ||
1345 | } | ||
1346 | if( y1 > y2 ) | ||
1347 | { | ||
1348 | i = y1; | ||
1349 | y1 = y2; | ||
1350 | y2 = i; | ||
1351 | } | ||
1352 | |||
1353 | copy_to_clipboard(); | ||
1354 | |||
1355 | fb_data color = rp_colors[ bgdrawcolor ]; | ||
1356 | const int width = x2 - x1, height = y2 - y1; | ||
1357 | const int sub_half = width/2-height/2, add_half = (width+height)/2; | ||
1358 | if( width > height ) | ||
1359 | { | ||
1360 | for( i = 0; i <= height; i++ ) | ||
1361 | { | ||
1362 | for( j = 0; j < sub_half; j++ ) | ||
1363 | save_buffer[(y1+i)*COLS+x1+j] = color; | ||
1364 | for( j = add_half+1; j <= width; j++ ) | ||
1365 | save_buffer[(y1+i)*COLS+x1+j] = color; | ||
1366 | } | ||
1367 | } | ||
1368 | else if( width < height ) | ||
1369 | { | ||
1370 | for( j = 0; j <= width; j++ ) | ||
1371 | { | ||
1372 | for( i = 0; i < -sub_half; i++ ) | ||
1373 | save_buffer[(y1+i)*COLS+x1+j] = color; | ||
1374 | for( i = add_half+1; i <= height; i++ ) | ||
1375 | save_buffer[(y1+i)*COLS+x1+j] = color; | ||
1376 | } | ||
1377 | } | ||
1378 | int x3 = x1 + sub_half, y3 = y1 - sub_half; | ||
1379 | int is = x3<0?-x3:0, ie = COLS-x3-1, js = y3<0?-y3:0, je = ROWS-y3-1; | ||
1380 | if( ie > height ) ie = height; | ||
1381 | if( je > width ) je = width; | ||
1382 | for( i = is; i <= ie; i++ ) | ||
1383 | { | ||
1384 | for( j = js; j <= je; j++ ) | ||
1385 | { | ||
1386 | int x, y; | ||
1387 | if(direction > 0) | ||
1388 | { | ||
1389 | x = x1+j; | ||
1390 | y = y1+height-i; | ||
1391 | } | ||
1392 | else | ||
1393 | { | ||
1394 | x = x1+width-j; | ||
1395 | y = y1+i; | ||
1396 | } | ||
1397 | save_buffer[(y3+j)*COLS+x3+i] = buffer.clipboard[y*COLS+x]; | ||
1398 | } | ||
1399 | } | ||
1400 | restore_screen(); | ||
1401 | rb->lcd_update(); | ||
1402 | } | ||
1403 | |||
1504 | static void draw_paste_rectangle( int src_x1, int src_y1, int src_x2, | 1404 | static void draw_paste_rectangle( int src_x1, int src_y1, int src_x2, |
1505 | int src_y2, int x1, int y1, int mode ) | 1405 | int src_y2, int x1, int y1, int mode ) |
1506 | { | 1406 | { |
@@ -1558,18 +1458,18 @@ static void show_grid( bool update ) | |||
1558 | 1458 | ||
1559 | static void draw_text( int x, int y ) | 1459 | static void draw_text( int x, int y ) |
1560 | { | 1460 | { |
1461 | int selected = 0; | ||
1561 | buffer.text.text[0] = '\0'; | 1462 | buffer.text.text[0] = '\0'; |
1562 | rb->snprintf( buffer.text.old_font, MAX_PATH, | 1463 | rb->snprintf( buffer.text.old_font, MAX_PATH, |
1563 | FONT_DIR "/%s.fnt", | 1464 | FONT_DIR "/%s.fnt", |
1564 | rb->global_settings->font_file ); | 1465 | rb->global_settings->font_file ); |
1565 | while( 1 ) | 1466 | while( 1 ) |
1566 | { | 1467 | { |
1567 | int m = TEXT_MENU_TEXT; | 1468 | switch( rb->do_menu( &text_menu, &selected, NULL, NULL ) ) |
1568 | switch( m = menu_display( text_menu, m ) ) | ||
1569 | { | 1469 | { |
1570 | case TEXT_MENU_TEXT: | 1470 | case TEXT_MENU_TEXT: |
1471 | rb->lcd_set_foreground(COLOR_BLACK); | ||
1571 | rb->kbd_input( buffer.text.text, MAX_TEXT ); | 1472 | rb->kbd_input( buffer.text.text, MAX_TEXT ); |
1572 | restore_screen(); | ||
1573 | break; | 1473 | break; |
1574 | 1474 | ||
1575 | case TEXT_MENU_FONT: | 1475 | case TEXT_MENU_FONT: |
@@ -1583,7 +1483,7 @@ static void draw_text( int x, int y ) | |||
1583 | rb->lcd_set_foreground( rp_colors[ drawcolor ] ); | 1483 | rb->lcd_set_foreground( rp_colors[ drawcolor ] ); |
1584 | while( 1 ) | 1484 | while( 1 ) |
1585 | { | 1485 | { |
1586 | unsigned int button; | 1486 | int button; |
1587 | restore_screen(); | 1487 | restore_screen(); |
1588 | rb->lcd_putsxy( x, y, buffer.text.text ); | 1488 | rb->lcd_putsxy( x, y, buffer.text.text ); |
1589 | rb->lcd_update(); | 1489 | rb->lcd_update(); |
@@ -1614,10 +1514,14 @@ static void draw_text( int x, int y ) | |||
1614 | break; | 1514 | break; |
1615 | 1515 | ||
1616 | case ROCKPAINT_DRAW: | 1516 | case ROCKPAINT_DRAW: |
1617 | button = 1242; | 1517 | break; |
1518 | default: | ||
1519 | if(rb->default_event_handler(button) | ||
1520 | == SYS_USB_CONNECTED) | ||
1521 | button = ROCKPAINT_DRAW; | ||
1618 | break; | 1522 | break; |
1619 | } | 1523 | } |
1620 | if( button == 1242 ) break; | 1524 | if( button == ROCKPAINT_DRAW ) break; |
1621 | } | 1525 | } |
1622 | break; | 1526 | break; |
1623 | 1527 | ||
@@ -1626,6 +1530,7 @@ static void draw_text( int x, int y ) | |||
1626 | buffer_putsxyofs( save_buffer, COLS, ROWS, x, y, 0, | 1530 | buffer_putsxyofs( save_buffer, COLS, ROWS, x, y, 0, |
1627 | buffer.text.text ); | 1531 | buffer.text.text ); |
1628 | case TEXT_MENU_CANCEL: | 1532 | case TEXT_MENU_CANCEL: |
1533 | default: | ||
1629 | restore_screen(); | 1534 | restore_screen(); |
1630 | rb->font_load( buffer.text.old_font ); | 1535 | rb->font_load( buffer.text.old_font ); |
1631 | return; | 1536 | return; |
@@ -2541,10 +2446,11 @@ static void clear_drawing(void) | |||
2541 | static void goto_menu(void) | 2446 | static void goto_menu(void) |
2542 | { | 2447 | { |
2543 | int multi; | 2448 | int multi; |
2449 | int selected = 0; | ||
2544 | 2450 | ||
2545 | while( 1 ) | 2451 | while( 1 ) |
2546 | { | 2452 | { |
2547 | switch( menu_display( main_menu, 1 ) ) | 2453 | switch( rb->do_menu( &main_menu, &selected, NULL, false ) ) |
2548 | { | 2454 | { |
2549 | case MAIN_MENU_NEW: | 2455 | case MAIN_MENU_NEW: |
2550 | clear_drawing(); | 2456 | clear_drawing(); |
@@ -2569,6 +2475,7 @@ static void goto_menu(void) | |||
2569 | break; | 2475 | break; |
2570 | 2476 | ||
2571 | case MAIN_MENU_SAVE: | 2477 | case MAIN_MENU_SAVE: |
2478 | rb->lcd_set_foreground(COLOR_BLACK); | ||
2572 | if (!filename[0]) | 2479 | if (!filename[0]) |
2573 | rb->strcpy(filename,"/"); | 2480 | rb->strcpy(filename,"/"); |
2574 | if( !rb->kbd_input( filename, MAX_PATH ) ) | 2481 | if( !rb->kbd_input( filename, MAX_PATH ) ) |
@@ -2582,15 +2489,19 @@ static void goto_menu(void) | |||
2582 | break; | 2489 | break; |
2583 | 2490 | ||
2584 | case MAIN_MENU_BRUSH_SIZE: | 2491 | case MAIN_MENU_BRUSH_SIZE: |
2585 | multi = menu_display( size_menu, bsize ); | 2492 | for(multi = 0; multi<4; multi++) |
2586 | if( multi != - 1 ) | 2493 | if(bsize == times_list[multi]) break; |
2587 | bsize = multi; | 2494 | rb->do_menu( &size_menu, &multi, NULL, false ); |
2495 | if( multi >= 0 ) | ||
2496 | bsize = times_list[multi]; | ||
2588 | break; | 2497 | break; |
2589 | 2498 | ||
2590 | case MAIN_MENU_BRUSH_SPEED: | 2499 | case MAIN_MENU_BRUSH_SPEED: |
2591 | multi = menu_display( speed_menu, bspeed ); | 2500 | for(multi = 0; multi<3; multi++) |
2592 | if( multi != -1 ) | 2501 | if(bspeed == times_list[multi]) break; |
2593 | bspeed = multi; | 2502 | rb->do_menu( &speed_menu, &multi, NULL, false ); |
2503 | if( multi >= 0 ) | ||
2504 | bspeed = times_list[multi]; | ||
2594 | break; | 2505 | break; |
2595 | 2506 | ||
2596 | case MAIN_MENU_COLOR: | 2507 | case MAIN_MENU_COLOR: |
@@ -2598,17 +2509,21 @@ static void goto_menu(void) | |||
2598 | break; | 2509 | break; |
2599 | 2510 | ||
2600 | case MAIN_MENU_GRID_SIZE: | 2511 | case MAIN_MENU_GRID_SIZE: |
2601 | multi = menu_display( gridsize_menu, gridsize ); | 2512 | for(multi = 0; multi<4; multi++) |
2602 | if( multi != - 1 ) | 2513 | if(gridsize == gridsize_list[multi]) break; |
2603 | gridsize = multi; | 2514 | rb->do_menu( &gridsize_menu, &multi, NULL, false ); |
2515 | if( multi >= 0 ) | ||
2516 | gridsize = gridsize_list[multi]; | ||
2604 | break; | 2517 | break; |
2605 | 2518 | ||
2606 | case MAIN_MENU_EXIT: | 2519 | case MAIN_MENU_EXIT: |
2520 | restore_screen(); | ||
2607 | quit=true; | 2521 | quit=true; |
2608 | return; | 2522 | return; |
2609 | 2523 | ||
2610 | case MAIN_MENU_RESUME: | 2524 | case MAIN_MENU_RESUME: |
2611 | case MENU_ESC: | 2525 | default: |
2526 | restore_screen(); | ||
2612 | return; | 2527 | return; |
2613 | }/* end switch */ | 2528 | }/* end switch */ |
2614 | }/* end while */ | 2529 | }/* end while */ |
@@ -2660,6 +2575,7 @@ static bool rockpaint_loop( void ) | |||
2660 | case ROCKPAINT_MENU: | 2575 | case ROCKPAINT_MENU: |
2661 | inv_cursor(false); | 2576 | inv_cursor(false); |
2662 | goto_menu(); | 2577 | goto_menu(); |
2578 | restore_screen(); | ||
2663 | inv_cursor(true); | 2579 | inv_cursor(true); |
2664 | break; | 2580 | break; |
2665 | 2581 | ||
@@ -2697,8 +2613,8 @@ static bool rockpaint_loop( void ) | |||
2697 | else if( tool == SelectRectangle | 2613 | else if( tool == SelectRectangle |
2698 | && ( prev_x2 == -1 || prev_y2 == -1 ) ) | 2614 | && ( prev_x2 == -1 || prev_y2 == -1 ) ) |
2699 | { | 2615 | { |
2700 | tool_mode = menu_display( select_menu, | 2616 | tool_mode = rb->do_menu( &select_menu, |
2701 | SELECT_MENU_CUT ); | 2617 | NULL, NULL, false ); |
2702 | switch( tool_mode ) | 2618 | switch( tool_mode ) |
2703 | { | 2619 | { |
2704 | case SELECT_MENU_CUT: | 2620 | case SELECT_MENU_CUT: |
@@ -2726,22 +2642,29 @@ static bool rockpaint_loop( void ) | |||
2726 | break; | 2642 | break; |
2727 | 2643 | ||
2728 | case SELECT_MENU_ROTATE90: | 2644 | case SELECT_MENU_ROTATE90: |
2645 | draw_rot_90_deg( prev_x, prev_y, x, y, 1 ); | ||
2646 | reset_tool(); | ||
2729 | break; | 2647 | break; |
2648 | |||
2730 | case SELECT_MENU_ROTATE180: | 2649 | case SELECT_MENU_ROTATE180: |
2731 | draw_hflip( prev_x, prev_y, x, y ); | 2650 | draw_hflip( prev_x, prev_y, x, y ); |
2732 | draw_vflip( prev_x, prev_y, x, y ); | 2651 | draw_vflip( prev_x, prev_y, x, y ); |
2733 | reset_tool(); | 2652 | reset_tool(); |
2734 | break; | 2653 | break; |
2654 | |||
2735 | case SELECT_MENU_ROTATE270: | 2655 | case SELECT_MENU_ROTATE270: |
2656 | draw_rot_90_deg( prev_x, prev_y, x, y, -1 ); | ||
2657 | reset_tool(); | ||
2736 | break; | 2658 | break; |
2737 | 2659 | ||
2738 | case SELECT_MENU_CANCEL: | 2660 | case SELECT_MENU_CANCEL: |
2739 | reset_tool(); | 2661 | reset_tool(); |
2740 | break; | 2662 | break; |
2741 | 2663 | ||
2742 | case MENU_ESC: | 2664 | default: |
2743 | break; | 2665 | break; |
2744 | } | 2666 | } |
2667 | restore_screen(); | ||
2745 | } | 2668 | } |
2746 | else if( tool == Curve | 2669 | else if( tool == Curve |
2747 | && ( prev_x3 == -1 || prev_y3 == -1 ) ) | 2670 | && ( prev_x3 == -1 || prev_y3 == -1 ) ) |
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index f9c2a63b52..80ef1af60d 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "lib/configfile.h" | 24 | #include "lib/configfile.h" |
25 | #include "button.h" | 25 | #include "button.h" |
26 | #include "lcd.h" | 26 | #include "lcd.h" |
27 | #include "lib/oldmenuapi.h" | ||
28 | 27 | ||
29 | #ifdef HAVE_LCD_BITMAP | 28 | #ifdef HAVE_LCD_BITMAP |
30 | 29 | ||
@@ -773,15 +772,10 @@ static struct configdata config[] = { | |||
773 | { TYPE_INT, 0, 1, { .int_p = &sol_disk.draw_type }, "draw_type", NULL } | 772 | { TYPE_INT, 0, 1, { .int_p = &sol_disk.draw_type }, "draw_type", NULL } |
774 | }; | 773 | }; |
775 | 774 | ||
776 | char draw_option_string[32]; | 775 | static const struct opt_items drawcards[2] = { |
777 | 776 | { "Draw Three Cards", -1 }, | |
778 | static void create_draw_option_string(void) | 777 | { "Draw One Card", -1 }, |
779 | { | 778 | }; |
780 | if (sol.draw_type == 0) | ||
781 | rb->strcpy(draw_option_string, "Draw Three Cards"); | ||
782 | else | ||
783 | rb->strcpy(draw_option_string, "Draw One Card"); | ||
784 | } | ||
785 | 779 | ||
786 | void solitaire_init(void); | 780 | void solitaire_init(void); |
787 | 781 | ||
@@ -790,37 +784,22 @@ enum { MENU_RESUME, MENU_SAVE_AND_QUIT, MENU_QUIT, MENU_USB }; | |||
790 | 784 | ||
791 | int solitaire_menu(bool in_game) | 785 | int solitaire_menu(bool in_game) |
792 | { | 786 | { |
793 | int m; | 787 | int selected = 0; |
794 | int result = -1; | 788 | int result = -1; |
795 | int i = 0; | ||
796 | |||
797 | struct menu_item items[6]; | ||
798 | 789 | ||
799 | if( in_game ) | 790 | MENUITEM_STRINGLIST(menu, "Solitaire Menu", NULL, |
800 | { | 791 | "Start Game", "Draw Cards Option", |
801 | items[i++].desc = "Resume Game"; | 792 | "Help", "Audio Playback", "Quit"); |
802 | items[i++].desc = "Restart Game"; | 793 | MENUITEM_STRINGLIST(menu_in_game, "Solitaire Menu", NULL, |
803 | } | 794 | "Resume Game", "Restart Game", "Help", |
804 | else | 795 | "Audio Playback", "Save and Quit", "Quit"); |
805 | { | ||
806 | items[i++].desc = "Start Game"; | ||
807 | items[i++].desc = draw_option_string; | ||
808 | } | ||
809 | items[i++].desc = "Help"; | ||
810 | items[i++].desc = "Audio Playback"; | ||
811 | if( in_game ) | ||
812 | { | ||
813 | items[i++].desc = "Save and Quit"; | ||
814 | } | ||
815 | items[i++].desc = "Quit"; | ||
816 | 796 | ||
817 | create_draw_option_string(); | ||
818 | m = menu_init(items, i, NULL, NULL, NULL, NULL); | ||
819 | while (result < 0) | 797 | while (result < 0) |
820 | { | 798 | { |
821 | switch (menu_show(m)) | 799 | switch (rb->do_menu(in_game? &menu_in_game: &menu, |
800 | &selected, NULL, false)) | ||
822 | { | 801 | { |
823 | case MENU_SELECTED_EXIT: | 802 | default: |
824 | result = MENU_RESUME; | 803 | result = MENU_RESUME; |
825 | break; | 804 | break; |
826 | 805 | ||
@@ -840,8 +819,9 @@ int solitaire_menu(bool in_game) | |||
840 | } | 819 | } |
841 | else | 820 | else |
842 | { | 821 | { |
843 | sol.draw_type = (sol.draw_type + 1) % 2; | 822 | if (rb->set_option("Draw Cards Option", &sol.draw_type, |
844 | create_draw_option_string(); | 823 | INT, drawcards, 2, NULL)) |
824 | result = MENU_USB; | ||
845 | } | 825 | } |
846 | break; | 826 | break; |
847 | 827 | ||
@@ -866,7 +846,6 @@ int solitaire_menu(bool in_game) | |||
866 | break; | 846 | break; |
867 | } | 847 | } |
868 | } | 848 | } |
869 | menu_exit(m); | ||
870 | return result; | 849 | return result; |
871 | } | 850 | } |
872 | 851 | ||
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index 413be298ea..da41a6986b 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c | |||
@@ -60,7 +60,6 @@ Example ".ss" file, and one with a saved state: | |||
60 | 60 | ||
61 | #include "plugin.h" | 61 | #include "plugin.h" |
62 | #include "lib/configfile.h" | 62 | #include "lib/configfile.h" |
63 | #include "lib/oldmenuapi.h" | ||
64 | 63 | ||
65 | #ifdef HAVE_LCD_BITMAP | 64 | #ifdef HAVE_LCD_BITMAP |
66 | 65 | ||
@@ -1167,30 +1166,20 @@ enum { | |||
1167 | 1166 | ||
1168 | bool sudoku_menu(struct sudoku_state_t* state) | 1167 | bool sudoku_menu(struct sudoku_state_t* state) |
1169 | { | 1168 | { |
1170 | int m; | ||
1171 | int result; | 1169 | int result; |
1172 | 1170 | ||
1173 | static const struct menu_item items[] = { | 1171 | MENUITEM_STRINGLIST(menu, "Sudoku Menu", NULL, |
1174 | [SM_AUDIO_PLAYBACK] = { "Audio Playback", NULL }, | 1172 | "Audio Playback", |
1175 | #ifdef HAVE_LCD_COLOR | 1173 | #ifdef HAVE_LCD_COLOR |
1176 | [SM_NUMBER_DISPLAY] = { "Number Display", NULL }, | 1174 | "Number Display", |
1177 | #endif | 1175 | #endif |
1178 | #ifdef SUDOKU_BUTTON_POSSIBLE | 1176 | #ifdef SUDOKU_BUTTON_POSSIBLE |
1179 | [SM_SHOW_MARKINGS] = { "Show Markings", NULL }, | 1177 | "Show Markings", |
1180 | #endif | 1178 | #endif |
1181 | [SM_SAVE] = { "Save", NULL }, | 1179 | "Save", "Reload", "Clear", "Solve", |
1182 | [SM_RELOAD] = { "Reload", NULL }, | 1180 | "Generate", "New", "Quit"); |
1183 | [SM_CLEAR] = { "Clear", NULL }, | ||
1184 | [SM_SOLVE] = { "Solve", NULL }, | ||
1185 | [SM_GENERATE] = { "Generate", NULL }, | ||
1186 | [SM_NEW] = { "New", NULL }, | ||
1187 | [SM_QUIT] = { "Quit", NULL }, | ||
1188 | }; | ||
1189 | |||
1190 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
1191 | NULL, NULL, NULL, NULL); | ||
1192 | 1181 | ||
1193 | result=menu_show(m); | 1182 | result = rb->do_menu(&menu, NULL, NULL, false); |
1194 | 1183 | ||
1195 | switch (result) { | 1184 | switch (result) { |
1196 | case SM_AUDIO_PLAYBACK: | 1185 | case SM_AUDIO_PLAYBACK: |
@@ -1235,7 +1224,6 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1235 | 1224 | ||
1236 | case SM_QUIT: | 1225 | case SM_QUIT: |
1237 | save_sudoku(state); | 1226 | save_sudoku(state); |
1238 | menu_exit(m); | ||
1239 | return true; | 1227 | return true; |
1240 | break; | 1228 | break; |
1241 | 1229 | ||
@@ -1243,26 +1231,18 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1243 | break; | 1231 | break; |
1244 | } | 1232 | } |
1245 | 1233 | ||
1246 | menu_exit(m); | ||
1247 | |||
1248 | return (result==MENU_ATTACHED_USB); | 1234 | return (result==MENU_ATTACHED_USB); |
1249 | } | 1235 | } |
1250 | 1236 | ||
1251 | /* Menu used when user is in edit mode - i.e. creating a new game manually */ | 1237 | /* Menu used when user is in edit mode - i.e. creating a new game manually */ |
1252 | int sudoku_edit_menu(struct sudoku_state_t* state) | 1238 | int sudoku_edit_menu(struct sudoku_state_t* state) |
1253 | { | 1239 | { |
1254 | int m; | ||
1255 | int result; | 1240 | int result; |
1256 | 1241 | ||
1257 | static const struct menu_item items[] = { | 1242 | MENUITEM_STRINGLIST(menu, "Edit Menu", NULL, |
1258 | { "Save as", NULL }, | 1243 | "Save as", "Quit"); |
1259 | { "Quit", NULL }, | ||
1260 | }; | ||
1261 | |||
1262 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
1263 | NULL, NULL, NULL, NULL); | ||
1264 | 1244 | ||
1265 | result=menu_show(m); | 1245 | result = rb->do_menu(&menu, NULL, NULL, false); |
1266 | 1246 | ||
1267 | switch (result) { | 1247 | switch (result) { |
1268 | case 0: /* Save new game */ | 1248 | case 0: /* Save new game */ |
@@ -1281,8 +1261,6 @@ int sudoku_edit_menu(struct sudoku_state_t* state) | |||
1281 | break; | 1261 | break; |
1282 | } | 1262 | } |
1283 | 1263 | ||
1284 | menu_exit(m); | ||
1285 | |||
1286 | return result; | 1264 | return result; |
1287 | } | 1265 | } |
1288 | 1266 | ||
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 2fa841b314..34cb94d9ae 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c | |||
@@ -20,7 +20,6 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "lib/oldmenuapi.h" | ||
24 | #include "lib/helper.h" | 23 | #include "lib/helper.h" |
25 | 24 | ||
26 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
@@ -406,11 +405,10 @@ static bool test_speed(void) | |||
406 | /* this is the plugin entry point */ | 405 | /* this is the plugin entry point */ |
407 | enum plugin_status plugin_start(const void* parameter) | 406 | enum plugin_status plugin_start(const void* parameter) |
408 | { | 407 | { |
409 | static const struct menu_item items[] = { | 408 | MENUITEM_STRINGLIST(menu, "Test Disk Menu", NULL, |
410 | { "Disk speed", test_speed }, | 409 | "Disk speed", "Write & verify"); |
411 | { "Write & verify", test_fs }, | 410 | int selected=0; |
412 | }; | 411 | bool quit = false; |
413 | int m; | ||
414 | int align; | 412 | int align; |
415 | DIR *dir; | 413 | DIR *dir; |
416 | 414 | ||
@@ -440,10 +438,21 @@ enum plugin_status plugin_start(const void* parameter) | |||
440 | /* Turn off backlight timeout */ | 438 | /* Turn off backlight timeout */ |
441 | backlight_force_on(); /* backlight control in lib/helper.c */ | 439 | backlight_force_on(); /* backlight control in lib/helper.c */ |
442 | 440 | ||
443 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, | 441 | while(!quit) |
444 | NULL, NULL, NULL); | 442 | { |
445 | menu_run(m); | 443 | switch(rb->do_menu(&menu, &selected, NULL, false)) |
446 | menu_exit(m); | 444 | { |
445 | case 0: | ||
446 | test_speed(); | ||
447 | break; | ||
448 | case 1: | ||
449 | test_fs(); | ||
450 | break; | ||
451 | default: | ||
452 | quit = true; | ||
453 | break; | ||
454 | } | ||
455 | } | ||
447 | 456 | ||
448 | /* Turn on backlight timeout (revert to settings) */ | 457 | /* Turn on backlight timeout (revert to settings) */ |
449 | backlight_use_settings(); /* backlight control in lib/helper.c */ | 458 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c index edfe261ab9..45e1e7822b 100644 --- a/apps/plugins/test_sampr.c +++ b/apps/plugins/test_sampr.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/oldmenuapi.h" | ||
23 | 22 | ||
24 | /* This plugin generates a 1kHz tone + noise in order to quickly verify | 23 | /* This plugin generates a 1kHz tone + noise in order to quickly verify |
25 | * hardware samplerate setup is operating correctly. | 24 | * hardware samplerate setup is operating correctly. |
@@ -285,32 +284,23 @@ enum plugin_status plugin_start(const void *parameter) | |||
285 | MENU_QUIT, | 284 | MENU_QUIT, |
286 | }; | 285 | }; |
287 | 286 | ||
288 | static const struct menu_item items[] = | 287 | MENUITEM_STRINGLIST(menu, "Test Sampr Menu", NULL, |
289 | { | ||
290 | #ifndef HAVE_VOLUME_IN_LIST | 288 | #ifndef HAVE_VOLUME_IN_LIST |
291 | [MENU_VOL_SET] = | 289 | "Set Volume", |
292 | { "Set Volume", NULL }, | ||
293 | #endif /* HAVE_VOLUME_IN_LIST */ | 290 | #endif /* HAVE_VOLUME_IN_LIST */ |
294 | [MENU_SAMPR_SET] = | 291 | "Set Samplerate", "Quit"); |
295 | { "Set Samplerate", NULL }, | ||
296 | [MENU_QUIT] = | ||
297 | { "Quit", NULL }, | ||
298 | }; | ||
299 | 292 | ||
300 | bool exit = false; | 293 | bool exit = false; |
301 | int m; | 294 | int selected = 0; |
302 | 295 | ||
303 | /* Disable all talking before initializing IRAM */ | 296 | /* Disable all talking before initializing IRAM */ |
304 | rb->talk_disable(true); | 297 | rb->talk_disable(true); |
305 | 298 | ||
306 | PLUGIN_IRAM_INIT(rb); | 299 | PLUGIN_IRAM_INIT(rb); |
307 | 300 | ||
308 | m = menu_init(items, ARRAYLEN(items), | ||
309 | NULL, NULL, NULL, NULL); | ||
310 | |||
311 | while (!exit) | 301 | while (!exit) |
312 | { | 302 | { |
313 | int result = menu_show(m); | 303 | int result = rb->do_menu(&menu, &selected, NULL, false); |
314 | 304 | ||
315 | switch (result) | 305 | switch (result) |
316 | { | 306 | { |
@@ -329,8 +319,6 @@ enum plugin_status plugin_start(const void *parameter) | |||
329 | } | 319 | } |
330 | } | 320 | } |
331 | 321 | ||
332 | menu_exit(m); | ||
333 | |||
334 | rb->talk_disable(false); | 322 | rb->talk_disable(false); |
335 | 323 | ||
336 | return PLUGIN_OK; | 324 | return PLUGIN_OK; |
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index e17033fcd1..e3d0903d01 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include <ctype.h> | 23 | #include <ctype.h> |
24 | #include "lib/playback_control.h" | 24 | #include "lib/playback_control.h" |
25 | #include "lib/oldmenuapi.h" | ||
26 | 25 | ||
27 | PLUGIN_HEADER | 26 | PLUGIN_HEADER |
28 | 27 | ||
@@ -1448,30 +1447,37 @@ static bool autoscroll_speed_setting(void) | |||
1448 | &prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); | 1447 | &prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); |
1449 | } | 1448 | } |
1450 | 1449 | ||
1450 | MENUITEM_FUNCTION(encoding_item, 0, "Encoding", encoding_setting, | ||
1451 | NULL, NULL, Icon_NOICON); | ||
1452 | MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", word_wrap_setting, | ||
1453 | NULL, NULL, Icon_NOICON); | ||
1454 | MENUITEM_FUNCTION(line_mode_item, 0, "Line Mode", line_mode_setting, | ||
1455 | NULL, NULL, Icon_NOICON); | ||
1456 | MENUITEM_FUNCTION(view_mode_item, 0, "Wide View", view_mode_setting, | ||
1457 | NULL, NULL, Icon_NOICON); | ||
1458 | #ifdef HAVE_LCD_BITMAP | ||
1459 | MENUITEM_FUNCTION(scrollbar_item, 0, "Show Scrollbar", scrollbar_setting, | ||
1460 | NULL, NULL, Icon_NOICON); | ||
1461 | MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", page_mode_setting, | ||
1462 | NULL, NULL, Icon_NOICON); | ||
1463 | #endif | ||
1464 | MENUITEM_FUNCTION(scroll_mode_item, 0, "Scroll Mode", scroll_mode_setting, | ||
1465 | NULL, NULL, Icon_NOICON); | ||
1466 | MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed", | ||
1467 | autoscroll_speed_setting, NULL, NULL, Icon_NOICON); | ||
1468 | MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, | ||
1469 | &encoding_item, &word_wrap_item, &line_mode_item, &view_mode_item, | ||
1470 | #ifdef HAVE_LCD_BITMAP | ||
1471 | &scrollbar_item, &page_mode_item, | ||
1472 | #endif | ||
1473 | &scroll_mode_item, &autoscroll_speed_item); | ||
1474 | |||
1451 | static bool viewer_options_menu(void) | 1475 | static bool viewer_options_menu(void) |
1452 | { | 1476 | { |
1453 | int m; | ||
1454 | bool result; | 1477 | bool result; |
1478 | result = (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB); | ||
1455 | 1479 | ||
1456 | static const struct menu_item items[] = { | ||
1457 | {"Encoding", encoding_setting }, | ||
1458 | {"Word Wrap", word_wrap_setting }, | ||
1459 | {"Line Mode", line_mode_setting }, | ||
1460 | {"Wide View", view_mode_setting }, | ||
1461 | #ifdef HAVE_LCD_BITMAP | 1480 | #ifdef HAVE_LCD_BITMAP |
1462 | {"Show Scrollbar", scrollbar_setting }, | ||
1463 | {"Overlap Pages", page_mode_setting }, | ||
1464 | #endif | ||
1465 | {"Scroll Mode", scroll_mode_setting}, | ||
1466 | {"Auto-Scroll Speed", autoscroll_speed_setting }, | ||
1467 | }; | ||
1468 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
1469 | NULL, NULL, NULL, NULL); | ||
1470 | |||
1471 | result = menu_run(m); | ||
1472 | menu_exit(m); | ||
1473 | #ifdef HAVE_LCD_BITMAP | ||
1474 | |||
1475 | /* Show-scrollbar mode for current view-width mode */ | 1481 | /* Show-scrollbar mode for current view-width mode */ |
1476 | init_need_scrollbar(); | 1482 | init_need_scrollbar(); |
1477 | #endif | 1483 | #endif |
@@ -1480,23 +1486,15 @@ static bool viewer_options_menu(void) | |||
1480 | 1486 | ||
1481 | static void viewer_menu(void) | 1487 | static void viewer_menu(void) |
1482 | { | 1488 | { |
1483 | int m; | ||
1484 | int result; | 1489 | int result; |
1485 | static const struct menu_item items[] = { | 1490 | MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL, |
1486 | {"Quit", NULL }, | 1491 | "Return", "Viewer Options", |
1487 | {"Viewer Options", NULL }, | 1492 | "Show Playback Menu", "Quit"); |
1488 | {"Show Playback Menu", NULL }, | ||
1489 | {"Return", NULL }, | ||
1490 | }; | ||
1491 | 1493 | ||
1492 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 1494 | result = rb->do_menu(&menu, NULL, NULL, false); |
1493 | result=menu_show(m); | ||
1494 | switch (result) | 1495 | switch (result) |
1495 | { | 1496 | { |
1496 | case 0: /* quit */ | 1497 | case 0: /* return */ |
1497 | menu_exit(m); | ||
1498 | viewer_exit(NULL); | ||
1499 | done = true; | ||
1500 | break; | 1498 | break; |
1501 | case 1: /* change settings */ | 1499 | case 1: /* change settings */ |
1502 | done = viewer_options_menu(); | 1500 | done = viewer_options_menu(); |
@@ -1504,10 +1502,11 @@ static void viewer_menu(void) | |||
1504 | case 2: /* playback control */ | 1502 | case 2: /* playback control */ |
1505 | playback_control(NULL); | 1503 | playback_control(NULL); |
1506 | break; | 1504 | break; |
1507 | case 3: /* return */ | 1505 | case 3: /* quit */ |
1506 | viewer_exit(NULL); | ||
1507 | done = true; | ||
1508 | break; | 1508 | break; |
1509 | } | 1509 | } |
1510 | menu_exit(m); | ||
1511 | viewer_draw(col); | 1510 | viewer_draw(col); |
1512 | } | 1511 | } |
1513 | 1512 | ||
diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c index b7d20ecf5e..e27770c70c 100644 --- a/apps/plugins/zxbox/spmain.c +++ b/apps/plugins/zxbox/spmain.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "zxmisc.h" | 20 | #include "zxmisc.h" |
21 | #include "zxconfig.h" | 21 | #include "zxconfig.h" |
22 | #include "lib/configfile.h" | 22 | #include "lib/configfile.h" |
23 | #include "lib/oldmenuapi.h" | ||
24 | 23 | ||
25 | #include "spperif.h" | 24 | #include "spperif.h" |
26 | #include "z80.h" | 25 | #include "z80.h" |
@@ -134,25 +133,18 @@ int spcf_read_conf_file(const char *filename) | |||
134 | 133 | ||
135 | /* set keys */ | 134 | /* set keys */ |
136 | static void set_keys(void){ | 135 | static void set_keys(void){ |
137 | int m; | ||
138 | char c; | 136 | char c; |
137 | int selected=0; | ||
139 | int result; | 138 | int result; |
140 | int menu_quit=0; | 139 | int menu_quit=0; |
141 | static const struct menu_item items[] = { | 140 | MENUITEM_STRINGLIST(menu, "Custom keymap", NULL, |
142 | { "Map Up key", NULL }, | 141 | "Map Up key", "Map Down key", "Map Left key", |
143 | { "Map Down key", NULL }, | 142 | "Map Right key", "Map Fire/Jump key"); |
144 | { "Map Left key", NULL }, | ||
145 | { "Map Right key", NULL }, | ||
146 | { "Map Fire/Jump key", NULL }, | ||
147 | }; | ||
148 | |||
149 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
150 | NULL, NULL, NULL, NULL); | ||
151 | 143 | ||
152 | rb->button_clear_queue(); | 144 | rb->button_clear_queue(); |
153 | 145 | ||
154 | while (!menu_quit) { | 146 | while (!menu_quit) { |
155 | result=menu_show(m); | 147 | result = rb->do_menu(&menu, &selected, NULL, false); |
156 | 148 | ||
157 | switch(result) | 149 | switch(result) |
158 | { | 150 | { |
@@ -161,7 +153,7 @@ static void set_keys(void){ | |||
161 | { | 153 | { |
162 | settings.keymap[0]=c; | 154 | settings.keymap[0]=c; |
163 | } | 155 | } |
164 | break; | 156 | break; |
165 | case 1: | 157 | case 1: |
166 | if (!zx_kbd_input((char*) &c)) | 158 | if (!zx_kbd_input((char*) &c)) |
167 | { | 159 | { |
@@ -191,41 +183,33 @@ static void set_keys(void){ | |||
191 | break; | 183 | break; |
192 | } | 184 | } |
193 | } | 185 | } |
194 | |||
195 | menu_exit(m); | ||
196 | } | 186 | } |
197 | 187 | ||
198 | /* select predefined keymap */ | 188 | /* select predefined keymap */ |
199 | static void select_keymap(void){ | 189 | static void select_keymap(void){ |
200 | int m; | 190 | int selected=0; |
201 | int result; | 191 | int result; |
202 | int menu_quit=0; | 192 | int menu_quit=0; |
203 | static const struct menu_item items[] = { | 193 | MENUITEM_STRINGLIST(menu, "Predefined keymap", NULL, |
204 | { "2w90z", NULL }, | 194 | "2w90z", "qaopS", "7658S"); |
205 | { "qaopS", NULL }, | ||
206 | { "7658S", NULL }, | ||
207 | }; | ||
208 | |||
209 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
210 | NULL, NULL, NULL, NULL); | ||
211 | 195 | ||
212 | rb->button_clear_queue(); | 196 | rb->button_clear_queue(); |
213 | 197 | ||
214 | while (!menu_quit) { | 198 | while (!menu_quit) { |
215 | result=menu_show(m); | 199 | result = rb->do_menu(&menu, &selected, NULL, false); |
216 | 200 | ||
217 | switch(result) | 201 | switch(result) |
218 | { | 202 | { |
219 | case 0: | 203 | case 0: |
220 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[0].desc , sizeof(items[0].desc)); | 204 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)"2w90z" , 5); |
221 | menu_quit=1; | 205 | menu_quit=1; |
222 | break; | 206 | break; |
223 | case 1: | 207 | case 1: |
224 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[1].desc , sizeof(items[1].desc)); | 208 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)"qaopS" , 5); |
225 | menu_quit=1; | 209 | menu_quit=1; |
226 | break; | 210 | break; |
227 | case 2: | 211 | case 2: |
228 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[2].desc , sizeof(items[2].desc)); | 212 | rb->memcpy ( (void*)&settings.keymap[0] , (void*)"7658S" , 5); |
229 | menu_quit=1; | 213 | menu_quit=1; |
230 | break; | 214 | break; |
231 | default: | 215 | default: |
@@ -233,8 +217,6 @@ static void select_keymap(void){ | |||
233 | break; | 217 | break; |
234 | } | 218 | } |
235 | } | 219 | } |
236 | |||
237 | menu_exit(m); | ||
238 | } | 220 | } |
239 | 221 | ||
240 | /* options menu */ | 222 | /* options menu */ |
@@ -243,20 +225,15 @@ static void options_menu(void){ | |||
243 | { "No", -1 }, | 225 | { "No", -1 }, |
244 | { "Yes", -1 }, | 226 | { "Yes", -1 }, |
245 | }; | 227 | }; |
246 | int m; | 228 | int selected; |
247 | int result; | 229 | int result; |
248 | int menu_quit=0; | 230 | int menu_quit=0; |
249 | int new_setting; | 231 | int new_setting; |
250 | static const struct menu_item items[] = { | 232 | MENUITEM_STRINGLIST(menu, "Options", NULL, |
251 | { "Map Keys to kempston", NULL }, | 233 | "Map Keys to kempston", "Display Speed", |
252 | { "Display Speed", NULL }, | 234 | "Invert Colors", "Frameskip", "Sound", "Volume", |
253 | { "Invert Colors", NULL }, | 235 | "Predefined keymap", "Custom keymap"); |
254 | { "Frameskip", NULL }, | 236 | |
255 | { "Sound", NULL }, | ||
256 | { "Volume", NULL }, | ||
257 | { "Predefined keymap", NULL }, | ||
258 | { "Custom keymap", NULL }, | ||
259 | }; | ||
260 | static struct opt_items frameskip_items[] = { | 237 | static struct opt_items frameskip_items[] = { |
261 | { "0", -1 }, | 238 | { "0", -1 }, |
262 | { "1", -1 }, | 239 | { "1", -1 }, |
@@ -269,15 +246,12 @@ static void options_menu(void){ | |||
269 | { "8", -1 }, | 246 | { "8", -1 }, |
270 | { "9", -1 }, | 247 | { "9", -1 }, |
271 | }; | 248 | }; |
272 | |||
273 | 249 | ||
274 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
275 | NULL, NULL, NULL, NULL); | ||
276 | 250 | ||
277 | rb->button_clear_queue(); | 251 | rb->button_clear_queue(); |
278 | 252 | ||
279 | while (!menu_quit) { | 253 | while (!menu_quit) { |
280 | result=menu_show(m); | 254 | result = rb->do_menu(&menu, &selected, NULL, false); |
281 | 255 | ||
282 | switch(result) | 256 | switch(result) |
283 | { | 257 | { |
@@ -287,7 +261,7 @@ static void options_menu(void){ | |||
287 | no_yes, 2, NULL); | 261 | no_yes, 2, NULL); |
288 | if (new_setting != settings.kempston ) | 262 | if (new_setting != settings.kempston ) |
289 | settings.kempston=new_setting; | 263 | settings.kempston=new_setting; |
290 | break; | 264 | break; |
291 | case 1: | 265 | case 1: |
292 | new_setting = settings.showfps; | 266 | new_setting = settings.showfps; |
293 | rb->set_option("Display Speed",&new_setting,INT, | 267 | rb->set_option("Display Speed",&new_setting,INT, |
@@ -339,8 +313,6 @@ static void options_menu(void){ | |||
339 | break; | 313 | break; |
340 | } | 314 | } |
341 | } | 315 | } |
342 | |||
343 | menu_exit(m); | ||
344 | } | 316 | } |
345 | 317 | ||
346 | /* menu */ | 318 | /* menu */ |
@@ -349,29 +321,21 @@ static bool zxbox_menu(void) | |||
349 | #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR | 321 | #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR |
350 | rb->pcm_play_stop(); | 322 | rb->pcm_play_stop(); |
351 | #endif | 323 | #endif |
352 | int m; | 324 | int selected=0; |
353 | int result; | 325 | int result; |
354 | int menu_quit=0; | 326 | int menu_quit=0; |
355 | int exit=0; | 327 | int exit=0; |
356 | char c; | 328 | char c; |
357 | static const struct menu_item items[] = { | 329 | MENUITEM_STRINGLIST(menu, "ZXBox Menu", NULL, |
358 | { "VKeyboard", NULL }, | 330 | "VKeyboard", "Play/Pause Tape", |
359 | { "Play/Pause Tape", NULL }, | 331 | "Save quick snapshot", "Load quick snapshot", |
360 | { "Save quick snapshot", NULL }, | 332 | "Save Snapshot", "Toggle \"fast\" mode", |
361 | { "Load quick snapshot", NULL }, | 333 | "Options", "Quit"); |
362 | { "Save Snapshot", NULL }, | ||
363 | { "Toggle \"fast\" mode", NULL }, | ||
364 | { "Options", NULL }, | ||
365 | { "Quit", NULL }, | ||
366 | }; | ||
367 | |||
368 | m = menu_init(items, sizeof(items) / sizeof(*items), | ||
369 | NULL, NULL, NULL, NULL); | ||
370 | 334 | ||
371 | rb->button_clear_queue(); | 335 | rb->button_clear_queue(); |
372 | 336 | ||
373 | while (!menu_quit) { | 337 | while (!menu_quit) { |
374 | result=menu_show(m); | 338 | result = rb->do_menu(&menu, &selected, NULL, false); |
375 | 339 | ||
376 | switch(result) | 340 | switch(result) |
377 | { | 341 | { |
@@ -415,7 +379,6 @@ static bool zxbox_menu(void) | |||
415 | } | 379 | } |
416 | } | 380 | } |
417 | 381 | ||
418 | menu_exit(m); | ||
419 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) | 382 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) |
420 | rb->cpu_boost(true); | 383 | rb->cpu_boost(true); |
421 | #endif | 384 | #endif |