Add Selected to serialization of CGUIListBox

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Add Selected to serialization of CGUIListBox

Post 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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Add Selected to serialization of CGUIListBox

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Add Selected to serialization of CGUIListBox

Post 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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Add Selected to serialization of CGUIListBox

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Add Selected to serialization of CGUIListBox

Post by chronologicaldot »

Maybe check if the attribute Selected exists and then set if it is.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Add Selected to serialization of CGUIListBox

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply