Advertisement
Dime333

Dolphin module

Aug 31st, 2020
5,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.98 KB | None | 0 0
  1. MEmu := "Dolphin"
  2. MEmuV := "v5.0"
  3. MURL := ["https://dolphin-emu.org/"]
  4. MAuthor := ["djvj","bleasby"]
  5. MVersion := "2.2.0"
  6. MCRC := "C7DEEF2C"
  7. iCRC := "9DF8C36F"
  8. MID := "635038268884477733"
  9. MSystem := ["Nintendo Gamecube","Nintendo Wii","Nintendo WiiWare"]
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Be sure you are running at least Dolphin v4.0 or greater.
  13. ; If you get an error that you are missing a vcomp100.dll, install Visual C++ 2010: http://www.microsoft.com/download/en/details.aspx?id=14632
  14. ; Also make sure you are running latest directx: http://www.microsoft.com/downloads/details.aspx?FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3
  15. ; Dolphin will sometimes crash when connnecting a Wiimote, then going back to the game. After all Wiimotes are connected that you want to use, it shouldn't have anymore issues.
  16. ; Convert all your games to ciso using Wii Backup Manager to save alot of space by stripping everything but the game partition. http://www.wiibackupmanager.tk/
  17. ; If you want to keep your Dolphin.ini in the emu folder, create a "portable.txt" file in MyDocuments\Dolphin Emulator\
  18. ;
  19. ; Bezels:
  20. ; If the game does not fit the window, you can try setting stretch to window manually in dolphin.
  21. ;
  22. ; Setting up custom Wiimote or GCPad profiles:
  23. ; First set UseCustomWiimoteProfiles or UseCustomGCpadProfiles to true in RocketLauncherUI for this module
  24. ; Launch Dolphin manually and goto Options->(Wiimote or Gamecube Pad) Settings and configure all your controls how you want your default setup to look like. This will be used for all games that you don't set a custom profile for. No need to save any profiles.
  25. ; All your controls are stored in WiimoteNew.ini or GCPadNew.ini and get copied to a _Default_(WiimoteNew or GCPadNew).ini on first launch. This ini contains all the controls for all 4 controllers.
  26. ; Do not confuse this with Dolphin's built-in profiles as those only contain info for only one controller. The (WiimoteNew or GCPadNew).ini and all the profiles RocketLauncher uses contain info for all controllers in one file.
  27. ; This new profile now called _Default_(WiimoteNew or GCPadNew).ini will be found in Dolphins settings folder: \Config\Profiles\(Wiimote or GCPad) (RL)\Default.ini
  28. ; For each game or custom control sets you want to use, edit the controls for all the controllers to work for that game and exit Dolphin. Now copy the (WiimoteNew or GCPadNew).ini to the "(Wiimote or GCPad) (RL)" folder and name it whatever you like.
  29. ; In RocketLauncherUI's module settings for Dolphin, Click the Rom Settings tab and add each game from your xml you want to use a this custom profile for.
  30. ; Now for all those games you added, make sure the Profile setting it set to the custom profile you want to load when that game is launched.
  31. ; Any game not added will use the "_Default_(WiimoteNew or GCPadNew).ini" profile RocketLauncher makes on first launch.
  32. ;
  33. ; To Pair a Wiimote:
  34. ; Highly suggest getting a Mayflash DolphinBar as it makes pairing and using wiimotes as easy as with a real Wii: http://www.amazon.com/TOTALCONSOLE-W010-Wireless-Sensor-DolphinBar/dp/B00HZWEB74
  35. ; If using the DolphinBar, just make sure Dolphin is set to continuously scan for wiimotes and set controls to use real wiimotes for as many wiimotes you have.
  36. ; You do not need to pair the wiimote with the PC first as you would with a standard blueooth and wiimote.
  37. ; DolphinBar should be on Mode 4. Wiimotes don't get paired until after Dolphin is running, not before!!
  38. ; After Dolphin is running, press 1+2 on each wiimote and after a few moments, the wiimote will pair and vibrate and one led will lock solid. Do this for each wiimote. That's it!
  39. ;
  40. ; If using a standard LED Bar:
  41. ; Make sure all your wiimotes have already been paired with your PC's bluetooth adapter
  42. ; All 4 leds on the wiimote should be flashing
  43. ; Press your Refresh key (set in RocketLauncherUI for this module) or enable continuous scanning in Dolphin
  44. ; Press 1 + 2 on the wiimote and one led should go solid designating the player number
  45. ;
  46. ; MultiGame:
  47. ; Currently unable to get disc swapping to work. See MultiGame section below for additional details.
  48. ;
  49. ; Netplay:
  50. ; If you're using a GameCube game with saves, synchronize your memory cards, Wii NAND needs to be synchronized, and some settings (such as CPU Clock Override) must be either synchronized or disabled.
  51. ; Because netplay may require different settings than you would normally use with local play, the module will look for any inis in your Dolphin user config folder ending with "_netplay" and use those configs instead of your normal ones.
  52. ; So for example, after you tweak all your dolphin settings for netplay, copy your dolphin.ini to dolphin_netplay.ini in the same folder.
  53. ; When the module launches and you choose multiplayer from RocketLauncher on screen menu, the module will backup dolphin.ini and copy dolphin_network.ini to dolphin.IniDelete
  54. ; On exit, the module will restore your backed up dolphin.ini and any other ini files in this folder (and all subfolders) that had the "_netplay" in the name.
  55. ; Guide on tweaking performance for netplay: https://dolphin-emu.org/docs/guides/netplay-guide/
  56. ; Another guide: https://docs.google.com/document/d/1CIkBAGcf_-kBUa4urn4KUj2U4UA6y_2a7stXJz85yiE/
  57. ;
  58. ; Linking a GameCube game with VBA-M
  59. ; Game tested: Legend of Zelda, The - Four Swords Adventures (USA)
  60. ; VBA-M emulator tested: visualboyadvance-m2.0.0Beta1
  61. ; dolphin emulator tested: dolphin-master-4.0-6725-x64
  62. ; On RocketLaunchUI, dolphin, GameCube Module settings set your VBA-M executable and VBA Bios file path on the VBALink tab.
  63. ; On RocketLaunchUI, dolphin, GameCube, Game name Module Settings enable VBA Link
  64. ; If your Game Boy Advanced Windows appear frozen after the RocketLauncher fade screen loads, increase the value of the VBADelay on GameCube, VBALink settings. Default value is 500 milliseconds.
  65. ; A game with one VBA window will use a two screens bezel file, Bezel [2S].png, the first screen for the GameCube game and the second one for the VBA screen. Two VBAs = Bezel [3S].png, again first screen for the GameCube game and second and third for the VBA screens, and so on.
  66. ;----------------------------------------------------------------------------
  67. StartModule()
  68. BezelGui()
  69. FadeInStart()
  70.  
  71. primaryExe := new Emulator(emuPath . "\" . executable) ; instantiate emulator executable object
  72.  
  73. Fullscreen := moduleIni.Read("Settings", "Fullscreen","true",,1)
  74. UseCustomWiimoteProfiles := moduleIni.Read("Settings", "UseCustomWiimoteProfiles","false",,1) ; set to true if you want to setup custom Wiimote profiles for games
  75. UseCustomGCPadProfiles := moduleIni.Read("Settings", "UseCustomGCPadProfiles","false",,1) ; set to true if you want to setup custom GCPad profiles for games
  76. HideMouse := moduleIni.Read("Settings", "HideMouse","true",,1) ; hides mouse cursor in the emu options
  77. RefreshKey := moduleIni.Read("Settings", "RefreshKey",,,1) ; hotkey to "Refresh" Wiimotes, delete the key to disable it
  78. Timeout := moduleIni.Read("Settings", "Timeout","5",,1) ; amount in seconds we should wait for the above hotkeys to timeout
  79. renderToMain := moduleIni.Read("Settings", "Render_To_Main","false",,1)
  80. enableNetworkPlay := moduleIni.Read("Network", "Enable_Network_Play","false",,1)
  81. controlTypePort1 := moduleIni.Read(romName . "|Controls", "Control_Type_Port_1",,,1)
  82. controlTypePort2 := moduleIni.Read(romName . "|Controls", "Control_Type_Port_2",,,1)
  83. controlTypePort3 := moduleIni.Read(romName . "|Controls", "Control_Type_Port_3",,,1)
  84. controlTypePort4 := moduleIni.Read(romName . "|Controls", "Control_Type_Port_4",,,1)
  85. enambleBTPassthrough := moduleIni.Read(romName . "|Controls", "Use_Bluetooth_Passthrough","true",,1)
  86.  
  87. ;options to Gamecube and VBA Link
  88. enableVBALink := moduleIni.Read(romName, "enableVBALink", "false",,1)
  89. VBAExePath := moduleIni.Read("VBA Link", "VBAExePath",,,1)
  90. VBABiosPath := moduleIni.Read("VBA Link", "VBABiosPath",,,1)
  91. VBADelay := moduleIni.Read("VBA Link", "VBADelay", 500,,1)
  92.  
  93. If (renderToMain = "true") {
  94. emuPrimaryWindow := new Window(new WindowTitle("Dolphin","Qt5150QWindowIcon")) ; instantiate primary emulator window object
  95. emuGameWindow := emuPrimaryWindow
  96. } Else {
  97. emuPrimaryWindow := new Window(new WindowTitle("Dolphin","Qt5150QWindowIcon")) ; instantiate primary emulator window object
  98. emuPrimaryWindow.ExcludeTitle := "FPS" ; when main window doesn't have the game, FPS will not be on the title bar
  99. emuGameWindow := new Window(new WindowTitle("FPS","Qt5150QWindowIcon"))
  100. }
  101. emuPrimaryWindow := new Window(new WindowTitle("Dolphin","Qt5150QWindowIcon")) ; instantiate primary emulator window object
  102. emuGameWindow := If renderToMain = "true" ? emuPrimaryWindow : new Window(new WindowTitle("FPS","Qt5150QWindowIcon")) ; Older dolphins used "FPS ahk_class wxWindowClassNR"
  103. emuScanningWindow := new Window(new WindowTitle("Scanning for ISOs","#32770"))
  104. emuNetPlaySetupWindow := new Window(new WindowTitle("Dolphin NetPlay Setup","Qt5150QWindowIcon"))
  105. emuNetPlayWindow := new Window(new WindowTitle("Dolphin NetPlay","Qt5150QWindowIcon"))
  106. emuWiimoteWindow := new Window(new WindowTitle("Dolphin Controller Configuration","#32770"))
  107. emuOpenROMWindow := new Window(new WindowTitle("Select","#32770"))
  108. emuErrorWindow1 := new Window(new WindowTitle("Warning","#32770"))
  109. emuErrorWindow2 := new Window(new WindowTitle("Error","#32770"))
  110. emuWiimoteWindow.CreateControl("OK")
  111.  
  112. ; Determine where Dolphin is storing its ini, this will act as the base folder for settings and profiles related to this emu
  113. dolphinININewPath := new File(A_MyDocuments . "\Dolphin Emulator\Config\Dolphin.ini") ; location of Dolphin.ini for v4.0+
  114. dolphinINIOldPath := new File(emuPath . "\User\Config\Dolphin.ini") ; location of Dolphin.ini prior to v4.0
  115. portableTxtFile := new File(emuPath . "\portable.txt")
  116. If (!portableTxtFile.Exist() && dolphinININewPath.Exist())
  117. { dolphinBasePath := A_MyDocuments . "\Dolphin Emulator"
  118. RLLog.Info("Module - Dolphin's base settings folder is not portable and found in: " . dolphinBasePath)
  119. } Else If (portableTxtFile.Exist() || dolphinINIOldPath.Exist())
  120. { dolphinBasePath := emuPath . "\User"
  121. RLLog.Info("Module - Dolphin's base settings folder is portable and found in: " . dolphinBasePath)
  122. } Else
  123. ScriptError("Could not find your Dolphin.ini in either of these folders. Please run Dolphin manually first to create it.`n" . dolphinINIOldPath.FileFullPath . "`n" . dolphinININewPath.FileFullPath)
  124. dolphinINI := new IniFile(dolphinBasePath . "\Config\Dolphin.ini")
  125.  
  126. If (enableVBALink = "true"){
  127. VBAExePath := AbsoluteFromRelative(EmuPath, VBAExePath)
  128. VBABiosPath := AbsoluteFromRelative(EmuPath, VBABiosPath)
  129. StringUtils.SplitPath(VBAExePath, VBAFile, VBAPath)
  130. SelectedNumberofPlayers := NumberOfPlayersSelectionMenu(4)
  131. If (SelectedNumberofPlayers = 1) {
  132. enableVBALink := "false"
  133. } Else {
  134. ; backup original ini
  135. dolphinINIBackup := new File(dolphinBasePath . "\Config\Dolphin_Backup.ini")
  136. dolphinINI.Copy(dolphinINIBackup.FileFullPath)
  137. Loop, % SelectedNumberofPlayers
  138. { tempCount := A_Index-1
  139. dolphinINI.Write(5, "Controls", PadType%tempCount%)
  140. }
  141. }
  142. }
  143.  
  144. If (enableVBALink = "true")
  145. BezelStart(SelectedNumberofPlayers+1)
  146. Else
  147. BezelStart()
  148.  
  149. If (enableVBALink = "true" and !bezelPath) ; disabling fullscreen if VBA Link mode
  150. Fullscreen := "false"
  151.  
  152. If (renderToMain = "true" && (enableVBALink = "true" || bezelEnabled = "true")) { ; disabling toolbar and statusbar if bezels or vba link is used as it will show when rendering to the main window
  153. dolphinINI.Write("False", "Interface", "ShowToolbar")
  154. dolphinINI.Write("False", "Interface", "ShowStatusbar")
  155. }
  156.  
  157. If (renderToMain = "true")
  158. hideEmuObj := Object(emuScanningWindow,0,emuNetPlayWindow,0,emuNetPlaySetupWindow,0,emuErrorWindow1,0,emuErrorWindow2,0,emuGameWindow,1)
  159. Else
  160. hideEmuObj := Object(emuScanningWindow,0,emuNetPlayWindow,0,emuNetPlaySetupWindow,0,emuErrorWindow1,0,emuErrorWindow2,0,emuPrimaryWindow,0,emuGameWindow,1)
  161.  
  162. ; Set control types in each port
  163. dolphinDevice := 0
  164. Loop 4 {
  165. If controlTypePort%A_Index%
  166. dolphinINI.Write(controlTypePort%A_Index%, "Core", "SIDevice" . dolphinDevice)
  167. dolphinDevice++
  168. }
  169.  
  170. If (enambleBTPassthrough = "false") {
  171. dolphinINI.Write("False", "BluetoothPassthrough", "Enabled")
  172. } Else {
  173. dolphinINI.Write("true", "BluetoothPassthrough", "Enabled")
  174. }
  175. 7z(romPath, romName, romExtension, sevenZExtractPath)
  176.  
  177. If StringUtils.Contains(romExtension,"\.zip|\.7z|\.rar")
  178. ScriptError(MEmu . " does not support compressed roms. Please enable 7z support in RocketLauncherUI to use this module/emu.")
  179.  
  180. If RefreshKey {
  181. RefreshKey := xHotKeyVarEdit(RefreshKey,"RefreshKey","~","Add")
  182. xHotKeywrapper(RefreshKey,"RefreshWiimote")
  183. }
  184.  
  185. Fullscreen := If Fullscreen = "true" ? "True" : "False"
  186. HideMouse := If HideMouse = "true" ? "True" : "False"
  187.  
  188. networkSession := ""
  189. If (enableNetworkPlay = "true") {
  190. RLLog.Info("Module - Network Multi-Player is an available option for " . dbName)
  191. dolphinNickname := dolphinINI.Read("NetPlay", "Nickname")
  192. dolphinAddress := dolphinINI.Read("NetPlay", "Address")
  193. dolphinCPort := dolphinINI.Read("NetPlay", "ConnectPort")
  194. dolphinHPort := dolphinINI.Read("NetPlay", "HostPort")
  195. netplayNickname := moduleIni.Read("Network", "NetPlay_Nickname","Player",,1)
  196. getWANIP := moduleIni.Read("Network", "Get_WAN_IP","false",,1)
  197. networkPlayers := 4 ; Max amount of networkable players
  198.  
  199. If (getWANIP = "true")
  200. myPublicIP := GetPublicIP()
  201.  
  202. defaultServerIP := moduleIni.Read("Network", "Default_Server_IP", myPublicIP,,1)
  203. defaultServerPort := moduleIni.Read("Network", "Default_Server_Port",,,1)
  204. lastIP := moduleIni.Read("Network", "Last_IP", defaultServerIP,,1) ; does not need to be on the ISD
  205. lastPort := moduleIni.Read("Network", "Last_Port", defaultServerPort,,1) ; does not need to be on the ISD
  206.  
  207. If (netplayNickname != dolphinNickname)
  208. dolphinINI.Write(netplayNickname, "NetPlay", "Nickname")
  209.  
  210. MultiplayerMenu(lastIP,lastPort,networkType,networkPlayers,0)
  211. If networkSession {
  212. RLLog.Info("Module - Using a Network for " . dbName)
  213.  
  214. restoreIniObject := Object() ; initialize object
  215. currentObj := ""
  216. dolphinConfigPath := dolphinBasePath . "\Config"
  217. Loop, % dolphinConfigPath . "\*.ini"
  218. {
  219. If StringUtils.InStr(A_LoopFileName, "_netplay.ini",,,,0) {
  220. RLLog.Info("Module - Found a network specific ini: " . A_LoopFileFullPath)
  221. networkIni%A_Index%File := new File(A_LoopFileFullPath)
  222. originalIni%A_Index%File := new File(StringUtils.RegExReplace(A_LoopFileFullPath, "_netplay",,,-1,15))
  223. backupIni%A_Index%File := new File(originalIni%A_Index%File.FileFullPath . ".backup")
  224. originalIni%A_Index%File.Move(backupIni%A_Index%File,1) ; backup original ini
  225. networkIni%A_Index%File.Copy(originalIni%A_Index%File) ; copy network ini to original name
  226. }
  227. }
  228.  
  229. moduleIni.Write(lastPort, "GlobalModuleIni", "Network", "Last_Port")
  230.  
  231. If (networkType = "client") {
  232. moduleIni.Write(lastIP, "GlobalModuleIni", "Network", "Last_IP") ; Save last used IP and Port for quicker launching next time
  233. dolphinINI.Write(lastIP, "Network", "Address")
  234. dolphinINI.Write(lastPort, "Network", "ConnectPort")
  235. } Else ; server
  236. dolphinINI.Write(lastPort, "Network", "HostPort")
  237.  
  238. dolphinINI.Write(romPath, "Network", "ISOPath0") ; makes browser only show the one game we want to play
  239. dolphinINI.Write(1, "General", "ISOPaths") ; makes browser only show the first path set
  240. dolphinINI.Write(romPath . "\" . romName . romExtension, "General", "LastFilename")
  241. RLLog.Info("Module - Starting a network session using the IP """ . networkIP . """ and PORT """ . networkPort . """")
  242. } Else
  243. RLLog.Info("Module - User chose Single Player mode for this session")
  244. }
  245.  
  246. gcSerialPort := 5 ; this puts the BBA network adapter into the serial port. If previous launch was Triforce, AM-Baseboard would be set here and would result in Unknown DVD command errors
  247.  
  248. ; Compare existing settings and if different than desired, write them to the emulator's ini
  249. dolphinINI.Write(Fullscreen, "Display", "Fullscreen", 1)
  250. dolphinINI.Write(renderToMain, "Display", "RenderToMain", 1)
  251. dolphinINI.Write(HideMouse, "Interface", "HideCursor", 1)
  252. dolphinINI.Write("False", "Interface", "ConfirmStop", 1)
  253. dolphinINI.Write("False", "Interface", "UsePanicHandlers", 1)
  254. dolphinINI.Write(gcSerialPort, "Core", "SerialPort1", 1)
  255.  
  256. ; Load default or user specified Wiimote or GCPad profiles for launching
  257. If (StringUtils.InStr(systemName, "wii") && UseCustomWiimoteProfiles = "true")
  258. ChangeDolphinProfile("Wiimote")
  259. If (UseCustomGCPadProfiles = "true")
  260. ChangeDolphinProfile("GCPad")
  261.  
  262. HideAppStart(hideEmuObj,hideEmu)
  263.  
  264. If networkSession
  265. primaryExe.Run() ; must be launched w/o -b for browser list to work
  266. Else
  267. primaryExe.Run(" -b -e """ . romPath . "\" . romName . romExtension . """") ; /b = batch (exit dolphin with emu), /e = load file
  268.  
  269. emuGameWindow.Wait()
  270. emuGameWindow.Get("ID")
  271. emuGameWindow.WaitActive()
  272.  
  273. If networkSession {
  274. RLLog.Info("Module - Opening NetPlay window")
  275.  
  276. ; Get the 6-letter ID of the game
  277. If (romExtension = ".wbfs")
  278. gameID := RLObject.readFileData(romPath . "\" . romName . romExtension,512,6,"UTF8")
  279. Else If (romExtension = ".iso")
  280. gameID := RLObject.readFileData(romPath . "\" . romName . romExtension,0,6,"UTF8")
  281. Else If (romExtension = ".ciso")
  282. gameID := RLObject.readFileData(romPath . "\" . romName . romExtension,32768,6,"UTF8")
  283.  
  284. ; Must wait for Dolphin to finish scanning isos before netplay window can be opened so the game list is populated. Opening too early and the game list will be blank or partially filled.
  285. If emuScanningWindow.Exist()
  286. emuScanningWindow.WaitClose(60) ; wait 60 seconds max. hopefully doesn't take longer than that to scan your isos...
  287. Else {
  288. errlvl := emuScanningWindow.Wait(5) ; wait 5 seconds max to appear
  289. If errlvl
  290. RLLog.Info("Module - Timed out waiting for ""Scanning for ISOs"" window to appear. It may have finished before it could be detected, moving on.")
  291. Else
  292. RLLog.Info("Module - ""Scanning for ISOs"" window found.")
  293. }
  294. emuPrimaryWindow.MenuSelectItem("Tools", "Start NetPlay")
  295. matchMode := A_TitleMatchMode ; store for restoration later
  296. MiscUtils.SetTitleMatchMode(3) ; changes match mode so title must match exactly
  297. emuNetPlaySetupWindow.Wait()
  298. emuNetPlaySetupWindow.WaitActive()
  299. emuNetPlayWindow.ExcludeTitle := emuNetPlaySetupWindow.WinTitle.GetWIndowTitle() ; set emuNetPlayWindow exclude title for the below command
  300. If (networkType = "client") {
  301. RLLog.Info("Module - Clicking Connect button")
  302.  
  303. emuNetPlaySetupWindow.CreateControl("Button1") ; instantiate new control for button1
  304. emuErrorWindow1.CreateControl("Button1")
  305. emuErrorWindow2.CreateControl("Button1")
  306.  
  307. While !breakLoops {
  308. emuNetPlaySetupWindow.GetControl("button1").Click() ; click connect button
  309. RLLog.Info("Module - Waiting for Host to start game")
  310. errlvl := emuNetPlayWindow.Wait(2) ; waits 2 seconds
  311. If errlvl { ; 1 if timed out, now check for any error windows and close them
  312. Loop, 2 ; loop through both error windows
  313. If emuErrorWindow%A_Index%.Exist() ; error windows that can appear when host is not running yet
  314. emuErrorWindow%A_Index%.GetControl("button1").Click() ; click ok to clear the error
  315. RLLog.Info("Module - Host not running yet, trying again")
  316. Continue
  317. } Else { ; window exists
  318. RLLog.Info("Module - Connected to host, waiting for host to start game")
  319. Break
  320. }
  321. }
  322. } Else { ; server
  323. emuNetPlayWindow.CreateControl("ListBox1") ; create a control called ListBox1
  324. emuNetPlayWindow.CreateControl("Button8") ; create a control called Button8 (the Host's Start button)
  325. emuNetPlaySetupWindow.CreateControl("ListBox1") ; create a control called ListBox1
  326. emuNetPlaySetupWindow.CreateControl("Button3") ; create a control called Button3 (the Host button)
  327. emuNetPlaySetupWindow.GetControl("ListBox1").Get("List") ; Get the text from the ListBox
  328. loopList := emuNetPlaySetupWindow.GetControl("ListBox1").List ; can't use this object directly on the Parse Loop below
  329. Loop, Parse, loopList, `n
  330. {
  331. If StringUtils.InStr(A_Loopfield, gameID,,,,0) {
  332. idLocation := A_Index ; record the location in the ListBox of our game
  333. RLLog.Info("Module - Game list shows """ . A_LoopField . """ as item " . A_Index) ; logging each items in ListBox
  334. }
  335. }
  336. If !idLocation { ; game was not found in list
  337. ScriptError("Could not find your """ . romName . """ in the game selection window for netplay. Possibly the gameID could not be found in your game. Please check your the RocketLauncher log and report this error.",,,,,1)
  338. Gosub, CloseProcess
  339. FadeInExit()
  340. Goto, CloseDolphin
  341. }
  342. emuNetPlaySetupWindow.GetControl("ListBox1").Control("Choose",idLocation) ; selects our game in the ListBox
  343. RLLog.Info("Module - Clicking Host button")
  344. emuNetPlaySetupWindow.GetControl("Button3").Click() ; click host button
  345. emuNetPlayWindow.Wait() ; this window should now appear when hosted correctly
  346. RLLog.Info("Module - Waiting for " . networkPlayers . " players until the game is started")
  347. While !breakLoops {
  348. emuNetPlayWindow.GetControl("ListBox1").Get("List") ; Get the text from the ListBox
  349. If StringUtils.InStr(emuNetPlayWindow.GetControl("ListBox1").List,"[" . networkPlayers . "]",,,,0) {
  350. RLLog.Info("Module - All players have joined, starting game")
  351. Break
  352. }
  353. TimerUtils.Sleep(100,0)
  354. }
  355. emuNetPlayWindow.GetControl("Button8").Click() ; click Start button
  356. }
  357. MiscUtils.SetTitleMatchMode(matchMode) ; restore old match mode
  358. }
  359.  
  360.  
  361. If (enableVBALink = "true") {
  362. vbaINI := new IniFile(VBAPath . "\vbam.ini")
  363. vbaINI.CheckFile()
  364. vbaINIBackup := new File(VBAPath . "\vbam_Backup.ini")
  365. vbaINI.Copy(vbaINIBackup.FileFullPath)
  366. ;removing fullscreen from VBA-M
  367. vbaINI.Write(0, "preferences", "fullScreen")
  368. ;setting other VBA-M ini options
  369. VBABiosPathDoubleSlash := StringUtils.Replace(VBABiosPath,"\","\\","all")
  370. vbaINI.Write(0, "preferences", "pauseWhenInactive")
  371. vbaINI.Write(VBABiosPathDoubleSlash, "GBA", "BiosFile")
  372. vbaINI.Write(1, "GBA", "LinkAuto")
  373. vbaINI.Write("127.0.0.1", "GBA", "LinkHost")
  374. vbaINI.Write(3, "GBA", "LinkType")
  375. vbaINI.Write(SelectedNumberofPlayers, "preferences", "LinkNumPlayers")
  376. vbaINI.Write(1, "preferences", "useBiosGBA")
  377. vbaINI.Write(1, "Display", "Stretch")
  378. vbaINI.Write(1, "Display", "Scale")
  379.  
  380. ;running VBA-M
  381. Loop % SelectedNumberofPlayers {
  382. currentScreen := A_Index + 1
  383. VBA%currentScreen%Exe := new Process(VBAExePath) ; instantiate a new process for each instance of VBA we need to run
  384. VBA%currentScreen%Exe.Run(" """ . VBABiosPath . """")
  385. ; msgbox % "PID: " . VBA%A_Index%Exe.PID . "`nVBABiosPath: " . VBABiosPath
  386. VBA%currentScreen%Window := new Window(new WindowTitle(,,,,VBA%currentScreen%Exe.PID))
  387. VBA%currentScreen%Window.Wait()
  388. TimerUtils.Sleep(VBADelay,0)
  389. bezelBottomOffsetScreen%currentScreen% := 24 ; to hide emu bottom bar
  390. }
  391. ;waiting for VBA-M windows bios loading
  392. timeout := A_TickCount
  393. VBAGBABiosWindow := new Window(new WindowTitle("gba_bios - VisualBoyAdvance-M"))
  394. Loop {
  395. VBAGBABiosWindow.Get("List") ; Get a list of all vba-m hwnd IDs
  396. If (VBAGBABiosWindow.List[0] = SelectedNumberofPlayers){
  397. Loop % VBAGBABiosWindow.List[0] { ; loop through each vba-m window
  398. currentScreen := A_Index + 1
  399. Screen%currentScreen%ID := VBAGBABiosWindow.List[A_Index] ; record each vba-m window's hwnd ID
  400. }
  401. RLLog.Info("Module - gba_bios Loaded")
  402. Break
  403. }
  404. If (timeout < A_TickCount - 10000) {
  405. RLLog.Warning("Module - Timed out waiting gba_bios to load")
  406. Break
  407. }
  408. TimerUtils.Sleep(100,0)
  409. }
  410. ;Resizing Windows to fill screen if no bezel file is found
  411. If !(bezelPath) {
  412. Loop % (SelectedNumberofPlayers + 1) {
  413. If (A_Index = 1) { ; the main Dolphin window
  414. X1 := 0
  415. Y1 := 0
  416. W1 := A_ScreenWidth//2
  417. H1 := A_ScreenHeight
  418. emuGameWindow.WinTitle.PID := "" ; remove PID from object's WinTitle so only the window hwnd ID is acted upon
  419. emuGameWindow.RemoveBorder()
  420. emuGameWindow.RemoveTitlebar()
  421. emuGameWindow.ToggleMenu()
  422. emuGameWindow.Move(X1,Y1,W1,H1)
  423. } Else { ; the vba-m windows
  424. X%A_Index% := A_ScreenWidth//2
  425. Y%A_Index% := (A_Index-2)*(A_ScreenHeight//SelectedNumberofPlayers)
  426. W%A_Index% := A_ScreenWidth//2
  427. H%A_Index% := (A_ScreenHeight//SelectedNumberofPlayers)+bezelBottomOffsetScreen%A_Index%
  428. VBA%A_Index%Window.WinTitle.ID := Screen%A_Index%ID ; set ID of window into object
  429. VBA%A_Index%Window.WinTitle.PID := "" ; remove PID from object's WinTitle so only the window hwnd ID is acted upon
  430. VBA%A_Index%Window.RemoveBorder()
  431. VBA%A_Index%Window.RemoveTitlebar()
  432. VBA%A_Index%Window.ToggleMenu()
  433. VBA%A_Index%Window.Move(X%A_Index%,Y%A_Index%,W%A_Index%,H%A_Index%)
  434. }
  435. }
  436. TimerUtils.Sleep(50)
  437. Loop % SelectedNumberofPlayers {
  438. currentScreen := A_Index + 1
  439. VBA%currentScreen%Window.Activate() ; put focus on all the VBA windows
  440. }
  441. VBA1Window.Activate() ; put focus on the first VBA window
  442. }
  443. }
  444.  
  445. BezelDraw()
  446.  
  447. emuGameWindow.Activate()
  448.  
  449. HideAppEnd(hideEmuObj,hideEmu)
  450. FadeInExit()
  451. primaryExe.Process("WaitClose")
  452.  
  453. CloseDolphin:
  454. If networkSession {
  455. Loop {
  456. If !IsObject(backupIni%A_Index%File)
  457. Break
  458. RLLog.Info("Module - Restoring the original ini: " . backupIni%A_Index%File.FileFullPath . " to " . originalIni%A_Index%File.FileFullPath)
  459. backupIni%A_Index%File.Move(originalIni%A_Index%File.FileFullPath,1) ; restore all backed up inis
  460. }
  461. }
  462.  
  463. 7zCleanUp()
  464. BezelExit()
  465. FadeOutExit()
  466. ExitModule()
  467.  
  468.  
  469. ChangeDolphinProfile(profileType) {
  470. Global settingsFile,romName,dolphinBasePath,RLLog,moduleIni
  471. profile := moduleIni.Read(romName, "profile", "Default",,1)
  472. RLProfilePath := new Folder(dolphinBasePath . "\Config\Profiles\" . profileType . " (RL)")
  473. currentProfileFile := new File(dolphinBasePath . "\Config\" . profileType . "New.ini")
  474. defaultProfileFile := new File(RLProfilePath.FilePath . "\_Default_" . profileType . "New.ini")
  475. customProfileFile := new File(RLProfilePath.FilePath . "\" . profile . ".ini")
  476. If !currentProfileFile.Exist() {
  477. RLLog.Warning("Module - You have custom " . profileType . " profiles enabled, but could not locate " . currentProfileFile.FileFullPath . ". This file stores all your current controls in Dolphin. Please setup your controls in Dolphin first.")
  478. Return
  479. }
  480. If !defaultProfileFile.Exist() {
  481. RLLog.Warning("Module - Creating initial Default " . profileType . " profile by copying " . profileType . ".ini to " . defaultProfileFile.FileFullPath)
  482. RLProfilePath.CreateDir()
  483. currentProfileFile.Copy(defaultProfileFile.FileFullPath) ; create the initial default profile on first launch
  484. }
  485. If (profile != "Default" && !customProfileFile.Exist())
  486. RLLog.Warning("Module - " . romName . " is set to load a custom " . profileType . " profile`, but it could not be found: " . customProfileFile.FileFullPath)
  487. currentProfileFile.Read() ; read current profile into memory
  488. customProfileFile.Read() ; read custom profile into memory
  489. If (currentProfileFile.Text != customProfileFile.Text) { ; if both profiles do not match exactly
  490. RLLog.Info("Module - Current " . profileType . " profile does not match the one this game should use.")
  491. If (profile != "Default") { ; if user set to use a custom profile
  492. RLLog.Info("Module - Copying this defined " . profileType . " profile to replace the current one: " . customProfileFile.FileFullPath)
  493. customProfileFile.Copy(currentProfileFile.FileFullPath,1)
  494. } Else { ; load default profile
  495. RLLog.Info("Module - Copying the default " . profileType . " profile to replace the current one: " . defaultProfileFile.FileFullPath)
  496. defaultProfileFile.Copy(currentProfileFile.FileFullPath,1)
  497. }
  498. } Else
  499. RLLog.Info("Module - Current " . profileType . " profile is already the correct one for this game, not touching it.")
  500. }
  501.  
  502. ConnectWiimote(key) {
  503. Global Timeout,emuPrimaryWindow,emuGameWindow,emuWiimoteWindow
  504. If !emuWiimoteWindow.Exist()
  505. {
  506. MiscUtils.DetectHiddenWindows("OFF") ; this needs to be off otherwise WinMenuSelectItem doesn't work for some odd reason
  507. emuPrimaryWindow.Activate()
  508. emuPrimaryWindow.MenuSelectItem("Options","Controller Settings")
  509. emuWiimoteWindow.Wait()
  510. emuWiimoteWindow.WaitActive()
  511. }
  512. ;emuWiimoteWindow.Activate() ; test if window needs to be active
  513. If !emuWiimoteWindow.GetControl(key)
  514. emuWiimoteWindow.CreateControl(key)
  515. emuWiimoteWindow.GetControl(key).Click()
  516. emuWiimoteWindow.GetControl("OK").Click()
  517. emuGameWindow.Activate()
  518. }
  519.  
  520. PairWiimote:
  521. ConnectWiimote("Pair Up")
  522. Return
  523.  
  524. RefreshWiimote:
  525. ConnectWiimote("Refresh")
  526. Return
  527.  
  528. HaltEmu:
  529. If RefreshKey
  530. XHotKeywrapper(RefreshKey,"RefreshWiimote","OFF")
  531. Return
  532.  
  533. MultiGame:
  534. ; MultiGame doesn't work with Dolphin currently because Dolphin hides itself from Winspector Spy and cannot send any commands to the emulator through scripts.
  535. If (fullscreen = "True")
  536. { KeyUtils.SetKeyDelay(50)
  537. KeyUtils.Send("{Alt Down}{Enter Down}{Enter Up}{Alt Up}") ; go windowed to get the menubar
  538. }
  539. If bezelEnabled
  540. emuGameWindow.ToggleMenu() ; put the menubar back
  541. ; emuPrimaryWindow.MenuSelectItem("File","Change Disc...")
  542. emuPrimaryWindow.MessageUtils.PostMessage("0x111", "00288") ; Change Disc
  543. OpenROM(emuOpenROMWindow.WinTitle.GetWindowTitle(), selectedRom)
  544. emuPrimaryWindow.WaitActive()
  545. If bezelEnabled
  546. emuGameWindow.ToggleMenu() ; remove the menubar again
  547. If (fullscreen = "True")
  548. KeyUtils.Send("{Alt Down}{Enter Down}{Enter Up}{Alt Up}") ; restore fullscreen
  549. Return
  550.  
  551. RestoreEmu:
  552. If RefreshKey
  553. XHotKeywrapper(RefreshKey,"RefreshWiimote","ON")
  554. Return
  555.  
  556. CloseProcess:
  557. breakLoops := 1
  558. FadeOutStart()
  559. If (enableVBALink = "true") {
  560. Loop % SelectedNumberofPlayers
  561. { currentScreen := A_Index + 1
  562. ;VBA%currentScreen%Window.Activate()
  563. VBA%currentScreen%Window.Close()
  564. TimerUtils.Sleep(100,0)
  565. }
  566. dolphinINIBackup.Move(dolphinINI.FileFullPath)
  567. vbaINIBackup.Move(vbaINI,1)
  568. }
  569. If networkSession {
  570. If emuNetPlaySetupWindow.Exist()
  571. emuNetPlaySetupWindow.Close()
  572. If emuNetPlayWindow.Exist()
  573. emuNetPlayWindow.Close()
  574. If !emuGameWindow.Exist() ; if game never launched, close the main emu window
  575. emuPrimaryWindow.Close()
  576. }
  577. If emuGameWindow.Exist()
  578. emuGameWindow.Close() ; this needs to close the window the game is running in otherwise dolphin crashes on exit
  579. Return
  580.  
  581. ; Unused messages for reference from Dolphin v4.0 build 6980 x64:
  582. ; emuPrimaryWindow.PostMessage("0x111", "0261") ; Toggle Fullscreen
  583. ; emuPrimaryWindow.PostMessage("0x111", "0258") ; Toggle Play/Pause
  584. ; emuPrimaryWindow.PostMessage("0x111", "0259") ; Stop
  585. ; emuPrimaryWindow.PostMessage("0x111", "0260") ; Reset
  586. ; emuPrimaryWindow.PostMessage("0x111", "00539") ; Show Toolbar
  587. ; emuPrimaryWindow.PostMessage("0x111", "00540") ; Show Statusbar
  588. ; emuPrimaryWindow.PostMessage("0x111", "05123") ; Refresh List
  589. ; emuPrimaryWindow.PostMessage("0x111", "0305") ; Change Disc
  590. ; emuPrimaryWindow.PostMessage("0x111", "00218") ; Load State Slot 1
  591. ; emuPrimaryWindow.PostMessage("0x111", "00227") ; Load State Slot 10
  592. ; emuPrimaryWindow.PostMessage("0x111", "00208") ; Save State Slot 1
  593. ; emuPrimaryWindow.PostMessage("0x111", "00217") ; Save State Slot 10
  594. ; emuPrimaryWindow.PostMessage("0x111", "00303") ; Start Netplay
  595. ; emuPrimaryWindow.PostMessage("0x111", "05000") ; Open
  596.  
  597. ; Unused messages for reference from Dolphin v4.0.2 x86:
  598. ; emuPrimaryWindow.PostMessage("0x111", "00248") ; Toggle Fullscreen
  599. ; emuPrimaryWindow.PostMessage("0x111", "00245") ; Toggle Play/Pause
  600. ; emuPrimaryWindow.PostMessage("0x111", "00246") ; Stop
  601. ; emuPrimaryWindow.PostMessage("0x111", "00247") ; Reset
  602. ; emuPrimaryWindow.PostMessage("0x111", "00501") ; Show Toolbar
  603. ; emuPrimaryWindow.PostMessage("0x111", "00502") ; Show Statusbar
  604. ; emuPrimaryWindow.PostMessage("0x111", "00217") ; Load State Slot 1
  605. ; emuPrimaryWindow.PostMessage("0x111", "00226") ; Load State Slot 10
  606. ; emuPrimaryWindow.PostMessage("0x111", "00207") ; Save State Slot 1
  607. ; emuPrimaryWindow.PostMessage("0x111", "00216") ; Save State Slot 10
  608. ; emuPrimaryWindow.PostMessage("0x111", "00286") ; Start Netplay
  609. ; emuPrimaryWindow.PostMessage("0x111", "05000") ; Open
  610. ; emuPrimaryWindow.PostMessage("0x111", "05006") ; Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement