#!/bin/sh

if [ $(id -u) !=  "0" ]; then
	echo "You need to be root to install this program (try \"sudo $0\")."
	echo "Vous devez etre root pour installer ce programme (essayez \"sudo $0\")."
	exit 1
fi

set -e

echo Installing main executable...
install -m755 -d				/usr/local/bin
install -m755 -s slimevolley			/usr/local/bin

echo Installing menu shortcuts...
install -m755 -d				/usr/share/applications
install -m644 debian/slimevolley.desktop	/usr/share/applications
install -m755 -d				/usr/local/share/pixmaps
install -m644 data/slimevolley_64.xpm	/usr/local/share/pixmaps
install -m644 data/slimevolley.xpm		/usr/local/share/pixmaps

echo Installing global data...
install -m755 -d				/usr/local/share/games/slimevolley
install -m644 data/icone.png			/usr/local/share/games/slimevolley

echo Installing slimes...
install -m755 -d				/usr/local/share/games/slimevolley/slimes
for path in data/slimes/*.png; do
	install -m644 $path			/usr/local/share/games/slimevolley/slimes
done

for theme in classic default mushrooms; do
	echo Installing $theme theme...
	install -m755 -d		/usr/local/share/games/slimevolley/themes/$theme
	for path in data/themes/$theme/*.png; do
		install -m644 $path	/usr/local/share/games/slimevolley/themes/$theme
	done
	for path in data/themes/$theme/*.wav; do
		install -m644 $path	/usr/local/share/games/slimevolley/themes/$theme
	done
	
	install -m644 data/themes/$theme/police.ttf /usr/local/share/games/slimevolley/themes/$theme
	install -m644 data/themes/$theme/theme.txt /usr/local/share/games/slimevolley/themes/$theme
done

echo Installing locale data...
for lang in fr it; do
	install -m755 -d		/usr/local/share/locale/$lang/LC_MESSAGES
	install -T -m644 po/$lang.gmo	/usr/local/share/locale/$lang/LC_MESSAGES/slimevolley.mo
done

echo Installing documentation...
install -m755 -d				/usr/local/share/man/man6
install -m644 docs/slimevolley.6		/usr/local/share/man/man6
install -m755 -d				/usr/local/share/man/fr/man6
install -T -m644 docs/slimevolley.6.fr		/usr/local/share/man/fr/man6/slimevolley.6

echo Installation of Slime Volley finished!
