Page 1 of 1

Scripts to simplify exporting/importing resources

Posted: August 4th, 2013, 10:15 pm
by Norbert
I'm working on scripts that will simplify exporting/importing resources with PR.

I've finished the first version for GNU/Linux:

Code: Select all

# Copyright (C) 2013 Prince of Persia modding community
# Version 0.1 (2013-08-04) by Norbert

clear
echo "PR.sh v0.1 (2013-08-04)"

# PR
echo "Enter the path to the PR executable and XML:"
read -e -i "`pwd`" PR
if [ ! -f $PR/pr ]; then
	echo "PR not found. Did you run \"make\" in the src/ directory?"
	exit 1
fi

# POP
echo "Where is Prince of Persia (the .DAT files):"
read -e -i "`pwd`" POP

# MODE AND RES
read -e -n 1 -p "Do you want to [E]xport or [I]mport? " MODE
if [ "$MODE" == "e" ] || [ "$MODE" == "E" ]
then
	echo "Directory to export to:"
	read -e -i "`pwd`/resources" RES
	$PR/pr -f --resource=$PR/resources.xml --export=$RES $POP/*.DAT
elif [ "$MODE" == "i" ] || [ "$MODE" == "I" ]
then
	echo "Directory to import from:"
	read -e -i "`pwd`/resources" RES
	$PR/pr -f --resource=$PR/resources.xml --import=$RES $POP/*.DAT
else
	echo "Unknown input."
	exit 1
fi

echo Done.
I will create a similar script for Windows and I'll post it in this thread when it's done.

Re: Scripts to simplify exporting/importing resources

Posted: August 5th, 2013, 2:38 am
by Jakim
What about PR with GUI based on sending right commands?

Re: Scripts to simplify exporting/importing resources

Posted: August 5th, 2013, 11:00 am
by Norbert
Jakim wrote:What about PR with GUI based on sending right commands?
For Windows users there is a wrapper available, called PRM. However, it's from 2003.
I haven't tested it myself. Maybe it works, maybe even with PR 1.3. If it doesn't, the source is available, so it could be improved.

Re: Scripts to simplify exporting/importing resources

Posted: August 5th, 2013, 2:33 pm
by Norbert
Norbert wrote:I will create a similar script for Windows and I'll post it in this thread when it's done.
Here it is:

Code: Select all

@echo off
:: Copyright (C) 2013 Prince of Persia modding community
:: Version 0.1 (2013-08-05) by Norbert

cls
echo PR.bat v0.1 (2013-08-05)

:: PR
echo Enter the path to the PR executable and XML:
set /p PR=%~dp0
set PRFULL=%~dp0%PR%\pr.exe
echo %PRFULL%
if not exist %PRFULL% (
	echo PR not found.
	exit /b 1
)

:: POP
echo Where is Prince of Persia (the .DAT files):
set /p POP=%~dp0
set POPFULL=%~dp0%POP%

:: MODE
set /p MODE=Do you want to [E]xport or [I]mport? 
if "%MODE%"=="e" GOTO EXPORT
if "%MODE%"=="E" GOTO EXPORT
if "%MODE%"=="i" GOTO IMPORT
if "%MODE%"=="I" GOTO IMPORT
echo Unknown input.
exit /B 1

:EXPORT
	echo Directory to export to:
	set /p RES=%~dp0resources
	set RESFULL=%~dp0resources%RES%
	%~dp0%PR%\pr.exe -f --resource=%~dp0%PR%\resources.xml --export=%RESFULL% %POPFULL%\*.DAT
	GOTO END

:IMPORT
	echo Directory to import from:
	set /p RES=%~dp0resources
	set RESFULL=%~dp0resources%RES%
	%~dp0%PR%\pr.exe -f --resource=%~dp0%PR%\resources.xml --import=%RESFULL% %POPFULL%\*.DAT
	GOTO END

:END
	echo Done.
Improvements are welcome, of course.