How to make this kind of window?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

How to make this kind of window?

Post by wsw1231 »

Image

It is quite common to see such kind of window but when it comes to do programming to make it, it seems to be quite hard.

How can the program know if the user has selected an option and then it will generate the preview?

How to make the preview? Is it a scene node? or just a 2D picture?
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Post by pandoragami »

I think example 5 for the user interface is something like that... no?
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

But example 5 does not show how to get the option that the user chose.
There are 2 possible options in the list box in example 5, which are "File open" and "Window created".

If the user clicks on window created, how can I know?
What should I do in the event receiver?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You catch the event (EGET_LISTBOX_CHANGED and EGET_LISTBOX_SELECTED_AGAIN for listboxes) in your eventreceiver and act on that. And previews are mostly 2d-images, although in RPG's for example you also often see real 3D models (probably using render-to-texture).
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
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

Code: Select all

if (listBox->getListItem(listBox->getSelected()) == L"ABC")
								Device->closeDevice();
In a list box, I have added an item called "ABC"

So, if I select "ABC", the device should be closed but it is not the case....

Is there something wrong in the if statement?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

In c++ you can't compare c-strings with ==. This will only check for identical pointers.

You have to either use a string class like core::stringw (probably easiest solution for you) or use the string-compare functions like wstrcmp.

So this should work probably:

Code: Select all

if (stringw(listBox->getListItem(listBox->getSelected())) == stringw(L"ABC")) 
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
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

CuteAlien wrote: So this should work probably:

Code: Select all

if (stringw(listBox->getListItem(listBox->getSelected())) == stringw(L"ABC")) 
Or instead of converting to Irrlicht strings, you can use strncmp from the C standard library. It's designed to do string comparisons between C-style strings.
Post Reply