using gui in irrwizard,gui no response?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
superpop
Posts: 21
Joined: Mon May 14, 2007 1:17 pm

using gui in irrwizard,gui no response?

Post by superpop »

gui no response

i using irrwizard in my project,for using irrlicht gui,i did modify the code:
in class GameState,

displace

Code: Select all

virtual void MouseEvent(CGameManager* pManager,const SEvent& event) = 0;
	virtual void KeyboardEvent(CGameManager* pManager,const SEvent& event) = 0;
with

Code: Select all

	virtual bool OnEvent(CGameManager* pManager,const SEvent& event) = 0;

so

Code: Select all

bool CGameManager::OnEvent(const SEvent& event)
{
	if (!m_pDriver)
		return false;

	if (event.EventType == EET_KEY_INPUT_EVENT)
	{
		
		m_pGameState->OnEvent(this,event);
			

	}
	else if (event.EventType == EET_MOUSE_INPUT_EVENT)
	{
		m_pGameState->OnEvent(this,event);
	}
	else if (event.EventType == EET_GUI_EVENT)
	{
		
		m_pGameState->OnEvent(this,event);
	}

	return true;
}


bool CGameMenuState::OnEvent(CGameManager* pManager,const SEvent& event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown == false)
	{
		if (event.KeyInput.Key == KEY_ESCAPE)
		{
			pManager->getDevice()->closeDevice();
		}
		else if ( event.KeyInput.Key == KEY_F1)
		{
			ChangeState(pManager, CGameStateLoad01::Instance());
		}
	}
	if (event.EventType == EET_GUI_EVENT)
	{
		s32 id = event.GUIEvent.Caller->getID();

		switch(event.GUIEvent.EventType)
		{
		case EGET_BUTTON_CLICKED:
			switch(id)
			{
			case 101:
				ChangeState(pManager, CGameStateLoad01::Instance());
				break;
			case 102:
				break;
			case 103:
				ChangeState(pManager, CGameCreditsState::Instance()); 
			    break;
			case 104:
				pManager->getDevice()->closeDevice();
			    break;
			default:
			    break;
			}
			break;
		default:
		    break;
		}
	}
	return false;
}

void CGameMenuState::Init(CGameManager * pManager)
{

	CGameState::Init(pManager);

	LoadMouseCursor(pManager);
	// to display mouse crusor
	pManager->getDevice()->getCursorControl()->setVisible(true);


	m_pIntroImage = pManager->getGUIEnvironment()->addImage(irr::core::rect< irr::s32 >(256,30,1024,768));
	m_pIntroImage->setImage(pManager->getDriver()->getTexture("media/intro.jpg"));

	m_pPlayButton = pManager->getGUIEnvironment()->addButton(core::rect< irr::s32 >(400,448,580,518),0,GUI_ID_PLAY_BUTTON);
	m_pPlayButton->setImage(pManager->getDriver()->getTexture("media/buttons/but_play.bmp"));
	m_pPlayButton->setPressedImage(pManager->getDriver()->getTexture("media/buttons/but_play_on.bmp"));

	// add other button
	.....

}

This project can be compiled to run well,If use the keyboard,Can switch to different scenes,gui make no any response when mouse click。int fact,in menu state i add the code:

Code: Select all

pManager->getDevice()->getCursorControl()->setVisible(true),
do not see the mouse cursor,i switch to a 3d scene,could see the mouse cursor,i use a 3rd camera,but the gui no response too,others Other features work well,
where is wrong?
i breakpoint at

Code: Select all

CGameMenuState::OnEvent or CGameManager.
s32 id = event.GUIEvent.Caller->getID();
the id always is -1,in fact the event catch nothing.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Is CGameManager the eventreceiver which you pass on to Irrlicht? In that case you should not "return true" in it. Returning true means that events will no further be processed - so you prevent for example that the Irrlicht GUI does receive the mouse-events. Do return false instead.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
superpop
Posts: 21
Joined: Mon May 14, 2007 1:17 pm

Post by superpop »

CuteAlien wrote:Is CGameManager the eventreceiver which you pass on to Irrlicht? In that case you should not "return true" in it. Returning true means that events will no further be processed - so you prevent for example that the Irrlicht GUI does receive the mouse-events. Do return false instead.
I have done as you said, but does not work
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Hm, then I guess I can't help. I don't know anything about irrwizard or what exactly you are trying to do there.

I would propose you debug it. Either set breakpoints in the eventreceiver and see what happens or add debug-messages all over the place so you know which code is called and which isn't.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply