Guest User

snes9xgit: [gocha] windows: drag and drop support for lua

a guest
Jan 15th, 2011
631
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From 0df6958863de140dfb4a996a302eefc851445e98 Mon Sep 17 00:00:00 2001
  2. From: gocha <gochaism@gmail.com>
  3. Date: Sun, 16 Jan 2011 11:14:52 +0900
  4. Subject: [PATCH 3/3] windows: drag and drop support for lua
  5.  
  6. ---
  7. win32/snes9xw.vcproj |   24 ++++++++++++------------
  8.  win32/wsnes9x.cpp    |   18 +++++++++++++++++-
  9.  2 files changed, 29 insertions(+), 13 deletions(-)
  10.  
  11. diff --git a/win32/snes9xw.vcproj b/win32/snes9xw.vcproj
  12. index 3c79f91..aed8bdf 100644
  13. --- a/win32/snes9xw.vcproj
  14. +++ b/win32/snes9xw.vcproj
  15. @@ -85,7 +85,7 @@
  16.             />
  17.             <Tool
  18.                 Name="VCLinkerTool"
  19. -               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 lua51.lib"
  20. +               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 lua51.lib"
  21.                 OutputFile=".\snes9x.exe"
  22.                 LinkIncremental="1"
  23.                 SuppressStartupBanner="true"
  24. @@ -187,7 +187,7 @@
  25.             />
  26.             <Tool
  27.                 Name="VCLinkerTool"
  28. -               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 lua51.lib"
  29. +               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 lua51.lib"
  30.                 OutputFile=".\snes9x-x64.exe"
  31.                 LinkIncremental="1"
  32.                 SuppressStartupBanner="true"
  33. @@ -284,7 +284,7 @@
  34.             />
  35.             <Tool
  36.                 Name="VCLinkerTool"
  37. -               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 lua51.lib"
  38. +               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 lua51.lib"
  39.                 OutputFile=".\snes9x-debug.exe"
  40.                 LinkIncremental="1"
  41.                 SuppressStartupBanner="true"
  42. @@ -383,7 +383,7 @@
  43.             />
  44.             <Tool
  45.                 Name="VCLinkerTool"
  46. -               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 lua51.lib"
  47. +               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 lua51.lib"
  48.                 OutputFile=".\snes9x-debug-x64.exe"
  49.                 LinkIncremental="1"
  50.                 SuppressStartupBanner="true"
  51. @@ -480,7 +480,7 @@
  52.             />
  53.             <Tool
  54.                 Name="VCLinkerTool"
  55. -               AdditionalDependencies="libpngmt.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 lua51.lib"
  56. +               AdditionalDependencies="libpngmt.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 lua51.lib"
  57.                 OutputFile=".\snes9x-debug.exe"
  58.                 LinkIncremental="1"
  59.                 SuppressStartupBanner="true"
  60. @@ -576,7 +576,7 @@
  61.             />
  62.             <Tool
  63.                 Name="VCLinkerTool"
  64. -               AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib xapobase.lib zlibdmt.lib lua51.lib"
  65. +               AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib xapobase.lib zlibdmt.lib shlwapi.lib lua51.lib"
  66.                 OutputFile=".\snes9x-debug-x64.exe"
  67.                 LinkIncremental="1"
  68.                 SuppressStartupBanner="true"
  69. @@ -676,7 +676,7 @@
  70.             />
  71.             <Tool
  72.                 Name="VCLinkerTool"
  73. -               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 lua51.lib"
  74. +               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 lua51.lib"
  75.                 OutputFile=".\snes9x.exe"
  76.                 LinkIncremental="1"
  77.                 SuppressStartupBanner="true"
  78. @@ -775,7 +775,7 @@
  79.             />
  80.             <Tool
  81.                 Name="VCLinkerTool"
  82. -               AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib xapobase.lib zlibmt.lib lua51.lib"
  83. +               AdditionalDependencies="libpngmt.lib comctl32.lib winmm.lib opengl32.lib glu32.lib wsock32.lib ddraw.lib dsound.lib dxguid.lib delayimp.lib vfw32.lib xapobase.lib zlibmt.lib shlwapi.lib lua51.lib"
  84.                 OutputFile=".\snes9x-x64.exe"
  85.                 LinkIncremental="1"
  86.                 SuppressStartupBanner="true"
  87. @@ -872,7 +872,7 @@
  88.             />
  89.             <Tool
  90.                 Name="VCLinkerTool"
  91. -               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 lua51.lib"
  92. +               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 lua51.lib"
  93.                 OutputFile=".\snes9x-debug.exe"
  94.                 LinkIncremental="1"
  95.                 SuppressStartupBanner="true"
  96. @@ -973,7 +973,7 @@
  97.             />
  98.             <Tool
  99.                 Name="VCLinkerTool"
  100. -               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 lua51.lib"
  101. +               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 lua51.lib"
  102.                 OutputFile=".\snes9x-debug-x64.exe"
  103.                 LinkIncremental="1"
  104.                 SuppressStartupBanner="true"
  105. @@ -1080,7 +1080,7 @@
  106.             />
  107.             <Tool
  108.                 Name="VCLinkerTool"
  109. -               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 lua51.lib"
  110. +               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 lua51.lib"
  111.                 OutputFile=".\snes9x.exe"
  112.                 LinkIncremental="1"
  113.                 SuppressStartupBanner="true"
  114. @@ -1185,7 +1185,7 @@
  115.             />
  116.             <Tool
  117.                 Name="VCLinkerTool"
  118. -               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 lua51.lib"
  119. +               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 lua51.lib"
  120.                 OutputFile=".\snes9x-x64.exe"
  121.                 LinkIncremental="1"
  122.                 SuppressStartupBanner="true"
  123. diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp
  124. index 32dc4b5..1a5176d 100644
  125. --- a/win32/wsnes9x.cpp
  126. +++ b/win32/wsnes9x.cpp
  127. @@ -195,6 +195,7 @@
  128.  #include <shlobj.h>
  129.  #include <objidl.h>
  130.  #include <Shobjidl.h>
  131. +#include <shlwapi.h>
  132.  
  133.  #include "wsnes9x.h"
  134.  #include "win32_sound.h"
  135. @@ -1494,9 +1495,24 @@ LRESULT CALLBACK WinProc(
  136.         if (fileCount == 1) {
  137.             DragQueryFile(hDrop, 0, droppedFile, PATH_MAX);
  138.  
  139. +           LPCTSTR extension = PathFindExtension(droppedFile);
  140.             if (ExtensionIsValid(droppedFile)) {
  141.                 LoadROM(droppedFile);
  142. -           } else {
  143. +           }
  144. +           else if (lstrcmpi(extension, TEXT(".lua")) == 0) {
  145. +               if(LuaScriptHWnds.size() < 16)
  146. +               {
  147. +                   char temp [1024];
  148. +                   strcpy(temp, droppedFile);
  149. +                   HWND IsScriptFileOpen(const char* Path);
  150. +                   if(!IsScriptFileOpen(temp))
  151. +                   {
  152. +                       HWND hDlg = CreateDialog(GUI.hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc);
  153. +                       SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp);
  154. +                   }
  155. +               }
  156. +           }
  157. +           else {
  158.                 S9xMessage(S9X_ERROR, S9X_ROM_INFO, "Unknown file extension.");
  159.             }
  160.         }
  161. --
  162. 1.7.3.1.msysgit.0
RAW Paste Data