Advertisement
djvj

scummvm module

Jan 26th, 2016
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. MEmu = ScummVM
  2. MEmuV = v1.7.0
  3. MURL = http://scummvm.org/
  4. MAuthor = djvj,brolly
  5. MVersion = 2.1.2
  6. MCRC = F1AA08B4
  7. iCRC = A0D209E7
  8. MID = 635038268922749586
  9. MSystem = "ScummVM","Microsoft MS-DOS"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; If your games are compressed archives, set your Rom_Path to the folder with all your games and Rom_Extension to just the archive type.
  13. ; Set Skipchecks to "Rom Extension" for this system If your roms are compressed archives and also turn on 7z support.
  14. ; If your games are already uncompressed into their own folders, set Skipchecks to "Rom Only" so RocketLauncher knows not to look for rom files.
  15. ;
  16. ; ScummVM will save the scummvm.ini file to %AppData%\ScummVM\scummvm.ini
  17. ; To add multiple games to ScummVM, put the mouse on top of the "Add Game" button and press Shift, the button caption will change to Mass Add, then click the button
  18. ; and navigate to the main folder where you have all your uncompressed ScummVM games.
  19. ;
  20. ; You can set your Save/Load/Menu hotkeys below to access them in game.
  21. ; The hotkeys will be processed by xHotkey, so they can be defined just like you would your Exit_Emulator_Key (like with delays or multiple sets of keys)
  22. ;
  23. ; If you prefer a portable ScummVM, place your scummvm.ini somewhere Else, like in the emulator's folder and set CustomConfig's path to this file. It will work with the ini from there instead of your appdata folder.
  24. ;
  25. ; You can manually map your database rom names to archive files If you keep your games compressed and have the files named differently from your database by putting a file named ZipMapping.ini in the modules folder (or ZipMapping - SystemName.ini), this file contents should be as follows:
  26. ; [mapping]
  27. ; romName=zipFileName
  28. ;
  29. ; Launch Method 1 - Rom_Path has archived games inside a zip, 7z, rar, etc
  30. ; Set Skipchecks to Rom Extension and enable 7z
  31. ; Launch Method 2 - Rom_Path has each game inside its own folder and uncompressed
  32. ; Set Skipchecks to Rom Only and disable 7z
  33. ; Launch Method 3 - Rom_Path has archived games inside a zip, 7z, rar, etc, all named from the scummvm torrent that does not match the names on your xml
  34. ; Set Skipchecks to Rom Extension, enable 7z, enable Rom Mapping. Make sure a proper mapping ini exists in the appropriate settings Rom Mapping folder and it contains all the correct mapping info.
  35. ;----------------------------------------------------------------------------
  36. StartModule()
  37. BezelGUI()
  38. FadeInStart()
  39.  
  40. settingsFile := modulePath . "\" . (If FileExist(modulePath . "\" . systemName . ".ini") ? systemName : moduleName) . ".ini" ; use a custom systemName ini If it exists
  41. scummDefaultConfigFile := A_AppData . "\ScummVM\scummvm.ini" ; ScummVM's default ini file it creates on first launch
  42. customConfigFile := IniReadCheck(settingsFile, "Settings", "CustomConfig","",,1) ; Set the path to a custom config file and the module will use this instead of the ScummVM's default one
  43. customConfigFile := GetFullName(customConfigFile) ; convert relative path to absolute
  44. configFile := CheckFile(If customConfigFile ? customConfigFile : scummDefaultConfigFile) ; checks If either the default config file or the custom one exists
  45. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  46. LaunchMode := IniReadCheck(settingsFile, "Settings|" . romName, "LaunchMode", "Auto",,1)
  47. GraphicFilter := IniReadCheck(settingsFile, "Settings|" . romName, "GraphicFilter", "Normal",,1)
  48. TargetName := IniReadCheck(settingsFile, romName, "TargetName", romName,,1)
  49. ForceExtractionToRomPath := IniReadCheck(settingsFile, "Settings" . "|" . romName, "ForceExtractionToRomPath", "false",,1)
  50. BezelDelay := IniReadCheck(settingsFile, "Settings|" . romName, "BezelDelay", "0",,1)
  51.  
  52. SaveKey := IniReadCheck(settingsFile, "Settings", "SaveKey","1",,1) ; hotkey to save state
  53. LoadKey := IniReadCheck(settingsFile, "Settings", "LoadKey","2",,1) ; hotkey to load state
  54. MenuKey := IniReadCheck(settingsFile, "Settings", "MenuKey","p",,1) ; hotkey to access the ScummVM menu
  55.  
  56. BezelStart()
  57.  
  58. If (sevenZEnabled != "true")
  59. If RegExMatch(romExtension,"i)" . sevenZFormatsRegEx)
  60. ScriptError("Your rom """ . romName . """ is a compressed archive`, but you have 7z support disabled. ScummVM does not support launching compressed roms directly. Enable 7z or extract your rom.",8)
  61.  
  62. ;Find the zip filename by looking it up in the ZipMapping.ini file or ZipMapping - SystemName.ini If one exists
  63. If FileExist(modulePath . "\ZipMapping - " . systemName ".ini")
  64. ZipMappingFile := modulePath . "\ZipMapping - " . systemName ".ini"
  65. Else
  66. ZipMappingFile := modulePath . "\ZipMapping.ini"
  67.  
  68. ZipName := IniReadCheck(ZipMappingFile, "mapping", romname, romname . (If romExtension ? romExtension : ".zip"),,1)
  69.  
  70. If (LaunchMode = "eXoDOS") {
  71. ;Find and set the romPath in case we have several
  72. romPathFound := "false"
  73. If (sevenZEnabled = "true")
  74. {
  75. Loop, Parse, romPath, |
  76. {
  77. currentPath := A_LoopField
  78. Log("Module - Searching for rom " . ZipName . " in " . currentPath,4)
  79. If FileExist(currentPath . "\" . ZipName)
  80. {
  81. romPath := currentPath
  82. romPathFound := "true"
  83. }
  84. }
  85. If (romPathFound != "true")
  86. ScriptError("Couldn't find rom " . ZipName . " in any of the defined rom paths")
  87. } Else {
  88. Loop, Parse, romPath, |
  89. {
  90. currentPath := A_LoopField
  91. Log("Module - Searching for rom " . romname . " in " . currentPath,4)
  92. If InStr(FileExist(currentPath . "\" . romname), "D")
  93. {
  94. romPath := currentPath
  95. romPathFound := "true"
  96. }
  97. }
  98. If (romPathFound != "true")
  99. ScriptError("Couldn't find rom " . romname . " in any of the defined rom paths")
  100. }
  101.  
  102. If (ForceExtractionToRomPath = "true") {
  103. Log("Module - ForceExtractionToRomPath is set to true, setting sevenZExtractPath to " . romPath . ". Careful when using this setting!",4)
  104. sevenZExtractPath := romPath
  105. }
  106. }
  107.  
  108. ;Lets split filename and extension
  109. SplitPath, ZipName,,,zipExtension,zipFileName
  110.  
  111. hideEmuObj := Object("ahk_class SDL_app",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  112. ;7z(romPath, romName, romExtension, sevenZExtractPath)
  113. 7z(romPath,zipFileName,"." . zipExtension,sevenZExtractPath,,If LaunchMode = "eXoDOS" ? "false" : "true")
  114.  
  115. ; Send ScummVM hotkeys through xHotkey so they are linked to the labels below
  116. SaveKey := xHotKeyVarEdit(SaveKey,"SaveKey","~","Add")
  117. LoadKey := xHotKeyVarEdit(LoadKey,"LoadKey","~","Add")
  118. MenuKey := xHotKeyVarEdit(MenuKey,"MenuKey","~","Add")
  119. xHotKeywrapper(SaveKey,"ScummvmSave")
  120. xHotKeywrapper(LoadKey,"ScummvmLoad")
  121. xHotKeywrapper(MenuKey,"ScummvmMenu")
  122.  
  123. If (LaunchMode = "ParseIni")
  124. { Log("Module - Launch mode: ParseIni")
  125. ;Try parsing the scummvm config ini file for the path
  126. StringReplace, romNameChanged, TargetName, %A_Space%, _, All ; replace all spaces in the name we lookup in ScummVM's ini because ScummVM does not support spaces in the section name
  127. romNameChanged := RegExReplace(romNameChanged, "\(|\)", "_") ; replaces all parenthesis with underscores
  128. If (TargetName != romNameChanged)
  129. Log("Module - Removed all unsupported characters from """ . TargetName . """ and using this to search for a section in ScummVM's ini: """ . romNameChanged . """")
  130.  
  131. scummRomPath := IniReadCheck(configFile, romNameChanged, "path",,,1) ; Grab the path in ScummVM's config
  132. ; msgbox % scummRomPath
  133. If (SubStr(scummRomPath, 0, 1) = "\") ; scummvm doesn't like sending it paths with a \ as the last character. If it exists, remove it.
  134. StringTrimRight, scummRomPath, scummRomPath, 1
  135. ; msgbox % scummRomPath
  136. If !scummRomPath {
  137. Log("Module - Could not locate a path in ScummVM's ini for section """ . romNameChanged . """. Checking If a path exists for the dbName instead: """ . dbName . """",2)
  138. scummRomPath := IniReadCheck(configFile, dbName, "path",,,1) ; If the romName, after removing all unsupporting characters to meet ScummVM's section name requirements, could not be found, try looking up the dbName instead
  139. }
  140. If !FileExist(scummRomPath) ; If user does not have a path set to this game in the ScummVM ini or the path does not exist that is set, attempt to send a proper one in CLI
  141. { Log("Module - " . (If !scummRomPath ? "No path defined in ScummVM's ini" : ("The path defined in ScummVM's ini does not exist : " . scummRomPath)) . ". Attempting to find a correct path to your rom and sending that to ScummVM.",2)
  142. If (InStr(romPath, romName) && FileExist(romPath)) { ; If the romName is already in the path of the romPath and that path exists, attempt to set that as the path we send to ScummVM
  143. scummRomPath := romPath
  144. Log("Module - Changing " . romName . " path to: " . scummRomPath,2)
  145. } Else If (FileExist(romPath . "\" . romName)) { ; If the romPath doesn't have the romName in the path, let's add it to check If that exists and send that.
  146. scummRomPath := romPath . "\" . romName
  147. Log("Module - Changing " . romName . " path to: " . scummRomPath,2)
  148. } Else
  149. ScriptError("The path to """ . romName . """ was not found. Please set it correctly by manually launching ScummVM and editing this rom's path to where it can be found.")
  150. }
  151. } Else If (LaunchMode = "eXoDOS") {
  152. Log("Module - Launch mode: eXoDOS")
  153. ;On eXoDOS sets game MUST be at this folder
  154. scummRomPath := CheckFile(romPath . "\" . romName)
  155. romNameChanged := TargetName
  156. } Else {
  157. Log("Module - Launch mode: Standard")
  158. ;Auto mode, scummRomPath will be empty here as everything will be read from the scummvm config ini file
  159. romNameChanged := TargetName
  160. }
  161.  
  162. options := " --no-console"
  163. configFile := If customConfigFile ? " -c""" . configFile . """" : "" ; If user set a path to a custom config file
  164. fullscreen := If Fullscreen = "true" ? " -f" : " -F"
  165. scummRomPath := If scummRomPath ? " -p""" . scummRomPath . """" : ""
  166.  
  167. If bezelPath
  168. GraphicFilter := " -gopengl_nearest"
  169. Else
  170. GraphicFilter := If GraphicFilter ? " -g" . GraphicFilter : ""
  171.  
  172. HideEmuStart()
  173. Run(executable . options . fullscreen . configFile . GraphicFilter . scummRomPath . " " . romNameChanged, emuPath)
  174.  
  175. WinWait("ahk_class SDL_app")
  176. WinWaitActive("ahk_class SDL_app")
  177.  
  178. Sleep, 700 ; Necessary otherwise your Front End window flashes back into view
  179.  
  180. If bezelPath
  181. Sleep, % bezelDelay
  182.  
  183. BezelDraw()
  184. HideEmuEnd()
  185. FadeInExit()
  186. Process("WaitClose", executable)
  187. 7zCleanUp(If LaunchMode = "eXoDOS" ? sevenZExtractPath . "\" . romName : "")
  188. BezelExit()
  189. FadeOutExit()
  190. ExitModule()
  191.  
  192.  
  193. ScummvmSave:
  194. Send, !1
  195. Return
  196. ScummvmLoad:
  197. Send, ^1
  198. Return
  199. ScummvmMenu:
  200. Send, ^{F5}
  201. Return
  202.  
  203. HaltEmu:
  204. If SaveKey
  205. XHotKeywrapper(SaveKey,"ScummvmSave","OFF")
  206. If LoadKey
  207. XHotKeywrapper(LoadKey,"ScummvmLoad","OFF")
  208. If MenuKey
  209. XHotKeywrapper(MenuKey,"ScummvmMenu","OFF")
  210. Return
  211.  
  212. RestoreEmu:
  213. If SaveKey
  214. XHotKeywrapper(SaveKey,"ScummvmSave","ON")
  215. If LoadKey
  216. XHotKeywrapper(LoadKey,"ScummvmLoad","ON")
  217. If MenuKey
  218. XHotKeywrapper(MenuKey,"ScummvmMenu","ON")
  219. Return
  220.  
  221. CloseProcess:
  222. FadeOutStart()
  223. WinClose("ahk_class SDL_app")
  224. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement