Advertisement
djvj

Untitled

Feb 8th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.65 KB | None | 0 0
  1. MEmu = Pinball Arcade
  2. MEmuV = N/A
  3. MURL = http://www.pinballarcade.com/
  4. MAuthor = djvj
  5. MVersion = 2.0
  6. MCRC = 63231BD7
  7. iCRC = C6BAEB7E
  8. mId = 635589857631115764
  9. MSystem = "Pinball Arcade","Pinball"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Initial setup:
  13. ; You must own all the games in the current module!!
  14. ; Manually run Pinball Arcade. If you own all the games and they can all be found in the My Tables folder, Simply Enter the My Tables folder and browse to the first table (alphabetically) and exit Pinball Arcade.
  15. ; The module comes default with all the available tables (as of 1/14/2014) alphabetically sorted in the module setting My_Tables.
  16. ; It will parse this setting and assume you own all the games. If you do not own all the games, recreate this setting in HLHQ with all the games you own, and separate each one with a |
  17. ;
  18. ; If you do not own all the games, there is some code implemented to deal with it, but it is not finished, so will not work.
  19. ; If you do not own all the games and the ones you do not own are in the Season folders and in your database (so you want to play them in free mode), enter each Season folder and browse to the first table (alphabetically) and exit Pinball Arcade when done.
  20. ; Order is critical that it matches what's in your My Tables folder.
  21. ;
  22. ; If launching as a Steam game:
  23. ; When setting this up in HLHQ under the global emulators tab, make sure to select it as a Virtual Emulator. Also no rom extensions, executable, or rom paths need to be defined.
  24. ; Set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  25. ;
  26. ; If not launching through Steam:
  27. ; Add this as any other standard emulator and define the PinballArcade.exe as your executable, but still select Virtual Emulator as you do not need rom extensions or rom paths
  28. ; Set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  29. ;
  30. ; This module requires BlockInput.exe to exist in your Module Extensions folder. It is used to prevent users from messing up the table selection routine.
  31. ; If BlockInput is not actually blocking input, it's due to not having admin credentials, which you will need to set this exe to run as admin.
  32. ; However, this also means HyperLaunch needs to be set to run as admin as well, keep this in mind.
  33. ;
  34. ; If you want bezel support set to the game be played in windowed mode
  35. ;
  36. ; How to run vertical games on a standard monitor:
  37. ; There are 3 methods supported by this module to rotate your desktop. Windows shortcuts, display.exe and irotate.exe. If one method does not work on your computer, try another.
  38. ;
  39. ; If the key sends are not working, make sure your hyperlaunch is set to run as administrator.
  40. ;
  41. ; Pinball Arcade stores some settings in your registry @ HKEY_CURRENT_USER\Software\PinballArcade\PinballArcade
  42. ;----------------------------------------------------------------------------
  43. StartModule()
  44.  
  45. settingsFile := modulePath . "\" . moduleName . ".ini"
  46. rotateMethod := IniReadCheck(settingsFile, "settings", "Rotate_Method",,,1) ; Shortcut, Display, iRotate
  47. rotateDisplay := IniReadCheck(settingsFile, "settings", "Rotate_Display", 0,,1) ; 0, 90, 180, 270
  48. moduleDebugging := IniReadCheck(settingsFile, "settings", "Module_Debugging", "false",,1)
  49.  
  50. If windowsRotate {
  51. Res := (A_ScreenWidth>A_ScreenWidth) ? A_ScreenWidth : A_ScreenWidth
  52. Gui 1: Color, 000000
  53. Gui 1: -Caption +ToolWindow
  54. Gui 1: Show, x0 y0 W%Res% H%Res%, BlackScreen ; experimental to hide entire desktop and windows
  55. If rotateMethod
  56. Rotate(rotateMethod, rotateDisplay)
  57. }
  58.  
  59. BezelGUI()
  60. FadeInStart()
  61.  
  62. pinballTitleClass := "Pinball Arcade ahk_class Pinball Arcade"
  63. fullscreen := IniReadCheck(settingsFile, "settings", "Fullscreen", "true",,1) ; 0, Shortcut, Display, iRotate
  64. sleepLogo := IniReadCheck(settingsFile, "Settings", "Sleep_Until_Logo",7000,,1)
  65. sleepBaseTime := IniReadCheck(settingsFile, "Settings", "Sleep_Base_Time",1,,1)
  66. initialSelection := IniReadCheck(settingsFile, "Settings", "Initial_Selection","MyTables",,1)
  67. lastMyTable := "Attack from Mars (Bally)" ; Mytables always starts on Attack from Mars
  68. ; myTables := IniReadCheck(settingsFile, "Settings", "My_Tables","Attack From Mars|Big Shot|Black Hole|Black Knight|Bride of Pin-Bot|Cactus Canyon|Centaur|Central Park|Champion Pub|Cirqus Voltaire|Class of 1812|Creature from the Black Lagoon|Cue Ball Wizard|Dr. Dude|El Dorado - City of Gold|Elvira|Firepower|Fish Tales|Flight 2000|Funhouse|Genie|Goin' Nuts|Gorgar|Harley-Davidson|Haunted House|Medieval Madness|Monster Bash|No Good Gofers|Pin-Bot|Ripley's Believe It or Not|Scared Stiff|Space Shuttle|Star Trek|Tales of the Arabian Nights|Taxi|Tee'd Off|Terminator 2|Theatre of Magic|Twilight Zone|Victory|Whirlwind|White Water",,1) ; | separated list of the tables I own
  69. myTables := IniReadCheck(settingsFile, "Settings", "My_Tables","Attack from Mars (Bally)|Big Shot (Gottlieb)|Black Hole (Gottlieb)|Black Knight 2000 (Williams)|Black Knight (Williams)|Black Rose (Bally)|Machine - Bride of Pin Bot, The (Williams)|Cactus Canyon (Bally)|Centaur (Bally)|Central Park (Gottlieb)|Champion Pub, The (Bally)|Cirqus Voltaire (Bally)|Class of 1812 (Gottlieb)|Creature from the Black Lagoon (Bally)|Cue Ball Wizard (Gottlieb)|Dr. Dude & His Excellent Ray (Bally)|El Dorado - City Of Gold (Gottlieb)|Elvira and the Party Monsters (Bally)|Firepower (Williams)|Fish Tales (Williams)|Flight 2000 (Stern)|FunHouse (Williams)|Genie (Gottlieb)|Goin' Nuts (Gottlieb)|Gorgar (Williams)|Harley-Davidson, 3rd Edition (Stern)|Haunted House (Gottlieb)|High Speed (Williams)|Junk Yard (Williams)|Medieval Madness (Williams)|Monster Bash (Williams)|No Good Gofers (Williams)|Pin Bot (Williams)|Ripley's Believe It or Not! (Stern)|Scared Stiff (Bally)|Space Shuttle (Williams)|Star Trek - The Next Generation (Williams)|Tales of the Arabian Nights (Williams)|Taxi (Williams)|Tee'd Off (Gottlieb)|Terminator 2 - Judgment Day (Williams)|Theatre of Magic (Bally)|Twilight Zone (Bally)|Victory (Gottlieb)|Whirlwind (Williams)|White Water (Williams)|WHO Dunnit (Bally)",,1) ; | separated list of the tables user owns
  70.  
  71. BezelStart()
  72.  
  73. ; get user's save path
  74. paUserPath := RegRead("HKCU", "Software\PinballArcade\PinballArcade", "SavePath", "Auto")
  75. pinballArcadeDat := CheckFile(paUserPath . "settings.dat")
  76.  
  77. ; Update fullscreen setting
  78. res := BinRead(pinballArcadeDat,pinballArcadeDatData,1,8) ; read current fullscreen setting
  79. Bin2Hex(hexData,pinballArcadeDatData,res)
  80. If (fullscreen = "true" && hexData != "02") {
  81. Hex2Bin(binData,"02")
  82. res := BinWrite(pinballArcadeDat,binData,1,8)
  83. } Else If (fullscreen != "true" && hexData != "00") {
  84. Hex2Bin(binData,"00")
  85. res := BinWrite(pinballArcadeDat,binData,1,8)
  86. }
  87.  
  88. ; Define Arrays for season folders
  89. season1Array := ["Attack From Mars","Big Shot","Black Hole","Black Knight","Bride of Pin-Bot","Cirqus Voltaire","Creature from the Black Lagoon","Elvira","Funhouse","Genie","Gorgar","Harley-Davidson","Medieval Madness","Monster Bash","No Good Gofers","Ripley's Believe It or Not","Scared Stiff","Star Trek","Taxi","Theatre of Magic","Twilight Zone"]
  90. ; season2Array := ["Cactus Canyon","Centaur","Central Park","Champion Pub","Class of 1812","Cue Ball Wizard","Dr. Dude","El Dorado - City of Gold","Firepower","Flight 2000","Goin' Nuts","Haunted House","Pin-Bot","Space Shuttle","Tee'd Off","Terminator 2","Victory","Whirlwind","White Water"]
  91. season2Array := [] ; leaving blank so Loops work
  92. season3Array := ["Fish Tales"]
  93.  
  94. ; Convert myTables into a real array
  95. myTablesArray := []
  96. Loop, Parse, myTables, |
  97. {
  98. myTablesArray[A_Index] := A_Loopfield
  99. ; msgbox % A_Loopfield
  100. If (romName = A_Loopfield) {
  101. thisTablePos := A_Index ; store the position (in the array) this table was found
  102. thisTableArray := "myTablesArray" ; save the array this table was found in
  103. lastTable := lastMyTable ; store the last table loaded for the same array as this table
  104. Log("Module - Found """ . romName . """ at position " . thisTablePos . " in MyTables")
  105. }
  106. }
  107.  
  108. ; If the current table was not found in My Tables, find its location in the Season folders
  109. If !thisTablePos {
  110. Log("Module - Did not find """ . romName . """ in MyTables. Searching for it in a Season folder")
  111. thisTableSeasonIndex :=
  112. Loop 3 {
  113. thisTableSeasonIndex := A_Index
  114. Loop % season%thisTableSeasonIndex%Array.MaxIndex() {
  115. If (romName = season%thisTableSeasonIndex%Array[A_Index]) {
  116. thisTablePos := A_Index ; store the position (in the array) this table was found
  117. thisTableArray := "season" . thisTableSeasonIndex . "Array" ; save the array this table was found in
  118. lastTable := lastSeason%thisTableSeasonIndex%Table ; store the last table loaded for the same array as this table
  119. Log("Module - Found """ . romName . """ at position " . thisTablePos . " in Season " . thisTableSeasonIndex)
  120. }
  121. }
  122. }
  123. }
  124.  
  125. ; Find the position of the last table used in the same array as this table
  126. lastTableSeasonIndex :=
  127. Loop % %thisTableArray%.MaxIndex() {
  128. If (lastTable = %thisTableArray%[A_Index]) {
  129. lastTablePos := A_Index ; store the position (in the array) the last table was found
  130. }
  131. }
  132. ; msgbox % "This table is """ . romName . """ found in array " . thisTableArray . " at position " . thisTablePos . "`nLast table is """ . lastTable . """ and in array " . thisTableArray . " at position " . lastTablePos
  133.  
  134. CheckFile(moduleExtensionsPath . "\BlockInput.exe")
  135.  
  136. If !thisTableArray
  137. ScriptError("This table """ . romName . """ was not found in any of the Season or My Tables folders. Please check its name that it matches what the module recognizes.")
  138. If !lastTablePos
  139. ScriptError("Unable to locate the last table """ . lastTable . """. The last table must be found otherwise the module does not know where it's starting position is. Please make sure your table names match what the module recognizes.",10)
  140. Log("Module - Table """ . romName . """ was found in array """ . thisTableArray . """ at position " . thisTablePos)
  141. Log("Module - Last Table of array """ . thisTableArray . """ left off at """ . lastTable . """ which was found at position " . lastTablePos)
  142.  
  143. ; Calculate the shortest distance to this table from the lastTable
  144. max := %thisTableArray%.MaxIndex()
  145. a := lastTablePos
  146. b := thisTablePos
  147. If (a > b) { ; 1 > 6
  148. moveDown := a - b ; 1 - 6 = -5
  149. moveUp := (max - a) + b ; 46 - 1 + 6 = 52
  150. } Else If (b > a) { ; 6 > 1
  151. moveDown := b - a ; 6 - 1 = 5
  152. moveUp := (max - b) + a ; 46 - 6 + 1 = 41
  153. } Else { ; a=b
  154. moveDown := 0
  155. moveUp := 0
  156. }
  157. moveDirection := If moveUp < moveDown ? "moveUp" : "moveDown"
  158. Log("Module - The array """ . thisTableArray . """ has " . max . " tables in it and shortest distance to this table is " . %moveDirection% . " in direction " . moveDirection)
  159.  
  160. ; msgbox max: %max%`na: %a%`nb: %b%`nmoveUp: %moveUp%`nmoveDown: %moveDown%`nmoveDirection: %moveDirection%
  161. ; msgbox % "Moving " . moveDirection . " for " . %moveDirection%
  162. ; exitapp
  163. If executable {
  164. Log("Module - Running Pinball Arcade as a stand alone game and not through Steam as an executable was defined.")
  165. Run(executable, emuPath)
  166. } Else {
  167. If !steamPath
  168. GetSteamPath()
  169. Log("Module - Running Pinball Arcade through Steam.")
  170. Steam(238260)
  171. }
  172.  
  173. WinWait(pinballTitleClass)
  174. WinWaitActive(pinballTitleClass)
  175.  
  176. BezelDraw()
  177. Run("BlockInput.exe 30", moduleExtensionsPath) ; start the tool that blocks all input so user cannot interrupt the launch process for 30 seconds
  178. If moduleDebugging = true
  179. Tooltip, waiting %sleepLogo% seconds for logo
  180. SetKeyDelay(80*sleepBaseTime)
  181. Sleep % sleepLogo ; sleep till Pinball FX2 logo appears
  182.  
  183. If moduleDebugging = true
  184. Tooltip, sending enter to get to the main menu
  185. Send, {Enter Down}{Enter Up}100{Enter Down}{Enter Up} ;100{Enter Down}{Enter Up} ; get to the Main menu
  186. ; If moduleDebugging = true
  187. ; Tooltip, waiting for main menu to show
  188. ; Sleep % 2000*sleepBaseTime
  189.  
  190.  
  191. If moduleDebugging = true
  192. Tooltip, entering MyTable folder
  193. ; SetKeyDelay(100*sleepBaseTime)
  194. ; If (thisTableArray = "lastSeason1Table") {
  195. ; If (initialSelection = "MyTables")
  196. ; Send, {Up Down}{Up Up}
  197. ; Else If (initialSelection = "Season3")
  198. ; Send, {Left Down}{Left Up}
  199. ; IniWrite, %romName%, %settingsFile%, Settings, Last_Season_1_Table ; Write the table loaded to the ini
  200. ; } Else If (thisTableArray = "lastSeason3Table") {
  201. ; If (initialSelection = "MyTables")
  202. ; Send, {Left Down}{Left Up}80{Down Down}{Down Up}
  203. ; Else If (initialSelection = "Season1")
  204. ; Send, {Right Down}{Right Up}
  205. ; IniWrite, %romName%, %settingsFile%, Settings, Last_Season_3_Table
  206. ; } Else If (thisTableArray = "myTablesArray") {
  207. ; If (initialSelection = "Season1")
  208. ; Send, {Up Down}{Up Up}
  209. ; Else If (initialSelection = "Season3")
  210. ; Send, {Up Down}{Up Up}80{Right Down}{Right Up}
  211. ; IniWrite, %romName%, %settingsFile%, Settings, Last_My_Table
  212. ; }
  213. ; Send, {Enter Down}{Enter Up} ; enter folder
  214. If moduleDebugging = true
  215. Tooltip, waiting for folder to load
  216. Sleep % 2000*sleepBaseTime ; wait for folder to load
  217.  
  218. If moduleDebugging = true
  219. Tooltip, navigating to %romName%
  220. SetKeyDelay(80*sleepBaseTime)
  221. If (moveDirection = "moveUp") {
  222. Loop % %moveDirection%
  223. { If moduleDebugging = true
  224. Tooltip % "Index: " . A_Index . " | Game: " . %thisTableArray%[A_Index]
  225. Send, {Up Down}{Up Up}
  226. Sleep % 100*sleepBaseTime
  227. }
  228. } Else { ; moveDown
  229. Loop % %moveDirection%
  230. { If moduleDebugging = true
  231. Tooltip % "Index: " . A_Index . " | Game: " . %thisTableArray%[A_Index]
  232. Send, {Down Down}{Down Up}
  233. Sleep % 100*sleepBaseTime
  234. }
  235. }
  236. Send, {Enter Down}{Enter Up} ; select game
  237. Sleep % 500*sleepBaseTime
  238.  
  239. If moduleDebugging = true
  240. Tooltip, waiting for game to load
  241. ; If (thisTableArray = "myTablesArray") { ; handle launch of games I own in My Tables folder
  242. Send, {Enter Down}{Enter Up}80{Enter Down}{Enter Up} ; select game
  243. Sleep % 4800*sleepBaseTime ; waiting for table to load
  244. Send, {Enter Down}{Enter Up}80{Enter Down}{Enter Up} ; start game
  245. ; } Else { ; handle launch of games I do not own in the season folders
  246. ; Send, {Down Down}{Down Up}{Down Down}{Down Up}{Enter Down}{Enter Up} ; select to play trial
  247. ; Sleep % 4800*sleepBaseTime ; waiting for table to load
  248. ; Send, {Enter Down}{Enter Up} ; start game
  249. ; }
  250. If moduleDebugging = true
  251. Tooltip, Finished
  252.  
  253. Process("Close", "BlockInput.exe") ; end script that blocks all input
  254.  
  255. FadeInExit()
  256. Process("WaitClose", "PinballArcade.exe")
  257. BezelExit()
  258. FadeOutExit()
  259.  
  260. If windowsRotate {
  261. Gui 1: Show
  262. If rotateMethod
  263. Rotate(rotateMethod, 0)
  264. Sleep % 200*sleepBaseTime
  265. Gui 1: Destroy
  266. }
  267.  
  268. ExitModule()
  269.  
  270.  
  271. HaltEmu:
  272. disableSuspendEmu := true
  273. Send, {ESC down}{ESC up}
  274. Return
  275. RestoreEmu:
  276. Send, {ESC down}{ESC up}
  277. Return
  278.  
  279. CloseProcess:
  280. FadeOutStart()
  281. WinClose(pinballTitleClass)
  282. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement