Kodi Community Forum

Full Version: Regarding variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm on my phone so no examples sorry. But I'm having an issue setting up variables and wondered if this is even possible. This is a scripts dialog if that matters.

Basically I want to mimick how addon settings work. I want the highlited button to retain a focused, but faded texture.

I thought to use a $VAR one for the texture to use button-focus if a property has been set, which is set when the button onfocus activates.

So for the control I set the texturenofocus to $VAR[varnam] and had the variable set in the same file just after the <window> tag. I copied as a test so I think it's right. This does not work. I put the $VAR in the label and did not work. I then put the variables in the includes.xml file and the label showed the value correctly.

I read they don't have to be in the includes. Is this correct?

I also tried setting up another variable for diffuse with no luck.

Can the variables be set up in a reg window XML can you use them in the colordiffuse tags. Is there an easier way to mimick what I'm trying. I used the dialogaddonsettings XML as abase. But this feature is handled by xbmc not skin conditions.

Thanks
One more thing how do you avoid text overlap in an edit control. I've played with the tag textwidth and align. But can't get it right and I didn't find any documentation on textwidth. I set textwidth to 520 and width to 720. But still it overlaps when long enough.

Thanks
(2012-05-28, 13:39)Nuka1195 Wrote: [ -> ]I'm on my phone so no examples sorry. But I'm having an issue setting up variables and wondered if this is even possible. This is a scripts dialog if that matters.

Basically I want to mimick how addon settings work. I want the highlited button to retain a focused, but faded texture.

I thought to use a $VAR one for the texture to use button-focus if a property has been set, which is set when the button onfocus activates.

So for the control I set the texturenofocus to $VAR[varnam] and had the variable set in the same file just after the <window> tag. I copied as a test so I think it's right. This does not work. I put the $VAR in the label and did not work. I then put the variables in the includes.xml file and the label showed the value correctly.

I read they don't have to be in the includes. Is this correct?

I also tried setting up another variable for diffuse with no luck.

Can the variables be set up in a reg window XML can you use them in the colordiffuse tags. Is there an easier way to mimick what I'm trying. I used the dialogaddonsettings XML as abase. But this feature is handled by xbmc not skin conditions.

Thanks
One more thing how do you avoid text overlap in an edit control. I've played with the tag textwidth and align. But can't get it right and I didn't find any documentation on textwidth. I set textwidth to 520 and width to 720. But still it overlaps when long enough.

Thanks

posting the xml would be nice.
there are probably several ways to get what you want (if i understood correctly)
alttexturefocus would also be possible for example I think ( --> toggle buttons, http://wiki.xbmc.org/index.php?title=Tog...on_control with <usealttexture>Control.HasFocus(xx)</usealttexture> for example)
concerning overlapping: you mean that label and hinttext overlap?

vars for colordifffuses work in general (i think vars work for everything when put between start-tag and end-tag, not sure if you can define them in custom xmls though. normal place would be variables.xml.
PHP Code:
    <variable name="categorybuttontexture">
        <
value condition="true">button-focus.png</value>
        <
value>button-nofocus.png</value>
    </
variable>
    <
variable name="categorybuttontexture300">
        <
value condition="StringCompare(Window.Property(Category),300)">button-focus.png</value>
        <
value>button-nofocus.png</value>
    </
variable>
    <
variable name="categorybuttondiffuse300">
        <
value condition="!Container(9).Control.HasFocus(300) + StringCompare(Window.Property(Category),300)">60FFFFFF</value>
        <
value>FFFFFFFF</value>
    </
variable

thanks for your response. i never thought of the toggle button, that may work. but here's what i was trying. i put that in the scripts xml file. i'm not sure if scripts support variables.xml, but will test. even with the condition set to true it doesn't work in the scripts xml file.
good news the togglebutton works perfect for the right texture. now i either have to find the proper faded texture or get the colordiffuse to work. i would like to be able to use $VAR[] in scripts so hopefully we can get a definite answer if they should work for scripts.

thanks
(2012-05-28, 16:25)Nuka1195 Wrote: [ -> ]
PHP Code:
    <variable name="categorybuttontexture">
        <
value condition="true">button-focus.png</value>
        <
value>button-nofocus.png</value>
    </
variable>
    <
variable name="categorybuttontexture300">
        <
value condition="StringCompare(Window.Property(Category),300)">button-focus.png</value>
        <
value>button-nofocus.png</value>
    </
variable>
    <
variable name="categorybuttondiffuse300">
        <
value condition="!Container(9).Control.HasFocus(300) + StringCompare(Window.Property(Category),300)">60FFFFFF</value>
        <
value>FFFFFFFF</value>
    </
variable

thanks for your response. i never thought of the toggle button, that may work. but here's what i was trying. i put that in the scripts xml file. i'm not sure if scripts support variables.xml, but will test. even with the condition set to true it doesn't work in the scripts xml file.
good news the togglebutton works perfect for the right texture. now i either have to find the proper faded texture or get the colordiffuse to work. i would like to be able to use $VAR[] in scripts so hopefully we can get a definite answer if they should work for scripts.

thanks

you could also use a conditional fade animation to work-around your problem Wink
and i meant the variables.xml in skin folder, I´m pretty sure that a script-own variables.xml does not work.
the fade would work, but it fades the text also. <colordiffuse> seems broken with togglebutton, it works with a regular "button". i'll just add my own diffused texture to the togglebutton. thanks for your help, it was confounding me last night.

jmarshall or any developers, <colordiffuse>20FFFFFF</colordiffuse> doesn't work with the togglebutton. at least not as i am using it.

PHP Code:
            <control type="togglebutton" id="300">
                <
description>Author Button</description>
                <
height>40</height>
                <
width>173</width>
                <
align>center</align>
                <
aligny>center</aligny>
                <
font>font12_title</font>
                <
label>$ADDON[lyrics.xbmc.lyrics 30905]</label>
                <
textcolor>white</textcolor>
                <
texturefocus>button-focus.png</texturefocus>
                <
texturenofocus>button-nofocus.png</texturenofocus>
                <
alttexturefocus>button-focus.png</alttexturefocus>
                <
alttexturenofocus>button-focus.png</alttexturenofocus>
                <
usealttexture>StringCompare(Window.Property(Category),300)</usealttexture>
                <
colordiffuse>60FFFFFF</colordiffuse>
                <
pulseonselect>false</pulseonselect>
                <
onfocus>SetProperty(Category,300)</onfocus>
            </
control
Or just leave the button textures blank and use two separate image controls underneath the button - one visible when !Control.HasFocus(300) and the other visible when Control.HasFocus(300).
(2012-05-28, 18:16)Nuka1195 Wrote: [ -> ]the fade would work, but it fades the text also. <colordiffuse> seems broken with togglebutton, it works with a regular "button". i'll just add my own diffused texture to the togglebutton. thanks for your help, it was confounding me last night.

jmarshall or any developers, <colordiffuse>20FFFFFF</colordiffuse> doesn't work with the togglebutton. at least not as i am using it.

PHP Code:
            <control type="togglebutton" id="300">
                <
description>Author Button</description>
                <
height>40</height>
                <
width>173</width>
                <
align>center</align>
                <
aligny>center</aligny>
                <
font>font12_title</font>
                <
label>$ADDON[lyrics.xbmc.lyrics 30905]</label>
                <
textcolor>white</textcolor>
                <
texturefocus>button-focus.png</texturefocus>
                <
texturenofocus>button-nofocus.png</texturenofocus>
                <
alttexturefocus>button-focus.png</alttexturefocus>
                <
alttexturenofocus>button-focus.png</alttexturenofocus>
                <
usealttexture>StringCompare(Window.Property(Category),300)</usealttexture>
                <
colordiffuse>60FFFFFF</colordiffuse>
                <
pulseonselect>false</pulseonselect>
                <
onfocus>SetProperty(Category,300)</onfocus>
            </
control

post it here, perhaps we´ll get attention then Smile

EDIT: colordiffuse for togglebuttons works in our skin (nox 3.0)
AFAIK, you can not use textures in variables.

Quote:<variable name="categorybuttontexture">
<value condition="true">button-focus.png</value>
<value>button-nofocus.png</value>
</variable>

In this case first condition is always true, so button-nofocus.png will not be used.

What Hitcher proposed is safest bet IMO.
(2012-05-28, 18:28)pecinko Wrote: [ -> ]AFAIK, you can not use textures in variables.

Quote:<variable name="categorybuttontexture">
<value condition="true">button-focus.png</value>
<value>button-nofocus.png</value>
</variable>

In this case first condition is always true, so button-nofocus.png will not be used.

What Hitcher proposed is safest bet IMO.

that was just an example from nuka, in general variables work for textures.
togglebutton would be the cleanest solution code-wise. (or colordiffuse variable)
@pecinko, yes that was to make sure it even worked.

what i've discovered is <colordiffuse>$VAR[foo]</colordiffuse> does not work.

i also had to put the <variable> in includes.xml in the skin or maybe variables.xml, but does not work in the scripts skin. maybe if i had the scripts skin in the skin. will test.

in includes.xml
PHP Code:
        <variable name="categorybuttontexture">
            <
value condition="true">button-focus.png</value>
            <
value>button-nofocus.png</value>
        </
variable>
        <
variable name="categorybuttontexture300">
            <
value condition="StringCompare(Window.Property(Category),300)">button-focus.png</value>
            <
value>button-nofocus.png</value>
        </
variable>
        <
variable name="categorybuttondiffuse300">
            <
value condition="StringCompare(Window.Property(Category),300)">20FFFFFF</value>
            <
value>FFFFFFFF</value>
        </
variable

in scripts skin
PHP Code:
            <control type="button" id="300">
                <
description>Author Button</description>
                <
height>40</height>
                <
width>173</width>
                <
align>center</align>
                <
aligny>center</aligny>
                <
font>font12_title</font>
                <
label>$VAR[categorybuttontexture300]</label>
                <
textcolor>white</textcolor>
                <
texturefocus>button-focus.png</texturefocus>
                <
texturenofocus>$VAR[categorybuttontexture300]</texturenofocus>
                <
alttexturefocus>button-focus.png</alttexturefocus>
                <
alttexturenofocus>button-focus.png</alttexturenofocus>
                <
usealttexture>StringCompare(Window.Property(Category),300)</usealttexture>
                <
colordiffuse>$VAR[categorybuttondiffuse300]</colordiffuse>
                <
pulseonselect>false</pulseonselect>
                <
onfocus>SetProperty(Category,300)</onfocus>
            </
control

the above code the label shows the correct value, but texturenofocus is empty, meaning no texture. i wonder if full paths are required?

i like the togglebutton solution best, just need to get colordiffuse working for the togglebutton and get $VAR[] working in colordiffuse.
(2012-05-28, 19:37)Nuka1195 Wrote: [ -> ]@pecinko, yes that was to make sure it even worked.

what i've discovered is <colordiffuse>$VAR[foo]</colordiffuse> does not work.

i also had to put the <variable> in includes.xml in the skin or maybe variables.xml, but does not work in the scripts skin. maybe if i had the scripts skin in the skin. will test.

in includes.xml
PHP Code:
        <variable name="categorybuttontexture">
            <
value condition="true">button-focus.png</value>
            <
value>button-nofocus.png</value>
        </
variable>
        <
variable name="categorybuttontexture300">
            <
value condition="StringCompare(Window.Property(Category),300)">button-focus.png</value>
            <
value>button-nofocus.png</value>
        </
variable>
        <
variable name="categorybuttondiffuse300">
            <
value condition="StringCompare(Window.Property(Category),300)">20FFFFFF</value>
            <
value>FFFFFFFF</value>
        </
variable

in scripts skin
PHP Code:
            <control type="button" id="300">
                <
description>Author Button</description>
                <
height>40</height>
                <
width>173</width>
                <
align>center</align>
                <
aligny>center</aligny>
                <
font>font12_title</font>
                <
label>$VAR[categorybuttontexture300]</label>
                <
textcolor>white</textcolor>
                <
texturefocus>button-focus.png</texturefocus>
                <
texturenofocus>$VAR[categorybuttontexture300]</texturenofocus>
                <
alttexturefocus>button-focus.png</alttexturefocus>
                <
alttexturenofocus>button-focus.png</alttexturenofocus>
                <
usealttexture>StringCompare(Window.Property(Category),300)</usealttexture>
                <
colordiffuse>$VAR[categorybuttondiffuse300]</colordiffuse>
                <
pulseonselect>false</pulseonselect>
                <
onfocus>SetProperty(Category,300)</onfocus>
            </
control

the above code the label shows the correct value, but texturenofocus is empty, meaning no texture. i wonder if full paths are required?

i like the togglebutton solution best, just need to get colordiffuse working for the togglebutton and get $VAR[] working in colordiffuse.

lookin at the skin code of nox 3.0 could help you perhaps. we´re using variables for colordiffuses and for textures (also in script windows)
thanks will have a look.

i saw your edit about colordiffuse and toggle controls, ill test some more.
Hmm. You rather test using VARs as button labels. Those did not work last time I tried.

Edit: scratch this. Problem was with fallback labels. VARs are fine.
-- nvm, was wrong here
Reguarding <colordiffuse> it doesn't work with the <alttexture*> only with the normal texture.

Can anyone else confirm this. I can't find an alternate tag for this either?