-// (c) Copyright 2006-2010 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * (C) Gražvydas "notaz" Ignotas, 2006-2010\r
+ *\r
+ * This work is licensed under the terms of any of these licenses\r
+ * (at your option):\r
+ * - GNU GPL, version 2 or later.\r
+ * - GNU LGPL, version 2.1 or later.\r
+ * See the COPYING file in the top-level directory.\r
+ */\r
\r
#include <stdio.h>\r
#include <string.h>\r
}\r
}\r
\r
-static void menu_enter(int is_rom_loaded)\r
-{\r
- if (is_rom_loaded)\r
- {\r
- // darken the active framebuffer\r
- menu_darken_bg(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 1);\r
- }\r
- else\r
- {\r
- char buff[256];\r
-\r
- // should really only happen once, on startup..\r
- emu_make_path(buff, "skin/background.png", sizeof(buff));\r
- if (readpng(g_menubg_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h) < 0)\r
- memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
- }\r
-\r
- plat_video_menu_enter(is_rom_loaded);\r
-}\r
-\r
static int me_id2offset(const menu_entry *ent, menu_id id)\r
{\r
int i;\r
h = g_menuscreen_h;\r
}\r
\r
- x = g_menuscreen_w / 2 - w / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
y = g_menuscreen_h / 2 - h / 2;\r
+#ifdef MENU_ALIGN_LEFT\r
+ if (x > 12) x = 12;\r
+#endif\r
\r
/* draw */\r
menu_draw_begin(1);\r
len = strlen(names[i]);\r
if (len > 10)\r
offs = 10 - len - 2;\r
- if (i == *(int *)ent->var) {\r
+ if (i == *(unsigned char *)ent->var) {\r
text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]);\r
break;\r
}\r
\r
/* ***************************************** */\r
\r
-static void draw_menu_credits(void)\r
+static void draw_menu_credits(void (*draw_more)(void))\r
{\r
const char *creds, *p;\r
int x, y, h, w, wt;\r
p++;\r
}\r
\r
- x = g_menuscreen_w / 2 - w * me_mfont_w / 2;\r
+ x = g_menuscreen_w / 2 - w * me_mfont_w / 2;\r
y = g_menuscreen_h / 2 - h * me_mfont_h / 2;\r
if (x < 0) x = 0;\r
if (y < 0) y = 0;\r
p++;\r
}\r
\r
+ if (draw_more != NULL)\r
+ draw_more();\r
+\r
menu_draw_end();\r
}\r
\r
\r
// -------------- ROM selector --------------\r
\r
-// rrrr rggg gggb bbbb\r
-static unsigned short file2color(const char *fname)\r
-{\r
- const char *ext = fname + strlen(fname) - 3;\r
- static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" };\r
- static const char *other_exts[] = { "gmv", "pat" };\r
- int i;\r
-\r
- if (ext < fname) ext = fname;\r
- for (i = 0; i < array_size(rom_exts); i++)\r
- if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; // FIXME: mk defines\r
- for (i = 0; i < array_size(other_exts); i++)\r
- if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5;\r
- return 0xffff;\r
-}\r
-\r
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)\r
{\r
int max_cnt, start, i, x, pos;\r
smalltext_out16(x, pos * me_sfont_h, "/", 0xfff6);\r
smalltext_out16(x + me_sfont_w, pos * me_sfont_h, namelist[i+1]->d_name, 0xfff6);\r
} else {\r
- unsigned short color = file2color(namelist[i+1]->d_name);\r
+ unsigned short color = fname2color(namelist[i+1]->d_name);\r
smalltext_out16(x, pos * me_sfont_h, namelist[i+1]->d_name, color);\r
}\r
}\r
{\r
int newlen;\r
char *p, *newdir;\r
- if (!(inp & PBTN_MOK)) continue;\r
+ if (!(inp & PBTN_MOK))\r
+ continue;\r
newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
newdir = malloc(newlen);\r
+ if (newdir == NULL)\r
+ break;\r
if (strcmp(namelist[sel+1]->d_name, "..") == 0) {\r
char *start = curr_path;\r
p = start + strlen(start) - 1;\r
free(namelist);\r
}\r
\r
+ // restore curr_path\r
+ if (fname != NULL) {\r
+ n = strlen(curr_path);\r
+ if (curr_path + n + 1 == fname)\r
+ curr_path[n] = '/';\r
+ }\r
+\r
return ret;\r
}\r
\r
if (x < 0) x = 0;\r
y = g_menuscreen_h / 2 - h / 2;\r
if (y < 0) y = 0;\r
+#ifdef MENU_ALIGN_LEFT\r
+ if (x > 12 + me_mfont_w * 2)\r
+ x = 12 + me_mfont_w * 2;\r
+#endif\r
\r
menu_draw_begin(1);\r
\r
-// (c) Copyright 2006-2009 notaz, All rights reserved.
+/*
+ * (C) Gražvydas "notaz" Ignotas, 2006-2010
+ *
+ * This work is licensed under the terms of any of these licenses
+ * (at your option):
+ * - GNU GPL, version 2 or later.
+ * - GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
typedef enum
{
const char *help;
} menu_entry;
+#define mee_handler_id_h(name, id, handler, help) \
+ { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL, NULL, help }
+
#define mee_handler_id(name, id, handler) \
- { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL, NULL, NULL }
+ mee_handler_id_h(name, id, handler, NULL)
#define mee_handler(name, handler) \
mee_handler_id(name, MA_NONE, handler)
+#define mee_handler_h(name, handler, help) \
+ mee_handler_id_h(name, MA_NONE, handler, help)
+
#define mee_label(name) \
{ name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL, NULL, NULL }
#include <pico/pico.h>
#include <pico/patch.h>
+// rrrr rggg gggb bbbb
+static unsigned short fname2color(const char *fname)
+{
+ const char *ext = fname + strlen(fname) - 3;
+ static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" };
+ static const char *other_exts[] = { "gmv", "pat" };
+ int i;
+
+ if (ext < fname) ext = fname;
+ for (i = 0; i < array_size(rom_exts); i++)
+ if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; // FIXME: mk defines
+ for (i = 0; i < array_size(other_exts); i++)
+ if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5;
+ return 0xffff;
+}
+
#include "menu.c"
/* platform specific options and handlers */
#define menu_main_plat_draw NULL
#endif
+static void menu_enter(int is_rom_loaded)
+{
+ if (is_rom_loaded)
+ {
+ // darken the active framebuffer
+ menu_darken_bg(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 1);
+ }
+ else
+ {
+ char buff[256];
+
+ // should really only happen once, on startup..
+ emu_make_path(buff, "skin/background.png", sizeof(buff));
+ if (readpng(g_menubg_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h) < 0)
+ memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);
+ }
+
+ plat_video_menu_enter(is_rom_loaded);
+}
+
static void draw_savestate_bg(int slot)
{
const char *fname;