diff --git a/Download Modpack.bat b/Download Modpack.bat index 09bb86e..665980e 100644 --- a/Download Modpack.bat +++ b/Download Modpack.bat @@ -4,6 +4,12 @@ set "mo2_install=%cd%" set "repository=%mo2_install%\Fika-Tarkov" +:: Specifying links to download for files +set "git_repository=https://files.moddinglounge.com/Rage/Fika-Tarkov.git" +set "git_file=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/PortableGit-2.47.1-64-bit.7z.exe" +set "SevenZ_file=https://www.7-zip.org/a/7zr.exe" +set "mo2_file=https://github.com/ModOrganizer2/modorganizer/releases/download/v2.5.2/Mod.Organizer-2.5.2.7z" + :: Set path to the portable Git executable set "portable_git=%mo2_install%\PortableGit\bin\git.exe" set "portable_7z=%mo2_install%\7zr.exe" @@ -22,7 +28,7 @@ if not exist "%mo2_install%\PortableGit\bin\git.exe" ( echo ---- echo Installing Portable Git... :: Download Git Portable - curl -L -o PortableGit-2.47.1-64-bit.7z.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/PortableGit-2.47.1-64-bit.7z.exe + curl -L -o PortableGit-2.47.1-64-bit.7z.exe %git_file% if %errorlevel% neq 0 ( echo ERROR: Failed to download Git Portable. Check your internet connection and try again. @@ -41,7 +47,7 @@ if not exist "%mo2_install%\7zr.exe" ( echo ---- echo Installing 7zip Portable... :: Download 7zip Portable - curl -L -o 7zr.exe https://www.7-zip.org/a/7zr.exe + curl -L -o 7zr.exe %SevenZ_file% ) :: Determining if an installation exists already @@ -64,10 +70,10 @@ IF EXIST "%mo2_install%\ModOrganizer.exe" ( timeout 10 :: Clone or update the Git repository - if not exist "Fika-Tarkov\.git" ( + if not exist "%repository%\.git" ( echo ---- echo Cloning repository... - "%portable_git%" clone https://files.moddinglounge.com/Rage/Fika-Tarkov.git + "%portable_git%" clone %git_repository% ) else ( echo ---- echo Repository already exists. Pulling latest changes... @@ -84,18 +90,11 @@ IF EXIST "%mo2_install%\ModOrganizer.exe" ( echo Synchronizing profiles folder... robocopy "%repository%/profiles" "%mo2_install%/profiles" /MIR - echo ---- - echo Synchronizing stylesheets folder... - robocopy "%repository%/stylesheets" "%mo2_install%/stylesheets" /E - - echo ---- - echo Synchronizing plugins folder... - robocopy "%repository%/plugins" "%mo2_install%/plugins" /E - pause exit /B 0 :InstallModpack + echo. echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! echo WARNING! The script will install the modpack in the folder this script is ran from! echo Be sure that your folder is empty before continuing with the installation! @@ -108,9 +107,19 @@ IF EXIST "%mo2_install%\ModOrganizer.exe" ( timeout 30 :: Requiring user input for game path + echo ---- + set /p "game_path=Please enter the path to your game installation: " + + if "%game_path%"=="" ( + echo. + echo No path entered. Exiting. + echo. + pause + exit /b 1 + ) :: Download MO2 - curl -L -o MO2.7z https://github.com/ModOrganizer2/modorganizer/releases/download/v2.5.2/Mod.Organizer-2.5.2.7z + curl -L -o MO2.7z %mo2_file% if %errorlevel% neq 0 ( echo ERROR: Failed to download the archive. Check your internet connection and try again. pause @@ -138,7 +147,7 @@ IF EXIST "%mo2_install%\ModOrganizer.exe" ( echo ---- echo Cloning repository... - "%portable_git%" clone https://files.moddinglounge.com/Rage/Fika-Tarkov.git + "%portable_git%" clone %git_repository% echo ---- echo Synchronizing mods folder... @@ -148,13 +157,52 @@ IF EXIST "%mo2_install%\ModOrganizer.exe" ( echo Synchronizing profiles folder... robocopy "%repository%/profiles" "%mo2_install%/profiles" /MIR + echo ---- + echo Synchronizing plugins folder... + robocopy "%repository%/plugins" "%mo2_install%/plugins" /E + echo ---- echo Synchronizing stylesheets folder... robocopy "%repository%/stylesheets" "%mo2_install%/stylesheets" /E + :: Escape backslashes in the game path + setlocal enabledelayedexpansion + + set "game_path=!game_path:\=/!" + set "escaped_path=" + + for /l %%i in (0,1,255) do ( + for /f "tokens=1,* delims=" %%a in ("!game_path:~%%i,1!") do ( + if "%%a"=="" goto path_done + if %%a==/ ( + set "escaped_path=!escaped_path!//" :: Double the backslash + ) else ( + set "escaped_path=!escaped_path!%%a" + ) + ) + ) + :path_done + + echo Original Path: %game_path% + echo Escaped Path: %escaped_path% + + :: Replace placeholders in ModOrganizer.ini echo ---- - echo Synchronizing plugins folder... - robocopy "%repository%/plugins" "%mo2_install%/plugins" /E + echo Updating ModOrganizer.ini... + set "ini_file=%repository%\ModOrganizer.ini" + set "temp_ini=%ini_file%.tmp" + + (for /f "usebackq delims=" %%A in ("%ini_file%") do ( + set "line=%%A" + set "line=!line:game_path=%escaped_path%!" + set "line=!line:replace_me=%game_path%!" + echo(!line! + )) > "%temp_ini%" + + move /y "%temp_ini%" "%mo2_install%\ModOrganizer.ini" + + echo ---- + echo ModOrganizer.ini updated successfully! echo ---- echo Installation complete. Launch ModOrganizer.exe and follow the remaining instructions.