SFML community forums

Help => General => Topic started by: Sumzary on July 25, 2013, 07:55:59 pm

Title: Getting key binds to/from an xml file.
Post by: Sumzary on July 25, 2013, 07:55:59 pm
Hi!

I have a program made with Qt that looks like this:

(http://oi42.tinypic.com/n396o5.jpg)

Then the binds should be exported to an xml file and imported by the game on startup.

How would I go about doing that?
Title: Re: Getting key binds to/from an xml file.
Post by: Aster on July 25, 2013, 09:19:36 pm
Should? This smells of homework. Have you checked the logo on the top right of the forum? This has nothing to do with SFML. Just get an XML parser, learn XML, and do it yourself.
Title: Re: Getting key binds to/from an xml file.
Post by: Sumzary on July 25, 2013, 09:47:40 pm
What I am asking is how would I convert the strings in the xml to the enums in SFML and the other way around.
Title: Re: Getting key binds to/from an xml file.
Post by: Nexus on July 25, 2013, 10:03:51 pm
SFML doesn't provide such conversion functions, but Thor (http://www.bromeon.ch/libraries/thor/v2.0/doc/_input_names_8hpp.html) does.

The problem is, to convert between enums and strings in C++, you have to list every single case explicitly -- that's why I included this boilerplate code to Thor, hoping that not everybody has to reinvent the wheel ;)
Title: Re: Getting key binds to/from an xml file.
Post by: Sumzary on July 25, 2013, 10:11:47 pm
Ooh, thanks a whole bunch Nexus, it would have taken AGES otherwise.

Thanks again :D