#! /bin/sh

cd "$(git rev-parse --show-toplevel)" || exit

material="base/textures/sprays/sprays.shader"
header="source/game/sprays.h"

rm -f "$material"
echo "// autogenerated by base/textures/sprays/gen_materials.sh" > "$header"

for f in base/textures/sprays/*.png; do
	name="$(basename "$f" .png)"

	{
		echo -e "textures/sprays/$name"
		echo -e "{"
		echo -e "\t{"
		echo -e "\t\tmap textures/sprays/$name"
		echo -e "\t}"
		echo -e "\tdecal"
		echo -e "}"
		echo -e ""
	} >> "$material"

	echo "\"textures/sprays/$name\"," >> "$header"
done

sed -i "$ d" "$material"
