# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^FullscreenViewportX=(.+)' -Substitution "FullscreenViewportX=$($Display.Bounds.Width)" -FilePath "$InstallDirectory\System\ut2004.ini"
Write-ReplaceContentInFile -Pattern '^FullscreenViewportY=(.+)' -Substitution "FullscreenViewportY=$($Display.Bounds.Height)" -FilePath "$InstallDirectory\System\ut2004.ini"
# Might need to set FOV
$FOV = 90
if (($Display.Bounds.Width / $Display.Bounds.Height) -eq (16 / 9)) {
$FOV = 106
} elseif (($Display.Bounds.Width / $Display.Bounds.Height) -eq (16 / 10)) {
$FOV = 100
}
Write-ReplaceContentInFile -Pattern '^DesiredFOV=(.+)' -Substitution "DesiredFOV=$FOV" -FilePath "$InstallDirectory\System\ut2004.ini"
Write-ReplaceContentInFile -Pattern '^DefaultFOV=(.+)' -Substitution "DefaultFOV=$FOV" -FilePath "$InstallDirectory\System\ut2004.ini"
Write-ReplaceContentInFile -Pattern '^FOVAngle=(.+)' -Substitution "DefaultFOV=$FOV.0" -FilePath "$InstallDirectory\System\ut2004.ini"
# Turns off Gamespy Stats & Replaces utmaster servers
Write-ReplaceContentInFile -Pattern "UplinkToGamespy=True" -Substitution "UplinkToGamespy=False" -FilePath "$InstallDirectory\System\UT2004.ini"
Write-ReplaceContentInFile -Pattern "ut2004master1.epicgames.com" -Substitution "utmaster.openspy.net" -FilePath "$InstallDirectory\System\UT2004.INI"
Write-ReplaceContentInFile -Pattern "ut2004master2.epicgames.com" -Substitution "ut2004master.333networks.com" -FilePath "$InstallDirectory\System\UT2004.INI"
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
# Creates or updates a key in the registry
# Non-destructively creates path in registry
New-Item -Path "$VirtualStore\WOW6432Node\Unreal Technology"
New-Item -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps"
New-Item -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "Version" -Value "1" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "CDKey" -Value "3QHVC-DHA9K-A84RE-KYRT4" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "ADMIN_RIGHTS" -Value "You need to run this program as an administrator, not as a guest or limited user account." -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "NO_DISC" -Value "No disc in drive. Please insert the disc labeled 'Unreal Tournament 2004 Play Disc' to continue." -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "NO_DRIVE" -Value "No CD-ROM or DVD-ROM drive detected." -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "TITLEBAR" -Value "Unreal Tournament 2004" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "WRONG_DISC" -Value "Wrong disc in drive. Please insert the disc labeled 'Unreal Tournament 2004 Play Disc' to continue." -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "YEAR" -Value "2004" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Name "Folder" -Value "$InstallDirectory" -Force
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
Remove-Item -Path "$VirtualStore\WOW6432Node\Unreal Technology\Installed Apps\UT2004" -Force -Recurse
Write-ReplaceContentInFile -Pattern 'Name=(.+)' -Substitution "Name=$NewPlayerAlias" -FilePath "$InstallDirectory\System\User.ini"