Index: apps/plugins/clix.c =================================================================== --- apps/plugins/clix.c (Revision 21906) +++ apps/plugins/clix.c (Arbeitskopie) @@ -231,56 +231,6 @@ CC_DARK_GREEN }; -/* display the highscore list and highlight the last one */ -static void clix_show_highscores(int position) -{ - int i, w, h; - char str[30]; - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); -#endif - rb->button_clear_queue(); - rb->lcd_clear_display(); - - rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("High Scores", &w, &h); - /* check wether it fits on screen */ - if ((4*h + h*(NUM_SCORES-1) + MARGIN) > LCD_HEIGHT) { - rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("High Scores", &w, &h); - } - rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores"); - rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score"); - rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level"); - - for (i = 0; ilcd_set_foreground(LCD_RGBPACK(245,0,0)); - } -#endif - rb->snprintf (str, sizeof (str), "%d)", i+1); - rb->lcd_putsxy (MARGIN,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", highest[i].score); - rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", highest[i].level); - rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str); - if(i == position) { -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1)); -#endif - } - } - rb->lcd_update(); - rb->button_get(true); - rb->lcd_setfont(FONT_SYSFIXED); -} - /* recursive function to check if a neighbour cell is of the same color if so call the function with the neighbours position */ @@ -660,7 +610,7 @@ return 1; break; case 3: - clix_show_highscores(NUM_SCORES); + show_highscores(NUM_SCORES, highest, NUM_SCORES); break; case 4: playback_control(NULL); @@ -805,16 +755,14 @@ clix_draw( state); rb->splash(HZ*2, "Game Over!"); rb->lcd_clear_display(); - if (highscore_would_update(state->score, - highest, NUM_SCORES)) { - position=highscore_update(state->score, - state->level, "", - highest,NUM_SCORES); - if (position == 0) { - rb->splash(HZ*2, "New High Score"); - } - clix_show_highscores(position); - } + position=highscore_update(state->score, + state->level, "", + highest,NUM_SCORES); + if (position == 0) + rb->splash(HZ*2, "New High Score"); + if (position != -1) + show_highscores(position, highest, + NUM_SCORES); if (clix_menu(state, 0)) return 1; break; Index: apps/plugins/jewels.c =================================================================== --- apps/plugins/jewels.c (Revision 21906) +++ apps/plugins/jewels.c (Arbeitskopie) @@ -472,7 +472,6 @@ #define HIGH_SCORE PLUGIN_GAMES_DIR "/jewels.score" struct highscore highest[NUM_SCORES]; -bool highest_updated = false; /***************************************************************************** @@ -1313,55 +1312,6 @@ bj->score += points; } -static void jewels_show_highscores(int position) -{ - int i, w, h; - char str[30]; - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); -#endif - rb->button_clear_queue(); - rb->lcd_clear_display(); - - rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("High Scores", &w, &h); - /* check wether it fits on screen */ - if ((4*h + h*(NUM_SCORES-1) + MARGIN) > LCD_HEIGHT) { - rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("High Scores", &w, &h); - } - rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores"); - rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score"); - rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level"); - - for (i = 0; ilcd_set_foreground(LCD_RGBPACK(245,0,0)); - } -#endif - rb->snprintf (str, sizeof (str), "%d)", i+1); - rb->lcd_putsxy (MARGIN,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", highest[i].score); - rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", highest[i].level); - rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str); - if(i == position) { -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1)); -#endif - } - } - rb->lcd_update(); - rb->button_get(true); - rb->lcd_setfont(FONT_SYSFIXED); -} - static bool jewels_help(void) { rb->lcd_setfont(FONT_UI); @@ -1459,7 +1409,7 @@ return 1; break; case 4: - jewels_show_highscores(NUM_SCORES); + show_highscores(NUM_SCORES, highest, NUM_SCORES); break; case 5: playback_control(NULL); @@ -1624,17 +1574,12 @@ rb->splash(HZ*2, "Game Over!"); rb->lcd_clear_display(); bj->score += (bj->level-1)*LEVEL_PTS; - if (highscore_would_update(bj->score, highest, - NUM_SCORES)) { - position=highscore_update(bj->score, - bj->level, "", - highest,NUM_SCORES); - highest_updated = true; - if (position == 0) { - rb->splash(HZ*2, "New High Score"); - } - jewels_show_highscores(position); - } + position=highscore_update(bj->score, bj->level, "", + highest, NUM_SCORES); + if (position == 0) + rb->splash(HZ*2, "New High Score"); + if (position != -1) + show_highscores(position, highest, NUM_SCORES); break; case GAME_TYPE_PUZZLE: rb->splash(2*HZ, "Game Over"); @@ -1654,7 +1599,6 @@ /* load high scores */ highscore_load(HIGH_SCORE,highest,NUM_SCORES); - highest_updated = false; rb->lcd_setfont(FONT_SYSFIXED); #if LCD_DEPTH > 1 @@ -1664,8 +1608,7 @@ struct game_context bj; bj.tmp_type = GAME_TYPE_NORMAL; jewels_main(&bj); - if(highest_updated) - highscore_save(HIGH_SCORE,highest,NUM_SCORES); + highscore_save(HIGH_SCORE,highest,NUM_SCORES); rb->lcd_setfont(FONT_UI); return PLUGIN_OK; Index: apps/plugins/bubbles.c =================================================================== --- apps/plugins/bubbles.c (Revision 21906) +++ apps/plugins/bubbles.c (Arbeitskopie) @@ -1240,7 +1240,6 @@ * elapsedshot is the shot elapsed time in 1/100s of seconds * startedshot is when the current shot began * resume denotes whether to resume the currently loaded game - * dirty denotes whether the high scores are out of sync with the saved file * playboard is the game playing board */ struct game_context { @@ -1259,7 +1258,6 @@ long elapsedshot; long startedshot; bool resume; - bool dirty; struct tile playboard[BB_HEIGHT][BB_WIDTH]; }; @@ -1277,7 +1275,6 @@ static int bubbles_fall(struct game_context* bb); static int bubbles_checklevel(struct game_context* bb); static void bubbles_recordscore(struct game_context* bb); -static void bubbles_displayscores(struct game_context* bb, int position); static void bubbles_savescores(struct game_context* bb); static bool bubbles_loadgame(struct game_context* bb); static void bubbles_savegame(struct game_context* bb); @@ -1291,6 +1288,7 @@ * bubbles_init() initializes bubbles data structures. ******************************************************************************/ static void bubbles_init(struct game_context* bb) { + bubbles_setcolors(); /* seed the rand generator */ rb->srand(*rb->current_tick); @@ -2118,15 +2116,12 @@ int position; - if (highscore_would_update(bb->score, bb->highscores, NUM_SCORES)) { - bb->dirty = true; - position = highscore_update(bb->score, bb->level, "", - bb->highscores, NUM_SCORES); - if (position==0) { - rb->splash(HZ*2, "New High Score"); - } - bubbles_displayscores(bb, position); - } + position = highscore_update(bb->score, bb->level, "", + bb->highscores, NUM_SCORES); + if (position==0) + rb->splash(HZ*2, "New High Score"); + if (position != -1) + show_highscores(position, &bb->highlevel, NUM_SCORES); } /***************************************************************************** @@ -2134,8 +2129,6 @@ ******************************************************************************/ static void bubbles_loadscores(struct game_context* bb) { - bb->dirty = false; - /* highlevel and highscores */ highscore_load(SCORE_FILE, &bb->highlevel, NUM_SCORES+1); @@ -2150,63 +2143,9 @@ /* highlevel and highscores */ highscore_save(SCORE_FILE, &bb->highlevel, NUM_SCORES+1); - bb->dirty = false; } /***************************************************************************** -* bubbles_displayscores() displays the high scores -******************************************************************************/ -#define MARGIN 5 -static void bubbles_displayscores(struct game_context* bb, int position) { - int i, w, h; - char str[30]; - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); -#endif - rb->button_clear_queue(); - rb->lcd_clear_display(); - - rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("High Scores", &w, &h); - /* check wether it fits on screen */ - if ((4*h + h*(NUM_SCORES-1) + MARGIN) > LCD_HEIGHT) { - rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_getstringsize("High Scores", &w, &h); - } - rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores"); - rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score"); - rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level"); - - for (i = 0; ilcd_set_foreground(LCD_RGBPACK(245,0,0)); - } -#endif - rb->snprintf (str, sizeof (str), "%d)", i+1); - rb->lcd_putsxy (MARGIN,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", bb->highscores[i].score); - rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str); - rb->snprintf (str, sizeof (str), "%d", bb->highscores[i].level); - rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str); - if(i == position) { -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1)-1); -#endif - } - } - rb->lcd_update(); - rb->button_get(true); - rb->lcd_setfont(FONT_SYSFIXED); - bubbles_setcolors(); -} - -/***************************************************************************** * bubbles_loadgame() loads the saved game and returns load success. ******************************************************************************/ static bool bubbles_loadgame(struct game_context* bb) { @@ -2282,10 +2221,7 @@ ******************************************************************************/ static void bubbles_callback(void* param) { struct game_context* bb = (struct game_context*) param; - if(bb->dirty) { - rb->splash(HZ/2, "Saving high scores..."); - bubbles_savescores(bb); - } + bubbles_savescores(bb); } /***************************************************************************** @@ -2381,8 +2317,6 @@ bool startgame = false; long timeout; - bubbles_setcolors(); - /* don't resume by default */ bb->resume = false; @@ -2414,7 +2348,7 @@ startlevel--; break; case 3: /* High scores */ - bubbles_displayscores(bb, 0); + show_highscores(NUM_SCORES, &bb->highlevel, NUM_SCORES); break; case 4: /* Playback Control */ playback_control(NULL); @@ -2499,7 +2433,6 @@ /* record high level */ if( NUM_LEVELS-1 > bb.highlevel.level) { bb.highlevel.level = NUM_LEVELS-1; - bb.dirty = true; } /* record high score */ bubbles_recordscore(&bb); @@ -2514,7 +2447,6 @@ /* record high level */ if((int)bb.level-1 > bb.highlevel.level) { bb.highlevel.level = bb.level-1; - bb.dirty = true; } /* record high score */ bubbles_recordscore(&bb); @@ -2526,10 +2458,7 @@ return PLUGIN_USB_CONNECTED; case BB_QUIT: - if(bb.dirty) { - rb->splash(HZ/2, "Saving high scores..."); - bubbles_savescores(&bb); - } + bubbles_savescores(&bb); exit = true; break;