Linux DLC

Re: Linux DLC

Postby cycyx on Sat May 26, 2012 2:00 pm

Hello there,

As I had a few minutes ahead, I wrote a small script to install DLC under Linux.
It handles the extraction, copy and conversion of graphic files.

No need for Windows or even Wine! ;)

Just pure Bash scripting, with help from InnoExtract and ImageMagick.

Feel free to comment.
You can find the original version here.

Here we go:
Code: Select all
#! /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:
#
# 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 1 "$DLC"

echo "Copying file"
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
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby Jeff on Mon Sep 17, 2012 4:02 pm

The script is really convenient, thanks. I can't get it to extract Galactic Conquest though. It reports "unknown DLC" when I run
Code: Select all
./installDLC.sh GSBGalacticConquest.exe GSB

All the other DLCs appear to have extracted okay and I can select those races in the faction select menu.
Jeff
Space cadet
Space cadet
 
Posts: 4
Joined: Mon Sep 17, 2012 2:39 pm

Re: Linux DLC

Postby cycyx on Mon Sep 17, 2012 4:10 pm

That's because your binary isn't named as my script expect it (mine was GalacticConquest.exe).

Rename it ('mv GSBGalacticConquest.exe GalacticConquest.exe') and try again.
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby Jeff on Mon Sep 17, 2012 4:14 pm

That was quick, and correct! Thanks.
Jeff
Space cadet
Space cadet
 
Posts: 4
Joined: Mon Sep 17, 2012 2:39 pm

Re: Linux DLC

Postby cycyx on Mon Sep 17, 2012 4:18 pm

You're welcome.
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby NupupuN on Fri Nov 02, 2012 3:45 pm

Demosthenex wrote:Converting the BMP files to JPG solves all the "white screen" issues.

Run these from within the new merged GSB directory:
find . -name '*.bmp' | while read X ; do NEW=$(echo $X | sed 's/\.bmp$/.jpg/g') ; [ -f "$NEW" ] || convert "$X" "$NEW" ; done
find . -name '*.dds' | while read X ; do NEW=$(echo $X | sed 's/\.dds$/.png/g') ; [ -f "$NEW" ] || convert "$X" "$NEW" ; done


Yes Those two lines are very handy indeed. Seems to fix this one problem.
NupupuN
Space cadet
Space cadet
 
Posts: 4
Joined: Fri Nov 02, 2012 12:58 pm

Re: Linux DLC

Postby cycyx on Fri Jan 11, 2013 9:35 pm

Just tested my script with Outcasts: worked like a charm! =)
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

No official Linux Support?

Postby allo on Sun Jan 27, 2013 8:07 am

Hi,
in my opinion it is strange. I bought GSB as part of the humblebundle because it was indicated as Linux compatible.
Now I'd like to buy some DLC (preferably all of them) and I am very interested in the galactic conquest DLC.

But I must read everywhere that these sddons are not supported for linux. While reading this forum I found that somebody
found a solution with the help of a Windows PC. Ok great, but I am not willing to buy a PC including Windows just to
convert some files.
Other users posted scripts which should convert the different races, but I do not know what these scripts do. I am not
willing to type some harmful code into my terminal. Sorry to these users, I do not think that you are going to post some
evil code, but I am better careful than sorry.
If a DLC conversion is a matter of three lines of code I wonder why Positech does not this conversion and sells the DLCs
usable for Linux also. For them it is not more than 5 mins of work, is it? Or at least would supply an official confirmed script?

I think the idea that the users should buy DLCs and then let them find out if they work or not is a strange business behaviour.
In that case GSB should never be advertised as Linux-compatible! A half-way strategy!

Are DLCs in real do not work or very seldom just at some Linux-Gurus? And Positech is nevertheless hoping to sell lots of them?
I really do not understand this.

This all to just save 5mins of work to convert their files, or to check and approve a user-supplied script if it does what it should?
5 mins! -or let it be 10 mins?
They do not take this time?

So will there be an official Linux support in future, or at least an official approved script for Galactic Conquest and the Race DLCs?
allo
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 6
Joined: Sun Jan 27, 2013 7:43 am

Re: Linux DLC

Postby cycyx on Sun Jan 27, 2013 8:56 am

Actually, last time I checked, Positech just didn't have the knowledge to insure Linux compatibility or even verify user scripts.
They don't know linux.

The Linux port included in the HiB was made by HiB team or contractor (icculus?). The DLC are not advertised as linux compatible anywhere on the official website (nor is the game itself).
So basically, you should ask HiB to check scripts/linux compatibility.

This isn't the first time this happens with HiB bundle: try to get on official answer from devs for Jamestown's DLC for example (you can't even buy it without Steam).

Now, if you want to be sure what a sript does, you can just actually "read" it: it's not a compiled program, it's a script, just and number of command lines grouped in a file to make the task simpler for users.

What I can tell you is the following (re my personal script): it uses a binary to uncompress the DLC (.exe programs can't be "understood" by Linux), copy the files in the correct folders and convert graphic files to another format.
Really, if you want to understand it, just install the required binaries (Image Magick and InnoExtract) and read their manual pages.

The script is hamrless, as long as you keep a safe copy of your installation folder.

Plus, as mentioned earlier, it is compatible with all the released DLC (as long as your DLC is correctly named).

Last thing, I follow this topic, and I'm practically stuck to my mail reader, so I can answer any question in a few hours.
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby allo on Tue Jan 29, 2013 11:31 pm

cycyx wrote:Actually, last time I checked, Positech just didn't have the knowledge to insure Linux compatibility or even verify user scripts.
They don't know linux. (...) The DLC are not advertised as linux compatible anywhere on the official website (nor is the game itself).

But obviously is their programming knowledge very well to produce clean code without just calling M$-routines.
So their game is doing well under Linux.

And the fact that it is running under Linux is for sure not a small sum in their pockets!
So a little effort/support is not asked too much, is it?

cycyx wrote:Last thing, I follow this topic, and I'm practically stuck to my mail reader, so I can answer any question in a few hours.


Thank you for your help.
I got the conversion done. the races are here, but the campaign button is not showing anywhere.
I double checked and tried to copy the campaign data files one more time, but there is no campaign mode.
I use Version 1.56. Any help would be great.
Thank you.

PS:(edit) I just found out that also the menu graphic should have changed. It is still the old one...
allo
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 6
Joined: Sun Jan 27, 2013 7:43 am

Re: Linux DLC

Postby cycyx on Wed Jan 30, 2013 7:20 am

Where did you copy the data files?

They must be inside a "campaign" directory in the main GSB folder. This is the main difference from the races DLC.

Hmmmm... Did you install Galactic Conquest using the script or manually (the script does install it in the correct directory...).

Last thing, re the money earned for the Linux version: it was a one shot thing. You could buy a Linux version from HiB, once, and now it's over.
Positech don't ensure compatibiliy for future version either...
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby allo on Wed Jan 30, 2013 1:58 pm

cycyx wrote:Where did you copy the data files?
They must be inside a "campaign" directory in the main GSB folder. This is the main difference from the races DLC.

Thank you, thank you, thank you very much!
This was it, i moved it into the data folder like all other DLCs.
btw. I did everything manually.

cycyx wrote:Last thing, re the money earned for the Linux version: it was a one shot thing. You could buy a Linux version from HiB, once, and now it's over.

Okay you are right. But...
But this one shot was not bad either. (based on HiB Diagrams I guess they made 20-30k$)
Not bad. What do you think? Money from users which would never ever have bought that game otherwise? So you see they made really a bunch of money with Linux users.
They got really good money for their work. Additionally some sold DLCs. And perhaps new customers for future DLCs.
It is okay! They should get paid well, so they can bring us other great games in future.

cycyx wrote:Positech don't ensure compatibiliy for future version either...

It is just a business decision. It is their business and they decide as they think its right for them.
I thought a little effort for this bunch of customers would not be the worst idea.
Obviously I am wrong, their business is running well, no need for 30.000 Linux customers.
If they want it that way, it is okay also.
allo
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 6
Joined: Sun Jan 27, 2013 7:43 am

Re: Linux DLC

Postby cycyx on Wed Jan 30, 2013 2:43 pm

Well, I have no shares in Positech, but I think there is a difference between what "they" want and what they can provide.

Positech, as many indie studio, is a one man company, and he doesn't have the knowledge to support Linux users.

That's fine by me: users on this forum can help each others, and Positech can continue to develop DLCs.

I have given Positech the option to "officialize" my script, but he hasn't the knowledge to verify it (imagine supporting binaries...), so we have to rely on each other.
User avatar
cycyx
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 8
Joined: Sat May 26, 2012 1:45 pm

Re: Linux DLC

Postby allo on Sat Feb 02, 2013 9:08 am

cycyx wrote:Positech, as many indie studio, is a one man company, and he doesn't have the knowledge to support Linux users.
That's fine by me: users on this forum can help each others, and Positech can continue to develop DLCs.
I have given Positech the option to "officialize" my script, but he hasn't the knowledge to verify it (imagine supporting binaries...), so we have to rely on each other.


Sorry, I didn't check before. I had a small company of 6-7 people in mind. My fault!

Okay, if Positech is only one man than it is understandable that he cannot do everything!
In that case I have agree to you.
I'd also agree to you that it is better he develops the game/DLCs instead of using time
in other things which have nothing to do with the core functionality.
allo
Ships Engineer (junior)
Ships Engineer (junior)
 
Posts: 6
Joined: Sun Jan 27, 2013 7:43 am

Re: Linux DLC

Postby cryptsphinx on Fri Jun 21, 2013 9:54 pm

Hi cycyx - thanks for posting a bash script for converting the DLC .
cryptsphinx
Space cadet
Space cadet
 
Posts: 1
Joined: Fri Jun 21, 2013 9:48 pm

PreviousNext

Return to Linux Support

Who is online

Users browsing this forum: No registered users and 1 guest