generated from DayZ-n-Chill/DayZ-Colorful-UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStart.bat
105 lines (90 loc) · 4.47 KB
/
Start.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
@echo off
SETLOCAL EnableExtensions DisableDelayedExpansion
:: Function to check if the P:\ drive is mounted
:CheckPDrive
set "PDriveMounted=false"
for /f %%d in ('wmic logicaldisk where "DeviceID='P:'" get DeviceID ^| find ":"') do set "PDriveMounted=true"
if not "%PDriveMounted%"=="true" (
echo.
powershell -Command "Write-Host 'P:\ Drive: Not Mounted' -ForegroundColor DarkRed;"
powershell -Command "Write-Host 'Exiting App' -ForegroundColor DarkYellow;"
exit /b 1
)
:: Reading the existing configuration and setting variables
for /f "tokens=1* delims== eol=#" %%i in (.\Utils\Shared\Globals.cfg) do (
set "%%i=%%j"
)
:: Show the DayZ n Chill Dev Logo.
SET "ASCIIARTPATH=.\Utils\Shared\Branding.txt"
SET "COLORS=Blue,Green,Cyan,DarkBlue,DarkGreen,DarkCyan,DarkRed,DarkMagenta,DarkYellow"
powershell -Command "$colors = '%COLORS%'.Split(','); $randomColor = Get-Random -InputObject $colors; $content = Get-Content -Path '%ASCIIARTPATH%'; $content | ForEach-Object {Write-Host $_ -ForegroundColor $randomColor}"
:: Begin DayZ Project Manager Setup
echo This setup file will help you configure your project with ease so you should only have to do this once.
echo Please follow along with the prompts and you will be ready to go in no time at all.
echo.
powershell -Command "Write-Host 'WARNING:' -ForegroundColor DarkYellow;"
powershell -Command "Write-Host 'If you have installed DayZ on a different drive than C:\, ' -ForegroundColor DarkCyan;"
powershell -Command "Write-Host 'please exit this application and and edit the globals.cfg file manually.' -ForegroundColor DarkCyan;"
echo.
pause
:: Detect the directory of this batch file
SET "DETECTEDDIR=%~dp0"
:: Ask the user if this directory should be the new PROJECTDIR
echo.
powershell -Command "Write-Host 'PROJECT DIRECTORY:' -ForegroundColor DarkMagenta -NoNewline; Write-Host ' %DETECTEDDIR%' -ForegroundColor DarkCyan;"
powershell -Command "Write-Host 'This should be the directory where you downloaded, or cloned the dayz-project-template from GitHub.' -ForegroundColor Gray;"
:: Define the message string
echo.
powershell -Command "$message = 'Please verify that this is your Project''s location listed above?'; Write-Host -ForegroundColor Yellow -NoNewline $message; Write-Host ' (Y/N)' -NoNewline;"
set /p USERCONFIRM=
if /i "%USERCONFIRM%" neq "Y" (
echo.
powershell -Command "Write-Host 'Please enter the path to your project directory manually: ' -ForegroundColor Yellow"
set /p NEWPROJECTDIR=
powershell -Command "Write-Host 'Setting project directory in Global.cfg ' -ForegroundColor Cyan"
) else (
SET "NEWPROJECTDIR=%DETECTEDDIR%"
echo.
powershell -Command "Write-Host 'Setting project directory in Global.cfg ' -ForegroundColor Cyan"
)
:: Remove trailing backslash from PROJECTDIR if it existsgranst
if "%NEWPROJECTDIR:~-1%"=="\" (
SET "NEWPROJECTDIR=%NEWPROJECTDIR:~0,-1%"
)
:: Create a temporary file for the updated configuration
SET "TEMPCFGFILE=%TEMP%\temp_globals.cfg"
if exist "%TEMPCFGFILE%" del "%TEMPCFGFILE%"
:: Read and write config file lines, modifying only PROJECTDIR
(for /f "tokens=1* delims== eol=#" %%i in (.\Utils\Shared\Globals.cfg) do (
set "key=%%i"
set "value=%%j"
setlocal EnableDelayedExpansion
if "!key!"=="PROJECTDIR" (
echo PROJECTDIR=!NEWPROJECTDIR!>> "!TEMPCFGFILE!"
) else if "!key!"=="YOURMODDIR" (
echo YOURMODDIR=!NEWPROJECTDIR!\Colorful-UI>> "!TEMPCFGFILE!"
) else (
echo !key!=!value!>> "!TEMPCFGFILE!"
)
endlocal
)) >nul
:: Replace the original Globals.cfg with the updated one
move /y "%TEMPCFGFILE%" "./Utils/Shared/Globals.cfg" >nul
powershell -Command "Write-Host 'PROJECTDIR updated successfully.' -ForegroundColor Green"
:: Reload the configuration from Globals.cfg
for /f "tokens=1* delims== eol=#" %%i in (.\Utils\Shared\Globals.cfg) do (
set "%%i=%%j"
)
:: Set Simlinks
echo.
powershell -Command "Write-Host 'Setting up symlinks.' -ForegroundColor Magenta"
call .\Utils\Batch\Setup\WorkshopSymlink.Bat
echo.
powershell -Command "Write-Host 'Setup is Complete.' -ForegroundColor Green"
echo.
powershell -Command "Write-Host 'Thank you for using Colorful-UI' -ForegroundColor Magenta"
powershell -Command "Write-Host 'This Setup uses a modified version of the DayZ Project Template.' -ForegroundColor DarkGray"
powershell -Command "Write-Host 'Get it Here!' -ForegroundColor DarkGray"
powershell -Command "Write-Host 'https://github.com/DayZ-n-Chill/DayZ-Project-Template' -ForegroundColor DarkGray"
timeout /t 30 /nobreak
exit