Page 1 of 1

GUI XML Parser ?

Posted: Mon Sep 15, 2008 1:11 pm
by IceFire_darkalex
Hi!

I'm searching for that since 2 hours now. I have seen the GUI Editor example but I cannot find a Sourcecode of it... So I want to ask you if Irrlicht has an XML-Reader built in which can read GUI Structures directly from XML Files?

Example XML:

Code: Select all

<?xml version="1.0"?>
<element type="button">

	<attributes>
		<int name="Id" value="100" />
		<string name="Caption" value="" />
		<rect name="Rect" value="460, 260, 560, 360" />
		<position name="MinSize" value="1, 1" />
		<position name="MaxSize" value="0, 0" />
		<bool name="NoClip" value="false" />
		<enum name="LeftAlign" value="upperLeft" />
		<enum name="RightAlign" value="upperLeft" />
		<enum name="TopAlign" value="upperLeft" />
		<enum name="BottomAlign" value="upperLeft" />
		<bool name="Visible" value="true" />
		<bool name="Enabled" value="true" />
		<bool name="TabStop" value="true" />
		<bool name="TabGroup" value="false" />
		<int name="TabOrder" value="1" />
		<bool name="PushButton" value="false" />
		<texture name="Image" value="" />
		<rect name="ImageRect" value="0, 0, 0, 0" />
		<texture name="PressedImage" value="" />
		<rect name="PressedImageRect" value="0, 0, 0, 0" />
		<bool name="Border" value="true" />
		<bool name="UseAlphaChannel" value="false" />
	</attributes>

</element>
This was created with the GUI Editor.








//Edit: LOL
That was too easy for me >.< I found it xD guienv->loadGUI()

Posted: Mon Sep 15, 2008 1:30 pm
by JP
No but it's incredibly simple to write an XML parser to get that information and construct the corresponding GUI elements anyway.

If you look at the MeshViewer tutorial there's some XML parsing in there (not sure if there's any other XML tutorials, probably some in irrXML i guess).

Posted: Mon Sep 15, 2008 1:31 pm
by hybrid
Yes, this can be loaded by the scene deserialization, just as 3d scenes from .irr files. Use environment->loadGUI()

Posted: Mon Sep 15, 2008 2:12 pm
by IceFire_darkalex
Thx! I found that out in that moment, too^^

But one more question about loadGUI():

If I want to make an Interface linke in WoW, where some things are on the right side of the screen, but If I want to let the user rescale the window so how can I realize thet for example a button is always 60% away from the right border

If the window is 1000 * 1000 it is on 400 from left. But what if the user rescales the window to 2000 * 2000 - if I write 400 in the XML it will now be 80% away from the right border

Posted: Mon Sep 15, 2008 8:27 pm
by bitplane
Look at the meshviewer example, the Irrlicht logo is always aligned to the bottom left corner of the window even if you resize it.
Or you could read the XML you pasted ;)

Code: Select all

      <enum name="LeftAlign" value="upperLeft" />
      <enum name="RightAlign" value="upperLeft" />
      <enum name="TopAlign" value="upperLeft" />
      <enum name="BottomAlign" value="upperLeft" />