Kodi Community Forum
Is there a better way to do this? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
+--- Thread: Is there a better way to do this? (/showthread.php?tid=130605)



Is there a better way to do this? - Aenima99x - 2012-05-03

I'm going to set the weather icons folder based on a setting toggle. So if the settings option is not checked, it will use the default icons in the weather_icons folder, but if it is checked then it will use the real style weather icons in weather_icons2. I'm just not sure if there is a better way of doing this than having two image controls with visibility conditions.

Code:
                <control type="image">
                    <width>140</width>
                    <height>140</height>
                    <posx>30</posx>
                    <posy>10</posy>
                    <texture>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</texture>
                    <visible>!Skin.HasSetting(WeatherIcons2)</visible>
                </control>
                <control type="image">
                    <width>140</width>
                    <height>140</height>
                    <posx>30</posx>
                    <posy>10</posy>
                    <texture>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</texture>
                    <visible>Skin.HasSetting(WeatherIcons2)</visible>
                </control>



RE: Is there a better way to do this? - Hitcher - 2012-05-03

This is how I'd do it.

Code:
    <control type="image">
        <width>140</width>
        <height>140</height>
        <posx>30</posx>
        <posy>10</posy>
        <texture>$VAR[Weather_Icons]</texture>
    </control>

Then in your Variables.xml

Code:
<variable name="Weather_Icons">
    <value condition="Skin.HasSetting(WeatherIcons2)">$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</value>
    <value>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</value>
</variable>



RE: Is there a better way to do this? - Aenima99x - 2012-05-03

Thanks Hitcher! It's been awhile since I've done much skinning, when did $VAR and variables.xml become available?


Re: Is there a better way to do this? - Martijn - 2012-05-03

Couple of months ago


RE: Is there a better way to do this? - Aenima99x - 2012-05-03

Awesome...thanks guys


RE: Is there a better way to do this? - Aenima99x - 2012-05-03

I've created a variables.xml and put in the code for the variable name and added the changes to the MyWeather.xml, but I keep getting this error
Quote:Label Formating: $VAR[Weather_Icons] is not defined
Any ideas what I'm doing wrong?

Edit - Apprently it helps to add variables.xml to the includes.xml and then put the <includes> tags in the variables.xml


RE: Is there a better way to do this? - Aenima99x - 2012-05-03

Ok one last question - How do I set the variable to detect what day I want the image to be? Do I need to hardcode all of the day0, day1, etc or is there some wildcard I can use? I see that the readme says Day%i.FanartCode, but that doesn't seem to work.
<value>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</value>



RE: Is there a better way to do this? - phil65 - 2012-05-04

(2012-05-03, 22:17)Aenima99x Wrote: Ok one last question - How do I set the variable to detect what day I want the image to be? Do I need to hardcode all of the day0, day1, etc or is there some wildcard I can use? I see that the readme says Day%i.FanartCode, but that doesn't seem to work.
<value>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</value>

you have to hardcode them. jmarshall is workin on a new way of parsing the xml tags (which makes it possible to use $INFO[] inside $INFO[] for example afaik), but atm you have to create every single item.
(2012-05-03, 21:37)Aenima99x Wrote: I've created a variables.xml and put in the code for the variable name and added the changes to the MyWeather.xml, but I keep getting this error
Quote:Label Formating: $VAR[Weather_Icons] is not defined
Any ideas what I'm doing wrong?

Edit - Apprently it helps to add variables.xml to the includes.xml and then put the <includes> tags in the variables.xml

you´re doing something wrong then. look at the implementation in other skins, no need to put variables in includes.


RE: Is there a better way to do this? - Aenima99x - 2012-05-04

(2012-05-04, 20:05)phil65 Wrote:
(2012-05-03, 22:17)Aenima99x Wrote: Ok one last question - How do I set the variable to detect what day I want the image to be? Do I need to hardcode all of the day0, day1, etc or is there some wildcard I can use? I see that the readme says Day%i.FanartCode, but that doesn't seem to work.
<value>$INFO[Window.Property(Day0.FanartCode),special://skin/extras/weather_icons/,.png]</value>

you have to hardcode them. jmarshall is workin on a new way of parsing the xml tags (which makes it possible to use $INFO[] inside $INFO[] for example afaik), but atm you have to create every single item.

Yeah I figured as much and went ahead and hardcoded them all.

(2012-05-03, 21:37)Aenima99x Wrote: I've created a variables.xml and put in the code for the variable name and added the changes to the MyWeather.xml, but I keep getting this error
Quote:Label Formating: $VAR[Weather_Icons] is not defined
Any ideas what I'm doing wrong?

Edit - Apprently it helps to add variables.xml to the includes.xml and then put the <includes> tags in the variables.xml

you´re doing something wrong then. look at the implementation in other skins, no need to put variables in includes.

Yup I was doing it wrong, got it sorted out.