-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateResourceFile.sh
executable file
·48 lines (40 loc) · 1.59 KB
/
generateResourceFile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
rcpOutputFile="resources/graphicResources.rcp"
hOutputFile="sauce/graphicResources.h"
assetsPath="resources/assets/"
fileSuffix=".bmp"
fileHiResSuffix="-144.bmp"
hires=0
if [ "$1" == "--hires" ]; then
hires=1
echo "Hires resources enabled"
fi
if [ -f $rcpOutputFile ]; then
rm $rcpOutputFile
fi
echo "#ifndef GRAPHICRESOURCES_H_" > $hOutputFile
echo "#define GRAPHICRESOURCES_H_" >> $hOutputFile
while IFS=';' read -r identifier name
do
# RCP FILE GENERATION
echo "BITMAPFAMILY ID $identifier" >> $rcpOutputFile
echo "BEGIN" >> $rcpOutputFile
hiresFile=$assetsPath$name$fileHiResSuffix
if [ $hires == 1 ] && [ -f $hiresFile ]; then
echo " BITMAP \"$assetsPath$name$fileHiResSuffix\" BPP 8 TRANSPARENTINDEX 4 DENSITY 144 COMPRESS" >> $rcpOutputFile
else
echo " BITMAP \"$assetsPath$name$fileSuffix\" BPP 8 TRANSPARENTINDEX 4 COMPRESS" >> $rcpOutputFile
#echo " BITMAP \"$assetsPath$name$fileSuffix\" BPP 4 TRANSPARENTINDEX 4 COMPRESS" >> $rcpOutputFile
fi
echo "END" >> $rcpOutputFile
# H FILE GENERATION
echo "#define GFX_RES_${name^^} $identifier" >> $hOutputFile
done < "resources/graphicResources.map"
# Find total number of frames for animation sets:
results=$(awk -F';' '{print $2}' "resources/graphicResources.map" | grep _ | awk '{gsub("_", ";"); print}' | sort -u | awk -F";" '{if($2 > max[$1]) max[$1] = $2} END {for (i in max) print i ";" max[i]}')
while IFS=';' read -r name maxCount
do
((maxCount++))
echo "#define GFX_FRAMECOUNT_${name^^} $maxCount" >> $hOutputFile
done <<< "$results"
echo "#endif" >> $hOutputFile