From ab7035377b114cfd6715e7e96083eba281df4783 Mon Sep 17 00:00:00 2001 From: murkl Date: Wed, 29 Jan 2025 09:11:31 +0100 Subject: [PATCH] add tweaks, add custom command --- d2launcher | 20 ++++++++---- docs/README.md | 11 ++++++- res/tweaks.db | 83 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 98 insertions(+), 16 deletions(-) diff --git a/d2launcher b/d2launcher index a81fc5f..fa4b201 100755 --- a/d2launcher +++ b/d2launcher @@ -1,7 +1,7 @@ #!/usr/bin/env bash # shellcheck disable=SC1090 -SCRIPT_VERSION="4.1.1" +SCRIPT_VERSION="4.1.2" # ///////////////////////////////////////////////////// # LOCATE SCRIPT WORKING DIR @@ -36,6 +36,7 @@ SCRIPT_RES_DIR="$WORKING_DIR/res" SCRIPT_HOME_DIR="$HOME/.d2launcher" SCRIPT_BIN_DIR="$SCRIPT_HOME_DIR/bin" SCRIPT_BACKUP_DIR="$SCRIPT_HOME_DIR/backup" +SCRIPT_TWEAKS_DIR="$SCRIPT_HOME_DIR/tweaks" SCRIPT_CONFIG_FILE="$SCRIPT_HOME_DIR/d2launcher.conf" SCRIPT_TWEAKS_FILE="$SCRIPT_HOME_DIR/tweaks.db" @@ -158,6 +159,7 @@ main() { mkdir -p "$SCRIPT_BIN_DIR" || { echo "Error creating ${SCRIPT_BIN_DIR}" && exit 1; } mkdir -p "$SCRIPT_BACKUP_DIR" || { echo "Error creating ${SCRIPT_BACKUP_DIR}" && exit 1; } mkdir -p "$SCRIPT_TEMP_DIR" || { echo "Error creating ${SCRIPT_TEMP_DIR}" && exit 1; } + mkdir -p "$SCRIPT_TWEAKS_DIR" || { echo "Error creating ${SCRIPT_TWEAKS_DIR}" && exit 1; } # Rotate logfile [ -f "$SCRIPT_LOG_FILE" ] && mv -f "$SCRIPT_LOG_FILE" "${SCRIPT_BACKUP_DIR}/d2launcher.log.old" @@ -398,6 +400,8 @@ show_update_manager_menu() { show_tweaks_menu() { + check_d2_dir || return 1 + # Download tweaks db from URL (if not exists) [ ! -f "$SCRIPT_TWEAKS_FILE" ] && ! show_gui_update_tweaks_db && return 1 @@ -462,7 +466,7 @@ show_tweaks_menu() { # View source? if zenity_question "View Sourcecode from ${result} Script?"; then - zenity --text-info --width="800" --height="600" --title="Source: ${result}" --ok-label="Continue" --cancel-label="Cancel" --font="monospace" --filename="$tweak_file" || return 1 + zenity --text-info --width="1920" --height="1080" --title="Source: ${result}" --ok-label="Continue" --cancel-label="Cancel" --font="monospace" --filename="$tweak_file" || return 1 fi # Install tweak? @@ -472,7 +476,7 @@ show_tweaks_menu() { # Run tweak script in temp as working dir ( - echo "// Install ${result}" + echo "// ${result}" chmod +x "${tweak_file}" bash -c "set -a && source ${SCRIPT_CONFIG_FILE} && ${tweak_file}" || echo $? >"${SCRIPT_TEMP_DIR}/tweaks/error" ) 2>&1 | tee -a "$tweak_log" & @@ -481,11 +485,11 @@ show_tweaks_menu() { return 1 fi if [ -f "${SCRIPT_TEMP_DIR}/tweaks/error" ]; then - echo ":: Error" >>"$tweak_log" + echo ":: ERROR Tweak installation failed" >>"$tweak_log" else - echo ":: Success" >>"$tweak_log" + echo ":: Tweak successfully installed" >>"$tweak_log" fi - zenity --text-info --width="800" --height="600" --title="Tweak Log" --ok-label="Ok" --cancel-label="Close" --font="monospace" --filename="$tweak_log" + zenity --text-info --width="1080" --height="720" --title="Tweak Log" --ok-label="Ok" --cancel-label="Close" --font="monospace" --filename="$tweak_log" return 0 } # ///////////////////////////////////////////////////// @@ -1004,6 +1008,10 @@ exec_wine_exe() { } exec_diablo2() { + if [ -n "$custom_command" ]; then + bash -c "$custom_command" + exit $? + fi check_d2_dir || return 1 check_wine_install || return 1 check_patch_installation || return 1 diff --git a/docs/README.md b/docs/README.md index dd4ed84..a243ef0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -65,7 +65,7 @@ d2_stats_tray="true" update_check="true" mxl_update_check="true" mxl_update_channel="public" -mxl_update_exclude=("cnc-ddraw config.exe" "ddraw.dll") +mxl_update_exclude=("d2gl.mpq" "glide3x.dll" "cnc-ddraw config.exe" "ddraw.dll") gui_width="420" gui_height="320" tweaks_url="https://my/custom/url/to/tweaks.db" @@ -79,11 +79,20 @@ All files are located here: `~/.d2launcher`. Simply copy & paste to another syst The logging file is `~/.d2launcher/d2launcher.log` and **is** rotated on every start of d2launcher. This contains only logs from execution of Diablo II. +## Menu Custom command +Replace "Diablo II" menu command with `custom_command="/my/custom/cmd"` + ## Exclude files from update patch Add this array property to exclude files from update `mxl_update_exclude=("file1" "file2")` +Best when using tweaks: + +``` +mxl_update_exclude=("d2gl.mpq" "glide3x.dll" "cnc-ddraw config.exe" "ddraw.dll") +``` + ## Median XL Beta Change the property `mxl_update_channel` from `public` to `beta`. diff --git a/res/tweaks.db b/res/tweaks.db index 1aaa250..cfc35a0 100644 --- a/res/tweaks.db +++ b/res/tweaks.db @@ -1,11 +1,76 @@ -###!> name: dummy_script_1 -###!> version: latest -echo ":: Dummy 1 script sourcecode..." + ###!> name: GavinK88/d2gl-mxl-1.0 + ###!> version: any + sleep 1.5 + github_author=GavinK88 + github_repo=d2gl-mxl-1.0 + releases_url="https://github.com/${github_author}/${github_repo}/releases" + github_version=$(zenity --entry --title="${github_author}/${github_repo}" --text="$releases_url\n\nEnter GitHub version (e.g. 1.0.5):" --entry-text="1.0.5") || exit 1 + file_name="${github_author}-${github_repo}-${github_version}" + file_ext="zip" + download_url="${releases_url}/download/${github_version}/Release.${file_ext}" + mkdir -p "${HOME}/.d2launcher/tweaks/" + echo -e ":: GitHub URL: ${releases_url}" -###!> name: dummy_script_2 -###!> version: latest -echo ":: Dummy 2 script sourcecode..." + # Check version + if [ -n "$github_version" ]; then + echo -e ":: GitHub Version: ${github_version}" + else + echo -e ":: Invalid GitHub Version" + exit 1 + fi -###!> name: dummy_script_3 -###!> version: latest -echo ":: Dummy 3 script sourcecode..." \ No newline at end of file + # Download if not exists + if [ ! -f "${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" ]; then + if curl -Lfs "${download_url}" >"${file_name}.${file_ext}"; then + mv -f "${file_name}.${file_ext}" "${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" + else + echo -e ":: Error downloading ${download_url}" + exit 1 + fi + fi + + # Unzip + if ! unzip -q -o "${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" -d "${HOME}/.d2launcher/bin/diablo2"; then + echo -e ":: Error unzip ${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" + exit 1 + fi + + # Finish + echo -e ":::::::::::::::::::::::::::::::::::::::::::::" + echo -e ":: Please set d2_args to: -3dfx" + echo -e ":: Open settings in Diablo II with: Ctrg + o" + echo -e ":::::::::::::::::::::::::::::::::::::::::::::" + + ###!> name: FunkyFr3sh/cnc-ddraw + ###!> version: latest + github_author=FunkyFr3sh + github_repo=cnc-ddraw + github_version=latest + file_name="${github_author}-${github_repo}-${github_version}" + file_ext="zip" + releases_url="https://github.com/${github_author}/${github_repo}/releases" + download_url="${releases_url}/latest/download/cnc-ddraw.${file_ext}" + mkdir -p "${HOME}/.d2launcher/tweaks/" + echo -e ":: GitHub URL: ${releases_url}" + + # Download + if curl -Lfs "${download_url}" >"${file_name}.${file_ext}"; then + mv -f "${file_name}.${file_ext}" "${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" + else + echo -e ":: Error downloading ${download_url}" + exit 1 + fi + + # Unzip + if ! unzip -q -o "${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" -d "${HOME}/.d2launcher/bin/diablo2"; then + echo -e ":: Error unzip ${HOME}/.d2launcher/tweaks/${file_name}.${file_ext}" + exit 1 + fi + + # Finish + echo -e ":::::::::::::::::::::::::::::::::::::::::::::" + echo -e ":: You have to do these steps manually:" + echo -e ":: - Goto Settings > Wine Settings > Library and override/add ddraw (set DLL load strategy to: native then built in)." + echo -e ":: - Goto Settings > Edit Configuration > set d2_args to: -ddraw" + echo -e ":: - Optimize prefered settings: Settings > Direct Draw Settings (optional)" + echo -e ":::::::::::::::::::::::::::::::::::::::::::::"