#!/bin/sh
BASENAME=`basename $0`
export SDL_VIDEO_X11_WMCLASS=${BASENAME}

if [ ! -e ~/.duke3d/duke3d.cfg ]; then
	# Show information before first run
	cat <<EOF > /tmp/notice.txt
Duke Nukem 3D

Controls are modified for tablets that don't have a keyboard
but you can of course change them in game. Controls are:

Stylus: Look around
Direction pad: Move
Direction pad select: Fire
Zoom out: Previous Weapon
Zoom in: Next Weapon
Fullscreen: Jump

Menu key works as a modifier key:

Menu + Direction pad select: Use Inventory Item
Menu + Zoom out: Previous Item
Menu + Zoom in: Next item
Menu + Fullscreen: Crouch
Menu + Esc: Open
EOF
	# To prevent the maemo-invoker not found error
	cd /usr/bin
	./maemo-confirm-text "Notice" /tmp/notice.txt
	rm -f /tmp/notice.txt
        /bin/mkdir -p ~/.duke3d
        /bin/cp /usr/share/duke3dsw/duke3d.cfg  ~/.duke3d
fi

PATH=""
for i in 1 2
do
        if [ -e /media/mmc$i/share/duke3dsw/duke3d.grp ]; then 
                PATH="/media/mmc$i/share/duke3dsw"
        fi
done
if [ "$PATH" != "" ]; then
        if [ ! -e "$PATH/defs.con" ]; then
                /bin/cp /usr/share/duke3dsw/*.con $PATH
        fi
        cd $PATH
        /usr/bin/duke3dswbin
fi
