C++ File browser/explorer?

Started by
3 comments, last by Stroppy Katamari 11 years, 11 months ago
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
Advertisement
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!

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 :)
For Windows lookup GetOpenFileName/GetSaveFileName:

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

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

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

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

^^^

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.

This topic is closed to new replies.

Advertisement