Skip to content
Snippets Groups Projects
Commit 937fed8d authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Add preset selection step

parent ee15449b
No related branches found
No related tags found
No related merge requests found
......@@ -70,9 +70,24 @@ function manage_plugins() {
SAVEIFS=$IFS
IFS=$'\n'
preset_list=($(git config -f Plugins/unrealplugins/presets.config --name-only --get-regexp ".*.name"))
plugin_list=($(git config -f Plugins/unrealplugins/plugins.config --name-only --get-regexp ".*.name"))
IFS=$SAVEIFS
declare -a preset_ids
declare -a preset_descriptions
declare -a presets
for i in ${!preset_list[@]}
do
preset_id=${preset_list[$i]%.name}
preset_ids+=("$preset_id")
preset_name=$(git config -f Plugins/unrealplugins/presets.config --get "$preset_id.name")
presets+=("${preset_name}")
preset_description=$(git config -f Plugins/unrealplugins/presets.config --get "$preset_id.description")
preset_descriptions+=("${preset_description}")
done
declare -a plugin_ids
declare -a plugins
declare -a plugin_repositories
......@@ -88,13 +103,7 @@ function manage_plugins() {
if [ "$1" == "initial_setup" ]
then
branch=($(git config -f Plugins/unrealplugins/plugins.config --get "$plugin_id.default-branch"))
if [ $? == 0 ]
then
plugin_branches+=("$branch")
else
plugin_branches+=("")
fi
else
path=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_id}.path")
if [ $? == 0 ]
......@@ -112,6 +121,89 @@ function manage_plugins() {
fi
done
if [ "$1" == "initial_setup" ]
then
selection=0
exit=false
cancel=false
num_presets_minus_one=${#presets[@]}
let num_presets_minus_one-=1
while [ $exit == "false" ]
do
clear
echo "Select plugin preset:"
echo ""
for i in ${!presets[@]}
do
if [ $i == $selection ]
then
printf "\e[7m"
fi
echo " ${presets[$i]}"
if [ $i == $selection ]
then
printf "\e[0m"
fi
done
echo ""
echo "${preset[$selection]}"
echo "${preset_descriptions[$selection]}"
echo ""
echo "[Arrow Up/Down] Select preset"
echo "[Enter] Continue"
echo "[Esc] Skip preset selection"
SAVEIFS=$IFS
IFS=''
escape_char=$(printf "\033")
escape=false
read -rsn1 mode # get 1 character
if [[ $mode == $escape_char ]]; then
escape=true
read -rsn2 mode # read 2 more chars
fi
IFS=$SAVEIFS
case $mode in
"") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;;
"[D") previous_branch $selection ;;
"[C") next_branch $selection ;;
"[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;;
"[B") if [ "$selection" -lt "$num_presets_minus_one" ]; then let selection+=1; fi ;;
*) >&2 ;;
esac
done
# Set the appropriate plugin branches
if [ "$cancel" != true ]
then
SAVEIFS=$IFS
IFS=$'\n'
preset_plugins=($(git config -f Plugins/unrealplugins/presets.config --name-only --get-regexp "${preset_ids[$selection]}\.plugins\..*"))
IFS=$SAVEIFS
for plugin in ${preset_plugins[@]}
do
plugin_id=${plugin#"${preset_ids[$selection]}.plugins."}
for i in ${!plugins[@]}
do
if [ $plugin_id == ${plugin_ids[$i]} ]
then
branch=$(git config -f Plugins/unrealplugins/presets.config --get "$plugin")
plugin_branches[$i]=$branch
fi
done
done
fi
fi
function next_branch() {
case ${plugin_branches[$1]} in
"") plugin_branches[$1]="master" ;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment