Magic number : 16
#!/bin/bash
# Date : (2009-05-23 15-00)
# Last revision : (2009-12-15 13-00)
# Wine version used : 1.1.24
# Distribution used to test : Fedora 11
# Author : NSLW
# Licence : Retail
# Depend : ImageMagick, unzip
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
download_patch()
{
cd "$REPERTOIRE/ressources"
if [ "`sha1sum < $PATCHFILE | sed 's/ .*//'`" != "$PATCHFILESUM" ]; then
POL_SetupWindow_download "PlayOnLinux is downloading $PATCHFILE" "Downloading patch" "$PATCHLINK/$PATCHFILE"
fi
if [ "`sha1sum < $PATCHFILE | sed 's/ .*//'`" != "$PATCHFILESUM" ]; then
echo 1 #checksum bad
else
echo 0 #checksum good
fi
}
patch_game()
{
POL_SetupWindow_menu "What installer should do?" "Actions" "Let me choose patch manually~Download patch automatically" "~"
if [ "$APP_ANSWER" == "Let me choose patch manually" ]; then
POL_SetupWindow_browse "Select patch file" "$TITLE" ""
PATCHFILE="$APP_ANSWER"
elif [ "$APP_ANSWER" == "Download patch automatically" ]
then
APP_ANSWER="TRUE"
while [ "$APP_ANSWER" == "TRUE" ]; do
APP_ANSWER="FALSE"
if [ $(download_patch) == "1" ]; then
sleep 1
POL_SetupWindow_question "Installer failed to download patch.\nDo you want to try again?" "$TITLE"
fi
done
fi
POL_SetupWindow_wait_next_signal "Installation in progress..." "$TITLE"
wine "$PATCHFILE"
POL_SetupWindow_detect_exit
POL_SetupWindow_message "Patch for $TITLE has been installed successfully" "$TITLE"
}
POL_SetupWindow_make_icon_for_shortcut()
{
convert "$HOME/.local/share/icons/$2" -geometry 32X32 "$REPERTOIRE/icones/32/$1"
}
Get_Latest_Wine_Version()
{
wget http://mulx.playonlinux.com/wine/linux-i386/LIST --output-document="$REPERTOIRE/tmp/LIST"
xyz=`cat "$REPERTOIRE/tmp/LIST" | sed -e 's/\.//g' | cut -d';' -f2 | sort -n | tail -n1`
echo "$(echo $xyz | cut -c1-1).$(echo $xyz | cut -c2-2).$(echo $xyz | cut -c3-4)"
}
TITLE="Diablo II"
PREFIX="DiabloII"
WORKINGWINEVERSION="1.1.36"
PATCHFILE="D2Patch_112a.exe"
PATCHLINK="http://ftp.blizzard.com/pub/diablo2/patches/PC"
PATCHFILESUM="cec6957c0c02fdc4fa4f296a70bd2637240e8e44"
wget http://upload.wikimedia.org/wikipedia/en/thumb/d/d5/Diablo_II_Coverart.png/250px-Diablo_II_Coverart.png --output-document="$REPERTOIRE/tmp/leftnotscaled.jpeg"
convert "$REPERTOIRE/tmp/leftnotscaled.jpeg" -scale 150x356\! "$REPERTOIRE/tmp/left.jpeg"
POL_SetupWindow_Init "" "$REPERTOIRE/tmp/left.jpeg"
POL_SetupWindow_presentation "$TITLE" "Blizzard" "www.blizzard.com" "NSLW" "$PREFIX"
select_prefix "$REPERTOIRE/wineprefix/$PREFIX"
#asking about patching
if [ -e "$REPERTOIRE/configurations/installed/$TITLE" ]; then
POL_SetupWindow_menu "What do you want to do?" "Actions" "Patch game" "~"
if [ "$APP_ANSWER" == "Patch game" ]; then
patch_game
fi
POL_SetupWindow_Close
exit
fi
POL_SetupWindow_message "Please insert \"Cinematics disc\" (3rd disc)" "$TITLE"
POL_SetupWindow_cdrom
cd "$CDROM"
CHECK=$(find . -iwholename ./D2video.mpq)
if [ "$CHECK" == "" ]; then
CHECK="installer tome 3.mpq"
fi
POL_SetupWindow_check_cdrom "$CHECK"
CDROM3="$CDROM"
POL_SetupWindow_prefixcreate
#fetching PROGRAMFILES environmental variable
PROGRAMFILES=`wine cmd /c echo "%ProgramFiles%" |tr -d '\015' | tr -d '\010'`
PROGRAMFILES=${PROGRAMFILES:3}
POL_SetupWindow_install_wine "$WORKINGWINEVERSION"
Use_WineVersion "$WORKINGWINEVERSION"
POL_SetupWindow_prefixcreate
cd "$WINEPREFIX/dosdevices"
#CDROM3="$CDROM"
ln -s "$CDROM3" g:
POL_SetupWindow_message "Please insert \"Play disc\" (2nd disc)" "$TITLE"
POL_SetupWindow_cdrom
cd "$CDROM"
CHECK=$(find . -iwholename ./D2music.mpq)
if [ "$CHECK" == "" ]; then
CHECK="installer tome 2.mpq"
fi
POL_SetupWindow_check_cdrom "$CHECK"
cd "$WINEPREFIX/dosdevices"
CDROM2="$CDROM"
ln -s "$CDROM2" f:
POL_SetupWindow_message "Please insert \"Install disc\" (1st disc)" "$TITLE"
POL_SetupWindow_cdrom
cd "$CDROM"
CHECK=$(find . -iwholename ./D2speech.mpq)
if [ "$CHECK" == "" ]; then
CHECK="installer tome.mpq"
fi
POL_SetupWindow_check_cdrom "$CHECK"
cd "$WINEPREFIX/dosdevices"
ln -s "$CDROM" e:
#cd "$WINEPREFIX/dosdevices"
#ln -s "$CDROM" e:
#ln -s "$CDROM2" f:
#ln -s "$CDROM3" g:
cd "$WINEPREFIX/drive_c/windows/temp/"
echo "[HKEY_LOCAL_MACHINE\\Software\\Wine\\Drives]" > cdrom.reg
echo "\"e:\"=\"cdrom\"" >> cdrom.reg
echo "\"f:\"=\"cdrom\"" >> cdrom.reg
echo "\"g:\"=\"cdrom\"" >> cdrom.reg
regedit cdrom.reg
sleep 5
#POL_SetupWindow_wait_next_signal "Installation in progress..." "$TITLE"
cd "$CDROM"
CHECK=$(find . -iwholename ./install.exe)
if [ "$CHECK" == "" ]; then
wine "installer.exe"
else
wine "install.exe"
fi
POL_SetupWindow_message "Click \"Next\" when installation will finish." "$TYTUL"
#POL_SetupWindow_detect_exit
#taking icon from the game
convert "$CDROM/disc.ico" -geometry 32X32 "$REPERTOIRE/icones/32/$TITLE"
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Diablo II" "Diablo II.exe" "" "$TITLE" "" ""
Set_WineVersion_Assign "$WORKINGWINEVERSION" "$TITLE"
POL_SetupWindow_make_icon_for_shortcut "$TITLE" "*_diablo ii.0.xpm"
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Diablo II" "D2VidTst.exe" "" "D2: Video Test" "" ""
Set_WineVersion_Assign "$WORKINGWINEVERSION" "Video Test"
POL_SetupWindow_make_icon_for_shortcut "Video Test" "*_d2vidtst.0.xpm"
POL_SetupWindow_question "Would you like to have got 3dfx Glide wrapper (recommended)?\nYou'll have to rerun Video Test after" "$TITLE"
if [ "$APP_ANSWER" == "TRUE" ]; then
cd "$REPERTOIRE/ressources"
if [ ! -e "$REPERTOIRE/ressources/gl32ogl14c.zip" ]; then
POL_SetupWindow_download "PlayOnLinux is downloading Glide wrapper" "Downloading wrapper" "http://www.svenswrapper.de/gl32ogl14c.zip"
fi
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Diablo II"
unzip "$REPERTOIRE/ressources/gl32ogl14c.zip"
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Diablo II" "glide-init.exe" "" "3dfx Glide configuration" "" ""
Set_WineVersion_Assign "$WORKINGWINEVERSION" "3dfx Glide configuration"
fi
POL_SetupWindow_reboot
POL_SetupWindow_message "$TITLE has been installed successfully" "$TITLE"
#asking about patching
POL_SetupWindow_question "Do you want to patch your game?" "$TITLE"
if [ "$APP_ANSWER" == "TRUE" ]; then
patch_game
fi
POL_SetupWindow_Close
exit