Page 1 of 1

Alternative to setGUISheet?

Posted: Sun May 21, 2006 19:55
by Duck
So far, I've managed to get a few main UI screens working. I can click buttons and go forward and backward between them.

I now want to be able to show modal message boxes over the top, for instance an 'Are you sure? Yes/No' window. I'd like the main menu screen to still be visible in the background, but be unresponsive.

I'm switching main menu screens by calling:

Code: Select all

   CEGUI::System::getSingleton().setGUISheet( sheet );


If I use this for my message box, the message box appears, but I lose the menu behind.

I tried to remove my calls to setGUISheet, in the hope that I could just manually control the visibility and enabled state as I switch around. However I can't find another way to make my windows appear other than setGUISheet.

I've already tried these tempting functions:

Code: Select all

   sheet->activate( );
   sheet->show( );



Fwiw, I'm using the layout editor to build my sheets. currently I just call:

Code: Select all

   CEGUI::WindowManager::getSingleton().loadWindowLayout( filename )

and then setGUISheet.

If someone could point me in the right direction, that would be great.

Thanks,
Duck

Posted: Sun May 21, 2006 20:24
by Gaal
In order to manage all my Dialog windows, here is what I'm doing :

First, I initialise a general "default window" with the following code :

Code: Select all

mGUI = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 0);
mGUISystem = new CEGUI::System(mGUI);
CEGUI::SchemeManager::getSingleton().loadScheme(schema);
mGUISystem->setDefaultMouseCursor(lookMouse, mouseCurseur);
mGUISystem->setDefaultFont(fontDefaut);
mRootGuiSheet = CEGUI::WindowManager::getSingleton().createWindow("DefaultGUISheet", "root");
mGUISystem->setGUISheet(mRootGuiSheet);


When the Ogre sceneManager is known I call

Code: Select all

mGUI->setTargetSceneManager(mSceneMgr);


Then each time I need a dialog window (such as a messageBox, or inputBox like in VB) I do the following:

Code: Select all

mWinDialog = CEGUI::WindowManager::getSingleton().loadWindowLayout("MsgBox.xml", mIdent);
mGUISystem->addChildWindow(mWinDialog);
mWinDialog->addEvent(EventReponse);
mWinDialog->setModalState(true);

EventReponse being an event fired by the dialog

Then with a set of appropriate methodes such as:

Code: Select all

bool handleMsgBoxReponse(const CEGUI::EventArgs& e)
{
   const MsgEventArgs& msgArgs = static_cast<const MsgEventArgs&>(e);
   if (msgArgs.reponse == MSG_REP_OUI)
   {
      <process the answer Yes...>;
   } else {
      <process the answer No...>;
   }
   return true;
}

I can manage all my dialogs...

Hope it help

Posted: Mon May 22, 2006 02:24
by Duck
Great,

Code: Select all

mGUISystem->addChildWindow(mWinDialog)


This was the bit I was missing.
So I now still use setGUISheet for changing the main page, but will just add/remove the temporary message boxes as child windows...

Thanks!

Posted: Mon May 22, 2006 06:50
by scriptkid
Hi,

good to hear you have a found a solution :-)

You might also be interested in this link:
http://www.cegui.org.uk/wiki/index.php/DialogSystem

Have fun.