Event managers

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
kormoran
Posts: 47
Joined: Mon Dec 28, 2015 4:50 pm
Location: Tolentino

Event managers

Post by kormoran »

I just discovered that any IGUIElement can have its own event manager. So:

1) what's the best choice? One grand super-duper Event Manager that juggles everything or many small, narrow-scoped managers?
2) should I make many managers (or just 2), how would they cooperate? What their relationship would be?

P.S. I got a ISceneNodeAnimator that all of a sudden stopped animating. I discovered the problem after a whole batch of code changes, so I can't tell exactly what I did... for now I solved the problem cutting away the culprit, but what if I do the same error later? How do I debug a node animator? :?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Event managers

Post by CuteAlien »

Irrlicht allows one event-receiver, but you can pass on events from that obviously to any class you want. Events inside gui-classes are usually so that the corresponding element handles it's own events (which only matters if you write new gui-elements).

Best choice is always the one that works best for you ;-) My way is usually to split event-receivers at least per screen. So each gui-screen which forms a dialog has one event-receiver class (which is then called from the main eventreceiver for example when that screen is visible).
And I might split it further inside that class. For example having a function called per event-type or even per gui-element.
If you need an example you can check: https://bitbucket.org/mzeilfelder/trunk_hc1/src
src/event_receiver_base.cpp has the base event-receiver. src/gui.cpp handles gui-specific events. And all the classes in src/gui_dialogs handle events per dialog.

Easiest way for debugging is usually to compile Irrlicht in debug. Then you can set breakpoints anywhere. Thought in this case it might be enough to compile your own project with debug. The animators are called in ISceneNode::OnAnimate which is implemented in the ISceneNode header, so you can maybe get all information you need already by setting a breakpoint there. The first to OnAnimate when running drawAll() is the OnAnimate for the SceneManager which will call all the other OnAnimate's.
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