Advertisement
djvj

Untitled

Dec 24th, 2014
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MEmu = Pinball Arcade
  2. MEmuV = N/A
  3. MURL = http://www.pinballarcade.com/
  4. MAuthor = djvj
  5. MVersion = 2.0
  6. MCRC =
  7. iCRC =
  8. mId =
  9. MSystem = "Pinball Arcade","Pinball"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Initial setup:
  13. ; 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.
  14. ; 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.
  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. ; Order is critical that it matches what's in your My Tables folder.
  18. ;
  19. ; If launching as a Steam game:
  20. ; 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.
  21. ; Set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  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
  25. ; Set Skip Checks to "Rom and Emu" when using this module as roms do not exist.
  26. ;
  27. ;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.
  28. ;
  29. ; If you want bezel support set to the game be played in windowed mode
  30. ;
  31. ; How to run vertical games on a standard monitor:
  32. ; 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.
  33. ;
  34. ;If the key sends are not working, make sure your hyperlaunch is set to run as administrator.
  35. ;
  36. ; Pinball Arcade stores some settings in your registry @ HKEY_CURRENT_USER\Software\PinballArcade\PinballArcade
  37. ;----------------------------------------------------------------------------
  38. StartModule()
  39.  
  40. settingsFile := modulePath . "\" . moduleName . ".ini"
  41. rotateMethod := IniReadCheck(settingsFile, "settings", "Rotate_Method",,,1) ; Shortcut, Display, iRotate
  42. rotateDisplay := IniReadCheck(settingsFile, "settings", "Rotate_Display", 0,,1) ; 0, 90, 180, 270
  43.  
  44. If windowsRotate {
  45.     Res := (A_ScreenWidth>A_ScreenWidth) ? A_ScreenWidth : A_ScreenWidth
  46.     Gui 1: Color, 000000
  47.     Gui 1: -Caption +ToolWindow
  48.     Gui 1: Show, x0 y0 W%Res% H%Res%, BlackScreen   ; experimental to hide entire desktop and windows
  49.     If rotateMethod
  50.         Rotate(rotateMethod, rotateDisplay)
  51. }
  52.  
  53. BezelGUI()
  54. FadeInStart()
  55.  
  56. pinballTitleClass := "Pinball Arcade ahk_class Pinball Arcade"
  57. fullscreen := IniReadCheck(settingsFile, "settings", "Fullscreen", "true",,1) ; 0, Shortcut, Display, iRotate
  58. sleepLogo := IniReadCheck(settingsFile, "Settings", "Sleep_Until_Logo",7000,,1)
  59. initialSelection := IniReadCheck(settingsFile, "Settings", "Initial_Selection","MyTables",,1)
  60. lastSeason1Table := IniReadCheck(settingsFile, "Settings", "Last_Season_1_Table", "Attack From Mars",,1)
  61. lastSeason3Table := IniReadCheck(settingsFile, "Settings", "Last_Season_3_Table", "Fish Tales",,1)
  62. ;lastMyTable := IniReadCheck(settingsFile, "Settings", "Last_My_Table", "Tales of the Arabian Nights",,1)
  63. lastMyTable := "Attack from Mars (Bally)"
  64. ; 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
  65. myTables := IniReadCheck(settingsFile, "Settings", "My_Tables","Attack from Mars (Bally)|Big Shot (Bally)|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
  66. sleepBaseTime := IniReadCheck(settingsFile, "Settings", "Sleep_Base_Time",1,,1)
  67.  
  68. BezelStart()
  69.  
  70. ; get user's save path
  71. paUserPath := RegRead("HKCU", "Software\PinballArcade\PinballArcade", "SavePath", "Auto")
  72. pinballArcadeDat := CheckFile(paUserPath . "settings.dat")
  73.  
  74. ; Update fullscreen setting
  75. res := BinRead(pinballArcadeDat,pinballArcadeDatData,1,8)   ; read current fullscreen setting
  76. Bin2Hex(hexData,pinballArcadeDatData,res)
  77. If (fullscreen = "true" && hexData != "02") {
  78.     Hex2Bin(binData,"02")
  79.     res := BinWrite(pinballArcadeDat,binData,1,8)
  80. } Else If (fullscreen != "true" && hexData != "00") {
  81.     Hex2Bin(binData,"00")
  82.     res := BinWrite(pinballArcadeDat,binData,1,8)
  83. }
  84.  
  85. ; Define Arrays for season folders
  86. 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"]
  87. ; 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"]
  88. season2Array := []  ; leaving blank so Loops work
  89. season3Array := ["Fish Tales"]
  90.  
  91. ; Convert myTables into a real array
  92. myTablesArray := []
  93. Loop, Parse, myTables, |
  94. {
  95.     myTablesArray[A_Index] := A_Loopfield
  96.     ; msgbox % A_Loopfield
  97.     If (romName = A_Loopfield) {
  98.         thisTablePos := A_Index ; store the position (in the array) this table was found
  99.         thisTableArray := "myTablesArray"       ; save the array this table was found in
  100.         lastTable := lastMyTable        ; store the last table loaded for the same array as this table
  101.         Log("Module -  Found """ . romName . """ at position " . thisTablePos . " in MyTables")
  102.     }
  103. }
  104.  
  105. ; If the current table was not found in My Tables, find its location in the Season folders
  106. If !thisTablePos {
  107.     Log("Module -  Did not find """ . romName . """ in MyTables. Searching for it in a Season folder")
  108.     thisTableSeasonIndex :=
  109.     Loop 3 {
  110.         thisTableSeasonIndex := A_Index
  111.         Loop % season%thisTableSeasonIndex%Array.MaxIndex() {
  112.             If (romName = season%thisTableSeasonIndex%Array[A_Index]) {
  113.                 thisTablePos := A_Index ; store the position (in the array) this table was found
  114.                 thisTableArray := "season" . thisTableSeasonIndex . "Array"     ; save the array this table was found in
  115.                 lastTable := lastSeason%thisTableSeasonIndex%Table      ; store the last table loaded for the same array as this table
  116.                 Log("Module -  Found """ . romName . """ at position " . thisTablePos . " in Season " . thisTableSeasonIndex)
  117.             }
  118.         }
  119.     }
  120. }
  121.  
  122. ; Find the position of the last table used in the same array as this table
  123. lastTableSeasonIndex :=
  124. Loop % %thisTableArray%.MaxIndex() {
  125.     If (lastTable = %thisTableArray%[A_Index]) {
  126.         lastTablePos := A_Index ; store the position (in the array) the last table was found
  127.     }
  128. }
  129. ; msgbox % "This table is """ . romName . """ found in array " . thisTableArray . " at position " . thisTablePos . "`nLast table is """ . lastTable . """ and in array " . thisTableArray . " at position " . lastTablePos
  130.  
  131. CheckFile(moduleExtensionsPath . "\BlockInput.exe")
  132.  
  133. If !thisTableArray
  134.     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.")
  135. If !lastTablePos
  136.     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)
  137. Log("Module - Table """ . romName . """ was found in array """ . thisTableArray . """ at position " . thisTablePos)
  138. Log("Module - Last Table of array """ . thisTableArray . """ left off at """ . lastTable . """ which was found at position " . lastTablePos)
  139.  
  140. ; Calculate the shortest distance to this table from the lastTable
  141. max := %thisTableArray%.MaxIndex()
  142. a := lastTablePos
  143. b := thisTablePos
  144. If (a > b) {    ; 1 > 6
  145.     moveDown := a - b   ; 1 - 6 = -5
  146.     moveUp := (max - a) + b ; 46 - 1 + 6 = 52
  147. } Else If (b > a) { ; 6 > 1
  148.     moveDown := b - a   ; 6 - 1 = 5
  149.     moveUp := (max - b) + a ; 46 - 6 + 1 = 41
  150. } Else {        ; a=b
  151.     moveDown := 0
  152.     moveUp := 0
  153. }
  154. moveDirection := If moveUp < moveDown ? "moveUp" : "moveDown"
  155. Log("Module - The array """ . thisTableArray . """ has " . max . " tables in it and shortest distance to this table is " . %moveDirection% . " in direction " . moveDirection)
  156.  
  157. ; msgbox max: %max%`na: %a%`nb: %b%`nmoveUp: %moveUp%`nmoveDown: %moveDown%`nmoveDirection: %moveDirection%
  158. ; msgbox % "Moving " . moveDirection . " for " . %moveDirection%
  159. ; exitapp
  160. If executable {
  161.     Log("Module - Running Pinball Arcade as a stand alone game and not through Steam as an executable was defined.")
  162.     Run(executable, emuPath)
  163. } Else {
  164.     If !steamPath
  165.         GetSteamPath()
  166.     Log("Module - Running Pinball Arcade through Steam.")
  167.     Steam(238260)
  168. }
  169.  
  170. WinWait(pinballTitleClass)
  171. WinWaitActive(pinballTitleClass)
  172.  
  173. BezelDraw()
  174. Run("BlockInput.exe 30", moduleExtensionsPath)        ; start the tool that blocks all input so user cannot interrupt the launch process for 30 seconds
  175. Tooltip, waiting %sleepLogo% seconds for logo
  176. SetKeyDelay(80*sleepBaseTime)
  177. Sleep, %sleepLogo%      ; sleep till Pinball FX2 logo appears
  178.  
  179. Tooltip, sending enter x3 to get to the main menu
  180. Send, {Enter Down}{Enter Up}80{Enter Down}{Enter Up}80{Enter Down}{Enter Up}        ; get to the Main menu
  181. Tooltip, waiting for main menu to show
  182. Sleep, 2000*sleepBaseTime
  183.  
  184. Tooltip, entering MyTable or Season folder
  185. SetKeyDelay(100*sleepBaseTime)
  186. If (thisTableArray = "lastSeason1Table") {
  187.     If (initialSelection = "MyTables")
  188.         Send, {Up Down}{Up Up}
  189.     Else If (initialSelection = "Season3")
  190.         Send, {Left Down}{Left Up}
  191.     IniWrite, %romName%, %settingsFile%, Settings, Last_Season_1_Table      ; Write the table loaded to the ini
  192. } Else If (thisTableArray = "lastSeason3Table") {
  193.     If (initialSelection = "MyTables")
  194.         Send, {Left Down}{Left Up}80{Down Down}{Down Up}
  195.     Else If (initialSelection = "Season1")
  196.         Send, {Right Down}{Right Up}
  197.     IniWrite, %romName%, %settingsFile%, Settings, Last_Season_3_Table
  198. } Else If (thisTableArray = "myTablesArray") {
  199.     If (initialSelection = "Season1")
  200.         Send, {Up Down}{Up Up}
  201.     Else If (initialSelection = "Season3")
  202.         Send, {Up Down}{Up Up}80{Right Down}{Right Up}
  203.     IniWrite, %romName%, %settingsFile%, Settings, Last_My_Table
  204. }
  205. Send, {Enter Down}{Enter Up}    ; enter folder
  206. Tooltip, waiting for folder to load
  207. Sleep, 2000*sleepBaseTime     ; wait for folder to load
  208.  
  209. Tooltip, navigating to %romName%
  210. SetKeyDelay(80*sleepBaseTime)
  211. If (moveDirection = "moveUp") {
  212.     Loop % %moveDirection%
  213.     {   Send, {Up Down}{Up Up}
  214.         Sleep, % 100*sleepBaseTime
  215.     }
  216. } Else {        ; moveDown
  217.     Loop % %moveDirection%
  218.     {   Tooltip % A_Index
  219.         Send, {Down Down}{Down Up}
  220.         Sleep, % 100*sleepBaseTime
  221.     }
  222. }
  223. Send, {Enter Down}{Enter Up}    ; select game
  224. Sleep, 500*sleepBaseTime
  225.  
  226. Tooltip, waiting for game to load
  227. If (thisTableArray = "myTablesArray") { ; handle launch of games I own in My Tables folder
  228.     Send, {Enter Down}{Enter Up}{Enter Down}{Enter Up}      ; select game
  229.     Sleep, % 4800*sleepBaseTime     ; waiting for table to load
  230.     Send, {Enter Down}{Enter Up}{Enter Down}{Enter Up}      ; start game
  231. } Else {        ; handle launch of games I do not own in the season folders
  232.     Send, {Down Down}{Down Up}{Down Down}{Down Up}{Enter Down}{Enter Up}    ; select to play trial
  233.     Sleep, % 4800*sleepBaseTime     ; waiting for table to load
  234.     Send, {Enter Down}{Enter Up}    ; start game
  235. }
  236. Tooltip, Finished
  237.  
  238. Process("Close", "BlockInput.exe")    ; end script that blocks all input
  239.  
  240. FadeInExit()
  241. Process("WaitClose", "PinballArcade.exe")
  242. BezelExit()
  243. FadeOutExit()
  244.  
  245. If windowsRotate {
  246.     Gui 1: Show
  247.     If rotateMethod
  248.         Rotate(rotateMethod, 0)
  249.     Sleep, % 200*sleepBaseTime
  250.     Gui 1: Destroy
  251. }
  252.  
  253. ExitModule()
  254.  
  255.  
  256. HaltEmu:
  257.     disableSuspendEmu := true
  258.     Send, {ESC down}{ESC up}
  259. Return
  260. RestoreEmu:
  261.     Send, {ESC down}{ESC up}
  262. Return    
  263.    
  264. CloseProcess:
  265.     FadeOutStart()
  266.     WinClose(pinballTitleClass)
  267. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement