Battlefield 1942: Difference between revisions
DoctorDalek (talk | contribs) (Created page with "Category:Games {{InfoBox.Game |Cover = cover.jpg |Developers = {{InfoBox.Game.Developer|Digital Illusions CE}} |Publishers = {{InfoBox.Game.Publisher|Electronic Arts}} {{InfoBox.Game.Publisher|Aspyr Media}} |Release Date = {{InfoBox.Game.ReleaseDate|Windows|September 10, 2002}} |Genres = {{InfoBox.Game.Genre|Shooter}} | PCGamingWiki = Battlefield_1942 }} == Name Change Script == A template profile is copied from the base game directory and some files have to be modi...") |
DoctorDalek (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
[[Category:Games]] | [[Category:Games]] | ||
{{InfoBox | {{Game.InfoBox | ||
|Cover = cover.jpg | |Cover = cover.jpg | ||
|Release Date = | |Release Date = | ||
{{InfoBox | {{Game.InfoBox.ReleaseDate|Windows|September 10, 2002}} | ||
| PCGamingWiki = Battlefield_1942 | | PCGamingWiki = Battlefield_1942 | ||
}} | }} | ||
== Name Change Script = | {{Game.ActionBox | ||
A template profile is copied from the base game directory and some files have to be modified to set the primary selected profile. | |Actions = | ||
<syntaxhighlight lang="powershell" line> | {{Game.ActionBox.Row|Name = Play Battlefield 1942: Secret Weapons of WWII|Path = BF1942.exe|Arguments = +game XPack2|WorkingDirectory = |Primary = True}} | ||
{{Game.ActionBox.Row|Name = Play Battlefield 1942|Path = BF1942.exe|Arguments = |WorkingDirectory = |Primary = True}} | |||
{{Game.ActionBox.Row|Name = Play Battlefield 1942: The Road to Rome|Path = BF1942.exe|Arguments = +game XPack1|WorkingDirectory = |Primary = True}} | |||
}} | |||
{{Game.Scripts.NameChange | |||
|Name = Name Change Script | |||
|Description = A template profile is copied from the base game directory and some files have to be modified to set the primary selected profile. | |||
|RequiresAdmin = False | |||
|Contents = <syntaxhighlight lang="powershell" line> | |||
$NewName = $args[0] | $NewName = $args[0] | ||
$InstallDir = $PSScriptRoot | $InstallDir = $PSScriptRoot | ||
Line 51: | Line 53: | ||
Write-ReplaceContentInFile -Regex 'game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName\GeneralOptions.con" | Write-ReplaceContentInFile -Regex 'game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName\GeneralOptions.con" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} |
Revision as of 06:54, 31 July 2023
Release Date | |
---|---|
Windows: September 10, 2002 | |
View at PCGamingWiki |
Actions
Name | Path | Arguments | Working Directory | Primary |
---|---|---|---|---|
Play Battlefield 1942: Secret Weapons of WWII | BF1942.exe | +game XPack2 | True | |
Play Battlefield 1942 | BF1942.exe | True | ||
Play Battlefield 1942: The Road to Rome | BF1942.exe | +game XPack1 | True |
Name Change Script
A template profile is copied from the base game directory and some files have to be modified to set the primary selected profile.
$NewName = $args[0]
$InstallDir = $PSScriptRoot
$OldName = ""
if ($args[1]) {
$OldName = $args[1]
}
function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
$content = (Get-Content $FilePath) -replace $Regex, $Replacement
[IO.File]::WriteAllLines($FilePath, $content)
}
# Clear out any existing profile with the same name
Remove-Item "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName" -Recurse -ErrorAction Ignore
if ($OldName -ne "") {
if (Test-Path -Path "$InstallDir\Mods\bf1942\Settings\Profiles\$OldName") {
# Profile exists with old name
Move-Item -Path "$InstallDir\Mods\bf1942\Settings\Profiles\$OldName" -Destination "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName" -Force
} else {
# Old profile doesn't exist, scaffold a new one
Copy-Item -Path "$InstallDir\ProfileTemplate" -Destination "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName" -Recurse
}
} else {
# New install, scaffold new profile
Copy-Item -Path "$InstallDir\ProfileTemplate" -Destination "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName" -Recurse
}
Write-ReplaceContentInFile -Regex 'rem \*\* (.+) \*\*' -Replacement "rem ** $NewName **" -FilePath "$InstallDir\Mods\bf1942\Settings\Profile.con"
Write-ReplaceContentInFile -Regex 'game.setProfile "(.+)"' -Replacement "game.setProfile ""$NewName""" -FilePath "$InstallDir\Mods\bf1942\Settings\Profile.con"
Write-ReplaceContentInFile -Regex 'game.setPlayerName "(.+)"' -Replacement "game.setPlayerName ""$NewName""" -FilePath "$InstallDir\Mods\bf1942\Settings\Profiles\$NewName\GeneralOptions.con"