Skip to content

Commit

Permalink
add tweaks, add custom command
Browse files Browse the repository at this point in the history
  • Loading branch information
murkl committed Jan 29, 2025
1 parent 829229d commit ab70353
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 16 deletions.
20 changes: 14 additions & 6 deletions d2launcher
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -462,7 +466,7 @@ show_tweaks_menu() {

# View source?
if zenity_question "View Sourcecode from <b>${result}</b> 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?
Expand All @@ -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" &
Expand All @@ -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
}
# /////////////////////////////////////////////////////
Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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`.
Expand Down
83 changes: 74 additions & 9 deletions res/tweaks.db
Original file line number Diff line number Diff line change
@@ -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..."
# 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 ":::::::::::::::::::::::::::::::::::::::::::::"

0 comments on commit ab70353

Please sign in to comment.