SHARE
TWEET

Pinball Arcade AHK module for version 1.50.6

a guest May 30th, 2016 859 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MEmu = Pinball Arcade
  2. MEmuV = v1.50.6
  3. MURL = http://www.pinballarcade.com/
  4. MAuthor = djvj,Metalzoic
  5. MVersion = 2.1.2
  6. MSystem = "Pinball Arcade","Pinball"
  7.  
  8. ;----------------------------------------------------------------------------
  9. ; Notes:
  10. ; Initial setup:
  11. ; Manually run Pinball Arcade.
  12. ; If you own all the tables and they can all be found in the My Tables section in-game, simply enter My Tables from the main Pinball Arcade menu, browse to the first table (alphabetically) and exit Pinball Arcade.
  13. ; The module comes default with all the available tables (as of 4/20/2016) alphabetically sorted in the module setting My_Tables.
  14. ; It will parse this setting and assume you own all the tables. If you do not own all the tables, recreate this setting in the RocketLauncherUI module settings with only the tables you do own, and separate each one with a |
  15. ; If you do not own all the tables you also need to change the All_Tables module setting in RocketLauncherUI to "false" for the module to navigate the menu properly.
  16. ; The My_Tables names must match the names from your database.
  17. ;
  18. ; If launching as a Steam game:
  19. ; When setting this up in RocketLauncherUI 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.
  20. ; Under the Pinball Arcade system settings in RocketLauncherUI set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  21. ; The executable must be named PinballArcade.exe to work properly. Rename it if it does not match that exactly.
  22. ;
  23. ; If not launching through Steam:
  24. ; 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 to be defined.
  25. ; Under the Pinball Arcade system settings in RocketLauncherUI set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  26. ; The executable must be named PinballArcade.exe to work properly. Rename it if it does not match that exactly.
  27. ;
  28. ; To use the DX11 version of Pinball Arcade you must select the DX11 option in the module settings.
  29. ; For the Steam version you must also rename the actual Steam DX11 exe file. Go to Programs (x86)/Steam/Steamapps/Common/PinballArcade and rename PinballArcade.exe to PinballArcadeDX9.exe (or whatever you want) to make a backup.
  30. ; Then rename PinballArcade11.exe to just PinballArcade.exe. Changing the name does not cause issues with updating, but you'll have to do this renaming step every time they update the game with a new version.
  31. ; If you are using a non-Steam version then you may or may not need to rename the exe and certain module setting may or may not work (such as no-nag), however your exe must be named PinballArcade.exe for it to work.
  32. ;
  33. ; 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.
  34. ; 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.
  35. ; However, this also means RocketLauncher needs to be set to run as admin as well, keep this in mind.
  36. ;
  37. ; If you want bezel support set to the game be played in windowed mode
  38. ;
  39. ; How to run vertical games on a standard monitor:
  40. ; 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.
  41. ;
  42. ; If the key sends are not working, make sure your RocketLauncher is set to run as administrator.
  43. ;
  44. ; Pinball Arcade stores some settings in your registry @ HKEY_CURRENT_USER\Software\PinballArcade\PinballArcade
  45. ;----------------------------------------------------------------------------
  46. StartModule()
  47.  
  48. settingsFile := modulePath . "\" . moduleName . ".ini"
  49. rotateMethod := IniReadCheck(settingsFile, "settings", "Rotate_Method", rotateMethod,,1) ; Shortcut, Display, iRotate
  50. rotateDisplay := IniReadCheck(settingsFile, "settings", "Rotate_Display", 0,,1) ; 0, 90, 180, 270
  51. moduleDebugging := IniReadCheck(settingsFile, "settings", "Module_Debugging", "false",,1)
  52. selectKey := IniReadCheck(settingsFile, "settings", "Select_Key", navSelectKey,,1)
  53.  
  54. If (RotateDisplay > 0) {
  55.     Res := (A_ScreenWidth>A_ScreenWidth) ? A_ScreenWidth : A_ScreenWidth
  56.     Gui 1: Color, 000000
  57.     Gui 1: -Caption +ToolWindow
  58.     Gui 1: Show, x0 y0 W%Res% H%Res%, BlackScreen   ; experimental to hide entire desktop and windows
  59.     Rotate(rotateMethod, rotateDisplay)
  60. }
  61.  
  62. BezelGUI()
  63. FadeInStart()
  64.  
  65. fullscreen := IniReadCheck(settingsFile, "settings", "Fullscreen", "true",,1) ; 0, Shortcut, Display, iRotate
  66. startGame := IniReadCheck(settingsFile, "settings", "Start_Game","true",,1)
  67. pinballVersion := IniReadCheck(settingsFile, "settings", "Pinball_Version", "DX11",,1)
  68. allTables := IniReadCheck(settingsFile, "settings", "All_Tables","true",,1)
  69. sleepLogo := IniReadCheck(settingsFile, "Settings", "Sleep_Until_Logo",7000,,1)
  70. sleepBaseTime := IniReadCheck(settingsFile, "Settings", "Sleep_Base_Time",1,,1)
  71. lastMyTable := "Addams Family, The (Bally)" ; Mytables always starts on The Addams Family
  72. myTables := IniReadCheck(settingsFile, "Settings", "My_Tables","Addams Family, The (Bally)|Attack from Mars (Bally)|Big Shot (Gottlieb)|Black Hole (Gottlieb)|Black Knight 2000 (Williams)|Black Knight (Williams)|Black Rose (Bally)|Bram Stoker's Dracula (Williams)|Bride of Pin-Bot (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)|Cyclone (Williams)|Diner (Williams)|Dr. Dude & His Excellent Ray (Bally)|Earthshaker (Williams)|El Dorado (Gottlieb)|El Dorado - City Of Gold (Gottlieb)|Elvira and the Party Monsters (Bally)|F-14 Tomcat (Williams)|Fireball (Bally)|Firepower (Williams)|Fish Tales (Williams)|Flight 2000 (Stern)|FunHouse (Williams)|Genie (Gottlieb)|Getaway, The - High Speed II (Williams)|Goin' Nuts (Gottlieb)|Gorgar (Williams)|Harley-Davidson, 3rd Edition (Stern)|Haunted House (Gottlieb)|High Roller Casino (Stern)|High Speed (Williams)|Hurricane (Williams)|Jack-Bot (Williams)|Judge Dredd (Bally)|Junk Yard (Williams)|Last Action Hero (Data East)|Lights... Camera... Action! (Gottlieb)|Mary Shelley's Frankenstein (Sega)|Medieval Madness (Williams)|Monster Bash (Williams)|No Fear - Dangerous Sports (Williams)|No Good Gofers (Williams)|Party Zone (Bally)|Phantom of the Opera, The (Data East)|Pin-Bot (Williams)|Red & Ted's Roadshow (Williams)|Rescue 911 (Gottlieb)|Ripley's Believe It or Not! (Stern)|Safe Cracker (Bally)|Scared Stiff (Bally)|Space Shuttle (Williams)|Star Trek - The Next Generation (Williams)|Starship Troopers (Sega)|Tales of the Arabian Nights (Williams)|Taxi (Williams)|Tee'd Off (Gottlieb)|Terminator 2 - Judgment Day (Williams)|Theatre of Magic (Bally)|Twilight Zone (Bally)|TX-Sector (Gottlieb)|Victory (Gottlieb)|Whirlwind (Williams)|White Water (Williams)|WHO Dunnit (Bally)|Xenon (Bally)",,1)   ; | v1.45.6 separated list of the tables user owns
  73.  
  74. pinballTitleClass := "Pinball Arcade ahk_class " . (If pinballVersion = "DX11" ? "GameWindowClass" : "Pinball Arcade")
  75.  
  76. BezelStart()
  77.  
  78. ; get user's save path
  79. paUserPath := RegRead("HKCU", "Software\PinballArcade\PinballArcade", "SavePath", "Auto")
  80. pinballArcadeDat := CheckFile(paUserPath . "settings.dat")
  81.  
  82. ; Update fullscreen setting
  83. res := BinRead(pinballArcadeDat,pinballArcadeDatData,1,8)   ; read current fullscreen setting
  84. Bin2Hex(hexData,pinballArcadeDatData,res)
  85. If (fullscreen = "true" && hexData != "02") {
  86.     Hex2Bin(binData,"02")
  87.     res := BinWrite(pinballArcadeDat,binData,1,8)
  88. } Else If (fullscreen != "true" && hexData != "00") {
  89.     Hex2Bin(binData,"00")
  90.     res := BinWrite(pinballArcadeDat,binData,1,8)
  91. }
  92.  
  93. ; Convert myTables into a real array
  94. myTablesArray := []
  95. Loop, Parse, myTables, |
  96. {
  97.     myTablesArray[A_Index] := A_Loopfield
  98.     If (romName = A_Loopfield) {
  99.         thisTablePos := A_Index ; store the position (in the array) this table was found
  100.         thisTableArray := "myTablesArray"       ; save the array this table was found in
  101.         lastTable := lastMyTable        ; store the last table loaded for the same array as this table
  102.         Log("Module -  Found """ . romName . """ at position " . thisTablePos . " in MyTables")
  103.     }
  104. }
  105.  
  106. CheckFile(moduleExtensionsPath . "\BlockInput.exe")
  107.  
  108. If !thisTableArray
  109.     ScriptError("This table """ . romName . """ was not found in My Tables folder. Please check its name that it matches what the module recognizes.")
  110. Log("Module - Table """ . romName . """ was found in array """ . thisTableArray . """ at position " . thisTablePos)
  111. Log("Module - Last Table of array """ . thisTableArray . """ left off at """ . lastTable . """ which was found at position " . lastTablePos)
  112.  
  113. ; Calculate the shortest distance to this table from the lastTable
  114. max := %thisTableArray%.MaxIndex()
  115. a := 1
  116. b := thisTablePos
  117. If (a > b) {
  118.     moveDown := a - b
  119.     moveUp := (max - a) + b
  120. } Else If (b > a) {
  121.     moveDown := b - a
  122.     moveUp := (max - b) + a
  123. } Else {    ; a=b
  124.     moveDown := 0
  125.     moveUp := 0
  126. }
  127. moveDirection := If moveUp < moveDown ? "moveUp" : "moveDown"
  128. Log("Module - The array """ . thisTableArray . """ has " . max . " tables in it and shortest distance to this table is " . %moveDirection% . " in direction " . moveDirection)
  129.  
  130. hideEmuObj := Object(pinballTitleClass,1)   ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  131. HideEmuStart()
  132.  
  133. If executable {
  134.     Log("Module - Running Pinball Arcade as a stand alone game and not through Steam as an executable was defined.")
  135.     Run(executable . " skipwhatsnew", emuPath)
  136. } Else {
  137.     If !steamPath
  138.         GetSteamPath()
  139.     Log("Module - Running Pinball Arcade through Steam.")
  140.     Steam(238260,,"skipwhatsnew")
  141. }
  142.  
  143. WinWait(pinballTitleClass)
  144. WinWaitActive(pinballTitleClass)
  145.  
  146. BezelDraw()
  147. Run("BlockInput.exe 30", moduleExtensionsPath)        ; start the tool that blocks all input so user cannot interrupt the launch process for 30 seconds
  148. If (moduleDebugging = "true")
  149.     Tooltip, waiting %sleepLogo% seconds for logo
  150. SetKeyDelay(80*sleepBaseTime)
  151. Sleep % sleepLogo      ; sleep till Pinball FX2 logo appears
  152.  
  153. If (moduleDebugging = "true")
  154.     Tooltip, sending %selectKey% to get to the main menu
  155. Send, {%selectKey% Down}{%selectKey% Up}        ; Presses select to enter Main Menu
  156. If (allTables = "false") {
  157.     Send, 300{Down Down}{Down Up}      ; Moves selection cursor down to My Tables if all tables aren't owned
  158. }
  159. Send, 300{%selectKey% Down}{%selectKey% Up}        ; Selects My Tables folder
  160.  
  161. If (moduleDebugging = "true")
  162.     Tooltip, entering MyTable folder
  163. Sleep % 2000*sleepBaseTime     ; wait for folder to load
  164.  
  165. If (moduleDebugging = "true")
  166.     Tooltip, navigating to %romName%
  167. SetKeyDelay(80*sleepBaseTime)
  168. If (moveDirection = "moveUp") {
  169.     Loop % %moveDirection%
  170.     {   If (moduleDebugging = "true")
  171.             Tooltip % "Index: " . A_Index . " | Game: " . %thisTableArray%[A_Index]
  172.         Send, {Up Down}{Up Up}
  173.         Sleep % 100*sleepBaseTime
  174.     }
  175. } Else {        ; moveDown
  176.     Loop % %moveDirection%
  177.     {   If (moduleDebugging = "true")
  178.             Tooltip % "Index: " . A_Index . " | Game: " . %thisTableArray%[A_Index]
  179.         Send, {Down Down}{Down Up}
  180.         Sleep % 100*sleepBaseTime
  181.     }
  182. }
  183. Send, {%selectKey% Down}{%selectKey% Up}    ; select game
  184. Sleep % 500*sleepBaseTime
  185.  
  186. If (moduleDebugging = "true")
  187.     Tooltip, waiting for game to load
  188. Send, {%selectKey% Down}{%selectKey% Up}80{%selectKey% Down}{%selectKey% Up}      ; select game
  189. If (startGame = "true") {
  190.     Sleep % 4800*sleepBaseTime     ; waiting for table to load
  191.     Send, {%selectKey% Down}{%selectKey% Up}80{%selectKey% Down}{%selectKey% Up}      ; start game
  192. }
  193. If (moduleDebugging = "true")
  194.     Tooltip, Finished
  195.  
  196. Process("Close", "BlockInput.exe")    ; end script that blocks all input
  197.  
  198. HideEmuEnd()
  199. FadeInExit()
  200. Process("WaitClose", "PinballArcade.exe")
  201. BezelExit()
  202. FadeOutExit()
  203.  
  204. If (RotateDisplay > 0) {
  205.     Gui 1: Show
  206.     Rotate(rotateMethod, 0)
  207.     Sleep % 200*sleepBaseTime
  208.     Gui 1: Destroy
  209. }
  210.  
  211. ExitModule()
  212.  
  213.  
  214. HaltEmu:
  215.     disableSuspendEmu := true
  216.     Send, {ESC down}{ESC up}
  217. Return
  218. RestoreEmu:
  219.     Send, {ESC down}{ESC up}
  220. Return
  221.  
  222. CloseProcess:
  223.     FadeOutStart()
  224.     WinClose(pinballTitleClass)
  225. Return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top