summaryrefslogtreecommitdiff
path: root/apps/plugins/jewels.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/jewels.c')
-rw-r--r--apps/plugins/jewels.c73
1 files changed, 8 insertions, 65 deletions
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index efec63f2cc..77c4030f61 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -408,7 +408,6 @@ struct puzzle_level puzzle_levels[NUM_PUZZLE_LEVELS] = {
408 408
409#define HIGH_SCORE PLUGIN_GAMES_DIR "/jewels.score" 409#define HIGH_SCORE PLUGIN_GAMES_DIR "/jewels.score"
410struct highscore highest[NUM_SCORES]; 410struct highscore highest[NUM_SCORES];
411bool highest_updated = false;
412 411
413 412
414/***************************************************************************** 413/*****************************************************************************
@@ -1249,55 +1248,6 @@ static void jewels_nextlevel(struct game_context* bj) {
1249 bj->score += points; 1248 bj->score += points;
1250} 1249}
1251 1250
1252static void jewels_show_highscores(int position)
1253{
1254 int i, w, h;
1255 char str[30];
1256
1257#ifdef HAVE_LCD_COLOR
1258 rb->lcd_set_background(LCD_BLACK);
1259 rb->lcd_set_foreground(LCD_WHITE);
1260#endif
1261 rb->button_clear_queue();
1262 rb->lcd_clear_display();
1263
1264 rb->lcd_setfont(FONT_UI);
1265 rb->lcd_getstringsize("High Scores", &w, &h);
1266 /* check wether it fits on screen */
1267 if ((4*h + h*(NUM_SCORES-1) + MARGIN) > LCD_HEIGHT) {
1268 rb->lcd_setfont(FONT_SYSFIXED);
1269 rb->lcd_getstringsize("High Scores", &w, &h);
1270 }
1271 rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores");
1272 rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score");
1273 rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level");
1274
1275 for (i = 0; i<NUM_SCORES; i++)
1276 {
1277#ifdef HAVE_LCD_COLOR
1278 if (i == position) {
1279 rb->lcd_set_foreground(LCD_RGBPACK(245,0,0));
1280 }
1281#endif
1282 rb->snprintf (str, sizeof (str), "%d)", i+1);
1283 rb->lcd_putsxy (MARGIN,3*h + h*i, str);
1284 rb->snprintf (str, sizeof (str), "%d", highest[i].score);
1285 rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str);
1286 rb->snprintf (str, sizeof (str), "%d", highest[i].level);
1287 rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str);
1288 if(i == position) {
1289#ifdef HAVE_LCD_COLOR
1290 rb->lcd_set_foreground(LCD_WHITE);
1291#else
1292 rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1));
1293#endif
1294 }
1295 }
1296 rb->lcd_update();
1297 rb->button_get(true);
1298 rb->lcd_setfont(FONT_SYSFIXED);
1299}
1300
1301static bool jewels_help(void) 1251static bool jewels_help(void)
1302{ 1252{
1303 rb->lcd_setfont(FONT_UI); 1253 rb->lcd_setfont(FONT_UI);
@@ -1395,7 +1345,7 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
1395 return 1; 1345 return 1;
1396 break; 1346 break;
1397 case 4: 1347 case 4:
1398 jewels_show_highscores(NUM_SCORES); 1348 highscore_show(NUM_SCORES, highest, NUM_SCORES);
1399 break; 1349 break;
1400 case 5: 1350 case 5:
1401 playback_control(NULL); 1351 playback_control(NULL);
@@ -1560,17 +1510,12 @@ static int jewels_main(struct game_context* bj) {
1560 rb->splash(HZ*2, "Game Over!"); 1510 rb->splash(HZ*2, "Game Over!");
1561 rb->lcd_clear_display(); 1511 rb->lcd_clear_display();
1562 bj->score += (bj->level-1)*LEVEL_PTS; 1512 bj->score += (bj->level-1)*LEVEL_PTS;
1563 if (highscore_would_update(bj->score, highest, 1513 position=highscore_update(bj->score, bj->level, "",
1564 NUM_SCORES)) { 1514 highest, NUM_SCORES);
1565 position=highscore_update(bj->score, 1515 if (position == 0)
1566 bj->level, "", 1516 rb->splash(HZ*2, "New High Score");
1567 highest,NUM_SCORES); 1517 if (position != -1)
1568 highest_updated = true; 1518 highscore_show(position, highest, NUM_SCORES);
1569 if (position == 0) {
1570 rb->splash(HZ*2, "New High Score");
1571 }
1572 jewels_show_highscores(position);
1573 }
1574 break; 1519 break;
1575 case GAME_TYPE_PUZZLE: 1520 case GAME_TYPE_PUZZLE:
1576 rb->splash(2*HZ, "Game Over"); 1521 rb->splash(2*HZ, "Game Over");
@@ -1590,7 +1535,6 @@ enum plugin_status plugin_start(const void* parameter)
1590 1535
1591 /* load high scores */ 1536 /* load high scores */
1592 highscore_load(HIGH_SCORE,highest,NUM_SCORES); 1537 highscore_load(HIGH_SCORE,highest,NUM_SCORES);
1593 highest_updated = false;
1594 1538
1595 rb->lcd_setfont(FONT_SYSFIXED); 1539 rb->lcd_setfont(FONT_SYSFIXED);
1596#if LCD_DEPTH > 1 1540#if LCD_DEPTH > 1
@@ -1600,8 +1544,7 @@ enum plugin_status plugin_start(const void* parameter)
1600 struct game_context bj; 1544 struct game_context bj;
1601 bj.tmp_type = GAME_TYPE_NORMAL; 1545 bj.tmp_type = GAME_TYPE_NORMAL;
1602 jewels_main(&bj); 1546 jewels_main(&bj);
1603 if(highest_updated) 1547 highscore_save(HIGH_SCORE,highest,NUM_SCORES);
1604 highscore_save(HIGH_SCORE,highest,NUM_SCORES);
1605 rb->lcd_setfont(FONT_UI); 1548 rb->lcd_setfont(FONT_UI);
1606 1549
1607 return PLUGIN_OK; 1550 return PLUGIN_OK;