In an effort to improve the lot of Skinners around the world, I've built an expression parser to help reduce the effort required to maintain both 4x3 and WS versions of a skin. It's currently fairly basic, only allowing numeric calculation (no strings), but I wanted to find out if there's any interest and/or point in taking it further.
It builds on the exiting <define> tag and '#' syntax as follows:
Say you have a skin element tag such as <posx> - you can use the following:
1. Absolute position (current functionality): <posx>120</posx>
2. Specified by a constant (current):
<define>#MyPosX:120</define>
...
<posx>#MyPosX</posx>
3. Absolute offset from right-hand side (120 pixels from the right edge):
<posx>#(#ScreenWidth - 120)</posx>
Sorry - forgot to mention that #ScreenHeight and #ScreenWidth are built-in and taken automatically from GUIGraphicContext.SkinSize
4. (10) Percent of the screen width:
<posx>#(#ScreenWidth*10/100)</posx>
5. You can use defines to create subexpressions:
<define>#TenPercentofWidth: (#ScreenWidth*10/100)</define>
...
<posx>#TenPercentofWidth</posx>
6. and use them in more complex expressions:
<posx>#(#TenPercentofWidth*3/2)</posx> (15% of width (I think!))
7. String expressions - e.g. you can calculate the name of a graphic
#('myHome' + #ScreenWidth + 'x' + #ScreenHeight + '.png') -- myHome1280x720.png
or maybe
#(#ScreenWidth + 'x' + #ScreenHeight + '\myHome' + '.png') -- 1280x720\myHome.png
if you want to put gfx for different sizes/aspect ratios in separate directories.
I need to define some built-in functions (e.g. if(,,) would possibly be useful), and also it currently does integral arithmetic, so floats would be an obvious extension.
That's enough from me. The questions are
1. Is this going to be useful
2. Would anybody use it
and therefore,
3. Should I continue working on it, or find something else to play with?
Note that it doesn't (seem to) break any existing skin syntax, but making sure it didn't has made some of the syntax (e.g. "#(...)" a bit clumsy... (Anyway, that's my excuse, and I'm sticking to it...)
It builds on the exiting <define> tag and '#' syntax as follows:
Say you have a skin element tag such as <posx> - you can use the following:
1. Absolute position (current functionality): <posx>120</posx>
2. Specified by a constant (current):
<define>#MyPosX:120</define>
...
<posx>#MyPosX</posx>
3. Absolute offset from right-hand side (120 pixels from the right edge):
<posx>#(#ScreenWidth - 120)</posx>
Sorry - forgot to mention that #ScreenHeight and #ScreenWidth are built-in and taken automatically from GUIGraphicContext.SkinSize
4. (10) Percent of the screen width:
<posx>#(#ScreenWidth*10/100)</posx>
5. You can use defines to create subexpressions:
<define>#TenPercentofWidth: (#ScreenWidth*10/100)</define>
...
<posx>#TenPercentofWidth</posx>
6. and use them in more complex expressions:
<posx>#(#TenPercentofWidth*3/2)</posx> (15% of width (I think!))
7. String expressions - e.g. you can calculate the name of a graphic
#('myHome' + #ScreenWidth + 'x' + #ScreenHeight + '.png') -- myHome1280x720.png
or maybe
#(#ScreenWidth + 'x' + #ScreenHeight + '\myHome' + '.png') -- 1280x720\myHome.png
if you want to put gfx for different sizes/aspect ratios in separate directories.
I need to define some built-in functions (e.g. if(,,) would possibly be useful), and also it currently does integral arithmetic, so floats would be an obvious extension.
That's enough from me. The questions are
1. Is this going to be useful
2. Would anybody use it
and therefore,
3. Should I continue working on it, or find something else to play with?
Note that it doesn't (seem to) break any existing skin syntax, but making sure it didn't has made some of the syntax (e.g. "#(...)" a bit clumsy... (Anyway, that's my excuse, and I'm sticking to it...)