Compare commits

..

No commits in common. "ea4e88d5b203b0e1da5e189deb9aab7e57e1549e" and "2343bfb7338cbba07f20a3c362badef0486f27b6" have entirely different histories.

View File

@ -97,16 +97,6 @@ helper_dir="$(realpath "$0" | xargs -0 dirname)"
tmp_dir="$(mktemp -d --suffix=".lughelper")" tmp_dir="$(mktemp -d --suffix=".lughelper")"
trap 'rm -r "$tmp_dir"' EXIT trap 'rm -r "$tmp_dir"' EXIT
# Set a maximum number of versions to display from each download url
max_download_items=20
# Pixels to add for each Zenity menu option
# used to dynamically determine the height of menus
menu_option_height="26"
# winetricks minimum version
winetricks_required="20210825"
######## Game Directories ################################################## ######## Game Directories ##################################################
# The game's base directory name # The game's base directory name
@ -162,6 +152,13 @@ dxvk_sources=(
"gnusenpai" "https://api.github.com/repos/gnusenpai/dxvk/releases" "gnusenpai" "https://api.github.com/repos/gnusenpai/dxvk/releases"
) )
# Set a maximum number of versions to display from each download url
max_download_items=20
# Pixels to add for each Zenity menu option
# used to dynamically determine the height of menus
menu_option_height="26"
######## Bundled Files ##################################################### ######## Bundled Files #####################################################
# Use logo installed by a packaged version of this script if available # Use logo installed by a packaged version of this script if available
@ -190,7 +187,7 @@ lug_wiki="https://github.com/starcitizen-lug/information-howtos/wiki"
# Github repo and script version info # Github repo and script version info
repo="starcitizen-lug/lug-helper" repo="starcitizen-lug/lug-helper"
releases_url="https://github.com/$repo/releases" releases_url="https://github.com/$repo/releases"
current_version="v2.1" current_version="v2.0"
############################################################################ ############################################################################
############################################################################ ############################################################################
@ -358,7 +355,10 @@ message() {
# #
# How to call this function: # How to call this function:
# #
# Requires the following variables: # Requires two arrays to be set: "menu_options" and "menu_actions"
# two string variables: "menu_text_zenity" and "menu_text_terminal"
# and one integer variable: "menu_height".
#
# - The array "menu_options" should contain the strings of each option. # - The array "menu_options" should contain the strings of each option.
# - The array "menu_actions" should contain function names to be called. # - The array "menu_actions" should contain function names to be called.
# - The strings "menu_text_zenity" and "menu_text_terminal" should contain # - The strings "menu_text_zenity" and "menu_text_terminal" should contain
@ -366,7 +366,6 @@ message() {
# This text will be displayed above the menu options. # This text will be displayed above the menu options.
# Zenity supports Pango Markup for text formatting. # Zenity supports Pango Markup for text formatting.
# - The integer "menu_height" specifies the height of the zenity menu. # - The integer "menu_height" specifies the height of the zenity menu.
# - The string "menu_type" should contain either "radiolist" or "checklist".
# - The string "cancel_label" should contain the text of the cancel button. # - The string "cancel_label" should contain the text of the cancel button.
# #
# The final element in each array is expected to be a quit option. # The final element in each array is expected to be a quit option.
@ -389,8 +388,6 @@ menu() {
debug_print exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting." debug_print exit "Script error: The string 'menu_text_terminal' was not set\nbefore calling the menu function. Aborting."
elif [ -z "$menu_height" ]; then elif [ -z "$menu_height" ]; then
debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting." debug_print exit "Script error: The string 'menu_height' was not set\nbefore calling the menu function. Aborting."
elif [ "$menu_type" != "radiolist" ] && [ "$menu_type" != "checklist" ]; then
debug_print exit "Script error: Unknown menu_type in menu() function. Aborting."
elif [ -z "$cancel_label" ]; then elif [ -z "$cancel_label" ]; then
debug_print exit "Script error: The string 'cancel_label' was not set\nbefore calling the menu function. Aborting." debug_print exit "Script error: The string 'cancel_label' was not set\nbefore calling the menu function. Aborting."
fi fi
@ -402,66 +399,28 @@ menu() {
# ie: "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3" # ie: "TRUE" "List item 1" "FALSE" "List item 2" "FALSE" "List item 3"
for (( i=0; i<"${#menu_options[@]}"-1; i++ )); do for (( i=0; i<"${#menu_options[@]}"-1; i++ )); do
if [ "$i" -eq 0 ]; then if [ "$i" -eq 0 ]; then
# Set the first element # Select the first radio button by default
if [ "$menu_type" = "radiolist" ]; then zen_options=("TRUE")
# Select the first radio button by default zen_options+=("${menu_options[i]}")
zen_options=("TRUE")
else
# Don't select the first checklist item
zen_options=("FALSE")
fi
else else
# Deselect all remaining items
zen_options+=("FALSE") zen_options+=("FALSE")
zen_options+=("${menu_options[i]}")
fi fi
# Add the menu list item
zen_options+=("${menu_options[i]}")
done done
# Display the zenity radio button menu # Display the zenity radio button menu
choice="$(zenity --list --"$menu_type" --width="480" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --cancel-label "$cancel_label" --window-icon="$lug_logo" --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)" choice="$(zenity --list --radiolist --width="480" --height="$menu_height" --text="$menu_text_zenity" --title="Star Citizen LUG Helper" --hide-header --cancel-label "$cancel_label" --window-icon="$lug_logo" --column="" --column="Option" "${zen_options[@]}" 2>/dev/null)"
# Match up choice with an element in menu_options # Loop through the options array to match the chosen option
matched="false" matched="false"
if [ "$menu_type" = "radiolist" ]; then for (( i=0; i<"${#menu_options[@]}"; i++ )); do
# Loop through the options array to match the chosen option if [ "$choice" = "${menu_options[i]}" ]; then
for (( i=0; i<"${#menu_options[@]}"; i++ )); do # Execute the corresponding action
if [ "$choice" = "${menu_options[i]}" ]; then ${menu_actions[i]}
# Execute the corresponding action for a radiolist menu matched="true"
${menu_actions[i]} break
matched="true"
break
fi
done
elif [ "$menu_type" = "checklist" ]; then
# choice will be empty if no selection was made
# Unfortunately, it's also empty when the user presses cancel
# so we can't differentiate between those two states
# Convert choice string to array elements for checklists
ifsBAK="$IFS"
IFS='|' read -a choices <<< "$choice"
IFS="$ifsBAK"
# Fetch the function to be called
function_call="$(echo "${menu_actions[0]}" | awk '{print $1}')"
# Loop through the options array to match the chosen option(s)
unset arguments_array
for (( i=0; i<"${#menu_options[@]}"; i++ )); do
for (( j=0; j<"${#choices[@]}"; j++ )); do
if [ "${choices[j]}" = "${menu_options[i]}" ]; then
arguments_array+=("$(echo "${menu_actions[i]}" | awk '{print $2}')")
matched="true"
fi
done
done
# Call the function with all matched elements as arguments
if [ "$matched" = "true" ]; then
$function_call "${arguments_array[@]}"
fi fi
fi done
# If no match was found, the user clicked cancel # If no match was found, the user clicked cancel
if [ "$matched" = "false" ]; then if [ "$matched" = "false" ]; then
@ -781,21 +740,6 @@ wine_check() {
fi fi
} }
# Check the installed winetricks version
winetricks_check() {
if [ -x "$(command -v winetricks)" ]; then
winetricks_current="$(winetricks --version | awk '{print $1}')"
if [ "$winetricks_required" != "$winetricks_current" ] &&
[ "$winetricks_current" = "$(printf "$winetricks_current\n$winetricks_required" | sort -V | head -n1)" ]; then
preflight_fail+=("Winetricks is out of date.\nVersion $winetricks_required or newer is required.\nPlease refer to our Quick Start Guide:\n$lug_wiki")
else
preflight_pass+=("Winetricks is installed and up to date.")
fi
else
preflight_fail+=("Winetricks does not appear to be installed.\nVersion $winetricks_required or newer is required.\nPlease refer to our Quick Start Guide:\n$lug_wiki")
fi
}
# Check total system memory # Check total system memory
memory_check() { memory_check() {
memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)" memtotal="$(LC_NUMERIC=C awk '/MemTotal/ {printf "%.1f \n", $2/1024/1024}' /proc/meminfo)"
@ -837,7 +781,6 @@ preflight_check() {
# Call the optimization functions to perform the checks # Call the optimization functions to perform the checks
wine_check wine_check
winetricks_check
memory_check memory_check
swap_check swap_check
avx_check avx_check
@ -1073,19 +1016,10 @@ download_delete() {
debug_print exit "Script error: The download_delete function expects an argument. Aborting." debug_print exit "Script error: The download_delete function expects an argument. Aborting."
fi fi
# Capture arguments and format a list of items item_to_delete="$1"
item_to_delete=("$@") if message question "Are you sure you want to delete the following ${download_type}?\n\n${installed_items[$item_to_delete]}"; then
unset list_to_delete rm -r "${installed_items[$item_to_delete]}"
for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do debug_print continue "Deleted ${installed_items[$item_to_delete]}"
list_to_delete+="\n${installed_items[${item_to_delete[i]}]}"
done
if message question "Are you sure you want to delete the following ${download_type}(s)?\n$list_to_delete"; then
# Loop through the arguments
for (( i=0; i<"${#item_to_delete[@]}"; i++ )); do
rm -r "${installed_items[${item_to_delete[i]}]}"
debug_print continue "Deleted ${installed_items[${item_to_delete[i]}]}"
done
lutris_needs_restart="true" lutris_needs_restart="true"
fi fi
} }
@ -1093,10 +1027,9 @@ download_delete() {
# List installed items for deletion. Called by download_manage() # List installed items for deletion. Called by download_manage()
download_select_delete() { download_select_delete() {
# Configure the menu # Configure the menu
menu_text_zenity="Select the $download_type(s) you want to remove:" menu_text_zenity="Select the $download_type you want to remove:"
menu_text_terminal="Select the $download_type you want to remove:" menu_text_terminal="Select the $download_type you want to remove:"
menu_text_height="60" menu_text_height="60"
menu_type="checklist"
goback="Return to the $download_type management menu" goback="Return to the $download_type management menu"
unset installed_items unset installed_items
unset installed_item_names unset installed_item_names
@ -1428,7 +1361,6 @@ download_select_install() {
menu_text_zenity="Select the $download_type you want to install:" menu_text_zenity="Select the $download_type you want to install:"
menu_text_terminal="Select the $download_type you want to install:" menu_text_terminal="Select the $download_type you want to install:"
menu_text_height="60" menu_text_height="60"
menu_type="radiolist"
goback="Return to the $download_type management menu" goback="Return to the $download_type management menu"
unset menu_options unset menu_options
unset menu_actions unset menu_actions
@ -1560,7 +1492,6 @@ download_manage() {
menu_text_zenity="<b><big>Manage Your $download_menu_heading</big>\n\n$download_menu_description</b>\n\nYou may choose from the following options:" menu_text_zenity="<b><big>Manage Your $download_menu_heading</big>\n\n$download_menu_description</b>\n\nYou may choose from the following options:"
menu_text_terminal="Manage Your $download_menu_heading\n\n$download_menu_description\nYou may choose from the following options:" menu_text_terminal="Manage Your $download_menu_heading\n\n$download_menu_description\nYou may choose from the following options:"
menu_text_height="$download_menu_height" menu_text_height="$download_menu_height"
menu_type="radiolist"
# Configure the menu options # Configure the menu options
delete="Remove an installed $download_type" delete="Remove an installed $download_type"
@ -1585,8 +1516,8 @@ download_manage() {
# Calculate the total height the menu should be # Calculate the total height the menu should be
menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))" menu_height="$(($menu_option_height * ${#menu_options[@]} + $menu_text_height))"
# Set the label for the cancel button # Set the label for the cancel button
cancel_label="Go Back" cancel_label="Go Back"
# Call the menu function. It will use the options as configured above # Call the menu function. It will use the options as configured above
menu menu
@ -1912,7 +1843,6 @@ maintenance_menu() {
menu_text_zenity="<b><big>Game Maintenance and Troubleshooting</big></b>\n\nYou may choose from the following options:" menu_text_zenity="<b><big>Game Maintenance and Troubleshooting</big></b>\n\nYou may choose from the following options:"
menu_text_terminal="Game Maintenance and Troubleshooting\n\nYou may choose from the following options:" menu_text_terminal="Game Maintenance and Troubleshooting\n\nYou may choose from the following options:"
menu_text_height="100" menu_text_height="100"
menu_type="radiolist"
# Configure the menu options # Configure the menu options
version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)" version_msg="Switch the Helper between LIVE and PTU (Currently: $live_or_ptu)"
@ -2219,7 +2149,6 @@ while true; do
menu_text_zenity="<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper!</big>\n\nThis Helper is designed to help optimize your system for Star Citizen</b>\n\nYou may choose from the following options:" menu_text_zenity="<b><big>Welcome, fellow Penguin, to the Star Citizen LUG Helper!</big>\n\nThis Helper is designed to help optimize your system for Star Citizen</b>\n\nYou may choose from the following options:"
menu_text_terminal="Welcome, fellow Penguin, to the Star Citizen Linux Users Group Helper!\n\nThis Helper is designed to help optimize your system for Star Citizen\nYou may choose from the following options:" menu_text_terminal="Welcome, fellow Penguin, to the Star Citizen Linux Users Group Helper!\n\nThis Helper is designed to help optimize your system for Star Citizen\nYou may choose from the following options:"
menu_text_height="140" menu_text_height="140"
menu_type="radiolist"
# Configure the menu options # Configure the menu options
preflight_msg="Preflight Check (System Optimization)" preflight_msg="Preflight Check (System Optimization)"