Jump to content
• Advertisement

File dialog for SDL project

This topic is 5399 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

Well I'm looking to make my map editor in SDL to try to keep the dependancies for my project down. Now I'm just wondering what's the best crossplatform way to implement a file choosing dialog(for opening and saving maps)? All I'm looking for is a way to list directory files and return a string the absolute path when they're chosen.

Share this post

Share on other sites
Advertisement
Best way is to do it yourself.

Share this post

Share on other sites
Well, here is some code that contains functions for looping through subdirectories and finding files. It will work on all platforms, provided you compile it on Windows with MinGW. If you try to use it with VC++ you'll run into trouble, as VC++ doesn't have the "dirent.h" header file, for some reason.

Hope this helps!

Ryan

Share this post

Share on other sites
I've used the filesystem library from Boost before. You might wanna check it out

Share this post

Share on other sites
#include <stdilb.h>

void ScanDirectory(void)
{
system("dir *.bmp -b > temp.txt");
}

that should do it in dos.

Share this post

Share on other sites
In case it wasn't clear, the actual dialog is something you'll have to write yourself. Unfortunately, this means you can't use the native file browser on any system, which is always annoying. But unless you want to write multiple OS-specialized code paths, you'll need to do it yourself.

Although I suppose a windowing toolkit such as Gtk+ or WxWindows might be very useful, since all the work is done.

Share this post

Share on other sites
oops should have mentioned it was in plain C(not C++) looking for something that kind of fits this pseudocode
/** * Creates a dialog that returns a filename to be passed to fopen * type is either save or load type */char * filedlg(char mode){  while(1){    /* get contents of current directory */    /* display them to screen */    /* allow user input */    /* if file return absolute path to file */    /* if change dir change to the dir */    /* if cancel return */  }}

So what's the best crossplatform(Linux, BSD, Windows, Mac, Solaris) way to get the contents of current directory?

Share this post

Share on other sites
Quote:
 So what's the best crossplatform(Linux, BSD, Windows, Mac, Solaris) way to get the contents of current directory?

I guess using standard library functions supported in all platforms or using a cross-platform library.
In Windows it's possible to use the default file browser because you can get the windows hwnd.

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Now

• 21
• 16
• 9
• 17
• 13
• Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!