Bonjour, je conçois une GUI sous irrlicht, mais j'ai un probléme avec la classe IEventReceiver. Quand je rajoute un objet IventReceiver à mon "device", les bouttons ne réagissent plus! C'est génant... mais je ne vois pas d'ou vien le probléme. Voilà le code source.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// RPG.cpp : définit le point d'entrée pour l'application console.
//
#define MENU_PRINCIPAL 0
#define RIEN 1
#define MENU_OPTION 2
#define CFG_JEU 3 //configure la partie multijoueurs
#define JEU 4
 
//id des boutons
#define CFG_PARTIE 100
#define OPTION 101
 
#include "stdafx.h"
#include "Irrlicht.h"
#pragma comment(lib,"Irrlicht.lib")
 
using namespace irr;
using namespace core;
 
irr::IrrlichtDevice *device;
irr::video::IVideoDriver *vd;
irr::scene::ISceneManager *ms;
irr::gui::IGUIEnvironment *guie;
int QueFaire = MENU_PRINCIPAL;
 
void MenuPrincipal(void);
 
class CEvent : public irr::IEventReceiver
{
public:
	virtual bool OnEvent(irr::SEvent event)
	{
		if(event.EventType == irr::EET_GUI_EVENT)
		{
			printf("EET_GUI_EVENT\n");
			return true;
		}
		return true;
	}
};
 
CEvent evt;
 
int _tmain(int argc, _TCHAR* argv[])
{
	device = irr::createDevice(irr::video::EDT_DIRECT3D9,dimension2d<s32>(800,600),16,false,false,false,0);
	vd = device->getVideoDriver();
	ms = device->getSceneManager();
	guie = device->getGUIEnvironment();
	device->setEventReceiver(&evt);
 
	while(device->run())
	{
		switch(QueFaire)
		{
		case MENU_PRINCIPAL:MenuPrincipal();break;
		default:break;
		}
		vd->beginScene(true,true,video::SColor(0,0,0,0));
		ms->drawAll();
		guie->drawAll();
		vd->endScene();
	}
 
	return 0;
}
 
void MenuPrincipal(void)
{
	QueFaire = RIEN;
	printf("Creation du menu principal\n");
	guie->addButton(rect<s32>(20,20,200,50),0,CFG_PARTIE,L"Partie multijoueurs");
	guie->addButton(rect<s32>(20,70,200,100),0,OPTION,L"Option");
}