Kodi Community Forum

Full Version: newbie skinner question, math module in xml?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So, i'm really trying to understand how things should work, i read and searched in the kodi wiki and didn't get an answer.
I want to set height for a control to be a CONSTANT\INFOLABEL, for ex. 10\10=1.

So, how is this done? it's such a basic thing to do in gen. coding but writing functions in xml feels like being handicapped.
I don't even know if infolabel if values are strings/ints if it even matter.

Should i use a built-in module?

thanks
[CAN'T EDIT MY OWN POST]

For example, and please I might just over complicated here, please enlighten me if so...

I wanted to have a video window that will align to the right and top of the screen, problem was that it didn't work for different aspect ratios of videos.
So i figured i need to have height adjusted to fit (or width, depending on who's the const).
I simply wanted to put in: WIDTH \ ASPECT_RATIO = HEIGHT.

Luckily, aspect ratio values are finite (and a small one), so UGLY CODE SOLUTION #1 - tried returning $var of height on conditions, apparently not possible.
then tried creating an include with conditions but figured that i have to write <height>X</height> for each one.

SO UGLY CODE SOLUTION #2 - 
Code:

<!--autistic workaround to assign correct height to video window-->
<include name="height_aspect_ratio_1.78">
<height>720</height>
</include>
<include name="height_aspect_ratio_2.4">
<height>534</height>
</include>
<include name="height_aspect_ratio_1.33">
<height>963</height>
</include> 
....

and then "call" it in control -
Code:
<include condition="Integer.IsEqual(VideoPlayer.VideoAspect,1.78)">height_aspect_ratio_1.78</include>
<include condition="Integer.IsEqual(VideoPlayer.VideoAspect,2.4)">height_aspect_ratio_2.4</include>
...

This just can't be right.
unless I am mistaken you can not do math in xml, xml/skinning is not programing in a logical sense. But if you take the time to set the var for each aspect ratio and then check if that aspect ratio is being used then it will work as a var.
(2018-06-27, 01:44)cartman.dos Wrote: [ -> ]This just can't be right.

Unfortunately it is. There are no ways to do integer operations or string manipulations in the skinning engine. Your solution is really the only possible way.

With an image you can use
Code:
<aspectration aligny="top" align="right">keep</aspectratio>

But that doesn't work with a videowindow, so I usually just add a black background behind it to get a letterboxed effect if the aspect is different.
e.g.
Code:
<control type="group">
  <width>1280</width>
  <height>720</height>
  <control type="image">
    <texture colordiffuse="ff000000">white.png</texture>
  </control>
  <control type="videowindow>
  </control>
</control>