Playing Life Is Strange: Before the Storm on Linux using Wine

This doesn’t really need much explanation since it’s platinum on WineHQ at the moment. If you know how Wine works, you don’t need the info in this post; but if you need a push then this can help. Basically the script, like in other posts I’ve made, will simply install steam and set everything up for you. Then, you have to install the game via Steam and you’re good to go. The desktop file at the end of the post is just for simplicity so that it’s easier to run, but you can run it manually or just create another launcher if you want.

I will gradually make my install scripts better, but this works for now. I’ve always used PlayOnLinux before, but since that platform hasn’t gotten much love lately; I decided to abandon it. I’ve tried multiple times to update my scripts on POL, but nothing ever happens since you need an admin to accept your changes all the time. Thus, I have decided to simply make bash scripts to install all my games, and share my results here. The goal is to have a general script template that I can use (that makes it more user friendly) that helps me and others to install games on Linux using Wine (without making it a larger project like POL). Anyway, enjoy :- ).

https://appdb.winehq.org/objectManager.php?sClass=version&iId=35717

But I’ll include the Steam install script anyway, plus the desktop file to launch it. An important detail about installing this, is that it has to be installed in a 64-bit prefix in Wine.

if ! [ -x "$(command -v wine)" ]; then
        echo "Installing latest wine"
        #Update all repos
        sudo apt-get update

        #Enable 32bit (If you're on 64bit)
        sudo dpkg --add-architecture i386

        #Add wine repo
        wget -nc https://dl.winehq.org/wine-builds/Release.key
        sudo apt-key add Release.key
        sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/

        #Install wine-devel (3.11)
        sudo apt-get update
        sudo apt-get install --install-recommends winehq-devel
fi

#Install latest winetricks
echo "Installing latest winetricks"
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv winetricks /usr/bin

echo "Installing Steam and various"
mkdir -p ~/.wine-apps/lis
WINEARCH=win64 WINEPREFIX=~/.wine-apps/lis/ winetricks tahoma corefonts ie8 allfonts steam

if you get an error saying “The content servers are unreachable” when trying to install the game via steam, then the following Reddit thread might be able to help you with that.

Also, if you want to have a launcher that you can search for in Unity or Gnome, then just create the file steam-lis.desktop with this content (replace USER with your username).

sudo vim /usr/share/applications/steam-lis.desktop

[Desktop Entry]
Name=Steam Life Is Strange - Before The Storm
Exec=env WINEPREFIX="/home/USER/.wine-apps/lis/" wine "/home/USER/.wine-apps/lis/drive_c/Program Files (x86)/Steam/Steam.exe" -no-cef-sandbox
Type=Application
StartupNotify=true
Path="/home/USER/.wine-apps/lis/drive_c/Program Files (x86)/Steam/"
Icon=BAC4_steam.0
StartupWMClass=steam.exe
Name[en_US]=Steam - Life Is Strange - Before The Storm

 

 

Playing Final Fantasy XIV (FFXIV) on Linux using Wine

There’s a pretty neat Reddit thread about this issue, but I don’t want to use Gallium so I just made a simple script to install it for me. Since it took a bit of experimenting to get it work (In the end it was all about the wine version, and not many other prerequisites were needed) I’m posting it in case others find it useful. Note that the last line is how you start the game later, so just make a start script or a desktop shortcut to start it afterwards.

Distro: Ubuntu 18.04 (x64)

if ! [ -x "$(command -v wine)" ]; then
	echo "Installing latest wine"
	#Update all repos
	sudo apt-get update
 
	#Enable 32bit (If you're on 64bit)
	sudo dpkg --add-architecture i386

	#Add wine repo
	wget -nc https://dl.winehq.org/wine-builds/Release.key
	sudo apt-key add Release.key
	sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
 
	#Install wine-stable (3.0.1)
	sudo apt-get update
	sudo apt-get install --install-recommends winehq-stable
fi

echo "Installing latest winetricks"
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv winetricks /usr/bin

echo "Creating FFXIV Wine prefix"
mkdir ~/.ffxiv
cd ~/.ffxiv

echo "Downloading FFXIV setup file"
wget http://gdl.square-enix.com/ffxiv/inst/ffxivsetup.exe

echo "Installing required files with winetricks"
WINEARCH=win32 WINEPREFIX=~/.ffxiv winetricks -q corefonts allfonts tahoma #ie8 wininet winhttp wmp9 wmp10 xinput ie8_kb2936068 devenum quartz hosts win7

echo "Installing game client"
WINEARCH=win32 WINEPREFIX=~/.ffxiv wine ffxivsetup.exe

echo "Starting game client. Please login and install the game"
cd "drive_c/Program Files/SquareEnix/FINAL FANTASY XIV - A Realm Reborn/boot"
WINEARCH=win32 WINEPREFIX=~/.ffxiv wine ffxivboot.exe

 

Playing visual novels on Linux using Wine

So I play a lot of visual novels these days. One problem is that most of them are only released on Windows, and I don’t use Windows. So for that I use Wine. Below is a simple script to setup Steam with Wine so that you can play the visual novels available through Steam. Make sure you check the visual novel on steam before you use this solution however, since some of them do have Linux support and can be run via the Steam Linux client.

Distro: Ubuntu 18.04 (x64)

if ! [ -x "$(command -v wine)" ]; then
	echo "Installing latest wine"
	#Update all repos
	sudo apt-get update

	#Enable 32bit (If you're on 64bit)
	sudo dpkg --add-architecture i386

	#Add wine repo
	wget -nc https://dl.winehq.org/wine-builds/Release.key
	sudo apt-key add Release.key
	sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/

	#Install wine-stable (3.0.1)
	sudo apt-get update
	sudo apt-get install --install-recommends winehq-stable
fi

#Install latest winetricks
echo "Installing latest winetricks"
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv winetricks /usr/bin

echo "Installing Steam and various"
mkdir -p ~/.wine-apps/steam
WINEARCH=win32 WINEPREFIX=~/.wine-apps/steam/ winetricks tahoma corefonts ie8 allfonts steam

echo "Login to steam and install the Visual Novel"

 

Also, if you need a desktop icon for the Steam client, you can put it in the file /usr/share/applications/steam-windows.desktop (Remember to replace USER with your username).

[Desktop Entry]
Name=Steam
Exec=env WINEPREFIX="/home/USER/.wine-apps/steam" wine "/home/USER/.wine-apps/steam/drive_c/Program Files/Steam/Steam.exe" -no-cef-sandbox
Type=Application
StartupNotify=true
Path=/home/USER/.wine-apps/steam/dosdevices/c:/Program Files/Steam
Icon=BAC4_steam.0
StartupWMClass=steam.exe
Name[en_US]=Steam - Windows

 

For other visual novels not on Steam, I just create a folder called “Games” under “/home/USER/.wine-apps/steam/dosdevices/c:/Program Files/” and put them there. Then you can add another shortcut to that specific game like below.

[Desktop Entry]
Name=VisualNovel
Exec=env WINEPREFIX="/home/USER/.wine-apps/steam" wine "/home/USER/.wine-apps/steam/drive_c/Program Files/Games/VN/VisualNovel.exe"
Type=Application
StartupNotify=true
Path=/home/USER/.wine-apps/steam/dosdevices/c:/Program Files/Games
Icon=/path/to/icon/file
StartupWMClass=VisualNovel.exe
Name[en_US]=VisualNovel

For steam download issue: https://www.reddit.com/r/wine_gaming/comments/8r0gh6/steam_in_winedevel_content_servers_unreachable/

Also, some visual novels outside of Steam may run into all sorts of problems. You can install a separate Wine prefix for that and do individual settings for such games. The following worked for me for one game that crashed when going into full screen. Generally I try to stick with the ones on Steam as I keep having the most luck with them using Wine. Sometimes they simply aren’t available though.

mkdir -p ~/.wine-apps/vn
WINEARCH=win32 WINEPREFIX=~/.wine-apps/vn/ winetricks tahoma corefonts ie8 allfonts d3dx9_36 wmp9 quartz ddr=gdi win7

#Start game
env WINEPREFIX="/home/USER/.wine-apps/vn" wine "/home/USER/.wine-apps/vn/drive_c/Program Files/Games/vn/vn.exe"

 

Installing EiskaltDC++ 2.2.10 on Ubuntu 18.04

Nothing really special, I just keep forgetting which packages I need (And it’s bothersome to keep going through the list of requirements). So here’s a quick guide/script of how to download and compile it. Mostly for myself, but I thought maybe someone else could make use of it.

sudo apt-get -y build-dep eiskaltdcpp-qt eiskaltdcpp eiskaltdcpp-cli eiskaltdcpp-common libeiskaltdcpp-devlibeiskaltdcpp-dev

sudo apt-get -y install libqt5core5a qt5-default qttools5-dev-tools qtmultimedia5-dev libbz2-dev libssl1.0-dev libidn11-dev libboost1.65-dev libaspell-dev libre2-dev libminiupnpc-dev lua5.1 liblua5.1-dev liblua50-dev libboost-system1.65-dev qml-module-qtquick2 libdee-qt5-dev qtscript5-dev qtdeclarative5-dev libqt4-dev libqt4-declarative

git clone https://github.com/eiskaltdcpp/eiskaltdcpp.git

cd eiskaltdcpp/

mkdir builddir && cd builddir

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DUSE_QT=ON -DUSE_GTK=ON -DUSE_JS=ON -DUSE_ASPELL=ON -DUSE_QT_QML=ON -DUSE_QT_SQLITE=ON -DLUA_SCRIPT=ON -DWITH_LUASCRIPTS=ON -DWITH_SOUNDS=ON -DPERL_REGEX=ON -DNO_UI_DAEMON=ON -DJSONRPC_DAEMON=ON -DUSE_CLI_JSONRPC=ON -DUSE_MINIUPNP=ON -DLOCAL_MINIUPNP=ON ..

make

sudo make install

‘make install’ will create a desktop file for you, so you should be able to reach it from whatever menu system you’re using, and add it to favorites/create a shortcut. I know there are some stuff that could be improved, but meh. If anyone feels like pointing them out, then feel free to do so 🙂

Installing Postfix and Courier with MySQL and SASL on Debian 7

I recently had to move to a new server and had some troube getting Postfix and Courier to work as I wanted. The tutorial I used to follow a bunch of years ago is gone and the tutorials I found were either outdated, wrong or didn’t do it my way. So with some inspiration from other tutorials including the old one I used to have, I have written my own modified version.

Step 1: Prepare your certificate now as you will be using it later
If you don’t already have one you can get one for free at StartSSL
This tutorial wont cover the steps at StartSSL as there are other documents for that.

Files that you will need:

– yourcert.crt
– yourprivatekey.key (in a decrypted state for server purpose)
– ca.pem
– sub.class1.server.ca.pem

Place them in a folder like /etc/ssl/StartCom/year-month-day
For example, I use /etc/ssl/StartCom/2015-08-10 since that is the expiration date for one of my certs.
When the files have been placed there you need to do the following:

cat yourcert.crt yourprivatekey.key ca.pem sub.class1.server.ca.pem > combined.pem

This is because Courier wants it in a pem file later, while Postfix wants them separated.
There might be a way to keep it consistent but I haven’t checked.

Also remember to set permissions to this folder!

chown -R root:root /etc/ssl/StartCom
chmod -R 640 /etc/ssl/StartCom

Your private key is in there and you need to protect it.

Step 2: Install required software

apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl apache2 libapache2-mod-php5 php5 php5-mysql libpam-smbpass

Step 3: Setup MySQL database

mysql -u root -p
CREATE mail;
GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail'@'localhost' IDENTIFIED BY 'mail_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail'@'localhost.localdomain' IDENTIFIED BY 'mail_password';
FLUSH PRIVILEGES;

USE mail;

CREATE TABLE domains (
domain varchar(50) NOT NULL,
PRIMARY KEY (domain) )
ENGINE=MyISAM;

CREATE TABLE forwardings (
source varchar(80) NOT NULL,
destination TEXT NOT NULL,
PRIMARY KEY (source) )
ENGINE=MyISAM;

CREATE TABLE users (
email varchar(80) NOT NULL,
password varchar(20) NOT NULL,
PRIMARY KEY (email)
) ENGINE=MyISAM;

CREATE TABLE transport (
domain varchar(128) NOT NULL default '',
transport varchar(128) NOT NULL default '',
UNIQUE KEY domain (domain)
) ENGINE=MyISAM;

exit

Step 4: Configure postfix

Create these files below and paste the content that follows.
Remember to replace the user and password with whatever you chose before.

vim /etc/postfix/mysql-virtual_domains.cf

user = mail
password = mail_password
dbname = mail
table = domains
select_field = 'virtual'
where_field = domain
hosts = 127.0.0.1
vim /etc/postfix/mysql-virtual_forwardings.cf

user = mail
password = mail_password
dbname = mail
table = forwardings
select_field = destination
where_field = source
hosts = 127.0.0.1
vim /etc/postfix/mysql-virtual_mailboxes.cf

user = mail
password = mail_password
dbname = mail
table = users
select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
where_field = email
hosts = 127.0.0.1
vim /etc/postfix/mysql-virtual_email2email.cf

user = mail
password = mail_password
dbname = mail
table = users
select_field = email
where_field = email
hosts = 127.0.0.1
vim /etc/postfix/mysql-virtual_transports.cf

user = mail
password = mail_password
dbname = mail
table = transport
select_field = transport
where_field = domain
hosts = 127.0.0.1

Change permissions of the files

chmod o= /etc/postfix/mysql-virtual_*.cf
chgrp postfix /etc/postfix/mysql-virtual_*.cf

Create user vmail

groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /home/vmail -m

Set options in the Postfix configuration file.
Replace server1.example.com with a FQDN of your server.
Also replace the cert and key file with the cert and key file in your StartCom folder.
For example instead of /etc/postfix/smtpd.cert you write /etc/ssl/StartCom/2015-08-10/yourcert.crt

postconf -e 'myhostname = server1.example.com'
postconf -e 'mydestination = localhost, localhost.localdomain'
postconf -e 'mynetworks = 127.0.0.0/8'
postconf -e 'virtual_alias_domains ='
postconf -e 'virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf'
postconf -e 'virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf'
postconf -e 'virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf'
postconf -e 'virtual_mailbox_base = /home/vmail'
postconf -e 'virtual_uid_maps = static:5000'
postconf -e 'virtual_gid_maps = static:5000'
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtpd_tls_auth_only = yes'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_helo_required = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/smtpd.cert'
postconf -e 'smtpd_tls_key_file = /etc/postfix/smtpd.key'
postconf -e 'smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3'
postconf -e 'transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf'
postconf -e 'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps'

Now open /etc/postfix/master.cf and uncomment the following section.
The format of these lines are important so only remove the comment characters (#) and nothing else.

#smtps     inet  n       -       -       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING

Step 5: Configure Saslauthd

Create a folder for saslauthd

mkdir -p /var/spool/postfix/var/run/saslauthd

Open the following file.
Set START to yes and change the line OPTIONS=”-c -m /var/run/saslauthd” to OPTIONS=”-c -m /var/spool/postfix/var/run/saslauthd -r”.

vim /etc/default/saslauthd

Open the following file and configure pam to use MySQL to authenticate you.

vim /etc/pam.d/smtp
auth    required   pam_mysql.so user=mail passwd=mail_password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1
account sufficient pam_mysql.so user=mail passwd=mail_password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1

Edit smtpd.conf and configure sasl to use the sql plugin to authenticate users.

vim /etc/postfix/sasl/smtpd.conf

pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: mail
sql_passwd: mail_password
sql_database: mail
sql_select: select password from users where email = '%u@%r'

Add the postfix user to the sasl group

adduser postfix sasl

Restart postfix and saslauthd

/etc/init.d/postfix restart
/etc/init.d/saslauthd restart

Step 6: Configure courier

Edit Courier to use MySQL to authenticate

vim /etc/courier/authdaemonrc

[...]
authmodulelist="authmysql"
[...]
cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig
cat /dev/null > /etc/courier/authmysqlrc
vim /etc/courier/authmysqlrc

MYSQL_SERVER localhost
MYSQL_USERNAME mail_admin
MYSQL_PASSWORD mail_password
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')

Now configure Courier to use your StartSSL cert for imap.
Courier wants the combined pem file.

vim /etc/courier/imapd-ssl

Find the row TLS_CERTFILE and change the path.
For example: TLS_CERTFILE=/etc/ssl/StartCom/2015-08-10/combined.pem

Also find the the following rows and make sure they are set to the values below.

IMAPDSTARTTLS=YES
IMAP_TLS_REQUIRED=1
TLS_PROTOCOL=TLS1
TLS_STARTTLS_PROTOCOL=TLS1

Since I don’t use pop3 I will make sure to disable it.

vim /etc/courier/pop3-ssl

Find the the following row and make sure it’s set to the value below.

POP3DSSLSTART=NO
vim /etc/courier/pop3
POP3DSTART=NO

Restart courier

/etc/init.d/courier-authdaemon restart
/etc/init.d/courier-imap restart
/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop restart
/etc/init.d/courier-pop-ssl restart

Step 7: Modify aliases

vim /etc/aliases

[...]
postmaster: root
root: postmaster@yourdomain.tld
[...]

Issue this command to update the aliases

newaliases

That should be all.
Don’t forget to populate the database with a user and a domain.

INSERT INTO domains VALUES('somedomain.com');
INSERT INTO users VALUES('user@somedomain.com', ENCRYPT('mypassword'));

If you have any comments or feedback then feel free to leave them in the comment section below.
This tutorial will be updated later with some more security related settings to protect against certain SSL/TLS attacks.

Bought new laptop

Haven’t written anything in a while now, so I decided it’s time write all those posts that have been piling up lately.
I’ll start with my new laptop.

I got the Asus UX31A, and I have to say that I’m really loving it so far.
It’s really slick and lightweight, and I really like how thin it is.
It doesn’t have any optical unit, nor does it have an Ethernet port.
Although the Ethernet comes as a USB adapter, which is pretty neat.
The screen is very clear and the machine is really fast and well performing overall.

I’ve been having some trouble with the touch pad since the pad and the buttons for it are one and the same,
so I keep moving the mouse pointer whenever I want to click something, which can get pretty frustrating (Especially when I’m sitting in bed and coding).

https://www.asus.com/Notebooks_Ultrabooks/ASUS_ZENBOOK_UX31A/

Isn’t it just beautiful?
2014-01-14 22.39.57

Comes with a really nice little case as well.
2014-01-14 22.39.07

I salvaged some nice stickers from my old work laptop.
2014-01-14 22.39.37

Wrote my first install script for PlayOnLinux

I like to play games once in a while, but I don’t have Windows.
So like many other Linux gamers, I use Wine, but I like to have an overlay to keep things neat and organized, and thus I use PlayOnLinux.
PlayOnLinux comes with installation scripts so that the games will work right away without me having to fiddle around with a bunch of hacks to get it working, but as it turns out, the game I wanted to play (Civilization IV: Complete Edition) didn’t have an installation script that worked, so I decided to write my own and try to get it approved by the people at PlayOnLinux, and thus added to the software list of approved and signed scripts 🙂

It hasn’t been approved yet, but it’s getting there.
This is the script so far (fully working in this state).

Go to the link below for the newest development info
http://www.playonlinux.com/en/topic-10740.html

Another interesting thing to note, is that I am hosting the Civ IV patches myself that the script is downloading and installing, since I want to make sure that it’s always being hosted on a fast connection for everyone to use.

If anyone else need the patches for use outside of this script, you can download them below. (The patches below are no longer hosted by me!)

Civilization IV Patch 1.74
Civilization IV – Warlords Patch 2.13
Civilization IV – Beyond The Sword Patch 3.19

#!/bin/bash
# Date : (2013-06-26)
# Last revision : (2013-07-23)
# Wine version used : 1.4.1
# Distribution used to test : xUbuntu 13.10
# Author : Jinny Ramsmark
# Licence : GPLv3
# Depend : msxml3, d3dx9

# This script was tested using the DVD version of `Civilization IV: Complete'
# version 1.74, bought in the 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"
AUTHOR="Jinny Ramsmark"
PREFIX="Civilization4"
WORKINGWINEVERSION="1.4.1"
STEAM_ID_CIV="3900"
STEAM_ID_W="3990"
STEAM_ID_BTS="8800"
STEAM_ID_COL="16810"

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 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://ayu.alcor.se/files/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.nnWhen 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

#Create shortcuts
if [ "$INSTALL_METHOD" == "STEAM" ]; then
    POL_Shortcut "Steam.exe" "$TITLECIV" "$TITLECIV.png" "-applaunch $STEAM_ID_CIV" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLEBTS" "$TITLEBTS.png" "-applaunch $STEAM_ID_BTS" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLEW" "$TITLEW.png" "-applaunch $STEAM_ID_W" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "$TITLECOL" "$TITLECOL.png" "-applaunch $STEAM_ID_COL" "Game;StrategyGame;"
    POL_Shortcut "Steam.exe" "Steam - Civ IV" "" "" "Game;"
else
    POL_Shortcut "Civilization4.exe" "$TITLECIV" "$TITLECIV.png" "" "Game;StrategyGame;"
    POL_Shortcut "Civ4BeyondSword.exe" "$TITLEBTS" "$TITLEBTS.png" "" "Game;StrategyGame;"
    POL_Shortcut "Civ4Warlords.exe" "$TITLEW" "$TITLEW.png" "" "Game;StrategyGame;"
fi

#Done!
POL_SetupWindow_message "$(eval_gettext 'Installation finishednnThe game might crash on the first attempt, but no worries, just try one more time.')" "$TITLECIV"
POL_SetupWindow_Close
exit 0