Code: Select all
/*
Comment Header
Source Generated by DracSoft Irrlicht GUI Designer
http://www.dracsoft.com/
support@dracsoft.com
*/
#include <irrlicht.h>
using namespace irr;
using namespace gui;
using namespace video;
using namespace scene;
using namespace core;
using namespace io;
//********************
//EVENT RECEIVER CLASS
//********************
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
//GUI EVENT
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{//MMMMMMM buttons start here
case EGET_BUTTON_CLICKED:
if (id == 101)
{
//handle first button code here
mydevice->closeDevice();
return true;
//*****************************//
//THIS IS WHERE IT DOESNT WORK//
}
break;
}
}
return false;
}
};
//******************
//IRRLICHT VARIABLES
//******************
IrrlichtDevice *mydevice;
IVideoDriver *mydriver;
ISceneManager *myscene;
IGUIEnvironment *mygui;
//****************
//GLOBAL FUNCTIONS
//****************
bool InitializeVideo()
{
//INITIALIZE VIDEO DEVICE
{ //OpenGL didn't work, try software
mydevice = irr::createDevice(EDT_SOFTWARE, dimension2d<s32>(700,480),32,false,true,false);
if (mydevice==0) //Software didn't work, the computer blows so quit
return false;
}
mydevice->setResizeAble(false);
return true;
}
void RenderAll()
{
mydriver->beginScene(true, true, SColor(255,255,255,255));
myscene->drawAll();
mygui->drawAll();
mydriver->endScene();
}
//*********************
//MAIN PROGRAM FUNCTION
//*********************
int main()
{
//start video
if (!InitializeVideo())
return 1;
//get video driver and scene manager
mydriver = mydevice->getVideoDriver();
myscene = mydevice->getSceneManager();
mygui = mydevice->getGUIEnvironment();
//declare event reciever
MyEventReceiver receiver;
mydevice->setEventReceiver(&receiver);
mydevice->setWindowCaption(L"Slayer- One Strike. One kill.");
//create the GUI
mygui->addStaticText(L"Version alpha-0.1", rect<s32>(272, 200, 368, 220), false, false, 0, -1);
mygui->addButton(rect<s32>(72, 344, 168, 384), 0, -101, L"Exit");
mygui->addButton(rect<s32>(72, 296, 168, 336), 0, -102, L"Credits");
mygui->addButton(rect<s32>(72, 248, 168, 288), 0, -103, L"Controls");
mygui->addButton(rect<s32>(72, 200, 168, 240), 0, -104, L"Play Game");
IGUIImage *img501 = mygui->addImage(rect<s32>(72, 40, 372, 190), 0, -1, L"");
img501->setImage(mygui->getVideoDriver()->getTexture("C:/irrlicht-0.7/media/Slayerlogo.jpg"));
//start updating the screen
while(mydevice->run())
{
RenderAll();
}
//do cleanup
mydevice->drop();
return 0;
}