Page 1 of 1

YAML

Posted: Fri Aug 05, 2011 23:15
by GrizzLyCRO
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)

Re: YAML

Posted: Mon Aug 08, 2011 12:11
by Jamarr
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.

Re: YAML

Posted: Fri Aug 12, 2011 16:46
by Mikademus
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.

Re: YAML

Posted: Thu Nov 24, 2011 03:18
by frank28_nfls
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.

Re: YAML

Posted: Thu Nov 24, 2011 09:03
by Kulik
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.

Re: YAML

Posted: Sat Dec 31, 2011 12:19
by Zoomulator
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?

Re: YAML

Posted: Sun Jan 01, 2012 10:13
by CrazyEddie
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.

Re: YAML

Posted: Sun Jan 01, 2012 11:01
by Zoomulator
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.