Tutorial 9 Question, I dont understand how the gui is made

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
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Tutorial 9 Question, I dont understand how the gui is made

Post by MasterM »

Hey,
I was reading the Meshtutorial/Tutorial 9 and i notice that the menu is builded like this

Code: Select all

// create menu
        gui::IGUIContextMenu* menu = env->addMenu();
        menu->addItem(L"File", -1, true, true);
        menu->addItem(L"View", -1, true, true);
        menu->addItem(L"Camera", -1, true, true);
        menu->addItem(L"Help", -1, true, true);

        gui::IGUIContextMenu* submenu;
        submenu = menu->getSubMenu(0);
        submenu->addItem(L"Open Model File & Texture...", 100);
        submenu->addItem(L"Set Model Archive...", 101);
        submenu->addItem(L"Load as Octree", 102);
        submenu->addSeparator();
        submenu->addItem(L"Quit", 200);

        submenu = menu->getSubMenu(1);
        submenu->addItem(L"sky box visible", 300, true, false, true);
        submenu->addItem(L"toggle model debug information", 400, true, true);
        submenu->addItem(L"model material", -1, true, true );

        submenu = submenu->getSubMenu(1);
        submenu->addItem(L"Off", 401);
        submenu->addItem(L"Bounding Box", 410);
        submenu->addItem(L"Normals", 420);
        submenu->addItem(L"Skeleton", 430);
        submenu->addItem(L"Wire overlay", 440);
        submenu->addItem(L"Half-Transparent", 450);
        submenu->addItem(L"Buffers bounding boxes", 460);
        submenu->addItem(L"All", 499);

        submenu = menu->getSubMenu(1)->getSubMenu(2);
        submenu->addItem(L"Solid", 610);
        submenu->addItem(L"Transparent", 620);
        submenu->addItem(L"Reflection", 630);

        submenu = menu->getSubMenu(2);
        submenu->addItem(L"Maya Style", 1000);
        submenu->addItem(L"First Person", 1100);

        submenu = menu->getSubMenu(3);
        submenu->addItem(L"About", 500);
What i don't understand is that it gets the submenu and then it gives it some items(well i understand that one)...and then i gets another submenu and gives that submenu its items(i also get that one,lol)...but its kinda confusing when i think about it cause wud'int it be better to do

Code: Select all

submenu1=menu->getSubMenu(1);
and submenu2=menu->getSubMenu(2);
Is there a reason why the Tutorial 9 creators did it the way they did it?
Thanks in advanced.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Tutorial 9 Question, I dont understand how the gui is ma

Post by sudi »

MasterM wrote: Is there a reason why the Tutorial 9 creators did it the way they did it?
Thanks in advanced.
Because they can...
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Why put 6 4-byte (or possibly 8-byte) pointers onto the stack when you can use 1? It's a simple as that. The way you specify is no optimization, in fact it is completely opposite, thus this is the reason they probably opted for that way.
TheQuestion = 2B || !2B
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

to be honest i think they were just lazy^^
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Tutorials DON'T follow recommended practices. They are made for ease of understanding, and should not be copied word for word in actual projects (Think NEHE, only for Irrlicht).
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

Ok, that makes more sense
Thanks for answering everyone :)
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
thespecial1
Posts: 135
Joined: Thu Oct 30, 2008 11:56 am
Location: UK
Contact:

Post by thespecial1 »

MasterM wrote:C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse

understatement of the year, price of the power
Post Reply