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.
Initializing "events"
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Initializing "events"
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.
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Initializing "events"
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 =)).
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 =)).
Who is online
Users browsing this forum: No registered users and 10 guests