From 29407cbe801bfdfbe59ad0e40be8fc8ced4ac778 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Wed, 25 Jul 2007 14:14:47 +0000 Subject: [PATCH] Implement feature request FS#7476: Add a "song progress percentage" WPS tag (%px) that can be used in a conditional to create custom progress meters. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13987 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 8 ++++++++ apps/gui/gwps.h | 1 + apps/gui/wps_debug.c | 4 ++++ apps/gui/wps_parser.c | 1 + manual/appendix/wps_tags.tex | 1 + 5 files changed, 15 insertions(+) diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index e5f0e882e8..62d710af54 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -848,6 +848,14 @@ static char *get_token_value(struct gui_wps *gwps, } return buf; + case WPS_TOKEN_TRACK_ELAPSED_PERCENT: + if (intval) + { + *intval = limit * (id3->elapsed + state->ff_rewind_count) / id3->length + 1; + } + snprintf(buf, buf_size, "%d", 100*(id3->elapsed + state->ff_rewind_count) / id3->length); + return buf; + case WPS_TOKEN_METADATA_ARTIST: return id3->artist; diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index cfa7e70714..371b2b0399 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h @@ -222,6 +222,7 @@ enum wps_token_type { WPS_TOKEN_VOLUME, /* Current track */ + WPS_TOKEN_TRACK_ELAPSED_PERCENT, WPS_TOKEN_TRACK_TIME_ELAPSED, WPS_TOKEN_TRACK_TIME_REMAINING, WPS_TOKEN_TRACK_LENGTH, diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index 317e73cf2a..0f40a57801 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c @@ -242,6 +242,10 @@ static void dump_wps_tokens(struct wps_data *data) snprintf(buf, sizeof(buf), "time elapsed in track"); break; + case WPS_TOKEN_TRACK_ELAPSED_PERCENT: + snprintf(buf, sizeof(buf), "played percentage of track"); + break; + case WPS_TOKEN_PLAYLIST_ENTRIES: snprintf(buf, sizeof(buf), "number of entries in playlist"); break; diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 43ea516b53..86b74129f2 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -247,6 +247,7 @@ static const struct wps_tag all_tags[] = { { WPS_TOKEN_VOLUME, "pv", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_TRACK_ELAPSED_PERCENT, "px", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_TRACK_TIME_ELAPSED, "pc", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_TRACK_TIME_REMAINING, "pr", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_TRACK_LENGTH, "pt", WPS_REFRESH_STATIC, NULL }, diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 805a61f3ac..af4018df50 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -89,6 +89,7 @@ Example for the \config{\%dN} commands: If the path is \opt{player}{% \config{\%pf} & Full-line progress bar \& time display\\ }% + \config{\%px} & Percentage Played In Song\\ \config{\%pc} & Current Time In Song\\ \config{\%pe} & Total Number of Playlist Entries\\ \nopt{player}{%