@echo off
cd _single
REM Inject texture files to assets.
REM You can specify the asset path with _export_as_tga.bat or _set_asset_path.bat

REM Define the default file path here
set DEFAULT_ASSET_PATH=asset\T_Veh_Van_01_EscapeVan.uasset
set DEFAULT_FILE_PATH=_tga\T_Veh_Van_01_EscapeVan.tga

REM If a file is dragged and dropped, use that file path. Otherwise, use the default file path.
if "%~1"=="" (
    set FILE_PATH=%DEFAULT_FILE_PATH%
) else (
    set FILE_PATH=%~1%
)

@pushd %~dp0
..\data\python\python.exe -E ..\data\src\main.py %DEFAULT_ASSET_PATH% "%FILE_PATH%" --save_folder=PAYDAY3\Content\Vehicle\Civilian\Van\Veh_Van_01\Textures --skip_non_texture --version=4.27 --image_filter=cubic
@popd

rem Create a temporary file list with full paths
dir /s /b /a-d PAYDAY3\* > temp_filelist.txt

rem Initialize filelist.txt
echo. > filelist.txt

rem Define the suffix to append
set suffix="../../../PAYDAY3/Content/Vehicle/Civilian/Van/Veh_Van_01/Textures/"

rem Read each line from temp_filelist.txt and format it
for /f "delims=" %%i in (temp_filelist.txt) do (
    echo "%%i" %suffix% >> filelist.txt
)

rem Run UnrealPak with the updated filelist.txt
..\data\Engine\Tool\unrealpak\UnrealPak.exe "..\..\..\..\_single\yourmodname_van.pak" -create=..\..\..\..\_single\filelist.txt -compress

rem Cleanup temporary file
del temp_filelist.txt
del filelist.txt

move yourmodname_van.pak ..\

if errorlevel 1 (
    echo Failed to move files from %SOURCE_DIR% to %DEST_DIR%.
    pause
    exit /b
)

echo FINISH!
pause