]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/rebrand-darkplaces-engine.sh
allow the path to xonotic.brand to come from XONOTIC_BRANDFILE
[xonotic/xonotic.git] / misc / tools / rebrand-darkplaces-engine.sh
index 19f05b12b094247fb3fc570e394a9e55ad25a402..6f6a76921336aa9b810ee8cde9b0ec8c88f36992 100755 (executable)
@@ -11,10 +11,22 @@ icon_icns=Darkplaces.app/Contents/Resources/Darkplaces.icns
 icon_ico=darkplaces.ico
 icon_xpm=darkplaces.xpm
 
+if [ -z "$1" ]; then
+       echo "Usage: $0 brandfile binaries..."
+       exit
+fi
 . "$1"; shift
 
-flags="$flags -customgamename \"$name\" -customgamedirname1 \"$dirname1\" -customgamedirname2 \"$dirname2\" -customgamescreenshotname \"$screenshotname\" -customuserdirname \"$userdirname\""
-echo "$flags" > darkplaces.opt
+d=`pwd`
+t=`mktemp -d -t darkplaces-rebrand.XXXXXX`
+
+flags="$flags -customgamename \"$name\" -customgamedirname1 \"$dirname1\" -customgamedirname2 \"$dirname2\" -customgamescreenshotname \"$screenshotname\" -customgameuserdirname \"$userdirname\""
+echo "$flags" > "$t/darkplaces.opt"
+
+cd "$t"
+zip -9r darkplaces.zip darkplaces.opt
+rm -f darkplaces.opt
+cd "$d"
 
 for EXECUTABLE in "$@"; do
        uses_xpm=false
@@ -48,40 +60,50 @@ for EXECUTABLE in "$@"; do
        esac
 
        # add a selfpack
-       rm -f darkplaces.zip
-       zip -9r darkplaces.zip darkplaces.opt
+       cp "$t/darkplaces.zip" "$t/darkplaces-this.zip"
 
        if $uses_xpm; then
-               cp "$icon_xpm" darkplaces-icon.xpm
-               zip -9r darkplaces.zip darkplaces-icon.xpm
-               rm -f darkplaces-icon.xpm
+               cp "$icon_xpm" "$t/darkplaces-icon.xpm"
+               cd "$t"
+               zip -9r darkplaces-this.zip darkplaces-icon.xpm
+               cd "$d"
        fi
 
-#      if $uses_ico; then
-#              e=$EXECUTABLE \
-#              i=$icon_ico \
-#              n=$name \
-#              perl <<'EOF'
-#              use strict;
-#              use warnings;
-#              use Win32::Exe;
-#
-#              my $n = $ENV{n};
-#              my $i = $ENV{i};
-#              my $e = $ENV{e};
-#
-#              my $exe = Win32::Exe->new($e)
-#                      or die "Win32::Exe->new: $!";
-#              $exe = $exe->create_resource_section()
-#                      unless $exe->has_resource_section();
-#              $exe->update(icon => $i);
-#              $exe->update(info => ["InternalName=$e"]);
-#              $exe->update(info => ["OriginalFilename=$e"]);
-#              $exe->update(info => ["ProductName=$n"]);
-#              $exe->write($e)
-#                      or die "Win32::Exe->write: $!";
-#EOF
-#      fi
+       if $uses_ico; then
+               cp "$icon_ico" "$t/darkplaces-icon.ico"
+               cp "$EXECUTABLE" "$t/darkplaces.exe"
+               cat >"$t/darkplaces.rc" <<EOF
+#include <windows.h> // include for version info constants
+
+A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "darkplaces-icon.ico"
+
+1 VERSIONINFO
+FILEVERSION 1,0,0,0
+PRODUCTVERSION 1,0,0,0
+FILETYPE VFT_APP
+{
+  BLOCK "StringFileInfo"
+        {
+                BLOCK "040904E4"
+                {
+                        VALUE "CompanyName", "Forest Hale Digital Services"
+                        VALUE "FileVersion", "1.0"
+                        VALUE "FileDescription", "$name"
+                        VALUE "InternalName", "${EXECUTABLE##*/}"
+                        VALUE "LegalCopyright", "id Software, Forest Hale, and contributors"
+                        VALUE "LegalTrademarks", ""
+                        VALUE "OriginalFilename", "${EXECUTABLE##*/}"
+                        VALUE "ProductName", "$name"
+                        VALUE "ProductVersion", "1.0"
+                }
+        }
+}
+EOF
+               cd "$t"
+               wine "c:/Program Files/ResEdit/ResEdit.exe" -convert darkplaces.rc darkplaces.exe
+               cd "$d"
+               mv "$t/darkplaces.exe" "$EXECUTABLE"
+       fi
 
        if $uses_icns; then
                # OS X is special here
@@ -93,8 +115,9 @@ for EXECUTABLE in "$@"; do
                                pkgdir=..
                                ;;
                esac
-               cp "$icon_icns" "$pkgdir/Resources/Darkplaces.icns"
-               cat <<EOF >"$pkgdir/Resources/English.lproj/InfoPlist.strings"
+               if [ -d "$pkgdir/Resources" ]; then
+                       cp "$icon_icns" "$pkgdir/Resources/Darkplaces.icns"
+                       cat <<EOF >"$pkgdir/Resources/English.lproj/InfoPlist.strings"
 /* Localized versions of Info.plist keys */
 
 CFBundleName = "$name";
@@ -102,10 +125,10 @@ CFBundleShortVersionString = "$name";
 CFBundleGetInfoString = "Darkplaces by Forest 'LordHavoc' Hale";
 NSHumanReadableCopyright = "Copyright `date +%Y`";
 EOF
+               fi
        fi
 
-       cat darkplaces.zip >> "$EXECUTABLE"
-       rm -f darkplaces.zip
+       cat "$t/darkplaces-this.zip" >> "$EXECUTABLE"
 done
 
-rm -f darkplaces.opt
+rm -rf "$t"