The forum

[script] Gothic

Author Replies
NSLW Monday 6 July 2009 at 16:34
NSLW

Hello,
I wrote script which installs Gothic. It also can patch the game after it's been installed
Wine version : 1.1.25
Distribution : Fedora
Distribution Version : 11 (32 bit)
Graphics card : Nvidia, GeForce 9xxx
Drivers of the graphics card : 185.18.14

Icon for the game:


#!/bin/bash
# Date : (2009-07-06 12-00)
# Last revision : (2009-07-06 12-00)
# Wine version used : 1.1.25
# Distribution used to test : Fedora 11
# Author : NSLW
# Licence : Retail
# Depend : ImageMagick, unzip

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

#fetching PROGRAMFILES environmental variable
PROGRAMFILES=`wine cmd /c echo "%ProgramFiles%"`
PROGRAMFILES=${PROGRAMFILES:3}

TYTUL="Gothic"
PREFIX="Gothic"
WORKINGWINEVERSION="1.1.25"

#procedure for patching Gothic
patch_gothic()
{
POL_SetupWindow_browse "Select patch file" "$TYTUL" ""
wine "$APP_ANSWER"
POL_SetupWindow_message "Patch for $TYTUL has been installed successfully" "$TYTUL"
}

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)"
}

Change_Resolution()
{

cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Piranha Bytes/Gothic/System"
OLDX=`cat Gothic.ini | grep "zVidResFullscreenX=" | cut -d"=" -f2`
OLDY=`cat Gothic.ini | grep "zVidResFullscreenY=" | cut -d"=" -f2`
OLDBPP=`cat Gothic.ini | grep "zVidResFullscreenBPP=" | cut -d"=" -f2`

POL_SetupWindow_menu_list "Choose display resolution" "Display resolution" "1280x800~1024x768~800x600~640x480" "~"
RES="$APP_ANSWER"
POL_SetupWindow_menu_list "Choose color depth" "Color depth" "32~16" "~"
NEWBPP="$APP_ANSWER"

NEWX=`echo $RES | cut -d"x" -f1`
NEWY=`echo $RES | cut -d"x" -f2`
rm Gothic.ini.bak
mv Gothic.ini Gothic.ini.bak

cat Gothic.ini.bak | sed -e "s/zVidResFullscreenX=$OLDX/zVidResFullscreenX=$NEWX/g" | sed -e "s/zVidResFullscreenY=$OLDY/zVidResFullscreenY=$NEWY/g" | sed -e "s/zVidResFullscreenBPP=$OLDBPP/zVidResFullscreenBPP=$NEWBPP/g" > Gothic.ini
}

download_pulseudio()
{
cd "$REPERTOIRE/ressources/"
if [ ! -e "$REPERTOIRE/ressources/$WORKINGWINEVERSION-mod.zip" ]; then
POL_SetupWindow_download "Downloading PulseAudio sound driver" "$TYTUL" "http://www.sigmirror.com/files/23682_vtvrr/$WORKINGWINEVERSION-mod.zip"
fi
cd "$WINEPREFIX/drive_c/windows/temp/"
unzip "$REPERTOIRE/ressources/$WORKINGWINEVERSION-mod.zip"
./$WORKINGWINEVERSION-mod -y
cp PulseAudio/* ./
}

prepare_patched_WineVesrsion()
{
POL_SetupWindow_install_wine "$1"
cd "$REPERTOIRE/WineVersions"
POL_SetupWindow_wait_next_signal "Removing old WineVersion" "$TYTUL"
rm -fr "$1-PA"
POL_SetupWindow_detect_exit
 
POL_SetupWindow_wait_next_signal "Copying WineVersion" "$TYTUL"
cp -r "$1" "$1-PA"
cp "$WINEPREFIX/drive_c/windows/temp/winepulse.drv.so" "$REPERTOIRE/WineVersions/$1-PA/usr/lib/wine/winepulse.drv.so"
POL_SetupWindow_detect_exit
}

POL_SetupWindow_Init
POL_SetupWindow_presentation "$TYTUL" "Piranha Bytes" "www.piranha-bytes.com" "NSLW" "$PREFIX" 

select_prefix "$REPERTOIRE/wineprefix/$PREFIX"

LATESTVERSION=$(Get_Latest_Wine_Version)
CHOSENWINEVERSION="$LATESTVERSION"
Use_WineVersion "$CHOSENWINEVERSION"

#asking about patching or updating Wine version
if [ -e "$REPERTOIRE/configurations/installed/$TYTUL" ]; then
POL_SetupWindow_menu "What do you want to do?" "Actions" "Patch game~Change resolution~Update Wine version to $WORKINGWINEVERSION" "~"

if [ "$APP_ANSWER" == "Patch game" ]; then
	patch_gothic
elif [ "$APP_ANSWER" == "Change resolution" ]
then
Change_Resolution
elif [ "$APP_ANSWER" == "Update Wine version to $WORKINGWINEVERSION" ]
then
	CHOSENWINEVERSION="$LATESTVERSION-PA"
	download_pulseudio
	prepare_patched_WineVesrsion "$LATESTVERSION"
	cd "$WINEPREFIX/drive_c/windows/temp/" 
	echo "[HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\Drivers]" > pa.reg
	echo "\\"Audio\\"=\\"pulse\\"" >> pa.reg
	regedit pa.reg
	Set_WineVersion_Assign "$CHOSENWINEVERSION" "$TYTUL"
fi

POL_SetupWindow_Close
exit
fi

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"

#taking icon from the game
convert "$CDROM/gothic.ico" -geometry 32X32 "$REPERTOIRE/icones/32/$TYTUL"

POL_SetupWindow_prefixcreate

#adding CD-ROM as drive d: e: f: to winecfg
CDROM2=${CDROM//"1"/"2"} #GOTHIC_CD2
cd "$WINEPREFIX/dosdevices"
ln -s "$CDROM" d:
ln -s "$CDROM2" e:

cd "$WINEPREFIX/drive_c/windows/temp/"
echo "[HKEY_LOCAL_MACHINE\\\\Software\\\\Wine\\\\Drives]" > cdrom.reg
echo "\\"d:\\"=\\"cdrom\\"" >> cdrom.reg
echo "\\"e:\\"=\\"cdrom\\"" >> cdrom.reg
regedit cdrom.reg
sleep 5

cd "$REPERTOIRE/ressources/"
#downloading dlls required for music
POL_SetupWindow_wait_next_signal "PlayOnLinux is downloading DLLs required for displaying help" "$TYTUL"

#dmband.dll (size 28.0KB)
if [ "`sha1sum < dmband.dll | sed 's/ .*//'`" != "72d574b557865850247e58ee69af84e37ef75ac2" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmband.dll" --output-document=dmband.dll
fi

#dmcompos.dll (size 60.0KB)
if [ "`sha1sum < dmcompos.dll | sed 's/ .*//'`" != "bc775f826398e9c6a656acbd41808217c995781e" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmcompos.dll" --output-document=dmcompos.dll
fi

#dmime.dll (size 177.0KB)
if [ "`sha1sum < dmime.dll | sed 's/ .*//'`" != "4dd11c042fd420325044ea379935a10102b0cc00" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmime.dll" --output-document=dmime.dll
fi

#dmloader.dll (size 35.0KB)
if [ "`sha1sum < dmloader.dll | sed 's/ .*//'`" != "4250676edacc33c54c6db511c812ff71571c305a" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmloader.dll" --output-document=dmloader.dll
fi

#dmsynth.dll (size 101.0KB)
if [ "`sha1sum < dmsynth.dll | sed 's/ .*//'`" != "7a7843d5f385795d6cc18f86e78c191ecd524424" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmsynth.dll" --output-document=dmsynth.dll
fi

#dmusic.dll (size 102.0KB)
if [ "`sha1sum < dmusic.dll | sed 's/ .*//'`" != "4eb4aa8f545c0073d012bfc69ceb837098db4f2e" ]; then
wget --referer="http://www.dlldump.com" "http://www.dlldump.com/dllfiles/D/dmusic.dll" --output-document=dmusic.dll
fi

#dmstyle.dll (size 103.5KB)
if [ "`sha1sum < dmstyle.dll.zip | sed 's/ .*//'`" != "e860c26e23310a5765c2e2110e40c5c076503643" ]; then
wget "http://www.dllbank.com/zip/d/dmstyle.dll.zip" --output-document=dmstyle.dll.zip
fi
unzip dmstyle.dll.zip

POL_SetupWindow_detect_exit

#starting installation
POL_SetupWindow_wait_next_signal "Installation in progress..." "$TYTUL"
cd "$CDROM"
wine "Setup.exe"
POL_SetupWindow_detect_exit

#asking about memory size
POL_SetupWindow_menu_list "How much memory do your graphic card have got?" "$TYTUL" "32-64-128-256-384-512-768-890-1024-2048" "-" "256"
VMS="$APP_ANSWER"
 
echo "[HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\Direct3D]" > vms.reg
echo "\\"VideoMemorySize\\"=\\"$VMS\\"" >> vms.reg
regedit vms.reg

#copying dlls required for music
cd "$WINEPREFIX/drive_c/windows/system32"
cp -f "$REPERTOIRE/ressources/dmband.dll" dmband.dll
cp -f "$REPERTOIRE/ressources/dmcompos.dll" dmcompos.dll
cp -f "$REPERTOIRE/ressources/dmime.dll" dmime.dll
cp -f "$REPERTOIRE/ressources/dmloader.dll" dmloader.dll
cp -f "$REPERTOIRE/ressources/dmsynth.dll" dmsynth.dll
cp -f "$REPERTOIRE/ressources/dmusic.dll" dmusic.dll
cp -f "$REPERTOIRE/ressources/dmstyle.dll" dmstyle.dll

#overriding dlls required for music
cd "$WINEPREFIX/drive_c/windows/temp"
echo "[HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\DllOverrides]" > override.reg
echo "\\"dmband\\"=\\"native\\"" >> override.reg
echo "\\"dmcompos\\"=\\"native\\"" >> override.reg
echo "\\"dmime\\"=\\"native\\"" >> override.reg
echo "\\"dmloader\\"=\\"native\\"" >> override.reg
echo "\\"dmsynth\\"=\\"native\\"" >> override.reg
echo "\\"dmusic\\"=\\"native\\"" >> override.reg
echo "\\"dmstyle\\"=\\"native\\"" >> override.reg
regedit override.reg

#asking about Pulseaudio
POL_SetupWindow_question "Do you want to use PulseAudio sound driver?\\nMore about this sound driver at art.ified.ca/?page_id=40" "$TYTUL"
if [ "$APP_ANSWER" == "TRUE" ]; then
	CHOSENWINEVERSION="$LATESTVERSION-PA"
	download_pulseudio
	prepare_patched_WineVesrsion "$LATESTVERSION"
	cd "$WINEPREFIX/drive_c/windows/temp/" 
	echo "[HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\Drivers]" > pa.reg
	echo "\\"Audio\\"=\\"pulse\\"" >> pa.reg
	regedit pa.reg
fi

#cleaning temp
#cd "$WINEPREFIX/drive_c/windows/temp/"
#rm -rf *

#making shortcut
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Piranha Bytes/Gothic/System" "GOTHIC.EXE" "" "$TYTUL" "" ""
Set_WineVersion_Assign "$CHOSENWINEVERSION" "$TYTUL"
POL_SetupWindow_message "$TYTUL has been installed successfully" "$TYTUL"

#asking about patching
POL_SetupWindow_question "Do you want to patch your game?" "$TYTUL" 
if [ "$APP_ANSWER" == "TRUE" ] ;then
patch_gothic2
fi

#asking about resolution
POL_SetupWindow_question "Every time you want to change game resolution\\nyou'll have to run this script again\\nDo you want to change resolution right now?" "$TYTUL" 
if [ "$APP_ANSWER" == "TRUE" ] ;then
Change_Resolution
fi

POL_SetupWindow_Close
exit