1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2009-06-16 04:25:21 +00:00
parent cb57a568e8
commit af9f405651
22 changed files with 729 additions and 1569 deletions

View file

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

View file

@ -39,7 +39,6 @@
#include "i_system.h" #include "i_system.h"
#include "hu_stuff.h" #include "hu_stuff.h"
#include "st_stuff.h" #include "st_stuff.h"
#include "lib/oldmenuapi.h"
#include "lib/helper.h" #include "lib/helper.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -217,8 +216,8 @@ const unsigned char wads_builtin[7][30] =
}; };
int namemap[7]; int namemap[7];
static struct menu_item *addons; static char **addons;
static struct menu_item *demolmp; static char **demolmp;
char addon[200]; char addon[200];
// This sets up the base game and builds up myargv/c // This sets up the base game and builds up myargv/c
bool Dhandle_ver (int dver) bool Dhandle_ver (int dver)
@ -274,14 +273,14 @@ bool Dhandle_ver (int dver)
if(argvlist.addonnum) if(argvlist.addonnum)
{ {
snprintf(addon,sizeof(addon),"%s%s", GAMEBASE"addons/", addons[argvlist.addonnum].desc); snprintf(addon,sizeof(addon),"%s%s", GAMEBASE"addons/", addons[argvlist.addonnum]);
D_AddFile(addon,source_pwad); D_AddFile(addon,source_pwad);
modifiedgame = true; modifiedgame = true;
} }
if(argvlist.demonum) if(argvlist.demonum)
{ {
snprintf(addon, sizeof(addon),"%s%s", GAMEBASE"demos/", demolmp[argvlist.demonum].desc); snprintf(addon, sizeof(addon),"%s%s", GAMEBASE"demos/", demolmp[argvlist.demonum]);
D_AddFile(addon, source_lmp); D_AddFile(addon, source_lmp);
G_DeferedPlayDemo(addon); G_DeferedPlayDemo(addon);
singledemo = true; // quit after one demo singledemo = true; // quit after one demo
@ -323,21 +322,20 @@ int Dbuild_base (struct opt_items *names)
// This is a general function that takes in a menu_item structure and makes a list // This is a general function that takes in a menu_item structure and makes a list
// of files within it based on matching the string stringmatch to the files. // of files within it based on matching the string stringmatch to the files.
int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory, char *stringmatch) int Dbuild_filelistm(char ***names, char *firstentry, char *directory, char *stringmatch)
{ {
int i=0; int i=0;
DIR *filedir; DIR *filedir;
struct dirent *dptr; struct dirent *dptr;
char *startpt; char *startpt;
struct menu_item *temp; char **temp;
filedir=rb->opendir(directory); filedir=rb->opendir(directory);
if(filedir==NULL) if(filedir==NULL)
{ {
temp=malloc(sizeof(struct menu_item)); temp=malloc(sizeof(char *));
temp[0].desc=firstentry; temp[0]=firstentry;
temp[0].function=0;
*names=temp; *names=temp;
return 1; return 1;
} }
@ -351,9 +349,8 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
filedir=rb->opendir(directory); filedir=rb->opendir(directory);
i++; i++;
temp=malloc(i*sizeof(struct menu_item)); temp=malloc(i*sizeof(char *));
temp[0].desc=firstentry; temp[0]=firstentry;
temp[0].function=0;
i=1; i=1;
while((dptr=rb->readdir(filedir))) while((dptr=rb->readdir(filedir)))
@ -362,8 +359,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
{ {
startpt=malloc(strlen(dptr->d_name)*sizeof(char)); startpt=malloc(strlen(dptr->d_name)*sizeof(char));
strcpy(startpt,dptr->d_name); strcpy(startpt,dptr->d_name);
temp[i].desc=startpt; temp[i]=startpt;
temp[i].function=0;
i++; i++;
} }
} }
@ -444,7 +440,7 @@ static int translatekey(int key)
int Oset_keys() int Oset_keys()
{ {
int m, result; int selected=0, result;
int menuquit=0; int menuquit=0;
@ -483,36 +479,24 @@ int Oset_keys()
int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys); int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys);
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Set Keys", NULL,
{ "Game Right", NULL }, "Game Right", "Game Left", "Game Up", "Game Down",
{ "Game Left", NULL }, "Game Shoot", "Game Open", "Game Strafe",
{ "Game Up", NULL }, "Game Weapon", "Game Automap");
{ "Game Down", NULL },
{ "Game Shoot", NULL },
{ "Game Open", NULL },
{ "Game Strafe", NULL },
{ "Game Weapon", NULL },
{ "Game Automap", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
while(!menuquit) while(!menuquit)
{ {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
if(result<0) if(result<0)
menuquit=1; menuquit=1;
else else
{ {
*keys[result]=translatekey(*keys[result]); *keys[result]=translatekey(*keys[result]);
rb->set_option(items[result].desc, keys[result], INT, doomkeys, numdoomkeys, NULL ); rb->set_option(menu_[result], keys[result], INT, doomkeys, numdoomkeys, NULL );
*keys[result]=translatekey(*keys[result]); *keys[result]=translatekey(*keys[result]);
} }
} }
menu_exit(m);
return (1); return (1);
} }
@ -525,24 +509,17 @@ static bool Doptions()
{ "On", -1 }, { "On", -1 },
}; };
int m, result; int selected=0, result;
int menuquit=0; int menuquit=0;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Options", NULL,
{ "Set Keys", NULL }, "Set Keys", "Sound", "Timedemo", "Player Bobbing",
{ "Sound", NULL }, "Weapon Recoil", "Translucency", "Fake Contrast",
{ "Timedemo", NULL }, "Always Run", "Headsup Display", "Statusbar Always Red",
{ "Player Bobbing", NULL },
{ "Weapon Recoil", NULL },
{ "Translucency", NULL },
{ "Fake Contrast", NULL },
{ "Always Run", NULL },
{ "Headsup Display", NULL },
{ "Statusbar Always Red", NULL },
#if(LCD_HEIGHT>LCD_WIDTH) #if(LCD_HEIGHT>LCD_WIDTH)
{ "Rotate Screen 90 deg", NULL }, "Rotate Screen 90 deg",
#endif #endif
}; );
void *options[]={ void *options[]={
&enable_sound, &enable_sound,
@ -559,36 +536,48 @@ static bool Doptions()
#endif #endif
}; };
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
while(!menuquit) while(!menuquit)
{ {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
if(result==0) if(result==0)
Oset_keys(); Oset_keys();
else if (result > 0) else if (result > 0)
rb->set_option(items[result].desc, options[result-1], INT, onoff, 2, NULL ); rb->set_option(menu_[result], options[result-1], INT, onoff, 2, NULL );
else else
menuquit=1; menuquit=1;
} }
menu_exit(m);
return (1); return (1);
} }
int menuchoice(struct menu_item *menu, int items) char* choice_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{ {
int m, result; char **names = (char **) data;
(void) buffer;
m = menu_init(menu, items,NULL, NULL, NULL, NULL); (void) buffer_len;
return names[selected_item];
}
int list_action_callback(int action, struct gui_synclist *lists)
{
(void) lists;
if (action == ACTION_STD_OK)
return ACTION_STD_CANCEL;
return action;
}
bool menuchoice(char **names, int count, int *selected)
{
struct simplelist_info info;
rb->simplelist_info_init(&info, NULL, count, (void*)names);
info.selection = *selected;
info.get_name = choice_get_name;
info.action_callback = list_action_callback;
if(rb->simplelist_show_list(&info))
return true;
result= menu_show(m); if(info.selection<count && info.selection>=0)
menu_exit(m); *selected = info.selection;
if(result<items && result>=0) return false;
return result;
return 0;
} }
// //
@ -596,22 +585,16 @@ int menuchoice(struct menu_item *menu, int items)
// //
int doom_menu() int doom_menu()
{ {
int m; int selected=0, result;
int result;
int status; int status;
int gamever; int gamever;
bool menuquit=0; bool menuquit=0;
static struct opt_items names[7]; static struct opt_items names[7];
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Doom Menu", NULL,
{ "Game", NULL }, "Game", "Addons", "Demos",
{ "Addons", NULL }, "Options", "Play Game", "Quit");
{ "Demos", NULL },
{ "Options", NULL },
{ "Play Game", NULL },
{ "Quit", NULL },
};
if( (status=Dbuild_base(names)) == 0 ) // Build up the base wad files (select last added file) if( (status=Dbuild_base(names)) == 0 ) // Build up the base wad files (select last added file)
{ {
@ -632,23 +615,20 @@ int doom_menu()
while (rb->button_get(false) != BUTTON_NONE) while (rb->button_get(false) != BUTTON_NONE)
rb->yield(); rb->yield();
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
while(!menuquit) while(!menuquit)
{ {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) { switch (result) {
case 0: /* Game picker */ case 0: /* Game picker */
rb->set_option("Game WAD", &gamever, INT, names, status, NULL ); rb->set_option("Game WAD", &gamever, INT, names, status, NULL );
break; break;
case 1: /* Addon picker */ case 1: /* Addon picker */
argvlist.addonnum=menuchoice(addons,numadd); menuchoice(addons,numadd,&argvlist.addonnum);
break; break;
case 2: /* Demos */ case 2: /* Demos */
argvlist.demonum=menuchoice(demolmp,numdemos); menuchoice(demolmp,numdemos,&argvlist.demonum);
break; break;
case 3: /* Options */ case 3: /* Options */
@ -669,8 +649,6 @@ int doom_menu()
} }
} }
menu_exit(m);
return (gamever); return (gamever);
} }

View file

@ -19,7 +19,6 @@
* *
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "lib/oldmenuapi.h"
#include "lib/helper.h" #include "lib/helper.h"
#include "lib/playback_control.h" #include "lib/playback_control.h"
@ -287,17 +286,10 @@ static const struct opt_items fps_settings[9] = {
int fps_values[9] = { int fps_values[9] = {
20, 25, 30, 35, 40, 45, 50, 55, 60 }; 20, 25, 30, 35, 40, 45, 50, 55, 60 };
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Fireworks Menu", NULL,
{ "Start Demo", NULL }, "Start Demo", "Auto-Fire", "Particles Per Firework",
{ "Auto-Fire", NULL }, "Particle Life", "Gravity", "Show Rockets",
{ "Particles Per Firework", NULL }, "FPS (Speed)", "Playback Control", "Quit");
{ "Particle Life", NULL },
{ "Gravity", NULL },
{ "Show Rockets", NULL },
{ "FPS (Speed)", NULL },
{ "Playback Control", NULL },
{ "Quit", NULL }
};
/* called on startup. initializes all variables, etc */ /* called on startup. initializes all variables, etc */
void init_all(void) void init_all(void)
@ -348,7 +340,7 @@ void init_rocket(int rocket)
/* startup/configuration menu. */ /* startup/configuration menu. */
void fireworks_menu(void) void fireworks_menu(void)
{ {
int m, result; int selected = 0, result;
bool menu_quit = false; bool menu_quit = false;
rb->lcd_setfont(FONT_UI); rb->lcd_setfont(FONT_UI);
@ -359,14 +351,11 @@ void fireworks_menu(void)
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_update(); rb->lcd_update();
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while(!menu_quit) while(!menu_quit)
{ {
result = menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
@ -419,8 +408,6 @@ void fireworks_menu(void)
break; break;
} }
} }
menu_exit(m);
} }
/* this is the plugin entry point */ /* this is the plugin entry point */

View file

@ -330,59 +330,6 @@ enum game_type {
GAME_TYPE_PUZZLE GAME_TYPE_PUZZLE
}; };
/* menu values */
#define FONT_HEIGHT 8
#define MAX_MITEMS 6
#define MENU_WIDTH 100
/* menu results */
enum menu_result {
MRES_NONE,
MRES_NEW,
MRES_PUZZLE,
MRES_SAVE,
MRES_RESUME,
MRES_SCORES,
MRES_HELP,
MRES_QUIT,
MRES_PLAYBACK,
MRES_EXIT
};
/* menu commands */
enum menu_cmd {
MCMD_NONE,
MCMD_NEXT,
MCMD_PREV,
MCMD_SELECT
};
/* menus */
struct jewels_menu {
char *title;
bool hasframe;
int selected;
int itemcnt;
struct jewels_menuitem {
char *text;
enum menu_result res;
} items[MAX_MITEMS];
} bjmenu[] = {
{"Jewels", false, 0, 6,
{{"New Game", MRES_NEW},
{"Puzzle", MRES_PUZZLE},
{"Resume Saved Game", MRES_RESUME},
{"High Scores", MRES_SCORES},
{"Help", MRES_HELP},
{"Quit", MRES_QUIT}}},
{"Menu", true, 0, 5,
{{"Audio Playback", MRES_PLAYBACK },
{"Resume Game", MRES_RESUME},
{"Save Game", MRES_SAVE},
{"End Game", MRES_QUIT},
{"Exit Jewels", MRES_EXIT}}}
};
/* external bitmaps */ /* external bitmaps */
extern const fb_data jewels[]; extern const fb_data jewels[];
@ -676,73 +623,6 @@ static void jewels_drawboard(struct game_context* bj) {
rb->lcd_update(); rb->lcd_update();
} }
/*****************************************************************************
* jewels_showmenu() displays the chosen menu after performing the chosen
* menu command.
******************************************************************************/
static enum menu_result jewels_showmenu(struct jewels_menu* menu,
enum menu_cmd cmd) {
int i;
int w, h;
int firstline;
int adj;
int extraline = LCD_HEIGHT <= ((menu->itemcnt+2)*FONT_HEIGHT) ? 0 : 1;
/* handle menu command */
switch(cmd) {
case MCMD_NEXT:
menu->selected = (menu->selected+1)%menu->itemcnt;
break;
case MCMD_PREV:
menu->selected = (menu->selected-1+menu->itemcnt)%menu->itemcnt;
break;
case MCMD_SELECT:
return menu->items[menu->selected].res;
default:
break;
}
/* clear menu area */
firstline = (LCD_HEIGHT/FONT_HEIGHT-(menu->itemcnt+3))/2;
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect((LCD_WIDTH-MENU_WIDTH)/2, firstline*FONT_HEIGHT,
MENU_WIDTH, (menu->itemcnt+3)*FONT_HEIGHT);
rb->lcd_set_drawmode(DRMODE_SOLID);
if(menu->hasframe) {
rb->lcd_drawrect((LCD_WIDTH-MENU_WIDTH)/2-1, firstline*FONT_HEIGHT-1,
MENU_WIDTH+2, (menu->itemcnt+3)*FONT_HEIGHT+2);
rb->lcd_hline((LCD_WIDTH-MENU_WIDTH)/2-1,
(LCD_WIDTH-MENU_WIDTH)/2-1+MENU_WIDTH+2,
(firstline+1)*FONT_HEIGHT);
}
/* draw menu items */
rb->lcd_getstringsize(menu->title, &w, &h);
rb->lcd_putsxy((LCD_WIDTH-w)/2, firstline*FONT_HEIGHT, menu->title);
for(i=0; i<menu->itemcnt; i++) {
if(i == menu->selected) {
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
}
rb->lcd_putsxy((LCD_WIDTH-MENU_WIDTH)/2,
(firstline+i+1+extraline)*FONT_HEIGHT,
menu->items[i].text);
if(i == menu->selected) {
rb->lcd_set_drawmode(DRMODE_SOLID);
}
}
adj = (firstline == 0 ? 0 : 1);
rb->lcd_update_rect((LCD_WIDTH-MENU_WIDTH)/2-1, firstline*FONT_HEIGHT-adj,
MENU_WIDTH+2, (menu->itemcnt+3)*FONT_HEIGHT+2*adj);
return MRES_NONE;
}
/***************************************************************************** /*****************************************************************************
* jewels_putjewels() makes the jewels fall to fill empty spots and adds * jewels_putjewels() makes the jewels fall to fill empty spots and adds
* new random jewels at the empty spots at the top of each row. * new random jewels at the empty spots at the top of each row.
@ -1456,19 +1336,37 @@ static void jewels_callback(void* param) {
} }
} }
/*****************************************************************************
* jewels_displayscores() displays the high scores
******************************************************************************/
static char * scores_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
struct game_context* bj = (struct game_context*)data;
rb->snprintf(buffer, buffer_len, "#%02d: %d",
selected_item+1, bj->highscores[selected_item]);
return buffer;
}
static void jewels_displayscores(struct game_context* bj)
{
struct simplelist_info info;
rb->simplelist_info_init(&info, "High Scores", NUM_SCORES, (void*)bj);
info.hide_selection = true;
info.get_name = scores_get_name;
rb->simplelist_show_list(&info);
}
/***************************************************************************** /*****************************************************************************
* jewels_main() is the main game subroutine, it returns the final game status. * jewels_main() is the main game subroutine, it returns the final game status.
******************************************************************************/ ******************************************************************************/
static int jewels_main(struct game_context* bj) { static int jewels_main(struct game_context* bj) {
int i, j;
int w, h; int w, h;
int button; int button;
struct viewport vp[NB_SCREENS];
char str[18]; char str[18];
bool startgame = false; bool inmenu = true;
bool inmenu = false;
bool selected = false; bool selected = false;
enum menu_cmd cmd = MCMD_NONE;
enum menu_result res;
/* the cursor coordinates */ /* the cursor coordinates */
int x=0, y=0; int x=0, y=0;
@ -1479,67 +1377,47 @@ static int jewels_main(struct game_context* bj) {
/******************** /********************
* menu * * menu *
********************/ ********************/
rb->lcd_clear_display(); MENUITEM_STRINGLIST(main_menu,"Jewels",NULL,
"New Game", "Puzzle", "Resume Saved Game",
"High Scores", "Help", "Quit");
FOR_NB_SCREENS(h)
{
rb->viewport_set_defaults(&vp[h], h);
#if (LCD_DEPTH >= 16) || defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH >= 16)
if (rb->screens[h]->depth >= 16)
{
vp->bg_pattern = LCD_RGBPACK(49, 26, 26);
vp->fg_pattern = LCD_RGBPACK(210, 181, 181);
}
#endif
}
while(!startgame) { while(inmenu) {
res = jewels_showmenu(&bjmenu[0], cmd);
cmd = MCMD_NONE;
rb->snprintf(str, 18, "High Score: %d", bj->highscores[0]); switch (rb->do_menu(&main_menu, NULL, vp, true)) {
rb->lcd_getstringsize(str, &w, &h); case 0:
rb->lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT-8, str); inmenu = false;
rb->lcd_update();
rb->yield();
switch(res) {
case MRES_NEW:
startgame = true;
bj->type = GAME_TYPE_NORMAL; bj->type = GAME_TYPE_NORMAL;
continue; break;
case MRES_PUZZLE: case 1:
startgame = true; inmenu = false;
bj->type = GAME_TYPE_PUZZLE; bj->type = GAME_TYPE_PUZZLE;
continue; break;
case MRES_RESUME: case 2:
if(!jewels_loadgame(bj)) { if(!jewels_loadgame(bj)) {
rb->splash(HZ*2, "Nothing to resume"); rb->splash(HZ*2, "Nothing to resume");
rb->lcd_clear_display();
} else { } else {
startgame = true; inmenu = false;
} }
continue; break;
case MRES_SCORES: case 3:
rb->lcd_clear_display(); jewels_displayscores(bj);
break;
/* room for a title? */ case 4:
j = 0;
if(LCD_HEIGHT-NUM_SCORES*8 >= 8) {
rb->snprintf(str, 12, "%s", "High Scores");
rb->lcd_getstringsize(str, &w, &h);
rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str);
j = 2;
}
/* print high scores */
for(i=0; i<NUM_SCORES; i++) {
rb->snprintf(str, 11, "#%02d: %d", i+1, bj->highscores[i]);
rb->lcd_puts(0, i+j, str);
}
rb->lcd_update();
while(true) {
button = rb->button_get(true);
if(button != BUTTON_NONE && !(button&BUTTON_REL)) break;
rb->yield();
}
rb->lcd_clear_display();
continue;
case MRES_HELP:
/* welcome screen to display key bindings */ /* welcome screen to display key bindings */
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->snprintf(str, 5, "%s", "Help"); rb->snprintf(str, 5, "%s", "Help");
@ -1694,54 +1572,17 @@ static int jewels_main(struct game_context* bj) {
if(button != BUTTON_NONE && !(button&BUTTON_REL)) break; if(button != BUTTON_NONE && !(button&BUTTON_REL)) break;
} }
rb->lcd_clear_display(); rb->lcd_clear_display();
continue; break;
case MRES_QUIT: case 5:
return BJ_QUIT; return BJ_QUIT;
case MENU_ATTACHED_USB:
jewels_callback(bj);
return BJ_USB;
default: default:
break;
}
/* handle menu button presses */
button = rb->button_get(true);
switch(button){
#ifdef JEWELS_SCROLLWHEEL
case JEWELS_PREV:
case (JEWELS_PREV|BUTTON_REPEAT):
#endif
case JEWELS_UP:
case (JEWELS_UP|BUTTON_REPEAT):
cmd = MCMD_PREV;
break;
#ifdef JEWELS_SCROLLWHEEL
case JEWELS_NEXT:
case (JEWELS_NEXT|BUTTON_REPEAT):
#endif
case JEWELS_DOWN:
case (JEWELS_DOWN|BUTTON_REPEAT):
cmd = MCMD_NEXT;
break;
case JEWELS_SELECT:
case JEWELS_RIGHT:
cmd = MCMD_SELECT;
break;
#ifdef JEWELS_CANCEL
#ifdef JEWELS_RC_CANCEL
case JEWELS_RC_CANCEL:
#endif
case JEWELS_CANCEL:
return BJ_QUIT; return BJ_QUIT;
#endif
default:
if(rb->default_event_handler_ex(button, jewels_callback,
(void*) bj) == SYS_USB_CONNECTED)
return BJ_USB;
break;
} }
} }
@ -1771,162 +1612,142 @@ static int jewels_main(struct game_context* bj) {
/********************** /**********************
* play * * play *
**********************/ **********************/
MENUITEM_STRINGLIST(ingame_menu,"Menu",NULL,
"Audio Playback", "Resume Game",
"Save Game", "End Game", "Exit Jewels");
selected = false;
while(true) { while(true) {
int no_movesavail = false; bool no_movesavail = false;
if(!inmenu) { while(inmenu) {
/* refresh the board */ switch (rb->do_menu(&ingame_menu, NULL, vp, true)) {
jewels_drawboard(bj); case 0:
/* display the cursor */
if(selected) {
rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
rb->lcd_fillrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
rb->lcd_set_drawmode(DRMODE_SOLID);
} else {
rb->lcd_drawrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
}
rb->lcd_update_rect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
} else {
res = jewels_showmenu(&bjmenu[1], cmd);
cmd = MCMD_NONE;
switch(res) {
case MRES_RESUME:
inmenu = false;
selected = false;
continue;
case MRES_PLAYBACK:
playback_control(NULL); playback_control(NULL);
rb->lcd_setfont(FONT_SYSFIXED);
inmenu = false; inmenu = false;
selected = false;
break; break;
case MRES_SAVE: case 1:
inmenu = false;
break;
case 2:
rb->splash(HZ, "Saving game..."); rb->splash(HZ, "Saving game...");
jewels_savegame(bj); jewels_savegame(bj);
return BJ_END; return BJ_END;
case MRES_QUIT: case 3:
return BJ_END; return BJ_END;
case MRES_EXIT: case 4:
return BJ_QUIT_FROM_GAME; return BJ_QUIT_FROM_GAME;
case MENU_ATTACHED_USB:
jewels_callback(bj);
return BJ_USB;
default: default:
inmenu = false;
break; break;
} }
} }
/* refresh the board */
jewels_drawboard(bj);
/* display the cursor */
if(selected) {
rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
rb->lcd_fillrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
rb->lcd_set_drawmode(DRMODE_SOLID);
} else {
rb->lcd_drawrect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
}
rb->lcd_update_rect(x*TILE_WIDTH, y*TILE_HEIGHT+YOFS,
TILE_WIDTH, TILE_HEIGHT);
/* handle game button presses */ /* handle game button presses */
rb->yield(); rb->yield();
button = rb->button_get(true); button = rb->button_get(true);
switch(button){ switch(button){
case JEWELS_LEFT: /* move cursor left */ case JEWELS_LEFT: /* move cursor left */
case (JEWELS_LEFT|BUTTON_REPEAT): case (JEWELS_LEFT|BUTTON_REPEAT):
if(!inmenu) { if(selected) {
if(selected) { bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT);
bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT); selected = false;
selected = false; if (!jewels_movesavail(bj)) no_movesavail = true;
if (!jewels_movesavail(bj)) no_movesavail = true; } else {
} else { x = (x+BJ_WIDTH-1)%BJ_WIDTH;
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
}
} }
break; break;
case JEWELS_RIGHT: /* move cursor right */ case JEWELS_RIGHT: /* move cursor right */
case (JEWELS_RIGHT|BUTTON_REPEAT): case (JEWELS_RIGHT|BUTTON_REPEAT):
if(!inmenu) { if(selected) {
if(selected) { bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT);
bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT); selected = false;
selected = false; if (!jewels_movesavail(bj)) no_movesavail = true;
if (!jewels_movesavail(bj)) no_movesavail = true;
} else {
x = (x+1)%BJ_WIDTH;
}
} else { } else {
cmd = MCMD_SELECT; x = (x+1)%BJ_WIDTH;
} }
break; break;
case JEWELS_DOWN: /* move cursor down */ case JEWELS_DOWN: /* move cursor down */
case (JEWELS_DOWN|BUTTON_REPEAT): case (JEWELS_DOWN|BUTTON_REPEAT):
if(!inmenu) { if(selected) {
if(selected) { bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN);
bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN); selected = false;
selected = false; if (!jewels_movesavail(bj)) no_movesavail = true;
if (!jewels_movesavail(bj)) no_movesavail = true;
} else {
y = (y+1)%(BJ_HEIGHT-1);
}
} else { } else {
cmd = MCMD_NEXT; y = (y+1)%(BJ_HEIGHT-1);
} }
break; break;
case JEWELS_UP: /* move cursor up */ case JEWELS_UP: /* move cursor up */
case (JEWELS_UP|BUTTON_REPEAT): case (JEWELS_UP|BUTTON_REPEAT):
if(!inmenu) { if(selected) {
if(selected) { bj->score += jewels_swapjewels(bj, x, y, SWAP_UP);
bj->score += jewels_swapjewels(bj, x, y, SWAP_UP); selected = false;
selected = false; if (!jewels_movesavail(bj)) no_movesavail = true;
if (!jewels_movesavail(bj)) no_movesavail = true;
} else {
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
}
} else { } else {
cmd = MCMD_PREV; y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
} }
break; break;
#ifdef JEWELS_SCROLLWHEEL #ifdef JEWELS_SCROLLWHEEL
case JEWELS_PREV: /* scroll backwards */ case JEWELS_PREV: /* scroll backwards */
case (JEWELS_PREV|BUTTON_REPEAT): case (JEWELS_PREV|BUTTON_REPEAT):
if(!inmenu) { if(!selected) {
if(!selected) { if(x == 0) {
if(x == 0) { y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
}
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
} }
} else { x = (x+BJ_WIDTH-1)%BJ_WIDTH;
cmd = MCMD_PREV;
} }
break; break;
case JEWELS_NEXT: /* scroll forwards */ case JEWELS_NEXT: /* scroll forwards */
case (JEWELS_NEXT|BUTTON_REPEAT): case (JEWELS_NEXT|BUTTON_REPEAT):
if(!inmenu) { if(!selected) {
if(!selected) { if(x == BJ_WIDTH-1) {
if(x == BJ_WIDTH-1) { y = (y+1)%(BJ_HEIGHT-1);
y = (y+1)%(BJ_HEIGHT-1);
}
x = (x+1)%BJ_WIDTH;
} }
} else { x = (x+1)%BJ_WIDTH;
cmd = MCMD_NEXT;
} }
break; break;
#endif #endif
case JEWELS_SELECT: /* toggle selected */ case JEWELS_SELECT: /* toggle selected */
if(!inmenu) { selected = !selected;
selected = !selected;
} else {
cmd = MCMD_SELECT;
}
break; break;
#ifdef JEWELS_MENU #ifdef JEWELS_MENU
case JEWELS_MENU: case JEWELS_MENU:
#endif #endif
case (JEWELS_SELECT|BUTTON_REPEAT): /* show menu */ case (JEWELS_SELECT|BUTTON_REPEAT): /* show menu */
if(!inmenu) inmenu = true; inmenu = true;
selected = false;
break; break;
#ifdef JEWELS_CANCEL #ifdef JEWELS_CANCEL

View file

@ -27,7 +27,6 @@
#include "plugin.h" #include "plugin.h"
#include <lib/playback_control.h> #include <lib/playback_control.h>
#include <lib/oldmenuapi.h>
#include <lib/helper.h> #include <lib/helper.h>
#include <lib/configfile.h> #include <lib/configfile.h>
@ -323,17 +322,16 @@ bool set_option_dithering(void)
return false; return false;
} }
MENUITEM_FUNCTION(grayscale_item, 0, "Greyscale",
set_option_grayscale, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(dithering_item, 0, "Dithering",
set_option_dithering, NULL, NULL, Icon_NOICON);
MAKE_MENU(display_menu, "Display Options", NULL, Icon_NOICON,
&grayscale_item, &dithering_item);
static void display_options(void) static void display_options(void)
{ {
static const struct menu_item items[] = { rb->do_menu(&display_menu, NULL, NULL, false);
{ "Greyscale", set_option_grayscale },
{ "Dithering", set_option_dithering },
};
int m = menu_init(items, ARRAYLEN(items),
NULL, NULL, NULL, NULL);
menu_run(m);
menu_exit(m);
} }
#endif /* HAVE_LCD_COLOR */ #endif /* HAVE_LCD_COLOR */
@ -349,12 +347,11 @@ int show_menu(void) /* return 1 to quit */
rb->lcd_set_background(LCD_WHITE); rb->lcd_set_background(LCD_WHITE);
#endif #endif
#endif #endif
int m;
int result; int result;
enum menu_id enum menu_id
{ {
MIID_QUIT = 0, MIID_RETURN = 0,
MIID_TOGGLE_SS_MODE, MIID_TOGGLE_SS_MODE,
MIID_CHANGE_SS_MODE, MIID_CHANGE_SS_MODE,
#if PLUGIN_BUFFER_SIZE >= MIN_MEM #if PLUGIN_BUFFER_SIZE >= MIN_MEM
@ -363,42 +360,30 @@ int show_menu(void) /* return 1 to quit */
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
MIID_DISPLAY_OPTIONS, MIID_DISPLAY_OPTIONS,
#endif #endif
MIID_RETURN, MIID_QUIT,
}; };
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Jpeg Menu", NULL,
[MIID_QUIT] = "Return", "Toggle Slideshow Mode",
{ "Quit", NULL }, "Change Slideshow Time",
[MIID_TOGGLE_SS_MODE] =
{ "Toggle Slideshow Mode", NULL },
[MIID_CHANGE_SS_MODE] =
{ "Change Slideshow Time", NULL },
#if PLUGIN_BUFFER_SIZE >= MIN_MEM #if PLUGIN_BUFFER_SIZE >= MIN_MEM
[MIID_SHOW_PLAYBACK_MENU] = "Show Playback Menu",
{ "Show Playback Menu", NULL },
#endif #endif
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
[MIID_DISPLAY_OPTIONS] = "Display Options",
{ "Display Options", NULL },
#endif #endif
[MIID_RETURN] = "Quit");
{ "Return", NULL },
};
static const struct opt_items slideshow[2] = { static const struct opt_items slideshow[2] = {
{ "Disable", -1 }, { "Disable", -1 },
{ "Enable", -1 }, { "Enable", -1 },
}; };
m = menu_init(items, sizeof(items) / sizeof(*items), result=rb->do_menu(&menu, NULL, NULL, false);
NULL, NULL, NULL, NULL);
result=menu_show(m);
switch (result) switch (result)
{ {
case MIID_QUIT: case MIID_RETURN:
menu_exit(m);
return 1;
break; break;
case MIID_TOGGLE_SS_MODE: case MIID_TOGGLE_SS_MODE:
rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, rb->set_option("Toggle Slideshow", &slideshow_enabled, INT,
@ -427,7 +412,8 @@ int show_menu(void) /* return 1 to quit */
display_options(); display_options();
break; break;
#endif #endif
case MIID_RETURN: case MIID_QUIT:
return 1;
break; break;
} }
@ -456,7 +442,6 @@ int show_menu(void) /* return 1 to quit */
rb->lcd_set_background(LCD_BLACK); rb->lcd_set_background(LCD_BLACK);
#endif #endif
rb->lcd_clear_display(); rb->lcd_clear_display();
menu_exit(m);
return 0; return 0;
} }

View file

@ -1,6 +1,5 @@
gcc-support.c gcc-support.c
jhash.c jhash.c
oldmenuapi.c
configfile.c configfile.c
fixedpoint.c fixedpoint.c
playback_control.c playback_control.c

View file

@ -1,237 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Robert E. Hak
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/*
2005 Kevin Ferrare :
- Multi screen support
- Rewrote/removed a lot of code now useless with the new gui API
*/
#include <stdbool.h>
#include <stdlib.h>
#include "plugin.h"
#include "oldmenuapi.h"
struct menu {
struct menu_item* items;
int (*callback)(int, int);
struct gui_synclist synclist;
};
#define MAX_MENUS 6
static struct menu menus[MAX_MENUS];
static bool inuse[MAX_MENUS] = { false };
static char * menu_get_itemname(int selected_item, void * data,
char *buffer, size_t buffer_len)
{
(void)buffer; (void)buffer_len;
struct menu *local_menus=(struct menu *)data;
return(local_menus->items[selected_item].desc);
}
static int menu_find_free(void)
{
int i;
/* Tries to find an unused slot to put the new menu */
for ( i=0; i<MAX_MENUS; i++ ) {
if ( !inuse[i] ) {
inuse[i] = true;
break;
}
}
if ( i == MAX_MENUS ) {
DEBUGF("Out of menus!\n");
return -1;
}
return(i);
}
int menu_init(const struct menu_item* mitems,
int count, int (*callback)(int, int),
const char *button1, const char *button2, const char *button3)
{
int menu=menu_find_free();
if(menu==-1)/* Out of menus */
return -1;
menus[menu].items = (struct menu_item*)mitems; /* de-const */
rb->gui_synclist_init(&(menus[menu].synclist),
&menu_get_itemname, &menus[menu], false, 1, NULL);
rb->gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL);
rb->gui_synclist_set_nb_items(&(menus[menu].synclist), count);
menus[menu].callback = callback;
(void)button1;
(void)button2;
(void)button3;
return menu;
}
void menu_exit(int m)
{
inuse[m] = false;
}
int menu_show(int m)
{
bool exit = false;
int key;
int bars = rb->viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
rb->gui_synclist_draw(&(menus[m].synclist));
while (!exit) {
key = rb->get_action(CONTEXT_MAINMENU,HZ/2);
/*
* "short-circuit" the default keypresses by running the
* callback function
* The callback may return a new key value, often this will be
* BUTTON_NONE or the same key value, but it's perfectly legal
* to "simulate" key presses by returning another value.
*/
if( menus[m].callback != NULL )
key = menus[m].callback(key, m);
rb->gui_synclist_do_button(&(menus[m].synclist), &key,LIST_WRAP_UNLESS_HELD);
switch( key ) {
case ACTION_STD_OK:
return rb->gui_synclist_get_sel_pos(&(menus[m].synclist));
case ACTION_STD_CANCEL:
case ACTION_STD_MENU:
case SYS_POWEROFF:
exit = true;
break;
default:
if(rb->default_event_handler(key) == SYS_USB_CONNECTED)
return MENU_ATTACHED_USB;
break;
}
}
rb->viewportmanager_set_statusbar(bars);
return MENU_SELECTED_EXIT;
}
bool menu_run(int m)
{
int selected;
while (1) {
switch (selected=menu_show(m))
{
case MENU_SELECTED_EXIT:
return false;
case MENU_ATTACHED_USB:
return true;
default:
{
if (menus[m].items[selected].function &&
menus[m].items[selected].function())
return true;
}
}
}
return false;
}
/*
* Property function - return the current cursor for "menu"
*/
int menu_cursor(int menu)
{
return rb->gui_synclist_get_sel_pos(&(menus[menu].synclist));
}
/*
* Property function - return the "menu" description at "position"
*/
char* menu_description(int menu, int position)
{
return menus[menu].items[position].desc;
}
/*
* Delete the element "position" from the menu items in "menu"
*/
void menu_delete(int menu, int position)
{
int i;
int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist));
/* copy the menu item from the one below */
for( i = position; i < nb_items - 1; i++)
menus[menu].items[i] = menus[menu].items[i + 1];
rb->gui_synclist_del_item(&(menus[menu].synclist));
}
void menu_insert(int menu, int position, char *desc, bool (*function) (void))
{
int i;
int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist));
if(position < 0)
position = nb_items;
/* Move the items below one position forward */
for( i = nb_items; i > position; i--)
menus[menu].items[i] = menus[menu].items[i - 1];
/* Update the current item */
menus[menu].items[position].desc = (unsigned char *)desc;
menus[menu].items[position].function = function;
rb->gui_synclist_add_item(&(menus[menu].synclist));
}
/*
* Property function - return the "count" of menu items in "menu"
*/
int menu_count(int menu)
{
return rb->gui_synclist_get_nb_items(&(menus[menu].synclist));
}
/*
* Allows to set the cursor position. Doesn't redraw by itself.
*/
void menu_set_cursor(int menu, int position)
{
rb->gui_synclist_select_item(&(menus[menu].synclist), position);
}
#if 0
void menu_talk_selected(int m)
{
if(rb->global_settings->talk_menu)
{
int selected=rb->gui_synclist_get_sel_pos(&(menus[m].synclist));
int voice_id = P2ID(menus[m].items[selected].desc);
if (voice_id >= 0) /* valid ID given? */
talk_id(voice_id, false); /* say it */
}
}
#endif
void menu_draw(int m)
{
rb->gui_synclist_draw(&(menus[m].synclist));
}

View file

@ -1,58 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Robert E. Hak
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/* This API is for existing plugins and shouldn't be used by new ones.
This provides a simpler menu system for plugins, but does not allow for
translatable or talkable strings in the menus. */
#ifndef __OLDMENUAPI_H__
#define __OLDMENUAPI_H__
#include <stdbool.h>
struct menu_item {
unsigned char *desc; /* string or ID */
bool (*function) (void); /* return true if USB was connected */
};
int menu_init(const struct menu_item* mitems,
int count, int (*callback)(int, int),
const char *button1, const char *button2, const char *button3);
void menu_exit(int menu);
void put_cursorxy(int x, int y, bool on);
/* Returns below define, or number of selected menu item*/
int menu_show(int m);
bool menu_run(int menu);
int menu_cursor(int menu);
char* menu_description(int menu, int position);
void menu_delete(int menu, int position);
int menu_count(int menu);
bool menu_moveup(int menu);
bool menu_movedown(int menu);
void menu_draw(int menu);
void menu_insert(int menu, int position, char *desc, bool (*function) (void));
void menu_set_cursor(int menu, int position);
void menu_talk_selected(int m);
#endif /* End __OLDMENUAPI_H__ */

View file

@ -1,7 +1,6 @@
#include "plugin.h" #include "plugin.h"
#include "lib/helper.h" #include "lib/helper.h"
#include "lib/configfile.h" #include "lib/configfile.h"
#include "lib/oldmenuapi.h"
#include "mpegplayer.h" #include "mpegplayer.h"
#include "mpeg_settings.h" #include "mpeg_settings.h"
@ -257,7 +256,7 @@ void mpeg_menu_sysevent_clear(void)
mpeg_menu_sysevent_id = 0; mpeg_menu_sysevent_id = 0;
} }
int mpeg_menu_sysevent_callback(int btn, int menu) int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu)
{ {
switch (btn) switch (btn)
{ {
@ -283,17 +282,6 @@ void mpeg_menu_sysevent_handle(void)
rb->default_event_handler(id); rb->default_event_handler(id);
} }
static void format_menu_item(struct menu_item *item, int bufsize,
const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
rb->vsnprintf(item->desc, bufsize, fmt, ap);
va_end(ap);
}
static bool mpeg_set_option(const char* string, static bool mpeg_set_option(const char* string,
void* variable, void* variable,
enum optiontype type, enum optiontype type,
@ -691,7 +679,7 @@ static int get_start_time(uint32_t duration)
button = tmo == TIMEOUT_BLOCK ? button = tmo == TIMEOUT_BLOCK ?
rb->button_get(true) : rb->button_get_w_tmo(tmo); rb->button_get(true) : rb->button_get_w_tmo(tmo);
button = mpeg_menu_sysevent_callback(button, -1); button = mpeg_menu_sysevent_callback(button, NULL);
switch (button) switch (button)
{ {
@ -822,43 +810,31 @@ static int get_start_time(uint32_t duration)
static int show_start_menu(uint32_t duration) static int show_start_menu(uint32_t duration)
{ {
int menu_id; int selected = 0;
int result = 0; int result = 0;
bool menu_quit = false; bool menu_quit = false;
/* add the resume time to the menu display */ /* add the resume time to the menu display */
char resume_str[32]; static char resume_str[32];
char hms_str[32]; char hms_str[32];
struct hms hms; struct hms hms;
struct menu_item items[] = MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback,
{ "Play from beginning", resume_str,
[MPEG_START_RESTART] = "Set start time", "Settings",
{ "Play from beginning", NULL }, "Quit mpegplayer");
[MPEG_START_RESUME] =
{ resume_str, NULL },
[MPEG_START_SEEK] =
{ "Set start time", NULL },
[MPEG_START_SETTINGS] =
{ "Settings", NULL },
[MPEG_START_QUIT] =
{ "Quit mpegplayer", NULL },
};
ts_to_hms(settings.resume_time, &hms); ts_to_hms(settings.resume_time, &hms);
hms_format(hms_str, sizeof(hms_str), &hms); hms_format(hms_str, sizeof(hms_str), &hms);
format_menu_item(&items[MPEG_START_RESUME], sizeof (resume_str), rb->snprintf(resume_str, sizeof (resume_str),
"Resume at: %s", hms_str); "Resume at: %s", hms_str);
menu_id = menu_init(items, ARRAYLEN(items),
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) while (!menu_quit)
{ {
mpeg_menu_sysevent_clear(); mpeg_menu_sysevent_clear();
result = menu_show(menu_id); result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -901,8 +877,6 @@ static int show_start_menu(uint32_t duration)
} }
} }
menu_exit(menu_id);
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_update(); rb->lcd_update();
@ -934,36 +908,26 @@ int mpeg_start_menu(uint32_t duration)
/** MPEG Menu **/ /** MPEG Menu **/
static void display_options(void) static void display_options(void)
{ {
int selected = 0;
int result; int result;
int menu_id;
bool menu_quit = false; bool menu_quit = false;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Display Options", mpeg_menu_sysevent_callback,
#if MPEG_OPTION_DITHERING_ENABLED #if MPEG_OPTION_DITHERING_ENABLED
[MPEG_OPTION_DITHERING] = "Dithering",
{ "Dithering", NULL },
#endif #endif
[MPEG_OPTION_DISPLAY_FPS] = "Display FPS", "Limit FPS", "Skip frames",
{ "Display FPS", NULL },
[MPEG_OPTION_LIMIT_FPS] =
{ "Limit FPS", NULL },
[MPEG_OPTION_SKIP_FRAMES] =
{ "Skip frames", NULL },
#ifdef HAVE_BACKLIGHT_BRIGHTNESS #ifdef HAVE_BACKLIGHT_BRIGHTNESS
[MPEG_OPTION_BACKLIGHT_BRIGHTNESS] = "Backlight brightness",
{ "Backlight brightness", NULL },
#endif #endif
}; );
menu_id = menu_init(items, ARRAYLEN(items),
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) while (!menu_quit)
{ {
mpeg_menu_sysevent_clear(); mpeg_menu_sysevent_clear();
result = menu_show(menu_id); result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -1014,38 +978,24 @@ static void display_options(void)
if (mpeg_menu_sysevent() != 0) if (mpeg_menu_sysevent() != 0)
menu_quit = true; menu_quit = true;
} }
menu_exit(menu_id);
} }
static void audio_options(void) static void audio_options(void)
{ {
int selected = 0;
int result; int result;
int menu_id;
bool menu_quit = false; bool menu_quit = false;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_menu_sysevent_callback,
[MPEG_AUDIO_TONE_CONTROLS] = "Tone Controls", "Channel Modes", "Crossfeed",
{ "Tone Controls", NULL }, "Equalizer", "Dithering");
[MPEG_AUDIO_CHANNEL_MODES] =
{ "Channel Modes", NULL },
[MPEG_AUDIO_CROSSFEED] =
{ "Crossfeed", NULL },
[MPEG_AUDIO_EQUALIZER] =
{ "Equalizer", NULL },
[MPEG_AUDIO_DITHERING] =
{ "Dithering", NULL },
};
menu_id = menu_init(items, ARRAYLEN(items),
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) while (!menu_quit)
{ {
mpeg_menu_sysevent_clear(); mpeg_menu_sysevent_clear();
result = menu_show(menu_id); result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -1087,8 +1037,6 @@ static void audio_options(void)
if (mpeg_menu_sysevent() != 0) if (mpeg_menu_sysevent() != 0)
menu_quit = true; menu_quit = true;
} }
menu_exit(menu_id);
} }
static void resume_options(void) static void resume_options(void)
@ -1121,32 +1069,23 @@ static void clear_resume_count(void)
int mpeg_menu(unsigned flags) int mpeg_menu(unsigned flags)
{ {
int menu_id; int selected = 0;
int result; int result;
bool menu_quit = false; bool menu_quit = false;
int item_count; static char clear_str[32];
char clear_str[32];
struct menu_item items[] = { MENUITEM_STRINGLIST(menu_with_quit, "Mpegplayer Menu",
[MPEG_MENU_DISPLAY_SETTINGS] = mpeg_menu_sysevent_callback,
{ "Display Options", NULL }, "Display Options", "Audio Options",
[MPEG_MENU_AUDIO_SETTINGS] = "Resume Options", clear_str, "Quit mpegplayer");
{ "Audio Options", NULL }, MENUITEM_STRINGLIST(menu_without_quit, "Settings",
[MPEG_MENU_ENABLE_START_MENU] = mpeg_menu_sysevent_callback,
{ "Resume Options", NULL }, "Display Options", "Audio Options",
[MPEG_MENU_CLEAR_RESUMES] = "Resume Options", clear_str);
{ clear_str, NULL }, const struct menu_item_ex *menu = &menu_with_quit;
[MPEG_MENU_QUIT] =
{ "Quit mpegplayer", NULL },
};
item_count = ARRAYLEN(items);
if (flags & MPEG_MENU_HIDE_QUIT_ITEM) if (flags & MPEG_MENU_HIDE_QUIT_ITEM)
item_count--; menu = &menu_without_quit;
menu_id = menu_init(items, item_count,
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
@ -1155,10 +1094,10 @@ int mpeg_menu(unsigned flags)
mpeg_menu_sysevent_clear(); mpeg_menu_sysevent_clear();
/* Format and add resume option to the menu display */ /* Format and add resume option to the menu display */
format_menu_item(&items[MPEG_MENU_CLEAR_RESUMES], sizeof(clear_str), rb->snprintf(clear_str, sizeof(clear_str),
"Clear all resumes: %u", settings.resume_count); "Clear all resumes: %u", settings.resume_count);
result = menu_show(menu_id); result = rb->do_menu(menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -1191,8 +1130,6 @@ int mpeg_menu(unsigned flags)
} }
} }
menu_exit(menu_id);
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_update(); rb->lcd_update();

View file

@ -100,7 +100,7 @@ enum
int mpeg_menu(unsigned flags); int mpeg_menu(unsigned flags);
void mpeg_menu_sysevent_clear(void); void mpeg_menu_sysevent_clear(void);
long mpeg_menu_sysevent(void); long mpeg_menu_sysevent(void);
int mpeg_menu_sysevent_callback(int btn, int menu); int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu);
void mpeg_menu_sysevent_handle(void); void mpeg_menu_sysevent_handle(void);
void init_settings(const char* filename); void init_settings(const char* filename);

View file

@ -1498,7 +1498,7 @@ static void button_loop(void)
mpeg_menu_sysevent_clear(); mpeg_menu_sysevent_clear();
button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL); button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL);
button = mpeg_menu_sysevent_callback(button, -1); button = mpeg_menu_sysevent_callback(button, NULL);
switch (button) switch (button)
{ {

View file

@ -29,7 +29,6 @@
#include "pacbox.h" #include "pacbox.h"
#include "pacbox_lcd.h" #include "pacbox_lcd.h"
#include "lib/configfile.h" #include "lib/configfile.h"
#include "lib/oldmenuapi.h"
PLUGIN_HEADER PLUGIN_HEADER
PLUGIN_IRAM_DECLARE PLUGIN_IRAM_DECLARE
@ -138,7 +137,7 @@ static int settings_to_dip(struct pacman_settings settings)
static bool pacbox_menu(void) static bool pacbox_menu(void)
{ {
int m; int selected=0;
int result; int result;
int menu_quit=0; int menu_quit=0;
int new_setting; int new_setting;
@ -173,23 +172,14 @@ static bool pacbox_menu(void)
{ "Alternate", -1 }, { "Alternate", -1 },
}; };
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Pacbox Menu", NULL,
{ "Difficulty", NULL }, "Difficulty", "Pacmen Per Game", "Bonus Life",
{ "Pacmen Per Game", NULL }, "Ghost Names", "Display FPS", "Restart", "Quit");
{ "Bonus Life", NULL },
{ "Ghost Names", NULL },
{ "Display FPS", NULL },
{ "Restart", NULL },
{ "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
result=menu_show(m); result=rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
@ -243,8 +233,6 @@ static bool pacbox_menu(void)
} }
} }
menu_exit(m);
if (need_restart) { if (need_restart) {
init_PacmanMachine(settings_to_dip(settings)); init_PacmanMachine(settings_to_dip(settings));
} }

View file

@ -19,7 +19,6 @@
* *
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "lib/oldmenuapi.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -321,15 +320,11 @@ int edit_list(void)
break; break;
case ACTION_STD_CONTEXT: case ACTION_STD_CONTEXT:
{ {
int m, len; int len;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Remove Menu", NULL,
{ "Remove Folder", NULL }, "Remove Folder", "Remove Folder Tree");
{ "Remove Folder Tree", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
switch (menu_show(m)) switch (rb->do_menu(&menu, NULL, NULL, false))
{ {
case 0: case 0:
list->folder[selection][0] = ' '; list->folder[selection][0] = ' ';
@ -351,20 +346,14 @@ int edit_list(void)
} }
break; break;
} }
menu_exit(m);
} }
break; break;
case ACTION_STD_CANCEL: case ACTION_STD_CANCEL:
{ {
int m; MENUITEM_STRINGLIST(menu, "Exit Menu", NULL,
static const struct menu_item items[] = { "Save and Exit", "Ignore Changes and Exit");
{ "Save and Exit", NULL },
{ "Ignore Changes and Exit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
switch (menu_show(m)) switch (rb->do_menu(&menu, NULL, NULL, false))
{ {
case 0: case 0:
save_list(); save_list();
@ -372,7 +361,6 @@ int edit_list(void)
exit = true; exit = true;
ret = -2; ret = -2;
} }
menu_exit(m);
} }
break; break;
} }
@ -474,19 +462,16 @@ int import_list_from_file_text(void)
int main_menu(void) int main_menu(void)
{ {
int m;
bool exit = false; bool exit = false;
static const struct menu_item items[] = {
{ "Generate Folder List", NULL },
{ "Edit Folder List", NULL },
{ "Export List To Textfile", NULL },
{ "Import List From Textfile", NULL },
{ "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
switch (menu_show(m)) MENUITEM_STRINGLIST(menu, "Main Menu", NULL,
"Generate Folder List",
"Edit Folder List",
"Export List To Textfile",
"Import List From Textfile",
"Quit");
switch (rb->do_menu(&menu, NULL, NULL, false))
{ {
case 0: /* generate */ case 0: /* generate */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ #ifdef HAVE_ADJUSTABLE_CPU_FREQ
@ -542,10 +527,8 @@ int main_menu(void)
rb->backlight_on(); rb->backlight_on();
break; break;
case 4: case 4:
menu_exit(m);
return 1; return 1;
} }
menu_exit(m);
return exit?1:0; return exit?1:0;
} }

View file

@ -47,7 +47,6 @@ further options:
#include "reversi-strategy.h" #include "reversi-strategy.h"
#include "reversi-gui.h" #include "reversi-gui.h"
#include "lib/oldmenuapi.h"
#include "lib/playback_control.h" #include "lib/playback_control.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -375,23 +374,15 @@ static bool reversi_gui_choose_strategy(
/* Returns true iff USB ws connected while in the menu */ /* Returns true iff USB ws connected while in the menu */
static bool reversi_gui_menu(void) { static bool reversi_gui_menu(void) {
int m, index, num_items, i; int index, num_items, i;
int result; int result;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Reversi Menu", NULL,
{ "Start new game", NULL }, "Start new game", "Pass the move",
{ "Pass the move", NULL }, MENU_TEXT_STRAT_BLACK, MENU_TEXT_STRAT_WHITE,
{ MENU_TEXT_STRAT_BLACK, NULL }, MENU_TEXT_WRAP_MODE, "Playback Control", "Quit");
{ MENU_TEXT_STRAT_WHITE, NULL },
{ MENU_TEXT_WRAP_MODE, NULL },
{ "Playback Control", NULL },
{ "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items), result = rb->do_menu(&menu, NULL, NULL, false);
NULL, NULL, NULL, NULL);
result = menu_show(m);
switch (result) { switch (result) {
case 0: /* Start a new game */ case 0: /* Start a new game */
@ -433,8 +424,6 @@ static bool reversi_gui_menu(void) {
break; break;
} }
menu_exit(m);
return (result == MENU_ATTACHED_USB); return (result == MENU_ATTACHED_USB);
} }

View file

@ -8,7 +8,6 @@
#include "rockmacros.h" #include "rockmacros.h"
#include "mem.h" #include "mem.h"
#include "save.h" #include "save.h"
#include "lib/oldmenuapi.h"
#include "rtc-gb.h" #include "rtc-gb.h"
#include "pcm.h" #include "pcm.h"
@ -85,7 +84,7 @@ static void setupkeys(void)
*/ */
int do_user_menu(void) { int do_user_menu(void) {
bool done=false; bool done=false;
int m, ret=0; int selected=0, ret=0;
int result; int result;
int time = 0; int time = 0;
@ -97,20 +96,15 @@ int do_user_menu(void) {
while (rb->button_get(false) != BUTTON_NONE) while (rb->button_get(false) != BUTTON_NONE)
rb->yield(); rb->yield();
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL,
{"Load Game", NULL }, "Load Game", "Save Game",
{"Save Game", NULL }, "Options", "Quit");
{"Options", NULL },
{"Quit", NULL },
};
pcm_init(); pcm_init();
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
while(!done) while(!done)
{ {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -133,8 +127,6 @@ int do_user_menu(void) {
} }
} }
menu_exit(m);
rb->lcd_setfont(0); /* Reset the font */ rb->lcd_setfont(0); /* Reset the font */
rb->lcd_clear_display(); /* Clear display for screen size changes */ rb->lcd_clear_display(); /* Clear display for screen size changes */
@ -288,50 +280,65 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
} }
} }
/*
* slot_get_name
*/
static char *slot_get_name(int selected_item, void * data,
char * buffer, size_t buffer_len)
{
char (*items)[20] = data;
(void) buffer;
(void) buffer_len;
return items[selected_item];
}
/*
* list_action_callback
*/
static int list_action_callback(int action, struct gui_synclist *lists)
{
(void) lists;
if (action == ACTION_STD_OK)
return ACTION_STD_CANCEL;
return action;
}
/* /*
* do_slot_menu - prompt the user for a load/save memory slot * do_slot_menu - prompt the user for a load/save memory slot
*/ */
static void do_slot_menu(bool is_load) { static void do_slot_menu(bool is_load) {
bool done=false; bool done=false;
char items[5][20];
char buf[5][20];
int m;
int result; int result;
int i; int i;
struct menu_item items[] = {
{ buf[0] , NULL },
{ buf[1] , NULL },
{ buf[2] , NULL },
{ buf[3] , NULL },
{ buf[4] , NULL },
};
int num_items = sizeof(items) / sizeof(*items); int num_items = sizeof(items) / sizeof(*items);
struct simplelist_info info;
/* create menu items */ /* create menu items */
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
slot_info(buf[i], 20, i); slot_info(items[i], 20, i);
m = menu_init(items, num_items, NULL, NULL, NULL, NULL); rb->simplelist_info_init(&info, NULL, num_items, (void *)items);
info.get_name = slot_get_name;
info.action_callback = list_action_callback;
while(!done) while(!done)
{ {
result=menu_show(m); if(rb->simplelist_show_list(&info))
break;
result = info.selection;
if (result<num_items && result >= 0 ) if (result<num_items && result >= 0 )
done = do_slot(result, is_load); done = do_slot(result, is_load);
else else
done = true; done = true;
} }
menu_exit(m);
} }
static void do_opt_menu(void) static void do_opt_menu(void)
{ {
bool done=false; bool done=false;
int m; int selected=0;
int result; int result;
static const struct opt_items onoff[2] = { static const struct opt_items onoff[2] = {
@ -379,63 +386,54 @@ static void do_opt_menu(void)
}; };
#endif #endif
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Options", NULL,
{ "Max Frameskip", NULL }, "Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)",
{ "Sound" , NULL },
{ "Stats" , NULL },
{ "Set Keys (Buggy)", NULL },
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
{ "Screen Size" , NULL }, "Screen Size", "Screen Rotate", "Set Palette",
{ "Screen Rotate" , NULL },
{ "Set Palette" , NULL },
#endif #endif
}; );
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
options.dirty=1; /* Assume that the settings have been changed */ options.dirty=1; /* Assume that the settings have been changed */
while(!done) while(!done)
{ {
result = rb->do_menu(&menu, &selected, NULL, false);
result=menu_show(m);
switch (result) switch (result)
{ {
case 0: /* Frameskip */ case 0: /* Frameskip */
rb->set_option(items[0].desc, &options.maxskip, INT, frameskip, rb->set_option("Max Frameskip", &options.maxskip, INT, frameskip,
sizeof(frameskip)/sizeof(*frameskip), NULL ); sizeof(frameskip)/sizeof(*frameskip), NULL );
break; break;
case 1: /* Sound */ case 1: /* Sound */
if(options.sound>1) options.sound=1; if(options.sound>1) options.sound=1;
rb->set_option(items[1].desc, &options.sound, INT, onoff, 2, NULL ); rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL );
if(options.sound) sound_dirty(); if(options.sound) sound_dirty();
break; break;
case 2: /* Stats */ case 2: /* Stats */
rb->set_option(items[2].desc, &options.showstats, INT, onoff, 2, NULL ); rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL );
break; break;
case 3: /* Keys */ case 3: /* Keys */
setupkeys(); setupkeys();
break; break;
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
case 4: /* Screen Size */ case 4: /* Screen Size */
rb->set_option(items[4].desc, &options.scaling, INT, scaling, rb->set_option("Screen Size", &options.scaling, INT, scaling,
sizeof(scaling)/sizeof(*scaling), NULL ); sizeof(scaling)/sizeof(*scaling), NULL );
setvidmode(); setvidmode();
break; break;
case 5: /* Screen rotate */ case 5: /* Screen rotate */
rb->set_option(items[5].desc, &options.rotate, INT, onoff, 2, NULL ); rb->set_option("Screen Rotate", &options.rotate, INT, onoff, 2, NULL );
setvidmode(); setvidmode();
break; break;
case 6: /* Palette */ case 6: /* Palette */
rb->set_option(items[6].desc, &options.pal, INT, palette, 17, NULL ); rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL );
set_pal(); set_pal();
break; break;
#endif #endif
default: default:
done=true; done=true;
break; break;
} }
} }
menu_exit(m);
} }

View file

@ -516,89 +516,46 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height,
/*********************************************************************** /***********************************************************************
* Menu handling * Menu handling
***********************************************************************/ ***********************************************************************/
struct menu_items
{
int value;
char label[16]; /* GRUIK ? */
};
#define MENU_ESC -1242
enum { enum {
/* Generic menu items */
MENU_END = -42, MENU_TITLE = -12,
/* Main menu */ /* Main menu */
MAIN_MENU_RESUME, MAIN_MENU_RESUME,
MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE, MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE,
MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR, MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR,
MAIN_MENU_GRID_SIZE, MAIN_MENU_GRID_SIZE,
MAIN_MENU_EXIT, MAIN_MENU_EXIT,
};
enum {
/* Select action menu */ /* Select action menu */
SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT, SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT,
SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90, SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90,
SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270, SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270,
SELECT_MENU_CANCEL, SELECT_MENU_CANCEL,
};
enum {
/* Text menu */ /* Text menu */
TEXT_MENU_TEXT, TEXT_MENU_FONT, TEXT_MENU_TEXT, TEXT_MENU_FONT,
TEXT_MENU_PREVIEW, TEXT_MENU_APPLY, TEXT_MENU_CANCEL, TEXT_MENU_PREVIEW, TEXT_MENU_APPLY, TEXT_MENU_CANCEL,
}; };
static struct menu_items main_menu[]= MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL,
{ { MENU_TITLE, "RockPaint" }, "Resume", "New", "Load", "Save",
{ MAIN_MENU_RESUME, "Resume" }, "Brush Size", "Brush Speed",
{ MAIN_MENU_NEW, "New" }, "Choose Color", "Grid Size", "Exit");
{ MAIN_MENU_LOAD, "Load" }, MENUITEM_STRINGLIST(size_menu, "Choose Size", NULL,
{ MAIN_MENU_SAVE, "Save" }, "1x", "2x","4x", "8x");
{ MAIN_MENU_BRUSH_SIZE, "Brush Size" }, MENUITEM_STRINGLIST(speed_menu, "Choose Speed", NULL,
{ MAIN_MENU_BRUSH_SPEED, "Brush Speed" }, "1x", "2x","4x");
{ MAIN_MENU_COLOR, "Choose Color" }, MENUITEM_STRINGLIST(gridsize_menu, "Grid Size", NULL,
{ MAIN_MENU_GRID_SIZE, "Grid Size" }, "No grid", "5px", "10px", "20px");
{ MAIN_MENU_EXIT, "Exit" }, MENUITEM_STRINGLIST(select_menu, "Select...", NULL,
{ MENU_END, "" } }; "Cut", "Copy", "Invert", "Horizontal Flip" ,
"Vertical Flip", "Rotate 90°",
static struct menu_items size_menu[] = "Rotate 180°", "Rotate 270°", "Cancel");
{ { MENU_TITLE, "Choose Size" }, MENUITEM_STRINGLIST(text_menu, "Text", NULL,
{ 1, "1x" }, "Set Text", "Change Font",
{ 2, "2x" }, "Preview", "Apply", "Cancel");
{ 4, "4x" }, static const int times_list[] = { 1, 2, 4, 8 };
{ 8, "8x" }, static const int gridsize_list[] = { 0, 5, 10, 20 };
{ MENU_END, "" } };
static struct menu_items speed_menu[] =
{ { MENU_TITLE, "Choose Speed" },
{ 1, "1x" },
{ 2, "2x" },
{ 4, "4x" },
{ MENU_END, "" } };
static struct menu_items gridsize_menu[] =
{ { MENU_TITLE, "Grid Size" },
{ 0, "No grid" },
{ 5, "5px" },
{ 10, "10px" },
{ 20, "20px" },
{ MENU_END, "" } };
static struct menu_items select_menu[] =
{ { MENU_TITLE, "Select..." },
{ SELECT_MENU_CUT, "Cut" },
{ SELECT_MENU_COPY, "Copy" },
{ SELECT_MENU_INVERT, "Invert" },
{ SELECT_MENU_HFLIP, "Horizontal flip" },
{ SELECT_MENU_VFLIP, "Vertical flip" },
// { SELECT_MENU_ROTATE90, "Rotate 90°" },
{ SELECT_MENU_ROTATE180, "Rotate 180°" },
// { SELECT_MENU_ROTATE270, "Rotate 270°" },
{ SELECT_MENU_CANCEL, "Cancel" },
{ MENU_END, "" } };
static struct menu_items text_menu[] =
{ { MENU_TITLE, "Text" },
{ TEXT_MENU_TEXT, "Set text" },
{ TEXT_MENU_FONT, "Change font" },
{ TEXT_MENU_PREVIEW, "Preview" },
{ TEXT_MENU_APPLY, "Apply" },
{ TEXT_MENU_CANCEL, "Cancel" },
{ MENU_END, "" } };
static int draw_window( int height, int width, static int draw_window( int height, int width,
int *top, int *left, int *top, int *left,
@ -624,144 +581,38 @@ static int draw_window( int height, int width,
return _top+fh+4; return _top+fh+4;
} }
static int menu_display( struct menu_items menu[], int prev_value )
{
int i,
fh, /* font height */
width, height,
a, b,
selection=1,
menu_length,
top, left;
int scroll = 0, onscreen = 0;
rb->lcd_getstringsize( menu[0].label, &width, &fh );
for( i=1; menu[i].value != MENU_END; i++ )
{
if( prev_value == menu[i].value )
{
selection = i;
}
rb->lcd_getstringsize( menu[i].label, &a, &b );
if( a > width ) width = a;
if( b > fh ) fh = b;
}
menu_length = i;
fh++;
width += 10;
height = menu_length * fh + 4 + 2 + 2;
if( height >= LCD_HEIGHT )
{
scroll = 1;
onscreen = ( LCD_HEIGHT - 4 - 2 - 2 )/fh;
height = onscreen * fh + 4 + 2 + 2;
width += 5;
}
else
{
onscreen = menu_length;
}
draw_window( height, width, &top, &left, menu[0].label );
while( 1 )
{
for( i = (scroll == 0 ? 1 : scroll);
i < (scroll ? scroll + onscreen - 1:onscreen);
i++ )
{
if( i == selection )
{
rb->lcd_set_foreground( COLOR_WHITE );
rb->lcd_set_background( COLOR_BLUE );
}
else
{
rb->lcd_set_foreground( COLOR_BLACK );
rb->lcd_set_background( COLOR_LIGHTGRAY );
}
rb->lcd_putsxy( left+2,
top+6+fh*(i-(scroll == 0 ? 0 : scroll-1 )),
menu[i].label );
}
if( scroll )
{
int scroll_height = ((height-fh-4-2)*onscreen)/menu_length;
rb->lcd_set_foreground( COLOR_BLACK );
rb->lcd_vline( left+width-5, top+fh+4, top+height-2 );
rb->lcd_fillrect( left+width-4,
top+fh+4+((height-4-2-fh-scroll_height)*(scroll-1))/(menu_length-onscreen),
3, scroll_height );
}
rb->lcd_update();
switch( rb->button_get(true) )
{
case ROCKPAINT_UP:
case ROCKPAINT_UP|BUTTON_REPEAT:
selection = (selection + menu_length-1)%menu_length;
if( !selection ) selection = menu_length-1;
break;
case ROCKPAINT_DOWN:
case ROCKPAINT_DOWN|BUTTON_REPEAT:
selection = (selection + 1)%menu_length;
if( !selection ) selection++;
break;
case ROCKPAINT_LEFT:
restore_screen();
return MENU_ESC;
case ROCKPAINT_RIGHT:
case ROCKPAINT_DRAW:
restore_screen();
return menu[selection].value;
}
if( scroll )
{
if( selection < scroll )
{
scroll = selection;
draw_window( height, width, NULL, NULL, menu[0].label );
}
if( selection >= scroll + onscreen - 1 )
{
scroll++;
draw_window( height, width, NULL, NULL, menu[0].label );
}
}
}
}
/*********************************************************************** /***********************************************************************
* File browser * File browser
***********************************************************************/ ***********************************************************************/
char bbuf[MAX_PATH+1]; /* used by file and font browsers */ char bbuf[MAX_PATH+1]; /* used by file and font browsers */
char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */ char bbuf_s[MAX_PATH+1]; /* used by file and font browsers */
struct tree_context *tree = NULL;
static char * browse_get_name_cb( int selected_item, void *data,
char *buffer, size_t buffer_len )
{
int *indexes = (int *) data;
struct entry* dc = tree->dircache;
struct entry* e = &dc[indexes[selected_item]];
(void) buffer;
(void) buffer_len;
return (e->name);
}
static bool browse( char *dst, int dst_size, const char *start ) static bool browse( char *dst, int dst_size, const char *start )
{ {
#define WIDTH ( LCD_WIDTH - 20 ) struct gui_synclist browse_list;
#define HEIGHT ( LCD_HEIGHT - 20 ) int item_count, selected, button;
#define LINE_SPACE 2 struct tree_context backup;
int top, top_inside, left; struct entry *dc;
bool reload = true;
int dirfilter = SHOW_ALL;
int *indexes = (int *) buffer.clipboard;
DIR *d;
struct dirent *de;
int fvi = 0; /* first visible item */
int lvi = 0; /* last visible item */
int si = 0; /* selected item */
int li = 0; /* last item */
int i;
int fh;
char *a; char *a;
rb->lcd_getstringsize( "Ap", NULL, &fh );
rb->strcpy( bbuf, start ); rb->strcpy( bbuf, start );
a = bbuf+rb->strlen(bbuf)-1; a = bbuf+rb->strlen(bbuf)-1;
if( *a != '/' ) if( *a != '/' )
@ -769,124 +620,106 @@ static bool browse( char *dst, int dst_size, const char *start )
a[1] = '/'; a[1] = '/';
a[2] = '\0'; a[2] = '\0';
} }
bbuf_s[0] = '\0';
rb->gui_synclist_init( &browse_list, browse_get_name_cb,
(void*) indexes, false, 1, NULL );
tree = rb->tree_get_context();
backup = *tree;
dc = tree->dircache;
a = backup.currdir+rb->strlen(backup.currdir)-1;
if( *a != '/' )
{
*++a = '/';
*++a = '\0';
}
rb->strcpy( a, dc[tree->selected_item].name );
tree->dirfilter = &dirfilter;
while( 1 ) while( 1 )
{ {
d = rb->opendir( bbuf ); if( reload )
if( !d )
{ {
/* int i;
if( errno == ENOTDIR ) rb->set_current_file(bbuf);
{*/ item_count = 0;
/* this is a file */ selected = 0;
bbuf[rb->strlen(bbuf)-1] = '\0'; for( i = 0; i < tree->filesindir ; i++)
rb->strncpy( dst, bbuf, dst_size );
return true;
/*}
else if( errno == EACCES || errno == ENOENT )
{ {
bbuf[0] = '/'; bbuf[1] = '\0'; /* only displayes directories and .bmp files */
d = rb->opendir( "/" ); if( ((dc[i].attr & ATTR_DIRECTORY ) &&
} rb->strcmp( dc[i].name, "." ) &&
else rb->strcmp( dc[i].name, ".." )) ||
{ ( !(dc[i].attr & ATTR_DIRECTORY) &&
return false; (a = rb->strrchr( dc[i].name,'.' )) &&
}*/ !rb->strcmp( a, ".bmp" ) ))
}
top_inside = draw_window( HEIGHT, WIDTH, &top, &left, bbuf );
i = 0;
li = -1;
while( i < fvi )
{
rb->readdir( d );
i++;
}
while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT )
{
de = rb->readdir( d );
if( !de )
{
li = i-1;
break;
}
rb->lcd_set_foreground((si==i?COLOR_WHITE:COLOR_BLACK));
rb->lcd_set_background((si==i?COLOR_BLUE:COLOR_LIGHTGRAY));
rb->lcd_putsxy( left+10,
top_inside+(i-fvi)*(fh+LINE_SPACE),
de->d_name );
if( si == i )
rb->strcpy( bbuf_s, de->d_name );
i++;
}
lvi = i-1;
if( li == -1 )
{
if( !rb->readdir( d ) )
{
li = lvi;
}
}
rb->closedir( d );
rb->lcd_update();
switch( rb->button_get(true) )
{
case ROCKPAINT_UP:
case ROCKPAINT_UP|BUTTON_REPEAT:
if( si > 0 )
{ {
si--; if( !rb->strcmp( dc[i].name, bbuf_s ) )
if( si<fvi ) selected = item_count;
indexes[item_count++] = i;
}
}
rb->gui_synclist_set_nb_items(&browse_list,item_count);
rb->gui_synclist_select_item(&browse_list, selected);
rb->gui_synclist_set_title(&browse_list, bbuf, NOICON);
rb->gui_synclist_draw(&browse_list);
reload = false;
}
button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
if (rb->gui_synclist_do_button(&browse_list,&button,LIST_WRAP_UNLESS_HELD))
continue;
switch( button )
{
case ACTION_STD_CANCEL:
if( !rb->strcmp( bbuf, "/" ) )
{
*tree = backup;
rb->set_current_file( backup.currdir );
return false;
}
rb->strcpy( bbuf_s, ".." );
case ACTION_STD_OK:
if( button == ACTION_STD_OK )
{
selected = rb->gui_synclist_get_sel_pos( &browse_list );
if( selected < 0 || selected >= item_count )
break;
struct entry* e = &dc[indexes[selected]];
rb->strncpy( bbuf_s, e->name, sizeof( bbuf_s ) );
if( !( e->attr & ATTR_DIRECTORY ) )
{ {
fvi--; *tree = backup;
rb->set_current_file( backup.currdir );
rb->snprintf( dst, dst_size, "%s%s", bbuf, bbuf_s );
return true;
} }
} }
break; if( !rb->strcmp( bbuf_s, "." ) ) break;
a = bbuf+rb->strlen(bbuf);
case ROCKPAINT_DOWN: if( !rb->strcmp( bbuf_s, ".." ) )
case ROCKPAINT_DOWN|BUTTON_REPEAT:
if( li == -1 || si < li )
{
si++;
if( si>lvi )
{
fvi++;
}
}
break;
case ROCKPAINT_LEFT:
if( bbuf[0] == '/' && !bbuf[1] ) return false;
bbuf_s[0] = '.';
bbuf_s[1] = '.';
bbuf_s[2] = '\0';
case ROCKPAINT_RIGHT:
case ROCKPAINT_DRAW:
if( *bbuf_s == '.' && !bbuf_s[1] ) break;
a = bbuf;
while( *a ) a++;
if( *bbuf_s == '.' && bbuf_s[1] == '.' && !bbuf_s[2] )
{ {
a--; a--;
if( a == bbuf ) break; if( a == bbuf ) break;
if( *a == '/' ) a--; if( *a == '/' ) a--;
while( *a != '/' ) a--; while( *a != '/' ) a--;
*++a = '\0'; rb->strcpy( bbuf_s, ++a );
/* select parent directory */
bbuf_s[rb->strlen(bbuf_s)-1] = '\0';
*a = '\0';
reload = true;
break; break;
} }
rb->strcpy( a, bbuf_s ); rb->snprintf( a, bbuf+sizeof(bbuf)-a, "%s/", bbuf_s );
while( *a ) a++; reload = true;
*a++ = '/';
*a = '\0';
fvi = si = 0;
break; break;
case ACTION_STD_MENU:
*tree = backup;
rb->set_current_file( backup.currdir );
return false;
} }
} }
#undef WIDTH
#undef HEIGHT
#undef LINE_SPACE
} }
/*********************************************************************** /***********************************************************************
@ -898,7 +731,6 @@ static bool browse( char *dst, int dst_size, const char *start )
***********************************************************************/ ***********************************************************************/
static bool browse_fonts( char *dst, int dst_size ) static bool browse_fonts( char *dst, int dst_size )
{ {
char old_font[MAX_PATH];
#define WIDTH ( LCD_WIDTH - 20 ) #define WIDTH ( LCD_WIDTH - 20 )
#define HEIGHT ( LCD_HEIGHT - 20 ) #define HEIGHT ( LCD_HEIGHT - 20 )
#define LINE_SPACE 2 #define LINE_SPACE 2
@ -923,7 +755,7 @@ static bool browse_fonts( char *dst, int dst_size )
int fw; int fw;
#define fontname_buf buffer.text.fontname_buf #define fontname_buf buffer.text.fontname_buf
rb->snprintf( old_font, MAX_PATH, rb->snprintf( buffer.text.old_font, MAX_PATH,
FONT_DIR "/%s.fnt", FONT_DIR "/%s.fnt",
rb->global_settings->font_file ); rb->global_settings->font_file );
@ -1019,7 +851,7 @@ static bool browse_fonts( char *dst, int dst_size )
nvih = fh; nvih = fh;
} }
} }
rb->font_load( old_font ); rb->font_load( buffer.text.old_font );
rb->closedir( d ); rb->closedir( d );
} }
@ -1501,6 +1333,74 @@ static void draw_vflip( int x1, int y1, int x2, int y2 )
rb->lcd_update(); rb->lcd_update();
} }
/* direction: -1 = left, 1 = right */
static void draw_rot_90_deg( int x1, int y1, int x2, int y2, int direction )
{
int i, j;
if( x1 > x2 )
{
i = x1;
x1 = x2;
x2 = i;
}
if( y1 > y2 )
{
i = y1;
y1 = y2;
y2 = i;
}
copy_to_clipboard();
fb_data color = rp_colors[ bgdrawcolor ];
const int width = x2 - x1, height = y2 - y1;
const int sub_half = width/2-height/2, add_half = (width+height)/2;
if( width > height )
{
for( i = 0; i <= height; i++ )
{
for( j = 0; j < sub_half; j++ )
save_buffer[(y1+i)*COLS+x1+j] = color;
for( j = add_half+1; j <= width; j++ )
save_buffer[(y1+i)*COLS+x1+j] = color;
}
}
else if( width < height )
{
for( j = 0; j <= width; j++ )
{
for( i = 0; i < -sub_half; i++ )
save_buffer[(y1+i)*COLS+x1+j] = color;
for( i = add_half+1; i <= height; i++ )
save_buffer[(y1+i)*COLS+x1+j] = color;
}
}
int x3 = x1 + sub_half, y3 = y1 - sub_half;
int is = x3<0?-x3:0, ie = COLS-x3-1, js = y3<0?-y3:0, je = ROWS-y3-1;
if( ie > height ) ie = height;
if( je > width ) je = width;
for( i = is; i <= ie; i++ )
{
for( j = js; j <= je; j++ )
{
int x, y;
if(direction > 0)
{
x = x1+j;
y = y1+height-i;
}
else
{
x = x1+width-j;
y = y1+i;
}
save_buffer[(y3+j)*COLS+x3+i] = buffer.clipboard[y*COLS+x];
}
}
restore_screen();
rb->lcd_update();
}
static void draw_paste_rectangle( int src_x1, int src_y1, int src_x2, static void draw_paste_rectangle( int src_x1, int src_y1, int src_x2,
int src_y2, int x1, int y1, int mode ) int src_y2, int x1, int y1, int mode )
{ {
@ -1558,18 +1458,18 @@ static void show_grid( bool update )
static void draw_text( int x, int y ) static void draw_text( int x, int y )
{ {
int selected = 0;
buffer.text.text[0] = '\0'; buffer.text.text[0] = '\0';
rb->snprintf( buffer.text.old_font, MAX_PATH, rb->snprintf( buffer.text.old_font, MAX_PATH,
FONT_DIR "/%s.fnt", FONT_DIR "/%s.fnt",
rb->global_settings->font_file ); rb->global_settings->font_file );
while( 1 ) while( 1 )
{ {
int m = TEXT_MENU_TEXT; switch( rb->do_menu( &text_menu, &selected, NULL, NULL ) )
switch( m = menu_display( text_menu, m ) )
{ {
case TEXT_MENU_TEXT: case TEXT_MENU_TEXT:
rb->lcd_set_foreground(COLOR_BLACK);
rb->kbd_input( buffer.text.text, MAX_TEXT ); rb->kbd_input( buffer.text.text, MAX_TEXT );
restore_screen();
break; break;
case TEXT_MENU_FONT: case TEXT_MENU_FONT:
@ -1583,7 +1483,7 @@ static void draw_text( int x, int y )
rb->lcd_set_foreground( rp_colors[ drawcolor ] ); rb->lcd_set_foreground( rp_colors[ drawcolor ] );
while( 1 ) while( 1 )
{ {
unsigned int button; int button;
restore_screen(); restore_screen();
rb->lcd_putsxy( x, y, buffer.text.text ); rb->lcd_putsxy( x, y, buffer.text.text );
rb->lcd_update(); rb->lcd_update();
@ -1614,10 +1514,14 @@ static void draw_text( int x, int y )
break; break;
case ROCKPAINT_DRAW: case ROCKPAINT_DRAW:
button = 1242; break;
default:
if(rb->default_event_handler(button)
== SYS_USB_CONNECTED)
button = ROCKPAINT_DRAW;
break; break;
} }
if( button == 1242 ) break; if( button == ROCKPAINT_DRAW ) break;
} }
break; break;
@ -1626,6 +1530,7 @@ static void draw_text( int x, int y )
buffer_putsxyofs( save_buffer, COLS, ROWS, x, y, 0, buffer_putsxyofs( save_buffer, COLS, ROWS, x, y, 0,
buffer.text.text ); buffer.text.text );
case TEXT_MENU_CANCEL: case TEXT_MENU_CANCEL:
default:
restore_screen(); restore_screen();
rb->font_load( buffer.text.old_font ); rb->font_load( buffer.text.old_font );
return; return;
@ -2541,10 +2446,11 @@ static void clear_drawing(void)
static void goto_menu(void) static void goto_menu(void)
{ {
int multi; int multi;
int selected = 0;
while( 1 ) while( 1 )
{ {
switch( menu_display( main_menu, 1 ) ) switch( rb->do_menu( &main_menu, &selected, NULL, false ) )
{ {
case MAIN_MENU_NEW: case MAIN_MENU_NEW:
clear_drawing(); clear_drawing();
@ -2569,6 +2475,7 @@ static void goto_menu(void)
break; break;
case MAIN_MENU_SAVE: case MAIN_MENU_SAVE:
rb->lcd_set_foreground(COLOR_BLACK);
if (!filename[0]) if (!filename[0])
rb->strcpy(filename,"/"); rb->strcpy(filename,"/");
if( !rb->kbd_input( filename, MAX_PATH ) ) if( !rb->kbd_input( filename, MAX_PATH ) )
@ -2582,15 +2489,19 @@ static void goto_menu(void)
break; break;
case MAIN_MENU_BRUSH_SIZE: case MAIN_MENU_BRUSH_SIZE:
multi = menu_display( size_menu, bsize ); for(multi = 0; multi<4; multi++)
if( multi != - 1 ) if(bsize == times_list[multi]) break;
bsize = multi; rb->do_menu( &size_menu, &multi, NULL, false );
if( multi >= 0 )
bsize = times_list[multi];
break; break;
case MAIN_MENU_BRUSH_SPEED: case MAIN_MENU_BRUSH_SPEED:
multi = menu_display( speed_menu, bspeed ); for(multi = 0; multi<3; multi++)
if( multi != -1 ) if(bspeed == times_list[multi]) break;
bspeed = multi; rb->do_menu( &speed_menu, &multi, NULL, false );
if( multi >= 0 )
bspeed = times_list[multi];
break; break;
case MAIN_MENU_COLOR: case MAIN_MENU_COLOR:
@ -2598,17 +2509,21 @@ static void goto_menu(void)
break; break;
case MAIN_MENU_GRID_SIZE: case MAIN_MENU_GRID_SIZE:
multi = menu_display( gridsize_menu, gridsize ); for(multi = 0; multi<4; multi++)
if( multi != - 1 ) if(gridsize == gridsize_list[multi]) break;
gridsize = multi; rb->do_menu( &gridsize_menu, &multi, NULL, false );
if( multi >= 0 )
gridsize = gridsize_list[multi];
break; break;
case MAIN_MENU_EXIT: case MAIN_MENU_EXIT:
restore_screen();
quit=true; quit=true;
return; return;
case MAIN_MENU_RESUME: case MAIN_MENU_RESUME:
case MENU_ESC: default:
restore_screen();
return; return;
}/* end switch */ }/* end switch */
}/* end while */ }/* end while */
@ -2660,6 +2575,7 @@ static bool rockpaint_loop( void )
case ROCKPAINT_MENU: case ROCKPAINT_MENU:
inv_cursor(false); inv_cursor(false);
goto_menu(); goto_menu();
restore_screen();
inv_cursor(true); inv_cursor(true);
break; break;
@ -2697,8 +2613,8 @@ static bool rockpaint_loop( void )
else if( tool == SelectRectangle else if( tool == SelectRectangle
&& ( prev_x2 == -1 || prev_y2 == -1 ) ) && ( prev_x2 == -1 || prev_y2 == -1 ) )
{ {
tool_mode = menu_display( select_menu, tool_mode = rb->do_menu( &select_menu,
SELECT_MENU_CUT ); NULL, NULL, false );
switch( tool_mode ) switch( tool_mode )
{ {
case SELECT_MENU_CUT: case SELECT_MENU_CUT:
@ -2726,22 +2642,29 @@ static bool rockpaint_loop( void )
break; break;
case SELECT_MENU_ROTATE90: case SELECT_MENU_ROTATE90:
draw_rot_90_deg( prev_x, prev_y, x, y, 1 );
reset_tool();
break; break;
case SELECT_MENU_ROTATE180: case SELECT_MENU_ROTATE180:
draw_hflip( prev_x, prev_y, x, y ); draw_hflip( prev_x, prev_y, x, y );
draw_vflip( prev_x, prev_y, x, y ); draw_vflip( prev_x, prev_y, x, y );
reset_tool(); reset_tool();
break; break;
case SELECT_MENU_ROTATE270: case SELECT_MENU_ROTATE270:
draw_rot_90_deg( prev_x, prev_y, x, y, -1 );
reset_tool();
break; break;
case SELECT_MENU_CANCEL: case SELECT_MENU_CANCEL:
reset_tool(); reset_tool();
break; break;
case MENU_ESC: default:
break; break;
} }
restore_screen();
} }
else if( tool == Curve else if( tool == Curve
&& ( prev_x3 == -1 || prev_y3 == -1 ) ) && ( prev_x3 == -1 || prev_y3 == -1 ) )

View file

@ -24,7 +24,6 @@
#include "lib/configfile.h" #include "lib/configfile.h"
#include "button.h" #include "button.h"
#include "lcd.h" #include "lcd.h"
#include "lib/oldmenuapi.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -773,15 +772,10 @@ static struct configdata config[] = {
{ TYPE_INT, 0, 1, { .int_p = &sol_disk.draw_type }, "draw_type", NULL } { TYPE_INT, 0, 1, { .int_p = &sol_disk.draw_type }, "draw_type", NULL }
}; };
char draw_option_string[32]; static const struct opt_items drawcards[2] = {
{ "Draw Three Cards", -1 },
static void create_draw_option_string(void) { "Draw One Card", -1 },
{ };
if (sol.draw_type == 0)
rb->strcpy(draw_option_string, "Draw Three Cards");
else
rb->strcpy(draw_option_string, "Draw One Card");
}
void solitaire_init(void); void solitaire_init(void);
@ -790,37 +784,22 @@ enum { MENU_RESUME, MENU_SAVE_AND_QUIT, MENU_QUIT, MENU_USB };
int solitaire_menu(bool in_game) int solitaire_menu(bool in_game)
{ {
int m; int selected = 0;
int result = -1; int result = -1;
int i = 0;
struct menu_item items[6]; MENUITEM_STRINGLIST(menu, "Solitaire Menu", NULL,
"Start Game", "Draw Cards Option",
"Help", "Audio Playback", "Quit");
MENUITEM_STRINGLIST(menu_in_game, "Solitaire Menu", NULL,
"Resume Game", "Restart Game", "Help",
"Audio Playback", "Save and Quit", "Quit");
if( in_game )
{
items[i++].desc = "Resume Game";
items[i++].desc = "Restart Game";
}
else
{
items[i++].desc = "Start Game";
items[i++].desc = draw_option_string;
}
items[i++].desc = "Help";
items[i++].desc = "Audio Playback";
if( in_game )
{
items[i++].desc = "Save and Quit";
}
items[i++].desc = "Quit";
create_draw_option_string();
m = menu_init(items, i, NULL, NULL, NULL, NULL);
while (result < 0) while (result < 0)
{ {
switch (menu_show(m)) switch (rb->do_menu(in_game? &menu_in_game: &menu,
&selected, NULL, false))
{ {
case MENU_SELECTED_EXIT: default:
result = MENU_RESUME; result = MENU_RESUME;
break; break;
@ -840,8 +819,9 @@ int solitaire_menu(bool in_game)
} }
else else
{ {
sol.draw_type = (sol.draw_type + 1) % 2; if (rb->set_option("Draw Cards Option", &sol.draw_type,
create_draw_option_string(); INT, drawcards, 2, NULL))
result = MENU_USB;
} }
break; break;
@ -866,7 +846,6 @@ int solitaire_menu(bool in_game)
break; break;
} }
} }
menu_exit(m);
return result; return result;
} }

View file

@ -60,7 +60,6 @@ Example ".ss" file, and one with a saved state:
#include "plugin.h" #include "plugin.h"
#include "lib/configfile.h" #include "lib/configfile.h"
#include "lib/oldmenuapi.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -1167,30 +1166,20 @@ enum {
bool sudoku_menu(struct sudoku_state_t* state) bool sudoku_menu(struct sudoku_state_t* state)
{ {
int m;
int result; int result;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Sudoku Menu", NULL,
[SM_AUDIO_PLAYBACK] = { "Audio Playback", NULL }, "Audio Playback",
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
[SM_NUMBER_DISPLAY] = { "Number Display", NULL }, "Number Display",
#endif #endif
#ifdef SUDOKU_BUTTON_POSSIBLE #ifdef SUDOKU_BUTTON_POSSIBLE
[SM_SHOW_MARKINGS] = { "Show Markings", NULL }, "Show Markings",
#endif #endif
[SM_SAVE] = { "Save", NULL }, "Save", "Reload", "Clear", "Solve",
[SM_RELOAD] = { "Reload", NULL }, "Generate", "New", "Quit");
[SM_CLEAR] = { "Clear", NULL },
[SM_SOLVE] = { "Solve", NULL },
[SM_GENERATE] = { "Generate", NULL },
[SM_NEW] = { "New", NULL },
[SM_QUIT] = { "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
result=menu_show(m); result = rb->do_menu(&menu, NULL, NULL, false);
switch (result) { switch (result) {
case SM_AUDIO_PLAYBACK: case SM_AUDIO_PLAYBACK:
@ -1235,7 +1224,6 @@ bool sudoku_menu(struct sudoku_state_t* state)
case SM_QUIT: case SM_QUIT:
save_sudoku(state); save_sudoku(state);
menu_exit(m);
return true; return true;
break; break;
@ -1243,26 +1231,18 @@ bool sudoku_menu(struct sudoku_state_t* state)
break; break;
} }
menu_exit(m);
return (result==MENU_ATTACHED_USB); return (result==MENU_ATTACHED_USB);
} }
/* Menu used when user is in edit mode - i.e. creating a new game manually */ /* Menu used when user is in edit mode - i.e. creating a new game manually */
int sudoku_edit_menu(struct sudoku_state_t* state) int sudoku_edit_menu(struct sudoku_state_t* state)
{ {
int m;
int result; int result;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Edit Menu", NULL,
{ "Save as", NULL }, "Save as", "Quit");
{ "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
result=menu_show(m); result = rb->do_menu(&menu, NULL, NULL, false);
switch (result) { switch (result) {
case 0: /* Save new game */ case 0: /* Save new game */
@ -1281,8 +1261,6 @@ int sudoku_edit_menu(struct sudoku_state_t* state)
break; break;
} }
menu_exit(m);
return result; return result;
} }

View file

@ -20,7 +20,6 @@
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "lib/oldmenuapi.h"
#include "lib/helper.h" #include "lib/helper.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -406,11 +405,10 @@ static bool test_speed(void)
/* this is the plugin entry point */ /* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter) enum plugin_status plugin_start(const void* parameter)
{ {
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Test Disk Menu", NULL,
{ "Disk speed", test_speed }, "Disk speed", "Write & verify");
{ "Write & verify", test_fs }, int selected=0;
}; bool quit = false;
int m;
int align; int align;
DIR *dir; DIR *dir;
@ -440,10 +438,21 @@ enum plugin_status plugin_start(const void* parameter)
/* Turn off backlight timeout */ /* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */ backlight_force_on(); /* backlight control in lib/helper.c */
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, while(!quit)
NULL, NULL, NULL); {
menu_run(m); switch(rb->do_menu(&menu, &selected, NULL, false))
menu_exit(m); {
case 0:
test_speed();
break;
case 1:
test_fs();
break;
default:
quit = true;
break;
}
}
/* Turn on backlight timeout (revert to settings) */ /* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */ backlight_use_settings(); /* backlight control in lib/helper.c */

View file

@ -19,7 +19,6 @@
* *
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "lib/oldmenuapi.h"
/* This plugin generates a 1kHz tone + noise in order to quickly verify /* This plugin generates a 1kHz tone + noise in order to quickly verify
* hardware samplerate setup is operating correctly. * hardware samplerate setup is operating correctly.
@ -285,32 +284,23 @@ enum plugin_status plugin_start(const void *parameter)
MENU_QUIT, MENU_QUIT,
}; };
static const struct menu_item items[] = MENUITEM_STRINGLIST(menu, "Test Sampr Menu", NULL,
{
#ifndef HAVE_VOLUME_IN_LIST #ifndef HAVE_VOLUME_IN_LIST
[MENU_VOL_SET] = "Set Volume",
{ "Set Volume", NULL },
#endif /* HAVE_VOLUME_IN_LIST */ #endif /* HAVE_VOLUME_IN_LIST */
[MENU_SAMPR_SET] = "Set Samplerate", "Quit");
{ "Set Samplerate", NULL },
[MENU_QUIT] =
{ "Quit", NULL },
};
bool exit = false; bool exit = false;
int m; int selected = 0;
/* Disable all talking before initializing IRAM */ /* Disable all talking before initializing IRAM */
rb->talk_disable(true); rb->talk_disable(true);
PLUGIN_IRAM_INIT(rb); PLUGIN_IRAM_INIT(rb);
m = menu_init(items, ARRAYLEN(items),
NULL, NULL, NULL, NULL);
while (!exit) while (!exit)
{ {
int result = menu_show(m); int result = rb->do_menu(&menu, &selected, NULL, false);
switch (result) switch (result)
{ {
@ -329,8 +319,6 @@ enum plugin_status plugin_start(const void *parameter)
} }
} }
menu_exit(m);
rb->talk_disable(false); rb->talk_disable(false);
return PLUGIN_OK; return PLUGIN_OK;

View file

@ -22,7 +22,6 @@
#include "plugin.h" #include "plugin.h"
#include <ctype.h> #include <ctype.h>
#include "lib/playback_control.h" #include "lib/playback_control.h"
#include "lib/oldmenuapi.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -1448,30 +1447,37 @@ static bool autoscroll_speed_setting(void)
&prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); &prefs.autoscroll_speed, NULL, 1, 1, 10, NULL);
} }
MENUITEM_FUNCTION(encoding_item, 0, "Encoding", encoding_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", word_wrap_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(line_mode_item, 0, "Line Mode", line_mode_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(view_mode_item, 0, "Wide View", view_mode_setting,
NULL, NULL, Icon_NOICON);
#ifdef HAVE_LCD_BITMAP
MENUITEM_FUNCTION(scrollbar_item, 0, "Show Scrollbar", scrollbar_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", page_mode_setting,
NULL, NULL, Icon_NOICON);
#endif
MENUITEM_FUNCTION(scroll_mode_item, 0, "Scroll Mode", scroll_mode_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
autoscroll_speed_setting, NULL, NULL, Icon_NOICON);
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
&encoding_item, &word_wrap_item, &line_mode_item, &view_mode_item,
#ifdef HAVE_LCD_BITMAP
&scrollbar_item, &page_mode_item,
#endif
&scroll_mode_item, &autoscroll_speed_item);
static bool viewer_options_menu(void) static bool viewer_options_menu(void)
{ {
int m;
bool result; bool result;
result = (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB);
static const struct menu_item items[] = {
{"Encoding", encoding_setting },
{"Word Wrap", word_wrap_setting },
{"Line Mode", line_mode_setting },
{"Wide View", view_mode_setting },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{"Show Scrollbar", scrollbar_setting },
{"Overlap Pages", page_mode_setting },
#endif
{"Scroll Mode", scroll_mode_setting},
{"Auto-Scroll Speed", autoscroll_speed_setting },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
result = menu_run(m);
menu_exit(m);
#ifdef HAVE_LCD_BITMAP
/* Show-scrollbar mode for current view-width mode */ /* Show-scrollbar mode for current view-width mode */
init_need_scrollbar(); init_need_scrollbar();
#endif #endif
@ -1480,23 +1486,15 @@ static bool viewer_options_menu(void)
static void viewer_menu(void) static void viewer_menu(void)
{ {
int m;
int result; int result;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL,
{"Quit", NULL }, "Return", "Viewer Options",
{"Viewer Options", NULL }, "Show Playback Menu", "Quit");
{"Show Playback Menu", NULL },
{"Return", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); result = rb->do_menu(&menu, NULL, NULL, false);
result=menu_show(m);
switch (result) switch (result)
{ {
case 0: /* quit */ case 0: /* return */
menu_exit(m);
viewer_exit(NULL);
done = true;
break; break;
case 1: /* change settings */ case 1: /* change settings */
done = viewer_options_menu(); done = viewer_options_menu();
@ -1504,10 +1502,11 @@ static void viewer_menu(void)
case 2: /* playback control */ case 2: /* playback control */
playback_control(NULL); playback_control(NULL);
break; break;
case 3: /* return */ case 3: /* quit */
viewer_exit(NULL);
done = true;
break; break;
} }
menu_exit(m);
viewer_draw(col); viewer_draw(col);
} }

View file

@ -20,7 +20,6 @@
#include "zxmisc.h" #include "zxmisc.h"
#include "zxconfig.h" #include "zxconfig.h"
#include "lib/configfile.h" #include "lib/configfile.h"
#include "lib/oldmenuapi.h"
#include "spperif.h" #include "spperif.h"
#include "z80.h" #include "z80.h"
@ -134,25 +133,18 @@ int spcf_read_conf_file(const char *filename)
/* set keys */ /* set keys */
static void set_keys(void){ static void set_keys(void){
int m;
char c; char c;
int selected=0;
int result; int result;
int menu_quit=0; int menu_quit=0;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Custom keymap", NULL,
{ "Map Up key", NULL }, "Map Up key", "Map Down key", "Map Left key",
{ "Map Down key", NULL }, "Map Right key", "Map Fire/Jump key");
{ "Map Left key", NULL },
{ "Map Right key", NULL },
{ "Map Fire/Jump key", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
@ -161,7 +153,7 @@ static void set_keys(void){
{ {
settings.keymap[0]=c; settings.keymap[0]=c;
} }
break; break;
case 1: case 1:
if (!zx_kbd_input((char*) &c)) if (!zx_kbd_input((char*) &c))
{ {
@ -191,41 +183,33 @@ static void set_keys(void){
break; break;
} }
} }
menu_exit(m);
} }
/* select predefined keymap */ /* select predefined keymap */
static void select_keymap(void){ static void select_keymap(void){
int m; int selected=0;
int result; int result;
int menu_quit=0; int menu_quit=0;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Predefined keymap", NULL,
{ "2w90z", NULL }, "2w90z", "qaopS", "7658S");
{ "qaopS", NULL },
{ "7658S", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
case 0: case 0:
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[0].desc , sizeof(items[0].desc)); rb->memcpy ( (void*)&settings.keymap[0] , (void*)"2w90z" , 5);
menu_quit=1; menu_quit=1;
break; break;
case 1: case 1:
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[1].desc , sizeof(items[1].desc)); rb->memcpy ( (void*)&settings.keymap[0] , (void*)"qaopS" , 5);
menu_quit=1; menu_quit=1;
break; break;
case 2: case 2:
rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[2].desc , sizeof(items[2].desc)); rb->memcpy ( (void*)&settings.keymap[0] , (void*)"7658S" , 5);
menu_quit=1; menu_quit=1;
break; break;
default: default:
@ -233,8 +217,6 @@ static void select_keymap(void){
break; break;
} }
} }
menu_exit(m);
} }
/* options menu */ /* options menu */
@ -243,20 +225,15 @@ static void options_menu(void){
{ "No", -1 }, { "No", -1 },
{ "Yes", -1 }, { "Yes", -1 },
}; };
int m; int selected;
int result; int result;
int menu_quit=0; int menu_quit=0;
int new_setting; int new_setting;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "Options", NULL,
{ "Map Keys to kempston", NULL }, "Map Keys to kempston", "Display Speed",
{ "Display Speed", NULL }, "Invert Colors", "Frameskip", "Sound", "Volume",
{ "Invert Colors", NULL }, "Predefined keymap", "Custom keymap");
{ "Frameskip", NULL },
{ "Sound", NULL },
{ "Volume", NULL },
{ "Predefined keymap", NULL },
{ "Custom keymap", NULL },
};
static struct opt_items frameskip_items[] = { static struct opt_items frameskip_items[] = {
{ "0", -1 }, { "0", -1 },
{ "1", -1 }, { "1", -1 },
@ -269,15 +246,12 @@ static void options_menu(void){
{ "8", -1 }, { "8", -1 },
{ "9", -1 }, { "9", -1 },
}; };
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
@ -287,7 +261,7 @@ static void options_menu(void){
no_yes, 2, NULL); no_yes, 2, NULL);
if (new_setting != settings.kempston ) if (new_setting != settings.kempston )
settings.kempston=new_setting; settings.kempston=new_setting;
break; break;
case 1: case 1:
new_setting = settings.showfps; new_setting = settings.showfps;
rb->set_option("Display Speed",&new_setting,INT, rb->set_option("Display Speed",&new_setting,INT,
@ -339,8 +313,6 @@ static void options_menu(void){
break; break;
} }
} }
menu_exit(m);
} }
/* menu */ /* menu */
@ -349,29 +321,21 @@ static bool zxbox_menu(void)
#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
rb->pcm_play_stop(); rb->pcm_play_stop();
#endif #endif
int m; int selected=0;
int result; int result;
int menu_quit=0; int menu_quit=0;
int exit=0; int exit=0;
char c; char c;
static const struct menu_item items[] = { MENUITEM_STRINGLIST(menu, "ZXBox Menu", NULL,
{ "VKeyboard", NULL }, "VKeyboard", "Play/Pause Tape",
{ "Play/Pause Tape", NULL }, "Save quick snapshot", "Load quick snapshot",
{ "Save quick snapshot", NULL }, "Save Snapshot", "Toggle \"fast\" mode",
{ "Load quick snapshot", NULL }, "Options", "Quit");
{ "Save Snapshot", NULL },
{ "Toggle \"fast\" mode", NULL },
{ "Options", NULL },
{ "Quit", NULL },
};
m = menu_init(items, sizeof(items) / sizeof(*items),
NULL, NULL, NULL, NULL);
rb->button_clear_queue(); rb->button_clear_queue();
while (!menu_quit) { while (!menu_quit) {
result=menu_show(m); result = rb->do_menu(&menu, &selected, NULL, false);
switch(result) switch(result)
{ {
@ -415,7 +379,6 @@ static bool zxbox_menu(void)
} }
} }
menu_exit(m);
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) #if defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(true); rb->cpu_boost(true);
#endif #endif