1#!/bin/sh 2KOULESDIR=/usr/local/bin 3XKOULESDIR=/usr/bin/X11 4if [ $TERM != console ]; then 5if [ $TERM != linux ]; then 6if [ $DISPLAY != "" ]; then 7 exec $KOULESDIR/koules.tcl 8fi 9fi 10fi 11single() 12{ 13 dialog --title "Koules options" --menu "Select resolution" 9 40 2 "320x200" "low resolution" "640x480" "High resolution" 2> /tmp/dialogout.$$ 14 resolution=`cat /tmp/dialogout.$$` 15 if [ $resolution = "320x200" ]; then 16 resolution="-s" 17 else 18 resolution="-l" 19 fi 20 dialog --title "Koules options" --checklist "Driver options" 9 40 2 "Mouse support" "" on "Sound support" "" on 2> /tmp/dialogout.$$ 21 drivers=`cat /tmp/dialogout.$$` 22 mouse="-M" 23 sound="-d" 24 for opt in $drivers; do 25 case $opt in 26 \"Mouse) mouse=" ";; 27 \"Sound) sound=" ";; 28 esac 29 done 30 opt="$resolution $mouse $sound" 31 dialog --title "Koules options" --yesno "Save configuration" 5 40 32 case $? in 33 0) echo "$KOULESDIR/koules.svga $opt" >~/.koules.single 34 esac 35} 36server() 37{ 38 dialog --title "Server options" --menu "Select resolution" 10 50 3 "Normal" "For 320x250 and 640x480 clients" "Wide" "For 320x200 and 640x400 clients" "Large" "For extra large 800x620 clients" 2> /tmp/dialogout.$$ 39 resolution=`cat /tmp/dialogout.$$` 40 case $resolution in 41 "Normal") resolution="" ;; 42 "Wide") resolution="-W" ;; 43 "Large") resolution="-E" ;; 44 esac 45 dialog --title "Server options" --menu "Difficulty" 12 50 5 "0" "Nightmare" "1" "hard" "2" "medium" "3" "easy" "4" "very easy" 2> /tmp/dialogout.$$ 46 diff=`cat /tmp/dialogout.$$` 47 dialog --title "Server options" --checklist "Game options" 8 40 1 "Deathmatch" "" off 2> /tmp/dialogout.$$ 48 drivers=`cat /tmp/dialogout.$$` 49 deathmatch="" 50 for opt in $drivers; do 51 case $opt in 52 *Deathmatch*) deathmatch="-K";; 53 esac 54 done 55 dialog --title "Server options" --inputbox "Starting level" 9 40 "1" 2>/tmp/dialogout.$$ 56 level=`cat /tmp/dialogout.$$` 57 dialog --title "Server options" --inputbox "Inet port" 9 40 "12345" 2>/tmp/dialogout.$$ 58 port=`cat /tmp/dialogout.$$` 59 opt="$resolution -S $deathmatch -D $diff -L $level -P $port" 60 dialog --title "Koules options" --yesno "Save configuration" 5 40 61 case $? in 62 0) echo "$KOULESDIR/koules.svga $opt" >~/.koules.server 63 esac 64} 65client() 66{ 67 dialog --title "Client options" --menu "Select resolution" 9 40 2 "320x200" "low resolution" "640x480" "High resolution" 2> /tmp/dialogout.$$ 68 resolution=`cat /tmp/dialogout.$$` 69 if [ $resolution = "320x200" ]; then 70 resolution="-s" 71 else 72 resolution="-l" 73 fi 74 dialog --title "Client options" --checklist "Driver options" 9 40 2 "Mouse support" "" on "Sound support" "" on 2> /tmp/dialogout.$$ 75 drivers=`cat /tmp/dialogout.$$` 76 mouse="-M" 77 sound="-d" 78 for opt in $drivers; do 79 case $opt in 80 \"Mouse) mouse=" ";; 81 \"Sound) sound=" ";; 82 esac 83 done 84 dialog --title "Client options" --inputbox "Host" 9 40 "localhost" 2>/tmp/dialogout.$$ 85 host=`cat /tmp/dialogout.$$` 86 dialog --title "Client options" --inputbox "Inet port" 9 40 "12345" 2>/tmp/dialogout.$$ 87 port=`cat /tmp/dialogout.$$` 88 opt="-C$host $resolution $mouse $sound -P $port" 89 dialog --title "Koules options" --yesno "Save configuration" 5 40 90 case $? in 91 0) echo "$KOULESDIR/koules.svga $opt" >~/.koules.client 92 esac 93} 94configure() 95{ 96dialog --title "Koules options" --menu "Select game mode" 11 30 4 "g" "single" "s" "Network server" "c" "Network client" "b" "Back to main menu" 2> /tmp/dialogout.$$ 97mode=`cat /tmp/dialogout.$$` 98case $mode in 99 g)\ 100 single ;; 101 s)\ 102 server ;; 103 c)\ 104 client ;; 105esac 106} 107 108mainmenu() 109{ 110dialog --title "Koules startup menu" --menu "Select game mode" 11 30 4 "g" "single" "s" "Network server" "c" "Network client" "m" "Configuration menu" 2> /tmp/dialogout.$$ 111mode=`cat /tmp/dialogout.$$` 112case $mode in 113 g)\ 114 if [ ! -r ~/.koules.single ]; then 115 single 116 fi 117 clear 118 sh ~/.koules.single ;; 119 s)\ 120 if [ ! -r ~/.koules.server ]; then 121 server 122 fi 123 clear 124 sh ~/.koules.server ;; 125 c)\ 126 if [ ! -r ~/.koules.client ]; then 127 client 128 fi 129 clear 130 sh ~/.koules.client ;; 131 m) 132 configure 133 mainmenu ;; 134esac 135} 136mainmenu 137