diff --git a/.gitignore b/.gitignore index 5dc49c2..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +0,0 @@ -ruinship_tournament_mods/ -шаблон.ps1 \ No newline at end of file diff --git a/download_mods.ps1 b/download_mods.ps1 index 2f690c3..9bf6355 100644 --- a/download_mods.ps1 +++ b/download_mods.ps1 @@ -17,12 +17,12 @@ if ($form) { $uriBuilder.Query = $queryString $downloadUrl = $uriBuilder.Uri.AbsoluteUri - Write-Host "[INFO] Downloading..." + Write-Host "[INFO] Downloading mods..." Invoke-WebRequest -Uri $downloadUrl -WebSession $session -OutFile $outputFile Write-Host "[INFO] The file was successfully downloaded with confirmation." } else { - Write-Host "[INFO] Downloading..." + Write-Host "[INFO] Downloading mods..." Invoke-WebRequest -Uri $baseUrl -OutFile $outputFile Write-Host "[INFO] The file was successfully downloaded directly." } @@ -31,6 +31,9 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition $rimworldMods = Resolve-Path (Join-Path $scriptDir "..") $sourceFolder = Get-ChildItem $outputFile | Select-Object -First 1 -Move-Item -Path $sourceFolder.FullName -Destination $rimworldMods +Copy-Item -Path $sourceFolder.FullName -Destination $rimworldMods + +Write-Host "[INFO] Cleaning up..." +Remove-Item $outputFile Write-Host "[INFO] The ruinship_mods.rar file has been installed to the path $rimworldMods. Please extract it to install all the necessary mods." -ForegroundColor Green diff --git a/install_modsconfig.ps1 b/install_modsconfig.ps1 new file mode 100644 index 0000000..396ae22 --- /dev/null +++ b/install_modsconfig.ps1 @@ -0,0 +1,23 @@ +$fileId = "1xxASbjTXkFWIGRwJe3zxgCqRXH4Kg_MD" +$baseUrl = "https://drive.google.com/uc?export=download&id=$fileId" + +$rimworldPath = Join-Path $env:USERPROFILE "AppData\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios" +$rimworldConfigPath = Join-Path $rimworldPath "Config\ModsConfig.xml" + +$response = Invoke-WebRequest -Uri $baseUrl -SessionVariable session + +$form = $response.Forms | Where-Object { $_.Id -eq "download-form" } +$queryParams = @{} +foreach ($field in $form.Fields.GetEnumerator()) { + $queryParams[$field.Key] = $field.Value +} + +$uriBuilder = New-Object System.UriBuilder $form.Action +$queryString = ($queryParams.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "&" +$uriBuilder.Query = $queryString +$downloadUrl = $uriBuilder.Uri.AbsoluteUri + +Write-Host "[INFO] Downloading ModsConfig.xml..." +Invoke-WebRequest -Uri $downloadUrl -WebSession $session -OutFile $rimworldConfigPath + +Write-Host "[INFO] ModsConfig.xml was successfully downloaded." -ForegroundColor Green \ No newline at end of file diff --git a/setup.bat b/setup.bat index 3db7eeb..fffda4f 100644 --- a/setup.bat +++ b/setup.bat @@ -2,6 +2,23 @@ setlocal enabledelayedexpansion chcp 65001 +if "%1"=="-mode" ( + if "%2"=="" ( + echo Ошибка: Аргумент не передан + exit /b 1 + ) + if "%2"=="mods" ( + call :modsInstall + goto end + ) + if "%2"=="config" ( + call :ModsConfigInstall + goto end + ) + echo Ошибка: Режима %2 не существует + goto end +) + echo Укажите, что вам нужно сделать: :ask echo 1) Установить моды (они будут только установлены в качестве архива и их надо будет вручную распаковать) @@ -13,13 +30,14 @@ echo 5) Выйти set /p choice=Введите нужный пункт: if /i "%choice%"=="1" ( - powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" + call :modsInstall + echo Не забудьте распаковать моды из архива в папке Mods^^! echo Вам что-то ещё? goto ask ) if /i "%choice%"=="2" ( - - echo Пока функция не готова. Вам что-то ещё? + call :ModsConfigInstall + echo Вам что-то ещё? goto ask ) if /i "%choice%"=="3" ( @@ -28,9 +46,10 @@ if /i "%choice%"=="3" ( goto ask ) if /i "%choice%"=="4" ( - powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" + call :installAll echo Всё готово^^! Осталось только распаковать моды из архива в папке Mods и можно начинать играть^^! + pause goto end ) if /i "%choice%"=="5" ( @@ -40,4 +59,17 @@ if /i "%choice%"=="5" ( echo Варианта %choice% не существует goto ask +:: Функции +:ModsConfigInstall +powershell -ExecutionPolicy Bypass -File "%~dp0install_modsconfig.ps1" +goto :eof + +:modsInstall +powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" +goto :eof + +:installAll +powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" +goto :eof + :end \ No newline at end of file