Posts: 26,215
Joined: Oct 2003
Reputation:
187
another thing to keep in mind is that this has to be performed every frame, for every label control or fadelabel control, so any solution that is finalized must be as optimal as possible.
i agree that less complexity is better, and can't really think of any useful scenarios in which the more complicated one is necessary that can't be overcome with using 2 or more label controls.
cheers,
jonathan
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
does you code allow for prefix and suffix text to be conditionally shown?
i redid the parselabel so it works like this.
you must have everything you want parsed in curly brackets. if there is not a matching pair of brackets, it doesn't parse it. if there is a least one pair, it will ignore anything outside of a pair. i did this to streamline the code. it forces more strict skinning, but it's probably better.
example: {it is }{$info(weather.conditions)outside and }{$info(weather.temperature)}
if weather.conditions was blank for example, it would return:
it is 55f (with the degree sign)
the conditional values control everything in there block. i just need to clean it up and do some more testing. if you think you might use this then i'll finish it. i could see a real benefit for the fadelabel.
Posts: 76
Joined: Jan 2005
Reputation:
0
but if weather.temperature would be blank it would still write 'outside and ' at the end... which would be rather meaningless.
for a perfect solution you _will_ have to incorporate conditional expressions... but as the devs consider it getting too complex and i don't use it myelf i will not continue on that path.
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
ok, i have it working like the following:
all info must be enclosed in {}. any text in with an $info() tag, will be dependent on there being info.
<label>{album: $info(musicplayer.album)}{ by }{$info(musicplayer.artist)}</label>
you notice the { by }, if there are no $info() tags then that block relies on both sides having info.
i'll clean it up and test more with $localize().
Posts: 76
Joined: Jan 2005
Reputation:
0
if you would have:
<label>{album: $info(musicplayer.album)}{, by }{$info(musicplayer.artist)}{, in the year }{$info(musicplayer.year)}</label>
and artist is not available, it will concat album and year info without delimiters
Posts: 7,172
Joined: Dec 2003
Reputation:
4
kraqh3d
Retired Developer
Posts: 7,172
thanks. that fix worked. the localized strings now are visible when appropiate.
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
:nuts: why can't people tag things correctly.
well it isn't perfect, but it does give some control to the skinner and would work for simple strings. probablt isn't worth it though.
oh well.
Posts: 7,172
Joined: Dec 2003
Reputation:
4
kraqh3d
Retired Developer
Posts: 7,172
sorry, ive been away for a few weeks. this has been in cvs for a while without the fancy conditionals. to concatentate infotags and localized strings you need to use control words which are parsed by the label control -- $localize() and $info(). anything else is assumed to be text.
the example from the changelog is:
<label>$localize(171) $info(musicplayer.artist)</label>
this will produce (in english):
artist: u2
missing fields in the middle will result in text seperators getting removed similar to how the tag formatting works in my music.
Posts: 26,215
Joined: Oct 2003
Reputation:
187
just squashed another bug in this, and have just realized this is being called for every label, every frame.
this seems a little wasteful.
perhaps a way around it would be to have it setup in the <info> tag, and if the <info> tag is not parsed (in guicontrolfactory::create()) to a number, have it as an additional string variable.
the label control then just needs to check this variable at render time, and only processes the parselabel() code (which mayaswell go in the infomanager) when it needs it.
thoughts?
edit: not really wasteful at all, as only labels with $ in them actually get parsed!
cheers,
jonathan