#! /bin/sh

#####################################################
# 
# Layout installation for MahJongg Solitaire 3D
# by Reto Schoelly (reto.schoelly@web.de)
# 
# Project homepage: www.reto-schoelly.de/mahjongg3d
# 
#####################################################

clear

echo " MahJongg Solitaire 3D tileset installer"
echo "----------------------------------------"
echo
echo "Homepage: www.reto-schoelly.de/mahjongg3d"
echo
GAMEBASEPATH=`mahjongg3d --data-prefix`
echo
echo "----------------------------------------"
echo

if test -z $GAMEBASEPATH ; then
echo "The game binary cannot be found!"
echo "No panic, you probably did not install the game to a path specified in PATH"
echo
read -p "Please specify the directory where the game data is: " GAMEBASEPATH
fi

if test -z $GAMEBASEPATH ; then
echo "No path entered!"
exit 1
fi

echo
echo "----------------------------------------"
echo

if [ -d $GAMEBASEPATH ] ; then
echo "Game data path: " $GAMEBASEPATH
else
echo "Path " $GAMEBASEPATH "does not exist, please try again."
exit 1
fi


clear

echo " MahJongg Solitaire 3D layout installer"
echo "----------------------------------------"
echo
echo "Homepage: www.reto-schoelly.de/mahjongg3d"
echo
echo

if [ -w $GAMEBASEPATH ] ; then
echo "Installing to" $GAMEBASEPATH
else
echo "You do not have write permissions to " $GAMEBASEPATH
echo
echo "To install the file to " $GAMEBASEPATH ", enter root mode with \"su\" and try again..."
exit 1
fi

read -p "Please enter the path to the tileset file to be installed: " FILEPATH

if test -z $FILEPATH ; then
echo "File" $FILEPATH "not found"
exit 1
fi
echo
echo

read -p "Please enter the path to the tileset directory to be installed: " FILEPATHDIR

if test -z $FILEPATHDIR ; then
echo "File" $FILEPATHDIR "not found"
exit 1
fi

if [ -d $FILEPATHDIR ] ; then
echo "Installing" $FILEPATHDIR" to " $GAMEBASEPATH
cp -r $FILEPATHDIR $GAMEBASEPATH
else
echo "Directory" $FILEPATHDIR "not found"
fi

if [ -e $FILEPATH ] ; then
echo "Installing" $FILEPATH" to " $GAMEBASEPATH
cp -r $FILEPATH $GAMEBASEPATH
else
echo "File" $FILEPATH "not found"
fi


