diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-11-11 10:58:09 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-11-11 10:58:09 +0000 |
commit | 91bab9b5a52fcadf984c33ac4df7bc87a8998dde (patch) | |
tree | f51913f17bfff9c22cda6a3381e5015841526624 | |
parent | 10807e85f60102e4edc89c8876abe7411b3d7b30 (diff) | |
download | rockbox-91bab9b5a52fcadf984c33ac4df7bc87a8998dde.tar.gz rockbox-91bab9b5a52fcadf984c33ac4df7bc87a8998dde.zip |
FS#11632: (rockboy) Some fixes and improvements by Michael Stummvoll
- increase number of slots to save/load state.
- add volume control.
- present old description when overwriting exsinting savegame and don't save when cancelled while input the description.
Flyspray: FS#11632
Author: Michael Stummvoll
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28554 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/rockboy/menu.c | 91 | ||||
-rw-r--r-- | docs/CREDITS | 1 |
2 files changed, 50 insertions, 42 deletions
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 64d469f86d..ec72d5e4e9 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "rtc-gb.h" | 11 | #include "rtc-gb.h" |
12 | #include "pcm.h" | 12 | #include "pcm.h" |
13 | 13 | ||
14 | #define MAX_SLOTS 5 | 14 | #define SLOT_COUNT 50 |
15 | #define DESC_SIZE 20 | 15 | #define DESC_SIZE 20 |
16 | 16 | ||
17 | /* load/save state function declarations */ | 17 | /* load/save state function declarations */ |
@@ -169,7 +169,7 @@ static void build_slot_path(char *buf, size_t bufsiz, int slot_id) { | |||
169 | * | 169 | * |
170 | * Returns true on success and false on failure. | 170 | * Returns true on success and false on failure. |
171 | * | 171 | * |
172 | * @desc is a brief user-provided description (<20 bytes) of the state. | 172 | * @desc is a brief user-provided description of the state. |
173 | * If no description is provided, set @desc to NULL. | 173 | * If no description is provided, set @desc to NULL. |
174 | * | 174 | * |
175 | */ | 175 | */ |
@@ -215,35 +215,11 @@ static bool do_file(char *path, char *desc, bool is_load) { | |||
215 | return true; | 215 | return true; |
216 | } | 216 | } |
217 | 217 | ||
218 | /* | ||
219 | * do_slot - load or save game data in the given slot | ||
220 | * | ||
221 | * Returns true on success and false on failure. | ||
222 | */ | ||
223 | static bool do_slot(int slot_id, bool is_load) { | ||
224 | char path_buf[256], desc_buf[DESC_SIZE]; | ||
225 | |||
226 | /* build slot filename, clear desc buf */ | ||
227 | build_slot_path(path_buf, sizeof(path_buf), slot_id); | ||
228 | memset(desc_buf, 0, sizeof(desc_buf)); | ||
229 | |||
230 | /* if we're saving to a slot, then get a brief description */ | ||
231 | if (!is_load) | ||
232 | { | ||
233 | if ( rb->kbd_input(desc_buf, sizeof(desc_buf)) < 0 ) | ||
234 | return false; | ||
235 | if ( !strlen(desc_buf) ) | ||
236 | strlcpy(desc_buf, "Untitled", sizeof(desc_buf)); | ||
237 | } | ||
238 | |||
239 | /* load/save file */ | ||
240 | return do_file(path_buf, desc_buf, is_load); | ||
241 | } | ||
242 | |||
243 | /* | 218 | /* |
244 | * get information on the given slot | 219 | * get information on the given slot |
245 | */ | 220 | */ |
246 | static void slot_info(char *info_buf, size_t info_bufsiz, int slot_id) { | 221 | static void slot_info(char *info_buf, size_t info_bufsiz, int slot_id, |
222 | bool number) { | ||
247 | char buf[256]; | 223 | char buf[256]; |
248 | int fd; | 224 | int fd; |
249 | 225 | ||
@@ -259,18 +235,44 @@ static void slot_info(char *info_buf, size_t info_bufsiz, int slot_id) { | |||
259 | buf[DESC_SIZE] = '\0'; | 235 | buf[DESC_SIZE] = '\0'; |
260 | strlcpy(info_buf, buf, info_bufsiz); | 236 | strlcpy(info_buf, buf, info_bufsiz); |
261 | } | 237 | } |
262 | else | 238 | else if(number) |
263 | strlcpy(info_buf, "ERROR", info_bufsiz); | 239 | strlcpy(info_buf, "ERROR", info_bufsiz); |
264 | 240 | ||
265 | close(fd); | 241 | close(fd); |
266 | } | 242 | } |
267 | else | 243 | else if(number) |
268 | { | 244 | { |
269 | /* if we couldn't open the file, then the slot is empty */ | 245 | /* if we couldn't open the file, then the slot is empty */ |
270 | strlcpy(info_buf, "<Empty>", info_bufsiz); | 246 | strlcpy(info_buf, "<Empty>", info_bufsiz); |
271 | } | 247 | } |
272 | } | 248 | } |
273 | 249 | ||
250 | /* | ||
251 | * do_slot - load or save game data in the given slot | ||
252 | * | ||
253 | * Returns true on success and false on failure. | ||
254 | */ | ||
255 | static bool do_slot(int slot_id, bool is_load) { | ||
256 | char path_buf[256], desc_buf[DESC_SIZE]; | ||
257 | |||
258 | /* build slot filename, clear desc buf */ | ||
259 | build_slot_path(path_buf, sizeof(path_buf), slot_id); | ||
260 | memset(desc_buf, 0, sizeof(desc_buf)); | ||
261 | |||
262 | /* if we're saving to a slot, then get a brief description */ | ||
263 | if (!is_load) | ||
264 | { | ||
265 | slot_info(desc_buf, sizeof(desc_buf), slot_id, false); | ||
266 | if ( rb->kbd_input(desc_buf, sizeof(desc_buf)) < 0 ) | ||
267 | return false; | ||
268 | if ( !strlen(desc_buf) ) | ||
269 | strlcpy(desc_buf, "Untitled", sizeof(desc_buf)); | ||
270 | } | ||
271 | |||
272 | /* load/save file */ | ||
273 | return do_file(path_buf, desc_buf, is_load); | ||
274 | } | ||
275 | |||
274 | /* | 276 | /* |
275 | * slot_get_name | 277 | * slot_get_name |
276 | */ | 278 | */ |
@@ -299,17 +301,16 @@ static int list_action_callback(int action, struct gui_synclist *lists) | |||
299 | */ | 301 | */ |
300 | static void do_slot_menu(bool is_load) { | 302 | static void do_slot_menu(bool is_load) { |
301 | bool done=false; | 303 | bool done=false; |
302 | char items[MAX_SLOTS][DESC_SIZE]; | 304 | char items[SLOT_COUNT][DESC_SIZE]; |
303 | int result; | 305 | int result; |
304 | int i; | 306 | int i; |
305 | int num_items = sizeof(items) / sizeof(*items); | ||
306 | struct simplelist_info info; | 307 | struct simplelist_info info; |
307 | 308 | ||
308 | /* create menu items */ | 309 | /* create menu items */ |
309 | for (i = 0; i < num_items; i++) | 310 | for (i = 0; i < SLOT_COUNT; i++) |
310 | slot_info(items[i], sizeof(*items), i); | 311 | slot_info(items[i], sizeof(*items), i, true); |
311 | 312 | ||
312 | rb->simplelist_info_init(&info, NULL, num_items, (void *)items); | 313 | rb->simplelist_info_init(&info, NULL, SLOT_COUNT, (void *)items); |
313 | info.get_name = slot_get_name; | 314 | info.get_name = slot_get_name; |
314 | info.action_callback = list_action_callback; | 315 | info.action_callback = list_action_callback; |
315 | 316 | ||
@@ -319,7 +320,7 @@ static void do_slot_menu(bool is_load) { | |||
319 | break; | 320 | break; |
320 | 321 | ||
321 | result = info.selection; | 322 | result = info.selection; |
322 | if (result<num_items && result >= 0 ) | 323 | if (result<SLOT_COUNT && result >= 0 ) |
323 | done = do_slot(result, is_load); | 324 | done = do_slot(result, is_load); |
324 | else | 325 | else |
325 | done = true; | 326 | done = true; |
@@ -384,7 +385,7 @@ static void do_opt_menu(void) | |||
384 | #endif | 385 | #endif |
385 | 386 | ||
386 | MENUITEM_STRINGLIST(menu, "Options", NULL, | 387 | MENUITEM_STRINGLIST(menu, "Options", NULL, |
387 | "Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)", | 388 | "Max Frameskip", "Sound", "Volume", "Stats", "Set Keys (Buggy)", |
388 | #ifdef HAVE_LCD_COLOR | 389 | #ifdef HAVE_LCD_COLOR |
389 | "Screen Size", "Screen Rotate", "Set Palette", | 390 | "Screen Size", "Screen Rotate", "Set Palette", |
390 | #endif | 391 | #endif |
@@ -392,6 +393,9 @@ static void do_opt_menu(void) | |||
392 | 393 | ||
393 | options.dirty=1; /* Assume that the settings have been changed */ | 394 | options.dirty=1; /* Assume that the settings have been changed */ |
394 | 395 | ||
396 | struct viewport *parentvp = NULL; | ||
397 | const struct settings_list* vol = rb->find_setting(&rb->global_settings->volume, NULL); | ||
398 | |||
395 | while(!done) | 399 | while(!done) |
396 | { | 400 | { |
397 | result = rb->do_menu(&menu, &selected, NULL, false); | 401 | result = rb->do_menu(&menu, &selected, NULL, false); |
@@ -407,24 +411,27 @@ static void do_opt_menu(void) | |||
407 | rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL ); | 411 | rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL ); |
408 | if(options.sound) sound_dirty(); | 412 | if(options.sound) sound_dirty(); |
409 | break; | 413 | break; |
410 | case 2: /* Stats */ | 414 | case 2: /* Volume */ |
415 | rb->option_screen((struct settings_list*)vol, parentvp, false, "Volume"); | ||
416 | break; | ||
417 | case 3: /* Stats */ | ||
411 | rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL ); | 418 | rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL ); |
412 | break; | 419 | break; |
413 | case 3: /* Keys */ | 420 | case 4: /* Keys */ |
414 | setupkeys(); | 421 | setupkeys(); |
415 | break; | 422 | break; |
416 | #ifdef HAVE_LCD_COLOR | 423 | #ifdef HAVE_LCD_COLOR |
417 | case 4: /* Screen Size */ | 424 | case 5: /* Screen Size */ |
418 | rb->set_option("Screen Size", &options.scaling, INT, scaling, | 425 | rb->set_option("Screen Size", &options.scaling, INT, scaling, |
419 | sizeof(scaling)/sizeof(*scaling), NULL ); | 426 | sizeof(scaling)/sizeof(*scaling), NULL ); |
420 | setvidmode(); | 427 | setvidmode(); |
421 | break; | 428 | break; |
422 | case 5: /* Screen rotate */ | 429 | case 6: /* Screen rotate */ |
423 | rb->set_option("Screen Rotate", &options.rotate, INT, rotate, | 430 | rb->set_option("Screen Rotate", &options.rotate, INT, rotate, |
424 | sizeof(rotate)/sizeof(*rotate), NULL ); | 431 | sizeof(rotate)/sizeof(*rotate), NULL ); |
425 | setvidmode(); | 432 | setvidmode(); |
426 | break; | 433 | break; |
427 | case 6: /* Palette */ | 434 | case 7: /* Palette */ |
428 | rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL ); | 435 | rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL ); |
429 | set_pal(); | 436 | set_pal(); |
430 | break; | 437 | break; |
diff --git a/docs/CREDITS b/docs/CREDITS index 06f416553c..24023e8e17 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -563,6 +563,7 @@ Calvin Walden | |||
563 | Michael Gentry | 563 | Michael Gentry |
564 | David Fowle | 564 | David Fowle |
565 | Fabian Vogel | 565 | Fabian Vogel |
566 | Michael Stummvoll | ||
566 | 567 | ||
567 | The libmad team | 568 | The libmad team |
568 | The wavpack team | 569 | The wavpack team |