SFML community forums

Help => General => Topic started by: GabrielS on September 25, 2013, 09:00:09 pm

Title: Choosing a File
Post by: GabrielS on September 25, 2013, 09:00:09 pm
Hello,

Currently developing a game in SFML where levels are saved as XML file, I would like to add to my GUI a button that displays a window to let the user choose the file level.xml he wants to chose.
Is it possible to do so ? Like letting the user browse a repertory to select the level he wants to load.

Please let me know if you have any idea on how to implement this properly ;)

Thanks !
Title: AW: Choosing a File
Post by: eXpl0it3r on September 25, 2013, 09:15:54 pm
Of course it's possible, but implementation wise there are thousand of different ways.

First you'll have to decide where to locate the xml files, simplest way would be to have one directory with all the files.
Next you'll have to decide how to grab the files. If you want to list all the files in the directory, you'll most likely have a look at boost::filesystem, otherwise you could just load an text file where you'd list all the existing xml files.

For the UI you can use rectangles and/or sprites, to create something nice looking. Keep in mind though, UI programming is quite difficult. ;)
Title: Re: Choosing a File
Post by: Ixrec on September 25, 2013, 09:18:04 pm
It's entirely possible but outside the scope of SFML.  If you want a button and a file open dialog without doing all the implementation/learning the system calls yourself, you'll need a GUI library.
Title: Re: Choosing a File
Post by: MorleyDev on September 25, 2013, 09:38:06 pm
It's outside of the scope of SFML but there are other 3rd party libraries you can integrate to create this functionality. For the GUI side you may want to look into SFGUI (http://sfgui.sfml-dev.de/). For file system exploration and the like, boost::filesystem (http://www.boost.org/doc/libs/1_54_0/libs/filesystem/doc/index.htm) is a good bet.
Title: Re: Choosing a File
Post by: GabrielS on September 27, 2013, 04:16:43 pm
Ok great thanks for your ideas, that helps =)
I am currently looking on boost::filesystem !

Thanks !  ;)