Outils pour utilisateurs

Outils du site


jeux:gsb_dlc_installer

Gratuitous Space Battles DLC

Pour installer les DLC sous Linux, vous aurez besoin de InnoExtract et ImageMagick.

Utilisation :

./GSB_DLC_installer NomadsInstaller.exe Gratuitous\ Space\ Battles/

GSB_DLC_Installer
#!/bin/bash
#
# This is a quick hack made in order to install the GSB DLC under Linux
#
# It comes with no warranty whatsoever: make a backup copy of your GSB directory!
#
# Obviously, you will need InnoExtract in order to extract the .exe file:
# https://github.com/dscharrer/InnoExtract/wiki
# 
# HISTORY:
# v0.1: creation and initial release
#
#
# ------------------------------------------------
#
# RETURN STATUS
# 0: Operation completed
# 1: Syntax error
# 2: GSB directory not found/not writable
# 3: Current directory not writable
# 4: DLC not found
# 5: Required binary not found
# 6: Unknown DLC
# 7: DLC already installed
# 8: User disagreed to proceed
#
 
declare -r YELLOW="\e[33;1m"
declare -r NORM="\e[0m"
 
function syntax () {
  cat <<__EoF__
Syntax: $0 DLC_Name GSB_dir
  GSB_dir must exist and be writable
  Current directory must be writable
__EoF__
exit 1
}
 
function die () {
  MSG="$1"
  EXIT_CODE=$2
  echo -e $MSG
  exit $EXIT_CODE
}
 
function check_bin () {
  BIN=`which $1 2>/dev/null`
  [[ -z $BIN ]] && die "Can't find $1 in your \$PATH..." 5
  return
}
 
[[ $# != 2 ]] && syntax
 
# Disclaimer/Agreement
clear
cat <<__EoF__
#######################################
##                                   ##
##  REMEMBER TO MAKE A BACKUP COPY   ##
##   OF YOUR GSB DIRECTORY BEFORE    ##
##      USING THIS SOFTWARE!!!       ##
##                                   ##
##   IF YOU HAVE A DIRECTORY NAMED   ##
##   app IN THE CURRENT DIRECTORY    ##
##  ITS CONTENT WILL BE OVERWRITTEN  ##
##        WITHOUT ASKING !!!         ##
##                                   ##
#######################################
 
__EoF__
echo -n "Do you want to continue? [Y/n] "
read answer
REGEX="^(n|N)(o|O)?.*$"
[[ $answer =~ $REGEX ]] && die "Aborting..." 8
 
DLC="$1"
GSB="$2"
# Stripping DLC from .exe extension
DLC_NAME=`basename "${DLC/.exe/}"`
 
# Writable dirs?
([[ -d "$2" ]] && [[ -w "$2" ]]) || die "$2 must be a writable directory" 2
[[ -w . ]] || die "Current directory must be writable" 3
 
# Is DLC a real file?
[[ -f "$DLC" ]] || die "$DLC not found" 4
 
# Check presence of required binaries
for b in innoextract convert find; do check_bin $b; done
 
# Handling DLC particularities
case $DLC_NAME in
  *Installer)
    # Basic DLC: getting rid of "Installer" and changing to lowercase
    DATA_DIR=${DLC_NAME/Installer/}
    DATA_DIR=${DATA_DIR,,}
    PRETTY_NAME="${YELLOW}${DATA_DIR^}${NORM}"
    ;;
  GalacticConquest)
    # Particular case of Galactic Conquest
    DATA_DIR="campaign";
    PRETTY_NAME="${YELLOW}Galactic Conquest${NORM}"
    ;;
  *)
    die "Unknown DLC" 6
    ;;
esac
 
# Won't re-install without warning user
CHECK_FILE="${GSB}/data/installs/${DATA_DIR}.txt"
[[ -f $CHECK_FILE ]] && die "$PRETTY_NAME appears to be already installed.\nTo re-install, remove $CHECK_FILE" 7
 
echo -e "Will install ${PRETTY_NAME}"
echo "Extracting DLC"
innoextract -s -p "$DLC"
 
echo "Copying files"
cp -a app/${DATA_DIR} "$GSB"
cp -a app/data/* "$GSB/data/"
[[ $DATA_DIR == campaign ]] && mv "$GSB/campaign/data/Campaign Manual.pdf" "$GSB/campaign/data/CampaignManual.pdf"
 
OLDIFS="$IFS"
IFS='\n'
echo "Converting DDS images to PNG (can take a while)"
find "$GSB/$DATA_DIR" -name "*.dds" | (while read dds_file; do
  convert "$dds_file" "${dds_file/.dds/.png}"
done)
#echo "Removing DDS images"
#find "$GSB" -name "*.dds" -exec rm {} \;
echo "Converting BMP images to JPG"
find "$GSB/$DATA_DIR" -name "*.bmp" | (while read bmp_file; do
  convert "$bmp_file" "${bmp_file/.bmp/.jpg}"
done)
#echo "Removing BMP images"
#find "$GSB" -name "*.bmp" -exec rm {} \;
IFS="$OLDIFS"
 
echo "Cleaning up"
rm -rf app
echo -e "${PRETTY_NAME} installed, enjoy!"
 
exit 0
 
# EoF
jeux/gsb_dlc_installer.txt · Dernière modification: 2015/12/06 18:34 par cyriac