@@ -1,135 +1,236 @@
#!/bin/bash
-# Date : (2009-05-29 18-00)
-# Last revision : (2010-01-03 22-00)
-# Wine version used : 1.1.35
-# Distribution used to test : Fedora 12
-# Author : NSLW
+# Date : (2009-05-29)
+# Last revision : see the changelog below
+# Wine version used : see the changelog below
+# Distribution used to test : XUbuntu 18.04 64 bits
+# Author : Dadu042
# Licence : Retail
+#
+# TESTED Editions: retail DVD-ROM v1.0 (FR/EN/DE) .
+#
+# Middlewares used by this software : vcrun2008, Bink.
+#
+# CHANGELOG
+# [NSLW] (2009-05-29 18-00)
+# Initial script.
+# [Dadu042] (2020-01-14 20:30)
+# Rewrite script.
+# Still needed ?: gecko, dotnet20
+#
+# KNOWN ISSUES:
+# - Wine amd64 4.0.3: crash when launching a race.
+#
+# KNOWN ISSUES (FIXED):
+# - Wine amd64 4.0.3: X
+
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
-
-TYTUL="Race Driver : GRID"
-PREFIX="GRID"
-WORKINGWINEVERSION="1.1.37"
-
-#procedure for patching GRID
-patch_grid()
-{
-POL_SetupWindow_browse "Select patch file downloaded from www.codemasters.com" "$TYTUL" ""
-wine "$APP_ANSWER"
-POL_SetupWindow_message "Patch for $TYTUL has been installed successfully" "$TYTUL"
-}
-
-POL_SetupWindow_make_icon_for_shortcut()
-{
-convert "$HOME/.local/share/icons/$2" -geometry 32X32 "$REPERTOIRE/icones/32/$1"
-}
-
+
+TITLE="Race Driver: Grid"
+PREFIX="race_driver_grid"
+EDITOR="Codemasters"
+AUTHOR="Dadu042"
+STEAM_ID=""
+GAME_VMS="256"
+SHORTCUT_FILENAME="GRID.exe"
+SOFTWARE_CATEGORIES="Game;SportsGame;"
+DOCUMENT_FILE="Readme.html"
+
+# Starting the script
POL_SetupWindow_Init
-POL_SetupWindow_presentation "$TYTUL" "Codemasters" "www.racedrivergrid.com" "NSLW" "$PREFIX"
-
-select_prefix "$REPERTOIRE/wineprefix/$PREFIX"
-
-#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" "~"
-
-if [ "$APP_ANSWER" == "Patch game" ]; then
- patch_grid
-fi
+
+# Starting debugging API
+POL_Debug_Init
+
+# Open dialogue box
+POL_SetupWindow_presentation "$TITLE" "$EDITOR" "$GAME_URL" "$AUTHOR" "$PREFIX"
+
+# POL_SetupWindow_message "$(eval_gettext 'WARNING: this software does exist in Linux native version.\n\nThis script only allow to run the Windows version on Linux, please prefer the Linux edition for better 3D speed.')" "$TITLE"
+
+# POL_SetupWindow_message "$(eval_gettext 'This game requires a fast 3D GPU (ie: Intel HD Graphics 4440 is not enough).')" "$TITLE"
+
+POL_RequiredVersion "4.0.0" || POL_Debug_Fatal "$APPLICATION_TITLE $VERSION is required to install $TITLE"
+
+# Setting prefix path
+POL_Wine_SelectPrefix "$PREFIX"
+
+# Determine Architecture
+# POL_System_SetArch "amd64"
+POL_System_SetArch "x86"
+
+# Downloading wine if necessary and creating prefix
+POL_Wine_PrefixCreate "3.0.3"
+
+POL_System_TmpCreate "$PREFIX"
+
+Set_OS "win7"
+
+#######################################
+# Installing mandatory dependencies #
+#######################################
+
+# POL_Call POL_Install_dotnet40
+# POL_Call POL_Install_mfc42
+# POL_Call POL_Install_dsound
+# POL_Call POL_Install_riched30
+# POL_Call POL_Install_phzysx
+# POL_Call POL_Install_corefonts
+# POL_Call POL_Install_d3dx11
+# POL_Call POL_Install_mono210
+
+
+################
+# GPU #
+################
-POL_SetupWindow_Close
-exit
-fi
-
-POL_SetupWindow_message "Please insert $TYTUL media into your disk drive."
-POL_SetupWindow_cdrom
-POL_SetupWindow_check_cdrom "setup.exe"
-
-POL_SetupWindow_install_wine "$WORKINGWINEVERSION"
-Use_WineVersion "$WORKINGWINEVERSION"
-POL_SetupWindow_prefixcreate
-
-#fetching PROGRAMFILES environmental variable
-PROGRAMFILES=`wine cmd /c echo "%ProgramFiles%" |tr -d '\015' | tr -d '\010'`
-PROGRAMFILES=${PROGRAMFILES:3}
-
-#adding CD-ROM as drive d: to winecfg
-cd "$WINEPREFIX/dosdevices"
-ln -s "$CDROM" e:
-
-cd "$WINEPREFIX/drive_c/windows/temp/"
-echo "[HKEY_LOCAL_MACHINE\\Software\\Wine\\Drives]" > cdrom.reg
-echo "\"d:\"=\"cdrom\"" >> cdrom.reg
-regedit cdrom.reg
-
-sleep 5
-
-mkdir "$HOME/.winetrickscache"
-cd "$HOME/.winetrickscache"
-# checking if gecko is in wine tricks cache if not then download
-if [ ! -e "wine_gecko-1.0.0-x86.cab" ]
-then
-fi
-
-#downloading .NET Framework 2.0
-if [ ! -e "$HOME/.winetrickscache/dotnet20/dotnetfx.exe" ]
-then
-mkdir "$HOME/.winetrickscache/dotnet20"
-cd "$HOME/.winetrickscache/dotnet20"
-fi
-
-cd "$REPERTOIRE/ressources/"
-#downloading winetricks
-if [ "`sha1sum < winetricks | sed 's/ .*//'`" != "56122055e5c3ce25bc708caa175a7ca3acf0577a" ]; then
-fi
+# Asking about memory size of graphic card
+POL_SetupWindow_VMS $GAME_VMS
+
+# Set Graphic Card information keys for wine
+POL_Wine_SetVideoDriver
+
+# Useful for Nvidia GPUs
+POL_Call POL_Install_physx
+
+
+#############################################
+# Sound problem fix - pulseaudio related #
+#############################################
+# [ "$POL_OS" = "Linux" ] && Set_SoundDriver "alsa"
+# [ "$POL_OS" = "Linux" ] && Set_SoundEmulDriver "Y"
+## End Fix
+
-#installing .NET Framework 2.0
-POL_SetupWindow_wait_next_signal "Installing .NET Framework 2.0..." "$TYTUL"
-bash winetricks -q dotnet20
-POL_SetupWindow_detect_exit
-
-#starting installation
-cd "$CDROM"
-wine "setup.exe"
-POL_SetupWindow_message "Click \"Next\" when installation will finish." "$TYTUL"
-POL_SetupWindow_message "$TYTUL has been installed successfully" "$TYTUL"
-
-cd "$WINEPREFIX/drive_c/windows/temp"
-#setting multisample to enabled
-echo "[HKEY_CURRENT_USER\\Software\\Wine\\Direct3D]" > multisampling.reg
-echo "\"Multisampling\"=\"enabled\"" >> multisampling.reg
-regedit multisampling.reg
-
-#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
-
-#making shortcut
-POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Codemasters/GRID" "GRID.exe" "" "$TYTUL" "" ""
-Set_WineVersion_Assign "$WORKINGWINEVERSION" "$TYTUL"
-POL_SetupWindow_make_icon_for_shortcut "$TYTUL" "*_grid.0.png"
-
-#asking about patching
-POL_SetupWindow_question "Do you want to patch your game?" "$TYTUL"
-if [ "$APP_ANSWER" == "TRUE" ] ;then
-patch_grid
+#######################################
+# Main part of this script #
+#######################################
+
+# Choose between Steam and other Digital Download versions
+# POL_SetupWindow_InstallMethod "STEAM,DVD,LOCAL,DOWNLOAD"
+POL_SetupWindow_InstallMethod "LOCAL,DVD"
+
+POL_SetupWindow_message "Warning: do not install DirectX." "$TITLE"
+
+# Begin game installation
+if [ "$INSTALL_METHOD" == "STEAM" ]; then
+ POL_Call POL_Install_steam
+ # Mandatory pre-install fix for steam
+ POL_Call POL_Install_steam_flags "$STEAM_ID"
+ # Shortcut done before install for steam version
+ # Steam install
+ POL_SetupWindow_message "$(eval_gettext 'When $TITLE download by Steam is finished,\nDo NOT click on Play.\n\nClose COMPLETELY the Steam interface, \nso that the installation script can continue')" "$TITLE"
+ cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam"
+ POL_Wine_WaitExit "$TITLE"
+
+elif [ "$INSTALL_METHOD" == "DVD" ]; then
+ POL_SetupWindow_cdrom
+
+ # POL_Call POL_Function_NoCDWarning
+
+ POL_SetupWindow_check_cdrom "ISSetup.dll"
+ POL_Wine start /unix "$CDROM/setup.exe"
+
+ POL_Wine_WaitExit "$TITLE"
+
+ # Restore screen resolution (game's default is 800x600 ?)
+ # POL_Shortcut_InsertBeforeWine "$SHORTCUT" "trap 'xrandr -s 0' EXIT"
+
+ POL_Shortcut "$SHORTCUT_FILENAME" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+ POL_Shortcut_Document "$TITLE" "$DOCUMENT_FILE"
+
+
+elif [ "$INSTALL_METHOD" == "DOWNLOAD" ]; then
+ cd "$WINEPREFIX/drive_c"
+ # POL_SetupWindow_message "$(eval_gettext 'Note: this script can only download the demo.')" "$TITLE"
+ # POL_SetupWindow_message "$(eval_gettext 'Note: we recommend you to uncheck all the checkboxes:\n[x] -> [ ]')" "$TITLE"
+
+ POL_Wine "setuprebuilt.exe" # "/SILENT"
+ POL_Wine_WaitBefore "$TITLE"
+ POL_Shortcut "$SHORTCUT_FILENAME" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+ POL_Shortcut_QuietDebug "$TITLE"
+
+ # Restore screen resolution (game's default is 1024x768 ?)
+ POL_Shortcut_InsertBeforeWine "$SHORTCUT" "trap 'xrandr -s 0' EXIT"
+
+ # POL_Shortcut "l.exe" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+ POL_Shortcut_Document "$TITLE" "$DOCUMENT_FILE"
+
+elif [ "$INSTALL_METHOD" == "LOCAL" ]; then
+ # POL_SetupWindow_menu "$(eval_gettext 'What is the type of the file?.')" "$TITLE" "$(eval_gettext '.EXE')~$(eval_gettext '.ZIP')~$(eval_gettext '.RAR')" "~"
+ POL_SetupWindow_menu "$(eval_gettext 'What is the type of the file?.')" "$TITLE" "$(eval_gettext '.ZIP')~$(eval_gettext '.EXE')~$(eval_gettext '.RAR')" "~"
+ # APP_ANSWER=".EXE"
+
+if [ "$APP_ANSWER" == ".EXE" ]; then
+ # Asking then installing local files of the game
+ cd "$HOME"
+ POL_SetupWindow_browse "$(eval_gettext 'Please select the setup file to run')" "$TITLE"
+ SETUP_EXE="$APP_ANSWER"
+ POL_Wine start /unix "$SETUP_EXE"
+ POL_Wine_WaitExit "$TITLE"
+
+ # Restore screen resolution (game's default is 640x480 ?)
+ # POL_Shortcut_InsertBeforeWine "$SHORTCUT" "trap 'xrandr -s 0' EXIT"
+
+ POL_Shortcut "$SHORTCUT_FILENAME" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+ # POL_Shortcut_QuietDebug "$TITLE"
+
+ # POL_Shortcut_Document "$TITLE" "$DOCUMENT_FILE"
+
+elif [ "$APP_ANSWER" == "$(eval_gettext '.ZIP')" ]; then
+ cd "$HOME"
+
+ POL_SetupWindow_message "$(eval_gettext '\n\nWARNING: the file name must not have SPACES in its name (otherwise: unzip error 9).')" "$TITLE"
+
+ POL_SetupWindow_browse "$(eval_gettext 'Please select the .ZIP file')" "$TITLE"
+ SETUP_EXE="$APP_ANSWER"
+ cd "$POL_System_TmpDir"
+ POL_SetupWindow_wait_next_signal "$(eval_gettext 'Extracting the archive...')" "$TITLE"
+ POL_System_unzip "$APP_ANSWER" -d "$WINEPREFIX/drive_c/game/"
+ POL_Shortcut "$SHORTCUT_FILENAME" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+
+ POL_Shortcut_Document "$TITLE" "$DOCUMENT_FILE"
+
+elif [ "$APP_ANSWER" == "$(eval_gettext '.RAR')" ]; then
+ cd "$HOME"
+ POL_SetupWindow_browse "$(eval_gettext 'Please select the .RAR file')" "$TITLE"
+ SETUP_EXE="$APP_ANSWER"
+ cd "$POL_System_TmpDir"
+ POL_SetupWindow_wait_next_signal "$(eval_gettext 'Extracting the archive...')" "$TITLE"
+ POL_System_unrar x "$APP_ANSWER" "$WINEPREFIX/drive_c/game/" || POL_Debug_Fatal "unrar is required to unarchive $TITLE (unrar package is not installed on the OS)."
+ POL_Shortcut "$SHORTCUT_FILENAME" "$TITLE" "" "" "$SOFTWARE_CATEGORIES"
+fi
+fi
+
+# sed -e 's/maxWidth="1280"/maxWidth="1920"/' -i "$WINEPREFIX/drive_c/GOG Games/Race Driver GRID/system/hardware_settings_restrictions.xml"
+
+################
+# Patch update #
+################
+
+POL_SetupWindow_menu "$(eval_gettext 'Do you want to install a official patch-update ?\n (to download by yourself).')" "$TITLE" "$(eval_gettext 'Yes')~$(eval_gettext 'No')" "~"
+
+if [ "$APP_ANSWER" == "$(eval_gettext 'Yes')" ]; then
+ POL_SetupWindow_browse "$(eval_gettext 'Please select the file to run')" "$TITLE"
+ PATCH_EXE="$APP_ANSWER"
+ POL_Wine start /unix "$PATCH_EXE"
+ POL_Wine_WaitExit "$PATCH_EXE"
fi
+
+# POL_SetupWindow_message "$(eval_gettext '\nInstallation is finished ! :)')" "$TITLE"
-#cleaning temp
-cd "$WINEPREFIX/drive_c/windows/temp/"
-rm -rf *
-
-POL_SetupWindow_message_image "Please note that this game has a copy protection system\nand sadly, it prevents Wine from running the game.\n\nPlayOnLinux will not provide any help concerning any illegal\nstuff." "Note about copy protection" "$PLAYONLINUX/themes/tango/warning.png"
+# POL_SetupWindow_message "$(eval_gettext 'WARNING: to avoid to have huge log file, you should type \ninto Debug flags : fixme-all')" "$TITLE"
+
+# Fail ?
+# POL_SetupWindow_message "$LNG_FIN" "$TITLE"
+POL_System_TmpDelete
POL_SetupWindow_Close
-exit
\ No newline at end of file
+exit 0
\ No newline at end of file