Solved Conditional <colordiffuse> of Icons in DialogKaiToast.xml
#1
I've been trying to add a conditional <colordiffuse> tag to the icon image (the built-in control id=400) in DialogKaiToast.xml for some time now. But I just haven't been able to get it to work, no matter what I try.

Specifically, I'm just wanting to <colordiffuse> 3 icons (should they be the ones shown): DialogIconError, DialogIconWarning, and DialogIconInfo.

I first tried adding a conditional to the colordiffuse tag, but that didn't work, and to be honest I'm not even sure if that's even a real thing

Then I tried using variables like so:

In DialogKaiToast.xml I had:

PHP Code:
<control type="image" id="400">
        <
description>Icon</description>
        <
posx>10</posx>
        <
posy>10</posy>
        <
width>60</width>
        <
height>60</height>
        <
aspectratio>keep</aspectratio>
        <
colordiffuse>$VAR[NotificationIconColor]</colordiffuse>
    </
control

And in Includes_Variables.xml I had:

PHP Code:
<variable name="NotificationIconColor">
        <
value condition="SubString(ListItem.Icon,Error) | SubString(ListItem.Icon,Info) | SubString(ListItem.Icon,Warning)">AccentColor</value>
        <
value condition="!SubString(ListItem.Icon,Error) + !SubString(ListItem.Icon,Info) + !SubString(ListItem.Icon,Warning)">-</value>
    </
variable

But this caused no icon to appear at all, regardless of if it was one of the three I intended to exclude. I figured that meant it had something to do with my conditional, so I tried this to test it out

PHP Code:
<variable name="NotificationIconColor">
        <
value condition="SubString(ListItem.Icon,Default)">AccentColor</value>
        <
value condition="!SubString(ListItem.Icon,Default)">-</value>
    </
variable

But I got the same result as I did when using the previous variables.
Thinking it might be the dash in the second value string, I changed that one to:
PHP Code:
<value condition="!SubString(ListItem.Icon,Default)">00000000</value
But that didn't work for me either.

I also tried using a conditional <include> in place of the colordiffuse tag, but I didn't have any luck with that either.

I'm sure this is another dumb mistake, but any help would be appreciated. Thank you in advance!
Reply
#2
P.s. I saw here (or at least I think I did) http://forum.kodi.tv/showthread.php?tid=107734&page=6 that variables can be used in <colordiffuse>, so that's why I figured it was worth asking.
Reply
#3
What if is using a AARRGGBB Color ? like FF00AAFF in value for example ?

Edit : Also not sure ListItem.Label is relevant here as a built in control. What if replacing it by Control.GetLabel(400) ?
[Skin] KOver - V1.1.0 Stable (Repo version)
[WIP] ReKOver - Skinning tool project

If I've been helpful or you like my work, hit "THANK USER" button ;) ...
Reply
#4
You can drop the second condition if its just an invert of the first (the variable will stop if it has a match). Also by setting the colortag to 00000000 you make the image invisible. If you want the image to be unaltered, use FFFFFFFF.
Reply
#5
(2015-10-16, 20:10)BigNoid Wrote: You can drop the second condition if its just an invert of the first (the variable will stop if it has a match). Also by setting the colortag to 00000000 you make the image invisible. If you want the image to be unaltered, use FFFFFFFF.

BigNoid, thanks for taking the time out to reply. I remember a while back when I first tried this, I had something similar to your suggestion.

Variables:
PHP Code:
<variable name="NotificationIconColor">
        <
value condition="SubString(ListItem.Icon,Error) | SubString(ListItem.Icon,Info) | SubString(ListItem.Icon,Warning)">AccentColor</value>
        <
value>FFFFFFFF</value>
    </
variable

DialogKaiToast.xml
PHP Code:
<control type="image" id="400">
        <
description>Icon</description>
        <
posx>10</posx>
        <
posy>10</posy>
        <
width>60</width>
        <
height>60</height>
        <
aspectratio>keep</aspectratio>
        <
colordiffuse>$VAR[NotificationIconColor]</colordiffuse>
    </
control

But this resulted in no icons being colored i.e. They appeared in their normal state, without any <colordiffuse>. I tried your suggestion of just leaving out the second condition as well as the the fallback FFFFFFFF (Side note: I realize now how dumb 00000000 was Confused). So I have:

PHP Code:
<variable name="NotificationIconColor">
        <
value condition="SubString(ListItem.Icon,Error) | SubString(ListItem.Icon,Info) | SubString(ListItem.Icon,Warning)">AccentColor</value>
    </
variable


But that results in the Info, Error, and Warning Icons not showing up at all. This got me thinking that it might be a problem with my color "AccentColor" defined in a color.xml. So I changed "AccentColor" to its ARGB value "FFFF3D00."

PHP Code:
<variable name="NotificationIconColor">
        <
value condition="SubString(ListItem.Icon,Error) | SubString(ListItem.Icon,Info) | SubString(ListItem.Icon,Warning)"FFFF3D00</value>
        <
value>FFFFFFFF</value>
    </
variable

But this didn't change anything (the icon didn't show up at all)

Leaving the fallback in their does result in the icon showing up, just without any <colordiffuse>
Reply
#6
ListItem.Icon wont work as there's no list. Use SubString(Control.GetLabel(400),Default,left) in jarvis. For isengard you'd have to check ID's 403-405 for the error icons.
Reply
#7
Ooooohhhh wow yeah that makes a lot of sense. No List = No ListItem...

And yes SubString(Control.GetLabel(400),Default,left) did work. Thank you again for your help man.

I hate to be the guy that keeps on asking, but could you explain why changing it around to SubString(Control.GetLabel(400),Info,right) doesn't work?
From the example in the wiki, it seems like it should since the icon's name is DefaultIconInfo.

Is it because the label doesn't contain the full icon name/title? Or is the extension .png part of the label, and therefore it would be what's found on the "right"?
Reply
#8
Because end is ".png" file extension as part of the returned value. Just don't use the left or right argument if you want to check Info as part inside the string.
[Skin] KOver - V1.1.0 Stable (Repo version)
[WIP] ReKOver - Skinning tool project

If I've been helpful or you like my work, hit "THANK USER" button ;) ...
Reply
#9
Thanks Jayz2k for the explanation. At least now I know that's a way to return a file extension if ever needed lol
Reply

Logout Mark Read Team Forum Stats Members Help
Conditional <colordiffuse> of Icons in DialogKaiToast.xml0