#!/bin/bash

DATAURL=http://alex.mamchenkov.net/wp-content/uploads/2007/07/data.zip
#DATAURL=http://www.guru.net.nz/blog/images/ttdx_data.zip (use if the above one 404's)

rm -r ttd_temp ; mkdir ttd_temp ; cd ttd_temp
wget -O data.zip $DATAURL || (
	echo '*** ERROR: Could not download requried file data.zip'
) && (
sudo apt-get install openttd
# Some data.zip files contain more than those required files.  Just get the ones openttd needs
sudo unzip -o -d /usr/share/games/openttd data.zip data/sample.cat data/trg1r.grf data/trgcr.grf data/trghr.grf data/trgir.grf data/trgtr.grf
mkdir ~/.openttd/scenario
# Bonus, download the BigNewZealand scenario
wget -O ~/.openttd/scenario/BigNewZealand.scn http://www.guru.net.nz/blog/images/ttdx/BigNewZealand.scn || ( echo '*** Could not download optional file BigNewZealand.scn' )
cd ..
rm -r ttd_temp
# Make a desktop entry for this
echo '[Desktop Entry]
Comment=
Comment[en_US]=
Encoding=UTF-8
Exec=/usr/games/openttd
GenericName=Open TTD
GenericName[en_US]=Open TTD
Icon=package_games_arcade
MimeType=
Name=Open TTD
Name[en_US]=Open TTD
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=' > ~/Desktop/Open\ TTD.desktop
)


