Sign in to follow this  

C++ File browser/explorer?

This topic is 2039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a tile editor that I'm creating in C++ for my game but I'm stuck on something. For loading/saving files I want to open a file explorer/browser thing so the user can select where they want to save the file(or load a file). I could probably achieve something by just using text commands in the cmd but I'd rather have a file explorer. I'm not sure how the best way to do this would be. Thanks.

PS I'm using SFML

Share this post


Link to post
Share on other sites
Normally this is done using the OS APIs (or a wrapper that includes that functionality), writing your own is certainly doable but takes quite alot of work so i'd recommend against it. Both wxwidgets and QT have easy to use file dialogs if you want a cross platform library for it, if you only need to support a single platform you can check the documentation for that platform. Edited by SimonForsman

Share this post


Link to post
Share on other sites
[quote name='SimonForsman' timestamp='1336794338' post='4939493']
Normally this is done using the OS APIs (or a wrapper that includes that functionality), writing your own is certainly doable but takes quite alot of work so i'd recommend against it. Both wxwidgets and QT have easy to use file dialogs if you want a cross platform library for it, if you only need to support a single platform you can check the documentation for that platform.
[/quote]

Thanks, I thought it might be quite involved but I knew there were system commands to open the file explorer so I thought there might be something similar, but whatever. I'll only need it to work for windows so I'll look in to QT perhaps in the future. For now I'll just do simple file loading with the command prompt :)

Share this post


Link to post
Share on other sites
For Windows lookup GetOpenFileName/GetSaveFileName:

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/ms646927(v=vs.85).aspx[/url]

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx"]http://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx[/url]

Just zero out and fill the struct properly and you're done.

Share this post


Link to post
Share on other sites
^^^

For flexible filesystem browsing/manipulation, like having your editor automatically find assets from given directories, or having an embedded savegame browser in your game, check out Boost.filesystem. (It's as "standard" as you can get; it almost made it to C++11 standard and will probably be in next language version.)

For an editor, a framework like Qt would probably save you a ton of trouble in other ways, not just cross-platform capability.

Share this post


Link to post
Share on other sites

This topic is 2039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this