forked from len0rd/rockbox
Changed WPS enum conditional functionality, displaying the last part in the list if the tag has no value. Also added enum support for battery (5 steps) and volume (10 steps).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7476 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
fbaf503d0d
commit
ff73f0dcbf
2 changed files with 29 additions and 6 deletions
|
@ -617,7 +617,10 @@ static char* get_tag(struct mp3entry* cid3,
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case 'c': /* File Codec */
|
case 'c': /* File Codec */
|
||||||
*intval = id3->codectype;
|
if(id3->codectype == AFMT_UNKNOWN)
|
||||||
|
*intval = AFMT_NUM_CODECS;
|
||||||
|
else
|
||||||
|
*intval = id3->codectype;
|
||||||
return id3_get_codec(id3);
|
return id3_get_codec(id3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -697,6 +700,7 @@ static char* get_tag(struct mp3entry* cid3,
|
||||||
case 'v': /* volume */
|
case 'v': /* volume */
|
||||||
*flags |= WPS_REFRESH_DYNAMIC;
|
*flags |= WPS_REFRESH_DYNAMIC;
|
||||||
snprintf(buf, buf_size, "%d%%", global_settings.volume);
|
snprintf(buf, buf_size, "%d%%", global_settings.volume);
|
||||||
|
*intval = global_settings.volume / 10 + 1;
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -752,9 +756,15 @@ static char* get_tag(struct mp3entry* cid3,
|
||||||
{
|
{
|
||||||
int l = battery_level();
|
int l = battery_level();
|
||||||
if (l > -1)
|
if (l > -1)
|
||||||
|
{
|
||||||
snprintf(buf, buf_size, "%d%%", l);
|
snprintf(buf, buf_size, "%d%%", l);
|
||||||
|
*intval = l / 20 + 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
*intval = 6;
|
||||||
return "?%";
|
return "?%";
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,6 +867,7 @@ static const char* skip_conditional(const char* fmt, int num)
|
||||||
{
|
{
|
||||||
int level = 1;
|
int level = 1;
|
||||||
int count = num;
|
int count = num;
|
||||||
|
const char *last_alternative = NULL;
|
||||||
|
|
||||||
while (*fmt)
|
while (*fmt)
|
||||||
{
|
{
|
||||||
|
@ -867,6 +878,7 @@ static const char* skip_conditional(const char* fmt, int num)
|
||||||
|
|
||||||
case '|':
|
case '|':
|
||||||
if(1 == level) {
|
if(1 == level) {
|
||||||
|
last_alternative = fmt;
|
||||||
if(num) {
|
if(num) {
|
||||||
count--;
|
count--;
|
||||||
if(count == 0)
|
if(count == 0)
|
||||||
|
@ -879,10 +891,18 @@ static const char* skip_conditional(const char* fmt, int num)
|
||||||
case '>':
|
case '>':
|
||||||
if (0 == --level)
|
if (0 == --level)
|
||||||
{
|
{
|
||||||
if (num)
|
/* We're just skipping to the end */
|
||||||
fmt--;
|
if(num == 0)
|
||||||
|
return fmt;
|
||||||
|
|
||||||
return fmt;
|
/* If we are parsing an enum, we'll return the selected
|
||||||
|
item. If there weren't enough items in the enum, we'll
|
||||||
|
return the last one found. */
|
||||||
|
if(count && last_alternative)
|
||||||
|
{
|
||||||
|
return last_alternative;
|
||||||
|
}
|
||||||
|
return fmt - 1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1069,9 +1089,10 @@ static void format_display(char* buf,
|
||||||
if ('<' == *fmt)
|
if ('<' == *fmt)
|
||||||
fmt++;
|
fmt++;
|
||||||
|
|
||||||
/* No value, so skip to else part */
|
/* No value, so skip to else part, using a sufficiently high
|
||||||
|
value to "hit" the last part of the conditional */
|
||||||
if ((!value) || (!strlen(value)))
|
if ((!value) || (!strlen(value)))
|
||||||
fmt = skip_conditional(fmt, 1);
|
fmt = skip_conditional(fmt, 1000);
|
||||||
else
|
else
|
||||||
if(intval > 1) /* enum */
|
if(intval > 1) /* enum */
|
||||||
fmt = skip_conditional(fmt, intval - 1);
|
fmt = skip_conditional(fmt, intval - 1);
|
||||||
|
|
|
@ -40,6 +40,8 @@ enum {
|
||||||
AFMT_WAVPACK, /* WavPack */
|
AFMT_WAVPACK, /* WavPack */
|
||||||
|
|
||||||
/* New formats must be added to the end of this list */
|
/* New formats must be added to the end of this list */
|
||||||
|
|
||||||
|
AFMT_NUM_CODECS
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mp3entry {
|
struct mp3entry {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue