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
Add Selected to serialization of CGUIListBox
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Add Selected to serialization of CGUIListBox
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).
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Add Selected to serialization of CGUIListBox
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
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
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Add Selected to serialization of CGUIListBox
Maybe check if the attribute Selected exists and then set if it is.
Re: Add Selected to serialization of CGUIListBox
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm