#!/bin/sh

mypath=`echo $0|sed 's/[^/]*$//'|sed 's/\/$//'`
if [ "$mypath" = "." ]; then
  mypath=`pwd`
fi
cd $mypath


RESULT=`xmessage -nearmouse -print -buttons "320x200","640x480","800x600","1024x768","manual" "Select resolution"`

if [ $RESULT = "manual" ]; then
beaver ~/.prboom/prboom.cfg
/usr/local/freedoom/prboom
exit
fi


if [ $RESULT = "320x200" ]; then
cat ~/.prboom/prboom.cfg.tpl | sed "s/XXX/320/" | sed "s/YYY/200/" >>~/.prboom/prboom.cfg.tmp
fi
if [ $RESULT = "640x480" ]; then
cat ~/.prboom/prboom.cfg.tpl | sed "s/XXX/640/" | sed "s/YYY/480/" >>~/.prboom/prboom.cfg.tmp
fi
if [ $RESULT = "800x600" ]; then
cat ~/.prboom/prboom.cfg.tpl | sed "s/XXX/800/" | sed "s/YYY/600/" >>~/.prboom/prboom.cfg.tmp
fi
if [ $RESULT = "1024x768" ]; then
cat ~/.prboom/prboom.cfg.tpl | sed "s/XXX/1024/" | sed "s/YYY/768/" >>~/.prboom/prboom.cfg.tmp
fi

RESULT=`xmessage -nearmouse -print -buttons "fullscreen","window" "choose..."`

if [ $RESULT = "fullscreen" ]; then
cat ~/.prboom/prboom.cfg.tmp | sed "s/FSMODE/1/" >>~/.prboom/prboom.cfg
fi

if [ $RESULT = "window" ]; then
cat ~/.prboom/prboom.cfg.tmp | sed "s/FSMODE/0/" >>~/.prboom/prboom.cfg
fi
/usr/local/freedoom/prboom
