#!/usr/bin/env bash

# Read in language
source ${BBROOTDIR}/lang/${BBLANG}/multi.lang

# Read in functions
source ${BBROOTDIR}/misc/commonfunctions.sh
source ${BBROOTDIR}/func/multifunc.sh


#####PROGRAM START#####
while true; do
# This is for the numbering of the menu choices. It is
# updated once before each entry printout in the menu
# except exit which should always be 0. The variable must
# be reset within this while loop or bad things will happen.
(( bb_m_c = 0 ))
# <colors>
#source "$BBROOTDIR"/misc/colors.idx
# </colors>
clear
# <table>
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|${BBHEADCOLOR} ${BBVERSION} ${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}${BBDECOLINE}"
echo -e "${BBTABLECOLOR}|"
echo -e "${BBTABLECOLOR}|-(${BBSUBCOLOR}$bb_multi_menu_title${BBTABLECOLOR})"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_multi_menu_1"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_multi_menu_2"
(( bb_m_c += 1 ))
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} $bb_m_c) $bb_multi_menu_3"
echo -e "${BBTABLECOLOR}|${BBMAINCOLOR} 0) $bb_multi_menu_0"
echo -e "${BBTABLECOLOR}|"
echo -n -e "${BBINPUTCOLOR}$bb_multi_menu_entry[0-$bb_m_c] |>${BBMAINCOLOR} "
read action
echo -e "$BBCOLOROFF"


case $action in
	1)				# Starting multisession CD, first burn
		BBMULTI="-multi"	# We need to add this to cdrecord
		BBGET_PREV_SESSION=0	# first burn there is no previous session data
		burn_multi		# Call function above
		break			# Return to main		
		;;
	2)				# Continuing multisession CD
		BBMULTI="-multi"	# We need to add this to cdrecord
		BBGET_PREV_SESSION=1	# anytime after first burn we need previous session -msinfo data
		burn_multi		# Call function above
		break			#Return to main		
		;;
	3)				# Finishing multisession
		BBMULTI=""		# -multi cannot be added			
		BBGET_PREV_SESSION=1	# anytime after first burn we need previous session -msinfo data
		burn_multi		# Call function above
		break			# Return to main
		;;
	0)				# Aborting
		break			# Back to main
		;;
	*)				# You entered a bad number
		echo "$bb_multi_err[0-$bb_m_c]"
		wait_for_enter
		continue
		;;
esac
done



syntax highlighted by Code2HTML, v. 0.9.1