Code: Select all
device = createDevice ( video::EDT_OPENGL,
core::dimension2d<s32>( 1024, 768 ), 16, false, false, this );
Code: Select all
device = createDevice ( video::EDT_OPENGL,
core::dimension2d<s32>( 1024, 768 ), 16, false, false, this );
Code: Select all
device = createDevice ( video::EDT_OPENGL,
core::dimension2d<s32>( 1024, 768 ), 16, false, false, this );
Code: Select all
bool CMenu::run ( )
{
printf ( "Attempting to create a device...\n");
device = createDevice ( video::EDT_OPENGL,
core::dimension2d<s32>( 1024, 768 ), 16, false, true, 0 );
printf ( "Device created [SUCCESS]\n" );
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
env->addButton ( core::rect<s32> ( 10,210, 100, 240 ), 0, 102, L"New Game" );
env->addButton ( core::rect<s32> (10, 250, 100, 290 ), 0, 103, L"Load Game" );
env->addButton ( core::rect<s32> (10, 300, 100, 340 ), 0, 101, L"Quit" );
printf ( "Entering menu loop...\n" );
while ( device->run() && driver )
{
if ( device->isWindowActive() )
{
driver->beginScene( true, true, video::SColor( 0, 122, 65, 171 ) );
env->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}
Code: Select all
bool CMenu::OnEvent ( SEvent event )
{
cnt = 0;
if ( event.EventType == EET_GUI_EVENT )
{
s32 id = event.GUIEvent.Caller->getID();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
switch ( event.GUIEvent.EventType )
{
case gui::EGET_BUTTON_CLICKED:
if ( id == 101 )
{
device->closeDevice();
return true;
}
if ( id == 102 )
{
gui::IGUIWindow* window = env->addWindow (
core::rect<s32> ( 100 + cnt, 100 + cnt, 300 + cnt, 360 + cnt),
true, //modal
L"Start a new game");
env->addStaticText ( L"Select difficulty level",
core::rect<s32>( 35, 35, 140, 50),
true, //border?
false, //wordwrap?
window);
env->addButton ( core::rect<s32>( 35, 55, 140, 85 ),
window, 121,
L"Baby" );
env->addButton ( core::rect<s32>( 35, 90, 140, 120 ),
window, 122,
L"Teen" );
env->addButton ( core::rect<s32>( 35, 125, 140, 155 ),
window, 123,
L"Mature" );
return true;
}
if ( id == 103 )
{
openDialog = env->addFileOpenDialog ( L"Select save file to load",
true, //modal
0, //parent
131 );
}
if ( id == 121 )
difficultyLevel = 1;
if ( id == 122 )
difficultyLevel = 2;
if ( id == 123 )
difficultyLevel = 3;
break;
case gui::EGET_FILE_SELECTED:
env->addMessageBox ( L"The file you selected was:",
openDialog->getFilename(),
true,
gui::EMBF_OK,
0, 221 );
break;
}
}
}