Skip to content

Instantly share code, notes, and snippets.

@Yepoleb
Last active December 8, 2015 14:50
Show Gist options
  • Save Yepoleb/a5b9a24e212fa6350fa1 to your computer and use it in GitHub Desktop.
Save Yepoleb/a5b9a24e212fa6350fa1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env playonlinux-bash
# Date : (2015-12-07 06-36)
# Last revision : (2015-12-07 06-36)
# Wine version used : 1.6.2
# Distribution used to test : Debian Sid (Unstable)
# Author : Gabriel Huber [email protected]
# Script licence : GPL v.2
# Program licence : Retail
# Depend :
[ -z "$PLAYONLINUX" ] && exit 0
source "$PLAYONLINUX/lib/sources"
GOGID="rollercoaster_tycoon_2"
PREFIX="RollerCoasterTycoon2_inno"
WORKING_WINE_VERSION="1.6.2"
TITLE="GOG.com - RollerCoaster Tycoon 2"
SHORTCUT_NAME="RollerCoaster Tycoon 2: Triple Thrill Pack"
# Manually set the install location because we're not using the installer
# Has to match with the one in the registry patch for the DRM to work
INSTALL_LOCATION="drive_c/GOG Games/RollerCoaster Tycoon 2 Triple Thrill Pack/"
#POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$PREFIX/left.jpg" "$TITLE"
POL_SetupWindow_Init
POL_SetupWindow_SetID 1481
POL_Debug_Init
POL_SetupWindow_presentation "$TITLE" "Chris Sawyer Productions / Atari" "http://www.gog.com/game/$GOGID" "Gabriel Huber" "$PREFIX"
# Check if we have innoextract
if ! innoextract --version >/dev/null 2>&1; then
POL_SetupWindow_message "Could not find innoextract binary. Install the \"innoextract\" package or see http://constexpr.org/innoextract for more information on how to install, then run the script again."
POL_SetupWindow_Close
exit $EXIT_ERROR
else
POL_Debug_Message "Found innoextract"
fi
# Get setup path
POL_Call POL_GoG_setup "$GOGID" "40c7dee00c3451ac0d484df0e384f22e"
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"
POL_System_TmpCreate "$PREFIX"
POL_SetupWindow_pulsebar "Extracting game files..." "$TITLE"
# Extract installer data
INNO_LOGFILE="$POL_System_TmpDir/innoextract.log"
LAST_PERCENTAGE="0"
# Fix return code for piped commands
set -o pipefail
# -e = extract, -q = quiet, -c = no color, -p = enable progress bar, -d = output directory
innoextract -e -q -c 0 -p 1 -d "$POL_System_TmpDir" "$POL_GoG_location" | tee "$INNO_LOGFILE" | while read -d $'\r' input
do
PERCENTAGE=`echo "$input" | grep -o -P '\d+(?=\.\d+%)'`
if [ "$PERCENTAGE" ] && [ "$PERCENTAGE" -ne "$LAST_PERCENTAGE" ]
then
# Wait for the last pulse update to finish, so we don't spawn to many processes
wait
# Run the command asyncronously because it takes about 300ms to finish
POL_SetupWindow_pulse "$PERCENTAGE" &
LAST_PERCENTAGE="$PERCENTAGE"
fi
done
# Wait for the last percentage update to finish
wait
# Check return code of innoextract and show the logfile if it failed
if [ $? -ne 0 ]
then
POL_SetupWindow_file "Failed to extract files. Check if innoextract is up to date and the input file is valid. Read logfile for more information:" "$TITLE" "$INNO_LOGFILE"
POL_SetupWindow_Close
exit $EXIT_ERROR
fi
# The localized versions can have files with leading whitespace.
# This is not intended and may cause problems, so we remove them.
# Find files with leading whitespace characters.
find "$POL_System_TmpDir/app" -name " *" -print0 | while read -d $'\0' filename
do
BASE=`basename "$filename"`
DIR=`dirname "$filename"`
# Replace leading whitespace with nothing
BASE_TRIM=`echo "$BASE" | sed -e "s/^ *//"`
# Rename the file
mv "$filename" "$DIR/$BASE_TRIM"
done
INSTALL_PATH="$WINEPREFIX/$INSTALL_LOCATION"
# Remove the install folder if it exists
if [ -e "$INSTALL_PATH" ]; then
rm -r "$INSTALL_PATH"
fi
# Make sure parent directory exists
mkdir -p "$(dirname "$INSTALL_PATH")"
# Move the app folder
mv "$POL_System_TmpDir/app" "$INSTALL_PATH"
# Apply the registry patch
cat > "$POL_System_TmpDir/rct2.reg" << EOF
REGEDIT4
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"Title"="Roll"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"Path"="C:\\\\GOG Games\\\\RollerCoaster Tycoon 2 Triple Thrill Pack"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"SetupPath"="C:\\\\GOG Games\\\\RollerCoaster Tycoon 2 Triple Thrill Pack"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"Executable"="RCT2.exe"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"FontPointSize"=dword:0000000c
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"Language"=dword:00000000
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"CDKey"=dword:00000000
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"CharSet"=dword:00000000
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"FontFaceName"="MS Sans Serif"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"OKPrompt"="OK"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"CancelPrompt"="Cancel"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"InstallLevel"=dword:00000001
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"AddOnPack1"="Wacky Worlds!"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Infogrames\\RollerCoaster Tycoon 2 Setup]
"AddOnPack2"="Time Twister!"
EOF
POL_Wine regedit "$POL_System_TmpDir/rct2.reg"
POL_System_TmpDelete
POL_SetupWindow_VMS "64"
# Doesn't hurt ;)
POL_Wine_reboot
POL_Shortcut "RCT2.EXE" "$SHORTCUT_NAME" "" "" "Game;Simulation;"
POL_Shortcut_Document "$SHORTCUT_NAME" "${INSTALL_PATH}manual.pdf"
POL_SetupWindow_message "Installation complete." "$TITLE"
POL_SetupWindow_Close
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment