mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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:
parent
cb57a568e8
commit
af9f405651
22 changed files with 729 additions and 1569 deletions
|
@ -298,7 +298,6 @@ static int chessclock_set_int(char* string,
|
|||
#define FLAGS_SET_INT_SECONDS 1
|
||||
|
||||
static char * show_time(int secs);
|
||||
static int simple_menu(int nr, unsigned char **strarr);
|
||||
|
||||
static bool pause;
|
||||
|
||||
|
@ -514,53 +513,57 @@ static int run_timer(int nr)
|
|||
/* MENU */
|
||||
case CHC_MENU:
|
||||
{
|
||||
int ret;
|
||||
char *menu[]={"Delete player", "Restart round",
|
||||
"Set round time", "Set total time"};
|
||||
ret=simple_menu(4, (unsigned char **)menu);
|
||||
if (ret==-1) {
|
||||
retval = 3;
|
||||
done=true;
|
||||
} else if (ret==-2) {
|
||||
} else if (ret==0) {
|
||||
/* delete timer */
|
||||
timer_holder[nr].hidden=true;
|
||||
retval=1;
|
||||
done=true;
|
||||
break;
|
||||
} else if (ret==1) {
|
||||
/* restart */
|
||||
ticks=0;
|
||||
break;
|
||||
} else if (ret==2) {
|
||||
/* set round time */
|
||||
int res;
|
||||
int val=(max_ticks-ticks)/HZ;
|
||||
res=chessclock_set_int("Round time",
|
||||
&val,
|
||||
10, 0, MAX_TIME,
|
||||
FLAGS_SET_INT_SECONDS);
|
||||
if (res==-1) { /*usb*/
|
||||
MENUITEM_STRINGLIST(menu, "Menu", NULL,
|
||||
"Delete player", "Restart round",
|
||||
"Set round time", "Set total time");
|
||||
|
||||
int val, res;
|
||||
switch(rb->do_menu(&menu, NULL, NULL, false))
|
||||
{
|
||||
case 0:
|
||||
/* delete timer */
|
||||
timer_holder[nr].hidden=true;
|
||||
retval=1;
|
||||
done=true;
|
||||
break;
|
||||
case 1:
|
||||
/* restart */
|
||||
ticks=0;
|
||||
break;
|
||||
case 2:
|
||||
/* set round time */
|
||||
val=(max_ticks-ticks)/HZ;
|
||||
res=chessclock_set_int("Round time",
|
||||
&val,
|
||||
10, 0, MAX_TIME,
|
||||
FLAGS_SET_INT_SECONDS);
|
||||
if (res==-1) { /*usb*/
|
||||
retval = 3;
|
||||
done=true;
|
||||
} else if (res==1) {
|
||||
ticks=max_ticks-val*HZ;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* set total time */
|
||||
val=timer_holder[nr].total_time;
|
||||
res=chessclock_set_int("Total time",
|
||||
&val,
|
||||
10, 0, MAX_TIME,
|
||||
FLAGS_SET_INT_SECONDS);
|
||||
if (res==-1) { /*usb*/
|
||||
retval = 3;
|
||||
done=true;
|
||||
} else if (res==1) {
|
||||
timer_holder[nr].total_time=val;
|
||||
}
|
||||
break;
|
||||
case MENU_ATTACHED_USB:
|
||||
retval = 3;
|
||||
done=true;
|
||||
} else if (res==1) {
|
||||
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;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rb->lcd_clear_display();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -664,55 +667,3 @@ static char * show_time(int seconds)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/* -1 = USB
|
||||
-2 = cancel
|
||||
*/
|
||||
static int simple_menu(int nr, unsigned char **strarr)
|
||||
{
|
||||
int show=0;
|
||||
int button;
|
||||
rb->lcd_clear_display();
|
||||
|
||||
while (1) {
|
||||
if (show>=nr)
|
||||
show=0;
|
||||
if (show<0)
|
||||
show=nr-1;
|
||||
rb->lcd_puts_scroll(0, FIRST_LINE, strarr[show]);
|
||||
rb->lcd_update();
|
||||
|
||||
button = rb->button_get(true);
|
||||
switch(button) {
|
||||
case CHC_SETTINGS_INC:
|
||||
case CHC_SETTINGS_INC | BUTTON_REPEAT:
|
||||
show++;
|
||||
break;
|
||||
|
||||
case CHC_SETTINGS_DEC:
|
||||
case CHC_SETTINGS_DEC | BUTTON_REPEAT:
|
||||
show--;
|
||||
break;
|
||||
|
||||
case CHC_SETTINGS_OK:
|
||||
#ifdef CHC_SETTINGS_OK2
|
||||
case CHC_SETTINGS_OK2:
|
||||
#endif
|
||||
return show;
|
||||
break;
|
||||
|
||||
case CHC_SETTINGS_CANCEL:
|
||||
#ifdef CHC_SETTINGS_CANCEL2
|
||||
case CHC_SETTINGS_CANCEL2:
|
||||
#endif
|
||||
return -2; /* cancel */
|
||||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
||||
return -1; /* been in usb mode */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "i_system.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "st_stuff.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
@ -217,8 +216,8 @@ const unsigned char wads_builtin[7][30] =
|
|||
};
|
||||
|
||||
int namemap[7];
|
||||
static struct menu_item *addons;
|
||||
static struct menu_item *demolmp;
|
||||
static char **addons;
|
||||
static char **demolmp;
|
||||
char addon[200];
|
||||
// This sets up the base game and builds up myargv/c
|
||||
bool Dhandle_ver (int dver)
|
||||
|
@ -274,14 +273,14 @@ bool Dhandle_ver (int dver)
|
|||
|
||||
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);
|
||||
modifiedgame = true;
|
||||
}
|
||||
|
||||
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);
|
||||
G_DeferedPlayDemo(addon);
|
||||
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
|
||||
// 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;
|
||||
DIR *filedir;
|
||||
struct dirent *dptr;
|
||||
char *startpt;
|
||||
struct menu_item *temp;
|
||||
char **temp;
|
||||
|
||||
filedir=rb->opendir(directory);
|
||||
|
||||
if(filedir==NULL)
|
||||
{
|
||||
temp=malloc(sizeof(struct menu_item));
|
||||
temp[0].desc=firstentry;
|
||||
temp[0].function=0;
|
||||
temp=malloc(sizeof(char *));
|
||||
temp[0]=firstentry;
|
||||
*names=temp;
|
||||
return 1;
|
||||
}
|
||||
|
@ -351,9 +349,8 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
|
|||
filedir=rb->opendir(directory);
|
||||
|
||||
i++;
|
||||
temp=malloc(i*sizeof(struct menu_item));
|
||||
temp[0].desc=firstentry;
|
||||
temp[0].function=0;
|
||||
temp=malloc(i*sizeof(char *));
|
||||
temp[0]=firstentry;
|
||||
i=1;
|
||||
|
||||
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));
|
||||
strcpy(startpt,dptr->d_name);
|
||||
temp[i].desc=startpt;
|
||||
temp[i].function=0;
|
||||
temp[i]=startpt;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +440,7 @@ static int translatekey(int key)
|
|||
|
||||
int Oset_keys()
|
||||
{
|
||||
int m, result;
|
||||
int selected=0, result;
|
||||
int menuquit=0;
|
||||
|
||||
|
||||
|
@ -483,36 +479,24 @@ int Oset_keys()
|
|||
|
||||
int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys);
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Game Right", NULL },
|
||||
{ "Game Left", NULL },
|
||||
{ "Game Up", NULL },
|
||||
{ "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);
|
||||
MENUITEM_STRINGLIST(menu, "Set Keys", NULL,
|
||||
"Game Right", "Game Left", "Game Up", "Game Down",
|
||||
"Game Shoot", "Game Open", "Game Strafe",
|
||||
"Game Weapon", "Game Automap");
|
||||
|
||||
while(!menuquit)
|
||||
{
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
if(result<0)
|
||||
menuquit=1;
|
||||
else
|
||||
{
|
||||
*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]);
|
||||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -525,24 +509,17 @@ static bool Doptions()
|
|||
{ "On", -1 },
|
||||
};
|
||||
|
||||
int m, result;
|
||||
int selected=0, result;
|
||||
int menuquit=0;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Set Keys", NULL },
|
||||
{ "Sound", NULL },
|
||||
{ "Timedemo", NULL },
|
||||
{ "Player Bobbing", NULL },
|
||||
{ "Weapon Recoil", NULL },
|
||||
{ "Translucency", NULL },
|
||||
{ "Fake Contrast", NULL },
|
||||
{ "Always Run", NULL },
|
||||
{ "Headsup Display", NULL },
|
||||
{ "Statusbar Always Red", NULL },
|
||||
MENUITEM_STRINGLIST(menu, "Options", NULL,
|
||||
"Set Keys", "Sound", "Timedemo", "Player Bobbing",
|
||||
"Weapon Recoil", "Translucency", "Fake Contrast",
|
||||
"Always Run", "Headsup Display", "Statusbar Always Red",
|
||||
#if(LCD_HEIGHT>LCD_WIDTH)
|
||||
{ "Rotate Screen 90 deg", NULL },
|
||||
"Rotate Screen 90 deg",
|
||||
#endif
|
||||
};
|
||||
);
|
||||
|
||||
void *options[]={
|
||||
&enable_sound,
|
||||
|
@ -559,36 +536,48 @@ static bool Doptions()
|
|||
#endif
|
||||
};
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
while(!menuquit)
|
||||
{
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
if(result==0)
|
||||
Oset_keys();
|
||||
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
|
||||
menuquit=1;
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
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;
|
||||
(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;
|
||||
|
||||
m = menu_init(menu, items,NULL, NULL, NULL, NULL);
|
||||
|
||||
result= menu_show(m);
|
||||
menu_exit(m);
|
||||
if(result<items && result>=0)
|
||||
return result;
|
||||
return 0;
|
||||
if(info.selection<count && info.selection>=0)
|
||||
*selected = info.selection;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -596,22 +585,16 @@ int menuchoice(struct menu_item *menu, int items)
|
|||
//
|
||||
int doom_menu()
|
||||
{
|
||||
int m;
|
||||
int result;
|
||||
int selected=0, result;
|
||||
int status;
|
||||
int gamever;
|
||||
bool menuquit=0;
|
||||
|
||||
static struct opt_items names[7];
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Game", NULL },
|
||||
{ "Addons", NULL },
|
||||
{ "Demos", NULL },
|
||||
{ "Options", NULL },
|
||||
{ "Play Game", NULL },
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Doom Menu", NULL,
|
||||
"Game", "Addons", "Demos",
|
||||
"Options", "Play Game", "Quit");
|
||||
|
||||
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)
|
||||
rb->yield();
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
while(!menuquit)
|
||||
{
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
switch (result) {
|
||||
case 0: /* Game picker */
|
||||
rb->set_option("Game WAD", &gamever, INT, names, status, NULL );
|
||||
break;
|
||||
|
||||
case 1: /* Addon picker */
|
||||
argvlist.addonnum=menuchoice(addons,numadd);
|
||||
menuchoice(addons,numadd,&argvlist.addonnum);
|
||||
break;
|
||||
|
||||
case 2: /* Demos */
|
||||
argvlist.demonum=menuchoice(demolmp,numdemos);
|
||||
menuchoice(demolmp,numdemos,&argvlist.demonum);
|
||||
break;
|
||||
|
||||
case 3: /* Options */
|
||||
|
@ -669,8 +649,6 @@ int doom_menu()
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
return (gamever);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
|
@ -287,17 +286,10 @@ static const struct opt_items fps_settings[9] = {
|
|||
int fps_values[9] = {
|
||||
20, 25, 30, 35, 40, 45, 50, 55, 60 };
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Start Demo", NULL },
|
||||
{ "Auto-Fire", NULL },
|
||||
{ "Particles Per Firework", NULL },
|
||||
{ "Particle Life", NULL },
|
||||
{ "Gravity", NULL },
|
||||
{ "Show Rockets", NULL },
|
||||
{ "FPS (Speed)", NULL },
|
||||
{ "Playback Control", NULL },
|
||||
{ "Quit", NULL }
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Fireworks Menu", NULL,
|
||||
"Start Demo", "Auto-Fire", "Particles Per Firework",
|
||||
"Particle Life", "Gravity", "Show Rockets",
|
||||
"FPS (Speed)", "Playback Control", "Quit");
|
||||
|
||||
/* called on startup. initializes all variables, etc */
|
||||
void init_all(void)
|
||||
|
@ -348,7 +340,7 @@ void init_rocket(int rocket)
|
|||
/* startup/configuration menu. */
|
||||
void fireworks_menu(void)
|
||||
{
|
||||
int m, result;
|
||||
int selected = 0, result;
|
||||
bool menu_quit = false;
|
||||
|
||||
rb->lcd_setfont(FONT_UI);
|
||||
|
@ -359,14 +351,11 @@ void fireworks_menu(void)
|
|||
rb->lcd_clear_display();
|
||||
rb->lcd_update();
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while(!menu_quit)
|
||||
{
|
||||
result = menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
|
@ -419,8 +408,6 @@ void fireworks_menu(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
}
|
||||
|
||||
/* this is the plugin entry point */
|
||||
|
|
|
@ -330,59 +330,6 @@ enum game_type {
|
|||
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 */
|
||||
extern const fb_data jewels[];
|
||||
|
||||
|
@ -676,73 +623,6 @@ static void jewels_drawboard(struct game_context* bj) {
|
|||
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
|
||||
* 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.
|
||||
******************************************************************************/
|
||||
static int jewels_main(struct game_context* bj) {
|
||||
int i, j;
|
||||
int w, h;
|
||||
int button;
|
||||
struct viewport vp[NB_SCREENS];
|
||||
char str[18];
|
||||
bool startgame = false;
|
||||
bool inmenu = false;
|
||||
bool inmenu = true;
|
||||
bool selected = false;
|
||||
enum menu_cmd cmd = MCMD_NONE;
|
||||
enum menu_result res;
|
||||
|
||||
/* the cursor coordinates */
|
||||
int x=0, y=0;
|
||||
|
@ -1479,67 +1377,47 @@ static int jewels_main(struct game_context* bj) {
|
|||
/********************
|
||||
* 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) {
|
||||
res = jewels_showmenu(&bjmenu[0], cmd);
|
||||
cmd = MCMD_NONE;
|
||||
while(inmenu) {
|
||||
|
||||
rb->snprintf(str, 18, "High Score: %d", bj->highscores[0]);
|
||||
rb->lcd_getstringsize(str, &w, &h);
|
||||
rb->lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT-8, str);
|
||||
rb->lcd_update();
|
||||
|
||||
rb->yield();
|
||||
|
||||
switch(res) {
|
||||
case MRES_NEW:
|
||||
startgame = true;
|
||||
switch (rb->do_menu(&main_menu, NULL, vp, true)) {
|
||||
case 0:
|
||||
inmenu = false;
|
||||
bj->type = GAME_TYPE_NORMAL;
|
||||
continue;
|
||||
break;
|
||||
|
||||
case MRES_PUZZLE:
|
||||
startgame = true;
|
||||
case 1:
|
||||
inmenu = false;
|
||||
bj->type = GAME_TYPE_PUZZLE;
|
||||
continue;
|
||||
break;
|
||||
|
||||
case MRES_RESUME:
|
||||
case 2:
|
||||
if(!jewels_loadgame(bj)) {
|
||||
rb->splash(HZ*2, "Nothing to resume");
|
||||
rb->lcd_clear_display();
|
||||
} else {
|
||||
startgame = true;
|
||||
inmenu = false;
|
||||
}
|
||||
continue;
|
||||
break;
|
||||
|
||||
case MRES_SCORES:
|
||||
rb->lcd_clear_display();
|
||||
case 3:
|
||||
jewels_displayscores(bj);
|
||||
break;
|
||||
|
||||
/* room for a title? */
|
||||
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:
|
||||
case 4:
|
||||
/* welcome screen to display key bindings */
|
||||
rb->lcd_clear_display();
|
||||
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;
|
||||
}
|
||||
rb->lcd_clear_display();
|
||||
continue;
|
||||
break;
|
||||
|
||||
case MRES_QUIT:
|
||||
case 5:
|
||||
return BJ_QUIT;
|
||||
|
||||
case MENU_ATTACHED_USB:
|
||||
jewels_callback(bj);
|
||||
return BJ_USB;
|
||||
|
||||
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;
|
||||
#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 *
|
||||
**********************/
|
||||
MENUITEM_STRINGLIST(ingame_menu,"Menu",NULL,
|
||||
"Audio Playback", "Resume Game",
|
||||
"Save Game", "End Game", "Exit Jewels");
|
||||
|
||||
selected = false;
|
||||
while(true) {
|
||||
int no_movesavail = false;
|
||||
bool no_movesavail = false;
|
||||
|
||||
if(!inmenu) {
|
||||
/* 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);
|
||||
} else {
|
||||
res = jewels_showmenu(&bjmenu[1], cmd);
|
||||
cmd = MCMD_NONE;
|
||||
switch(res) {
|
||||
case MRES_RESUME:
|
||||
inmenu = false;
|
||||
selected = false;
|
||||
continue;
|
||||
|
||||
case MRES_PLAYBACK:
|
||||
while(inmenu) {
|
||||
switch (rb->do_menu(&ingame_menu, NULL, vp, true)) {
|
||||
case 0:
|
||||
playback_control(NULL);
|
||||
rb->lcd_setfont(FONT_SYSFIXED);
|
||||
inmenu = false;
|
||||
selected = false;
|
||||
break;
|
||||
|
||||
case MRES_SAVE:
|
||||
case 1:
|
||||
inmenu = false;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
rb->splash(HZ, "Saving game...");
|
||||
jewels_savegame(bj);
|
||||
return BJ_END;
|
||||
|
||||
case MRES_QUIT:
|
||||
case 3:
|
||||
return BJ_END;
|
||||
|
||||
case MRES_EXIT:
|
||||
case 4:
|
||||
return BJ_QUIT_FROM_GAME;
|
||||
|
||||
case MENU_ATTACHED_USB:
|
||||
jewels_callback(bj);
|
||||
return BJ_USB;
|
||||
|
||||
default:
|
||||
inmenu = false;
|
||||
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 */
|
||||
rb->yield();
|
||||
button = rb->button_get(true);
|
||||
switch(button){
|
||||
case JEWELS_LEFT: /* move cursor left */
|
||||
case (JEWELS_LEFT|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
|
||||
}
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_LEFT);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
|
||||
}
|
||||
break;
|
||||
|
||||
case JEWELS_RIGHT: /* move cursor right */
|
||||
case (JEWELS_RIGHT|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
x = (x+1)%BJ_WIDTH;
|
||||
}
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_RIGHT);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
cmd = MCMD_SELECT;
|
||||
x = (x+1)%BJ_WIDTH;
|
||||
}
|
||||
break;
|
||||
|
||||
case JEWELS_DOWN: /* move cursor down */
|
||||
case (JEWELS_DOWN|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
y = (y+1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_DOWN);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
cmd = MCMD_NEXT;
|
||||
y = (y+1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case JEWELS_UP: /* move cursor up */
|
||||
case (JEWELS_UP|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_UP);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
if(selected) {
|
||||
bj->score += jewels_swapjewels(bj, x, y, SWAP_UP);
|
||||
selected = false;
|
||||
if (!jewels_movesavail(bj)) no_movesavail = true;
|
||||
} else {
|
||||
cmd = MCMD_PREV;
|
||||
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef JEWELS_SCROLLWHEEL
|
||||
case JEWELS_PREV: /* scroll backwards */
|
||||
case (JEWELS_PREV|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(!selected) {
|
||||
if(x == 0) {
|
||||
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
|
||||
if(!selected) {
|
||||
if(x == 0) {
|
||||
y = (y+(BJ_HEIGHT-1)-1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
} else {
|
||||
cmd = MCMD_PREV;
|
||||
x = (x+BJ_WIDTH-1)%BJ_WIDTH;
|
||||
}
|
||||
break;
|
||||
|
||||
case JEWELS_NEXT: /* scroll forwards */
|
||||
case (JEWELS_NEXT|BUTTON_REPEAT):
|
||||
if(!inmenu) {
|
||||
if(!selected) {
|
||||
if(x == BJ_WIDTH-1) {
|
||||
y = (y+1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
x = (x+1)%BJ_WIDTH;
|
||||
if(!selected) {
|
||||
if(x == BJ_WIDTH-1) {
|
||||
y = (y+1)%(BJ_HEIGHT-1);
|
||||
}
|
||||
} else {
|
||||
cmd = MCMD_NEXT;
|
||||
x = (x+1)%BJ_WIDTH;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case JEWELS_SELECT: /* toggle selected */
|
||||
if(!inmenu) {
|
||||
selected = !selected;
|
||||
} else {
|
||||
cmd = MCMD_SELECT;
|
||||
}
|
||||
selected = !selected;
|
||||
break;
|
||||
|
||||
#ifdef JEWELS_MENU
|
||||
case JEWELS_MENU:
|
||||
#endif
|
||||
case (JEWELS_SELECT|BUTTON_REPEAT): /* show menu */
|
||||
if(!inmenu) inmenu = true;
|
||||
inmenu = true;
|
||||
selected = false;
|
||||
break;
|
||||
|
||||
#ifdef JEWELS_CANCEL
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "plugin.h"
|
||||
#include <lib/playback_control.h>
|
||||
#include <lib/oldmenuapi.h>
|
||||
#include <lib/helper.h>
|
||||
#include <lib/configfile.h>
|
||||
|
||||
|
@ -323,17 +322,16 @@ bool set_option_dithering(void)
|
|||
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 const struct menu_item items[] = {
|
||||
{ "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);
|
||||
rb->do_menu(&display_menu, NULL, NULL, false);
|
||||
}
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
|
||||
|
@ -349,12 +347,11 @@ int show_menu(void) /* return 1 to quit */
|
|||
rb->lcd_set_background(LCD_WHITE);
|
||||
#endif
|
||||
#endif
|
||||
int m;
|
||||
int result;
|
||||
|
||||
enum menu_id
|
||||
{
|
||||
MIID_QUIT = 0,
|
||||
MIID_RETURN = 0,
|
||||
MIID_TOGGLE_SS_MODE,
|
||||
MIID_CHANGE_SS_MODE,
|
||||
#if PLUGIN_BUFFER_SIZE >= MIN_MEM
|
||||
|
@ -363,42 +360,30 @@ int show_menu(void) /* return 1 to quit */
|
|||
#ifdef HAVE_LCD_COLOR
|
||||
MIID_DISPLAY_OPTIONS,
|
||||
#endif
|
||||
MIID_RETURN,
|
||||
MIID_QUIT,
|
||||
};
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
[MIID_QUIT] =
|
||||
{ "Quit", NULL },
|
||||
[MIID_TOGGLE_SS_MODE] =
|
||||
{ "Toggle Slideshow Mode", NULL },
|
||||
[MIID_CHANGE_SS_MODE] =
|
||||
{ "Change Slideshow Time", NULL },
|
||||
MENUITEM_STRINGLIST(menu, "Jpeg Menu", NULL,
|
||||
"Return", "Toggle Slideshow Mode",
|
||||
"Change Slideshow Time",
|
||||
#if PLUGIN_BUFFER_SIZE >= MIN_MEM
|
||||
[MIID_SHOW_PLAYBACK_MENU] =
|
||||
{ "Show Playback Menu", NULL },
|
||||
"Show Playback Menu",
|
||||
#endif
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
[MIID_DISPLAY_OPTIONS] =
|
||||
{ "Display Options", NULL },
|
||||
"Display Options",
|
||||
#endif
|
||||
[MIID_RETURN] =
|
||||
{ "Return", NULL },
|
||||
};
|
||||
"Quit");
|
||||
|
||||
static const struct opt_items slideshow[2] = {
|
||||
{ "Disable", -1 },
|
||||
{ "Enable", -1 },
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
case MIID_QUIT:
|
||||
menu_exit(m);
|
||||
return 1;
|
||||
case MIID_RETURN:
|
||||
break;
|
||||
case MIID_TOGGLE_SS_MODE:
|
||||
rb->set_option("Toggle Slideshow", &slideshow_enabled, INT,
|
||||
|
@ -427,7 +412,8 @@ int show_menu(void) /* return 1 to quit */
|
|||
display_options();
|
||||
break;
|
||||
#endif
|
||||
case MIID_RETURN:
|
||||
case MIID_QUIT:
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -456,7 +442,6 @@ int show_menu(void) /* return 1 to quit */
|
|||
rb->lcd_set_background(LCD_BLACK);
|
||||
#endif
|
||||
rb->lcd_clear_display();
|
||||
menu_exit(m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
gcc-support.c
|
||||
jhash.c
|
||||
oldmenuapi.c
|
||||
configfile.c
|
||||
fixedpoint.c
|
||||
playback_control.c
|
||||
|
|
|
@ -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));
|
||||
}
|
|
@ -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__ */
|
|
@ -1,7 +1,6 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/configfile.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
#include "mpegplayer.h"
|
||||
#include "mpeg_settings.h"
|
||||
|
@ -257,7 +256,7 @@ void mpeg_menu_sysevent_clear(void)
|
|||
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)
|
||||
{
|
||||
|
@ -283,17 +282,6 @@ void mpeg_menu_sysevent_handle(void)
|
|||
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,
|
||||
void* variable,
|
||||
enum optiontype type,
|
||||
|
@ -691,7 +679,7 @@ static int get_start_time(uint32_t duration)
|
|||
button = tmo == TIMEOUT_BLOCK ?
|
||||
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)
|
||||
{
|
||||
|
@ -822,43 +810,31 @@ static int get_start_time(uint32_t duration)
|
|||
|
||||
static int show_start_menu(uint32_t duration)
|
||||
{
|
||||
int menu_id;
|
||||
int selected = 0;
|
||||
int result = 0;
|
||||
bool menu_quit = false;
|
||||
|
||||
/* add the resume time to the menu display */
|
||||
char resume_str[32];
|
||||
static char resume_str[32];
|
||||
char hms_str[32];
|
||||
struct hms hms;
|
||||
|
||||
struct menu_item items[] =
|
||||
{
|
||||
[MPEG_START_RESTART] =
|
||||
{ "Play from beginning", NULL },
|
||||
[MPEG_START_RESUME] =
|
||||
{ resume_str, NULL },
|
||||
[MPEG_START_SEEK] =
|
||||
{ "Set start time", NULL },
|
||||
[MPEG_START_SETTINGS] =
|
||||
{ "Settings", NULL },
|
||||
[MPEG_START_QUIT] =
|
||||
{ "Quit mpegplayer", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback,
|
||||
"Play from beginning", resume_str,
|
||||
"Set start time", "Settings",
|
||||
"Quit mpegplayer");
|
||||
|
||||
ts_to_hms(settings.resume_time, &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);
|
||||
|
||||
menu_id = menu_init(items, ARRAYLEN(items),
|
||||
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit)
|
||||
{
|
||||
mpeg_menu_sysevent_clear();
|
||||
result = menu_show(menu_id);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -901,8 +877,6 @@ static int show_start_menu(uint32_t duration)
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(menu_id);
|
||||
|
||||
rb->lcd_clear_display();
|
||||
rb->lcd_update();
|
||||
|
||||
|
@ -934,36 +908,26 @@ int mpeg_start_menu(uint32_t duration)
|
|||
/** MPEG Menu **/
|
||||
static void display_options(void)
|
||||
{
|
||||
int selected = 0;
|
||||
int result;
|
||||
int menu_id;
|
||||
bool menu_quit = false;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
MENUITEM_STRINGLIST(menu, "Display Options", mpeg_menu_sysevent_callback,
|
||||
#if MPEG_OPTION_DITHERING_ENABLED
|
||||
[MPEG_OPTION_DITHERING] =
|
||||
{ "Dithering", NULL },
|
||||
"Dithering",
|
||||
#endif
|
||||
[MPEG_OPTION_DISPLAY_FPS] =
|
||||
{ "Display FPS", NULL },
|
||||
[MPEG_OPTION_LIMIT_FPS] =
|
||||
{ "Limit FPS", NULL },
|
||||
[MPEG_OPTION_SKIP_FRAMES] =
|
||||
{ "Skip frames", NULL },
|
||||
"Display FPS", "Limit FPS", "Skip frames",
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
[MPEG_OPTION_BACKLIGHT_BRIGHTNESS] =
|
||||
{ "Backlight brightness", NULL },
|
||||
"Backlight brightness",
|
||||
#endif
|
||||
};
|
||||
|
||||
menu_id = menu_init(items, ARRAYLEN(items),
|
||||
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
|
||||
);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit)
|
||||
{
|
||||
mpeg_menu_sysevent_clear();
|
||||
result = menu_show(menu_id);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -1014,38 +978,24 @@ static void display_options(void)
|
|||
if (mpeg_menu_sysevent() != 0)
|
||||
menu_quit = true;
|
||||
}
|
||||
|
||||
menu_exit(menu_id);
|
||||
}
|
||||
|
||||
static void audio_options(void)
|
||||
{
|
||||
int selected = 0;
|
||||
int result;
|
||||
int menu_id;
|
||||
bool menu_quit = false;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
[MPEG_AUDIO_TONE_CONTROLS] =
|
||||
{ "Tone Controls", NULL },
|
||||
[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);
|
||||
MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_menu_sysevent_callback,
|
||||
"Tone Controls", "Channel Modes", "Crossfeed",
|
||||
"Equalizer", "Dithering");
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit)
|
||||
{
|
||||
mpeg_menu_sysevent_clear();
|
||||
result = menu_show(menu_id);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -1087,8 +1037,6 @@ static void audio_options(void)
|
|||
if (mpeg_menu_sysevent() != 0)
|
||||
menu_quit = true;
|
||||
}
|
||||
|
||||
menu_exit(menu_id);
|
||||
}
|
||||
|
||||
static void resume_options(void)
|
||||
|
@ -1121,32 +1069,23 @@ static void clear_resume_count(void)
|
|||
|
||||
int mpeg_menu(unsigned flags)
|
||||
{
|
||||
int menu_id;
|
||||
int selected = 0;
|
||||
int result;
|
||||
bool menu_quit = false;
|
||||
int item_count;
|
||||
char clear_str[32];
|
||||
static char clear_str[32];
|
||||
|
||||
struct menu_item items[] = {
|
||||
[MPEG_MENU_DISPLAY_SETTINGS] =
|
||||
{ "Display Options", NULL },
|
||||
[MPEG_MENU_AUDIO_SETTINGS] =
|
||||
{ "Audio Options", NULL },
|
||||
[MPEG_MENU_ENABLE_START_MENU] =
|
||||
{ "Resume Options", NULL },
|
||||
[MPEG_MENU_CLEAR_RESUMES] =
|
||||
{ clear_str, NULL },
|
||||
[MPEG_MENU_QUIT] =
|
||||
{ "Quit mpegplayer", NULL },
|
||||
};
|
||||
|
||||
item_count = ARRAYLEN(items);
|
||||
MENUITEM_STRINGLIST(menu_with_quit, "Mpegplayer Menu",
|
||||
mpeg_menu_sysevent_callback,
|
||||
"Display Options", "Audio Options",
|
||||
"Resume Options", clear_str, "Quit mpegplayer");
|
||||
MENUITEM_STRINGLIST(menu_without_quit, "Settings",
|
||||
mpeg_menu_sysevent_callback,
|
||||
"Display Options", "Audio Options",
|
||||
"Resume Options", clear_str);
|
||||
const struct menu_item_ex *menu = &menu_with_quit;
|
||||
|
||||
if (flags & MPEG_MENU_HIDE_QUIT_ITEM)
|
||||
item_count--;
|
||||
|
||||
menu_id = menu_init(items, item_count,
|
||||
mpeg_menu_sysevent_callback, NULL, NULL, NULL);
|
||||
menu = &menu_without_quit;
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
|
@ -1155,10 +1094,10 @@ int mpeg_menu(unsigned flags)
|
|||
mpeg_menu_sysevent_clear();
|
||||
|
||||
/* Format and add resume option to the menu display */
|
||||
format_menu_item(&items[MPEG_MENU_CLEAR_RESUMES], sizeof(clear_str),
|
||||
"Clear all resumes: %u", settings.resume_count);
|
||||
rb->snprintf(clear_str, sizeof(clear_str),
|
||||
"Clear all resumes: %u", settings.resume_count);
|
||||
|
||||
result = menu_show(menu_id);
|
||||
result = rb->do_menu(menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -1191,8 +1130,6 @@ int mpeg_menu(unsigned flags)
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(menu_id);
|
||||
|
||||
rb->lcd_clear_display();
|
||||
rb->lcd_update();
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ enum
|
|||
int mpeg_menu(unsigned flags);
|
||||
void mpeg_menu_sysevent_clear(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 init_settings(const char* filename);
|
||||
|
|
|
@ -1498,7 +1498,7 @@ static void button_loop(void)
|
|||
mpeg_menu_sysevent_clear();
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "pacbox.h"
|
||||
#include "pacbox_lcd.h"
|
||||
#include "lib/configfile.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
@ -138,7 +137,7 @@ static int settings_to_dip(struct pacman_settings settings)
|
|||
|
||||
static bool pacbox_menu(void)
|
||||
{
|
||||
int m;
|
||||
int selected=0;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
int new_setting;
|
||||
|
@ -173,23 +172,14 @@ static bool pacbox_menu(void)
|
|||
{ "Alternate", -1 },
|
||||
};
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Difficulty", NULL },
|
||||
{ "Pacmen Per Game", NULL },
|
||||
{ "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);
|
||||
MENUITEM_STRINGLIST(menu, "Pacbox Menu", NULL,
|
||||
"Difficulty", "Pacmen Per Game", "Bonus Life",
|
||||
"Ghost Names", "Display FPS", "Restart", "Quit");
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=menu_show(m);
|
||||
result=rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
|
@ -243,8 +233,6 @@ static bool pacbox_menu(void)
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
if (need_restart) {
|
||||
init_PacmanMachine(settings_to_dip(settings));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
@ -321,15 +320,11 @@ int edit_list(void)
|
|||
break;
|
||||
case ACTION_STD_CONTEXT:
|
||||
{
|
||||
int m, len;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Remove Folder", NULL },
|
||||
{ "Remove Folder Tree", NULL },
|
||||
};
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
int len;
|
||||
MENUITEM_STRINGLIST(menu, "Remove Menu", NULL,
|
||||
"Remove Folder", "Remove Folder Tree");
|
||||
|
||||
switch (menu_show(m))
|
||||
switch (rb->do_menu(&menu, NULL, NULL, false))
|
||||
{
|
||||
case 0:
|
||||
list->folder[selection][0] = ' ';
|
||||
|
@ -351,20 +346,14 @@ int edit_list(void)
|
|||
}
|
||||
break;
|
||||
}
|
||||
menu_exit(m);
|
||||
}
|
||||
break;
|
||||
case ACTION_STD_CANCEL:
|
||||
{
|
||||
int m;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Save and Exit", NULL },
|
||||
{ "Ignore Changes and Exit", NULL },
|
||||
};
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
MENUITEM_STRINGLIST(menu, "Exit Menu", NULL,
|
||||
"Save and Exit", "Ignore Changes and Exit");
|
||||
|
||||
switch (menu_show(m))
|
||||
switch (rb->do_menu(&menu, NULL, NULL, false))
|
||||
{
|
||||
case 0:
|
||||
save_list();
|
||||
|
@ -372,7 +361,6 @@ int edit_list(void)
|
|||
exit = true;
|
||||
ret = -2;
|
||||
}
|
||||
menu_exit(m);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -474,19 +462,16 @@ int import_list_from_file_text(void)
|
|||
|
||||
int main_menu(void)
|
||||
{
|
||||
int m;
|
||||
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 */
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
|
@ -542,10 +527,8 @@ int main_menu(void)
|
|||
rb->backlight_on();
|
||||
break;
|
||||
case 4:
|
||||
menu_exit(m);
|
||||
return 1;
|
||||
}
|
||||
menu_exit(m);
|
||||
return exit?1:0;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ further options:
|
|||
#include "reversi-strategy.h"
|
||||
#include "reversi-gui.h"
|
||||
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
@ -375,23 +374,15 @@ static bool reversi_gui_choose_strategy(
|
|||
|
||||
/* Returns true iff USB ws connected while in the menu */
|
||||
static bool reversi_gui_menu(void) {
|
||||
int m, index, num_items, i;
|
||||
int index, num_items, i;
|
||||
int result;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Start new game", NULL },
|
||||
{ "Pass the move", NULL },
|
||||
{ MENU_TEXT_STRAT_BLACK, NULL },
|
||||
{ MENU_TEXT_STRAT_WHITE, NULL },
|
||||
{ MENU_TEXT_WRAP_MODE, NULL },
|
||||
{ "Playback Control", NULL },
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Reversi Menu", NULL,
|
||||
"Start new game", "Pass the move",
|
||||
MENU_TEXT_STRAT_BLACK, MENU_TEXT_STRAT_WHITE,
|
||||
MENU_TEXT_WRAP_MODE, "Playback Control", "Quit");
|
||||
|
||||
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) {
|
||||
case 0: /* Start a new game */
|
||||
|
@ -433,8 +424,6 @@ static bool reversi_gui_menu(void) {
|
|||
break;
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
return (result == MENU_ATTACHED_USB);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "rockmacros.h"
|
||||
#include "mem.h"
|
||||
#include "save.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "rtc-gb.h"
|
||||
#include "pcm.h"
|
||||
|
||||
|
@ -85,7 +84,7 @@ static void setupkeys(void)
|
|||
*/
|
||||
int do_user_menu(void) {
|
||||
bool done=false;
|
||||
int m, ret=0;
|
||||
int selected=0, ret=0;
|
||||
int result;
|
||||
int time = 0;
|
||||
|
||||
|
@ -97,20 +96,15 @@ int do_user_menu(void) {
|
|||
while (rb->button_get(false) != BUTTON_NONE)
|
||||
rb->yield();
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{"Load Game", NULL },
|
||||
{"Save Game", NULL },
|
||||
{"Options", NULL },
|
||||
{"Quit", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL,
|
||||
"Load Game", "Save Game",
|
||||
"Options", "Quit");
|
||||
|
||||
pcm_init();
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
|
||||
|
||||
while(!done)
|
||||
{
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -133,8 +127,6 @@ int do_user_menu(void) {
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
rb->lcd_setfont(0); /* Reset the font */
|
||||
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
|
||||
*/
|
||||
static void do_slot_menu(bool is_load) {
|
||||
bool done=false;
|
||||
|
||||
char buf[5][20];
|
||||
|
||||
int m;
|
||||
char items[5][20];
|
||||
int result;
|
||||
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);
|
||||
struct simplelist_info info;
|
||||
|
||||
/* create menu items */
|
||||
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)
|
||||
{
|
||||
result=menu_show(m);
|
||||
if(rb->simplelist_show_list(&info))
|
||||
break;
|
||||
|
||||
result = info.selection;
|
||||
if (result<num_items && result >= 0 )
|
||||
done = do_slot(result, is_load);
|
||||
else
|
||||
done = true;
|
||||
}
|
||||
menu_exit(m);
|
||||
}
|
||||
|
||||
static void do_opt_menu(void)
|
||||
{
|
||||
bool done=false;
|
||||
int m;
|
||||
int selected=0;
|
||||
int result;
|
||||
|
||||
static const struct opt_items onoff[2] = {
|
||||
|
@ -379,56 +386,48 @@ static void do_opt_menu(void)
|
|||
};
|
||||
#endif
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Max Frameskip", NULL },
|
||||
{ "Sound" , NULL },
|
||||
{ "Stats" , NULL },
|
||||
{ "Set Keys (Buggy)", NULL },
|
||||
MENUITEM_STRINGLIST(menu, "Options", NULL,
|
||||
"Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)",
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
{ "Screen Size" , NULL },
|
||||
{ "Screen Rotate" , NULL },
|
||||
{ "Set Palette" , NULL },
|
||||
"Screen Size", "Screen Rotate", "Set Palette",
|
||||
#endif
|
||||
};
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
|
||||
);
|
||||
|
||||
options.dirty=1; /* Assume that the settings have been changed */
|
||||
|
||||
while(!done)
|
||||
{
|
||||
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
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 );
|
||||
break;
|
||||
case 1: /* Sound */
|
||||
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();
|
||||
break;
|
||||
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;
|
||||
case 3: /* Keys */
|
||||
setupkeys();
|
||||
break;
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
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 );
|
||||
setvidmode();
|
||||
break;
|
||||
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();
|
||||
break;
|
||||
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();
|
||||
break;
|
||||
#endif
|
||||
|
@ -437,5 +436,4 @@ static void do_opt_menu(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
menu_exit(m);
|
||||
}
|
||||
|
|
|
@ -516,89 +516,46 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height,
|
|||
/***********************************************************************
|
||||
* Menu handling
|
||||
***********************************************************************/
|
||||
struct menu_items
|
||||
{
|
||||
int value;
|
||||
char label[16]; /* GRUIK ? */
|
||||
};
|
||||
|
||||
#define MENU_ESC -1242
|
||||
enum {
|
||||
/* Generic menu items */
|
||||
MENU_END = -42, MENU_TITLE = -12,
|
||||
/* Main menu */
|
||||
MAIN_MENU_RESUME,
|
||||
MAIN_MENU_NEW, MAIN_MENU_LOAD, MAIN_MENU_SAVE,
|
||||
MAIN_MENU_BRUSH_SIZE, MAIN_MENU_BRUSH_SPEED, MAIN_MENU_COLOR,
|
||||
MAIN_MENU_GRID_SIZE,
|
||||
MAIN_MENU_EXIT,
|
||||
};
|
||||
enum {
|
||||
/* Select action menu */
|
||||
SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT,
|
||||
SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90,
|
||||
SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270,
|
||||
SELECT_MENU_CANCEL,
|
||||
};
|
||||
enum {
|
||||
/* Text menu */
|
||||
TEXT_MENU_TEXT, TEXT_MENU_FONT,
|
||||
TEXT_MENU_PREVIEW, TEXT_MENU_APPLY, TEXT_MENU_CANCEL,
|
||||
};
|
||||
|
||||
static struct menu_items main_menu[]=
|
||||
{ { MENU_TITLE, "RockPaint" },
|
||||
{ MAIN_MENU_RESUME, "Resume" },
|
||||
{ MAIN_MENU_NEW, "New" },
|
||||
{ MAIN_MENU_LOAD, "Load" },
|
||||
{ MAIN_MENU_SAVE, "Save" },
|
||||
{ MAIN_MENU_BRUSH_SIZE, "Brush Size" },
|
||||
{ MAIN_MENU_BRUSH_SPEED, "Brush Speed" },
|
||||
{ MAIN_MENU_COLOR, "Choose Color" },
|
||||
{ MAIN_MENU_GRID_SIZE, "Grid Size" },
|
||||
{ MAIN_MENU_EXIT, "Exit" },
|
||||
{ MENU_END, "" } };
|
||||
|
||||
static struct menu_items size_menu[] =
|
||||
{ { MENU_TITLE, "Choose Size" },
|
||||
{ 1, "1x" },
|
||||
{ 2, "2x" },
|
||||
{ 4, "4x" },
|
||||
{ 8, "8x" },
|
||||
{ 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, "" } };
|
||||
MENUITEM_STRINGLIST(main_menu, "RockPaint", NULL,
|
||||
"Resume", "New", "Load", "Save",
|
||||
"Brush Size", "Brush Speed",
|
||||
"Choose Color", "Grid Size", "Exit");
|
||||
MENUITEM_STRINGLIST(size_menu, "Choose Size", NULL,
|
||||
"1x", "2x","4x", "8x");
|
||||
MENUITEM_STRINGLIST(speed_menu, "Choose Speed", NULL,
|
||||
"1x", "2x","4x");
|
||||
MENUITEM_STRINGLIST(gridsize_menu, "Grid Size", NULL,
|
||||
"No grid", "5px", "10px", "20px");
|
||||
MENUITEM_STRINGLIST(select_menu, "Select...", NULL,
|
||||
"Cut", "Copy", "Invert", "Horizontal Flip" ,
|
||||
"Vertical Flip", "Rotate 90°",
|
||||
"Rotate 180°", "Rotate 270°", "Cancel");
|
||||
MENUITEM_STRINGLIST(text_menu, "Text", NULL,
|
||||
"Set Text", "Change Font",
|
||||
"Preview", "Apply", "Cancel");
|
||||
static const int times_list[] = { 1, 2, 4, 8 };
|
||||
static const int gridsize_list[] = { 0, 5, 10, 20 };
|
||||
|
||||
static int draw_window( int height, int width,
|
||||
int *top, int *left,
|
||||
|
@ -624,144 +581,38 @@ static int draw_window( int height, int width,
|
|||
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
|
||||
***********************************************************************/
|
||||
|
||||
char bbuf[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 )
|
||||
{
|
||||
#define WIDTH ( LCD_WIDTH - 20 )
|
||||
#define HEIGHT ( LCD_HEIGHT - 20 )
|
||||
#define LINE_SPACE 2
|
||||
int top, top_inside, left;
|
||||
struct gui_synclist browse_list;
|
||||
int item_count, selected, button;
|
||||
struct tree_context backup;
|
||||
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;
|
||||
|
||||
rb->lcd_getstringsize( "Ap", NULL, &fh );
|
||||
|
||||
rb->strcpy( bbuf, start );
|
||||
a = bbuf+rb->strlen(bbuf)-1;
|
||||
if( *a != '/' )
|
||||
|
@ -769,124 +620,106 @@ static bool browse( char *dst, int dst_size, const char *start )
|
|||
a[1] = '/';
|
||||
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 )
|
||||
{
|
||||
d = rb->opendir( bbuf );
|
||||
if( !d )
|
||||
if( reload )
|
||||
{
|
||||
/*
|
||||
if( errno == ENOTDIR )
|
||||
{*/
|
||||
/* this is a file */
|
||||
bbuf[rb->strlen(bbuf)-1] = '\0';
|
||||
rb->strncpy( dst, bbuf, dst_size );
|
||||
return true;
|
||||
/*}
|
||||
else if( errno == EACCES || errno == ENOENT )
|
||||
int i;
|
||||
rb->set_current_file(bbuf);
|
||||
item_count = 0;
|
||||
selected = 0;
|
||||
for( i = 0; i < tree->filesindir ; i++)
|
||||
{
|
||||
bbuf[0] = '/'; bbuf[1] = '\0';
|
||||
d = rb->opendir( "/" );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
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 )
|
||||
/* only displayes directories and .bmp files */
|
||||
if( ((dc[i].attr & ATTR_DIRECTORY ) &&
|
||||
rb->strcmp( dc[i].name, "." ) &&
|
||||
rb->strcmp( dc[i].name, ".." )) ||
|
||||
( !(dc[i].attr & ATTR_DIRECTORY) &&
|
||||
(a = rb->strrchr( dc[i].name,'.' )) &&
|
||||
!rb->strcmp( a, ".bmp" ) ))
|
||||
{
|
||||
si--;
|
||||
if( si<fvi )
|
||||
if( !rb->strcmp( dc[i].name, bbuf_s ) )
|
||||
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;
|
||||
|
||||
case ROCKPAINT_DOWN:
|
||||
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] )
|
||||
if( !rb->strcmp( bbuf_s, "." ) ) break;
|
||||
a = bbuf+rb->strlen(bbuf);
|
||||
if( !rb->strcmp( bbuf_s, ".." ) )
|
||||
{
|
||||
a--;
|
||||
if( a == bbuf ) break;
|
||||
if( *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;
|
||||
}
|
||||
rb->strcpy( a, bbuf_s );
|
||||
while( *a ) a++;
|
||||
*a++ = '/';
|
||||
*a = '\0';
|
||||
fvi = si = 0;
|
||||
rb->snprintf( a, bbuf+sizeof(bbuf)-a, "%s/", bbuf_s );
|
||||
reload = true;
|
||||
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 )
|
||||
{
|
||||
char old_font[MAX_PATH];
|
||||
#define WIDTH ( LCD_WIDTH - 20 )
|
||||
#define HEIGHT ( LCD_HEIGHT - 20 )
|
||||
#define LINE_SPACE 2
|
||||
|
@ -923,7 +755,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
int fw;
|
||||
#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",
|
||||
rb->global_settings->font_file );
|
||||
|
||||
|
@ -1019,7 +851,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
nvih = fh;
|
||||
}
|
||||
}
|
||||
rb->font_load( old_font );
|
||||
rb->font_load( buffer.text.old_font );
|
||||
rb->closedir( d );
|
||||
}
|
||||
|
||||
|
@ -1501,6 +1333,74 @@ static void draw_vflip( int x1, int y1, int x2, int y2 )
|
|||
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,
|
||||
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 )
|
||||
{
|
||||
int selected = 0;
|
||||
buffer.text.text[0] = '\0';
|
||||
rb->snprintf( buffer.text.old_font, MAX_PATH,
|
||||
FONT_DIR "/%s.fnt",
|
||||
rb->global_settings->font_file );
|
||||
while( 1 )
|
||||
{
|
||||
int m = TEXT_MENU_TEXT;
|
||||
switch( m = menu_display( text_menu, m ) )
|
||||
switch( rb->do_menu( &text_menu, &selected, NULL, NULL ) )
|
||||
{
|
||||
case TEXT_MENU_TEXT:
|
||||
rb->lcd_set_foreground(COLOR_BLACK);
|
||||
rb->kbd_input( buffer.text.text, MAX_TEXT );
|
||||
restore_screen();
|
||||
break;
|
||||
|
||||
case TEXT_MENU_FONT:
|
||||
|
@ -1583,7 +1483,7 @@ static void draw_text( int x, int y )
|
|||
rb->lcd_set_foreground( rp_colors[ drawcolor ] );
|
||||
while( 1 )
|
||||
{
|
||||
unsigned int button;
|
||||
int button;
|
||||
restore_screen();
|
||||
rb->lcd_putsxy( x, y, buffer.text.text );
|
||||
rb->lcd_update();
|
||||
|
@ -1614,10 +1514,14 @@ static void draw_text( int x, int y )
|
|||
break;
|
||||
|
||||
case ROCKPAINT_DRAW:
|
||||
button = 1242;
|
||||
break;
|
||||
default:
|
||||
if(rb->default_event_handler(button)
|
||||
== SYS_USB_CONNECTED)
|
||||
button = ROCKPAINT_DRAW;
|
||||
break;
|
||||
}
|
||||
if( button == 1242 ) break;
|
||||
if( button == ROCKPAINT_DRAW ) break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1626,6 +1530,7 @@ static void draw_text( int x, int y )
|
|||
buffer_putsxyofs( save_buffer, COLS, ROWS, x, y, 0,
|
||||
buffer.text.text );
|
||||
case TEXT_MENU_CANCEL:
|
||||
default:
|
||||
restore_screen();
|
||||
rb->font_load( buffer.text.old_font );
|
||||
return;
|
||||
|
@ -2541,10 +2446,11 @@ static void clear_drawing(void)
|
|||
static void goto_menu(void)
|
||||
{
|
||||
int multi;
|
||||
int selected = 0;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
switch( menu_display( main_menu, 1 ) )
|
||||
switch( rb->do_menu( &main_menu, &selected, NULL, false ) )
|
||||
{
|
||||
case MAIN_MENU_NEW:
|
||||
clear_drawing();
|
||||
|
@ -2569,6 +2475,7 @@ static void goto_menu(void)
|
|||
break;
|
||||
|
||||
case MAIN_MENU_SAVE:
|
||||
rb->lcd_set_foreground(COLOR_BLACK);
|
||||
if (!filename[0])
|
||||
rb->strcpy(filename,"/");
|
||||
if( !rb->kbd_input( filename, MAX_PATH ) )
|
||||
|
@ -2582,15 +2489,19 @@ static void goto_menu(void)
|
|||
break;
|
||||
|
||||
case MAIN_MENU_BRUSH_SIZE:
|
||||
multi = menu_display( size_menu, bsize );
|
||||
if( multi != - 1 )
|
||||
bsize = multi;
|
||||
for(multi = 0; multi<4; multi++)
|
||||
if(bsize == times_list[multi]) break;
|
||||
rb->do_menu( &size_menu, &multi, NULL, false );
|
||||
if( multi >= 0 )
|
||||
bsize = times_list[multi];
|
||||
break;
|
||||
|
||||
case MAIN_MENU_BRUSH_SPEED:
|
||||
multi = menu_display( speed_menu, bspeed );
|
||||
if( multi != -1 )
|
||||
bspeed = multi;
|
||||
for(multi = 0; multi<3; multi++)
|
||||
if(bspeed == times_list[multi]) break;
|
||||
rb->do_menu( &speed_menu, &multi, NULL, false );
|
||||
if( multi >= 0 )
|
||||
bspeed = times_list[multi];
|
||||
break;
|
||||
|
||||
case MAIN_MENU_COLOR:
|
||||
|
@ -2598,17 +2509,21 @@ static void goto_menu(void)
|
|||
break;
|
||||
|
||||
case MAIN_MENU_GRID_SIZE:
|
||||
multi = menu_display( gridsize_menu, gridsize );
|
||||
if( multi != - 1 )
|
||||
gridsize = multi;
|
||||
for(multi = 0; multi<4; multi++)
|
||||
if(gridsize == gridsize_list[multi]) break;
|
||||
rb->do_menu( &gridsize_menu, &multi, NULL, false );
|
||||
if( multi >= 0 )
|
||||
gridsize = gridsize_list[multi];
|
||||
break;
|
||||
|
||||
case MAIN_MENU_EXIT:
|
||||
restore_screen();
|
||||
quit=true;
|
||||
return;
|
||||
|
||||
case MAIN_MENU_RESUME:
|
||||
case MENU_ESC:
|
||||
default:
|
||||
restore_screen();
|
||||
return;
|
||||
}/* end switch */
|
||||
}/* end while */
|
||||
|
@ -2660,6 +2575,7 @@ static bool rockpaint_loop( void )
|
|||
case ROCKPAINT_MENU:
|
||||
inv_cursor(false);
|
||||
goto_menu();
|
||||
restore_screen();
|
||||
inv_cursor(true);
|
||||
break;
|
||||
|
||||
|
@ -2697,8 +2613,8 @@ static bool rockpaint_loop( void )
|
|||
else if( tool == SelectRectangle
|
||||
&& ( prev_x2 == -1 || prev_y2 == -1 ) )
|
||||
{
|
||||
tool_mode = menu_display( select_menu,
|
||||
SELECT_MENU_CUT );
|
||||
tool_mode = rb->do_menu( &select_menu,
|
||||
NULL, NULL, false );
|
||||
switch( tool_mode )
|
||||
{
|
||||
case SELECT_MENU_CUT:
|
||||
|
@ -2726,22 +2642,29 @@ static bool rockpaint_loop( void )
|
|||
break;
|
||||
|
||||
case SELECT_MENU_ROTATE90:
|
||||
draw_rot_90_deg( prev_x, prev_y, x, y, 1 );
|
||||
reset_tool();
|
||||
break;
|
||||
|
||||
case SELECT_MENU_ROTATE180:
|
||||
draw_hflip( prev_x, prev_y, x, y );
|
||||
draw_vflip( prev_x, prev_y, x, y );
|
||||
reset_tool();
|
||||
break;
|
||||
|
||||
case SELECT_MENU_ROTATE270:
|
||||
draw_rot_90_deg( prev_x, prev_y, x, y, -1 );
|
||||
reset_tool();
|
||||
break;
|
||||
|
||||
case SELECT_MENU_CANCEL:
|
||||
reset_tool();
|
||||
break;
|
||||
|
||||
case MENU_ESC:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
restore_screen();
|
||||
}
|
||||
else if( tool == Curve
|
||||
&& ( prev_x3 == -1 || prev_y3 == -1 ) )
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "lib/configfile.h"
|
||||
#include "button.h"
|
||||
#include "lcd.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
#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 }
|
||||
};
|
||||
|
||||
char draw_option_string[32];
|
||||
|
||||
static void create_draw_option_string(void)
|
||||
{
|
||||
if (sol.draw_type == 0)
|
||||
rb->strcpy(draw_option_string, "Draw Three Cards");
|
||||
else
|
||||
rb->strcpy(draw_option_string, "Draw One Card");
|
||||
}
|
||||
static const struct opt_items drawcards[2] = {
|
||||
{ "Draw Three Cards", -1 },
|
||||
{ "Draw One Card", -1 },
|
||||
};
|
||||
|
||||
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 m;
|
||||
int selected = 0;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
break;
|
||||
|
||||
|
@ -840,8 +819,9 @@ int solitaire_menu(bool in_game)
|
|||
}
|
||||
else
|
||||
{
|
||||
sol.draw_type = (sol.draw_type + 1) % 2;
|
||||
create_draw_option_string();
|
||||
if (rb->set_option("Draw Cards Option", &sol.draw_type,
|
||||
INT, drawcards, 2, NULL))
|
||||
result = MENU_USB;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -866,7 +846,6 @@ int solitaire_menu(bool in_game)
|
|||
break;
|
||||
}
|
||||
}
|
||||
menu_exit(m);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ Example ".ss" file, and one with a saved state:
|
|||
|
||||
#include "plugin.h"
|
||||
#include "lib/configfile.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
||||
|
@ -1167,30 +1166,20 @@ enum {
|
|||
|
||||
bool sudoku_menu(struct sudoku_state_t* state)
|
||||
{
|
||||
int m;
|
||||
int result;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
[SM_AUDIO_PLAYBACK] = { "Audio Playback", NULL },
|
||||
MENUITEM_STRINGLIST(menu, "Sudoku Menu", NULL,
|
||||
"Audio Playback",
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
[SM_NUMBER_DISPLAY] = { "Number Display", NULL },
|
||||
"Number Display",
|
||||
#endif
|
||||
#ifdef SUDOKU_BUTTON_POSSIBLE
|
||||
[SM_SHOW_MARKINGS] = { "Show Markings", NULL },
|
||||
"Show Markings",
|
||||
#endif
|
||||
[SM_SAVE] = { "Save", NULL },
|
||||
[SM_RELOAD] = { "Reload", NULL },
|
||||
[SM_CLEAR] = { "Clear", NULL },
|
||||
[SM_SOLVE] = { "Solve", NULL },
|
||||
[SM_GENERATE] = { "Generate", NULL },
|
||||
[SM_NEW] = { "New", NULL },
|
||||
[SM_QUIT] = { "Quit", NULL },
|
||||
};
|
||||
"Save", "Reload", "Clear", "Solve",
|
||||
"Generate", "New", "Quit");
|
||||
|
||||
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) {
|
||||
case SM_AUDIO_PLAYBACK:
|
||||
|
@ -1235,7 +1224,6 @@ bool sudoku_menu(struct sudoku_state_t* state)
|
|||
|
||||
case SM_QUIT:
|
||||
save_sudoku(state);
|
||||
menu_exit(m);
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
@ -1243,26 +1231,18 @@ bool sudoku_menu(struct sudoku_state_t* state)
|
|||
break;
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
return (result==MENU_ATTACHED_USB);
|
||||
}
|
||||
|
||||
/* 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 m;
|
||||
int result;
|
||||
|
||||
static const struct menu_item items[] = {
|
||||
{ "Save as", NULL },
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Edit Menu", NULL,
|
||||
"Save as", "Quit");
|
||||
|
||||
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) {
|
||||
case 0: /* Save new game */
|
||||
|
@ -1281,8 +1261,6 @@ int sudoku_edit_menu(struct sudoku_state_t* state)
|
|||
break;
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
@ -406,11 +405,10 @@ static bool test_speed(void)
|
|||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
{
|
||||
static const struct menu_item items[] = {
|
||||
{ "Disk speed", test_speed },
|
||||
{ "Write & verify", test_fs },
|
||||
};
|
||||
int m;
|
||||
MENUITEM_STRINGLIST(menu, "Test Disk Menu", NULL,
|
||||
"Disk speed", "Write & verify");
|
||||
int selected=0;
|
||||
bool quit = false;
|
||||
int align;
|
||||
DIR *dir;
|
||||
|
||||
|
@ -440,10 +438,21 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
/* Turn off backlight timeout */
|
||||
backlight_force_on(); /* backlight control in lib/helper.c */
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items), NULL,
|
||||
NULL, NULL, NULL);
|
||||
menu_run(m);
|
||||
menu_exit(m);
|
||||
while(!quit)
|
||||
{
|
||||
switch(rb->do_menu(&menu, &selected, NULL, false))
|
||||
{
|
||||
case 0:
|
||||
test_speed();
|
||||
break;
|
||||
case 1:
|
||||
test_fs();
|
||||
break;
|
||||
default:
|
||||
quit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn on backlight timeout (revert to settings) */
|
||||
backlight_use_settings(); /* backlight control in lib/helper.c */
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
/* This plugin generates a 1kHz tone + noise in order to quickly verify
|
||||
* hardware samplerate setup is operating correctly.
|
||||
|
@ -285,32 +284,23 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
MENU_QUIT,
|
||||
};
|
||||
|
||||
static const struct menu_item items[] =
|
||||
{
|
||||
MENUITEM_STRINGLIST(menu, "Test Sampr Menu", NULL,
|
||||
#ifndef HAVE_VOLUME_IN_LIST
|
||||
[MENU_VOL_SET] =
|
||||
{ "Set Volume", NULL },
|
||||
"Set Volume",
|
||||
#endif /* HAVE_VOLUME_IN_LIST */
|
||||
[MENU_SAMPR_SET] =
|
||||
{ "Set Samplerate", NULL },
|
||||
[MENU_QUIT] =
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
"Set Samplerate", "Quit");
|
||||
|
||||
bool exit = false;
|
||||
int m;
|
||||
int selected = 0;
|
||||
|
||||
/* Disable all talking before initializing IRAM */
|
||||
rb->talk_disable(true);
|
||||
|
||||
PLUGIN_IRAM_INIT(rb);
|
||||
|
||||
m = menu_init(items, ARRAYLEN(items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
while (!exit)
|
||||
{
|
||||
int result = menu_show(m);
|
||||
int result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
@ -329,8 +319,6 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
|
||||
rb->talk_disable(false);
|
||||
|
||||
return PLUGIN_OK;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "plugin.h"
|
||||
#include <ctype.h>
|
||||
#include "lib/playback_control.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
@ -1448,30 +1447,37 @@ static bool autoscroll_speed_setting(void)
|
|||
&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)
|
||||
{
|
||||
int m;
|
||||
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
|
||||
{"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 */
|
||||
init_need_scrollbar();
|
||||
#endif
|
||||
|
@ -1480,23 +1486,15 @@ static bool viewer_options_menu(void)
|
|||
|
||||
static void viewer_menu(void)
|
||||
{
|
||||
int m;
|
||||
int result;
|
||||
static const struct menu_item items[] = {
|
||||
{"Quit", NULL },
|
||||
{"Viewer Options", NULL },
|
||||
{"Show Playback Menu", NULL },
|
||||
{"Return", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL,
|
||||
"Return", "Viewer Options",
|
||||
"Show Playback Menu", "Quit");
|
||||
|
||||
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)
|
||||
{
|
||||
case 0: /* quit */
|
||||
menu_exit(m);
|
||||
viewer_exit(NULL);
|
||||
done = true;
|
||||
case 0: /* return */
|
||||
break;
|
||||
case 1: /* change settings */
|
||||
done = viewer_options_menu();
|
||||
|
@ -1504,10 +1502,11 @@ static void viewer_menu(void)
|
|||
case 2: /* playback control */
|
||||
playback_control(NULL);
|
||||
break;
|
||||
case 3: /* return */
|
||||
case 3: /* quit */
|
||||
viewer_exit(NULL);
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
menu_exit(m);
|
||||
viewer_draw(col);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "zxmisc.h"
|
||||
#include "zxconfig.h"
|
||||
#include "lib/configfile.h"
|
||||
#include "lib/oldmenuapi.h"
|
||||
|
||||
#include "spperif.h"
|
||||
#include "z80.h"
|
||||
|
@ -134,25 +133,18 @@ int spcf_read_conf_file(const char *filename)
|
|||
|
||||
/* set keys */
|
||||
static void set_keys(void){
|
||||
int m;
|
||||
char c;
|
||||
int selected=0;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Map Up key", NULL },
|
||||
{ "Map Down key", NULL },
|
||||
{ "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);
|
||||
MENUITEM_STRINGLIST(menu, "Custom keymap", NULL,
|
||||
"Map Up key", "Map Down key", "Map Left key",
|
||||
"Map Right key", "Map Fire/Jump key");
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
|
@ -191,41 +183,33 @@ static void set_keys(void){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
}
|
||||
|
||||
/* select predefined keymap */
|
||||
static void select_keymap(void){
|
||||
int m;
|
||||
int selected=0;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
static const struct menu_item items[] = {
|
||||
{ "2w90z", NULL },
|
||||
{ "qaopS", NULL },
|
||||
{ "7658S", NULL },
|
||||
};
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
MENUITEM_STRINGLIST(menu, "Predefined keymap", NULL,
|
||||
"2w90z", "qaopS", "7658S");
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
default:
|
||||
|
@ -233,8 +217,6 @@ static void select_keymap(void){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
}
|
||||
|
||||
/* options menu */
|
||||
|
@ -243,20 +225,15 @@ static void options_menu(void){
|
|||
{ "No", -1 },
|
||||
{ "Yes", -1 },
|
||||
};
|
||||
int m;
|
||||
int selected;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
int new_setting;
|
||||
static const struct menu_item items[] = {
|
||||
{ "Map Keys to kempston", NULL },
|
||||
{ "Display Speed", NULL },
|
||||
{ "Invert Colors", NULL },
|
||||
{ "Frameskip", NULL },
|
||||
{ "Sound", NULL },
|
||||
{ "Volume", NULL },
|
||||
{ "Predefined keymap", NULL },
|
||||
{ "Custom keymap", NULL },
|
||||
};
|
||||
MENUITEM_STRINGLIST(menu, "Options", NULL,
|
||||
"Map Keys to kempston", "Display Speed",
|
||||
"Invert Colors", "Frameskip", "Sound", "Volume",
|
||||
"Predefined keymap", "Custom keymap");
|
||||
|
||||
static struct opt_items frameskip_items[] = {
|
||||
{ "0", -1 },
|
||||
{ "1", -1 },
|
||||
|
@ -271,13 +248,10 @@ static void options_menu(void){
|
|||
};
|
||||
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
|
@ -339,8 +313,6 @@ static void options_menu(void){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
}
|
||||
|
||||
/* menu */
|
||||
|
@ -349,29 +321,21 @@ static bool zxbox_menu(void)
|
|||
#if CONFIG_CODEC == SWCODEC && !defined SIMULATOR
|
||||
rb->pcm_play_stop();
|
||||
#endif
|
||||
int m;
|
||||
int selected=0;
|
||||
int result;
|
||||
int menu_quit=0;
|
||||
int exit=0;
|
||||
char c;
|
||||
static const struct menu_item items[] = {
|
||||
{ "VKeyboard", NULL },
|
||||
{ "Play/Pause Tape", NULL },
|
||||
{ "Save quick snapshot", NULL },
|
||||
{ "Load quick snapshot", NULL },
|
||||
{ "Save Snapshot", NULL },
|
||||
{ "Toggle \"fast\" mode", NULL },
|
||||
{ "Options", NULL },
|
||||
{ "Quit", NULL },
|
||||
};
|
||||
|
||||
m = menu_init(items, sizeof(items) / sizeof(*items),
|
||||
NULL, NULL, NULL, NULL);
|
||||
MENUITEM_STRINGLIST(menu, "ZXBox Menu", NULL,
|
||||
"VKeyboard", "Play/Pause Tape",
|
||||
"Save quick snapshot", "Load quick snapshot",
|
||||
"Save Snapshot", "Toggle \"fast\" mode",
|
||||
"Options", "Quit");
|
||||
|
||||
rb->button_clear_queue();
|
||||
|
||||
while (!menu_quit) {
|
||||
result=menu_show(m);
|
||||
result = rb->do_menu(&menu, &selected, NULL, false);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
|
@ -415,7 +379,6 @@ static bool zxbox_menu(void)
|
|||
}
|
||||
}
|
||||
|
||||
menu_exit(m);
|
||||
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue