# 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 '^persistent extern INDEX sam_iScreenSizeI=\(INDEX\)(\d+);' -Substitution "persistent extern INDEX sam_iScreenSizeI=(INDEX)$($Display.Bounds.Width);" -FilePath "$InstallDirectory\Scripts\PersistentSymbols.ini"
Write-ReplaceContentInFile -Pattern '^persistent extern INDEX sam_iScreenSizeJ=\(INDEX\)(\d+);' -Substitution "persistent extern INDEX sam_iScreenSizeJ=(INDEX)$($Display.Bounds.Height);" -FilePath "$InstallDirectory\Scripts\PersistentSymbols.ini"
# Might need to set FOV
$FOV = 90
if (($Display.Bounds.Width / $Display.Bounds.Height) -eq (16 / 9)) {
$FOV = 105
} elseif (($Display.Bounds.Width / $Display.Bounds.Height) -eq (16 / 10)) {
$FOV = 100
}
Write-ReplaceContentInFile -Pattern '^persistent extern user FLOAT plr_fFOV=\(FLOAT\)(\d+);' -Substitution "persistent extern FLOAT plr_fFOV=\(FLOAT\)$FOV;" -FilePath "$InstallDirectory\Scripts\PersistentSymbols.ini"
# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
$nameBytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 11 -MinLength 11
$teamBytes = ConvertTo-StringBytes -Input "Vintage" -MaxLength 7 -MinLength 7
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$InstallDirectory\Players\Player0.plr"
Edit-PatchBinary -FilePath "$InstallDirectory\Players\Player0.plr" -Offset 0x8 -Data $nameBytes
Edit-PatchBinary -FilePath "$InstallDirectory\Players\Player0.plr" -Offset 0x17 -Data $teamBytes