Hello ALL
Actually I am using Irrlicht I made checkboxes in my game. So I want to do another process when one of the checkboxes is checked. I can not handle it... Is there anyone help me
Check box usage method
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
If all graphics rendering stays within the main thread, there's no problem with having multi-threading with Irrlicht. So just use the thread API you like and spawn the threads at the proper place. Probably in the event receiver. You need to take care of the thread joining somewhere else, in order to delete them for sure in the end.
hi
hI THANKS FOR YOUR REPLIES BUT I CAN NOT DO IT TILL .
THIS IS MY CODE. SO CAN YOU SUGGEST SOMETHING TO DO:
WHAT I WANT TO IS THAT "WHEN FIRST CHECKBOX IS CHECKED SHOW THE BUTTON WHICH IS "YES THAT'S RIGHT"
}
THANKS FOR YOUR KIND REPLY
THIS IS MY CODE. SO CAN YOU SUGGEST SOMETHING TO DO:
WHAT I WANT TO IS THAT "WHEN FIRST CHECKBOX IS CHECKED SHOW THE BUTTON WHICH IS "YES THAT'S RIGHT"
}
Code: Select all
if (event.EventType==irr::EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* guienv=device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
{
IGUICheckBox* chk = (IGUICheckBox*)guienv->getRootGUIElement()->getElementFromId(MYGUI_BOLD,true);// enen deer ochood button press hiigdeh yum baina
bool bold = true;//chk->isChecked();
if(bold)
{
ch = (IGUIButton*)guienv->getRootGUIElement()->getElementFromId(MYGUI_HELPBUTTON,true);
}
IGUICheckBox* chk1 = (IGUICheckBox*)guienv->getRootGUIElement()->getElementFromId(MYGUI_ITALIC,true);
bool italic = chk1->isChecked();
IGUICheckBox* chk2 = (IGUICheckBox*)guienv->getRootGUIElement()->getElementFromId(MYGUI_ALPHA,true);
bool alpha = chk2->isChecked();
IGUICheckBox* chk3 = (IGUICheckBox*)guienv->getRootGUIElement()->getElementFromId(MYGUI_ANTIALIAS,true);
bool aa = chk3->isChecked();
// vector fonts disabled
//chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_VECTOR,true);
//bool vec = false;//chk->isChecked()
}
case EGET_CHECKBOX_CHANGED:
if(id==MYGUI_BOLD)
{
//{
//IGUICheckBox* chk = 0;
IGUICheckBox* ch = (IGUICheckBox*)event.GUIEvent.Caller;
//if(bold)
//{
//
// ch = (IGUIButton*)guienv->getRootGUIElement()->getElementFromId(MYGUI_HELPBUTTON,true);
}
}
...
guienv->addGUIElement("GUIEditor");
IGUIWindow *win =guienv->addWindow(core::rect<s32>(10,10,260,220), true, L"Good Luck for your Test",0, -1);
win->getCloseButton()->setVisible(false);
IGUISkin *skin = guienv->createSkin(EGST_WINDOWS_CLASSIC);
guienv->setSkin(skin);
//if(guienv)
//{
guienv->addButton(core::rect<s32>(35,35,200,50), 0, 0, L"Please choose right word" );
//guienv->addCheckBox(true, rect<s32>(35,35,80,100), 0,0, L"Star");
s32 xs=10,xp=xs, yp=50, h=20;
// bold checkbox
guienv->addCheckBox(false, core::rect<s32>(xp,yp,xp+60,yp+yp),win, MYGUI_BOLD, L"sar");
xp += 45;
// italic checkbox
guienv->addCheckBox(false, core::rect<s32>(xp,yp,xp+80,yp+yp),win, MYGUI_ITALIC, L"nar");
xp += 45;
// AA checkbox
guienv->addCheckBox(false, core::rect<s32>(xp,yp,xp+80,yp+yp),win, MYGUI_ANTIALIAS, L"mangar");
xp +=40;
// Alpha checkbox
guienv->addCheckBox(false, core::rect<s32>(xp,yp,xp+80,yp+yp),win, MYGUI_ALPHA, L"teneg");
xp = xs;
yp += (s32)(h*1.5f);
device->getCursorControl()->setVisible(true);
device->sleep(5, true);
}
if(ch)
{
guienv->addButton(core::rect<s32>
(35,35,200,50), 0, 0, L"Yes That's right" );
}
//win->setVisible(false);
I can not understand
Hello all
Again I can not handle this What I want is that when checked visible checkbox button which is named button should disappear and following enable... But it can not do it. Can you guys look over it?????????
Again I can not handle this What I want is that when checked visible checkbox button which is named button should disappear and following enable... But it can not do it. Can you guys look over it?????????
Code: Select all
#include <irrlicht.h>
#include <iostream>
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
enum GUI
{
GUI_ID_CHECKBOX_VISIBLE,
GUI_ID_CHECKBOX_ENABLED,
};
IrrlichtDevice * device;
array<IGUIElement*> mGuiElements;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == irr::EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_CHECKBOX_CHANGED:
{
IGUICheckBox *cb = (IGUICheckBox*) event.GUIEvent.Caller;
switch ( id )
{
case GUI_ID_CHECKBOX_VISIBLE:
for ( u32 i=0; i < mGuiElements.size(); ++i )
{
mGuiElements[i]->setVisible( cb->isChecked() );
}
break;
case GUI_ID_CHECKBOX_ENABLED:
for ( u32 i=0; i < mGuiElements.size(); ++i )
{
mGuiElements[i]->setEnabled( cb->isChecked() );
}
break;
default:
break;
}
break;
}
default:
break;
}
}
return false;
}
};
void AddTestGuiElements(IGUIEnvironment* env, IGUIElement * parent) // this is a function
{
mGuiElements.push_back( env->addToolBar (parent, /*s32 id=*/-1) );
s32 top = 40;
s32 default_height = 15;
s32 default_width = 150;
s32 default_gap = 30;
core::rect<s32> rect(10, top, 10 + default_width, top + default_height);
mGuiElements.push_back( env->addButton (rect, parent, /*s32 id=*/-1, /*const wchar_t *text=*/L"button", /*const wchar_t *tooltiptext=*/L"tooltip") );
rect.UpperLeftCorner.Y = rect.LowerRightCorner.Y + default_gap;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + default_height;
mGuiElements.push_back( env->addButton (rect, parent, /*s32 id=*/-1, /*const wchar_t *text=*/L"button", /*const wchar_t *tooltiptext=*/L"tooltip") );
}
void AddControlElements(IGUIEnvironment* env, IGUIElement * parent)
{
env->addStaticText (/*const wchar_t *text*/L"", rect<s32>(500, 50, 630, 480), /*bool border=*/true, /*bool wordWrap=*/false, parent, /*s32 id=*/-1,/* bool fillBackground=*/false);
env->addCheckBox (/*bool checked*/true, rect<s32>(510, 60, 620, 80), parent, /*s32 id=*/GUI_ID_CHECKBOX_VISIBLE, /*const wchar_t *text=*/L"visible");
env->addCheckBox (/*bool checked*/true, rect<s32>(510, 100, 620, 120), parent, /*s32 id=*/GUI_ID_CHECKBOX_ENABLED, /*const wchar_t *text=*/L"enabled");
}
int main()
{
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
AddTestGuiElements(env, 0);
MyEventReceiver receiver();
// device->setEventReceiver(&receiver);
AddControlElements(env, 0);
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}
well, what should this be about :
GUI_ID_CHECKBOX_VISIBLE and GUI_ID_CHECKBOX_ENABLED are not related to event.GUIEvent.EventType in any way !!!
where do you set GUI_ID_CHECKBOX_VISIBLE or GUI_ID_CHECKBOX_ENABLED for the event type !?!?!
Code: Select all
switch(event.GUIEvent.EventType)
case GUI_ID_CHECKBOX_VISIBLE:
for ( u32 i=0; i < mGuiElements.size(); ++i )
{
mGuiElements[i]->setVisible( cb->isChecked() );
}
break;
case GUI_ID_CHECKBOX_ENABLED:
for ( u32 i=0; i < mGuiElements.size(); ++i )
{
mGuiElements[i]->setEnabled( cb->isChecked() );
}
break;
}
where do you set GUI_ID_CHECKBOX_VISIBLE or GUI_ID_CHECKBOX_ENABLED for the event type !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java