Page 1 of 1

Problem closing window

Posted: Thu Dec 28, 2006 23:57
by mikachu
Hi all,
For my game, I pre-load several windows and pre-bind each button.
Then, I use

Code: Select all

mGUISystem->setGUISheet(mySheet);

to show a window (only one window is shown at a time).
I use

Code: Select all

mGUISystem->setGUISheet(0);

to hide the window.

It's working, but the problem is that "sometimes" the windows doesn't get closed. It seems that the bug appears only when the mouse isn't over a button (In my game, I can manually close the ingame menu by pressing escape key)

Am I completely wrong with my method? Or did I miss something?

Posted: Fri Dec 29, 2006 02:31
by Rackle
A different approach would be to use a single sheet:

Code: Select all

Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
System::getSingleton().setGUISheet(sheet);


Load each layout, which I'm assuming contains each window you want to preload:

Code: Select all

Window* guiLayout = winMgr.loadWindowLayout("MyLayout.layout");


Hide the window:

Code: Select all

CEGUI::WindowManager::getSingleton().getWindow("Window Name")->setVisible(true);


Then add the window to the layout:

Code: Select all

sheet->addChildWindow(guiLayout);


With this approach you only have to call setVisible() with true to display a window and false to hide it. Well, this approach should work. The only bit I'm unsure is hiding the window before adding it to the sheet.

The difficulty with having a .layout per window is that the Layout Editor automatically creates a root DefaultWindow for you, which breaks the rule that the name of each window must be unique (each layout tries to create a window called root). To fix this I used to manually edit the .layout file to remove that root window but there is supposed to be a way to export a portion of a layout, which would accomplish the same task.

Posted: Fri Dec 29, 2006 08:43
by mikachu
Thank you for the tip, I'll try it right now.
As for the CELayoutEditor problem, I knew about it, and I have already renamed all my windows in layouts. Right now, I'm creating layouts manually, with lots of copy/paste, and I find it as fast as using CELayoutEditor..