$Display = Get-PrimaryDisplay
$InstallDrive = Split-Path -Path $InstallDirectory -Qualifier
New-Item -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0"
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "language" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "Installed" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sPath_DataMin" -Value "$InstallDirectory\data\datamin" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sPath_DataMax" -Value "$InstallDirectory\data\datamax" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sNotBovine" -Value "$InstallDrive" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "bStartNet" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "bStartA3d" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionDiff" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionSoundRes" -Value 2 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionGraphicsRes" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionMusicVol" -Value 10 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionFxVol" -Value 6 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionCheckTime" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysUp" -Value 38 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysDown" -Value 40 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysLeft" -Value 37 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysRight" -Value 39 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysFast" -Value 16 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysSlow" -Value 17 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysFireCannon" -Value 18 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysFire" -Value 32 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionKeysAirBrakes" -Value 13 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysUpN" -Value "UP" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysDownN" -Value "DOWN" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysLeftN" -Value "LEFT" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysRightN" -Value "RIGHT" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysFastN" -Value "SHIFT" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysSlowN" -Value "CTRL" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysFireCannonN" -Value "ALT" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysFireN" -Value "SPACE" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionKeysAirBrakesN" -Value "ENTER" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionJoyFast" -Value 7 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionJoySlow" -Value 8 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionJoyFireCannon" -Value 2 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionJoyFire" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iOptionJoyAirBrakes" -Value 3 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionJoyFastN" -Value "BUTTON 7" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionJoySlowN" -Value "BUTTON 8" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionJoyFireCannonN" -Value "BUTTON 2" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionJoyFireN" -Value "BUTTON 1" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "sOptionJoyAirBrakesN" -Value "BUTTON 3" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy\1.0" -Name "iStartRes" -Value 13 -Force
$Resolution = Convert-AspectRatio -Width $Display.Bounds.Width -Height $Display.Bounds.Height -AspectRatio (4 / 3)
Write-ReplaceContentInFile -Pattern '^Resolution (.+)' -Substitution "Resolution = h:$($Resolution.Width), v:$($Resolution.Height), refrate:60" -FilePath "$InstallDirectory\dgVoodoo.conf"
Remove-Item -Path "registry::\HKEY_CURRENT_USER\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\Europress\Plane Crazy" -Force -Recurse
# Plane Crazy stores player/plane strings in a binary .pln file in the data\DataMin\Planes directory
# The following script should change the player name in plane1.pln. The length of the name seems to
# be arbitrary, so make sure MaxLength matches the length of the template plane1.pln file you will
# have to place at the root of the game's directory before packaging.
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16
Edit-PatchBinary -FilePath "$InstallDirectory\data\DataMin\Planes\plane1.pln" -Offset 0x00 -Data $bytes