Actions
Name |
Path |
Arguments |
Working Directory |
Primary |
Play |
Battle_Realms_F.exe |
|
{InstallDir} |
True |
Install Script
#######################################################################
#Updates Screen Resolution to match desktop resolution and full screen
#######################################################################
$Config = "$InstallDirectory\Battle_Realms.ini"
# 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 '^Height =(.+)' -Substitution "Height =$($Display.Bounds.Height)" -FilePath "$Config"
Write-ReplaceContentInFile -Pattern '^Width =(.+)' -Substitution "Width =$($Display.Bounds.Width)" -FilePath "$Config"
Write-ReplaceContentInFile -Pattern '^Fullscreen =(.+)' -Substitution "Fullscreen =1" -FilePath "$Config"
Write-ReplaceContentInFile -Pattern '^Depth =(.+)' -Substitution "Depth =32" -FilePath "$Config"
#######################################################################
Name Change Script
Battle Realms requires names to be no more than 20 characters and it stores them by using the filename of the profile. This script will sanitize the name and attempt to replace the old profile. Otherwise, it will scaffold a new one. Make sure to put a ProfileTemplate.brp in the install directory for your archive.
# Takes the variable $Filename, splits it by invalid characters, then joins to remove them
$OldPlayerAlias = $OldPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join ''
$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join ''
# Trim a string down to a specified amount of characters
if ($OldPlayerAlias.Length -gt 20) {
$OldPlayerAlias = $OldPlayerAlias.Substring(0, 20);
}
if ($NewPlayerAlias.Length -gt 20) {
$NewPlayerAlias = $NewPlayerAlias.Substring(0, 20);
}
if (Test-Path "$InstallDirectory\PlayerProfiles\$OldPlayerAlias.brp") {
Rename-Item -Path "$InstallDirectory\PlayerProfiles\$OldPlayerAlias.brp" -NewName "$InstallDirectory\PlayerProfiles\$NewPlayerAlias.brp"
} else {
Copy-Item -Path "$InstallDirectory\ProfileTemplate.brp" -Destination "$InstallDirectory\PlayerProfiles\$NewPlayerAlias.brp"
}