forked from goodidea82/SAxVCxLC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install.bat
181 lines (159 loc) · 7.96 KB
/
Install.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@echo off
echo(
echo SAxVCxLC 0.8.5-a7 Installation
echo(
echo http://gtaforums.com/topic/813938-saxvcxlc-vc-and-lc-in-san-andreas/
echo https://github.com/goodidea82/SAxVCxLC
echo(
REM %~dp0 refers to the full path to the batch file's directory (static)
REM When running as administrator, the directory gets lost and we have to change back to the SAxVCxLC directory.
set prevDir=%CD%
cd %~dp0
REM Some space is needed in the SAxVCxLC_source directory to build .img archives (see buildIMGarchives.bat) and to download and extract mp3 files (see Music.bat)
call :checkSpace "%CD%" 1500
echo Use a clean game ^(GTA San Andreas^) with the patch GTA SA v1.0 HOODLUM with
echo 14.383.616 bytes and no other modifications. You can add modifications later.
echo(
echo Enter the full path to the GTA SA root folder WITHOUT a backslash at the end.
if "%prevDir%\"=="%~dp0" (
echo Instead of typing you can drag ^& drop^ the folder here from windows explorer,
echo then click on this command window again.
) else (
echo If drag ^& drop^ of the folder does not work, you can copy-and-paste the path using right-click on this window.
)
:SArootLabel
SET /P GTASAroot=GTASAroot=
REM Remove quotes from the string in GTASAroot, because quotes will be added later.
set GTASAroot=%GTASAroot:"=%
if not exist "%GTASAroot%\GTA_SA.exe" (
echo(
echo "%GTASAroot%\GTA_SA.exe" DOES NOT EXIST.
echo The path is probably wrong. Try again.
echo(
goto :SArootLabel
)
REM Check if we have write access to GTASAroot
set SAVCLCDir=pwd
set tmpDir="%GTASAroot%\testAccess"
mkdir %tmpDir%
if "%ERRORLEVEL%"=="1" (
ECHO --------------------------------------------
ECHO This user probably does not have permissions to write to "%GTASAroot%"
ECHO .
ECHO SOLUTION: Right-click on Install.bat and select "Run as Administrator". When you run as Administrator, then Drag'n'Drop may not work for the path so you have to enter the path manually or copy-and-paste it.
SET /P a=Press enter to quit and try again...
GOTO:EOF
)
rmdir /q %tmpDir%
REM Check space of the destination.
call :checkSpace "%GTASAroot%" 1500
REM Check if clean installation.
for %%F in ("%GTASAroot%\*.asi") do (
if not %%F=="cleo.asi" (
if not %%F=="modloader.asi" (
if not %%F=="cleo.asi" (
SET /P a=Detected some .asi mods. You must start with a clean GTA installation. Try again...
goto :SArootLabel
)
)
)
)
REM Generate InstallSettings.bat. It is used by copyOnlyNewerFiles.bat to update an installation during development.
echo REM This file was generated by Install.bat and is used by copyOnlyNewerFiles.bat. > InstallSettings.bat
echo REM You can edit or delete this file. >> InstallSettings.bat
echo SET GTASAroot="%GTASAroot%" >> InstallSettings.bat
REM echo The path is: %GTASAroot%
echo Added the path to InstallSettings.bat
echo ----------------------
REM --------------------------------------
echo Installation variants:
echo 1. Standard version with minor extras. Will download mp3 files ^(+600MB^).
echo 2. Raw/basic version without any extras
echo 3. MTA version ^(Not available yet^)
echo 4. Install additional mods ^(SAxVCxLC must have been installed already!^) ^(Not available yet^)
choice /C 1234 /M "Select an installation variant."
REM The choice is stored in the variable %ERRORLEVEL%. See: https://en.wikibooks.org/wiki/Windows_Batch_Scripting
SET Variant=%ERRORLEVEL%
echo SET Variant=%Variant% >> InstallSettings.bat
echo Added installation variant decision to InstallSettings.bat
echo ----------------------
REM --------------------------------------
:repeatML
choice /M "Use ModLoader"
SET useModLoader=%ERRORLEVEL%
echo SET useModLoader=%useModLoader% >> InstallSettings.bat
echo Added ModLoader decision to InstallSettings.bat
if "%ERRORLEVEL%"=="1" (
if not exist "%GTASAroot%\modloader.asi" (
toolsForInstallation\7z\7z.exe x toolsForInstallation\modloader.7z -o"%GTASAroot%" -r
if not exist "%GTASAroot%\modloader.asi" (
echo(
echo "%GTASAroot%\modloader.asi" DOES NOT EXIST. The following command has failed:
echo toolsForInstallation\7z\7z.exe x toolsForInstallation\modloader.7z -o"%GTASAroot%" -r
echo(
goto :repeatML
)
)
)
REM --------------------------------------
REM S= Use this option to copy directories, subdirectories, and the files contained within them, in addition to the files in the root of source. Empty folders will not be recreated.
REM I= Use this option to show a list of the files and folders to copied... but no copying is actually done. The /l option is useful if you're building a complicated xcopy command with several options and you'd like to see how it would function hypothetically.
REM Y= Use this option to stop the xcopy command from prompting you about overwriting files from source that already exist in destination.
REM D= Use the xcopy command with /d option and a specific date, in MM-DD-YYYY format, to copy files changed on or after that date. You can also use this option without specifying a specific date to copy only those files in source that are newer than the same files that already exist in destination. This is helpful when using the xcopy command to perform regular file backups.
REM r= Use this option to overwrite read-only files in destination. If you don't use this option when you want to overwrite a read-only file in destination, you'll be prompted with an "Access denied" message and the xcopy command will stop running.
REM https://www.lifewire.com/xcopy-command-2618103
REM WARNING: Do not use empty options in xcpyOpt, because it will result in an empty string and the parameters will not be passed correctly.
set xcpyOpt=/Y
:skipDOpt
REM --------------------------------------
REM Start Installation
if "%Variant%"=="1" (call toolsForInstallation\Standard.bat %xcpyOpt% %useModLoader% "%GTASAroot%")
if "%Variant%"=="2" (call toolsForInstallation\Base.bat %xcpyOpt% %useModLoader% "%GTASAroot%")
if "%Variant%"=="3" (call toolsForInstallation\MTA.bat %xcpyOpt% %useModLoader% "%GTASAroot%")
if "%Variant%"=="4" (
call toolsForInstallation\otherMods.bat %xcpyOpt% %useModLoader% "%GTASAroot%"
exit
)
REM -------------------------------------
echo --------------------------
REM Perform changes to models\gta3.img. You can see which changes are made in the script file gta3_img_changes.txt
REM which is located in SAxVCxLC_source\base\models. The file should have been copied to GTASAroot by the BAT scripts in toolsForInstallation.
echo update models\gta3.img
if not exist "%GTASAroot%\models\gta3_img_changes.txt" (
echo ERROR: Did not find the file "%GTASAroot%\models\gta3_img_changes.txt". It should have been already copied by the installation script from the directory SAxVCxLC_source\base\models.
SET /P a=Press enter if you want to continue...
)
set toolsForInstDir=%CD%\toolsForInstallation
set thisDir=%CD%
cd "%GTASAroot%\models"
"%toolsForInstDir%\fastman92ImgConsole32.exe" -script gta3_img_changes.txt
cd "%thisDir%"
:finish
REM -------------------------------
echo --------------------------
echo(
SET /P a=Finished installation of SAxVCxLC. Press enter to quit...
EXIT
REM ====================================
REM See: http://stackoverflow.com/questions/18239350/batch-script-to-test-free-space-of-drive
REM See: http://stackoverflow.com/questions/293780/free-space-in-a-cmd-shell
:checkSpace
set drive=%~d1
set minsize=%2
FOR /F "usebackq tokens=3" %%s IN (`DIR %drive% /-C /-O /W`) DO (
SET FREE_SPACE=%%s
)
REM ECHO FREE_SPACE is %FREE_SPACE%
if %FREE_SPACE% LEQ %minsize%000000 (
echo There is probably not enough disc space on %drive%. At least %minsize% MB should be available.
SET /P a=Press enter if you want to continue...
echo(
)
exit /b
REM --------------------------------------
REM Removes spaces at the end and beginning of strings.
:Trim
SetLocal EnableDelayedExpansion
set Params=%*
for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b