]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/rebrand-darkplaces-engine.sh
Revert "Update Windows 32 bit SDL build dependency to 2.0.10"
[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                         case "$EXECUTABLE" in
60                                 *-dedicated.exe)
61                                         ;;
62                                 *)
63                                         uses_ico=true
64                                         ;;
65                         esac
66                         ;;
67         esac
68
69         # add a selfpack
70         cp "$t/darkplaces.zip" "$t/darkplaces-this.zip"
71
72         if $uses_xpm; then
73                 cp "$icon_xpm" "$t/darkplaces-icon.xpm"
74                 cnt=
75                 for i in $icons_tga; do
76                         convert "$i" "$t/darkplaces-icon$cnt.tga"
77                         if [ -z "$cnt" ]; then
78                                 cnt=2
79                         else
80                                 cnt=$(($cnt+1))
81                         fi
82                 done
83                 cd "$t"
84                 zip -9r darkplaces-this.zip darkplaces-icon*
85                 cd "$d"
86         fi
87
88         if $uses_ico; then
89                 cp "$icon_ico" "$t/darkplaces-icon.ico"
90                 cp "$EXECUTABLE" "$t/darkplaces.exe"
91                 cat >"$t/darkplaces.rc" <<EOF
92 #include <windows.h> // include for version info constants
93
94 A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "darkplaces-icon.ico"
95
96 1 VERSIONINFO
97 FILEVERSION 1,0,0,0
98 PRODUCTVERSION 1,0,0,0
99 FILETYPE VFT_APP
100 {
101   BLOCK "StringFileInfo"
102          {
103                  BLOCK "040904E4"
104                  {
105                          VALUE "CompanyName", "Forest Hale Digital Services"
106                          VALUE "FileVersion", "1.0"
107                          VALUE "FileDescription", "$name"
108                          VALUE "InternalName", "${EXECUTABLE##*/}"
109                          VALUE "LegalCopyright", "id Software, Forest Hale, and contributors"
110                          VALUE "LegalTrademarks", ""
111                          VALUE "OriginalFilename", "${EXECUTABLE##*/}"
112                          VALUE "ProductName", "$name"
113                          VALUE "ProductVersion", "1.0"
114                  }
115          }
116 }
117 EOF
118                 cd "$t"
119                 wine "c:/Program Files/ResEdit/ResEdit.exe" -convert darkplaces.rc darkplaces.exe
120                 cd "$d"
121                 mv "$t/darkplaces.exe" "$EXECUTABLE"
122         fi
123
124         if $uses_icns; then
125                 # OS X is special here
126                 case "$EXECUTABLE" in
127                         */*)
128                                 pkgdir="${EXECUTABLE%/*}/.."
129                                 ;;
130                         *)
131                                 pkgdir=..
132                                 ;;
133                 esac
134                 if [ -d "$pkgdir/Resources" ]; then
135                         cp "$icon_icns" "$pkgdir/Resources/Darkplaces.icns"
136                         cat <<EOF >"$pkgdir/Resources/English.lproj/InfoPlist.strings"
137 /* Localized versions of Info.plist keys */
138
139 CFBundleName = "$name";
140 CFBundleShortVersionString = "$name";
141 CFBundleGetInfoString = "Darkplaces by Forest 'LordHavoc' Hale";
142 NSHumanReadableCopyright = "Copyright `date +%Y`";
143 EOF
144                 fi
145         fi
146
147         cat "$t/darkplaces-this.zip" >> "$EXECUTABLE"
148 done
149
150 rm -rf "$t"