Fora

FlatOut 2

Autor Odpowiedzi
Jump to the page: 1 - 2
zedtux Sunday 18 October 2009 at 20:09
zedtux

Hello, i create a script for FLatOut 2. Works correctly, no audio or graphic bug.

Wine version : 1.1.31
Distribution : Ubuntu 9.04
Carte Graphique : Nvidia, GeForce 8800 GTX
Drivers carte graphique : 185.18.36

Game's icon :


Created script: http://www.playonlinux.com/repository/?script=497

#!/bin/bash
# Date : (2009-06-02 10-00)
# Last revision : (2009-10-18 10-00)
# Wine version used : 1.1.31
# Distribution used to test : Ubuntu 9.04
# Author : zedtux
# Licence : Retail

GAMENAME="FlatOut 2"
PREFIX="flatout2"
NEEDEDWINEVERSION="1.1.31"
MENU_ACTION_INSTALL="Install the game"
MENU_ACTION_PATCH="Patch the game"
GAME_SETUP="setup.exe"
PATCHMIME="application/zip"
ZENITYPATH=`which zenity`
UNZIPPATH=`which unzip`
PROGRAMFILES=`wine cmd /c echo "%ProgramFiles%"`
PROGRAMFILES=${PROGRAMFILES:3} 

# Include mandatory PlayOnLinux libs
if [ "$PLAYONLINUX" = "" ]then
	# Display Error in console
	echo "Can't find PlayOnLinux libraries !"
	echo "Please check PLAYONLINUX"
	
	# Display error in GUI if zenity installed
	if [ "$ZENITYPATH" != "" ] ; then
		zenity --error --title="$GAMENAME PlayOnLinux Script" --text="The PlayOnLinux libraries can't be found \\! Please check the varaible PLAONLINUX \\!

It should be something like :
export PLAYONLINUX=/usr/share/playonlinux"
	fi
	
	exit 0
fi
source "$PLAYONLINUX/lib/sources"
cfg_check

# Get Cover and convert it
wget http://www.mobygames.com/images/covers/large/1174536160-00.jpg --output-document="$REPERTOIRE/tmp/flatout2.cover.jpeg"
convert "$REPERTOIRE/tmp/flatout2.cover.jpeg" -scale 150x356\\! "$REPERTOIRE/tmp/left.flatout.2.jpeg"

# Initialize the main window
POL_SetupWindow_Init "" "$REPERTOIRE/tmp/left.flatout.2.jpeg"
POL_SetupWindow_presentation "$GAMENAME" "zedtux" "http://www.zedroot.org" "zedtux" "$PREFIX"


select_prefix "$REPERTOIRE/wineprefix/$PREFIX"


# Provide possibility to run install of a patch for the game
patch_game()
{
	POL_SetupWindow_browse "Select the patch file for $GAMENAME (Should be like flatout_2_patch_*.zip)" "Patching $GAMENAME" ""
	if [ "$APP_ANSWER" != "" ] ; then
		if [ `file -bi $APP_ANSWER` == "$PATCHMIME" ] ; then
			
			# Extract file, and replace existing files in the game folder
			cd $REPERTOIRE/wineprefix/$PREFIX/drive_c/Program\\ Files/Empire\\ Interactive/FlatOut2
			echo "Unziping patch into `pwd`"
			unzip -o $APP_ANSWER
		fi
		POL_SetupWindow_message "$GAMENAME patched successfully" "$TYTUL"
		POL_SetupWindow_Close
		exit
	fi
}

# Create Wine environnement before install the game
POL_SetupWindow_prefixcreate

#
# Make a menu to select one action
#
# If unzip is not installed, the script can't patch the game, so just install the game without choices
if [ "$UNZIPPATH" != "" ] ; then
	
	# Give the choice to user between install or patch the game
	POL_SetupWindow_menu "What do you want to do?" "Actions" "$MENU_ACTION_INSTALL~$MENU_ACTION_PATCH" "~"
	
	if [ "$APP_ANSWER" == "$MENU_ACTION_PATCH" ]; then
	
		# Checking if destination exist, else create it
		#[ -a "$REPERTOIRE/wineprefix/$PREFIX" ] || mkdir "$REPERTOIRE/wineprefix/$PREFIX"
	
		if [ -e "$REPERTOIRE/wineprefix/$PREFIX" ]; then
			patch_game
		fi
	
		POL_SetupWindow_Close
	fi
fi

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom $GAME_SETUP

# Adding CD-ROM as drive d: to winecfg
cd $WINEPREFIX/dosdevices
ln -s $CDROM d:
cd "$WINEPREFIX/drive_c/windows/temp/" 
echo "[HKEY_LOCAL_MACHINE\\\\Software\\\\Wine\\\\Drives]" > cdrom.reg
echo "\\"d:\\"=\\"cdrom\\"" >> cdrom.reg
regedit cdrom.reg

# Launching Installation
POL_SetupWindow_wait_next_signal "Installing $GAMENAME..." "$GAMENAME"
cd $CDROM
wine $GAME_SETUP

# Defining options of the environnement
Set_SoundDriver alsa
POL_SetupWindow_install_wine $NEEDEDWINEVERSION
Set_WineVersion_Assign $NEEDEDWINEVERSION "$GAMENAME"

# Creating shortcut
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Empire Interactive/FlatOut2" "FlatOut2.exe" "" "$GAMENAME" ""

POL_SetupWindow_message "$GAMENAME has been installed successfully" "$GAMENAME"

# Close the main window !
POL_SetupWindow_Close

echo "End Of Script"
exit
NSLW Sunday 18 October 2009 at 20:19
NSLW

1)not required
cfg_check
because deprecated

2)not required
# Include mandatory PlayOnLinux libs
if [ "$PLAYONLINUX" = "" ]
then
     # Display Error in console
     echo "Can't find PlayOnLinux libraries !"
     echo "Please check PLAYONLINUX"

     # Display error in GUI if zenity installed
     if [ "$ZENITYPATH" != "" ] ; then
          zenity --error --title="$GAMENAME PlayOnLinux Script" --text="The PlayOnLinux libraries can't be found \\! Please check the varaible PLAONLINUX \\!

It should be something like :
export PLAYONLINUX=/usr/share/playonlinux"
     fi

     exit 0
fi

because PlayOnLinux should show such errors

3) Why not to use wikipedia?
http://www.mobygames.com/images/covers/large/1174536160-00.jpg

4) Not quoted and contains "Program Files" which isn't in all languages
cd $REPERTOIRE/wineprefix/$PREFIX/drive_c/Program\\ Files/Empire\\ Interactive/FlatOut2

5) not required
if [ "$UNZIPPATH" != "" ] ; then
because unzip is playonlinux dependency

6) Wrong
if [ -e "$REPERTOIRE/wineprefix/$PREFIX" ]; then
First: -e is for testing file and not directory
Second: use it to know if you could ask about patch

7) quote all
$CDROM
and maybe other paths
zedtux Sunday 18 October 2009 at 20:48
zedtux

Hello,

Thanks for your comments !

Everythings fixed : http://svn.zedroot.org/PlayOnLinuxScripts/flatout.2.sh

Only point about wikipedia: Can you tell me where can I make the search to found the cover ?
I've only found the page about the game with a logo, not the cover.

Can you tell me why is it so important to quote variables ?
( I'm nearly new with bash )

And finaly, my script that I post for validation is not up to date any more. How can I do to update it ?


Thanks for your reply, and hope to help playonlinux ! :)

Edytowane przez zedtux

NSLW Sunday 18 October 2009 at 21:01
NSLW


Everythings fixed : http://svn.zedroot.org/PlayOnLinuxScripts/flatout.2.sh

Quote from zedtux


1) why this?
ZENITYPATH=`which zenity`
UNZIPPATH=`which unzip`

Only point about wikipedia: Can you tell me where can I make the search to found the cover ?
I've only found the page about the game with a logo, not the cover.

Cytuj


2) Wikipedia link for game cover
http://en.wikipedia.org/wiki/File:Flatout2pc.jpg

3) Probably wrong
"$REPERTOIRE/wineprefix/$PREFIX/drive_c/$PROGRAMFILES/Empire\\ Interactive/FlatOut2"

It should be
"$REPERTOIRE/wineprefix/$PREFIX/drive_c/$PROGRAMFILES/Empire Interactive/FlatOut2"

Can you tell me why is it so important to quote variables ?
( I'm nearly new with bash )

Quote from zedtux

Because sometimes path to cd rom can contain spaces and if you won't quote that then some commands may not work


And finaly, my script that I post for validation is not up to date any more. How can I do to update it ?

Quote from zedtux


I rejected your script so you can correct it.
zedtux Sunday 18 October 2009 at 22:33
zedtux

Okay thanks again for tour reply!

Let me make l'astre modifications, ans I'll update my script.
zedtux Sunday 18 October 2009 at 23:11
zedtux

1) why this?
ZENITYPATH=`which zenity`
UNZIPPATH=`which unzip`

Quote from NSLW


I had forget this and fix it before your post ;)
So it's fixed !

3) Probably wrong
"$REPERTOIRE/wineprefix/$PREFIX/drive_c/$PROGRAMFILES/Empire\\ Interactive/FlatOut2"

It should be
"$REPERTOIRE/wineprefix/$PREFIX/drive_c/$PROGRAMFILES/Empire Interactive/FlatOut2"

Quote from NSLW


No, cause of the space. It's linux path, not windows path.

I rejected your script so you can correct it.

Quote from NSLW


Thanks you !


I have fixed latest points, can you check please ?
NSLW Monday 19 October 2009 at 8:58
NSLW

No, cause of the space. It's linux path, not windows path.

Quote from zedtux

If you use quotes then you don't have to use backslashes for spaces.
zedtux Monday 19 October 2009 at 9:33
zedtux

Ha ok !

Cool ! I've learn something ! :D

I've made the modification, I'm updating the script.

Thanks.
zedtux Monday 19 October 2009 at 17:36
zedtux

I've just fixed another bug that I've discover during creation of a new script.

Can you refuse (again sorry) my script to patch my script please ?
NSLW Monday 19 October 2009 at 17:41
NSLW

done
zedtux Monday 19 October 2009 at 18:19
zedtux

Thank you very much !

Script patched and waiting for validation ;)
NSLW Monday 19 October 2009 at 19:28
NSLW

I've got one more question:
Does this is required?
Set_SoundDriver alsa
Doesn't sound works with default Wine settings?
zedtux Monday 19 October 2009 at 21:00
zedtux

Hum... yeah it should...

I think I had try with OSS, and have not work.. But Yeah agree, I can delete this line.
zedtux Monday 19 October 2009 at 21:02
zedtux

On my side is done.

You can refuse my script to let me patch it, or you can do this if you want.
Let me know what's your choice ;)
NSLW Monday 19 October 2009 at 21:04
NSLW

Corrected and accepted. Thanks for the script :)
zedtux Monday 19 October 2009 at 21:10
zedtux

Thanks to you for your help !
zedtux Tuesday 20 October 2009 at 19:27
zedtux

Heum... is it possible to update the script ?

I'have found that a shortcut is missing to configure the game !
So the script miss a second line with POL_SetupWindow_make_shortcut:

Line 91:
POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/Empire Interactive/FlatOut2" "FlatOut2.exe" "" "$GAMENAME Setup" "" "-setup"
Berillions Tuesday 20 October 2009 at 20:29
Berillions

Updated

zedtux Tuesday 20 October 2009 at 21:55
zedtux

Thanks ! :)
zedtux Tuesday 20 October 2009 at 22:00
zedtux

Could you tell me why the game icon don't appear in PlayOnLinux please ?
Jesteś tutaj: Index > Your creations. > FlatOut 2