diff --git a/setup.sh b/setup.sh index 0ecb3364a57c93774ad93caf0104911fcff58389..79e41a3d779038a0aed4f8e51fb95794e857f84b 100644 --- a/setup.sh +++ b/setup.sh @@ -44,13 +44,169 @@ function initial_setup() { fi echo "Done!" else - echo "Skipping setup. Press enter to continue" - read temp + echo "Skipping setup." fi } function manage_plugins() { - echo "Hello!" + plugins=( + "likert scale plugin" + "Logging Plugin" + "nDisplayExtensions" + "NDisplay Launch Button" + "UniversalLogging" + "Unreal Cave Overlay" + "Unreal-Study-Framework" + "Unreal VA Plugin" + "UnrealVisPlugin" + "Widget Interaction Plugin" + ) + + plugin_repositories=( + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/likert-scale-plugin.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/logging-plugin.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/ndisplayextensions.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/NDisplayLaunchButton.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/universallogging.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-cave-overlay.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-study-framework.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-va-plugin.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unrealvisplugin.git" + "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/widgetinteraction.git" + ) + + if [ "$1" == "initial_setup" ] + then + plugin_branches=( + "" + "" + "master" + "" + "" + "master" + "" + "" + "" + "" + ) + else + plugin_branches=( + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + ) + + + for i in ${!plugins[@]} + do + repo_name_with_extension=${plugin_repositories[$i]##*/} + repo_name=${repo_name_with_extension%*.git} + + path=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.path") + if [ $? == 0 ] + then + branch=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.branch") + if [ $? -ne 0 ] + then + plugin_branches[$i]="master" + else + plugin_branches[$i]="$branch" + fi + fi + done + fi + + function toggle_branch() { + case ${plugin_branches[$1]} in + "") plugin_branches[$1]="master" ;; + "master") plugin_branches[$1]="develop" ;; + "develop") plugin_branches[$1]="" ;; + *) >&2; plugin_branches[$1]="" ;; + esac + } + + selection=0 + exit=false + cancel=false + num_plugins_minus_one=${#plugins[@]} + let num_plugins_minus_one-=1 + + while [ $exit == "false" ] + do + clear + + echo "Select plugins to install:" + echo "" + + for i in ${!plugins[@]} + do + if [ $i == $selection ] + then + printf "\e[7m" + fi + + if [ -z ${plugin_branches[$i]} ] + then + echo " [ ] ${plugins[$i]}" + else + echo " [X] ${plugins[$i]}: ${plugin_branches[$i]}" + fi + + if [ $i == $selection ] + then + printf "\e[0m" + fi + done + + + echo "" + echo "[Arrow Up/Down] Select Plugin" + echo "[Space] Toggle branch" + echo "[Enter] Continue" + echo "[Esc] Cancel" + + IFS='' + escape_char=$(printf "\u1b") + escape=false + read -rsn1 mode # get 1 character + if [[ $mode == $escape_char ]]; then + escape=true + read -rsn2 -t 0.1 mode # read 2 more chars + fi + case $mode in + "") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;; + " ") toggle_branch $selection ;; + "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;; + "[B") if [ "$selection" -lt "$num_plugins_minus_one" ]; then let selection+=1; fi ;; + *) >&2 ;; + esac + done + + if [ "$cancel" != true ] + then + clear + mkdir -p Plugins + cd Plugins + echo "Adding plugins..." + + + for i in ${!plugins[@]} + do + if [ -n "${plugin_branches[$i]}" ] + then + echo "${plugins[$i]}" + git submodule add -b ${plugin_branches[$i]} ${plugin_repositories[$i]} + fi + done + cd .. + fi } function show_main_menu() { @@ -62,8 +218,6 @@ function show_main_menu() { clear echo "Select Task:" - echo "[Arrow Up/Down] Change Selection" - echo "[Enter] Select" echo "" items=("InitialSetup" "ManagePlugins" "Exit") @@ -85,6 +239,10 @@ function show_main_menu() { fi done + echo "" + echo "[Arrow Up/Down] Change Selection" + echo "[Enter] Select" + IFS='' escape_char=$(printf "\u1b") read -rsn1 mode # get 1 character