Page 1 of 1

Add Selected to serialization of CGUIListBox

Posted: Mon May 31, 2021 11:21 pm
by chronologicaldot
It's a very small change. CGUIListBox has a member named Selected. It'd be nice if this were serialized and deserialized, esp for the sake of scripting languages.
Thanks

Re: Add Selected to serialization of CGUIListBox

Posted: Tue Jun 01, 2021 11:09 am
by CuteAlien
Hm, I suppose it can barely count as property. Added to trunk in r6218.
Would be nice if you could give it a quick test (yeah, I checked this in untested ... I shouldn't do that).

Re: Add Selected to serialization of CGUIListBox

Posted: Mon Jun 14, 2021 11:28 pm
by chronologicaldot
I tested it. It works. Thank you!
Edit: I noticed there's no bounds checking, which there would be if you used setSelected(), which means some funny scrolling would happen if Selected > ItemCount. lol

Re: Add Selected to serialization of CGUIListBox

Posted: Tue Jun 15, 2021 10:38 am
by CuteAlien
Yeah, I thought about it. But in general serialize values are just read in. I could have called setSelected, but then it jumps always on serializing and not sure if that's better. Bit of "there's several options, take the simplest" solution. Can change to a setSelected call if that works better for you.

Re: Add Selected to serialization of CGUIListBox

Posted: Wed Jun 23, 2021 9:39 pm
by chronologicaldot
Maybe check if the attribute Selected exists and then set if it is.

Re: Add Selected to serialization of CGUIListBox

Posted: Thu Jun 24, 2021 12:11 pm
by CuteAlien
The getAttributeAs functions in Irrlicht trunk generally do that now (one of the changes since 1.8). The last parameter passed in is now a default value which is set when the attribute is not found - so passing in the old variable value means stuff is only changed when the attribute doesn't exist.

Fatal: Not able to open ./cache/production/data_global.php