From 1f32ef303a87a7ee9ea7285357d42c989d82c641 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 15 Dec 2023 20:20:31 -0500 Subject: [PATCH] Started work on settings menu. Set username works, odd issue, it refuses to chop anonymous: off of the beginning until it has been ran once. The actual changing of user name does work though. --- tojam | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tojam b/tojam index 01d7198..87c5b37 100755 --- a/tojam +++ b/tojam @@ -99,8 +99,35 @@ delete_server() { } -settings() { - echo "Settings coming soon" +configure_ninjam() { + local menuCode=0 + while [[ $menuCode -ne 1 ]]; do + settings=( + "anonymous" "Login in anonymously: ($anonymous)" + "save source files" "Save Source Files: (${saveSourceFiles/-nosavesourcefiles/false recommended})" + "sound driver" "Sound Driver: (${soundDriver%% *})" + "username" "Set User Name: (${userName#*anonymous:})" + ) + setting="$(dialog --backtitle "Tojam" \ + --no-tags \ + --menu "Select a setting" -1 -1 -1 "${settings[@]}" --stdout)" + menuCode=$? + if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then + exit 0 + fi + case "${setting}" in + "username") + userName="$(dialog --backtitle "Tojam" \ + --inputbox "Enter User Name (letters, numbers, dash, and underscore accepted):" -1 -1 "${userName#*anonymous:}" --stdout)" + menuCode=$? + [[ ${menuCode} -ne 0 ]] && continue + [[ "${anonymous}" == "true" ]] && userName="anonymous:${userName}" + sed -i "s/^userName=.*/userName='${userName}'/" "${config}/config" && + dialog --msgbox "Username set to \"${userName#*anonymous:}\"." -1 -1 + ;; + esac + done + exit 0 } @@ -186,7 +213,7 @@ server="$(dialog --clear \ menuCode=$? case ${menuCode} in 1|255) exit 0;; - 2) settings;; + 2) configure_ninjam;; 3) add_server;; esac