1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2025-01-01 15:12:05 +01:00

Toggle debug in-app

This commit is contained in:
aclist 2022-06-22 22:33:52 +09:00 committed by GitHub
parent f9fa553351
commit 36428bfd69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -o pipefail set -o pipefail
version=2.1.0 version=2.2.0
aid=221100 aid=221100
game="dayz" game="dayz"
workshop="https://steamcommunity.com/sharedfiles/filedetails/?id=" workshop="https://steamcommunity.com/sharedfiles/filedetails/?id="
@ -33,19 +33,19 @@ depcheck(){
command -v $dep 2>&1>/dev/null || (printf "[ERROR] Requires %s >= %s\nCheck your system package manager." $dep ${deps[$dep]}; exit 1) command -v $dep 2>&1>/dev/null || (printf "[ERROR] Requires %s >= %s\nCheck your system package manager." $dep ${deps[$dep]}; exit 1)
done done
} }
init_items(){
items=( items=(
"Launch server list" "Launch server list"
"Quick connect to favorite server" "Quick connect to favorite server"
"Add server by ID" "Add server by ID"
"Add favorite server" "Add favorite server"
"List installed mods" "List installed mods"
#"Toggle debug mode" "Toggle debug mode"
"Report bug (opens in browser)" "Report bug (opens in browser)"
"Help file (opens in browser)" "Help file (opens in browser)"
"View changelog" "View changelog"
) )
}
#exit_and_cleanup(){ #exit_and_cleanup(){
#rm $tmp #rm $tmp
#rm $link_file #rm $link_file
@ -402,9 +402,11 @@ connect_to_fav(){
} }
main_menu(){ main_menu(){
if [[ $debug -eq 1 ]]; then
items+=("Debug options")
fi
set_mode set_mode
if [[ -n $fav ]]; then if [[ -n $fav ]]; then
set_fav
items[3]="Change favorite server" items[3]="Change favorite server"
fi fi
while true; do while true; do
@ -435,10 +437,14 @@ main_menu(){
elif [[ $sel == "${items[4]}" ]]; then elif [[ $sel == "${items[4]}" ]]; then
list_mods list_mods
elif [[ $sel == "${items[5]}" ]]; then elif [[ $sel == "${items[5]}" ]]; then
report_bug toggle_debug
main_menu
return
elif [[ $sel == "${items[6]}" ]]; then elif [[ $sel == "${items[6]}" ]]; then
help_file report_bug
elif [[ $sel == "${items[7]}" ]]; then elif [[ $sel == "${items[7]}" ]]; then
help_file
elif [[ $sel == "${items[8]}" ]]; then
changelog | zenity --text-info $sd_res --title="DZGUI" 2>/dev/null changelog | zenity --text-info $sd_res --title="DZGUI" 2>/dev/null
else else
warn "This feature is not yet implemented." warn "This feature is not yet implemented."
@ -558,7 +564,7 @@ check_version(){
fi fi
} }
check_architecture(){ check_architecture(){
os_release=$(awk '/steamdeck/' "/etc/os-release") os_release=$(awk '/SteamOS/' "/etc/os-release")
if [[ -f "/etc/os-release" ]] && [[ -n $os_releasec ]]; then if [[ -f "/etc/os-release" ]] && [[ -n $os_releasec ]]; then
is_steam_deck=1 is_steam_deck=1
echo "[DZGUI] Setting architecture to 'Steam Deck'" echo "[DZGUI] Setting architecture to 'Steam Deck'"
@ -590,6 +596,28 @@ add_by_id(){
fi fi
done done
} }
toggle_debug(){
mv $config_file ${config_path}dztuirc.old
nr=$(awk '/debug=/ {print NR}' ${config_path}dztuirc.old)
if [[ $debug -eq 1 ]]; then
debug=0
items=()
init_items
else
debug=1
fi
flip_debug="debug=\"$debug\""
awk -v "var=$flip_debug" -v "nr=$nr" 'NR==nr {$0=var}{print}' ${config_path}dztuirc.old > $config_file
printf "[DZGUI] Toggled debug flag to '$debug'\n"
source $config_file
}
setup(){
if [[ -n $fav ]]; then
set_fav
items[3]="Change favorite server"
fi
}
add_by_fav(){ add_by_fav(){
while true; do while true; do
fav_id=$(zenity --entry --text="Enter server ID" --title="DZGUI" 2>/dev/null) fav_id=$(zenity --entry --text="Enter server ID" --title="DZGUI" 2>/dev/null)
@ -620,6 +648,8 @@ main(){
check_architecture check_architecture
config config
run_varcheck run_varcheck
init_items
setup
main_menu main_menu
} }