Initializing "events"

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Eralp
Just popping in
Just popping in
Posts: 10
Joined: Fri Apr 24, 2009 17:23

Initializing "events"

Postby Eralp » Tue Apr 28, 2009 18:00

Hi , i am a little bit in trouble =) I have a gui system in mind and I dont want to code it further before deciding what to do.
I am thinking of loading layout files at the beginning of my program and when the game state changes I will change the "sheet" too.But where should I register events? in functions which cause state changes? I mean should I register them after I change the sheet?

And what happens (if it is possible to) when reregistered? player goes from menu to game and again back to menu,which can cause reregistering.And do the windows keep their registered events, even if they are inactive? Another way could be to register events when loading layouts from files, so reregistering wouldn't be a problem.

I hope you can understand :) have a nice day.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Initializing "events"

Postby CrazyEddie » Tue Apr 28, 2009 20:40

Hi, and welcome :)

If you were to register the subscribers upon entering a state, the next time you reregister the event subscribers you end up with two copies of the subscription, so the handler would be called multiple times - so probably not what you want.

You really need to keep the initialisation phase separate from 'state' changes - the event setup should probably be done at the same time you load the layout. If this is not possible, or not desirable I guess you could drop the event connections upon leaving the state, then the next time you enter that state the connections would be remade and would only exist once. The subscribeEvent function returns a CEGUI::Event::Connection object for this purpose, or you can use a CEGUI::Event::ScopedConnection object that will auto-disconnect when the object is destroyed.

HTH

CE.

Eralp
Just popping in
Just popping in
Posts: 10
Joined: Fri Apr 24, 2009 17:23

Re: Initializing "events"

Postby Eralp » Tue Apr 28, 2009 20:55

Thank you for taking time replying my question, it was helpful.
I will try to register them as I load them (if there won't be any problem like gui class doesnt know about other instances of classes or whatever, oop thing u know =)).


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 14 guests