diff options
author | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-12-17 15:37:52 +0000 |
---|---|---|
committer | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-12-17 15:37:52 +0000 |
commit | c50209ef7f6c4fc8efe9913552924cc56333b871 (patch) | |
tree | d373b1e7bd4ae30be956d3a871ac2274de8c57d3 /apps/plugins/bubbles.c | |
parent | 665bdd5638bc6a24a805d9ef302a10f8eee18708 (diff) | |
download | rockbox-c50209ef7f6c4fc8efe9913552924cc56333b871.tar.gz rockbox-c50209ef7f6c4fc8efe9913552924cc56333b871.zip |
Hide menu entries "Resume Game" and "Quit without Saving" if not available and clean up the code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24046 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/bubbles.c')
-rw-r--r-- | apps/plugins/bubbles.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c index 6d386aa08c..76affa270b 100644 --- a/apps/plugins/bubbles.c +++ b/apps/plugins/bubbles.c | |||
@@ -90,7 +90,7 @@ enum { | |||
90 | #define BUBBLES_FIRE PLA_FIRE | 90 | #define BUBBLES_FIRE PLA_FIRE |
91 | 91 | ||
92 | /* external bitmaps */ | 92 | /* external bitmaps */ |
93 | #ifdef HAVE_LCD_COLOR | 93 | #ifdef HAVE_LCD_COLOR |
94 | #include "pluginbitmaps/bubbles_background.h" | 94 | #include "pluginbitmaps/bubbles_background.h" |
95 | #endif | 95 | #endif |
96 | #include "pluginbitmaps/bubbles_bubble.h" | 96 | #include "pluginbitmaps/bubbles_bubble.h" |
@@ -1433,8 +1433,8 @@ static void bubbles_drawboard(struct game_context* bb) { | |||
1433 | for(j=0; j<colmax; j++) { | 1433 | for(j=0; j<colmax; j++) { |
1434 | if(bb->playboard[i][j].type >= 0 && !bb->playboard[i][j].delete) { | 1434 | if(bb->playboard[i][j].type >= 0 && !bb->playboard[i][j].delete) { |
1435 | rb->lcd_bitmap_part(bubbles_emblem, | 1435 | rb->lcd_bitmap_part(bubbles_emblem, |
1436 | 0, EMBLEM_HEIGHT*bb->playboard[i][j].type, | 1436 | 0, EMBLEM_HEIGHT*bb->playboard[i][j].type, |
1437 | STRIDE( SCREEN_MAIN, | 1437 | STRIDE( SCREEN_MAIN, |
1438 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), | 1438 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), |
1439 | XOFS+indent+BUBBLE_WIDTH*j+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, | 1439 | XOFS+indent+BUBBLE_WIDTH*j+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, |
1440 | YOFS+ROW_HEIGHT*i+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2+bb->compress*ROW_HEIGHT, | 1440 | YOFS+ROW_HEIGHT*i+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2+bb->compress*ROW_HEIGHT, |
@@ -1451,8 +1451,8 @@ static void bubbles_drawboard(struct game_context* bb) { | |||
1451 | 1451 | ||
1452 | /* display bubble to be shot */ | 1452 | /* display bubble to be shot */ |
1453 | rb->lcd_bitmap_part(bubbles_emblem, | 1453 | rb->lcd_bitmap_part(bubbles_emblem, |
1454 | 0, EMBLEM_HEIGHT*bb->queue[bb->nextinq], | 1454 | 0, EMBLEM_HEIGHT*bb->queue[bb->nextinq], |
1455 | STRIDE( SCREEN_MAIN, | 1455 | STRIDE( SCREEN_MAIN, |
1456 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), | 1456 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), |
1457 | SHOTX+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, | 1457 | SHOTX+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, |
1458 | SHOTY+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, | 1458 | SHOTY+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, |
@@ -1466,8 +1466,8 @@ static void bubbles_drawboard(struct game_context* bb) { | |||
1466 | /* display next bubble to be shot */ | 1466 | /* display next bubble to be shot */ |
1467 | #ifndef NEXT_BB_X | 1467 | #ifndef NEXT_BB_X |
1468 | rb->lcd_bitmap_part(bubbles_emblem, | 1468 | rb->lcd_bitmap_part(bubbles_emblem, |
1469 | 0, EMBLEM_HEIGHT*bb->queue[(bb->nextinq+1)%NUM_QUEUE], | 1469 | 0, EMBLEM_HEIGHT*bb->queue[(bb->nextinq+1)%NUM_QUEUE], |
1470 | STRIDE( SCREEN_MAIN, | 1470 | STRIDE( SCREEN_MAIN, |
1471 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), | 1471 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), |
1472 | XOFS/2-BUBBLE_WIDTH/2+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, | 1472 | XOFS/2-BUBBLE_WIDTH/2+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, |
1473 | SHOTY+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, | 1473 | SHOTY+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, |
@@ -1479,8 +1479,8 @@ static void bubbles_drawboard(struct game_context* bb) { | |||
1479 | rb->lcd_set_drawmode(DRMODE_SOLID); | 1479 | rb->lcd_set_drawmode(DRMODE_SOLID); |
1480 | #else | 1480 | #else |
1481 | rb->lcd_bitmap_part(bubbles_emblem, | 1481 | rb->lcd_bitmap_part(bubbles_emblem, |
1482 | 0, EMBLEM_HEIGHT*bb->queue[(bb->nextinq+1)%NUM_QUEUE], | 1482 | 0, EMBLEM_HEIGHT*bb->queue[(bb->nextinq+1)%NUM_QUEUE], |
1483 | STRIDE( SCREEN_MAIN, | 1483 | STRIDE( SCREEN_MAIN, |
1484 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), | 1484 | BMPWIDTH_bubbles_emblem, BMPHEIGHT_bubbles_emblem), |
1485 | NEXT_BB_X + NEXT_BB_WIDTH/2-BUBBLE_WIDTH/2+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, | 1485 | NEXT_BB_X + NEXT_BB_WIDTH/2-BUBBLE_WIDTH/2+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, |
1486 | NEXT_BB_Y + (BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2 + h, | 1486 | NEXT_BB_Y + (BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2 + h, |
@@ -1543,7 +1543,7 @@ static void bubbles_drawboard(struct game_context* bb) { | |||
1543 | #else | 1543 | #else |
1544 | rb->lcd_putsxy(NEXT_BB_X+(NEXT_BB_WIDTH/2-w1/2), NEXT_BB_Y, next); | 1544 | rb->lcd_putsxy(NEXT_BB_X+(NEXT_BB_WIDTH/2-w1/2), NEXT_BB_Y, next); |
1545 | #endif | 1545 | #endif |
1546 | 1546 | ||
1547 | 1547 | ||
1548 | if(bb->elapsedshot >= (MAX_SHOTTIME*7)/10) { | 1548 | if(bb->elapsedshot >= (MAX_SHOTTIME*7)/10) { |
1549 | rb->lcd_getstringsize(hurry, &w1, &h); | 1549 | rb->lcd_getstringsize(hurry, &w1, &h); |
@@ -1603,9 +1603,9 @@ static int bubbles_fire(struct game_context* bb) { | |||
1603 | 1603 | ||
1604 | /* display shot */ | 1604 | /* display shot */ |
1605 | bubbles_drawboard(bb); | 1605 | bubbles_drawboard(bb); |
1606 | rb->lcd_bitmap_part(bubbles_emblem, 0, EMBLEM_HEIGHT*bubblecur, | 1606 | rb->lcd_bitmap_part(bubbles_emblem, 0, EMBLEM_HEIGHT*bubblecur, |
1607 | STRIDE( SCREEN_MAIN, | 1607 | STRIDE( SCREEN_MAIN, |
1608 | BMPWIDTH_bubbles_emblem, | 1608 | BMPWIDTH_bubbles_emblem, |
1609 | BMPHEIGHT_bubbles_emblem), | 1609 | BMPHEIGHT_bubbles_emblem), |
1610 | SHOTX+tempxofs+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, | 1610 | SHOTX+tempxofs+(BUBBLE_WIDTH-EMBLEM_WIDTH)/2, |
1611 | SHOTY+tempyofs+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, | 1611 | SHOTY+tempyofs+(BUBBLE_HEIGHT-EMBLEM_HEIGHT)/2, |
@@ -2068,9 +2068,9 @@ static int bubbles_fall(struct game_context* bb) { | |||
2068 | onscreen = true; | 2068 | onscreen = true; |
2069 | 2069 | ||
2070 | rb->lcd_bitmap_part(bubbles_emblem, 0, | 2070 | rb->lcd_bitmap_part(bubbles_emblem, 0, |
2071 | EMBLEM_HEIGHT*bb->playboard[i][j].type, | 2071 | EMBLEM_HEIGHT*bb->playboard[i][j].type, |
2072 | STRIDE( SCREEN_MAIN, | 2072 | STRIDE( SCREEN_MAIN, |
2073 | BMPWIDTH_bubbles_emblem, | 2073 | BMPWIDTH_bubbles_emblem, |
2074 | BMPHEIGHT_bubbles_emblem), | 2074 | BMPHEIGHT_bubbles_emblem), |
2075 | XOFS+indent+BUBBLE_WIDTH*j+ | 2075 | XOFS+indent+BUBBLE_WIDTH*j+ |
2076 | (BUBBLE_WIDTH-EMBLEM_WIDTH)/2+xofs, | 2076 | (BUBBLE_WIDTH-EMBLEM_WIDTH)/2+xofs, |
@@ -2365,15 +2365,24 @@ static int bubbles_handlebuttons(struct game_context* bb, bool animblock, | |||
2365 | return BB_NONE; | 2365 | return BB_NONE; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | static int bubbles_menu_cb(int action, const struct menu_item_ex *this_item) | ||
2369 | { | ||
2370 | int i = ((intptr_t)this_item); | ||
2371 | if(action == ACTION_REQUEST_MENUITEM | ||
2372 | && !resume && (i==0 || i==5)) | ||
2373 | return ACTION_EXIT_MENUITEM; | ||
2374 | return action; | ||
2375 | } | ||
2376 | |||
2368 | /***************************************************************************** | 2377 | /***************************************************************************** |
2369 | * bubbles_menu() is the initial menu at the start of the game. | 2378 | * bubbles_menu() is the initial menu at the start of the game. |
2370 | ******************************************************************************/ | 2379 | ******************************************************************************/ |
2371 | static int bubbles_menu(struct game_context* bb) { | 2380 | static int bubbles_menu(struct game_context* bb) { |
2372 | static unsigned int startlevel = 0; | 2381 | static unsigned int startlevel = 0; |
2373 | int selected = resume?0:1; | 2382 | int selected = 0; |
2374 | bool startgame = false; | 2383 | bool startgame = false; |
2375 | 2384 | ||
2376 | MENUITEM_STRINGLIST(menu,"Bubbles Menu",NULL, | 2385 | MENUITEM_STRINGLIST(menu,"Bubbles Menu",bubbles_menu_cb, |
2377 | "Resume Game", "Start New Game", | 2386 | "Resume Game", "Start New Game", |
2378 | "Level", "High Scores", "Playback Control", | 2387 | "Level", "High Scores", "Playback Control", |
2379 | "Quit without Saving", "Quit"); | 2388 | "Quit without Saving", "Quit"); |
@@ -2382,10 +2391,7 @@ static int bubbles_menu(struct game_context* bb) { | |||
2382 | switch (rb->do_menu(&menu, &selected, NULL, false)) | 2391 | switch (rb->do_menu(&menu, &selected, NULL, false)) |
2383 | { | 2392 | { |
2384 | case 0: /* resume game */ | 2393 | case 0: /* resume game */ |
2385 | if (!resume) | 2394 | startgame = true; |
2386 | rb->splash(HZ/2, "Nothing to resume"); | ||
2387 | else | ||
2388 | startgame = true; | ||
2389 | if(resume_file) | 2395 | if(resume_file) |
2390 | rb->remove(SAVE_FILE); | 2396 | rb->remove(SAVE_FILE); |
2391 | resume_file = false; | 2397 | resume_file = false; |
@@ -2411,7 +2417,10 @@ static int bubbles_menu(struct game_context* bb) { | |||
2411 | case 5: /* quit but don't save */ | 2417 | case 5: /* quit but don't save */ |
2412 | return BB_QUIT_WITHOUT_SAVING; | 2418 | return BB_QUIT_WITHOUT_SAVING; |
2413 | case 6: /* save and quit */ | 2419 | case 6: /* save and quit */ |
2414 | return BB_QUIT; | 2420 | if (resume) |
2421 | return BB_QUIT; | ||
2422 | else | ||
2423 | return BB_QUIT_WITHOUT_SAVING; | ||
2415 | case MENU_ATTACHED_USB: | 2424 | case MENU_ATTACHED_USB: |
2416 | bubbles_callback(bb); | 2425 | bubbles_callback(bb); |
2417 | return BB_USB; | 2426 | return BB_USB; |
@@ -2528,14 +2537,8 @@ enum plugin_status plugin_start(const void* parameter) { | |||
2528 | break; | 2537 | break; |
2529 | 2538 | ||
2530 | case BB_QUIT: | 2539 | case BB_QUIT: |
2531 | #define SAVE_MESSAGE "Saving Game and Scores..." | 2540 | rb->splash(HZ*1, "Saving game ..."); |
2532 | /* the first splash is to make sure it's read, but don't make it | ||
2533 | * too long to not delay the saving further */ | ||
2534 | rb->splash(HZ/5, SAVE_MESSAGE); | ||
2535 | rb->splash(0, SAVE_MESSAGE); | ||
2536 | bubbles_savegame(&bb); | 2541 | bubbles_savegame(&bb); |
2537 | bubbles_savedata(); | ||
2538 | highscore_save(SCORE_FILE, highscores, NUM_SCORES); | ||
2539 | /* fall through */ | 2542 | /* fall through */ |
2540 | 2543 | ||
2541 | case BB_QUIT_WITHOUT_SAVING: | 2544 | case BB_QUIT_WITHOUT_SAVING: |
@@ -2546,7 +2549,8 @@ enum plugin_status plugin_start(const void* parameter) { | |||
2546 | break; | 2549 | break; |
2547 | } | 2550 | } |
2548 | } | 2551 | } |
2549 | 2552 | bubbles_savedata(); | |
2553 | highscore_save(SCORE_FILE, highscores, NUM_SCORES); | ||
2550 | rb->lcd_setfont(FONT_UI); | 2554 | rb->lcd_setfont(FONT_UI); |
2551 | return ret; | 2555 | return ret; |
2552 | } | 2556 | } |