layout loding problem

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

Ninja
Quite a regular
Quite a regular
Posts: 86
Joined: Sun Aug 20, 2006 11:42

layout loding problem

Postby Ninja » Tue Sep 05, 2006 18:09

Hi Guys

been experimenting with loading a window with the xml way

i have a push button that calls



Code: Select all

bool HandleButtonSetUp(const CEGUI::EventArgs& e)
{
   Window* Menu = WindowManager::getSingletonPtr()->loadWindowLayout("art/Setup/SetUp.xml");
   
   return true;   
}


at first press this inserts into the cegui log

(InfL1) ---- Successfully completed loading of GUI layout from 'art/Setup/SetUp.xml' ----


but no window appears on screen if i press the button a 2nd time i get an error and in cegui log

Error) Exception: WindowManager::createWindow - A Window object with the name 'SetUP' already exists within the system.
05/09/2006 19:06:04 (Error) Exception: GUILayout_xmlHandler::startElement - layout loading has been aborted since Window named 'SetUP' already exists.
05/09/2006 19:06:04 (Error) WindowManager::loadWindowLayout - loading of layout from file 'art/Setup/SetUp.xml' failed.


the xml file has only this in

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
            <Window Type="TaharezLook/FrameWindow" Name="SetUP">
            <Property Name="RelativeMinSize" Value="w:320 h:320" />
            <Property Name="RelativeMaxSize" Value="w:320 h:320" />
            <Property Name="Position" Value="x:0 y:0" />
            <Property Name="Size" Value="w:320 h:320" />
            <Property Name="Text" Value="Test Window" />
            <Property Name="CloseButtonEnabled" Value="true" />
            <Property Name="FrameEnabled" Value="true" />
          </Window>
</GUILayout>


where did i go wrong please

TIA

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Sep 05, 2006 20:47

From Widget Galore

Code: Select all

// Retrieve the window manager
WindowManager& winMgr = WindowManager::getSingleton();

// Load the TaharezLook scheme and set up the default mouse cursor and font
SchemeManager::getSingleton().loadScheme("TaharezLookSkin.scheme");
System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
FontManager::getSingleton().createFont("Commonwealth-10.font");

// Set the GUI Sheet
Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
System::getSingleton().setGUISheet(sheet);

// Load a layout
Window* guiLayout = winMgr.loadWindowLayout("WidgetGalore.layout");
sheet->addChildWindow(guiLayout);


You're probably missing the GUI sheet creation and the call to sheet->addChildWindow(guiLayout)

The first call to loadWindowLayout creates the window but since you do not attach it to the sheet it is not displayed. Pressing the button once more attempts to reload the layout but since it is already loaded you receive the duplicate names error.

Ninja
Quite a regular
Quite a regular
Posts: 86
Joined: Sun Aug 20, 2006 11:42

Postby Ninja » Tue Sep 05, 2006 22:13

heya

Thanks for the reply this opens a new window but loses the original window that has the background and buttons on it

what i'am attempting to do is have a child window open on top the main window if possible

ie have the main ui with buttons bg image then on button press this opens the window from the .layout file on top of the main screen

also how would you use the CloseButtonEnabled function using this way

TIA

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 » Wed Sep 06, 2006 07:43

Hi Ninja,

if you have a pointer to your main window, just say "MainWindow->AddChildwindow(Menu);" Changing the GuiSheet indeed removes all current windows (at least visually).

For closing, use the RemoveChildWindow method the same way.

About the other question in your first reply: window names must be unique. You can do multiple loadings of one layout by using the second parameter to give a prefix.

Good luck! :-)

Ninja
Quite a regular
Quite a regular
Posts: 86
Joined: Sun Aug 20, 2006 11:42

Postby Ninja » Wed Sep 06, 2006 09:01

heya
thanks for all the patiance with me n00b showing i guess :oops:

ok from my button press i call

Code: Select all

bool HandleButtonSetUp(const CEGUI::EventArgs& e)
{   
   using namespace CEGUI;
   // Retrieve the window manager
WindowManager& winMgr = WindowManager::getSingleton();

// Set the GUI Sheet
Window* child = winMgr.createWindow("DefaultWindow", "Setup_wnd");
System::getSingleton().setGUISheet(child);

// Load a layout
Window* setup = winMgr.loadWindowLayout("art/Setup/SetUp.layout");
child->addChildWindow(setup);

   return true;   
}


this works ok but as i said loads a new window and removes the main one
where all i need it to is load

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
           <Window Type="DefaultWindow" Name="setup_wnd">

        <Window Type="TaharezLook/FrameWindow" Name="testwindow">
            <Property Name="RelativeMinSize" Value="w:0.2 h:0.2" />
            <Property Name="RelativeMaxSize" Value="w:0.8 h:0.8" />
            <Property Name="Position" Value="x:0.2 y:0.2" />
            <Property Name="Size" Value="w:0.5 h:0.5" />
            <Property Name="Text" Value="Test Window" />
            <Property Name="CloseButtonEnabled" Value="True"  />
        </Window>
    </Window>
</GUILayout>


over the top if i hardcode the window this works fine with it being visable on load up (not ideal) but i have the closebuttonenabled working via the

Code: Select all

textwnd->subscribeEvent(FrameWindow::EventCloseClicked, Event::Subscriber(handleCloseButton));


which pulls

Code: Select all

bool handleCloseButton(const CEGUI::EventArgs& e)
{
static_cast<const CEGUI::WindowEventArgs&>(e).window->hide();    
   return true;
}


but cant seem to get this working with the layout way

TIA

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Sep 06, 2006 12:23

From my own code. When initializing the game I create the sheet:

Code: Select all

CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
Window* guiSheet = winMgr.createWindow("DefaultWindow", "guiSheet");
CEGUI::System::getSingleton().setGUISheet(guiSheet);



Afterward I pre-load multiple windows onto that existing sheet, which you could do from your button:

Code: Select all

CEGUI::Window* chatBox = winMgr.loadWindowLayout("ChatBox.layout");
guiSheet->addChildWindow(chatBox);

CEGUI::Window* cargo = winMgr.loadWindowLayout("Cargo.layout");
guiSheet->addChildWindow(cargo);

CEGUI::Window* merchant = winMgr.loadWindowLayout("Merchant.layout");
guiSheet->addChildWindow(merchant);


The problem could be that you have a sheet for your buttons and when you press on the setup button you use a new sheet whereas you seem to want to reuse the same sheet.

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 » Wed Sep 06, 2006 15:10

Hi Rackle,

I was already able to help Ninja out on IRC :-)

But thanks for your answers, next time i will add such info sooner ;-)

Ninja
Quite a regular
Quite a regular
Posts: 86
Joined: Sun Aug 20, 2006 11:42

Postby Ninja » Thu Sep 07, 2006 11:49

hi rackle

Sorry i wasnt able to get back onto the site untill now for some strange reason the site keeps timing out on me

ScriptKid was kind enough to teach me a few things yesterday on IRC

but thanks for the posts and trying to help

Much appreatiated


Return to “Help”

Who is online

Users browsing this forum: No registered users and 41 guests