| 1 | #!/bin/bash |
| 2 | |
| 3 | dir=`dirname $0` |
| 4 | |
| 5 | case $# in |
| 6 | 2) |
| 7 | ;; |
| 8 | *) |
| 9 | echo "usage: $0 cards.c cards.h" |
| 10 | exit 1 |
| 11 | ;; |
| 12 | esac |
| 13 | |
| 14 | ( |
| 15 | echo '#include "'"$2"'"' |
| 16 | for suit in C D H S; do |
| 17 | for rank in A 2 3 4 5 6 7 8 9 T J Q K; do |
| 18 | file="$dir"/cards/"$rank""$suit".svg |
| 19 | echo "const char svg_card_$rank$suit[]" = |
| 20 | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/ "/' -e 's/$/\\n"/' "$file" |
| 21 | echo " ;"; |
| 22 | echo "" |
| 23 | done |
| 24 | done |
| 25 | |
| 26 | file="$dir"/cards/kgames.svg |
| 27 | echo "const char svg_card_game[]" = |
| 28 | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/ "/' -e 's/$/\\n"/' "$file" |
| 29 | echo " ;"; |
| 30 | echo "" |
| 31 | |
| 32 | echo "const char *const svg_cards[52] = {" |
| 33 | for suit in C D H S; do |
| 34 | for rank in A 2 3 4 5 6 7 8 9 T J Q K; do |
| 35 | echo " svg_card_$rank$suit,"; |
| 36 | done |
| 37 | done |
| 38 | echo "};" |
| 39 | echo "" |
| 40 | ) > "$1" |
| 41 | |
| 42 | ( |
| 43 | echo '#define svg_card_width 270' |
| 44 | echo '#define svg_card_height 420' |
| 45 | echo "extern const char *const svg_cards[52];" |
| 46 | echo "extern const char svg_card_game[];" |
| 47 | ) > "$2" |