Improve code converting doors.
Extract code into function. Add workarounds for non-standart sizes. Handle animated textures. Fixes #16
This commit is contained in:
parent
62cdf5f92a
commit
9166e21931
@ -35,6 +35,41 @@ convert_alphatex() {
|
||||
fi
|
||||
}
|
||||
|
||||
compose_door() {
|
||||
l=$1
|
||||
u=$2
|
||||
r=$3
|
||||
|
||||
if [ -f $l -a -f $u ]; then
|
||||
# Cut out first frame if animated texture
|
||||
if [ -e $l.mcmeta ]; then
|
||||
w=`file $l |sed 's/.*, \([0-9]*\) x.*/\1/'`
|
||||
convert $l -background none -crop ${w}x${w}+0+0 _n/_cl.png
|
||||
l=_n/_cl.png
|
||||
fi
|
||||
if [ -e $u.mcmeta ]; then
|
||||
w=`file $u |sed 's/.*, \([0-9]*\) x.*/\1/'`
|
||||
convert $u -background none -crop ${w}x${w}+0+0 _n/_cu.png
|
||||
u=_n/_cu.png
|
||||
fi
|
||||
convert -background none $u -resize ${PXSIZE}x${PXSIZE} _n/_u.png
|
||||
convert -background none $l -resize ${PXSIZE}x${PXSIZE} _n/_l.png
|
||||
convert -background none _n/_u.png -flop _n/_fu.png
|
||||
convert -background none _n/_l.png -flop _n/_fl.png
|
||||
montage -background none _n/_fu.png _n/_u.png _n/_fl.png _n/_l.png -geometry +0+0 _n/_d.png
|
||||
convert _n/_d.png -background none -extent $(( (PXSIZE * 2) + (3 * (PXSIZE / 8) ) ))x$((PXSIZE * 2)) _n/_d2.png
|
||||
convert _n/_d2.png \
|
||||
\( -clone 0 -crop $((PXSIZE/8))x$((PXSIZE*2))+$((PXSIZE-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(PXSIZE/8)))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(3*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(4*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(5*(PXSIZE/16))))+0 -composite \
|
||||
$r
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
convert_file() {
|
||||
n=`basename "$@" .zip | tr -d ' \t."()[]' | tr -d "'"`
|
||||
echo "Found: $n"
|
||||
@ -75,7 +110,7 @@ convert_file() {
|
||||
if [ ! -d "$assets_dir"/minecraft/textures ]; then
|
||||
echo "No directory \"$assets_dir/minecraft/textures\" found in $@"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# beware of zip files with a random extra toplevel folder.
|
||||
ln -sf _z/"$assets_dir"/minecraft/textures ../_n || exit 1
|
||||
cd ..
|
||||
@ -280,8 +315,8 @@ RENAMES
|
||||
echo -e "." >> _n/_counter
|
||||
cp "_z/$IN" "$OUT"
|
||||
# uncomment below 2 lines to see if any textures were not found.
|
||||
#else
|
||||
# echo "+$IN $OUT $FLAG: Not Found"
|
||||
else
|
||||
echo "+$IN $OUT $FLAG: Not Found"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -381,38 +416,12 @@ RENAMES
|
||||
|
||||
# compose doors texture maps
|
||||
echo -e "." >> _n/_tot
|
||||
if [ -f _n/blocks/door_wood_lower.png -a -f _n/blocks/door_wood_upper.png ]; then
|
||||
convert -background none _n/blocks/door_wood_upper.png -flop _n/_fu.png
|
||||
convert -background none _n/blocks/door_wood_lower.png -flop _n/_fl.png
|
||||
montage -background none _n/_fu.png _n/blocks/door_wood_upper.png \
|
||||
_n/_fl.png _n/blocks/door_wood_lower.png \
|
||||
-geometry +0+0 _n/_d.png
|
||||
convert _n/_d.png -background none -extent $(( (PXSIZE * 2) + (3 * (PXSIZE / 8) ) ))x$((PXSIZE * 2)) _n/_d2.png
|
||||
convert _n/_d2.png \
|
||||
\( -clone 0 -crop $((PXSIZE/8))x$((PXSIZE*2))+$((PXSIZE-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(PXSIZE/8)))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(3*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(4*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(5*(PXSIZE/16))))+0 -composite \
|
||||
doors_door_wood.png
|
||||
if compose_door _n/blocks/door_wood_lower.png _n/blocks/door_wood_upper.png doors_door_wood.png; then
|
||||
echo -e "." >> _n/_counter
|
||||
fi
|
||||
|
||||
echo -e "." >> _n/_tot
|
||||
if [ -f _n/blocks/door_iron_lower.png -a -f _n/blocks/door_iron_upper.png ]; then
|
||||
convert -background none _n/blocks/door_iron_upper.png -flop _n/_fu.png
|
||||
convert -background none _n/blocks/door_iron_lower.png -flop _n/_fl.png
|
||||
montage -background none _n/_fu.png _n/blocks/door_iron_upper.png \
|
||||
_n/_fl.png _n/blocks/door_iron_lower.png \
|
||||
-geometry +0+0 _n/_d.png
|
||||
convert _n/_d.png -background none -extent $(( (PXSIZE * 2) + (3 * (PXSIZE / 8) ) ))x$((PXSIZE * 2)) _n/_d2.png
|
||||
convert _n/_d2.png \
|
||||
\( -clone 0 -crop $((PXSIZE/8))x$((PXSIZE*2))+$((PXSIZE-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(PXSIZE/8)))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(3*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+0+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(4*(PXSIZE/16))))+0 -composite \
|
||||
\( -clone 0 -crop $((PXSIZE/16))x$((PXSIZE*2))+$((PXSIZE*2-1))+0 \) -gravity NorthWest -geometry +$((PXSIZE*2+(5*(PXSIZE/16))))+0 -composite \
|
||||
doors_door_steel.png
|
||||
if compose_door _n/blocks/door_iron_lower.png _n/blocks/door_iron_upper.png doors_door_steel.png; then
|
||||
echo -e "." >> _n/_counter
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user