Code: Select all
//includes
#include <irrlicht.h>
//namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//not sure about this bit
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
//this is need for the gui
IrrlichtDevice *device = 0;
s32 cnt = 0;
IGUIListBox* listbox = 0;
//event reciever
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* guienv = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 101)
{
//problem here
guienv->clear();
guienv->addButton(rect<s32>(104, 64, 320, 96), 0, -1, L"Back");
guienv->addStaticText(L"Story mode in develpoment", rect<s32>(104, 32, 320, 52), false, false, 0, -1);
return true;
}
}
}
}
};
//main bit for drawing
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 32, true, false, false, 0);
device->setWindowCaption(L"Window");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addButton(rect<s32>(88, 200, 304, 240), 0, 4, L"Exit");
guienv->addButton(rect<s32>(88, 152, 304, 192), 0, 3, L"Options");
guienv->addButton(rect<s32>(88, 104, 304, 144), 0, 2, L"Multiplayer");
guienv->addButton(rect<s32>(88, 56, 304, 96), 0, 101, L"Story Mode");
guienv->addStaticText(L"Game menu", rect<s32>(88, 16, 304, 36), false, false, 0, -1);
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
}