2014-03-23, 18:57
Don't know if something similar had been proposed before, but it would be nice if includes could accept parameters and be able to generate dynamic content based on them. I think this could clean up skin XMLs a bit while not being too difficult to implement (in fact I might do it when I find some time).
Say you want to include some complex control in various places in the skin (maybe even in the same window) but each time with a slight variation like different position, color, texture, etc. Say that control is composite, consisting of multiple nested controls, and that this slight change affects most of them. Also, let this variation not be based on any specific condition like player state, current window or such -- you just want slightly different instances in multiple places (e.g. keyboard dialog buttons).
AFAIK, currently you'd have to duplicate great deal of XML for the entire "outer shell" of the control (and do the same for all nested controls!), while possibly including just some tiny common bits here and there. So inclusion doesn't help much here.
Global variables are also not suitable because their value cannot be changed once defined, so they cannot simulate true parameters.
Possible syntax might be:
Parameter names could be given in different case, with some prefix or such, to differentiate them from built-in attributes.
This would basically turn includes into "procedures" (when needed) and their "calls" into one-liners.
What do you think?
Say you want to include some complex control in various places in the skin (maybe even in the same window) but each time with a slight variation like different position, color, texture, etc. Say that control is composite, consisting of multiple nested controls, and that this slight change affects most of them. Also, let this variation not be based on any specific condition like player state, current window or such -- you just want slightly different instances in multiple places (e.g. keyboard dialog buttons).
AFAIK, currently you'd have to duplicate great deal of XML for the entire "outer shell" of the control (and do the same for all nested controls!), while possibly including just some tiny common bits here and there. So inclusion doesn't help much here.
Global variables are also not suitable because their value cannot be changed once defined, so they cannot simulate true parameters.
Possible syntax might be:
Code:
<!-- default parameter values are given here, others are mandatory -->
<include name="MyControl" PosX="120" PosY="120">
<control ...>
<posx>$PARAM[PosX]</posx>
<posy>$PARAM[PosY]</posy>
<control ...>
...
<texture border="$PARAM[Border]">$PARAM[Background]</texture>
</control>
...
<include Color="$PARAM[Color]">MyControl2</include>
...
</control>
...
</include>
Parameter names could be given in different case, with some prefix or such, to differentiate them from built-in attributes.
This would basically turn includes into "procedures" (when needed) and their "calls" into one-liners.
What do you think?