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.

This commit is contained in:
Storm Dragon 2023-12-15 20:20:31 -05:00
parent 7c2a9dbf2c
commit 1f32ef303a

33
tojam
View File

@ -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