$Display = Get-PrimaryDisplay
New-Item -ItemType Directory -Force -Path "$InstallDirectory\$($env:LOCALAPPDATA)\Gearbox Software\Nightfire"
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$($env:LOCALAPPDATA)\Gearbox Software\Nightfire\bond" -Recurse
New-Item -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software"
New-Item -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire"
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayWidth" -Value $Display.Bounds.Width -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayHeight" -Value $Display.Bounds.Height -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayDepth" -Value 24 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayRefreshRate" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayMultisampleCount" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Gearbox Software\Nightfire" -Name "DisplayVSYNC" -Value 267265 -Force
if (!Test-Path -Path "$($env:LOCALAPPDATA)\Gearbox Software\Nightfire\bond\config.cfg") {
Copy-Item -Path "$InstallDirectory\ProfileTemplate\config.cfg" -Destination "$($env:LOCALAPPDATA)\Gearbox Software\Nightfire\bond\config.cfg"
}
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^cl_name "(.+)"' -Substitution "cl_name ""$NewPlayerAlias""" -FilePath "$($env:LOCALAPPDATA)\Gearbox Software\Nightfire\bond"