diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b4bcea8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ruinship_tournament_mods/ \ No newline at end of file diff --git a/README.md b/README.md index f2a7959..f25dea4 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # Установщик турнира RuinShip для RimWorld + +Данный репозиторий никак не относится к администрации турнира и является по большей части независимым, фанатским проектом \ No newline at end of file diff --git a/setup.bat b/setup.bat new file mode 100644 index 0000000..a7ef2e7 --- /dev/null +++ b/setup.bat @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy Bypass -File "%~dp0setup.ps1" \ No newline at end of file diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..635feb9 --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,33 @@ +$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 diff --git a/шаблон.ps1 b/шаблон.ps1 new file mode 100644 index 0000000..c5cf0d8 --- /dev/null +++ b/шаблон.ps1 @@ -0,0 +1,57 @@ +# Указываем ссылки и пути +$repoUrl = "https://github.com/HypoxiE/rimworld-add-my-music-mod/archive/refs/heads/main.zip" +$zipPath = "$env:TEMP\custom_music.zip" +$extractPath = "$env:TEMP\custom_music_temp" + +# Путь к папке Mods +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$steamappsPath = Resolve-Path (Join-Path $scriptDir "..\..\..\..") +if (-not($steamappsPath -like "*steamapps")){ + Write-Host "[ERROR] The download is not possible because the mod is not located in the steamapps\workshop\content\294100\3523549667 folder" -ForegroundColor Red + Write-Host "[INFO] You can download the mod manually from the page https://github.com/HypoxiE/rimworld-add-my-music-mod if you are using an unlicensed version of the game" + Pause + exit +} +$rimworldMods = Join-Path $steamappsPath "common\RimWorld\Mods" +if (-not(Test-Path $rimworldMods)) { + Write-Host "[ERROR] The download is not possible because the game is not detected on the steamapps\common\RimWorld path" -ForegroundColor Red + Write-Host "[INFO] You can download the mod manually from the page https://github.com/HypoxiE/rimworld-add-my-music-mod if you are using an unlicensed version of the game" + Pause + exit +} +$instalationPath = Join-Path $rimworldMods "add_my_music_mod" +Write-Host "[DEBUG] Detected Steamapps: $steamappsPath" +Write-Host "[DEBUG] RimWorld Mods folder: $rimworldMods" + +# Скачиваем и распаковываем архив +Write-Host "[INFO] Downloading mod from GitHub..." +Invoke-WebRequest -Uri $repoUrl -OutFile $zipPath +Write-Host "[INFO] Extracting..." +Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force + +# Удаляем старую папку мода, если есть +if (Test-Path $instalationPath) { + Write-Host "[INFO] Removing old mod files..." + Remove-Item -Recurse -Force $instalationPath +} + +# Переносим файлы в Mods +Write-Host "[INFO] Installing mod..." +$sourceFolder = Get-ChildItem $extractPath | Select-Object -First 1 +Move-Item -Path $sourceFolder.FullName -Destination $instalationPath + +# Создаём нужные папки +New-Item -ItemType Directory -Path (Join-Path $instalationPath "Defs\SongDefs") -Force | Out-Null +New-Item -ItemType Directory -Path (Join-Path $instalationPath "Sounds\Gameplay") -Force | Out-Null + +# Удаляем временные файлы +Write-Host "[INFO] Cleaning up..." +Remove-Item $zipPath +Remove-Item $extractPath -Recurse -Force + +Write-Host "[INFO] Done! Mod installed to $instalationPath" +Write-Host "The installation is complete and the window can be closed. If you want to copy the path to the mod folder, press Enter" -ForegroundColor Green +Pause +Set-Clipboard -Value "$instalationPath" +Write-Host "[INFO] The path is copied" +Pause \ No newline at end of file