#!/bin/msh
export TERM=linux
N="
"
echo $@ | grep trace && set -x
echo $@ | grep echo && set -v
set +v
while :
do
	dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "Main Menu" --cancel-label "Quit" --menu "" 0 0 0 \
	"Internet" "Web, IRC, ssh, ..." \
	"Audio" "MP3, Modules, Ogg, etc." \
	"Games" "If DSLinux isnt adventurous enough" \
	"Tools" "Text editor, calculator, etc" \
	"Misc" "Some other things to play around with" \
	"Settings" "Configure DSLinux in the way you like" \
	"" "" \
	"About" "About DSLinux and this app" \
	"" "" \
	"Return to shell" "Return to the shell prompt" \
	"Turn off" "Shutdown DSLinux and turn off your DS"`
	case $? in
		1|255) exit 0 ;;
	esac
	case "$dlginput" in
		Internet)
			dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "Internet" --cancel-label "Back" --menu "" 0 0 0 \
			"retawq" "a lightweigh text browser" \
			"links" "another textbrowser" \
			"links2" "graphical mode of links (buggy)" \
			"irssi" "a irc client"`
			case $dlginput in
				retawq)
					dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "retawq - quick help" --yes-label "Run" --no-label "Back" --yesno "To exit retawq, press m, choose quit and press y.${N}${N}To show the menu press m${N}${N}To enter an URL press g${N}${N}To get further help, press h (need to be online)" 0 0`
					case $? in
						0) retawq ;;
					esac
					;;
				links)
					dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "links - quick help" --yes-label "Run" --no-label "Back" --yesno "To exit links, hit q.${N}{N}To show the menu, hit F9 or Esc${N}{N}To go to an URL, hit g${N}{N}To get further Help, check \"Help\" in the menu" 0 0`
					case $? in
						0)
							dialog --backtitle "Wizzystart - DSLinux start menu" --title "Please wait" --infobox "Please wait..." 0 0
							links
							;;
					esac
					;;
				links2)
					dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "links - quick help" --yes-label "Run" --no-label "Back" --yesno "To exit links, hit q.${N}${N}To show the menu, hit F9 or Esc${N}${N}To go to an URL, hit g${N}${N}To get further Help, check \"Help\" in the menu" 0 0`
					case $? in
						0)
							links -g
							dialog --backtitle "Wizzystart - DSLinux start menu" --title "Please wait" --infobox "Please wait..." 0 0
							;; # FIXME run the improved version
					esac
					;;
				irssi)
					dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "irssi" --yes-label "Run" --no-label "Back" --yesno "To exit irssi, type /quit and hit enter.${N}${N}To connect to a server use /server, e.g. /server irc.rizon.net${N}${N}To join a channel use /j, e.g. /j #compiler.${N}${N}To get further help, check out www.irssi.org" 0 0`
					case $? in
						0)
							irssi
							dialog --backtitle "Wizzystart - DSLinux start menu" --title "Please wait" --infobox "Please wait..." 0 0
							;;
					esac
					;;
			esac
			;;
		Audio)
			dlginput=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "Audio" --cancel-label "Back" --menu "" 0 0 0 \
			"xmp" "play modules and other tracker files" \
			"tinysid" "play .sid modules" \
			"madplay" "MP3-Player" \
			"mp3play" "another MP3-Player" \
			"rawplay" "a .raw-player"`
			case $dlginput in
				xmp)
					dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "How to use the file selection" --cancel-label "Back" --msgbox "To switch between the fields, use Tab${N}To enter a directory, double-press B on your DS${N}If the path in the under field is okay, switch to OK using Tab and press A on your DS.${N}You may select folders or files."
					file=`dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "xmp - select files" --yes-label "Select" --no-label "Back" --flist /media/ 0 0`
					dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "xmp" --yes-label "Run" --no-label "Back" --yesno "To exit xmp, press Ctrl then press C." 0 0
					case $? in
						0)
							if [ -f $file ]; then
								xmp -m8 -b 8 $file
							else
								dialog --stdout --backtitle "Wizzystart - DSLinux start menu" --title "xmp" --yes-label "Run" --no-label "Back" --yesno "Shuffle files?" 0 0
								[ $0 = 0 ] && xmp -m8R -b 8 $file/*
								[ $0 = 1 ] && xmp -m8 -b 8 $file/*
							fi
							;;
					esac
					;;
				tinysid)
					;;
				madplay)
					;;
				mp3play)
					;;
				rawplay)
					;;
			esac
			;;
		Games)

			;;
		Tools)
			;;
		Misc)
			;;
		Settings)
			;;
		About)
			;;
		"Return to shell")
			exit 0
			;;
		"Turn off")
			dialog --backtitle "Wizzystart - DSLinux start menu" --title "Bye..." --yesno "Really turn off?" 0 0 && poweroff
			;;
	esac
done

