# Включаем кодировку UTF8 для консоли [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $lineBreak = [Environment]::NewLine # Пути $SongsGameplayXMLPath = "Defs\SongDefs" $musicPath = "Sounds\Gameplay" # Проверяем, что папка для xml существует, если нет — создаём if (-not (Test-Path $SongsGameplayXMLPath)) { New-Item -ItemType Directory -Path $SongsGameplayXMLPath | Out-Null } if (Test-Path "$SongsGameplayXMLPath\Songs_Gameplay.xml") { $content = Get-Content -Path "$SongsGameplayXMLPath\Songs_Gameplay.xml" -Raw } else { $content = "" } $allSongDefs = @() if ($content -ne "") { $blockPattern = "" $allSongDefs = [regex]::Matches($content, $blockPattern, [System.Text.RegularExpressions.RegexOptions]::Singleline) } # Переменная для накопления текста $xmlContent = @" "@ Get-ChildItem -Path $musicPath -File | ForEach-Object { $soundName = $_.BaseName $existingBlock = $null foreach ($block in $allSongDefs) { if ($block.Value -like "*$soundName*") { $existingBlock = $block.Value break } } if ($existingBlock) { Write-Output "Found existing block for $soundName" $xmlContent += "${lineBreak}$existingBlock${lineBreak}" } else { Write-Output "Added new block for $soundName" $xmlContent += @" ${lineBreak} $soundName Gameplay/$soundName 1.0 1.0 false
  • Winter
  • Spring
  • Summer
  • Fall
  • ${lineBreak} "@ } } # Закрываем тег $xmlContent += "
    " # Записать в файл одним вызовом $xmlContent | Out-File -FilePath "$SongsGameplayXMLPath\Songs_Gameplay.xml" -Encoding utf8 Write-Host "Songs_Gameplay.xml overwritten. After restarting the game, music will be added." Read-Host "Press Enter to exit"