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

Make plugin system more flexible

parent c29e5554
Branches
No related tags found
No related merge requests found
...@@ -55,79 +55,51 @@ function initial_setup() { ...@@ -55,79 +55,51 @@ function initial_setup() {
} }
function manage_plugins() { function manage_plugins() {
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=(
""
""
""
""
""
""
""
""
""
""
)
SAVEIFS=$IFS
IFS=$'\n'
plugin_list=($(git config -f Plugins/UnrealPlugins/plugins.config --name-only --get-regexp ".*.name"))
IFS=$SAVEIFS
for i in ${!plugins[@]} declare -a plugin_ids
declare -a plugins
declare -a plugin_repositories
declare -a plugin_branches
for i in ${!plugin_list[@]}
do do
repo_name_with_extension=${plugin_repositories[$i]##*/} plugin_id=${plugin_list[$i]%.name}
repo_name=${repo_name_with_extension%*.git} plugin_ids+=("$plugin_id")
plugin_name=$(git config -f Plugins/UnrealPlugins/plugins.config --get "$plugin_id.name")
plugins+=("${plugin_name}")
plugin_repositories+=($(git config -f Plugins/UnrealPlugins/plugins.config --get "$plugin_id.url"))
path=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.path") 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 ] if [ $? == 0 ]
then then
branch=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.branch") branch=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_id}.branch")
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
plugin_branches[$i]="master" plugin_branches+=("master")
else else
plugin_branches[$i]="$branch" plugin_branches+=("$branch")
fi fi
else
plugin_branches+=("")
fi fi
done
fi fi
done
function toggle_branch() { function toggle_branch() {
case ${plugin_branches[$1]} in case ${plugin_branches[$1]} in
...@@ -178,6 +150,7 @@ function manage_plugins() { ...@@ -178,6 +150,7 @@ function manage_plugins() {
echo "[Enter] Continue" echo "[Enter] Continue"
echo "[Esc] Cancel" echo "[Esc] Cancel"
SAVEIFS=$IFS
IFS='' IFS=''
escape_char=$(printf "\u1b") escape_char=$(printf "\u1b")
escape=false escape=false
...@@ -186,6 +159,7 @@ function manage_plugins() { ...@@ -186,6 +159,7 @@ function manage_plugins() {
escape=true escape=true
read -rsn2 -t 0.1 mode # read 2 more chars read -rsn2 -t 0.1 mode # read 2 more chars
fi fi
IFS=$SAVEIFS
case $mode in case $mode in
"") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;; "") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;;
" ") toggle_branch $selection ;; " ") toggle_branch $selection ;;
...@@ -193,6 +167,7 @@ function manage_plugins() { ...@@ -193,6 +167,7 @@ function manage_plugins() {
"[B") if [ "$selection" -lt "$num_plugins_minus_one" ]; then let selection+=1; fi ;; "[B") if [ "$selection" -lt "$num_plugins_minus_one" ]; then let selection+=1; fi ;;
*) >&2 ;; *) >&2 ;;
esac esac
done done
if [ "$cancel" != true ] if [ "$cancel" != true ]
...@@ -204,9 +179,7 @@ function manage_plugins() { ...@@ -204,9 +179,7 @@ function manage_plugins() {
for i in ${!plugins[@]} for i in ${!plugins[@]}
do do
# Check if plugin is already present # Check if plugin is already present
repo_name_with_extension=${plugin_repositories[$i]##*/} path=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_ids[$i]}.path")
repo_name=${repo_name_with_extension%*.git}
path=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.path")
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
plugin_present=false plugin_present=false
...@@ -226,7 +199,7 @@ function manage_plugins() { ...@@ -226,7 +199,7 @@ function manage_plugins() {
else else
# Updating existing plugin # Updating existing plugin
echo "Update plugin: ${plugins[$i]}" echo "Update plugin: ${plugins[$i]}"
cd Plugins/$repo_name cd "Plugins/${plugin_ids[$i]}"
git fetch git fetch
git checkout ${plugin_branches[$i]} git checkout ${plugin_branches[$i]}
git pull git pull
...@@ -236,7 +209,7 @@ function manage_plugins() { ...@@ -236,7 +209,7 @@ function manage_plugins() {
if [ "$plugin_present" == true ] if [ "$plugin_present" == true ]
then then
# Remove plugin! # Remove plugin!
git rm -f "Plugins/$repo_name" git rm -f "Plugins/${plugin_ids[$i]}"
fi fi
fi fi
done done
...@@ -281,6 +254,7 @@ function show_main_menu() { ...@@ -281,6 +254,7 @@ function show_main_menu() {
echo "[Enter] Select" echo "[Enter] Select"
echo "[Esc] Quit" echo "[Esc] Quit"
SAVEIFS=$IFS
IFS='' IFS=''
escape_char=$(printf "\u1b") escape_char=$(printf "\u1b")
escape=false escape=false
...@@ -289,6 +263,7 @@ function show_main_menu() { ...@@ -289,6 +263,7 @@ function show_main_menu() {
escape=true escape=true
read -rsn2 -t 0.1 mode # read 2 more chars read -rsn2 -t 0.1 mode # read 2 more chars
fi fi
IFS=$SAVEIFS
case $mode in case $mode in
"") if [ "$escape" = true ]; then quit=true; fi; exit=true ;; "") if [ "$escape" = true ]; then quit=true; fi; exit=true ;;
"[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;; "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment