YAML

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

GrizzLyCRO
Just popping in
Just popping in
Posts: 2
Joined: Fri Aug 05, 2011 22:49

YAML

Postby GrizzLyCRO » Fri Aug 05, 2011 23:15

Hey, i am interested in option to load YAML files, not only XML.

http://pastie.org/2327238
http://pastie.org/2327308

How hard would it be to integrate such functionality? Can i somehow get list of required and available properties in code?

"Window" is general name for entity?
For layouts, i guess that "Type" and "Name" are required?

Can you give me pointers where to start?
I already started experimenting on this in python (using panda3d)

EDIT1:
Ok,i tested my idea, and it should be very easy to do it, here is some sample proof of concept code :)

Code: Select all

        stream = file('x.yaml', 'r')
        x = yaml.load(stream)
        Name = x["GUILayout"]["Window"]["Name"]
        Type = x["GUILayout"]["Window"]["Type"]

        t = self.CEGUI.WindowManager.createWindow(Type,Name)
        t.setPosition(PyCEGUI.UVector2(PyCEGUI.UDim(0,50), PyCEGUI.UDim(0,0)))
        #t.setProperty("Image","set:TaharezLook image:full_image")
        t.setSize(UVector2(UDim(0,750),UDim(0,650)));
        v = self.CEGUI.WindowManager.createWindow(Type,Name+"2")
        v.setPosition(PyCEGUI.UVector2(PyCEGUI.UDim(0.25,50), PyCEGUI.UDim(0,0)))
        v.setSize(UVector2(UDim(0,150),UDim(0,150)));
        t.addChildWindow(v)
        self.CEGUI.System.setGUISheet(t)

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: YAML

Postby Jamarr » Mon Aug 08, 2011 12:11

GrizzLyCRO wrote:Hey, i am interested in option to load YAML files, not only XML.

http://pastie.org/2327238
http://pastie.org/2327308

How hard would it be to integrate such functionality?


I do not think this would be hard per se, however extending CEGUI to support a different markup-language may require some refactoring as it seems to be somewhat coupled to XML.

I think you could write a custom XMLParser that does YAML, but I am not sure if the XMLHandler interface it uses translates easily to YAML. If these cannot be easily customized for YAML then you might need to refactor the xml-loading system to allow different types of parsers, so as it is not so coupled to XML.

Can i somehow get list of required and available properties in code?


There are a couple references for properties:
The API (ex: WindowProperties)
The Wiki (ex: WindowsLookProperties)

However for the most complete/up-to-date list you might try using the PropertyFinder.

"Window" is general name for entity? For layouts, i guess that "Type" and "Name" are required? Can you give me pointers where to start? I already started experimenting on this in python (using panda3d)


You should start with the Main API Docs, under "Additional reference material" for XML markup information.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
Mikademus
CEGUI MVP
CEGUI MVP
Posts: 130
Joined: Wed Mar 18, 2009 19:14

Re: YAML

Postby Mikademus » Fri Aug 12, 2011 16:46

Jamarr wrote:I do not think this would be hard per se, however extending CEGUI to support a different markup-language may require some refactoring as it seems to be somewhat coupled to XML.

I think you could write a custom XMLParser that does YAML, but I am not sure if the XMLHandler interface it uses translates easily to YAML. If these cannot be easily customized for YAML then you might need to refactor the xml-loading system to allow different types of parsers, so as it is not so coupled to XML.


This is a very interesting point. It might be worth to slate for 0.8.1 or something a separation between CEGUI and XML, that is, to decouple CEGUI from being dependent on any particular mark-up language. Let all parsers be concrete instances of an abstract base and CEGUI could support XML as well as JSON and YAML. I would use it to write a parser for my own JSON-like format.

frank28_nfls
Just popping in
Just popping in
Posts: 2
Joined: Wed Nov 16, 2011 09:21

Re: YAML

Postby frank28_nfls » Thu Nov 24, 2011 03:18

Mikademus wrote:a separation between CEGUI and XML, that is, to decouple CEGUI from being dependent on any particular mark-up language. Let all parsers be concrete instances of an abstract base and CEGUI could support XML as well as JSON and YAML. I would use it to write a parser for my own JSON-like format.


Just want to second for this! An pure abstract parser module in CEGUIBase enables the possibility to parse those files even in binary format. Glad to see this to happen soon.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: YAML

Postby Kulik » Thu Nov 24, 2011 09:03

frank28_nfls: All of this is possible even now. The only problem is that the abstract classes are called XMLParsers. They can be implemented to parse JSON, binary data, whatever you like.

I would maybe couple parsers/loaders and serializers, right now they are separate.

Zoomulator
Just popping in
Just popping in
Posts: 8
Joined: Tue Dec 20, 2011 22:12

Re: YAML

Postby Zoomulator » Sat Dec 31, 2011 12:19

I'd also like to second this.

Using XML for declaring windows without an editor is tedious and involves a lot of redundant typing with all those tags. It's also difficult to read and get a good overview of! XML is overrated as far as I'm concerned.


Kulik wrote:frank28_nfls: All of this is possible even now. The only problem is that the abstract classes are called XMLParsers. They can be implemented to parse JSON, binary data, whatever you like.

I would maybe couple parsers/loaders and serializers, right now they are separate.

I'm not very familiar with the inner workings of CEGUI yet. I'm wondering what you mean by "possible even now". Is it possible to parse YAML out of the box, or do I have to write a module to replace the XMLParser with a YAML one myself?

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

Re: YAML

Postby CrazyEddie » Sun Jan 01, 2012 10:13

YAML and/or other file formats are not, and will never be, supported out of the box as far as the core CEGUI distributions go (if it were, it would make offering technical support about 100 times worse than what it is now).

What is meant by the "possible even now", is that there already exists an abstract interface for loading data files. While this is totally geared towards a SAX approach to parsing XML, it can - with some imagination and ingenuity - be used to load other types of file. To restate: in order to load from some other file type, you need to implement the XMLParser interface in such a way that you pass the appropriate data to the XMLHandler implementation (which most likely will involve 'faking' certain things).

CE.

Zoomulator
Just popping in
Just popping in
Posts: 8
Joined: Tue Dec 20, 2011 22:12

Re: YAML

Postby Zoomulator » Sun Jan 01, 2012 11:01

Thanks for a clear answer CrazyEddie!
I fully understand that the workload could get out of hand.

Happy new year to you all in the CEGUI team.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests