#!/bin/bash

# Copyright (C) 2007 Pâris Quentin

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 

if [ "$PLAYONLINUX" = "" ]
then
exit 0
fi
source "$PLAYONLINUX/lib/sources"
cfg_check

prefixe=$(detect_wineprefix "$1")
POL_SetupWindow_Init
LNG_DIRECTX=$(eval_gettext "$(eval_gettext 'This wizard will help you to install a directx patch in playonlinux')\n\n$(eval_gettext 'The patch will be applied in :')")
POL_SetupWindow_free_presentation "Direct X" "$LNG_DIRECTX\n$prefixe"

if [ "$OFFLINE" == "1" ]
then
	LNG_OFFLINE_MODE=$(eval_gettext "You are in offline mode")
	LNG_ERROR=$(eval_gettext "Error")
	POL_SetupWindow_message "$LNG_OFFLINE_MODE" "$LNG_ERROR"
	POL_SetupWindow_Close
	exit
fi

if [ -e "$prefixe" ]
then
	select_prefixe "$prefixe"
	mkdir $REPERTOIRE/tmp/dx9 -p
	cd $REPERTOIRE/tmp/dx9
	POL_SetupWindow_download "$(eval_gettext 'Downloading Direct X')" "$(eval_gettext 'Downloading...')" "$SITE/divers/dx9/dx9.tar.gz"
	POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$(eval_gettext 'Extracting...')" "cd $PWD && tar -xvf dx9.tar.gz"
	wine ./DXSETUP.exe
	cd $REPERTOIRE
	rm $REPERTOIRE/tmp/dx9 -r
	POL_SetupWindow_reboot
	POL_SetupWindow_Close
fi
exit 
