Star Wars: Jedi Knight - Dark Forces II

From LANCommander
Revision as of 01:30, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|LucasArts}} |Publishers = {{Game.InfoBox.Publisher|LucasArts}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|September 30, 1997}} |Genres = {{Game.InfoBox.Genre|Shooter}} | PCGamingWiki = Star_Wars:_Jedi_Knight_-_Dark_Forces_II }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = openjkdf2-64.exe|Arguments = |WorkingDirectory = |Primary = True}} }} {{Game...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
LucasArts
Publishers
LucasArts
Release Date
Windows: September 30, 1997
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play openjkdf2-64.exe True

Name Change Script

$InstallDir = $PSScriptRoot
$NewName = $args[0].Split([IO.Path]::GetInvalidFileNameChars()) -join '_'

$OldName = ""
if ($args[1]) {
	$OldName = $args[1].Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
}

function Write-ReplaceContentInFile([string]$Regex, [string]$Replacement, [string]$FilePath)
{
    $content = (Get-Content $FilePath) -replace $Regex, $Replacement
    [IO.File]::WriteAllLines($FilePath, $content)
}

# Trim a string down to a specified amount of characters
if ($OldName.Length -gt 15) {
    $OldName = $OldName.Substring(0, 15);
}

if ($NewName.Length -gt 15) {
    $NewName = $NewName.Substring(0, 15);
}

# Scaffold an "old" profile using the included template
if (!$OldName) {
    $OldName = "ProfileTemplate";
    Copy-Item -Path "$InstallDir\ProfileTemplate" -Destination "$InstallDir\player\$OldName" -Recurse
}

Copy-Item -Path "$InstallDir\player\$OldName" -Destination "$InstallDir\player\$NewName" -Recurse
Remove-Item "$InstallDir\player\$OldName" -Recurse -ErrorAction Ignore

Rename-Item "$InstallDir\player\$NewName\$OldName.plr" "$InstallDir\player\$NewName\$NewName.plr"
Rename-Item "$InstallDir\player\$NewName\$OldName.mpc" "$InstallDir\player\$NewName\$NewName.mpc"

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Regex '"gameName": "(.+)",' -Replacement """gameName"": ""$NewName's Game""," -FilePath "$InstallDir\registry.json"
Write-ReplaceContentInFile -Regex '"playerShortname": "(.+)",' -Replacement """playerShortname"": ""$NewName""," -FilePath "$InstallDir\registry.json"