forked from len0rd/rockbox
plugin: implement highscore_show for player and use it in rockblox.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24861 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
adf5bbdc46
commit
c1bb06c3af
3 changed files with 49 additions and 18 deletions
|
@ -120,12 +120,15 @@ bool highscore_would_update(int score, struct highscore *scores,
|
|||
}
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
void highscore_show(int position, struct highscore *scores, int num_scores, bool show_level)
|
||||
#define MARGIN 5
|
||||
void highscore_show(int position, struct highscore *scores, int num_scores,
|
||||
bool show_level)
|
||||
{
|
||||
int i, w, h;
|
||||
char str[30];
|
||||
#define MARGIN 5
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
unsigned bgcolor = rb->lcd_get_background();
|
||||
unsigned fgcolor = rb->lcd_get_foreground();
|
||||
rb->lcd_set_background(LCD_BLACK);
|
||||
rb->lcd_set_foreground(LCD_WHITE);
|
||||
#endif
|
||||
|
@ -141,7 +144,6 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
|
|||
rb->lcd_putsxy(LCD_WIDTH/2-w/2, MARGIN, "High Scores");
|
||||
rb->lcd_putsxy(LCD_WIDTH/4-w/4,2*h, "Score");
|
||||
|
||||
/* Decide whether to display the level column or not */
|
||||
if(show_level) {
|
||||
rb->lcd_putsxy(LCD_WIDTH*3/4-w/4,2*h, "Level");
|
||||
}
|
||||
|
@ -158,7 +160,6 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
|
|||
rb->snprintf (str, sizeof (str), "%d", scores[i].score);
|
||||
rb->lcd_putsxy (LCD_WIDTH/4-w/4,3*h + h*i, str);
|
||||
|
||||
/* Decide whether to display the level column or not */
|
||||
if(show_level) {
|
||||
rb->snprintf (str, sizeof (str), "%d", scores[i].level);
|
||||
rb->lcd_putsxy (LCD_WIDTH*3/4-w/4,3*h + h*i, str);
|
||||
|
@ -168,7 +169,7 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
|
|||
#ifdef HAVE_LCD_COLOR
|
||||
rb->lcd_set_foreground(LCD_WHITE);
|
||||
#else
|
||||
rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN, 3*h + h*(i+1));
|
||||
rb->lcd_hline(MARGIN, LCD_WIDTH-MARGIN*2, 3*h + h*(i+1) - 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -177,5 +178,42 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
|
|||
rb->button_clear_queue();
|
||||
rb->button_get(true);
|
||||
rb->lcd_setfont(FONT_SYSFIXED);
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
rb->lcd_set_background(bgcolor);
|
||||
rb->lcd_set_foreground(fgcolor);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
struct scoreinfo {
|
||||
struct highscore *scores;
|
||||
int position;
|
||||
bool show_level;
|
||||
};
|
||||
static const char* get_score(int selected, void * data,
|
||||
char * buffer, size_t buffer_len)
|
||||
{
|
||||
struct scoreinfo *scoreinfo = (struct scoreinfo *) data;
|
||||
int len;
|
||||
len = rb->snprintf(buffer, buffer_len, "%c%d) %4d",
|
||||
(scoreinfo->position == selected?'*':' '),
|
||||
selected+1, scoreinfo->scores[selected].score);
|
||||
|
||||
if (scoreinfo->show_level)
|
||||
rb->snprintf(buffer + len, buffer_len - len, " %d",
|
||||
scoreinfo->scores[selected].level);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void highscore_show(int position, struct highscore *scores, int num_scores,
|
||||
bool show_level)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
struct scoreinfo scoreinfo = {scores, position, show_level};
|
||||
rb->simplelist_info_init(&info, "High Scores", num_scores, &scoreinfo);
|
||||
if (position >= 0)
|
||||
info.selection = position;
|
||||
info.hide_selection = true;
|
||||
info.get_name = get_score;
|
||||
rb->simplelist_show_list(&info);
|
||||
}
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue