Explorar o código

Loads of UI improvements and fixes

still lots of testing to do
Daniel Gibbs %!s(int64=9) %!d(string=hai) anos
pai
achega
1985955f3a

+ 2 - 2
lgsm/functions/command_mods_install.sh

@@ -29,14 +29,14 @@ fn_mods_install_init(){
 			# Exit if user says exit or abort
 			if [ "${usermodselect}" == "exit" ]||[ "${usermodselect}" == "abort" ]; then
 					core_exit.sh
-			# Supplementary output upon invalid user input 
+			# Supplementary output upon invalid user input
 			elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
 				fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
 			fi
 	done
 	echo ""
 	echo "Installing ${modprettyname}"
-	echo "================================="	
+	echo "================================="
 	fn_script_log "Installing ${modprettyname}."
 	# Gives a pretty name to the user and get all mod info
 	currentmod="${usermodselect}"

+ 45 - 9
lgsm/functions/command_mods_remove.sh

@@ -19,7 +19,6 @@ fn_mods_remove_init(){
 	# A simple function to exit if no mods were installed
 	# Also returns ${installedmodscount} if mods were found
 	fn_mods_exit_if_not_installed
-	echo ""
 	# Displays installed addons to the user
 	fn_installed_mods_medium_list
 	echo ""
@@ -30,12 +29,12 @@ fn_mods_remove_init(){
 		# Exit if user says exit or abort
 		if [ "${usermodselect}" == "exit" ]||[ "${usermodselect}" == "abort" ]; then
 				core_exit.sh
-		# Supplementary output upon invalid user input 
+		# Supplementary output upon invalid user input
 		elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
 			fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
 		fi
 	done
-	fn_print_warning_nl "You are about to remove ${usermodselect}."
+	fn_print_warning_nl "You are about to remove ${cyan}${usermodselect}${default}."
 	echo " * Any custom files/configuration will be removed."
 	while true; do
 		read -e -i "y" -p "Continue? [Y/n]" yn
@@ -44,40 +43,77 @@ fn_mods_remove_init(){
 		[Nn]* ) echo Exiting; exit;;
 		* ) echo "Please answer yes or no.";;
 	esac
-	done	
+	done
 	# Gives a pretty name to the user and get all mod info
 	currentmod="${usermodselect}"
 	fn_mod_get_info_from_command
 	# Check file list in order to make sure we're able to remove the mod (returns ${modsfilelistsize})
 	fn_check_files_list
-	fn_script_log "Removing ${modsfilelistsize} files from ${modprettyname}"
-	fn_print_dots "Removing ${modsfilelistsize} files from ${modprettyname}"
+
 }
 
 # Uninstall the mod
 fn_mod_remove_process(){
+	fn_script_log "Removing ${modsfilelistsize} files from ${modprettyname}"
+	echo -e "removing ${modprettyname}"
+	echo -e "* ${modsfilelistsize} files to be removed"
+	echo -e "* location: ${modinstalldir}"
+	sleep 1
 	# Go through every file and remove it
 	modfileline="1"
+	tput sc
 	while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
 		# Current line defines current file to remove
 		currentfileremove="$(sed "${modfileline}q;d" "${modsdatadir}/${modcommand}-files.txt")"
 		# If file or directory exists, then remove it
+		fn_script_log "Removing: ${modinstalldir}/${currentfileremove}"
 		if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then
-			fn_script_log "Removing: ${modinstalldir}/${currentfileremove}"
 			rm -rf "${modinstalldir}/${currentfileremove}"
+			local exitcode=$?
 		fi
+		tput rc; tput el
+		printf  "removing ${modprettyname} ${totalfileswc} / ${modsfilelistsize} : ${currentfileremove}..."
+
+		((totalfileswc++))
 		let modfileline=modfileline+1
 	done
+	tput rc; tput ed;
+	echo -ne "removing ${modprettyname} ${totalfileswc} / ${modsfilelistsize}..."
+	if [ ${exitcode} -ne 0 ]; then
+		fn_print_fail_eol_nl
+		core_exit.sh
+	else
+		fn_print_ok_eol_nl
+	fi
+	sleep 0.5
 	# Remove file list
+	echo -en "removing ${modcommand}-files.txt..."
+	sleep 0.5
 	fn_script_log "Removing: ${modsdatadir}/${modcommand}-files.txt"
 	rm -rf "${modsdatadir}/${modcommand}-files.txt"
+	local exitcode=$?
+	if [ ${exitcode} -ne 0 ]; then
+		fn_print_fail_eol_nl
+		core_exit.sh
+	else
+		fn_print_ok_eol_nl
+	fi
 	# Remove from installed mods list
+	echo -en "removing ${modcommand} from ${modslockfile}..."
+	sleep 0.5
 	fn_script_log "Removing: ${modcommand} from ${modslockfilefullpath}"
 	sed -i "/^${modcommand}$/d" "${modslockfilefullpath}"
 	# Post install tasks to solve potential issues
+	local exitcode=$?
+	if [ ${exitcode} -ne 0 ]; then
+		fn_print_fail_eol_nl
+		core_exit.sh
+	else
+		fn_print_ok_eol_nl
+	fi
 	fn_postuninstall_tasks
-	fn_print_ok_nl "Removed ${modprettyname}"
-	fn_script_log "Removed ${modprettyname}"
+	echo "${modprettyname} removed"
+	fn_script_log "${modprettyname} removed"
 }
 
 fn_mods_remove_init

+ 32 - 28
lgsm/functions/mods_core.sh

@@ -93,21 +93,23 @@ fn_mod_lowercase(){
 		fn_script_log "Converting ${modprettyname} files to lowercase"
 		files=$(find "${extractdir}" -depth | wc -l)
 		echo -en "\r"
-		while read SRC; do
-		    DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'`
-		    if [ "${SRC}" != "${DST}" ]
-		    then
-		        [ ! -e "${DST}" ] && mv -T "${SRC}" "${DST}" || echo "${SRC} was not renamed"
-		        ((renamedwc++))
-		    fi
+		while read src; do
+			dst=`dirname "${src}"`/`basename "${src}" | tr '[A-Z]' '[a-z]'`
+			if [ "${src}" != "${dst}" ]
+			then
+				[ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo "${src} was not renamed"
+				local exitcode=$?
+				((renamedwc++))
+			fi
 			echo -ne "${renamedwc} / ${totalfileswc} / $files converting ${modprettyname} files to lowercase..." $'\r'
 			((totalfileswc++))
 		done < <(find "${extractdir}" -depth)
 		echo -ne "${renamedwc} / ${totalfileswc} / $files converting ${modprettyname} files to lowercase..."
-		local exitcode=$?
+
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
-		else	
+			core_exit.sh
+		else
 			fn_print_ok_eol_nl
 		fi
 		sleep 0.5
@@ -153,7 +155,7 @@ fn_mod_fileslist(){
 	local exitcode=$?
 	if [ ${exitcode} -ne 0 ]; then
 		fn_print_fail_eol_nl
-	else	
+	else
 		fn_print_ok_eol_nl
 	fi
 	fn_script_log "Writing file list: ${modsdatadir}/${modcommand}-files.txt}"
@@ -173,7 +175,7 @@ fn_mod_copy_destination(){
 	local exitcode=$?
 	if [ ${exitcode} -ne 0 ]; then
 		fn_print_fail_eol_nl
-	else	
+	else
 		fn_print_ok_eol_nl
 	fi
 }
@@ -213,19 +215,16 @@ fn_check_files_list(){
 	# How many lines is the file list
 		modsfilelistsize="$(cat "${modsdatadir}/${modcommand}-files.txt" | wc -l)"
 		# If file list is empty
-		if [ $modsfilelistsize -eq 0 ]; then
-			fn_print_error_nl "${modcommand}-files.txt is empty"
-			echo "Exiting."
-			fn_scrip_log_fatal "${modcommand}-files.txt is empty"
-			exitcode="2"
+		if [ "${modsfilelistsize}" -eq 0 ]; then
+			fn_print_failure "${modcommand}-files.txt is empty"
+			echo "* Unable to remove ${modprettyname}"
+			fn_script_log_fatal "${modcommand}-files.txt is empty: Unable to remove ${modprettyname}."
 			core_exit.sh
 		fi
 	else
-			fn_print_error_nl "${modsdatadir}/${modcommand}-files.txt don't exist"
-			echo "Exiting."
-			fn_scrip_log_fatal "${modsdatadir}/${modcommand}-files.txt don't exist"
-			exitcode="2"
-			core_exit.sh
+		fn_print_failure "${modsdatadir}/${modcommand}-files.txt does not exist"
+		fn_script_log_fatal "${modsdatadir}/${modcommand}-files.txt does not exist: Unable to remove ${modprettyname}."
+		core_exit.sh
 	fi
 }
 
@@ -253,11 +252,11 @@ fn_postinstall_tasks(){
 		local exitcode=$?
 		if [ ${exitcode} -ne 0 ]; then
 			break
-		fi	
-	done	
+		fi
+	done
 	if [ ${exitcode} -ne 0 ]; then
 		fn_print_fail_eol_nl
-	else	
+	else
 		fn_print_ok_eol_nl
 	fi
 
@@ -527,7 +526,7 @@ fn_installed_mods_medium_list(){
 
 # Displays a simple list of installed mods
 # Requires fn_check_installed_mods and fn_mods_available_commands_from_installed to run
-# This list is only displayed when some mods are installed 
+# This list is only displayed when some mods are installed
 fn_installed_mods_light_list(){
 	fn_check_installed_mods
 	fn_mods_available_commands_from_installed
@@ -575,9 +574,11 @@ fn_installed_mods_update_list(){
 		# If the mode is just overwritten
 		elif [ "${modkeepfiles}" == "OVERWRITE" ]; then
 			echo -e " * \e[1m${modprettyname}${default} (overwrite)"
-		else			
+		else
 			echo -e " * ${yellow}${modprettyname}${default} (common custom files remain untouched)"
 		fi
+		((totalmodsinstalled++))
+		fn_script_log_info "${totalmodsinstalled} are already installed"
 	done
 }
 
@@ -598,17 +599,20 @@ fn_mod_get_info_from_command(){
 					modinfocommand="1"
 					break
 				fi
+				((totalmods++))
 			done
+
 		fi
 		# Exit the loop if job is done
 		if [ "${modinfocommand}" == "1" ]; then
 			break
 		fi
 	done
+	fn_script_log_info "${totalmods} are available for install"
 	# What happens if mod is not found
 	if [ "${modinfocommand}" == "0" ]; then
-		fn_script_log_error "Couldn't find information for ${currentmod}"
-		fn_print_error_nl "Couldn't find information for ${currentmod}"
+		fn_script_log_error "Could not find information for ${currentmod}"
+		fn_print_error_nl "Could not find information for ${currentmod}"
 		exitcode="1"
 		core_exit.sh
 	fi

+ 3 - 3
lgsm/functions/mods_list.sh

@@ -4,7 +4,7 @@
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
 # Description: Lists and defines available mods for LGSM supported servers.
-# Usage: To add a mod, you just need to add an array variable into fn_mods_info following the guide to set proper values. 
+# Usage: To add a mod, you just need to add an array variable into fn_mods_info following the guide to set proper values.
 # Usage: Then add this array to the mods_global_array.
 # Usage: If needed, you can scrape to define the download URL inside the fn_mods_scrape_urls function.
 
@@ -35,7 +35,7 @@ fn_mods_info(){
 	# [7] 	| "modinstalldir": the directory in which to install the mode ( use LGSM dir variables such as ${systemdir})
 	# [8]	| "/files/to/keep;", files & directories that should not be overwritten upon update, separated and ended with a semicolon; you can also use "OVERWRITE" to ignore the value or "NOUPDATE" to disallow updating
 	# [9] 	| "Supported Engines;": list them according to LGSM ${engine} variables, separated and ended with a semicolon, or use ENGINES to ignore the value
-	# [10] 	| "Supported Games;": list them according to LGSM ${gamename} variables, separated and ended with a semicolon, or use GAMES to ignore the value 
+	# [10] 	| "Supported Games;": list them according to LGSM ${gamename} variables, separated and ended with a semicolon, or use GAMES to ignore the value
 	# [11]	| "Unsupported Games;": list them according to LGSM ${gamename} variables, separated and ended with a semicolon, or use NOTGAMES to ignore the value (useful to exclude a game when using Supported Engines)
 	# [12]	| "AUTHOR_URL" is the author's website, displayed to the user when chosing mods to install
 	# [13]	| "Short Description" a description showed to the user upon installation
@@ -64,7 +64,7 @@ fn_mods_info(){
 
 # Get a proper URL for mods that don't provide a good one (optional)
 fn_mods_scrape_urls(){
-	fn_script_log "Retriving latest mods URLs"
+	fn_script_log_info "retrieving latest mods URLs"
 	# Metamod
 	metamodscrapeurl="http://www.gsptalk.com/mirror/sourcemod"
 	metamodlatestfile="$(wget "${metamodscrapeurl}/?MD" -q -O -| grep "mmsource" | grep "\-linux" | head -n1 | awk -F '>' '{ print $3 }' | awk -F '<' '{ print $1}')"