Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ File browser/explorer?

Started by Deadlybones May 12, 2012 at 3:27 AM 3 replies 11.7k views
Original Post
Deadlybones
Deadlybones
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
SimonForsman
SimonForsman
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.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Deadlybones
Deadlybones

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.


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
Stroppy Katamari
Stroppy Katamari
^^^

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.