www.pudn.com > ICE_1.4.zip > gs_optionmenu.cpp
// Class automatically generated by Dev-C++ New Class wizard
#include "gs_optionmenu.h" // class's header file
irr::gui::IGUIButton* gs_OptionMenu::m_btn_done = NULL;
irr::gui::IGUICheckBox* gs_OptionMenu::m_chk_hideconf = NULL;
irr::gui::IGUIScrollBar* gs_OptionMenu::m_scr_level = NULL;
irr::gui::IGUIStaticText* gs_OptionMenu::m_txt_scrLevelTxt = NULL;
// class constructor
//gsr_Intro::gs_Intro(IrrlichtDevice* dv, video::IVideoDriver *dr) : game_State(dv, dr)
gs_OptionMenu::gs_OptionMenu(game_StateHandler*handler) : game_State(handler)
{
using namespace irr;
//TODO: get resolution from device, and set pos according to that
int btn_x = 200 ;
int btn_y = 200 ;
#define BTN_ROW_SPACING 40
#define BTN_W 90
#define BTN_H 30
if(!m_btn_done) {
m_btn_done = m_env->addButton(core::rect(btn_x, btn_y, btn_x + BTN_W, btn_y + BTN_H), 0, GSO_GUI_BTN_DONE, L"Done");
btn_y -= BTN_ROW_SPACING; // move up
m_chk_hideconf = m_env->addCheckBox ( (ICE_Options::getConfig("configured") == "T") ,
core::rect(btn_x, btn_y, btn_x + BTN_W*2, btn_y + BTN_H), 0, GSO_GUI_CHK_HIDECONF,
L"Hide Configuration Screen" ) ;
btn_y -= BTN_ROW_SPACING; // move up
m_scr_level = m_env->addScrollBar(true, core::rect(btn_x, btn_y, btn_x + BTN_W*3, btn_y + BTN_H), 0, GSO_GUI_SCR_LEVEL);
m_scr_level->setMax( 20 );
btn_y -= BTN_ROW_SPACING/2; // move up
m_txt_scrLevelTxt = m_env->addStaticText(L"Difficulty:", false, core::rect(btn_x, btn_y, btn_x + BTN_W*2, btn_y + BTN_H) );
}else {
m_btn_done->setVisible(true);
m_chk_hideconf->setVisible(true);
m_txt_scrLevelTxt->setVisible(true);
m_scr_level->setVisible(true);
}
//set level of difficulty scroll bar to options's setting
m_scr_level->setPos( 0 ); //tetris_Options::getCurrLevel() );
}
// class destructor
gs_OptionMenu::~gs_OptionMenu()
{
if(m_btn_done) {
m_btn_done->setVisible(false);
m_chk_hideconf->setVisible(false);
m_txt_scrLevelTxt->setVisible(false);
m_scr_level->setVisible(false);
}
}
void gs_OptionMenu::Render() {
using namespace irr;
m_driver->beginScene(true, true, OPTIONMENU_BGCOLOR);
m_env->drawAll();
m_driver->endScene();
}
#include
bool gs_OptionMenu::onEvent(irr::SEvent event) {
using namespace irr;
using namespace gui;
if (event.EventType == EET_GUI_EVENT) {
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) {
case EGET_BUTTON_CLICKED:
if(id == GSO_GUI_BTN_DONE) {
m_handler->RequestStateChange(GS_INTRO);
return true;
}
break;
case EGET_CHECKBOX_CHANGED :
if(id == GSO_GUI_CHK_HIDECONF) { //change configured setting
if(ICE_Options::getConfig("configured") == "T")
ICE_Options::setConfig("configured", "F");
else
ICE_Options::setConfig("configured", "T");
return true;
}
break;
case EGET_SCROLL_BAR_CHANGED:
if(id == GSO_GUI_SCR_LEVEL) {
s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
//ICE_Options::setDifficultyLevel(pos);
//printf("difficulty level set: %d\n", pos);
return true;
}
break;
}//end switch: type of GUI event
}//end if: GUI event
return false;
}
void gs_OptionMenu::Update() {
}