Page 1 of 1

loading gui sheet doesn't work

Posted: Mon Mar 09, 2009 03:25
by Xenomorph
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!

Posted: Mon Mar 09, 2009 08:37
by scriptkid
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 :)