• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category User Interface → Themes
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Release 3.6
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by jdgordon - 2010-08-03
Last edited by jdgordon - 2010-08-19

FS#11516 - new skin tag... %if() allows you to have more control over conditionals

This patch adds a new tag which lets you have more control over conditionals.
%if( <tag>, <operator>, <value> [, num_options] ) ….
tag is a different token which you want to use (i.e %mp)
operator is any of: (without the quotes) “eq” for equality, “neq” for not equality, “lt” for less than. “lte” for less than or equal, “gt” for greater than” and “gte” for great than or equal. (If people would prefer I’m happy to change these to ==, !=, <, ⇐, >, >= )
value is the value to compare against.
num_options is an optional value to give to the tag to say how many options it “has” (some tags scale the value to the number of conditional options, i.e %pv)

OK, so how would you use this tag? Lets say you want to do a small animation when fast forwarding…
%?if( %mp, eq, 4)<%t(0.1)%xd(Aa);%t(0.1)%xd(Ab);%t(0.1)%xd(Ac);%t(0.1)%xd(Ad)>
and the opposite animation for rewind… %?if( %mp, eq, 5)<%t(0.1)%xd(Ad);%t(0.1)%xd(Ac);%t(0.1)%xd(Ab);%t(0.1)%xd(Aa)>

Compare that to:

Closed by  jdgordon
2010-08-19 13:55
Reason for closing:  Accepted
fg commented on 2010-08-03 12:47

Would this only work for numeric tags?

I wouldn’t mind seeing this in a slightly more general way, where value could also be a tag, and where string tags can be used. That would allow things like showing the next album/artist *only* if they’re different from the current one, which is something I’ve wanted to do a few times.

right now it is only numeric, and text tags are treated as 1 if there is text and 0 if not.
I was thinking that adding string comparisons would be fairly trivial. tag compare is slightly harder because the parser doesnt (yet) let you specify either a tag or a number param. but fixing that shuldnt be too hard.

To maintain some similitude with other programming languages, I suggest to avoid the three letter operator. So:

But, after all, ye old symbols are preferable… :-)

I’m hoping to do string and tag comparisson tonight so maybe I’ll just use the actual symbols (and I’ll use the numeric string sorting code so < and > for strings work.)

I wonder if there is any point adding a “between” operator also. I’m not sure it would ever be used but I thought %if( %if( %pv, gte, -10), eq, %if(%pv, lte, 10)) might be a bit hard to read? :D


Available keyboard shortcuts


Task Details

Task Editing