Skin Variables / Conditional Labels
#1
It was often mentioned - now it's about time to get it done.

This is now just discussion - it's not done yet

Skin variables are meant to get rid of multiples controls differing only by value of <texture> / <label> depending on <visible> condition.
Good example of its use are media flags (I'll use video type based on filename - bluray / hddvd / dvd / tv / vhs):

Currently this is done:
Code:
<include name="VideoTypeHackFlaggingConditions">
    <control type="image">
        <description>Bluray Image</description>
        <width>80</width>
        <height>35</height>
        <aspectratio align="left">keep</aspectratio>
        <texture>flagging/video/bluray.png</texture>
        <visible>[substring(ListItem.FilenameAndPath,bluray) | substring(ListItem.FilenameAndPath,bdrip)] + !Skin.HasSetting(HideFilenameFlagging)</visible>
    </control>
    <control type="image">
        <description>HDDVD Image</description>
        <width>80</width>
        <height>35</height>
        <aspectratio align="left">keep</aspectratio>
        <texture>flagging/video/hddvd.png</texture>
        <visible>substring(ListItem.FilenameAndPath,hddvd) + !Skin.HasSetting(HideFilenameFlagging)</visible>
    </control>
    <control type="image">
        <description>DVD Image</description>
        <width>80</width>
        <height>35</height>
        <aspectratio align="left">keep</aspectratio>
        <texture>flagging/video/dvd.png</texture>
        <visible>[substring(ListItem.FilenameAndPath,dvd) + ![substring(ListItem.FilenameAndPath,hddvd) | substring(ListItem.FilenameAndPath,bluray) | substring(ListItem.FilenameAndPath,bdrip)]] + !Skin.HasSetting(HideFilenameFlagging)</visible>
    </control>
    <control type="image">
        <description>TV Types Image</description>
        <width>80</width>
        <height>35</height>
        <aspectratio align="left">keep</aspectratio>
        <texture>flagging/video/TV.png</texture>
        <visible>[substring(ListItem.FilenameAndPath,pdtv) | substring(ListItem.FilenameAndPath,hdtv) | substring(ListItem.FilenameAndPath,dsr)] + !Skin.HasSetting(HideFilenameFlagging)</visible>
    </control>
    <control type="image">
        <description>VHS Image</description>
        <width>80</width>
        <height>35</height>
        <aspectratio align="left">keep</aspectratio>
        <texture>flagging/video/vhs.png</texture>
        <visible>substring(ListItem.FilenameAndPath,vhs) + !Skin.HasSetting(HideFilenameFlagging)</visible>
    </control>
</include>

With skin variables it could be:

Code:
<variable name="filename_video_type">
    <value condition="substring(ListItem.FilenameAndPath,bluray) | substring(ListItem.FilenameAndPath,bdrip)">bluray</value>
    <value condition="substring(ListItem.FilenameAndPath,hddvd)">hddvd</value>
    <value condition="substring(ListItem.FilenameAndPath,dvd)">dvd</value>
    <value condition="substring(ListItem.FilenameAndPath,pdtv) | substring(ListItem.FilenameAndPath,hdtv) | substring(ListItem.FilenameAndPath,dsr)">TV</value>
    <value condition="substring(ListItem.FilenameAndPath,vhs)">vhs</value>
</variable>

-- note difference with "dvd" checking: in variables condition I don't check against "hddvd" because if path would contain "hddvd" previous condition would be met and variable would already have value hddvd (and further checking would be aborted)

and then single image control with

Code:
<control type="image">
    <description>Video type image</description>
    <width>80</width>
    <height>35</height>
    <aspectratio align="left">keep</aspectratio>
    <texture>$VAR[filename_video_type,flagging/video/,.png]</texture>
    <!-- alternatively You could omit $VAR and use <texture>filename_video_type</texture> (along with slightly changed variable values) -->
    <visible>!Skin.HasSetting(HideFilenameFlagging)</visible>
</control>

Of course variables could contain $INFO[] or any ether element normal label / texture could have.

Skin variables could be contained in variables.xml

Code:
<variables>
  <variable name="x">
    <value="foo">bar</value>
    <value>default</value> <!-- if default not set then default value would be empty "" -->
  </variable>
</variables>

Do You have ideas how to make it better? Let's start discussion.
Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

My previous forum/trac nickname: grajen3
Reply


Messages In This Thread
Skin Variables / Conditional Labels - by pieh - 2011-08-15, 01:34
[No subject] - by wyrm - 2011-08-15, 04:08
[No subject] - by jmarshall - 2011-08-15, 08:19
[No subject] - by wyrm - 2011-08-15, 08:31
[No subject] - by Hitcher - 2011-08-15, 08:49
[No subject] - by wyrm - 2011-08-15, 09:11
[No subject] - by wyrm - 2011-08-15, 09:47
[No subject] - by pieh - 2011-08-15, 10:17
[No subject] - by pieh - 2011-08-15, 11:13
[No subject] - by wyrm - 2011-08-16, 03:50
[No subject] - by pieh - 2011-08-16, 07:36
[No subject] - by Jezz_X - 2011-08-16, 07:43
[No subject] - by pieh - 2011-08-16, 07:57
[No subject] - by jmarshall - 2011-08-17, 00:51
[No subject] - by wyrm - 2011-08-17, 04:49
[No subject] - by pieh - 2011-08-17, 08:23
[No subject] - by pieh - 2011-08-17, 10:41
[No subject] - by Jezz_X - 2011-08-17, 11:48
[No subject] - by topfs2 - 2011-08-17, 12:17
[No subject] - by pieh - 2011-08-17, 12:47
[No subject] - by wyrm - 2011-08-17, 17:07
[No subject] - by pieh - 2011-08-17, 20:45
[No subject] - by jmarshall - 2011-08-18, 00:23
[No subject] - by wyrm - 2011-08-18, 03:34
[No subject] - by pieh - 2011-08-18, 07:22
[No subject] - by Jezz_X - 2011-08-18, 07:54
[No subject] - by Jezz_X - 2011-08-18, 08:01
[No subject] - by Jezz_X - 2011-08-18, 08:16
[No subject] - by pieh - 2011-08-18, 08:39
[No subject] - by jmarshall - 2011-08-18, 12:32
[No subject] - by pieh - 2011-08-18, 13:02
[No subject] - by wyrm - 2011-08-18, 15:59
[No subject] - by pieh - 2011-08-18, 17:39
[No subject] - by thedeadman - 2011-08-22, 11:20
[No subject] - by pieh - 2011-08-22, 11:36
[No subject] - by thedeadman - 2011-08-22, 19:15
[No subject] - by pieh - 2011-08-25, 13:25
[No subject] - by `Black - 2011-08-25, 13:41
[No subject] - by topfs2 - 2011-08-25, 15:12
[No subject] - by Jeroen - 2011-08-27, 12:04
[No subject] - by pieh - 2011-08-27, 12:37
RE: - by Jezz_X - 2012-09-08, 04:08
[No subject] - by Jeroen - 2011-08-27, 16:59
[No subject] - by Hitcher - 2011-09-30, 18:18
[No subject] - by Jeroen - 2011-09-30, 18:59
[No subject] - by `Black - 2011-09-30, 19:21
[No subject] - by Jeroen - 2011-09-30, 21:22
[No subject] - by `Black - 2011-09-30, 22:22
[No subject] - by Jeroen - 2011-09-30, 22:33
[No subject] - by `Black - 2011-10-01, 00:23
[No subject] - by BigNoid - 2011-10-01, 00:45
[No subject] - by `Black - 2011-10-01, 00:55
[No subject] - by BigNoid - 2011-10-01, 10:06
[No subject] - by Hitcher - 2011-10-01, 10:17
[No subject] - by pieh - 2011-10-01, 12:53
[No subject] - by BigNoid - 2011-10-01, 13:18
[No subject] - by Jeroen - 2011-10-01, 14:18
[No subject] - by Jeroen - 2011-10-01, 16:17
[No subject] - by Hitcher - 2011-10-01, 16:37
[No subject] - by pieh - 2011-10-01, 16:43
[No subject] - by Jeroen - 2011-10-01, 17:33
[No subject] - by ronie - 2011-10-01, 19:25
[No subject] - by pieh - 2011-10-02, 09:04
[No subject] - by `Black - 2011-10-02, 15:14
[No subject] - by ronie - 2011-10-02, 15:58
[No subject] - by Jeroen - 2011-10-02, 16:50
[No subject] - by Jeroen - 2011-10-02, 17:13
[No subject] - by BigNoid - 2011-10-02, 17:50
[No subject] - by `Black - 2011-10-03, 21:52
[No subject] - by pieh - 2011-10-06, 12:44
[No subject] - by `Black - 2011-10-06, 12:59
[No subject] - by pieh - 2011-10-06, 14:27
[No subject] - by `Black - 2011-10-06, 14:59
[No subject] - by pieh - 2011-10-06, 16:01
[No subject] - by pieh - 2011-10-07, 13:57
[No subject] - by `Black - 2011-10-07, 14:34
[No subject] - by pieh - 2011-10-18, 12:59
[No subject] - by `Black - 2011-10-18, 13:53
[No subject] - by BigNoid - 2011-10-19, 17:57
[No subject] - by `Black - 2011-10-19, 18:29
[No subject] - by pieh - 2011-10-20, 08:46
[No subject] - by BigNoid - 2011-10-20, 12:32
[No subject] - by pecinko - 2011-10-22, 16:18
Logout Mark Read Team Forum Stats Members Help
Skin Variables / Conditional Labels0