Win32 - drag n drop for savestates and movie files.

This commit is contained in:
adelikat 2009-08-02 20:32:53 +00:00
parent 07bdf7d148
commit 64e0b8a2af
1 changed files with 34 additions and 2 deletions

View File

@ -2292,7 +2292,7 @@ static BOOL OpenCore(const char* filename)
{ {
char LogicalName[1024], PhysicalName[1024]; 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))) if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions)))
return FALSE; return FALSE;
@ -2886,7 +2886,39 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
char filename[MAX_PATH] = ""; char filename[MAX_PATH] = "";
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
DragFinish((HDROP)wParam); 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; romloaded = TRUE;
} }