Retrieve a non-default gui context[SOLVED]

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

Jefferian
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Wed May 08, 2013 21:55

Retrieve a non-default gui context[SOLVED]

Postby Jefferian » Tue Aug 27, 2013 15:48

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?
Last edited by Jefferian on Fri Aug 30, 2013 09:33, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Retrieve a non-default gui context

Postby Kulik » Tue Aug 27, 2013 16:18

You are supposed to store the reference yourself. GUI contexts don't have names so it would be problematic to retrieve them.

Jefferian
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Wed May 08, 2013 21:55

Re: Retrieve a non-default gui context

Postby Jefferian » Tue Aug 27, 2013 21:04

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.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Retrieve a non-default gui context

Postby Kulik » Tue Aug 27, 2013 22:14

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())
{}

Jefferian
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Wed May 08, 2013 21:55

Re: Retrieve a non-default gui context

Postby Jefferian » Wed Aug 28, 2013 08:43

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.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 8 guests