summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-11-28 02:31:17 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-11-28 02:31:17 +0000
commitfc9dc0a54aaa049b89b0526509765e27027f076f (patch)
tree98253e682a6b8a866439bb8993b003632bb2553a
parent5656f8245f63c5104085998c0865bac0aea95d44 (diff)
downloadrockbox-fc9dc0a54aaa049b89b0526509765e27027f076f.tar.gz
rockbox-fc9dc0a54aaa049b89b0526509765e27027f076f.zip
Replace the bubbles start screen with a standard menu to fix FS#8950.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19253 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/bubbles.c204
1 files changed, 42 insertions, 162 deletions
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c
index a736e74542..ecd9096870 100644
--- a/apps/plugins/bubbles.c
+++ b/apps/plugins/bubbles.c
@@ -2194,6 +2194,28 @@ static void bubbles_savescores(struct game_context* bb) {
2194} 2194}
2195 2195
2196/***************************************************************************** 2196/*****************************************************************************
2197* bubbles_displaycores() displays the high scores
2198******************************************************************************/
2199static char * scores_get_name(int selected_item, void * data,
2200 char * buffer, size_t buffer_len)
2201{
2202 struct game_context* bb = (struct game_context*)data;
2203 rb->snprintf(buffer, buffer_len, "#%02d: %d, Lvl %d",
2204 selected_item+1,
2205 bb->highscores[selected_item].score,
2206 bb->highscores[selected_item].level);
2207 return buffer;
2208}
2209static void bubbles_displayscores(struct game_context* bb) {
2210 struct simplelist_info info;
2211 rb->simplelist_info_init(&info, "High Scores", NUM_SCORES, (void*)bb);
2212 info.hide_selection = true;
2213 info.get_name = scores_get_name;
2214 rb->simplelist_show_list(&info);
2215}
2216
2217
2218/*****************************************************************************
2197* bubbles_loadgame() loads the saved game and returns load success. 2219* bubbles_loadgame() loads the saved game and returns load success.
2198******************************************************************************/ 2220******************************************************************************/
2199static bool bubbles_loadgame(struct game_context* bb) { 2221static bool bubbles_loadgame(struct game_context* bb) {
@@ -2362,17 +2384,10 @@ static int bubbles_handlebuttons(struct game_context* bb, bool animblock,
2362* bubbles() is the main game subroutine, it returns the final game status. 2384* bubbles() is the main game subroutine, it returns the final game status.
2363******************************************************************************/ 2385******************************************************************************/
2364static int bubbles(struct game_context* bb) { 2386static int bubbles(struct game_context* bb) {
2365 int i;
2366 int w, h;
2367 int button;
2368 int buttonres; 2387 int buttonres;
2369 unsigned int startlevel = 0; 2388 unsigned int startlevel = 0;
2370 char *title = "Bubbles";
2371 bool startgame = false; 2389 bool startgame = false;
2372 bool showscores = false;
2373 long timeout; 2390 long timeout;
2374 const struct button_mapping *plugin_contexts[]
2375 = {generic_actions,generic_directions};
2376 2391
2377 bubbles_setcolors(); 2392 bubbles_setcolors();
2378 2393
@@ -2382,170 +2397,38 @@ static int bubbles(struct game_context* bb) {
2382 /******************** 2397 /********************
2383 * menu * 2398 * menu *
2384 ********************/ 2399 ********************/
2400 MENUITEM_STRINGLIST(menu,"Bubbles Menu",NULL,
2401 "Start New Game", "Resume Game",
2402 "Level", "Display High Scores", "Quit");
2385 while(!startgame){ 2403 while(!startgame){
2386 char str[30]; 2404 switch (rb->do_menu(&menu, NULL, NULL, false))
2387 rb->lcd_clear_display(); 2405 {
2388 2406 case 0: /* new game */
2389 if(!showscores) {
2390 /* welcome screen to display key bindings */
2391 rb->lcd_getstringsize(title, &w, &h);
2392 rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, title);
2393#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
2394 rb->lcd_puts(0, 2, "ON to start/pause");
2395 rb->lcd_puts(0, 3, "MODE to save/resume");
2396 rb->lcd_puts(0, 4, "OFF to exit");
2397 rb->lcd_puts(0, 5, "SELECT to fire");
2398 rb->lcd_puts(0, 6, " and show high scores");
2399 rb->lcd_puts(0, 7, "LEFT/RIGHT to aim");
2400 rb->lcd_puts(0, 8, "UP/DOWN to change level");
2401#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
2402 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
2403 rb->lcd_puts(0, 2, "PLAY to start/pause");
2404 rb->lcd_puts(0, 3, "MENU to save/resume");
2405 rb->lcd_puts(0, 4, "MENU+SELECT to exit");
2406 rb->lcd_puts(0, 5, "SELECT to fire");
2407 rb->lcd_puts(0, 6, " and show high scores");
2408 rb->lcd_puts(0, 7, "SCROLL to aim");
2409 rb->lcd_puts(0, 8, " and to change level");
2410#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
2411 rb->lcd_puts(0, 2, "PLAY to start/pause");
2412 rb->lcd_puts(0, 3, "REC to save/resume");
2413 rb->lcd_puts(0, 4, "POWER to exit");
2414 rb->lcd_puts(0, 5, "SELECT to fire");
2415 rb->lcd_puts(0, 6, " and show high scores");
2416 rb->lcd_puts(0, 7, "LEFT/RIGHT to aim");
2417 rb->lcd_puts(0, 8, "UP/DOWN to change level");
2418#elif CONFIG_KEYPAD == GIGABEAT_PAD
2419 rb->lcd_puts(0, 2, "A to start/pause");
2420 rb->lcd_puts(0, 3, "MENU to save/resume");
2421 rb->lcd_puts(0, 4, "POWER to exit");
2422 rb->lcd_puts(0, 5, "SELECT to fire");
2423 rb->lcd_puts(0, 6, " and show high scores");
2424 rb->lcd_puts(0, 7, "LEFT/RIGHT to aim");
2425 rb->lcd_puts(0, 8, "UP/DOWN to change level");
2426#elif CONFIG_KEYPAD == RECORDER_PAD
2427 rb->lcd_puts_scroll(0, 2, "ON to start/pause, "
2428 "F1 to save/resume, "
2429 "OFF to exit, "
2430 "PLAY to fire and show high scores, "
2431 "LEFT/RIGHT to aim, "
2432 "UP/DOWN to change level.");
2433#elif CONFIG_KEYPAD == ONDIO_PAD
2434 rb->lcd_puts_scroll(0, 2, "MODE to start/pause, "
2435 "DOWN to save/resume, "
2436 "OFF to exit, "
2437 "UP to fire and show high scores, "
2438 "LEFT/RIGHT to aim and to change level.");
2439#elif CONFIG_KEYPAD == IRIVER_H10_PAD
2440 rb->lcd_puts(0, 2, "PLAY to start/pause");
2441 rb->lcd_puts(0, 3, "FF to save/resume");
2442 rb->lcd_puts(0, 4, "POWER to exit");
2443 rb->lcd_puts(0, 5, "REW/UP to fire");
2444 rb->lcd_puts(0, 6, " and show high scores");
2445 rb->lcd_puts(0, 7, "LEFT/RIGHT to aim");
2446 rb->lcd_puts(0, 8, "UP/DOWN to change level");
2447#elif CONFIG_KEYPAD == SANSA_E200_PAD
2448 rb->lcd_puts(0, 2, "PLAY to start/pause");
2449 rb->lcd_puts(0, 3, "SUBMENU to save/resume");
2450 rb->lcd_puts(0, 4, "POWER to exit");
2451 rb->lcd_puts(0, 5, "SELECT to fire");
2452 rb->lcd_puts(0, 6, " and show high scores");
2453 rb->lcd_puts(0, 7, "SCROLL to aim");
2454 rb->lcd_puts(0, 8, " and change level");
2455#elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_CLIP_PAD
2456 rb->lcd_puts(0, 2, "PLAY to start/pause");
2457 rb->lcd_puts(0, 3, "SUBMENU to save/resume");
2458 rb->lcd_puts(0, 4, "POWER to exit");
2459 rb->lcd_puts_scroll(0, 5, "SELECT to fire and show high scores, "
2460 "LEFT/RIGHT to aim and change level");
2461#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
2462 rb->lcd_puts(0, 2, "PLAY to start/pause");
2463 rb->lcd_puts(0, 3, "MENU to save/resume");
2464 rb->lcd_puts(0, 4, "REC to exit");
2465 rb->lcd_puts(0, 5, "MODE to fire");
2466 rb->lcd_puts(0, 6, " and show high scores");
2467 rb->lcd_puts(0, 7, "REW/FF to aim");
2468 rb->lcd_puts(0, 8, "VOL UP/DN to chg. lvl");
2469#endif
2470#if LCD_WIDTH >= 138
2471 rb->snprintf(str, 28, "Start on level %d of %d", startlevel+1,
2472 bb->highlevel+1);
2473#else
2474 rb->snprintf(str, 28, "Start on lvl %d/%d", startlevel+1,
2475 bb->highlevel+1);
2476#endif
2477 rb->lcd_puts(0, MIN(TEXT_LINES-3,10), str);
2478 rb->lcd_puts(0, MIN(TEXT_LINES-2,12), "High Score:");
2479 rb->snprintf(str, 30, "%d, Lvl %d",
2480 bb->highscores[0].score, bb->highscores[0].level);
2481 rb->lcd_puts(2, MIN(TEXT_LINES-1,13), str);
2482 } else {
2483 /* show high scores */
2484 rb->snprintf(str, 12, "High Scores");
2485 rb->lcd_getstringsize(str, &w, &h);
2486 rb->lcd_putsxy((LCD_WIDTH-w)/2, 0, str);
2487
2488 for(i=0; i<NUM_SCORES; i++) {
2489 rb->snprintf(str, 30, "#%02d: %d, Lvl %d", i+1,
2490 bb->highscores[i].score, bb->highscores[i].level);
2491 rb->lcd_puts(0, i+2, str);
2492 }
2493 }
2494
2495 rb->lcd_update();
2496
2497 /* handle menu button presses */
2498 button = pluginlib_getaction(rb,TIMEOUT_BLOCK,plugin_contexts,2);
2499 switch(button){
2500 case BUBBLES_START: /* start playing */
2501 bb->level = startlevel; 2407 bb->level = startlevel;
2502 startgame = true; 2408 startgame = true;
2503 break; 2409 break;
2504 case BUBBLES_QUIT: /* quit program */ 2410 case 1: /* resume game */
2505 if(showscores) {
2506 showscores = false;
2507 break;
2508 }
2509 return BB_QUIT;
2510
2511 case BUBBLES_RESUME: /* resume game */
2512 if(!bubbles_loadgame(bb)) { 2411 if(!bubbles_loadgame(bb)) {
2513 rb->splash(HZ*2, "Nothing to resume"); 2412 rb->splash(HZ*2, "Nothing to resume");
2514 } else { 2413 } else {
2515 startgame = true; 2414 startgame = true;
2516 } 2415 }
2517 break; 2416 break;
2518 2417 case 2: /* choose level */
2519 case BUBBLES_SELECT: /* toggle high scores */ 2418 startlevel++;
2520 showscores = !showscores; 2419 rb->set_int("Choose start level", "", UNIT_INT, &startlevel, NULL, 1, 1, bb->highlevel+1, NULL);
2521 break; 2420 startlevel--;
2522
2523 case BUBBLES_LVLINC: /* increase starting level */
2524 case BUBBLES_LVLINC_REP:
2525 if(startlevel >= bb->highlevel) {
2526 startlevel = 0;
2527 } else {
2528 startlevel++;
2529 }
2530 break;
2531
2532 case BUBBLES_LVLDEC: /* decrease starting level */
2533 case BUBBLES_LVLDEC_REP:
2534 if(startlevel <= 0) {
2535 startlevel = bb->highlevel;
2536 } else {
2537 startlevel--;
2538 }
2539 break; 2421 break;
2540 2422 case 3: /* High scores */
2541 default: 2423 bubbles_displayscores(bb);
2542 if(rb->default_event_handler_ex(button, bubbles_callback,
2543 (void*) bb) == SYS_USB_CONNECTED)
2544 return BB_USB;
2545 break; 2424 break;
2425 case 4: /* quit */
2426 return BB_QUIT;
2427 case MENU_ATTACHED_USB:
2428 bubbles_callback(bb);
2429 return BB_USB;
2546 } 2430 }
2547 } 2431 }
2548
2549 /******************** 2432 /********************
2550 * init * 2433 * init *
2551 ********************/ 2434 ********************/
@@ -2620,7 +2503,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
2620 2503
2621 while(!exit) { 2504 while(!exit) {
2622 switch(bubbles(&bb)){ 2505 switch(bubbles(&bb)){
2623 char str[19];
2624 case BB_WIN: 2506 case BB_WIN:
2625 rb->splash(HZ*2, "You Win!"); 2507 rb->splash(HZ*2, "You Win!");
2626 /* record high level */ 2508 /* record high level */
@@ -2631,8 +2513,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
2631 2513
2632 /* record high score */ 2514 /* record high score */
2633 if((position = bubbles_recordscore(&bb))) { 2515 if((position = bubbles_recordscore(&bb))) {
2634 rb->snprintf(str, 19, "New high score #%d!", position); 2516 rb->splashf(HZ*2, "New high score #%d!", position);
2635 rb->splash(HZ*2, str);
2636 } 2517 }
2637 break; 2518 break;
2638 2519
@@ -2650,8 +2531,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
2650 2531
2651 /* record high score */ 2532 /* record high score */
2652 if((position = bubbles_recordscore(&bb))) { 2533 if((position = bubbles_recordscore(&bb))) {
2653 rb->snprintf(str, 19, "New high score #%d!", position); 2534 rb->splashf(HZ*2, "New high score #%d!", position);
2654 rb->splash(HZ*2, str);
2655 } 2535 }
2656 } 2536 }
2657 break; 2537 break;