From 96040fecb637119ef4c36722417cde9ce8e72eed Mon Sep 17 00:00:00 2001 From: shashclp Date: Fri, 12 Jan 2007 23:43:32 +0000 Subject: [PATCH] - Added the option to show .zip/.gz in the loading dialog, if supported when compiling --- desmume/src/windows/main.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/desmume/src/windows/main.c b/desmume/src/windows/main.c index 23cdad8e2..e1b4e6a9e 100644 --- a/desmume/src/windows/main.c +++ b/desmume/src/windows/main.c @@ -614,14 +614,35 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { case IDM_OPEN: { + int filterSize = 0, i = 0; OPENFILENAME ofn; - char filename[MAX_PATH] = ""; + char filename[MAX_PATH] = "", + fileFilter[512]=""; NDS_Pause(); //Stop emulation while opening new rom ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "NDS ROM file (*.nds)\0*.nds\0NDS/GBA ROM File (*.ds.gba)\0*.ds.gba\0Any file (*.*)\0*.*\0\0"; + + // To avoid #ifdef hell, we'll do a little trick, as lpstrFilter + // needs 0 terminated string, and standard string library, of course, + // can't help us with string creation: just put a '|' were a string end + // should be, and later transform prior assigning to the OPENFILENAME structure + strcpy (fileFilter, "NDS ROM file (*.nds)|*.nds|NDS/GBA ROM File (*.ds.gba)|*.ds.gba|"); +#ifdef HAVE_LIBZZIP + strcat (fileFilter, "Zipped NDS ROM file (*.zip)|*.zip|"); +#endif +#ifdef HAVE_LIBZ + strcat (fileFilter, "GZipped NDS ROM file (*.gz)|*.gz|"); +#endif + strcat (fileFilter, "Any file (*.*)|*.*||"); + + filterSize = strlen(fileFilter); + for (i = 0; i < filterSize; i++) + { + if (fileFilter[i] == '|') fileFilter[i] = '\0'; + } + ofn.lpstrFilter = fileFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH;