Skip to content

Instantly share code, notes, and snippets.

@cbeck88
Created July 30, 2017 05:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbeck88/03f04bb5dbe62f564fe8112182f8a47b to your computer and use it in GitHub Desktop.
Save cbeck88/03f04bb5dbe62f564fe8112182f8a47b to your computer and use it in GitHub Desktop.
play on linux install script for Civilization IV: Beyond the Sword, and the Fall from Heaven 2 mod
#!/bin/bash
# Date : (2013-06-26)
# Last revision : (2017-07-29)
# Wine version used : 2.13-staging
# Distribution used to test : xUbuntu 16.04
# Author : Jimmy Ramsmark, Chris Beck
# Licence : GPLv3
# Depend : msxml3, d3dx9
# This script was tested using the DVD version of `Civilization IV: Complete'
# version 1.74, bought in Sweden in 2011.
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
TITLE="Civilization IV: Complete Edition"
TITLECIV="Civilization IV"
TITLEBTS="Civilization IV - Beyond The Sword"
TITLEW="Civilization IV - Warlords"
TITLECOL="Civilization IV - Colonization"
TITLEFFH="Fall from Heaven II"
AUTHOR="Jimmy Ramsmark, Chris Beck"
#PREFIX="Civilization4"
#^ TODO Uncomment and restore old prefix after testing
OLDPREFIX="Civilization4"
PREFIX="Civilization4FFH"
WORKINGWINEVERSION="2.13-staging"
STEAM_ID_CIV="3900"
STEAM_ID_W="3990"
STEAM_ID_BTS="8800"
STEAM_ID_COL="16810"
FFH2="false"
FFH2_MEDIA="false"
# POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$PREFIX/left.jpg" "$TITLE"
POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$OLDPREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$OLDPREFIX/left.jpg" "$TITLE"
POL_SetupWindow_Init
POL_SetupWindow_SetID 1779
POL_Debug_Init
POL_SetupWindow_presentation "$TITLE" "Firaxis Games" "http://www.firaxis.com/" "$AUTHOR" "$PREFIX"
POL_Wine_SelectPrefix "$PREFIX"
POL_SetupWindow_InstallMethod "DVD,STEAM"
if [ "$INSTALL_METHOD" == "DVD" ]; then
# Let the user select a DVD
POL_SetupWindow_cdrom
# Check if this DVD is the Civilization IV DVD
POL_SetupWindow_check_cdrom "Autorun/Civ4Installer.ico"
fi
# Set and install the correct Wine version
POL_Wine_PrefixCreate "$WORKINGWINEVERSION"
# Install DirectX9
POL_Call POL_Install_d3dx9
if [ "$INSTALL_METHOD" == "DVD" ]; then
# Run installer
POL_Wine_WaitBefore "$TITLECIV"
POL_Wine start /unix "$CDROM/setup.exe"
POL_Wine_WaitExit "$TITLECIV"
#Patch Civilization IV: Beyond the sword to 3.19
cd "$POL_USER_ROOT/tmp"
POL_Download "http://files.playonlinux.com/Civ4BeyondTheSwordPatch3.19.exe" "c45f6e028f51db2386120a5861eabe7c"
POL_Wine_WaitBefore "$TITLECIV"
POL_Wine Civ4BeyondTheSwordPatch3.19.exe
POL_Wine_WaitExit "$TITLECIV"
else
POL_Call POL_Install_steam
# Start steam, update it, and install the games
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam"
POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_CIV
POL_SetupWindow_message "$(eval_gettext 'Steam is about to perform an update.\nAfter Steam finishes updating and shows you to the login interface, login and then let $TITLE install.\n\nWhen the installation is finished, press next (Do not close Steam)')" "$TITLECIV"
POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_W
POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLEW, press next when the installation is finished')" "$TITLECIV"
POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_BTS
POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLEBTS, press next when the installation is finished')" "$TITLECIV"
POL_Wine start /unix "Steam.exe" steam://install/$STEAM_ID_COL
POL_SetupWindow_message "$(eval_gettext 'Steam is installing $TITLECOL, please quit Steam properly when the installation is finished (make sure Steam is not still in the traybar) and then press next so that the installation script can continue.')" "$TITLECIV"
POL_Wine_WaitExit "$TITLECIV"
fi
# Install msxml3.msi
# Override for msxml3 is needed before the install
# The msvcr71 one is just there so that mods will work later on
POL_Wine_OverrideDLL "native" "msxml3"
POL_Wine_OverrideDLL "builtin" "msvcr71"
POL_Call POL_Install_msxml3
# Ask Fall From Heaven question
POL_SetupWindow_question "$(eval_gettext 'Do you want to install the Fall From Heaven II mod?')" "Fall from Heaven II"
if [ "$APP_ANSWER" == "TRUE" ]; then
FFH2="true"
POL_SetupWindow_question "$(eval_gettext 'Do you want to install the (optional) Fall From Heaven II media pack?')" "Fall from Heaven II media pack"
if [ "$APP_ANSWER" == "TRUE" ]; then
FFH2_MEDIA="true"
fi
fi
# Check prerequesites (need 7zip to silently install FFH2)
if [ "$FFH2" == "true" -a "$INSTALL_METHOD" == "STEAM" ]; then
if hash 7z 2>/dev/null; then
POL_Debug_Message "Found 7zip"
else
POL_SetupWindow_message "$(eval_gettext 'We could not find the program \"7z\".\n\n7zip is needed to continue with Fall from Heaven installation.\n\nPlease install it and click \"next\", or Fall from Heaven will be skipped.\n\nOn Debian and Ubuntu, you can use \"sudo apt-get install p7zip\".')" "Fall from Heaven II"
if hash 7z 2>/dev/null; then
POL_Debug_Message "Found 7zip on second try"
else
FFH2="false"
POL_Debug_Message "Didn't find 7zip on second try, skipping Fall From Heaven"
fi
fi
fi
# Install mods
if [ "$FFH2" == "true" ]; then
NSIS_ARGS=""
# Make a directory to hold FFH2 download
POL_System_TmpCreate "FFH2"
TMP="$POL_System_TmpDir"
cd "$TMP"
# HACK: The FFH installer can't find Civ IV when it was installed from Steam.
# We also can't pass it the correct installation directory, I think because it is a buggy @#$#@$!@#
# So, instead of running the installer we use 7zip.
#
# We make a symlink to the Mods dir named $_OUTDIR, this causes 7zip to do the right thing, and the
# symlink gets cleaned up when the temp folder is deleted.
#
# When we aren't installing from steam, we don't actually know the installation directory, so 7zip isn't
# an option. We just have to use the installers, and the user has to retype the installation directory three times.
if [ "$INSTALL_METHOD" == "STEAM" ]; then
ln -s "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam/steamapps/common/Sid Meier's Civilization IV Beyond the Sword/Beyond the Sword/Mods" \$_OUTDIR
fi
# Download FFH2 installer
# POL_Download "http://www.moddb.com/downloads/mirror/16159/114/c2856c8897dd4e0045f8b1252ce4e368" "c64b7408ea844d276e272815a7fbea9e"
# Rename the wget'd file... thanks moddb
# mv c2856c8897dd4e0045f8b1252ce4e368 FallfromHeaven2041n.exe
# TODO: moddb url doesn't seem compatible with POL_Download... find a stable download location
POL_Download "http://chrisbeck.co/FallfromHeaven2041n.exe" "c64b7408ea844d276e272815a7fbea9e"
POL_Wine_WaitBefore "$TITLE_CIV"
if [ "$INSTALL_METHOD" == "STEAM" ]; then
7z x -y "FallfromHeaven2041n.exe"
else
POL_Wine start /unix "FallfromHeaven2041n.exe" "$NSIS_ARGS"
fi
POL_Wine_WaitExit "$TITLE_CIV"
# Download FFH2 patch o (final release)
POL_Download "http://kael.civfanatics.net/files/FfH2041o.exe" "e30116d7356be06dc0780aac74fd6594"
POL_Wine_WaitBefore "$TITLE_CIV"
if [ "$INSTALL_METHOD" == "STEAM" ]; then
7z x -y "FfH2041o.exe"
else
POL_Wine start /unix "FfH2041o.exe" "$NSIS_ARGS"
fi
POL_Wine_WaitExit "$TITLE_CIV"
if [ "$FFH2_MEDIA" == "true" ]; then
# Download FFH2 Media Pack
POL_Download "http://kael.civfanatics.net/files/FfH2media.exe" "9bd3a25008a50225975126a1c066fc80"
POL_Wine_WaitBefore "$TITLE_CIV"
if [ "$INSTALL_METHOD" == "STEAM" ]; then
7z x -y "FfH2media.exe"
else
POL_Wine start /unix "FfH2media.exe" "$NSIS_ARGS"
fi
POL_Wine_WaitExit "$TITLE_CIV"
fi
cd "$WINEPREFIX/drive_c/"
POL_System_TmpDelete
fi
#Create shortcuts
if [ "$INSTALL_METHOD" == "STEAM" ]; then
POL_Shortcut "Steam.exe" "TEST $TITLECIV" "$TITLECIV.png" "-applaunch $STEAM_ID_CIV" "Game;StrategyGame;"
POL_Shortcut "Steam.exe" "TEST $TITLEBTS" "$TITLEBTS.png" "-applaunch $STEAM_ID_BTS" "Game;StrategyGame;"
POL_Shortcut "Steam.exe" "TEST $TITLEW" "$TITLEW.png" "-applaunch $STEAM_ID_W" "Game;StrategyGame;"
POL_Shortcut "Steam.exe" "TEST $TITLECOL" "$TITLECOL.png" "-applaunch $STEAM_ID_COL" "Game;StrategyGame;"
POL_Shortcut "Steam.exe" "TEST Steam - Civ IV" "" "" "Game;"
# TODO remove TEST from these shortcut names after testing
if [ "$FFH2" == "true" ]; then
POL_Shortcut "Steam.exe" "$TITLEFFH" "$TITLEBTS.png" "-applaunch $STEAM_ID_BTS mod='\Fall from Heaven 2'" "Game;StrategyGame;"
# TODO: Get a proper FFH image here
# There is an icon.bmp in the mod folder that is appropriate
fi
else
POL_Shortcut "Civilization4.exe" "TEST $TITLECIV" "$TITLECIV.png" "" "Game;StrategyGame;"
POL_Shortcut "Civ4BeyondSword.exe" "TEST $TITLEBTS" "$TITLEBTS.png" "" "Game;StrategyGame;"
POL_Shortcut "Civ4Warlords.exe" "TEST $TITLEW" "$TITLEW.png" "" "Game;StrategyGame;"
if [ "$FFH2" == "true" ]; then
POL_Shortcut "Civ4BeyondSword.exe" "$TITLEFFH" "$TITLEBTS.png" "mod='\Fall from Heaven 2'" "Game;StrategyGame;"
fi
fi
#Done!
POL_SetupWindow_message "$(eval_gettext 'Installation finished\n')" "$TITLECIV"
POL_SetupWindow_Close
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment