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.
 
 
 

206 lines
8.6 KiB

#------------------------------------------------------
## Prepare the script for possible Ctrl+C termination
while ($true)
{
#------------------------------------------------------
## Initial script messages
"***Welcome Comrade***"
Start-Sleep -s 3
"`nThis script will generate OpenRA with Tiberian Sun & Red Alert 2 for Windows."
Start-Sleep -s 4
"`n- Make sure you have Microsoft .NET Framework 4.5 installed on your computer."
Start-Sleep -s 3
"`n- This script is NOT made by the OpenRA developers and may contain bugs."
Start-Sleep -s 3
"`n- If you worry about what the script is doing, you can always check its code (\data\install.ps1)"
Start-Sleep -s 4
"`n- Press Ctrl+C if you want terminate script execution."
Start-Sleep -s 4
"`n***Starting execution sequence now***"
Start-Sleep -s 3
#------------------------------------------------------
## Remove all old source files if they exist
"`nRemoving all old source files that may exist in the data directory."
Remove-Item .\data\OpenRA-bleed -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item .\data\ra2-master -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item .\data\OpenRA-bleed.zip -Force -ErrorAction SilentlyContinue
Remove-Item .\data\ra2-master.zip -Force -ErrorAction SilentlyContinue
#------------------------------------------------------
## Prepare Github environment for downloading the source
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$client = New-Object System.Net.WebClient
$client.Headers.Add("Authorization","token 1234567890notarealtoken987654321")
$client.Headers.Add("Accept","application/vnd.github.v3.raw")
#------------------------------------------------------
## Download OpenRA-bleed source code
"`nDownloading OpenRA source files from Github. Please Stand By."
$client.DownloadFile("https://github.com/OpenRA/OpenRA/archive/bleed.zip?ref=bleed",".\data\OpenRA-bleed.zip”)
#------------------------------------------------------
## Download Red Alert 2 mod files
"`nDownloading Red Alert 2 mod files from Github. Please Stand By."
$client.DownloadFile("https://github.com/OpenRA/ra2/archive/master.zip?ref=master",".\data\ra2-master.zip)
#------------------------------------------------------
## Unzip OpenRA-bleed source files
"`nUnzipping OpenRA source files into data folder."
$shell_app=new-object -com shell.application
$filename = "OpenRA-bleed.zip"
$zip_file = $shell_app.namespace((Get-Location).Path + "\data" + "\$filename")
$destination = $shell_app.namespace((Get-Location).Path + "\data")
$destination.Copyhere($zip_file.items())
#------------------------------------------------------
## Unzip Red Alert 2 mod files
"`nUnzipping Red Alert 2 mod files into data folder."
$shell_app=new-object -com shell.application
$filename2 = "ra2-master.zip"
$zip_file2 = $shell_app.namespace((Get-Location).Path + "\data" + "\$filename2")
$destination = $shell_app.namespace((Get-Location).Path + "\data")
$destination.Copyhere($zip_file2.items())
#------------------------------------------------------
## Merge OpenRA source files and Red Alert 2 mod files together
"`nMerging OpenRA source & Red Alert 2 mod files."
move-item ".\data\ra2-master\OpenRA.Mods.RA2" ".\data\OpenRA-bleed\OpenRA.Mods.RA2"
move-item ".\data\ra2-master" ".\data\OpenRA-bleed\mods\ra2"
#------------------------------------------------------
## Get OpenRA Git version number
"`nRetrieving OpenRA & Red Alert 2 Git version numbers."
$web = New-Object System.Net.WebClient
$web.DownloadFile("https://github.com/OpenRA/OpenRA",".\data\openra-github.html")
$flag=0
Get-Content .\data\openra-github.html |
foreach {
Switch -Wildcard ($_){
"*Latest commit*" {$flag=1}
"*time datetime*" {$flag=0}
}
if ($flag -eq 1){
Out-File .\data\openra-html-stripped.txt -InputObject $_ -Append
}
}
(Get-Content .\data\openra-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\openra-latestcommit.txt
$openra_gitversion = [IO.File]::ReadAllText(".\data\openra-latestcommit.txt").trim("`r`n")
#------------------------------------------------------
## Get Red Alert 2 Git version number
$web = New-Object System.Net.WebClient
$web.DownloadFile("https://github.com/OpenRA/ra2",".\data\ra2-github.html")
$flag=0
Get-Content .\data\ra2-github.html |
foreach {
Switch -Wildcard ($_){
"*Latest commit*" {$flag=1}
"*time datetime*" {$flag=0}
}
if ($flag -eq 1){
Out-File .\data\ra2-html-stripped.txt -InputObject $_ -Append
}
}
(Get-Content .\data\ra2-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\ra2-latestcommit.txt
$ra2_gitversion = [IO.File]::ReadAllText(".\data\ra2-latestcommit.txt").trim("`r`n")
#------------------------------------------------------
## Prepare OpenRA source code for Tiberian Sun & Red Alert 2
Start-Sleep -s 3
"`nPatching OpenRA source code for Tiberian Sun & Red Alert 2."
cd .\data
.\patch.exe -d OpenRA-bleed -Np1 -i ..\openra-srcpatch.patch
cd ..
#------------------------------------------------------
## Push version numbers to mod files
# Red Alert
(Get-Content .\data\Openra-bleed\mods\ra\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\ra\mod.yaml
# Tiberian Dawn
(Get-Content .\data\Openra-bleed\mods\cnc\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\cnc\mod.yaml
# Dune 2K
(Get-Content .\data\Openra-bleed\mods\d2k\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\d2k\mod.yaml
# Tiberian Sun
(Get-Content .\data\Openra-bleed\mods\ts\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\ts\mod.yaml
# Red Alert 2
(Get-Content .\data\Openra-bleed\mods\ra2\mod.yaml) -replace '{DEV_VERSION}',$ra2_gitversion | Set-Content .\data\Openra-bleed\mods\ra2\mod.yaml
# Mod Chooser
(Get-Content .\data\Openra-bleed\mods\modchooser\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\modchooser\mod.yaml
# All
(Get-Content .\data\Openra-bleed\mods\all\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\Openra-bleed\mods\all\mod.yaml
#------------------------------------------------------
## Remove temporary files
Remove-Item .\data\openra-github.html
Remove-Item .\data\openra-html-stripped.txt
Remove-Item .\data\ra2-github.html
Remove-Item .\data\ra2-html-stripped.txt
Remove-Item .\data\openra-latestcommit.txt
Remove-Item .\data\ra2-latestcommit.txt
#------------------------------------------------------
## Compile OpenRA with Tiberian Sun & Red Alert 2
"`nCompiling OpenRA with Tiberian Sun & Red Alert 2.`n"
cd .\data\OpenRA-bleed\
.\make.cmd dependencies
.\make.cmd all
cd ..
cd ..
move-item ".\data\OpenRA-bleed\" ".\OpenRA-bleed-tibsunra2"
#------------------------------------------------------
## Post-installation messages
"`nCompilation process completed. You find the game inside 'OpenRA-bleed-tibsunra2' folder"
Start-Sleep -s 4
"`nTO PLAY OPENRA: Click OpenRA.exe (maybe you should create a desktop shortcut for it?)"
"`nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so."
"`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)"
"`nMULTIPLAYER: It's recommended to use exactly same compiled EXE files (and other stuff) for multiplayer usage to minimize possible version differences/conflicts between players. If your friends compiles this package with another operating system, please make sure they use exactly same source files for their OpenRA compilation process."
"`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\"
"`nHave fun!"
exit
#------------------------------------------------------
## Termination code for the script (Ctrl + C)
if ($Host.UI.RawUI.KeyAvailable -and (3 -eq [int]$Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character))
{
write-host "Installation script terminated by user."
$key = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
if ($key.Character -eq "N") { break; }
}
}