Page 1 of 1
Retrieve a non-default gui context[SOLVED]
Posted: Tue Aug 27, 2013 15:48
by Jefferian
Basically...as the title says. If i wanted to retrieve the default one, all i need to do is call getDefaultGUIContext. By doing so i get a reference to the default one.
But there is no similar function for ones created manually. The only reference to them is given when you manually create them. And i need some way to retrieve it when i need to check for inputs or some other thing.
So...how am i supposed to work with them, design-wise?
Re: Retrieve a non-default gui context
Posted: Tue Aug 27, 2013 16:18
by Kulik
You are supposed to store the reference yourself. GUI contexts don't have names so it would be problematic to retrieve them.
Re: Retrieve a non-default gui context
Posted: Tue Aug 27, 2013 21:04
by Jefferian
Kulik wrote:You are supposed to store the reference yourself. GUI contexts don't have names so it would be problematic to retrieve them.
And being a reference i can't simply have it as a class member of the state it belongs to - unlike a pointer. As it is created inside it, where a reference would have to be passed at initializiation to be a class member. Guess i've got to think of some other way to store it. Maybe a separate class to handle those context references.
Well, thanks for the reply.
Re: Retrieve a non-default gui context
Posted: Tue Aug 27, 2013 22:14
by Kulik
Code: Select all
GUIContext* context = &CEGUI::System::getSingleton().createGUIContext();
You can store them as a class member if you do this in a ctor initialiser list.
Code: Select all
SomeClass::SomeClass():
mMyGUIContext(CEGUI::System::getSingleton().createGUIContext())
{}
Re: Retrieve a non-default gui context
Posted: Wed Aug 28, 2013 08:43
by Jefferian
Kulik wrote:Code: Select all
GUIContext* context = &CEGUI::System::getSingleton().createGUIContext();
You can store them as a class member if you do this in a ctor initialiser list.
Code: Select all
SomeClass::SomeClass():
mMyGUIContext(CEGUI::System::getSingleton().createGUIContext())
{}
Uh, i was somehow convinced the first option wasn't actually feasible. Nice to see i was wrong, cause that's exactly what i needed. Thank you very much.