rebrand: also add TGA icons (possibly converted from png)
[xonotic/xonotic.git] / misc / tools / rebrand-darkplaces-engine.sh
index 50c6a588ffa22a3f3e399d9714370f8c3f6ab3e3..0e911bb37ecf750b2f0160e9d8c0faf854827bc4 100755 (executable)
@@ -10,11 +10,24 @@ userdirname=darkplaces
 icon_icns=Darkplaces.app/Contents/Resources/Darkplaces.icns
 icon_ico=darkplaces.ico
 icon_xpm=darkplaces.xpm
+icons_tga=
 
+if [ -z "$1" ] || [ x"$1" = x"--help" ]; then
+       echo "Usage: $0 brandfile binaries..."
+       exit
+fi
 . "$1"; shift
 
+d=`pwd`
+t=`mktemp -d -t darkplaces-rebrand.XXXXXX`
+
 flags="$flags -customgamename \"$name\" -customgamedirname1 \"$dirname1\" -customgamedirname2 \"$dirname2\" -customgamescreenshotname \"$screenshotname\" -customgameuserdirname \"$userdirname\""
-echo "$flags" > darkplaces.opt
+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,22 +61,31 @@ 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"
+               cnt=
+               for i in $icons_tga; do
+                       convert "$i" "$t/darkplaces-icon$cnt.tga"
+                       if [ -z "$cnt" ]; then
+                               cnt=2
+                       else
+                               cnt=$(($cnt+1))
+                       fi
+               done
+               cd "$t"
+               zip -9r darkplaces-this.zip darkplaces-icon*
+               cd "$d"
        fi
 
        if $uses_ico; then
-               cp "$icon_ico" darkplaces-rebrand.ico
-               cp "$EXECUTABLE" darkplaces-rebrand.exe
-               cat >darkplaces-rebrand.rc <<EOF
+               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-rebrand.ico"
+A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "darkplaces-icon.ico"
 
 1 VERSIONINFO
 FILEVERSION 1,0,0,0
@@ -87,9 +109,10 @@ FILETYPE VFT_APP
         }
 }
 EOF
-               wine ~/ResEdit/ResEdit.exe -convert darkplaces-rebrand.rc darkplaces-rebrand.exe
-               rm -f darkplaces-rebrand.rc darkplaces-rebrand.ico
-               mv darkplaces-rebrand.exe "$EXECUTABLE"
+               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
@@ -102,8 +125,9 @@ EOF
                                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";
@@ -111,10 +135,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"