forked from len0rd/rockbox
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:
parent
982d995ae9
commit
93ff94949c
3 changed files with 8 additions and 5 deletions
|
|
@ -438,6 +438,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
lcd_setmargins,
|
lcd_setmargins,
|
||||||
#endif
|
#endif
|
||||||
|
utf8seek,
|
||||||
};
|
};
|
||||||
|
|
||||||
int plugin_load(const char* plugin, void* parameter)
|
int plugin_load(const char* plugin, void* parameter)
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* 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
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
|
|
@ -514,6 +514,7 @@ struct plugin_api {
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
void (*lcd_setmargins)(int x, int y);
|
void (*lcd_setmargins)(int x, int y);
|
||||||
#endif
|
#endif
|
||||||
|
int (*utf8seek)(const unsigned char* utf8, int offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* plugin header */
|
/* plugin header */
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ void roll_credits(void)
|
||||||
{
|
{
|
||||||
int numnames = sizeof(credits)/sizeof(char*);
|
int numnames = sizeof(credits)/sizeof(char*);
|
||||||
int curr_name = 0;
|
int curr_name = 0;
|
||||||
int curr_len = rb->strlen(credits[0]);
|
int curr_len = rb->utf8length(credits[0]);
|
||||||
int curr_index = 0;
|
int curr_index = 0;
|
||||||
int curr_line = 0;
|
int curr_line = 0;
|
||||||
int name, len, new_len, line, x;
|
int name, len, new_len, line, x;
|
||||||
|
|
@ -77,19 +77,20 @@ void roll_credits(void)
|
||||||
int x2;
|
int x2;
|
||||||
|
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
rb->lcd_puts(0, line, credits[name] - x);
|
rb->lcd_puts(0, line, credits[name] + rb->utf8seek(credits[name], -x));
|
||||||
else
|
else
|
||||||
rb->lcd_puts(x, line, credits[name]);
|
rb->lcd_puts(x, line, credits[name]);
|
||||||
|
|
||||||
if (++name >= numnames)
|
if (++name >= numnames)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
line ^= 1;
|
line ^= 1;
|
||||||
|
|
||||||
x2 = x + len/2;
|
x2 = x + len/2;
|
||||||
if ((unsigned)x2 < 11)
|
if ((unsigned)x2 < 11)
|
||||||
rb->lcd_putc(x2, line, '*');
|
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);
|
x += MAX(len/2 + 2, len - new_len/2 + 1);
|
||||||
len = new_len;
|
len = new_len;
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +102,7 @@ void roll_credits(void)
|
||||||
{
|
{
|
||||||
if (++curr_name >= numnames)
|
if (++curr_name >= numnames)
|
||||||
break;
|
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_index -= MAX(curr_len/2 + 2, curr_len - new_len/2 + 1);
|
||||||
curr_len = new_len;
|
curr_len = new_len;
|
||||||
curr_line ^= 1;
|
curr_line ^= 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue