]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rebrand-darkplaces-engine.sh
Merge branch 'master' into divVerent/crypto2
[xonotic/xonotic.git] / misc / tools / rebrand-darkplaces-engine.sh
1 #!/bin/sh
2
3 # all these shall be defined in a .brand file passed as first argument
4 flags="-quake"
5 name=DarkPlaces-Quake
6 dirname1=id1
7 dirname2=
8 screenshotname=dp
9 userdirname=darkplaces
10 icon_icns=Darkplaces.app/Contents/Resources/Darkplaces.icns
11 icon_ico=darkplaces.ico
12 icon_xpm=darkplaces.xpm
13
14 if [ -z "$1" ] || [ x"$1" = x"--help" ]; then
15         echo "Usage: $0 brandfile binaries..."
16         exit
17 fi
18 . "$1"; shift
19
20 d=`pwd`
21 t=`mktemp -d -t darkplaces-rebrand.XXXXXX`
22
23 flags="$flags -customgamename \"$name\" -customgamedirname1 \"$dirname1\" -customgamedirname2 \"$dirname2\" -customgamescreenshotname \"$screenshotname\" -customgameuserdirname \"$userdirname\""
24 echo "$flags" > "$t/darkplaces.opt"
25
26 cd "$t"
27 zip -9r darkplaces.zip darkplaces.opt
28 rm -f darkplaces.opt
29 cd "$d"
30
31 for EXECUTABLE in "$@"; do
32         uses_xpm=false
33         uses_ico=false
34         uses_icns=false
35
36         # detect what the executable is
37         case "`file -b "$EXECUTABLE"`" in
38                 *ELF*)
39                         case "$EXECUTABLE" in
40                                 *-dedicated)
41                                         ;;
42                                 *)
43                                         uses_xpm=true
44                                         ;;
45                         esac
46                         ;;
47                 *Mach*)
48                         uses_icns=true
49                         case "$EXECUTABLE" in
50                                 *-sdl)
51                                         uses_xpm=true
52                                         ;;
53                                 *)
54                                         ;;
55                         esac
56                         ;;
57                 *PE*)
58                         uses_ico=true
59                         ;;
60         esac
61
62         # add a selfpack
63         cp "$t/darkplaces.zip" "$t/darkplaces-this.zip"
64
65         if $uses_xpm; then
66                 cp "$icon_xpm" "$t/darkplaces-icon.xpm"
67                 cd "$t"
68                 zip -9r darkplaces-this.zip darkplaces-icon.xpm
69                 cd "$d"
70         fi
71
72         if $uses_ico; then
73                 cp "$icon_ico" "$t/darkplaces-icon.ico"
74                 cp "$EXECUTABLE" "$t/darkplaces.exe"
75                 cat >"$t/darkplaces.rc" <<EOF
76 #include <windows.h> // include for version info constants
77
78 A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "darkplaces-icon.ico"
79
80 1 VERSIONINFO
81 FILEVERSION 1,0,0,0
82 PRODUCTVERSION 1,0,0,0
83 FILETYPE VFT_APP
84 {
85   BLOCK "StringFileInfo"
86          {
87                  BLOCK "040904E4"
88                  {
89                          VALUE "CompanyName", "Forest Hale Digital Services"
90                          VALUE "FileVersion", "1.0"
91                          VALUE "FileDescription", "$name"
92                          VALUE "InternalName", "${EXECUTABLE##*/}"
93                          VALUE "LegalCopyright", "id Software, Forest Hale, and contributors"
94                          VALUE "LegalTrademarks", ""
95                          VALUE "OriginalFilename", "${EXECUTABLE##*/}"
96                          VALUE "ProductName", "$name"
97                          VALUE "ProductVersion", "1.0"
98                  }
99          }
100 }
101 EOF
102                 cd "$t"
103                 wine "c:/Program Files/ResEdit/ResEdit.exe" -convert darkplaces.rc darkplaces.exe
104                 cd "$d"
105                 mv "$t/darkplaces.exe" "$EXECUTABLE"
106         fi
107
108         if $uses_icns; then
109                 # OS X is special here
110                 case "$EXECUTABLE" in
111                         */*)
112                                 pkgdir="${EXECUTABLE%/*}/.."
113                                 ;;
114                         *)
115                                 pkgdir=..
116                                 ;;
117                 esac
118                 if [ -d "$pkgdir/Resources" ]; then
119                         cp "$icon_icns" "$pkgdir/Resources/Darkplaces.icns"
120                         cat <<EOF >"$pkgdir/Resources/English.lproj/InfoPlist.strings"
121 /* Localized versions of Info.plist keys */
122
123 CFBundleName = "$name";
124 CFBundleShortVersionString = "$name";
125 CFBundleGetInfoString = "Darkplaces by Forest 'LordHavoc' Hale";
126 NSHumanReadableCopyright = "Copyright `date +%Y`";
127 EOF
128                 fi
129         fi
130
131         cat "$t/darkplaces-this.zip" >> "$EXECUTABLE"
132 done
133
134 rm -rf "$t"