Click here to Skip to main content
15,902,189 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionBinary file read writing problem Pin
ganesh_IT26-Aug-10 23:46
ganesh_IT26-Aug-10 23:46 
AnswerRe: Binary file read writing problem Pin
CPallini26-Aug-10 23:51
mveCPallini26-Aug-10 23:51 
AnswerRe: Binary file read writing problem Pin
ThatsAlok29-Aug-10 20:59
ThatsAlok29-Aug-10 20:59 
QuestionGUI Pin
T.RATHA KRISHNAN26-Aug-10 20:10
T.RATHA KRISHNAN26-Aug-10 20:10 
AnswerRe: GUI Pin
Niklas L26-Aug-10 22:00
Niklas L26-Aug-10 22:00 
GeneralRe: GUI Pin
T.RATHA KRISHNAN26-Aug-10 23:05
T.RATHA KRISHNAN26-Aug-10 23:05 
GeneralRe: GUI Pin
Niklas L26-Aug-10 23:22
Niklas L26-Aug-10 23:22 
GeneralRe: GUI Pin
T.RATHA KRISHNAN26-Aug-10 23:29
T.RATHA KRISHNAN26-Aug-10 23:29 
Hi!
This is my initial Menu class.

#include <irrlicht.h> 
#include "../include/InitMenu.h" 
#include "../include/OptionsMenu.h" 
#include <stdio.h> 
#include <stdlib.h> 

using namespace irr; 
using namespace core; 
using namespace video; 
using namespace gui; 
using namespace io; 
using namespace scene; 

class COptionsMenu; 
InitEventReceiver::InitEventReceiver(SInitMenuContext &context):initMenuContext(context) 
{ 

} 

bool InitEventReceiver::OnEvent(const irr::SEvent& event) 
{ 
 if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) 
 { 
  s32 idBtn = event.GUIEvent.Caller->getID(); 
  switch(idBtn) 
  { 
   case PLAY_BUTTON: 
      return true; 
      break; 
   case OPTIONS_BUTTON: 
      { 
       COptionsMenu *optMNU = new COptionsMenu(); 
      optMNU->runGame(); 
      initMenuContext.device->closeDevice(); 
      return true; 
      break; 
      } 
   case CREDITS_BUTTON: 
      return true; 
      break; 
   case EXIT_BUTTON: 
      initMenuContext.device->closeDevice(); 
      break; 
      return true; 
   default: 
      return false; 
  } 
  return true; 
 } 
 return false; 
} 

CInitMenu::CInitMenu() 
{ 
 IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9,core::dimension2d<u32>(640,480),16,false,false,false,0); 
 dev = device; 
 int width = 180; 
 int height = 50; 
 int x = (device->getVideoDriver()->getScreenSize().Width - 200)/2; 
 int y = 100; 
 SColor WHITE = video::SColor(255,255,255,255); 
 SColor BLUE = video::SColor(255,0,0,255); 
 gui::IGUISkin* skin = device->getGUIEnvironment()->createSkin(EGUI_SKIN_TYPE::EGST_WINDOWS_METALLIC); 
 skin->setColor(gui::EGDC_BUTTON_TEXT,WHITE); 
 skin->setColor(gui::EGDC_WINDOW,BLUE); 
 device->getGUIEnvironment()->setSkin(skin); 
 device->getSceneManager()->loadScene("Data/experimentalMenuSystem/Shop.irr"); 
 device->getSceneManager()->addCameraSceneNode(0,core::vector3df(0,100,0),core::vector3df(0,0,100),-1,true); 
 m_pPlayButton = device->getGUIEnvironment()->addButton(core::recti(x,y,x+width,y+height),0,PLAY_BUTTON,L"Play"); 
 y = y+height; 
 m_pOptionsButton = device->getGUIEnvironment()->addButton(core::recti(x,y,x+width,y+height),0,OPTIONS_BUTTON,L"Options"); 
 y = y+height; 
 m_pCreditsButton = device->getGUIEnvironment()->addButton(core::recti(x,y,x+width,y+height),0,CREDITS_BUTTON,L"Credits"); 
 y = y+height; 
 m_pExitButton = device->getGUIEnvironment()->addButton(core::recti(x,y,x+width,y+height),0,EXIT_BUTTON,L"Exit"); 
 initMnuContext.device = device; 
 initMnuContext.m_pPlayButton = m_pPlayButton; 
 initMnuContext.m_pOptionsButton = m_pOptionsButton; 
 initMnuContext.m_pCreditsButton = m_pCreditsButton; 
 initMnuContext.m_pExitButton = m_pExitButton; 
} 
int main(int argc, char **argv) 
{ 
 CInitMenu* cIMNU = new CInitMenu(); 
 cIMNU->runGame(); 
} 

void CInitMenu::runGame() 
{ 
 InitEventReceiver initReceiver(initMnuContext); 
 dev->setEventReceiver(&initReceiver); 
 while(dev->run()) 
 { 
  if (dev->isWindowActive()) 
  { 
   dev->getVideoDriver()->beginScene(true, true, video::SColor(0,200,200,200)); 
   dev->getSceneManager()->drawAll(); 
   dev->getGUIEnvironment()->drawAll(); 
   dev->getVideoDriver()->endScene(); 
  } 
 } 
 dev->drop(); 
} 


This is Options Menu class:

#include <irrlicht.h> 
#include "../include/OptionsMenu.h" 
#include "../include/InitMenu.h" 

//CInitMenu cIMNU; 
using namespace irr; 
using namespace core; 
using namespace video; 
using namespace gui; 
using namespace io; 
using namespace scene; 

OptionsEventReceiver::OptionsEventReceiver(SOptionsContext &optionsContext):OptionsContext(optionsContext) 
{ 

} 

bool OptionsEventReceiver::OnEvent(const irr::SEvent& event) 
{ 
 if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) 
 { 
  s32 idBtn = event.GUIEvent.Caller->getID(); 
  printf("Button Clicked: %d \n",idBtn); 
  switch(idBtn) 
  { 
   case PROFILE_BUTTON: 
      return true; 
      break; 
   case FAVOURITES_BUTTON: 
      return true; 
      break; 
   case MATCH_RESULT_BUTTON: 
      return true; 
      break; 
   case  OPTIONS_BACK_BUTTON: 
      { 
       CInitMenu *cInitMNU  = new CInitMenu(); 
      cInitMNU->runGame(); 
      OptionsContext.device->closeDevice(); 
       return true; 
      break; 
      } 
   default: 
       return false; 
  } 
  return false; 
 } 
} 

COptionsMenu::COptionsMenu() 
{ 
 IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9,core::dimension2d<u32>(640,480),16,false,false,false,0); 
 dev = device; 
 int width = 180; 
 int height = 50; 
 int x = (device->getVideoDriver()->getScreenSize().Width - 200)/2; 
 int y = 100; 
 SColor WHITE = video::SColor(255,255,255,255); 
 SColor BLUE = video::SColor(255,0,0,255); 
 gui::IGUISkin* skin = device->getGUIEnvironment()->createSkin(EGUI_SKIN_TYPE::EGST_WINDOWS_METALLIC); 
 skin->setColor(gui::EGDC_BUTTON_TEXT,WHITE); 
 skin->setColor(gui::EGDC_WINDOW,BLUE); 
 device->getGUIEnvironment()->setSkin(skin); 
 device->getSceneManager()->loadScene("Data/experimentalMenuSystem/Shop.irr"); 
 device->getSceneManager()->addCameraSceneNode(0,core::vector3df(0,100,0),core::vector3df(0,0,100),-1,true); 
 m_pPlayerProfileButton = device->getGUIEnvironment()->addButton(recti(x,y,x+width,y+height),0,PROFILE_BUTTON,L"Player Profile"); 
 y = y+height; 
 m_pFavouritesButton = device->getGUIEnvironment()->addButton(recti(x,y,x+width,y+height),0,FAVOURITES_BUTTON,L"Favorites"); 
 y = y+height; 
 m_pMatchResultButton = device->getGUIEnvironment()->addButton(recti(x,y,x+width,y+height),0,MATCH_RESULT_BUTTON,L"Match Result"); 
 m_pOptionsBackButton = device->getGUIEnvironment()->addButton(recti(0,400,192,458),0,OPTIONS_BACK_BUTTON,L"Back"); 
 optionsContext.device = device; 
 optionsContext.m_pPlayerProfileButton = m_pPlayerProfileButton; 
 optionsContext.m_pFavouritesButton = m_pFavouritesButton; 
 optionsContext.m_pMatchResultButton = m_pMatchResultButton; 
 optionsContext.m_pOptionsBackButton = m_pOptionsBackButton; 
} 

void COptionsMenu::runGame() 
{ 
 OptionsEventReceiver optReceiver(optionsContext); 
 dev->setEventReceiver(&optReceiver); 
 while(dev->run()) 
 { 
  if (dev->isWindowActive()) 
  { 
   dev->getVideoDriver()->beginScene(true, true, video::SColor(0,200,200,200)); 
   dev->getSceneManager()->drawAll(); 
   dev->getGUIEnvironment()->drawAll(); 
   dev->getVideoDriver()->endScene(); 
  } 
 } 
 dev->drop(); 
} 

GeneralRe: GUI Pin
Niklas L27-Aug-10 1:09
Niklas L27-Aug-10 1:09 
GeneralRe: GUI Pin
T.RATHA KRISHNAN27-Aug-10 2:08
T.RATHA KRISHNAN27-Aug-10 2:08 
GeneralRe: GUI Pin
Niklas L27-Aug-10 2:45
Niklas L27-Aug-10 2:45 
Questionunresolved external symbol in TAPI prog Pin
AmbiguousName26-Aug-10 10:46
AmbiguousName26-Aug-10 10:46 
AnswerRe: unresolved external symbol in TAPI prog Pin
Niklas L26-Aug-10 11:29
Niklas L26-Aug-10 11:29 
GeneralRe: unresolved external symbol in TAPI prog Pin
AmbiguousName26-Aug-10 23:09
AmbiguousName26-Aug-10 23:09 
AnswerRe: unresolved external symbol in TAPI prog Pin
«_Superman_»26-Aug-10 17:45
professional«_Superman_»26-Aug-10 17:45 
GeneralRe: unresolved external symbol in TAPI prog Pin
Niklas L26-Aug-10 20:36
Niklas L26-Aug-10 20:36 
GeneralRe: unresolved external symbol in TAPI prog Pin
AmbiguousName26-Aug-10 23:37
AmbiguousName26-Aug-10 23:37 
GeneralRe: unresolved external symbol in TAPI prog Pin
wsauer27-Aug-10 15:01
wsauer27-Aug-10 15:01 
QuestionIntel IPP static libs addition to the project Pin
Chesnokov Yuriy26-Aug-10 10:15
professionalChesnokov Yuriy26-Aug-10 10:15 
AnswerRe: Intel IPP static libs addition to the project Pin
Niklas L26-Aug-10 11:38
Niklas L26-Aug-10 11:38 
GeneralRe: Intel IPP static libs addition to the project Pin
Chesnokov Yuriy26-Aug-10 19:35
professionalChesnokov Yuriy26-Aug-10 19:35 
AnswerRe: Intel IPP static libs addition to the project Pin
«_Superman_»26-Aug-10 17:56
professional«_Superman_»26-Aug-10 17:56 
GeneralRe: Intel IPP static libs addition to the project Pin
Chesnokov Yuriy26-Aug-10 19:37
professionalChesnokov Yuriy26-Aug-10 19:37 
GeneralRe: Intel IPP static libs addition to the project Pin
«_Superman_»27-Aug-10 3:56
professional«_Superman_»27-Aug-10 3:56 
QuestionAnyone use CppCheck ? Enum 'MyEnum' hides typedef with same name... Pin
Maximilien26-Aug-10 3:32
Maximilien26-Aug-10 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.