Kodi Community Forum
Bug $VAR[] to position an image? - 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: Bug $VAR[] to position an image? (/showthread.php?tid=182619)



$VAR[] to position an image? - powlo - 2014-01-07

I'm trying to use a var to position an image. The most basic trial doesn't work:

Code:
<control type="image">
    <left>$VAR[Thingumy]</left>
    <top>570</top>
    <width>50</width>
    <height>50</height>
    <texture>somepic.png</texture>
</control>

<variable name="Thingumy">
    <value>100</value>
</variable>

I know the variable is being set because I can change its value for the texture name and use it in the <texture>, and it works fine.

Any ideas?


RE: $VAR[] to position an image? - Martijn - 2014-01-07

Not supported for positions


RE: $VAR[] to position an image? - `Black - 2014-01-07

Variables don't work with integer values. Only strings are supported atm. Don't know if pieh is working on it but I wouldn't wait for support anytime soon.


RE: $VAR[] to position an image? - powlo - 2014-01-08

OK That totally blows my understanding of how $VARs work.

Why does the renderer care where a $VAR is used? Shouldn't it just scan for all uses of $VAR and substitute values?

Why does the renderer care what type a $VAR has? In my mind a $VAR value is just a piece of data.

Anyway, thanks for the clarification.


RE: $VAR[] to position an image? - EtgarDizz - 2014-01-27

(2014-01-08, 14:52)powlo Wrote: Why does the renderer care what type a $VAR has? In my mind a $VAR value is just a piece of data.
Second this.
I also think that the renderer shouldn't care where or how the $VAR is used, it should be a (fairly simple) substitution-type mechanism.

(2014-01-07, 22:29)`Black Wrote: Variables don't work with integer values. Only strings are supported atm. Don't know if pieh is working on it but I wouldn't wait for support anytime soon.
I've tried this on another use-case that involves strings, still no luck.
My case is about displaying different items from the Skin Widgets service. Something like this:

PHP Code:
<item id="1">
    <
visible>!IsEmpty(Window.Property($VAR[itemtype].1.File))</visible>
    <
label>$INFO[Window.Property($VAR[itemtype].1.Title)]</label>
    <
onclick>PlayMedia($ESCINFO[Window(Home).Property($VAR[itemtype].1.File)])</onclick>
</
item>

<
variable name="itemtype">
    <
value condition="Skin.HasSetting(itemtype2)">RandomEpisode</value>
    <
value>RecentEpisode</value>
</
variable

I want to use user-defined settings to say if I show recent or random items.

Is this possible currently?
If not - has anyboy figured a workaround for this? (other than copy-pasting the entire block twice)


RE: $VAR[] to position an image? - jmarshall - 2014-01-27

"The renderer" is a shit load of code. I'd be happy if someone wishes to improve it.

$VAR is evaluated at runtime (i.e. per frame). It doesn't work everywhere for just that reason, as not everything is queried at runtime.


RE: $VAR[] to position an image? - warlion - 2014-01-27

(2014-01-27, 21:11)EtgarDizz Wrote:
PHP Code:
<item id="1">
    <
visible>!IsEmpty(Window.Property($VAR[itemtype].1.File))</visible>
    <
label>$INFO[Window.Property($VAR[itemtype].1.Title)]</label>
    <
onclick>PlayMedia($ESCINFO[Window(Home).Property($VAR[itemtype].1.File)])</onclick>
</
item>

<
variable name="itemtype">
    <
value condition="Skin.HasSetting(itemtype2)">RandomEpisode</value>
    <
value>RecentEpisode</value>
</
variable

I want to use user-defined settings to say if I show recent or random items.

Is this possible currently?
If not - has anyboy figured a workaround for this? (other than copy-pasting the entire block twice)

This is something I will love to see


RE: $VAR[] to position an image? - Hitcher - 2014-01-27

(2014-01-27, 21:11)EtgarDizz Wrote:
(2014-01-08, 14:52)powlo Wrote: Why does the renderer care what type a $VAR has? In my mind a $VAR value is just a piece of data.
Second this.
I also think that the renderer shouldn't care where or how the $VAR is used, it should be a (fairly simple) substitution-type mechanism.

(2014-01-07, 22:29)`Black Wrote: Variables don't work with integer values. Only strings are supported atm. Don't know if pieh is working on it but I wouldn't wait for support anytime soon.
I've tried this on another use-case that involves strings, still no luck.
My case is about displaying different items from the Skin Widgets service. Something like this:

PHP Code:
<item id="1">
    <
visible>!IsEmpty(Window.Property($VAR[itemtype].1.File))</visible>
    <
label>$INFO[Window.Property($VAR[itemtype].1.Title)]</label>
    <
onclick>PlayMedia($ESCINFO[Window(Home).Property($VAR[itemtype].1.File)])</onclick>
</
item>

<
variable name="itemtype">
    <
value condition="Skin.HasSetting(itemtype2)">RandomEpisode</value>
    <
value>RecentEpisode</value>
</
variable

I want to use user-defined settings to say if I show recent or random items.

Is this possible currently?
If not - has anyboy figured a workaround for this? (other than copy-pasting the entire block twice)

Just use conditional includes - one for Recent and one for Random items - and then fill each include with all the relevant items. this is exactly how I do it for Alaska HD.


RE: $VAR[] to position an image? - jurialmunkey - 2014-01-27

@powlo - why not just use a conditional slide animation with time="0" to reposition the control -- e.g.

Code:
<control type="image">
    <width>50</width>
    <height>50</height>
    <texture>somepic.png</texture>
    <animation effect="slide" start="0" end="100,0" time="0" condition="Condition1">Conditional</animation>
    <animation effect="slide" start="0" end="200,100" time="0" condition="Condition2">Conditional</animation>
    <animation effect="slide" start="0" end="500,100" time="0" condition="Condition3">Conditional</animation>
</control>



RE: $VAR[] to position an image? - EtgarDizz - 2014-01-28

(2014-01-27, 23:43)Hitcher Wrote: Just use conditional includes - one for Recent and one for Random items - and then fill each include with all the relevant items. this is exactly how I do it for Alaska HD.

Ok, I see how that would help to clean the code... But it still means I will have to have two copies of the same block, with the only difference being the Random/Recent bit...
... and once I want to add an option for "Recommended"... three copies of the same block. And so on.


RE: $VAR[] to position an image? - Hitcher - 2014-01-28

It's literally a Copy/Paste/Find/Replace job though.


RE: $VAR[] to position an image? - warlion - 2014-01-28

(2014-01-28, 19:11)Hitcher Wrote: It's literally a Copy/Paste/Find/Replace job though.

RoflRoflRoflRoflRoflRofl


RE: $VAR[] to position an image? - EtgarDizz - 2014-01-28

(2014-01-28, 19:11)Hitcher Wrote: It's literally a Copy/Paste/Find/Replace job though.

Not to take away from the sheer joy of search/replace (especially when using regular expressions for the job)...
Wasn't quite what I meant by "workaround". I'm trying to avoid having huge files with redundant code in them.

Would be nice if someone figured out a creative way to accomplish this.


RE: $VAR[] to position an image? - Hitcher - 2014-01-28

I wouldn't worry as they'll have no impact on performance, in fact using conditional includes are better for performance as they're loaded on window load whereas variables are checked every screen refresh.