From 5b29ebfb5d395be068ea5ee5901946a3bb1fb395 Mon Sep 17 00:00:00 2001 From: HypoxiE Date: Mon, 11 Aug 2025 23:46:48 +0700 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20=D1=81=D0=BA=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BC=D0=BE=D0=B4=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- README.md | 2 +- download_mods.ps1 | 36 ++++++++++++++++++++++++++++++++++++ setup.bat | 43 ++++++++++++++++++++++++++++++++++++++++++- setup.ps1 | 33 --------------------------------- 5 files changed, 81 insertions(+), 36 deletions(-) create mode 100644 download_mods.ps1 delete mode 100644 setup.ps1 diff --git a/.gitignore b/.gitignore index b4bcea8..5dc49c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -ruinship_tournament_mods/ \ No newline at end of file +ruinship_tournament_mods/ +шаблон.ps1 \ No newline at end of file diff --git a/README.md b/README.md index f25dea4..72fae73 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Установщик турнира RuinShip для RimWorld -Данный репозиторий никак не относится к администрации турнира и является по большей части независимым, фанатским проектом \ No newline at end of file +🔴**Данный репозиторий не относится к администрации турнира и является по большей части независимым, фанатским проектом** \ No newline at end of file diff --git a/download_mods.ps1 b/download_mods.ps1 new file mode 100644 index 0000000..2f690c3 --- /dev/null +++ b/download_mods.ps1 @@ -0,0 +1,36 @@ +$fileId = "13im-l6X2j-s5scZZlBvt2DCjYBbk2qI8" +$baseUrl = "https://drive.google.com/uc?export=download&id=$fileId" +$outputFile = "$env:TEMP\ruinship_mods.rar" + +$response = Invoke-WebRequest -Uri $baseUrl -SessionVariable session + +$form = $response.Forms | Where-Object { $_.Id -eq "download-form" } + +if ($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..." + Invoke-WebRequest -Uri $downloadUrl -WebSession $session -OutFile $outputFile + Write-Host "[INFO] The file was successfully downloaded with confirmation." +} +else { + Write-Host "[INFO] Downloading..." + Invoke-WebRequest -Uri $baseUrl -OutFile $outputFile + Write-Host "[INFO] The file was successfully downloaded directly." +} + +$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 + +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/setup.bat b/setup.bat index a7ef2e7..3db7eeb 100644 --- a/setup.bat +++ b/setup.bat @@ -1,2 +1,43 @@ @echo off -powershell -ExecutionPolicy Bypass -File "%~dp0setup.ps1" \ No newline at end of file +setlocal enabledelayedexpansion +chcp 65001 + +echo Укажите, что вам нужно сделать: +:ask +echo 1) Установить моды (они будут только установлены в качестве архива и их надо будет вручную распаковать) +echo 2) Поставить сценарий +echo 3) Поставить ModsConfig +echo 4) Установить всё +echo 5) Выйти + +set /p choice=Введите нужный пункт: + +if /i "%choice%"=="1" ( + powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" + echo Вам что-то ещё? + goto ask +) +if /i "%choice%"=="2" ( + + echo Пока функция не готова. Вам что-то ещё? + goto ask +) +if /i "%choice%"=="3" ( + + echo Пока функция не готова. Вам что-то ещё? + goto ask +) +if /i "%choice%"=="4" ( + powershell -ExecutionPolicy Bypass -File "%~dp0download_mods.ps1" + + echo Всё готово^^! Осталось только распаковать моды из архива в папке Mods и можно начинать играть^^! + goto end +) +if /i "%choice%"=="5" ( + echo Выхожу... + goto end +) +echo Варианта %choice% не существует +goto ask + +:end \ No newline at end of file diff --git a/setup.ps1 b/setup.ps1 deleted file mode 100644 index 635feb9..0000000 --- a/setup.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition -$rimworldModsPath = Resolve-Path (Join-Path $scriptDir "..") -$tmpHtml = "$env:TEMP\ruinship_tournament_gd.html" -$ModsFilesId = "13im-l6X2j-s5scZZlBvt2DCjYBbk2qI8" -$OutFile = "$env:TEMP\ruinship_tournament_mods.zip" - -Invoke-WebRequest -Uri "https://drive.google.com/uc?export=download&id=$ModsFilesId" -OutFile $tmpHtml -SessionVariable session - -$htmlContent = Get-Content $tmpHtml -Raw - -if ($htmlContent -match 'confirm=([0-9A-Za-z_]+)') { - $confirmToken = $matches[1] - if ($htmlContent -match 'name="uuid" value="([0-9a-f-]+)"') { - $uuid = $matches[1] - } else { - $uuid = "" - } - Write-Host "Found confirm-token: $confirmToken" - Write-Host "Found uuid: $uuid" - - $downloadUrl = "https://drive.google.com/uc?export=download&confirm=$confirmToken&id=$ModsFilesId" - if ($uuid) { - $downloadUrl += "&uuid=$uuid" - } - Write-Host "Downloading from URL: $downloadUrl" - Invoke-WebRequest -Uri $downloadUrl -WebSession $session -OutFile $OutFile -} else { - Write-Host "No confirm token found, downloading directly..." - Invoke-WebRequest -Uri "https://drive.google.com/uc?export=download&id=$ModsFilesId" -WebSession $session -OutFile $OutFile -} - -Write-Host "Extracting archive..." -Expand-Archive -Path $OutFile -DestinationPath $rimworldModsPath -Force