The forum

Starflight 1 & 2 (GoG)

Author Replies
petch Saturday 3 December 2011 at 22:36
petch

Bonjour,
Voici mon script pour installer Starflight 1 et 2 (de GoG).
Rien de vraiment particulier à signaler, à part peut-être qu'il s'agit de jeux DOS, et que le script propose donc d'utiliser soit la version Windows, soit la version Linux de dosbox (seconde solution chaudement recommandée pour des raisons de performances, de clavier,...). Le script a été testé avec la version native 0.74 (même que la version Windows).

Un avertissement en passant, pas lié à mon script mais aux jeux Starflight : les fichiers de partie sont modifiés en cours de jeu, il n'est pas possible de revenir dans l'état de la dernière sauvegarde en quittant le jeu et en le relançant : la partie serait corrompue et le jeu ne pourrait pas reprendre.
Pour faire cela, il faut impérativement faire des sauvegardes des fichiers de partie, (Starflight est fourni avec des menus en shell pour vous simplifier cette tâche), et restaurer une version précédente des fichiers de partie. Dans ce cas, "quitter sans sauvegarder" est utile pour économiser le temps nécessaire à rendre les fichiers de la partie courantes cohérents alors que l'on s'apprête à les écraser avec une autre version...


Maintenant, le script:
https://raw.github.com/petchema/playonlinux/master/starflight1&2-gog
#!/bin/bash
# Date : (2011-12-01 22-38)
# Last revision : (2011-12-01 22-38)
# Wine version used : 
# Distribution used to test : Debian Sid (Unstable)
# Author : Pierre Etchemaite petchema@concept-micro.com
# Script licence : GPL v.2
# Program licence : Retail
# Depend : dosbox 

# prefer native dosbox version

[ -z "$PLAYONLINUX" ] && exit 0
source "$PLAYONLINUX/lib/sources"

abort () {
    POL_SetupWindow_message_image "$LNG_ABORTED" "$TITLE" "$PLAYONLINUX/themes/tango/warning.png"
    POL_SetupWindow_Close
    exit 1
}

check_install_archive () {
    POL_SetupWindow_wait_next_signal "$LNG_CHECK_ARCHIVE" "$TITLE"

    EXPECTED_NAME='setup_starflight_1_2.exe'
    EXPECTED_SIZE=44526203
    EXPECTED_MD5="4b3e884d1bbe066470338456991dc73e"

    # Temporarily prevent word splitting
    OLDIFS="$IFS"
    IFS=''
    NAME="$(basename $ARCHIVE)"
    SIZE="$(stat -c%s $ARCHIVE)"
    MD5="$(POL_MD5_file $ARCHIVE)"
    IFS="$OLDIFS"

    POL_SetupWindow_detect_exit

    if [ $SIZE -ne $EXPECTED_SIZE -o "$MD5" != "$EXPECTED_MD5" ]; then
        POL_SetupWindow_message_image "$LNG_ARCHIVE_MISMATCH\\nName: $NAME (expected $EXPECTED_NAME)\\nSize: $SIZE (expected $EXPECTED_SIZE)\\nMD5: $MD5\\n     (expected $EXPECTED_MD5)" "$TITLE" "$PLAYONLINUX/themes/tango/warning.png"
        POL_SetupWindow_question "$LNG_CONTINUE" "$TITLE"
        [ "$APP_ANSWER" != "TRUE" ] && abort
    fi
}


PREFIX="Starflight_1_2_gog"
WORKING_WINE_VERSION="1.3.23"
# GoG tools (graphic mode setup, code wheel work _almost_ ok with 1.3.23

case "$POL_LANG" in
    fr)
        TITLE="Starflight 1 et 2 (version GoG)"
        SHORTCUT1_NAME="Starflight 1"
        SHORTCUT1_CODEWHEEL="Starflight 1 - Roue de codes"
        SHORTCUT1_DOC="Starflight 1 - Manuel d'utilisation"
        SHORTCUT1_MAP="Starflight 1 - Carte stellaire"
        SHORTCUT2_NAME="Starflight 2"
        SHORTCUT2_DOC="Starflight 2 - Manuel d'utilisation"
        SHORTCUT2_MAP="Starflight 2 - Carte stellaire"
        LNG_ABORTED="Une erreur est survenue, l'installation est interrompue."
        LNG_CHECK_ARCHIVE="Test de l'archive d'installation..."
        LNG_ARCHIVE_MISMATCH="L'archive ne correspond pas.\\nOu bien elle est corrompue, ou ce n'est pas la version attendue.\\nCe script ne peut pas garantir que l'installation se passera bien, pensez à communiquer le résultat de l'installation sur le forum de PlayOnLinux."
	LNG_CONTINUE="Continuer ?"
        LNG_ARCHIVE_LOCATION="Indiquez l'emplacement de l'archive d'installation"
        LNG_SELECT_FILE="Sélectionnez le fichier"
        LNG_INSTALLING="Installation de $TITLE..."
        ;;
    *)
        TITLE="Starflight 1 and 2 (GoG release)"
        SHORTCUT1_NAME="Starflight 1"
        SHORTCUT1_CODEWHEEL="Starflight 1 - Code wheel"
        SHORTCUT1_DOC="Starflight 1 - User manual"
        SHORTCUT1_MAP="Starflight 1 - Stellar map"
        SHORTCUT2_NAME="Starflight 2"
        SHORTCUT2_DOC="Starflight 2 - User manual"
        SHORTCUT2_MAP="Starflight 2 - Stellar map"
        LNG_ABORTED="An error occurred, the installation is aborted."
        LNG_CHECK_ARCHIVE="Checking install archive..."
        LNG_ARCHIVE_MISMATCH="Install archive mismatch.\\nEither your install archive is corrupted, or is not the expected version.\\nThis script cannot guarantee that installation will work correctly. Please report success or failure to PlayOnLinux forums."
        LNG_CONTINUE="Continue?"
        LNG_ARCHIVE_LOCATION="Please select the location of the install file"
        LNG_SELECT_FILE="Select file"
        LNG_INSTALLING="Installing $TITLE..."
        ;;
esac

POL_SetupWindow_Init
POL_SetupWindow_presentation "$TITLE" "Binary Systems / Electronic Arts" "http://www.gog.com/en/gamecard/starflight_1_2" "Pierre Etchemaite" "$PREFIX"

check_one "dosbox" "dosbox"
POL_SetupWindow_missing
 
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate

cd $HOME
POL_SetupWindow_browse "$LNG_ARCHIVE_LOCATION" "$LNG_SELECT_FILE"
ARCHIVE="$APP_ANSWER"

check_install_archive

if [ -n "$WORKING_WINE_VERSION" ]; then
    POL_Wine_InstallVersion "$WORKING_WINE_VERSION"
    export WINEVERSION="$WORKING_WINE_VERSION"
fi


POL_SetupWindow_wait_next_signal "$LNG_INSTALLING" "$TITLE"

# Associate .PDF with native app 
# http://wiki.winehq.org/FAQ#head-91bf3f0a8ccbfab8dee96f82fae2f1a489e0d243
# Do it before installing the game, so you have the possibility to open
# PDFs with Win32 reader if you choose to install it
cat <<'EOF' > $REPERTOIRE/tmp/pdfnativereader.reg
[HKEY_CLASSES_ROOT\\.pdf]
@="PDFfile"
"Content Type"="application/pdf"
[HKEY_CLASSES_ROOT\\PDFfile\\Shell\\Open\\command]
@="winebrowser \\"%1\\""
EOF
POL_Wine regedit $REPERTOIRE/tmp/pdfnativereader.reg

POL_Wine "$ARCHIVE" || abort

# GoG work!
Set_OS winxp


POL_SetupWindow_detect_exit

# Doesn't hurt ;)
POL_Wine_reboot 

# Sadly, it seems GoG installer unpacks both games even if you only ask for 1
# So test below is uneffective and all shortcuts are always created
if [ -d "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1" ]; then
    # Better default settings in my opinion
    sed -i.orig -e 's/^fullscreen=.*/fullscreen=false/; s/^scaler=.*/scaler=hq2x/' "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/dosboxSF1.conf"

    POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/" "C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/DOSBOX/DOSBox.exe" "-conf dosboxSF1.conf -noconsole" "$SHORTCUT1_NAME"
    cp -n "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/gfw_high.ico" "$REPERTOIRE/icones/32/$SHORTCUT1_NAME"
    # Thanks to exec, will only start W32 dosbox if native dosbox fails to start
    POL_Shortcut_InsertBeforeWine "$SHORTCUT1_NAME" "exec dosbox -conf dosboxSF1.conf"
    if [ -n "$WORKING_WINE_VERSION" ]; then
        Set_WineVersion_Assign "$WORKING_WINE_VERSION" "$SHORTCUT1_NAME"
    fi

    POL_Shortcut "Starflight_codes_by_gog.exe" "$SHORTCUT1_CODEWHEEL"

    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT1_DOC" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/manual.pdf'"

    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT1_MAP" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 1/map.pdf'"
fi

if [ -d "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2" ]; then
    # Better default settings in my opinion
    sed -i.orig -e 's/^fullscreen=.*/fullscreen=false/; s/^scaler=.*/scaler=hq2x/' "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/dosboxSF2.conf"

    POL_SetupWindow_make_shortcut "$PREFIX" "$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/" "C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/DOSBOX/DOSBox.exe" "-conf dosboxSF2.conf -noconsole" "$SHORTCUT2_NAME"
    cp -n "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/gfw_high.ico" "$REPERTOIRE/icones/32/$SHORTCUT2_NAME"
    # Thanks to exec, will only start W32 dosbox if native dosbox fails to start
    POL_Shortcut_InsertBeforeWine "$SHORTCUT2_NAME" "exec dosbox -conf dosboxSF2.conf"
    if [ -n "$WORKING_WINE_VERSION" ]; then
        Set_WineVersion_Assign "$WORKING_WINE_VERSION" "$SHORTCUT2_NAME"
    fi

    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT2_DOC" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/manual.pdf'"

    POL_SetupWindow_make_shortcut "$PREFIX" "/windows/command" "start.exe" "" "$SHORTCUT2_MAP" "" "'C:/$PROGRAMFILES/GOG.com/Starflight 1 and 2/Starflight 2/map.pdf'"
fi

POL_SetupWindow_Close

cat <<EOF > $REPERTOIRE/configurations/configurators/"$SHORTCUT1_NAME"
#!/bin/bash
[ -z "\\$PLAYONLINUX" ] && exit 0
source "\\$PLAYONLINUX/lib/sources"
export WINEPREFIX="$REPERTOIRE/wineprefix/$PREFIX"
export WINEDEBUG=""

POL_LoadVar_PROGRAMFILES

cd "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/" || exit

# Make sure that if user presses "start game", it will launch the right dosbox
DOSBOX="`which dosbox`"
if [ -n "\\$DOSBOX" ]; then
    cat <<-EOFINI > $REPERTOIRE/tmp/sf1nativedosbox.reg
	REGEDIT4

	[HKEY_LOCAL_MACHINE\\Software\\GOG.com\\GOGSTARFLIGHT1]
	"LAUNCHCOMMAND"="\\$DOSBOX -conf dosboxSF1.conf"
	EOFINI
    POL_Wine regedit $REPERTOIRE/tmp/sf1nativedosbox.reg
fi

POL_Wine "Graphic mode setup.exe" "GOGSTARFLIGHT1"
exit
EOF

cat <<EOF > $REPERTOIRE/configurations/configurators/"$SHORTCUT2_NAME"
#!/bin/bash
[ -z "\\$PLAYONLINUX" ] && exit 0
source "\\$PLAYONLINUX/lib/sources"
export WINEPREFIX="$REPERTOIRE/wineprefix/$PREFIX"
export WINEDEBUG=""

POL_LoadVar_PROGRAMFILES

cd "$WINEPREFIX/drive_c/$PROGRAMFILES/GOG.com/Starflight 1 and 2/" || exit
# Make sure that if user presses "start game", it will launch the right dosbox
DOSBOX="`which dosbox`"
if [ -n "\\$DOSBOX" ]; then
    cat <<-EOFINI > $REPERTOIRE/tmp/sf2nativedosbox.reg
	REGEDIT4

	[HKEY_LOCAL_MACHINE\\Software\\GOG.com\\GOGSTARFLIGHT2]
	"LAUNCHCOMMAND"="\\$DOSBOX -conf dosboxSF2.conf"
	EOFINI
    POL_Wine regedit $REPERTOIRE/tmp/sf2nativedosbox.reg
fi

POL_Wine "Graphic mode setup.exe" "GOGSTARFLIGHT2"
exit
EOF

exit

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmcayonlinux.com