Advertisement
djvj

Untitled

Jan 10th, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.04 KB | None | 0 0
  1. MEmu = MFME
  2. MEmuV = v3.2 & v9.4 & v10.1a
  3. MURL = http://www.fruit-emu.com/
  4. MAuthor = djvj
  5. MVersion = 2.0.7
  6. MCRC =
  7. iCRC =
  8. MID =
  9. MSystem = "Fruit Machine","MFME"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; MFME's different versions all support different games. No one version plays them all. Place all your MFME exes into your Emu_Path dir. Create one emu section for each of the 3 MFME versions used by this module in your Global Emulators or Emulators.ini
  13. ; Each game should be in its own dir. The dir name should match the game name from your database xml.
  14. ; Each game has a ".gam" file, It's name needs to match the name from the database. This is like a cue file that contains info about a game's settings and where to find the rest of the files.
  15. ; For example, if you have a game name of "Back To The Features" and when you extract the game it looks like this:
  16. ; Back To The Features\Back_To_The_Features.gam
  17. ; Rename it so it looks like this:
  18. ; Back To The Features\Back To The Features.gam
  19. ;
  20. ; MFME layouts only support a fixed resolution, so if your desktop is not set to the same size as these layouts, it takes away from the MFME environment. By default this resolution is 1280x1024, so the module will change your desktop to match if resizeDesktop is enabled (default).
  21. ;
  22. ; Your Games.ini needs to have a section for each game that will not use your default emulator defined in Emulators.ini. This module supports MFME v3.2, 9.4, and 10.1a
  23. ; I would set MFME v10.1a as your default emulator.
  24. ; For each game that needs to use MFME v9.4, create a section like this:
  25. ; [Game 1]
  26. ; Emulator=MFME v9.4
  27. ; For each game that needs to use MFME v3.2, create a section like this:
  28. ; [Game 1]
  29. ; Emulator=MFME v3.2
  30. ; See the RocketLauncher site on how to use Games.ini for additional help
  31.  
  32. ; If you use Magnifier mode, start it manually once and set it's view to Dock, then Exit
  33. ; If you want the script to be able to move and remove the border/title of the magnifier window, it has to be done as admin or you need to turn off UAC.
  34. ; Optionally you can set MagnifyWrapper.exe to run as admin if you are on win7 or greater and it will close Magnifier on exit
  35. ; One known issue is the magnifier window sometimes won't launch with the desired position on screen. Yet if you launch it manually it will show where you previously told it to start. I can't find the solution to this as the values are being stored in the registry properly.
  36. ; Magnifier's settings are stored in the registry @ HKEY_CURRENT_USER\Software\Microsoft\ScreenMagnifier
  37. ;
  38. ; MFME stores its settings (pretty much only launch history) in the registry @ HKEY_CURRENT_USER\Software\CJW\MFME
  39. ; As far as I can tell, there is no way to go fullscreen (only v3.2 supports it)
  40. ;----------------------------------------------------------------------------
  41. StartModule()
  42. BezelGUI()
  43.  
  44. settingsFile := modulePath . "\" . moduleName . ".ini"
  45. minimizeWindows := IniReadCheck(settingsFile, "Settings", "minimizeWindows","true",,1)
  46. resizeDesktop := IniReadCheck(settingsFile, "Settings", "resizeDesktop","true",,1)
  47. backgroundPic := IniReadCheck(settingsFile, "Settings", "backgroundPic",modulePath . "\Background.png",,1)
  48. magnify := IniReadCheck(settingsFile, "Settings", "Magnify","true",,1) ; Create a windows magnifier window in the bottom right corner to see things closer over your cursor
  49. magnifyPercentage := IniReadCheck(settingsFile, "Settings", "MagnifyPercentage","200",,1)
  50. magnifyAlignment := IniReadCheck(settingsFile, "Settings", "MagnifyAlignment","Bottom Right Corner",,1)
  51. magWinW := IniReadCheck(settingsFile, "Settings", "MagnifyWinSizeW","245",,1)
  52. magWinH := IniReadCheck(settingsFile, "Settings", "MagnifyWinSizeH","245",,1)
  53. magWinX := IniReadCheck(settingsFile, "Settings", "MagnifyWinPosX",A_Space,,1)
  54. magWinY := IniReadCheck(settingsFile, "Settings", "MagnifyWinPosY",A_Space,,1)
  55. ambientSound := IniReadCheck(settingsFile, "Settings", "ambientSound","true",,1)
  56. ambientSoundFile := IniReadCheck(settingsFile, "Settings", "ambientSoundFile",moduleExtensionsPath . "\Quiet atmosphere in a small restaurant (indistinct speech) - 1978 (1R8,reprocessed).mp3",,1)
  57. ambientSoundPlayer := IniReadCheck(settingsFile, "Settings", "ambientSoundPlayer",moduleExtensionsPath . "\djAmbiencePlayer.exe",,1)
  58. ambientStopKey := IniReadCheck(settingsFile, "Settings", "ambientStopKey","PAUSE",,1)
  59. resetKey := IniReadCheck(settingsFile, "Settings", "resetKey","F12",,1) ; key to reset the game while playing
  60.  
  61. If (magnify = "true")
  62. { magnifyWrapperFullPath := moduleExtensionsPath . "\MagnifyWrapper.exe"
  63. magnifyFullPath := A_WinDir . "\system32\magnify.exe"
  64. SplitPath, magnifyWrapperFullPath, magnifyWrapperName, magnifyWrapperPath
  65. SplitPath, magnifyFullPath, magnifyName, magnifyPath
  66. CheckFile(magnifyWrapperFullPath, "You have Magnify enabled but could not find the module extension to handle it: " . magnifyWrapperFullPath)
  67. CheckFile(magnifyFullPath,"Could not find Windows Magnifier in " . magnifyFullPath . "`nPlease disable Magnify in the module settings in RocketLauncherUI, or copy it to the above folder.")
  68. }
  69. If (ambientSound = "true")
  70. { ambientSoundFile := CheckFile(ambientSoundFile)
  71. ambientSoundPlayer := CheckFile(ambientSoundPlayer)
  72. SplitPath, ambientSoundPlayer, ambientSoundPlayerName, ambientSoundPlayerPath
  73. }
  74.  
  75. ; This gets rid of the emu window that pops up on launch
  76. ; GUI 5 creates the background that persists during gameplay.
  77. If (fadeIn = "true")
  78. { ; must keep fade on its own line so it passes authenticity checks
  79. FadeInStart()
  80. Gui 5: +LastFound
  81. WinGet GUI_ID5, ID
  82. Gui 5: -AlwaysOnTop -Caption +ToolWindow
  83. Gui 5: Color, %loadingColor%
  84. backgroundPicHandle := Gdip_CreateBitmapFromFile(backgroundPic)
  85. Gdip_GetImageDimensions(backgroundPicHandle, backgroundPicW, backgroundPicH)
  86. Log("Module - backgroundPic's dimensions are: " . backgroundPicW . "x" . backgroundPicH,4)
  87. backXPos := ( A_ScreenWidth / 2 ) - ( backgroundPicW / 2 )
  88. backYPos := ( A_ScreenHeight / 2 ) - ( backgroundPicH / 2 )
  89. Gui 5: Add, Picture,x%backXPos% y%backYPos%, %backgroundPic%
  90. Gui 5: Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%
  91. Log("Module - Displaying backgroundPic's dimensions at - x: " . backXPos . " y: " . backYPos,4)
  92. }
  93.  
  94. resetKey := xHotKeyVarEdit(resetKey,"resetKey","~","Add")
  95. xHotKeywrapper(resetKey,"Reset")
  96.  
  97. If (minimizeWindows = "true")
  98. WinMinimizeAll
  99.  
  100. BezelStart()
  101.  
  102. If (resizeDesktop = "true")
  103. { ;Sleep, 1000 ; probably don't need this
  104. currentFloat := A_FormatFloat ; backup current float
  105. SetFormat, Float, 6.2
  106. If bezelPath ; if bezels are user, utilized monitor should be the desired bezel monitor, not the primary one for the system
  107. MFME_Monitor := bezelMonitor
  108. Else
  109. MFME_Monitor := primMonitor
  110. ; msgbox % MFME_Monitor
  111. ; originalScreenRes := ConvertToMonitorObject(MFME_Monitor . "|" . MonitorTable[MFME_Monitor].Width . "|" . MonitorTable[MFME_Monitor].Height . "|" . MonitorTable[MFME_Monitor].BitDepth . "|" . MonitorTable[MFME_Monitor].Frequency) ; build monitor object
  112. ; originalScreenRes := CheckForNearestSupportedRes(MFME_Monitor, originalScreenRes) ; assures that the current resolution is a compatible mode (sometimes the frequency can be wrongly defined on the previous function, this line double check this to avoid any issues).
  113. ; desiredRes := ConvertToMonitorObject(MFME_Monitor . "|1280|1024|" . originalScreenRes[MFME_Monitor].BitDepth . "|" . originalScreenRes[MFME_Monitor].Frequency ) ; build monitor object from array
  114. ; desiredRes := CheckForNearestSupportedRes(MFME_Monitor, desiredRes) ; determine the supported res nearest to the desired 1280x1024 res.
  115. ; Log("Module - Changing monitor " . MFME_Monitor . " to resolution width: " . desiredRes[MFME_Monitor].Width . ", height: " . desiredRes[MFME_Monitor].Height . ", bit depth: " . desiredRes[MFME_Monitor].BitDepth . ", frequency: " . desiredRes[MFME_Monitor].Frequency,1)
  116. ; SetDisplaySettings(desiredRes) ; changes the res to 1280x1024
  117. desiredRes := ConvertToMonitorObject(MFME_Monitor . "|1280|1024|" . monitorTable[MFME_Monitor].BitDepth . "|" . monitorTable[MFME_Monitor].Frequency ) ; build monitor object from array
  118. desiredRes := CheckForNearestSupportedRes(MFME_Monitor, desiredRes) ; determine the supported res nearest to the desired 1280x1024 res.
  119. Log("Module - Changing monitor " . MFME_Monitor . " to resolution width: " . desiredRes[MFME_Monitor].Width . ", height: " . desiredRes[MFME_Monitor].Height . ", bit depth: " . desiredRes[MFME_Monitor].BitDepth . ", frequency: " . desiredRes[MFME_Monitor].Frequency,1)
  120. SetDisplaySettings(desiredRes) ; changes the res to 1280x1024
  121.  
  122. ; mfmeMonObj := ConvertToMonitorObject(MFME_Monitor . "|1280|1024|" . monitorTable[monitorTable.PrimaryMonitor].BitDepth . "|" . monitorTable[monitorTable.PrimaryMonitor].Frequency) ; build monitor object from array
  123. ; mfmeRes := CheckForNearestSupportedRes(MFME_Monitor, mfmeMonObj) ; find closest supported res for the monitor that matches the bezel's size
  124. ; SetDisplaySettings(mfmeMonObj) ; change current res to one that matches the bezel's size
  125. ;Sleep, 1000 ; probably don't need this
  126. }
  127.  
  128. hideEmuObj := Object("ahk_class TForm1",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  129. 7z(romPath, romName, romExtension, sevenZExtractPath)
  130.  
  131. HideEmuStart()
  132.  
  133. emuPID := Run(executable . " """ . romPath . "\" . romName . romExtension . """", emuPath)
  134.  
  135. WinWait("ahk_class TForm1")
  136. WinWaitActive("ahk_class TForm1")
  137.  
  138. Sleep, 1000
  139. WinSet, Style, -0xC00000, ahk_class TForm1 ;Removes the titlebar of the game window
  140. WinSet, Style, -0x40000, ahk_class TForm1 ;Removes the border of the game window
  141. DllCall("SetMenu", uint, WinActive( "A" ), uint, 0) ;Removes the MenuBar
  142. ; Control, Hide, , TPanel, AHK_class TForm1 ;Removes the TPanel - Doesn't seem to work
  143. ; WinSet, TransColor, F0F0F0, ahk_class TForm1 ; Removes the grey around the machine, but slightly darkens the overall image
  144.  
  145. WinActivate, ahk_class TForm1
  146. WinWaitActive("ahk_class TForm1")
  147.  
  148. If (magnify = "true")
  149. { Sleep, 500
  150. magPID := Process("Exist", magnifyName)
  151. If (magPID != 0)
  152. Process("Close", magnifyName)
  153.  
  154. GetMagWinPosition(magWinX, magWinY, magWinW, magWinH, magnifyAlignment) ; Calculate the positioning of the Magnify Window
  155.  
  156. ; If A_OSVersion not in WIN_2003, WIN_XP, WIN_2000, WIN_NT4, WIN_95, WIN_98, WIN_M
  157. ; { RootKey = HKCU
  158. ; SubKey = Software\Microsoft\ScreenMagnifier
  159. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,MagnifierUIWindowMinimized, 1 ; start with ui minimized
  160. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,MagnificationMode, 1 ;choosing docked mode
  161. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,ClassicDocked, 0 ;choosing classic window mode
  162. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,Magnification, %magnifyPercentage% ;Magnification Percentage
  163. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,ClassicWindowX, %magWinX% ;Window Pos x
  164. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,ClassicWindowY, %magWinY% ;Window Pos y
  165. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,ClassicWindowCX, %magWinW% ;Window Width
  166. ; regwrite, REG_DWORD ,%RootKey%,%SubKey%,ClassicWindowCY, %magWinH% ;Window Height
  167. ; }
  168. ; Run(magnifierExe) ;,, Min
  169. ; WinWait("ahk_class Screen Magnifier Window",,5)
  170. ; If ErrorLevel {
  171. ; SetKeyDelay, 50
  172. ; Send,^!d ; turning on docked mode - does not work w/o admin mode
  173. ; Sleep, 3000
  174. ; }
  175. ; WinWait("ahk_class Screen Magnifier Window",,6)
  176. ; If ErrorLevel {
  177. ; mfmeError=1
  178. ; Gosub, CloseProcess
  179. ; }
  180. If RegExMatch(A_OSVersion,"i)WIN_2003|WIN_XP|WIN_2000|WIN_NT4|WIN_95|WIN_98|WIN_M")
  181. { XpBelow := "true"
  182. WinSet, Style, -0xC00000, ahk_class Screen Magnifier Window ;Removes the titlebar of the magnifier window
  183. WinSet, Style, -0x40000, ahk_class Screen Magnifier Window ;Removes the border of the magnifier window
  184. WinMinimize, ahk_class MagUIClass
  185. WinMove, ahk_class Screen Magnifier Window,, %magWinX%, %magWinY%, %magWinW%, %magWinH%
  186. } Else {
  187. ;This is because of UAC control if it's turned off this will run much smoother
  188. ; errorLvl := Run("MagnifyWrapper.exe """ . executable . """ " . x . " " . y, modulePath,"UseErrorLevel")
  189. errorLvl := Run(magnifyWrapperName . """" . executable . """ " . magWinX . " " . magWinY . " " . magWinW . " " . magWinH, modulePath,"UseErrorLevel")
  190. If errorLvl {
  191. mfmeError := 1
  192. Goto, CloseProcess
  193. }
  194. }
  195. }
  196.  
  197. If (ambientSound = "true")
  198. Run(ambientSoundPlayerName . " """ . ambientSoundFile . """ " . ambientStopKey, ambientSoundPlayerPath)
  199.  
  200. If (resizeDesktop = "true")
  201. SetFormat, Float, %currentFloat% ; restore previous value
  202.  
  203. BezelDraw()
  204. HideEmuEnd()
  205. FadeInExit()
  206.  
  207. ; WinSet, TransColor, 42424A 200, ahk_class TForm1
  208. ; PID doesn't seem to work for MFME, so have to use this method instead
  209. Process("WaitClose", executable)
  210. BezelExit()
  211.  
  212. If (magnify = "true") And (XpBelow = "true")
  213. Process("Close",magnifyName)
  214.  
  215. If (ambientSound = "true")
  216. Process("Close", ambientSoundPlayerName)
  217.  
  218. ;restore original resolution
  219. If (resizeDesktop = "true")
  220. {
  221. ; Log("Module - Restoring monitor " . MFME_Monitor . " to resolution width: " . originalScreenRes[MFME_Monitor].Width . ", height: " . originalScreenRes[MFME_Monitor].Height . ", bit depth: " . originalScreenRes[MFME_Monitor].BitDepth . ", frequency: " . originalScreenRes[MFME_Monitor].Frequency,1)
  222. ; SetDisplaySettings(originalScreenRes) ; change res back to original
  223. SetDisplaySettings(monitorTable) ; change res back to original
  224. ;Sleep, 1000
  225. }
  226.  
  227. If (minimizeWindows = "true")
  228. WinMinimizeAllUndo
  229.  
  230. 7zCleanUp()
  231.  
  232. If mfmeError {
  233. Sleep, 1000 ; giving some extra time in case desktop needs to be resized
  234. ScriptError("There was an error launching and docking the Magnifier window. Please manually start Magnifier and set it to docked view.")
  235. }
  236.  
  237. FadeOutExit()
  238. ExitModule()
  239.  
  240.  
  241. GetMagWinPosition(ByRef x, ByRef y, ByRef w, ByRef h,pos){
  242. SysGet, b, 2 ; SM_CXVSCROLL - Get size of scrollbars, use this to adjust the size, and position of the final window. If this is not adjusted, the magnifier window has white background on the bottom and right sides.
  243. If (pos = "Center") {
  244. x := ( A_ScreenWidth / 2 ) - ( w / 2 ) + ( b / 2 )
  245. y := ( A_ScreenHeight / 2 ) - ( h / 2 ) + ( b / 2 )
  246. } Else If (pos = "Top Left Corner") {
  247. x := 0
  248. y := 0
  249. } Else If (pos = "Top Right Corner") {
  250. x := A_ScreenWidth - w + b
  251. y := 0
  252. } Else If (pos = "Bottom Left Corner") {
  253. x := 0
  254. y := A_ScreenHeight - h + b
  255. } Else If (pos = "Bottom Right Corner") {
  256. x := A_ScreenWidth - w + b
  257. y := A_ScreenHeight - h + b
  258. } Else If (pos = "Top Center") {
  259. x := ( A_ScreenWidth / 2 ) - ( w / 2 ) + ( b / 2 )
  260. y := 0
  261. } Else If (pos = "Bottom Center") {
  262. x := ( A_ScreenWidth / 2 ) - ( w / 2 ) + b
  263. y := A_ScreenHeight - h + b
  264. } Else If (pos = "Left Center") {
  265. x := 0
  266. y := ( A_ScreenHeight / 2 ) - ( h / 2 ) + ( b / 2 )
  267. } Else If (pos = "Right Center") {
  268. x := A_ScreenWidth - w + b
  269. y := ( A_ScreenHeight / 2 ) - ( h / 2 ) + ( b / 2 )
  270. } Else {
  271. x := x
  272. y := y
  273. }
  274. w := w - b
  275. h := h - b
  276. }
  277.  
  278. Reset:
  279. Send !r
  280. Return
  281.  
  282. CloseProcess:
  283. FadeOutStart()
  284. Sleep, 400
  285. ; WinClose("MFME")
  286. ; WinClose("ahk_pid " . emuPID)
  287. WinClose("ahk_class TForm1")
  288. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement