diff --git a/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh b/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh index 157c3b33..2a55c709 100755 --- a/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh +++ b/core/tabs/gaming/diablo-ii/d2r-loot-filters.sh @@ -4,18 +4,18 @@ # Check for required commands for cmd in find curl unzip stty; do - if ! command -v "$cmd" >/dev/null 2>&1; then - printf "%b\n" "Error: $cmd is not installed." + if ! command_exists "$cmd"; then + printf "%b\n" "${RED}$cmd is not installed.${RC}" exit 1 fi done # Search for possible Diablo II Resurrected folder locations -printf "%b\n" "Searching for Diablo II Resurrected folders..." +printf "%b\n" "${YELLOW}Searching for Diablo II Resurrected folders...${RC}" possible_paths=$(find "$HOME" -type d -path "*/drive_c/Program Files (x86)/Diablo II Resurrected" 2>/dev/null) if [ -z "$possible_paths" ]; then - printf "%b\n" "Error: No Diablo II Resurrected folders found." + printf "%b\n" "${RED}No Diablo II Resurrected folders found.${RC}" exit 1 fi @@ -35,7 +35,7 @@ total=$i selected=0 print_menu() { - command -v clear >/dev/null 2>&1 && clear + clear max_display=$((total < 10 ? total : 10)) start=$((selected - max_display / 2)) if [ $start -lt 0 ]; then start=0; fi @@ -70,12 +70,12 @@ select_path() { stty echo case "$key" in - $(printf '\033')A | k) + "$(printf '\033')A" | k) if [ $selected -gt 0 ]; then selected=$((selected - 1)) fi ;; - $(printf '\033')B | j) + "$(printf '\033')B" | j) if [ $selected -lt $((total - 1)) ]; then selected=$((selected + 1)) fi @@ -87,7 +87,7 @@ select_path() { esac done - command -v clear >/dev/null 2>&1 && clear + clear } # Use the select_path function @@ -95,7 +95,7 @@ select_path # Validate the path if [ ! -d "$d2r_path" ]; then - printf "%b\n" "Error: The specified path does not exist." + printf "%b\n" "${RED}The specified path does not exist.${RC}" exit 1 fi @@ -106,23 +106,23 @@ mkdir -p "$mods_path" # Download the latest release printf "%b\n" "Downloading the latest loot filter..." if ! curl -sSLo /tmp/lootfilter.zip https://github.com/ChrisTitusTech/d2r-loot-filter/releases/latest/download/lootfilter.zip; then - printf "%b\n" "Error: Failed to download the loot filter." + printf "%b\n" "${RED}Failed to download the loot filter.${RC}" exit 1 fi # Extract the contents to the mods folder printf "%b\n" "Extracting loot filter to $mods_path..." if ! unzip -q -o /tmp/lootfilter.zip -d "$mods_path"; then - printf "%b\n" "Error: Failed to extract the loot filter." + printf "%b\n" "${RED}Failed to extract the loot filter.${RC}" exit 1 fi # Clean up rm /tmp/lootfilter.zip -printf "%b\n" "Loot filter installed successfully in $mods_path" +printf "%b\n" "${GREEN}Loot filter installed successfully in $mods_path${RC}" -printf "%b\n" "To complete the setup, please follow these steps to add launch options in Battle.net:" +printf "%b\n" "${YELLOW}To complete the setup, please follow these steps to add launch options in Battle.net:${RC}" printf "%b\n" "1. Open the Battle.net launcher" printf "%b\n" "2. Select Diablo II: Resurrected" printf "%b\n" "3. Click the gear icon next to the 'Play' button"