#$Display = Get-PrimaryDisplay
# Bounds accessible via $Resolution.Height, $Resolution.Width
#$Resolution = Convert-AspectRatio -Width $Display.Bounds.Width -Height $Display.Bounds.Height -AspectRatio (4 / 3)
#Write-ReplaceContentInFile -Pattern '^"SCREENWIDTH" "(.+)"' -Substitution """SCREENWIDTH"" ""$($Resolution.Width)""" -FilePath "$InstallDirectory\Aliens vs. Predator 2\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"GameScreenWidth" "(.+)"' -Substitution """GameScreenWidth"" ""$($Resolution.Width)""" -FilePath "$InstallDirectory\Aliens vs. Predator 2\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"SCREENHEIGHT" "(.+)"' -Substitution """SCREENHEIGHT"" ""$($Resolution.Height)""" -FilePath "$InstallDirectory\Aliens vs. Predator 2\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"GameScreenHeight" "(.+)"' -Substitution """GameScreenHeight"" ""$($Resolution.Height)""" -FilePath "$InstallDirectory\Aliens vs. Predator 2\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"SCREENWIDTH" "(.+)"' -Substitution """SCREENWIDTH"" ""$($Resolution.Width)""" -FilePath "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"GameScreenWidth" "(.+)"' -Substitution """GameScreenWidth"" ""$($Resolution.Width)""" -FilePath "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"SCREENHEIGHT" "(.+)"' -Substitution """SCREENHEIGHT"" ""$($Resolution.Height)""" -FilePath "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\autoexec.cfg"
#Write-ReplaceContentInFile -Pattern '^"GameScreenHeight" "(.+)"' -Substitution """GameScreenHeight"" ""$($Resolution.Height)""" -FilePath "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\autoexec.cfg"
# Define the path to the autoexec.cfg file
$filePath = "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\autoexec.cfg"
# Get the screen resolution
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Size
$width = $screen.Width
$height= $screen.Height
# Read the content of the file
$content = Get-Content -Path $filePath
# Loop through each line in the file
for ($i = 0; $i -lt $content.Count; $i++) {
$line = $content[$i]
# Check if the line contains "SCREENWIDTH" and "640"
if ($line -like '*SCREENWIDTH*') {
# Replace the line with the updated width
$content[$i] = """SCREENWIDTH"" ""$width"""
}
if ($line -like '*GameScreenWidth*') {
# Replace the line with the updated width
$content[$i] = """GameScreenWidth"" ""$width"""
}
if ($line -like '*SCREENHEIGHT*') {
# Replace the line with the updated height
$content[$i] = """SCREENHEIGHT"" ""$height"""
}
if ($line -like '*GameScreenHeight*') {
# Replace the line with the updated height
$content[$i] = """GameScreenHeight"" ""$height"""
}
}
# Save the updated content back to the file
$content | Set-Content -Path $filePath
Write-ReplaceContentInFile -Pattern '^PlayerName = "(.+)"' -Substitution "PlayerName = ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Aliens versus Predator 2 - Primal Hunt\Profiles\Player_0.txt"
Write-ReplaceContentInFile -Pattern '^PlayerName = "(.+)"' -Substitution "PlayerName = ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Aliens vs. Predator 2\Profiles\Player_0.txt"