The debugger pointed to this line being the "violater":
Code: Select all
io::IXMLReader* xml = device->getFileSystem()->createXMLReader("settings.xml");
Code: Select all
#include "include/irrlicht.h"
#include "include/irrxml.h"
#include <string>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
IrrlichtDevice *device = 0;
core::stringw width;
core::stringw height;
core::stringw name;
core::stringw slogan;
s32 cnt = 0;
IGUIListBox* listbox = 0;
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 == 1)
{
guienv->clear();
guienv->addButton(rect<s32>(88, 64, 304, 96), 0, 5, L"Back");
guienv->addStaticText(L"Story mode in develpoment", rect<s32>(88, 16, 304, 36), false, false, 0, -1);
return true;
}
if (id == 2)
{
guienv->clear();
guienv->addButton(rect<s32>(88, 64, 304, 96), 0, 5, L"Back");
guienv->addStaticText(L"Multiplayer mode in develpoment", rect<s32>(88, 16, 304, 36), false, false, 0, 5);
}
if (id == 5)
{
guienv->clear();
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, 1, L"Story Mode");
guienv->addStaticText(L"Game menu", rect<s32>(88, 16, 304, 36), false, false, 0, -1);
}
if (id == 4)
{
device->closeDevice();
}
if (id == 3)
{
guienv->clear();
}
}
}
return false;}
};
int main()
{
//XML settisdaadasdngs reader
// read configuration from xml file
io::IXMLReader* xml = device->getFileSystem()->createXMLReader("settings.xml");
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case io::EXN_TEXT:
// in this xml file, the only text which occurs is the messageText
//MessageText = xml->getNodeData();
break;
case EXN_ELEMENT:
{
if (core::stringw("windowsize") == xml->getNodeName())
{
width = xml->getAttributeValue(L"width");
height = xml->getAttributeValue(L"width");
}
else
if (core::stringw("userdata") == xml->getNodeName())
{
name = xml->getAttributeValue(L"name");
slogan = xml->getAttributeValue(L"slogan");
}
}
break;
}
}
if (xml)
xml->drop(); // don't forget to delete the xml reader
//End XML settings reader
MyEventReceiver receiver;
device = createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 32, true, false, false, &receiver);
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, 1, L"Story Mode");
guienv->addStaticText(L"WW2D", rect<s32>(88, 10, 304, 36), false, false, 0, -1);
guienv->addStaticText(L"Game menu", rect<s32>(88, 16, 304, 36), false, false, 0, -1);
/*IGUIImage *img501 = guienv->addImage(rect<s32>(168, 40, 268, 65), 0, -1, L"");
img501->setImage(guienv->getVideoDriver()->getTexture("C:/Documents and Settings/Sameh/My Documents/My Pictures/button.png"));*/
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
}