loading gui sheet doesn't work

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

User avatar
Xenomorph
Just popping in
Just popping in
Posts: 2
Joined: Mon Mar 09, 2009 02:56

loading gui sheet doesn't work

Postby Xenomorph » Mon Mar 09, 2009 03:25

Hi everybody!
I have the following problem with my code. I load a layout for the main menu with the following code:

Code: Select all

CEGUI::Window *sheet = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"mainMenu.layout");
   
   //load image into the staticImage holder
   CEGUI::Window *background = CEGUI::WindowManager::getSingleton().getWindow("imageBackground");
   CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile("BackgroundImage", "Background.tga");
   CEGUI::DefaultWindow *staticImage = static_cast<CEGUI::DefaultWindow*>(background);
   staticImage->setProperty("Image", "set:BackgroundImage image:full_image");
mSystem->setGUISheet(sheet);

This layout has a background picture and four buttons. Now after pressing one of those buttons I want to load a different layout. I do this with the following code:

Code: Select all

CEGUI::Window *sheet = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"pilotLog.layout");

   //load image into the staticImage holder
   CEGUI::Window *background = CEGUI::WindowManager::getSingleton().getWindow("pilotLogimageBackground");
   CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile("BackgroundImage", "Background.tga");
   CEGUI::DefaultWindow *staticImage = static_cast<CEGUI::DefaultWindow*>(background);
   staticImage->setProperty("Image", "set:BackgroundImage image:full_image");
   mSystem->setGUISheet(sheet);

Now this window doesn't load for some reason. The screen just freezes, so I tried to load the ogregui.layout file instead like:

Code: Select all

CEGUI::Window *sheet = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"ogregui.layout");
mSystem->setGUISheet(sheet);

This works fine. So I thought I might have done something wrong with my second layout, so I tried to make a new layout with only one button and I tried to load this and it froze again. I really don't know why it doesn't load the other layout if it is one of mine. It loads the ogregui layout. It's just weird.
Am I doing something wrong? Do I have to destroy the first window before loading the second one? I don't know.
Any help would really be appreciated.
Btw I used the CE Layout Manager to create the layouts.
Thanks in advance!

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon Mar 09, 2009 08:37

Hi and welcome,

this seems to be the offending line:

Code: Select all

CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile("BackgroundImage", "Background.tga");

Because the imageset with the name "BackgroundImage" already/still exists. Just remove that second call or make this call before loading your 2nd layout:

Code: Select all

CEGUI::ImagesetManager::getSingletonPtr()->destroyImageset("BackgroundImage");


BTW your Cegui.log file will show this error too. Also, try to put Cegui calls beteen a "try ... catch (CEGUI::Exception)" block.

HTH :)
Check out my released snake game using Cegui!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests