Player: Credits plugin correctly working with UTF-8. Patch by Marcoen Hirschberg.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9862 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2006-05-02 21:44:04 +00:00
parent 982d995ae9
commit 93ff94949c
3 changed files with 8 additions and 5 deletions

View file

@ -438,6 +438,7 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_LCD_BITMAP
lcd_setmargins,
#endif
utf8seek,
};
int plugin_load(const char* plugin, void* parameter)

View file

@ -103,7 +103,7 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 19
#define PLUGIN_API_VERSION 20
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
@ -514,6 +514,7 @@ struct plugin_api {
#ifdef HAVE_LCD_BITMAP
void (*lcd_setmargins)(int x, int y);
#endif
int (*utf8seek)(const unsigned char* utf8, int offset);
};
/* plugin header */

View file

@ -58,7 +58,7 @@ void roll_credits(void)
{
int numnames = sizeof(credits)/sizeof(char*);
int curr_name = 0;
int curr_len = rb->strlen(credits[0]);
int curr_len = rb->utf8length(credits[0]);
int curr_index = 0;
int curr_line = 0;
int name, len, new_len, line, x;
@ -77,19 +77,20 @@ void roll_credits(void)
int x2;
if (x < 0)
rb->lcd_puts(0, line, credits[name] - x);
rb->lcd_puts(0, line, credits[name] + rb->utf8seek(credits[name], -x));
else
rb->lcd_puts(x, line, credits[name]);
if (++name >= numnames)
break;
line ^= 1;
x2 = x + len/2;
if ((unsigned)x2 < 11)
rb->lcd_putc(x2, line, '*');
new_len = rb->strlen(credits[name]);
new_len = rb->utf8length(credits[name]);
x += MAX(len/2 + 2, len - new_len/2 + 1);
len = new_len;
}
@ -101,7 +102,7 @@ void roll_credits(void)
{
if (++curr_name >= numnames)
break;
new_len = rb->strlen(credits[curr_name]);
new_len = rb->utf8length(credits[curr_name]);
curr_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1);
curr_len = new_len;
curr_line ^= 1;