Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Choosing a File  (Read 2519 times)

0 Members and 1 Guest are viewing this topic.

GabrielS

  • Newbie
  • *
  • Posts: 25
    • View Profile
Choosing a File
« 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 !

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Choosing a File
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Choosing a File
« Reply #2 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.

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Re: Choosing a File
« Reply #3 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. For file system exploration and the like, boost::filesystem is a good bet.
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

GabrielS

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Choosing a File
« Reply #4 on: September 27, 2013, 04:16:43 pm »
Ok great thanks for your ideas, that helps =)
I am currently looking on boost::filesystem !

Thanks !  ;)