Skip to content

Commit

Permalink
IL-2 Great Battles configuration script: fixed and simplified devices…
Browse files Browse the repository at this point in the history
….txt generation
  • Loading branch information
bwRavencl committed Oct 30, 2023
1 parent 8601ad7 commit 01888f0
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions configs/IL-2_GB/Configure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,7 @@ if ($null -eq $vJoyDevice) {
}

$devicesTxt = "$il2InputDir\devices.txt"

if (Test-Path $devicesTxt -PathType Leaf) {
$devicesTxtContent = (Get-Content $devicesTxt -Raw)
}

if ([string]::IsNullOrEmpty($devicesTxtContent)) {
$devicesTxtContent = 'configId,guid,model|'
}

$vJoyDeviceLineWithoutIndex = $([uri]::EscapeUriString("`"$(($vJoyDevice.InstanceGuid.ToString().ToLower() -split '-', 5)[0..2] -join '-')-0000545345440380`",$($vJoyDevice.InstanceName.ToString())"))
$vJoyDeviceLineWithIndexZero = "0,$vJoyDeviceLineWithoutIndex"
$escapedVJoyDeviceLineWithoutIndex = $([Regex]::Escape($vJoyDeviceLineWithoutIndex))

$devicesTxtContent = $devicesTxtContent -replace "(?m)^[1-9][0-9]*(,$escapedVJoyDeviceLineWithoutIndex)", '0$1'
$devicesTxtContent = $devicesTxtContent -replace "(?m)^0(,(?!$escapedVJoyDeviceLineWithoutIndex))", '1$1'

if ($devicesTxtContent -notmatch $([Regex]::Escape($vJoyDeviceLineWithIndexZero))) {
$devicesTxtContent += "`n`n$vJoyDeviceLineWithIndexZero"
}
$devicesTxtContent = "configId,guid,model|`n`n0," + $([uri]::EscapeUriString("`"$(($vJoyDevice.InstanceGuid.ToString().ToLower() -split '-', 5)[0..2] -join '-')-0000545345440380`",$($vJoyDevice.InstanceName.ToString())"))

try {
Get-ChildItem -Path $il2InputDir -File -Depth 0 | Remove-Item
Expand Down

0 comments on commit 01888f0

Please sign in to comment.