# 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.
