Page 1 of 1

[Solved] CELayoutEditor layout to code

Posted: Tue May 24, 2005 12:03
by pokemoen
I can't find any ready made routines in CEGUI to load the xml layout generated by the layouteditor.. Do I need to parse the file myself or have I overlooked something?

I mean... the following code from the demo project could be generated from the xml file right?

Code: Select all

PushButton* btn = (PushButton*)WindowManager::getSingleton().createWindow((utf8*)"TaharezLook/Button", (utf8*)"QuitButton");
      sheet->addChildWindow(btn);
      btn->setText((utf8*)"Quit!");
      btn->setPosition(Point(0.035f, 0.0f));
      btn->setSize(Size(0.1f, 0.036f));

loop all the widgets in the xml file and maybe manually subscribe eventlisteners to each... I really can't imagine such a function isn't available somewhere... any place someone can point me to?

Thanks in advance,
Alex

Re: CELayoutEditor layout to code

Posted: Tue May 24, 2005 12:09
by pokemoen
and ofcourse just after I post in the forum I find it myself... :roll:

Code: Select all

00175 Window* WindowManager::loadWindowLayout(const String& filename, const String& name_prefix, const String& resourceGroup, PropertyCallback* callback, void* userdata)


Is that it?

ltr,
Alex
:hammer:

Re: CELayoutEditor layout to code

Posted: Tue May 24, 2005 13:24
by pokemoen
24/05/2005 13:09:48 (Error) Exception: WindowManager::loadWindowLayout - An unexpected error occurred while parsing gui-layout file '../data/layouts/menus.xml'.

:x

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
   <Window Type="DefaultWindow" Name="Menus">
      <Window Type="TaharezLook/FrameWindow" Name="login_window">
         <Property Name="AbsoluteRect" Value="l:47.000000 t:18.000000 r:527.000000 b:564.000000" />
         <Property Name="RelativeRect" Value="l:0.046055 t:0.023073 r:0.514609 b:0.734791" />
         <Property Name="Text" Value="Login" />
         <Window Type="TaharezLook/Editbox" Name="username_editbox">
            <Property Name="AbsoluteRect" Value="l:183.000000 t:96.000000 r:388.000000 b:134.000000" />
            <Property Name="RelativeRect" Value="l:0.381758 t:0.175052 r:0.807344 b:0.246145" />
         </Window>
      </Window>
   </Window>
</GUILayout>


Hmmm... it works in CELayoutEditor...any ideas?

Thanks,
Alex

Re: CELayoutEditor layout to code

Posted: Tue May 24, 2005 13:49
by lindquist
At a glimpse this layout looks fine.
could you post your codeline that loads it ?

Re: CELayoutEditor layout to code

Posted: Tue May 24, 2005 17:14
by pokemoen
Sure:

Code: Select all

      SchemeManager::getSingleton().loadScheme((utf8*)"../data/schemes/TaharezLook.scheme");
      System::getSingleton().setDefaultMouseCursor((utf8*)"TaharezLook", (utf8*)"MouseArrow");

      Window* sheet;
      WindowManager::getSingletonPtr()->loadWindowLayout((utf8*)"../data/layouts/menus.xml",(utf8*)"");
      menuLayout = WindowManager::getSingleton().getWindow((utf8*)"Menus");
      gameLayout = WindowManager::getSingletonPtr()->loadWindowLayout((utf8*)"../data/layouts/game.xml");
      cardSelectLayout = WindowManager::getSingletonPtr()->loadWindowLayout((utf8*)"../data/layouts/cardselect.xml");
      sheet->addChildWindow(menuLayout);
      sheet->addChildWindow(gameLayout);      
      sheet->addChildWindow(cardSelectLayout);
      displayLayout(1);


At first all 3 layouts were loaded like 'gameLayout' and 'cardSelectLayout' above, then I did some experimenting with menuLayout... So, that's why they're different in the above code..

But anyway, the error is logged in (the first) loadWindowLayout().

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 06:58
by scriptkid
Maybe it's a path issue. Is the "distance" to data and CEGUI files (schemes, images and such) the same from the editor and your own code when you load a layout?

But it might be something else, since CEGUI has some clear errors on such cases...

Good luck anyway!

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 09:24
by pokemoen
Nope, that's not it..
So I turned on INSANE logging and that helps a little :/

Code: Select all

25/05/2005 09:13:15 (InfL2)   ---- Beginning loading of GUI layout from 'menus.xml' ----
25/05/2005 09:13:18 (InfL2)   Window 'Menus' of type 'DefaultWindow' has been created.
25/05/2005 09:13:18 (InfL2)   Window 'login_window__auto_titlebar__' of type 'TaharezLook/Titlebar' has been created.
25/05/2005 09:13:18 (InfL2)   Window 'login_window__auto_closebutton__' of type 'TaharezLook/CloseButton' has been created.
25/05/2005 09:13:18 (Error)   Exception: WindowManager::loadWindowLayout - An unexpected error occurred while parsing gui-layout file 'menus.xml'.


So the default window with the close_button is created and it crashes after that.. next line in the layout file is "<Property Name="AbsoluteRect" Value="l:47.000000 t:18.000000 r:527.000000 b:564.000000" />"; are those values pixels?

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 09:44
by pokemoen
Okay, some code I thought was irrelevant was causing the program to crash. I removed it (it were some old eventlistener subscribers), now it runs, but the error still appears in the logfile and I only get a blue screen without a GUI...

This is my log now:

Code: Select all

(...)
25/05/2005 09:42:47 (InfL1)   WindowFactory for 'TaharezLook/VUMeter' windows added.
25/05/2005 09:42:47 (InfL2)   ---- Resource loading for GUI scheme 'TaharezLook' completed ----
25/05/2005 09:42:47 (InfL2)   ---- Beginning loading of GUI layout from '../data/layouts/menus.xml' ----
25/05/2005 09:42:47 (InfL2)   Window 'Menus' of type 'DefaultWindow' has been created.
25/05/2005 09:42:47 (InfL2)   Window 'login_window__auto_titlebar__' of type 'TaharezLook/Titlebar' has been created.
25/05/2005 09:42:47 (InfL2)   Window 'login_window__auto_closebutton__' of type 'TaharezLook/CloseButton' has been created.
25/05/2005 09:42:49 (Error)   Exception: WindowManager::loadWindowLayout - An unexpected error occurred while parsing gui-layout file '../data/layouts/menus.xml'.
25/05/2005 09:42:57 (InfL1)   ---- Begining CEGUI System destruction ----
25/05/2005 09:42:57 (InfL2)   Window 'Menus' has been destroyed.
(...)

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 10:02
by CrazyEddie
Hi,

Are you using Xerces or TinyXML for the XML file parsing?

Thanks,

CE.

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 11:26
by pokemoen
Xerces (2.5.0)

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 19:49
by CrazyEddie
It's failing part way through construction of the FrameWindow object. I got nothing but wild guesses really, so...

Have you loaded at least one font and, if you're using anything other than CVS HEAD, set a font to be used as a default font?

CE.

Re: CELayoutEditor layout to code

Posted: Wed May 25, 2005 20:39
by pokemoen
Eddie... you're the KING of wild guesses :D
I went back to my fontloading code and it was indeed _after_ the layout loading code.. which brought me to a "Window* sheet" not being inited right, etc.
Anyway, it's working now, thanks again!
CEGUI is great! ;)