-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.bat
More file actions
442 lines (406 loc) · 13 KB
/
Copy pathbuild.bat
File metadata and controls
442 lines (406 loc) · 13 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
@echo off
::stolen from https://gist.github.com/maciakl/f30629d1a606030e55855842447472c5
if "%1" == "elevated" goto start
powershell -command "Start-Process %~nx0 elevated -Verb runas"
goto :EOF
:start
cls
:: Configuration
SET "ROOT_BUILD_DIR=%~dp0to sdcard"
SET "BUILD_DIR=%~dp0to sdcard\wiiu\apps\balatro"
SET "GLSLDIR=%~dp0to sdcard\wiiu\apps\balatro"
SET "OUTPUT_NAME=Balatro U"
:MENU
cls
:: Build mode selection
echo ================================
echo Balatro Wii U Builder
echo ================================
echo 1. Install dependencies
echo 2. Extract files
echo 3. Build
echo 4. Clean
echo 0. Exit
echo ================================
set /p BUILD_MODE="Select build mode (0-4): "
if "%BUILD_MODE%"=="1" goto :INSTALL_DEPS
if "%BUILD_MODE%"=="2" goto :Extract
if "%BUILD_MODE%"=="3" goto :Build_menu
if "%BUILD_MODE%"=="4" (
cls
echo ================================
echo Cleaning...
echo ================================
rmdir /s /q "%ROOT_BUILD_DIR%"
rmdir /s /q "%~dp0temp"
echo Build directory cleaned.
rmdir /s /q temp
echo Temporary files cleaned.
echo Cleaning up old Docker images...
docker rmi lovepotion-wiiu 2>nul || echo No old image to remove
docker builder prune -f -a 2>nul || echo No old build cache to prune
pause
goto :MENU
)
if "%BUILD_MODE%"=="0" exit
else (
echo Invalid selection. Please try again.
pause
goto :MENU
)
:Build_menu
cls
:: Build mode selection
echo ================================
echo Balatro Wii U Builder
echo ================================
echo 1. Build using Docker
echo 2. Build using a precompiled binary
echo 0. Back
echo ================================
set /p BUILD="Select build mode (0-2): "
if "%BUILD%"=="1" goto :Build_select
if "%BUILD%"=="2" goto :Build_precompiled
if "%BUILD%"=="0" goto :MENU
else (
echo Invalid selection. Please try again.
pause
goto :Build_menu
)
:Build_select
cls
echo ================================
echo Balatro Wii U Builder
echo ================================
echo 1. Build Release
echo 2. Build Debug
echo 0. Back
echo ================================
set /p BUILD="Select build mode (0-2): "
if "%BUILD%"=="1" SET "Type=Release" & goto :Build
if "%BUILD%"=="2" SET "Type=Debug" & goto :Build
if "%BUILD%"=="0" goto :Build_menu
else (
echo Invalid selection. Please try again.
pause
goto :Build_select
)
:INSTALL_DEPS
cls
echo ================================
echo Installing Dependencies...
echo ================================
:: Better admin check - try to create a file in Windows directory
echo Checking administrator privileges...
echo test > "%WINDIR%\admin_test.tmp" 2>nul
if not exist "%WINDIR%\admin_test.tmp" (
echo ERROR: This script must be run as Administrator to install dependencies.
echo Please:
echo 1. Right-click on build.bat
echo 2. Select "Run as administrator"
echo 3. Choose option 1 again
pause
goto :MENU
) else (
del "%WINDIR%\admin_test.tmp" 2>nul
echo Administrator privileges confirmed.
)
echo Installing required dependencies for Wii U development...
:: Install Git
echo Installing Git...
winget install -e --id Git.Git --silent --accept-package-agreements --accept-source-agreements 2>nul
if errorlevel 1 (
echo WARNING: Git installation failed or already installed
)
:: Install 7-Zip for archive extraction
echo Installing 7-Zip...
winget install 7z --silent --accept-package-agreements --accept-source-agreements 2>nul
set PATH=%PATH%;C:\Program Files\7-Zip\
if errorlevel 1 (
echo WARNING: 7-Zip installation failed or already installed
)
:: Install WSL
echo Installing Windows Subsystem for Linux (WSL)...
winget install -e --id Canonical.Ubuntu.2204 --silent --accept-package-agreements --accept-source-agreements 2>nul
if errorlevel 1 (
echo WARNING: WSL installation failed or already installed
)
:: Install Docker
echo Installing Docker...
winget install -e --id Docker.DockerDesktop --silent --accept-package-agreements --accept-source-agreements 2>nul
if errorlevel 1 (
echo WARNING: Docker installation failed or already installed
)
echo.
echo ================================
echo Dependency Installation Complete!
echo ================================
echo.
echo Components that should be installed:
echo - Git
echo - 7-Zip
echo - Ubuntu 22.04 WSL - you will need to set it up yourself
echo - Docker - you will need set it up yourself
pause
goto :MENU
:Extract
cls
setlocal enabledelayedexpansion
echo ================================
echo Extracting needed files from Balatro...
echo ================================
:: Check for local Balatro.exe first (priority)
if exist "%~dp0Balatro.exe" (
echo Found local Balatro.exe
set "BALATRO_PATH=%~dp0Balatro.exe"
echo Checking SHA256 hash of Balatro.exe...
certUtil -hashfile "%~dp0Balatro.exe" SHA256 > hash.txt
set "BALATRO_HASH="
set "HASH_FOUND="
for /f "skip=1 delims=" %%H in (hash.txt) do (
if not defined HASH_FOUND if not "%%H"=="" (
set "BALATRO_HASH=%%H"
set "HASH_FOUND=1"
)
)
set "BALATRO_HASH=!BALATRO_HASH: =!"
del hash.txt
if "!BALATRO_HASH!"=="" (
echo ERROR: Failed to read SHA256 hash! Aborting.
pause
goto :MENU
)
set "BALATRO_HASH_EXPECTED=0d75fe164accf3312734d4b37ac98788dd15f0b8e4f9bb8b7f90c4e59de93f47"
echo SHA256: !BALATRO_HASH!
if /I not "!BALATRO_HASH!"=="!BALATRO_HASH_EXPECTED!" (
echo WARNING: The hash of Balatro.exe does not match the expected version!
echo Continue? (press any key to continue or Ctrl+C to cancel)
pause
)
goto :EXTRACT_FILES
)
:: Search for Steam installation
echo Searching for Balatro in Steam...
:: Try to find Steam through registry
echo Checking Steam registry...
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Valve\Steam" /v "InstallPath" 2^>nul') do (
if exist "%%b\steamapps\common\Balatro\Balatro.exe" (
echo Found Balatro via registry: %%b\steamapps\common\Balatro\
set "BALATRO_PATH=%%b\steamapps\common\Balatro\Balatro.exe"
echo Checking SHA256 hash of Balatro.exe...
certUtil -hashfile "%%b\steamapps\common\Balatro\Balatro.exe" SHA256 > hash.txt
set "BALATRO_HASH="
for /f "skip=1 delims=" %%H in (hash.txt) do (
if not "%%H"=="" (
set "BALATRO_HASH=%%H"
)
)
set "BALATRO_HASH="
set "HASH_FOUND="
for /f "skip=1 delims=" %%H in (hash.txt) do (
if not defined HASH_FOUND if not "%%H"=="" (
set "BALATRO_HASH=%%H"
set "HASH_FOUND=1"
)
)
set "BALATRO_HASH=!BALATRO_HASH: =!"
del hash.txt
if "!BALATRO_HASH!"=="" (
echo ERROR: Failed to read SHA256 hash! Aborting.
pause
goto :MENU
)
set "BALATRO_HASH_EXPECTED=0d75fe164accf3312734d4b37ac98788dd15f0b8e4f9bb8b7f90c4e59de93f47"
echo SHA256: !BALATRO_HASH!
if /I not "!BALATRO_HASH!"=="!BALATRO_HASH_EXPECTED!" (
echo WARNING: The hash of Balatro.exe does not match the expected version!
echo Continue? (press any key to continue or Ctrl+C to cancel)
pause
)
goto :EXTRACT_FILES
)
:: Alternative registry path
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam" /v "InstallPath" 2^>nul') do (
if exist "%%b\steamapps\common\Balatro\Balatro.exe" (
echo Found Balatro via registry: %%b\steamapps\common\Balatro\
set "BALATRO_PATH=%%b\steamapps\common\Balatro\Balatro.exe"
echo Checking SHA256 hash of Balatro.exe...
certUtil -hashfile "%%b\steamapps\common\Balatro\Balatro.exe" SHA256 > hash.txt
set "BALATRO_HASH="
for /f "skip=1 delims=" %%H in (hash.txt) do (
if not "%%H"=="" (
set "BALATRO_HASH=%%H"
)
)
set "BALATRO_HASH="
set "HASH_FOUND="
for /f "skip=1 delims=" %%H in (hash.txt) do (
if not defined HASH_FOUND if not "%%H"=="" (
set "BALATRO_HASH=%%H"
set "HASH_FOUND=1"
)
)
set "BALATRO_HASH=!BALATRO_HASH: =!"
del hash.txt
if "!BALATRO_HASH!"=="" (
echo ERROR: Failed to read SHA256 hash! Aborting.
pause
goto :MENU
)
set "BALATRO_HASH_EXPECTED=0d75fe164accf3312734d4b37ac98788dd15f0b8e4f9bb8b7f90c4e59de93f47"
echo SHA256: !BALATRO_HASH!
if /I not "!BALATRO_HASH!"=="!BALATRO_HASH_EXPECTED!" (
echo WARNING: The hash of Balatro.exe does not match the expected version!
echo Continue? (press any key to continue or Ctrl+C to cancel)
pause
)
goto :EXTRACT_FILES
)
}
echo ERROR: Balatro.exe not found!
echo.
echo Please either:
echo 1. Copy Balatro.exe to this folder, OR
echo 2. Install Balatro through Steam
echo.
echo Searched locations:
echo - Current folder: %~dp0Balatro.exe
echo - Steam common folders
echo.
pause
goto :MENU
:EXTRACT_FILES
echo Using Balatro from: "%BALATRO_PATH%"
echo Debug: BALATRO_PATH="%BALATRO_PATH%"
if "%BALATRO_PATH%"=="" (
echo ERROR: BALATRO_PATH is not set!
pause
goto :MENU
)
if not exist "%~dp0game" (
echo Creating game directory...
mkdir "%~dp0game"
) else (
echo Removing existing game directory...
rmdir /s /q "%~dp0game" 2>nul
mkdir "%~dp0game"
)
"C:\Program Files\7-Zip\7z.exe" x "%BALATRO_PATH%" -o"%~dp0game" -y
if errorlevel 1 (
echo ERROR: Failed to extract Balatro.exe
echo Make sure the file is not corrupted and 7-Zip is installed.
pause
goto :MENU
)
echo.
echo ================================
echo Extraction completed successfully!
echo ================================
echo.
echo Game files extracted to: game\
echo.
pause
goto :MENU
:Build_precompiled
cls
echo ================================
echo Building with a precompiled binary...
echo ================================
rmdir /s /q "%ROOT_BUILD_DIR%"
rmdir /s /q "%~dp0temp"
echo Build directory cleaned.
mkdir "%~dp0temp"
cd /d "%~dp0temp"
wget https://github.com/xtomasnemec/Balatro-U-precompiled/raw/refs/heads/main/lovepotion.wuhb
cd /d "%~dp0"
echo Patching the game files...
xcopy "%~dp0game\*" "%~dp0temp\game\" /E /Y /I
xcopy "%~dp0patch\*" "%~dp0temp\game\" /E /Y /I
cd /d "%~dp0temp"
echo Fusing lovepotion.wuhb and game.love...
cmd /c "C:\Program Files\7zip\7z.exe" a -r game.zip ./game/*
move game.zip game.love
copy /b "%~dp0\lovepotion.wuhb"+game.love "%~dp0temp\balatro.wuhb"
cd /d "%~dp0"
:: Check existence and size of balatro.wuhb
set "WUHBSRC=%~dp0temp\balatro.wuhb"
if not exist "%WUHBSRC%" (
echo ERROR: balatro.wuhb not found in %WUHBSRC%.
pause
goto :MENU
)
for %%F in ("%WUHBSRC%") do set "WUHBSIZE=%%~zF"
echo Size of balatro.wuhb after build: %WUHBSIZE% bytes
:: Copy built file(s) to build dir
echo Copying built files to %BUILD_DIR%...
if not exist "%BUILD_DIR%" (
mkdir "%BUILD_DIR%"
)
if not exist "%GLSLDIR%" (
mkdir "%GLSLDIR%"
)
xcopy "%WUHBSRC%" "%BUILD_DIR%\" /E /Y /I
for %%F in ("%BUILD_DIR%\balatro.wuhb") do set "WUHBSIZE2=%%~zF"
echo Size of balatro.wuhb in %BUILD_DIR%: %WUHBSIZE2% bytes
cd "%GLSLDIR%"
curl -L -o glslcompiler.rpl https://github.com/Exzap/CafeGLSL/releases/download/v0.2.0/glslcompiler.rpl
cls
echo ================================
echo Build complete!
echo ================================
pause
goto :MENU
:Build
cls
echo ================================
echo Building...
echo ================================
rmdir /s /q "%ROOT_BUILD_DIR%"
rmdir /s /q "%~dp0temp"
echo Build directory cleaned.
echo Cloning Lovepotion repository...
mkdir "%~dp0temp"
cd /d "%~dp0temp"
git clone https://github.com/xtomasnemec/lovepotion.git --branch 3.1.0-development --single-branch
if errorlevel 1 (
echo ERROR: Failed to clone Lovepotion repository.
echo Make sure Git is installed and working.
pause
goto :MENU
)
cd /d "%~dp0"
echo Patching the game files...
xcopy "%~dp0game\*" "%~dp0temp\lovepotion\game\" /E /Y /I
xcopy "%~dp0patch\*" "%~dp0temp\lovepotion\game\" /E /Y /I
cd /d "%~dp0temp\lovepotion"
echo Building Lovepotion...
call build.bat %Type%
cd /d "%~dp0"
:: Check existence and size of balatro.wuhb
set "WUHBSRC=%~dp0temp\lovepotion\build\balatro.wuhb"
if not exist "%WUHBSRC%" (
echo ERROR: balatro.wuhb not found in %WUHBSRC%.
pause
goto :MENU
)
for %%F in ("%WUHBSRC%") do set "WUHBSIZE=%%~zF"
echo Size of balatro.wuhb after build: %WUHBSIZE% bytes
:: Copy built file(s) to build dir
echo Copying built files to %BUILD_DIR%...
if not exist "%BUILD_DIR%" (
mkdir "%BUILD_DIR%"
)
if not exist "%GLSLDIR%" (
mkdir "%GLSLDIR%"
)
xcopy "%WUHBSRC%" "%BUILD_DIR%\" /E /Y /I
for %%F in ("%BUILD_DIR%\balatro.wuhb") do set "WUHBSIZE2=%%~zF"
echo Size of balatro.wuhb in %BUILD_DIR%: %WUHBSIZE2% bytes
cd "%GLSLDIR%"
curl -L -o glslcompiler.rpl https://github.com/Exzap/CafeGLSL/releases/download/v0.2.0/glslcompiler.rpl
cls
echo ================================
echo Build complete!
echo ================================
pause
goto :MENU