[Solved] CELayoutEditor layout to code

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

[Solved] CELayoutEditor layout to code

Postby pokemoen » Tue May 24, 2005 12:03

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

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Tue May 24, 2005 12:09

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:

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Tue May 24, 2005 13:24

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

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: CELayoutEditor layout to code

Postby lindquist » Tue May 24, 2005 13:49

At a glimpse this layout looks fine.
could you post your codeline that loads it ?

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Tue May 24, 2005 17:14

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().

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:

Re: CELayoutEditor layout to code

Postby scriptkid » Wed May 25, 2005 06:58

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!

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Wed May 25, 2005 09:24

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?

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Wed May 25, 2005 09:44

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.
(...)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CELayoutEditor layout to code

Postby CrazyEddie » Wed May 25, 2005 10:02

Hi,

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

Thanks,

CE.

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Wed May 25, 2005 11:26

Xerces (2.5.0)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CELayoutEditor layout to code

Postby CrazyEddie » Wed May 25, 2005 19:49

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.

User avatar
pokemoen
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Thu Mar 10, 2005 10:55
Contact:

Re: CELayoutEditor layout to code

Postby pokemoen » Wed May 25, 2005 20:39

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! ;)


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 11 guests