#!/bin/bash
#
APPROOT="${0%/*}"
if [ ! -d "$APPROOT" ] ; then
echo "Use open /PATH/Diablo2.app or double click the icon in Finder"
exit 0
fi
WINEROOT="$(find ${APPROOT} -type f -iname 'wine')"
WINEROOT="${WINEROOT%/bin/*}" #the distribution from wine which contains the bin and lib folders
WINEPREFIX="${APPROOT}/prefix" #this is where all .wine stuff will go instead of dirtying ${HOME}
DIABLODIR="$(find ${APPROOT} -iname 'Diablo II.exe' | tail -n 1)"
DIABLOEXE="$(echo ${DIABLODIR} | rev | cut -f1 -d'/' | rev)"
DIABLODIR="${DIABLODIR%/*}"
PATH="${PATH}:${WINEROOT}/bin/" #put wine in the path, so we dont have to invoke it absolutely
DYLD_FALLBACK_LIBRARY_PATH="/usr/X11/lib:${WINEROOT}/lib" #make sure wine is happy
export WINEPREFIX PATH DYLD_FALLBACK_LIBRARY_PATH #instead of using env, exporting variables
export WINEDLLOVERRIDES="mshtml=" #diablo2 doesn't need wine gecko, so supress it:
cd "${DIABLODIR}"
if [ -z "${DIABLODIR}" ] ; then
say "Diablo folder not found! Please copy Diablo 2 folder into the Contents/MacOS"
else
if [ ! -d "${WINEPREFIX}" ] ; then
say "Configuring wine... please wait."
regedit - <<END
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\Explorer]
"Desktop"="Default"
[HKEY_CURRENT_USER\Software\Wine\Explorer\Desktops]
"Default"="800x600"
END
say "Wine configured. Don't forget to modify in-game video settings"
fi
wine "${DIABLOEXE}"
fi