Provides automatic installation scripts for OpenRA with Tiberian Sun & Red Alert 2 + Dune 2 (Windows, Linux)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
11 KiB

  1. #------------------------------------------------------
  2. ## Prepare the script for possible Ctrl+C termination
  3. while ($true)
  4. {
  5. #------------------------------------------------------
  6. ## Initial script messages
  7. "***Welcome Comrade***"
  8. Start-Sleep -s 3
  9. "`nThis script will generate OpenRA with Tiberian Sun & Red Alert 2 for Windows."
  10. Start-Sleep -s 4
  11. "`n- Make sure you have Microsoft .NET Framework 4.5 installed on your computer."
  12. Start-Sleep -s 3
  13. "`n- This script is NOT made by the OpenRA developers and may have bugs."
  14. Start-Sleep -s 3
  15. "`n- If you worry about what the script is doing, you can always check its code (\data\windows\install.ps1)"
  16. Start-Sleep -s 4
  17. "`n- Press Ctrl+C if you want terminate script execution."
  18. Start-Sleep -s 4
  19. "`n***Starting execution sequence now***"
  20. Start-Sleep -s 3
  21. #------------------------------------------------------
  22. ## Hotfix question
  23. If (Test-Path ".\data\hotfixes\windows\*.patch"){
  24. "`n- Hotfixes -- Question`n"
  25. "Use custom hotfixes if added by the user (Default: No)?\nNOTE: If you choose YES (y), be aware that your OpenRA/RA2 version will likely not be compatible with the other players unless they've applied exactly same hotfixes in their game versions, too!"
  26. "`nAvailable hotfixes are:"
  27. ##List available hotfix files:
  28. get-childitem ".\data\hotfixes\windows\" -recurse | where {$_.extension -eq '.patch'} | format-table Name
  29. $hotfixes = Read-Host "Use these hotfixes? (y/N)"
  30. if ($hotfixes -eq "y") {
  31. "`nHotfixes applied. Continuing."
  32. } else {
  33. "`nHotfixes ignored and skipped. Continuing."
  34. }
  35. }Else{
  36. "`nAvailable hotfixes: None"
  37. }
  38. Start-Sleep -s 2
  39. #------------------------------------------------------
  40. ## Remove all old source files if they exist
  41. "`nRemoving all old source files that may exist in the data directory."
  42. Remove-Item .\data\windows\OpenRA-bleed -Force -Recurse -ErrorAction SilentlyContinue
  43. Remove-Item .\data\windows\ra2-master -Force -Recurse -ErrorAction SilentlyContinue
  44. Remove-Item .\data\windows\OpenRA-bleed.zip -Force -ErrorAction SilentlyContinue
  45. Remove-Item .\data\windows\ra2-master.zip -Force -ErrorAction SilentlyContinue
  46. Remove-Item .\data\windows\*.html -Force -ErrorAction SilentlyContinue
  47. Remove-Item .\data\windows\*.txt -Force -ErrorAction SilentlyContinue
  48. Remove-Item .\data\windows\*.zip -Force -ErrorAction SilentlyContinue
  49. Remove-Item .\data\windows\*.patch -Force -ErrorAction SilentlyContinue
  50. #------------------------------------------------------
  51. ## Prepare Github environment for downloading the source
  52. [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
  53. $client = New-Object System.Net.WebClient
  54. $client.Headers.Add("Authorization","token 1234567890notarealtoken987654321")
  55. $client.Headers.Add("Accept","application/vnd.github.v3.raw")
  56. #------------------------------------------------------
  57. ## Download OpenRA-bleed source code
  58. "`nDownloading OpenRA source files from Github. Please Stand By."
  59. $client.DownloadFile("https://github.com/OpenRA/OpenRA/archive/bleed.zip?ref=bleed",".\data\windows\OpenRA-bleed.zip")
  60. #------------------------------------------------------
  61. ## Download Red Alert 2 mod files
  62. "`nDownloading Red Alert 2 mod files from Github. Please Stand By."
  63. $client.DownloadFile("https://github.com/OpenRA/ra2/archive/master.zip?ref=master",".\data\windows\ra2-master.zip")
  64. #------------------------------------------------------
  65. ## Unzip OpenRA-bleed source files
  66. "`nUnzipping OpenRA source files into \data\windows folder."
  67. $shell_app=new-object -com shell.application
  68. $filename = "OpenRA-bleed.zip"
  69. $zip_file = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename")
  70. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  71. $destination.Copyhere($zip_file.items())
  72. #------------------------------------------------------
  73. ## Unzip Red Alert 2 mod files
  74. "`nUnzipping Red Alert 2 mod files into \data\windows folder."
  75. $shell_app=new-object -com shell.application
  76. $filename2 = "ra2-master.zip"
  77. $zip_file2 = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename2")
  78. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  79. $destination.Copyhere($zip_file2.items())
  80. #------------------------------------------------------
  81. ## Merge OpenRA source files and Red Alert 2 mod files together
  82. "`nMerging OpenRA source & Red Alert 2 mod files."
  83. Copy-Item -Recurse ".\data\windows\ra2-master\OpenRA.Mods.RA2" ".\data\windows\OpenRA-bleed\OpenRA.Mods.RA2"
  84. Copy-Item -Recurse ".\data\windows\ra2-master" ".\data\windows\OpenRA-bleed\mods\ra2"
  85. Remove-Item -Recurse .\data\windows\ra2-master\*
  86. #------------------------------------------------------
  87. ## Get OpenRA Git version number
  88. "`nRetrieving OpenRA & Red Alert 2 Git version numbers."
  89. $web = New-Object System.Net.WebClient
  90. $web.DownloadFile("https://github.com/OpenRA/OpenRA",".\data\windows\openra-github.html")
  91. $flag=0
  92. Get-Content .\data\windows\openra-github.html |
  93. foreach {
  94. Switch -Wildcard ($_){
  95. "*Latest commit*" {$flag=1}
  96. "*time datetime*" {$flag=0}
  97. }
  98. if ($flag -eq 1){
  99. Out-File .\data\windows\openra-html-stripped.txt -InputObject $_ -Append
  100. }
  101. }
  102. (Get-Content .\data\windows\openra-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\openra-latestcommit.txt
  103. $openra_gitversion = [IO.File]::ReadAllText(".\data\windows\openra-latestcommit.txt").trim("`r`n")
  104. Write-Output "`nOpenRA version: $openra_gitversion"
  105. #------------------------------------------------------
  106. ## Get Red Alert 2 Git version number
  107. $web = New-Object System.Net.WebClient
  108. $web.DownloadFile("https://github.com/OpenRA/ra2",".\data\windows\ra2-github.html")
  109. $flag=0
  110. Get-Content .\data\windows\ra2-github.html |
  111. foreach {
  112. Switch -Wildcard ($_){
  113. "*Latest commit*" {$flag=1}
  114. "*time datetime*" {$flag=0}
  115. }
  116. if ($flag -eq 1){
  117. Out-File .\data\windows\ra2-html-stripped.txt -InputObject $_ -Append
  118. }
  119. }
  120. (Get-Content .\data\windows\ra2-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\ra2-latestcommit.txt
  121. $ra2_gitversion = [IO.File]::ReadAllText(".\data\windows\ra2-latestcommit.txt").trim("`r`n")
  122. Write-Output "RA2 version: $ra2_gitversion"
  123. #------------------------------------------------------
  124. ## Prepare OpenRA source code for Tiberian Sun & Red Alert 2
  125. Copy-Item ".\data\patches\windows\*.patch" ".\data\windows"
  126. if ($hotfixes -eq "y") {
  127. Copy-Item ".\data\hotfixes\windows\*.patch" ".\data\windows"
  128. }
  129. Start-Sleep -s 3
  130. "`nPatching OpenRA source code for Tiberian Sun & Red Alert 2."
  131. cd .\data\windows
  132. "`nFor each time a patch/hotfix is being applied, UAC may ask permission for patch.exe."
  133. $patchcount = (Get-Childitem .\ | where {$_.extension -eq ".patch"} | Measure-Object ).Count;
  134. Write-Output "`nExecuting patch.exe $patchcount times now."
  135. Start-Sleep -s 6
  136. Get-ChildItem .\ -include *.patch -recurse | Foreach ($_) {.\patch.exe -d OpenRA-bleed -Np1 -i $_.fullname }
  137. cd ..
  138. cd ..
  139. #------------------------------------------------------
  140. ## Push version numbers to mod files
  141. # Red Alert
  142. (Get-Content .\data\windows\Openra-bleed\mods\ra\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ra\mod.yaml
  143. # Tiberian Dawn
  144. (Get-Content .\data\windows\Openra-bleed\mods\cnc\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\cnc\mod.yaml
  145. # Dune 2K
  146. (Get-Content .\data\windows\Openra-bleed\mods\d2k\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\d2k\mod.yaml
  147. # Tiberian Sun
  148. (Get-Content .\data\windows\Openra-bleed\mods\ts\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ts\mod.yaml
  149. # Red Alert 2
  150. (Get-Content .\data\windows\Openra-bleed\mods\ra2\mod.yaml) -replace '{DEV_VERSION}',$ra2_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ra2\mod.yaml
  151. # Mod Chooser
  152. (Get-Content .\data\windows\Openra-bleed\mods\modchooser\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\modchooser\mod.yaml
  153. # All
  154. (Get-Content .\data\windows\Openra-bleed\mods\all\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\all\mod.yaml
  155. #------------------------------------------------------
  156. ## Remove temporary files
  157. Remove-Item .\data\windows\*.html
  158. Remove-Item .\data\windows\*.txt
  159. Remove-Item .\data\windows\*.zip
  160. Remove-Item .\data\windows\*.patch
  161. #------------------------------------------------------
  162. ## Compile OpenRA with Tiberian Sun & Red Alert 2
  163. "`nCompiling OpenRA with Tiberian Sun & Red Alert 2.`n"
  164. cd .\data\windows\OpenRA-bleed\
  165. .\make.cmd dependencies
  166. .\make.cmd all
  167. cd ..
  168. cd ..
  169. cd ..
  170. "`nCopying OpenRA files to the final location.`n"
  171. Copy-Item -Recurse ".\data\windows\OpenRA-bleed\" ".\OpenRA-tibsunra2-Windows"
  172. Remove-Item .\data\windows\OpenRA-bleed\* -Recurse
  173. Remove-Item .\data\windows\OpenRA-bleed
  174. Remove-Item .\data\windows\ra2-master
  175. #------------------------------------------------------
  176. ## Post-installation messages
  177. "`nCompilation process completed. You find the game inside 'OpenRA-tibsunra2-Windows' folder"
  178. Start-Sleep -s 4
  179. "`nTO PLAY OPENRA: Click OpenRA.exe (maybe you should create a desktop shortcut for it?)"
  180. "`nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so."
  181. "`nTO PLAY RED ALERT 2: you must install language.mix, multi.mix, ra2.mix and theme.mix into \My Documents\OpenRA\Content\ra2\ folder.`nYou find these files from original RA2 installation media (CD's):`n`ntheme.mix, multi.mix = RA2 CD Root folder`nra2.mix, language.mix = RA2 CD Root\INSTALL\Game1.CAB (inside that archive file)"
  182. "`nMULTIPLAYER: It's recommended to build OpenRA using exactly same GIT source files for multiplayer usage to minimize possible version differences/conflicts between players. Please make sure all players have exactly same git versions of their in-game mods (RA, CNC, D2K, TS, RA2). Version numbers are formatted like 'git-e0d7445' etc. and can be found in each mod description in the mod selection menu."
  183. "`nFor this compilation, the version numbers are as follows:"
  184. Write-Output "OpenRA version: $openra_gitversion"
  185. Write-Output "RA2 version: $ra2_gitversion"
  186. "`nUNINSTALLATION: Since the game has been compiled from source and no additional setup programs are provided, all you need to do is to delete the contents of 'OpenRA-bleed-tibsunra2' folder and \My Documents\OpenRA\"
  187. "`nHave fun!"
  188. exit
  189. #------------------------------------------------------
  190. ## Termination code for the script (Ctrl + C)
  191. if ($Host.UI.RawUI.KeyAvailable -and (3 -eq [int]$Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character))
  192. {
  193. write-host "Installation script terminated by user."
  194. $key = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
  195. if ($key.Character -eq "N") { break; }
  196. }
  197. }