win32: drag and drop support for snes9x movie (*.smv)

Conflicts:

	win32/snes9xw.vcproj
This commit is contained in:
gocha 2012-08-05 06:43:51 +09:00 committed by OV2
parent fb2935d454
commit 7ed405d6e2
2 changed files with 118 additions and 9 deletions

View File

@ -85,7 +85,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmt.lib msxml2.lib"
AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmt.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -187,7 +187,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtx64.lib msxml2.lib"
AdditionalDependencies="libpngmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtx64.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-x64.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -284,7 +284,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngdmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmt.lib msxml2.lib"
AdditionalDependencies="libpngdmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmt.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-debug.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -383,7 +383,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngdmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtx64.lib msxml2.lib"
AdditionalDependencies="libpngdmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtx64.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-debug-x64.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -482,7 +482,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngdmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtu.lib msxml2.lib"
AdditionalDependencies="libpngdmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtu.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-debug.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -583,7 +583,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngdmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtux64.lib msxml2.lib"
AdditionalDependencies="libpngdmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibdmtux64.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-debug-x64.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -690,7 +690,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtu.lib msxml2.lib"
AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtu.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@ -795,7 +795,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libpngmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtux64.lib msxml2.lib"
AdditionalDependencies="libpngmtx64.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib zlibmtux64.lib msxml2.lib shlwapi.lib"
OutputFile=".\snes9x-x64.exe"
LinkIncremental="1"
SuppressStartupBanner="true"

View File

@ -195,6 +195,7 @@
#include <shlobj.h>
#include <objidl.h>
#include <shlwapi.h>
#include <Shobjidl.h>
#include "wsnes9x.h"
@ -664,6 +665,38 @@ static void absToRel(TCHAR* relPath, const TCHAR* absPath, const TCHAR* baseDir)
}
}
BOOL SendMenuCommand (UINT uID)
{
MENUITEMINFO mii;
CheckMenuStates();
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;
if (!GetMenuItemInfo(GUI.hMenu, uID, FALSE, &mii))
return FALSE;
if (!(mii.fState & MFS_DISABLED))
return SendMessage(GUI.hWnd, WM_COMMAND, (WPARAM)(uID),(LPARAM)(NULL));
else
return FALSE;
}
BOOL PostMenuCommand (UINT uID)
{
MENUITEMINFO mii;
CheckMenuStates();
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;
if (!GetMenuItemInfo(GUI.hMenu, uID, FALSE, &mii))
return FALSE;
if (!(mii.fState & MFS_DISABLED))
return PostMessage(GUI.hWnd, WM_COMMAND, (WPARAM)(uID),(LPARAM)(NULL));
else
return FALSE;
}
void S9xMouseOn ()
{
if(Settings.StopEmulation)
@ -1431,6 +1464,77 @@ static bool DoOpenRomDialog(TCHAR filename [_MAX_PATH], bool noCustomDlg = false
}
}
bool WinMoviePlay(LPCTSTR filename)
{
struct MovieInfo info;
int err;
if (Settings.StopEmulation) {
SendMenuCommand(ID_FILE_LOAD_GAME);
if (Settings.StopEmulation)
return false;
}
err = S9xMovieGetInfo(_tToChar(filename), &info);
if (err != SUCCESS) {
TCHAR* err_string = MOVIE_ERR_COULD_NOT_OPEN;
switch(err)
{
case FILE_NOT_FOUND:
err_string = MOVIE_ERR_NOT_FOUND_SHORT;
break;
case WRONG_FORMAT:
err_string = MOVIE_ERR_WRONG_FORMAT_SHORT;
break;
case WRONG_VERSION:
err_string = MOVIE_ERR_WRONG_VERSION_SHORT;
break;
}
S9xSetInfoString(_tToChar(err_string));
return false;
}
while (info.ROMCRC32 != Memory.ROMCRC32 || strcmp(info.ROMName, Memory.RawROMName) != 0) {
TCHAR temp[512];
wsprintf(temp, TEXT("Movie's ROM: crc32=%08X, name=%s\nCurrent ROM: crc32=%08X, name=%s\n\nstill want to play the movie?"),
info.ROMCRC32, _tFromMS932(info.ROMName), Memory.ROMCRC32, _tFromMS932(Memory.RawROMName));
int sel = MessageBox(GUI.hWnd, temp, SNES9X_INFO, MB_ABORTRETRYIGNORE|MB_ICONQUESTION);
switch (sel) {
case IDABORT:
return false;
case IDRETRY:
SendMenuCommand(ID_FILE_LOAD_GAME);
if (Settings.StopEmulation)
return false;
break;
default:
goto romcheck_exit;
}
}
romcheck_exit:
S9xMovieOpen (_tToChar(filename), GUI.MovieReadOnly);
if(err != SUCCESS)
{
TCHAR* err_string = MOVIE_ERR_COULD_NOT_OPEN;
switch(err)
{
case FILE_NOT_FOUND:
err_string = MOVIE_ERR_NOT_FOUND_SHORT;
break;
case WRONG_FORMAT:
err_string = MOVIE_ERR_WRONG_FORMAT_SHORT;
break;
case WRONG_VERSION:
err_string = MOVIE_ERR_WRONG_VERSION_SHORT;
break;
}
S9xSetInfoString(_tToChar(err_string));
return false;
}
return true;
}
TCHAR multiRomA [MAX_PATH] = {0}; // lazy, should put in sGUI and add init to {0} somewhere
TCHAR multiRomB [MAX_PATH] = {0};
@ -1510,9 +1614,14 @@ LRESULT CALLBACK WinProc(
if (fileCount == 1) {
DragQueryFile(hDrop, 0, droppedFile, PATH_MAX);
LPCTSTR ext = PathFindExtension(droppedFile);
if (ExtensionIsValid(droppedFile)) {
LoadROM(droppedFile);
} else {
}
else if (lstrcmpi(ext, TEXT(".smv")) == 0) {
WinMoviePlay(droppedFile);
}
else {
S9xMessage(S9X_ERROR, S9X_ROM_INFO, "Unknown file extension.");
}
}