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