From 64e0b8a2af7443451691586f9d9053a29856779c Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 2 Aug 2009 20:32:53 +0000 Subject: [PATCH] Win32 - drag n drop for savestates and movie files. --- desmume/src/windows/main.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 3dff7d100..4e7afc30f 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -2292,7 +2292,7 @@ static BOOL OpenCore(const char* filename) { char LogicalName[1024], PhysicalName[1024]; - const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*"}; + const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*", "dst"}; if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions))) return FALSE; @@ -2886,7 +2886,39 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM char filename[MAX_PATH] = ""; DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); DragFinish((HDROP)wParam); - if(OpenCore(filename)) + + //adelikat: dropping these in from FCEUX, I hope this is the best place for that + std::string fileDropped = filename; + //------------------------------------------------------- + //Check if Movie file + //------------------------------------------------------- + if (!(fileDropped.find(".dsm") == string::npos) && (fileDropped.find(".dsm") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename + { + if (romloaded && !(fileDropped.find(".dsm") == string::npos)) //.dsm is at the end of the filename so that must be the extension + FCEUI_LoadMovie(fileDropped.c_str(), 1, false, false); //We are convinced it is a movie file, attempt to load it + } + + //------------------------------------------------------- + //Check if Savestate file + //------------------------------------------------------- + else if (!(fileDropped.find(".ds") == string::npos)) + { + if (fileDropped.find(".ds") == fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character + { + if ((fileDropped[fileDropped.length()-1] >= '0' && fileDropped[fileDropped.length()-1] <= '9') || fileDropped[fileDropped.length()-1] == 't') //If last character is 0-9 (making .ds0 - .ds9) or .dst + { + savestate_load(filename); + Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating + Update_RAM_Search(); //hotkey.cpp - HK_StateLoadSlot & State_Load also call these functions + } + } + } + + //------------------------------------------------------- + //Else load it as a ROM + //------------------------------------------------------- + + else if(OpenCore(filename)) { romloaded = TRUE; }