mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-26 23:59:43 +00:00
removed some non-portable parameters...
...and rewrote parameter parsing to be more readable
This commit is contained in:
parent
07349d0cc9
commit
f8def0c67d
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
scriptname="hexometer"
|
scriptname=$(basename $0)
|
||||||
help ()
|
help ()
|
||||||
{
|
{
|
||||||
echo "Search png images not fitting in a hex"
|
echo "Search png images not fitting in a hex"
|
||||||
@ -20,7 +20,7 @@ help ()
|
|||||||
echo "(-1 if the image is not a standard 72x72 image and -f was not used"
|
echo "(-1 if the image is not a standard 72x72 image and -f was not used"
|
||||||
}
|
}
|
||||||
|
|
||||||
mask="alphamask.png"
|
mask="$(dirname $0)/alphamask.png"
|
||||||
format=0
|
format=0
|
||||||
quiet=0
|
quiet=0
|
||||||
|
|
||||||
@ -30,55 +30,37 @@ anim=".*-attack.*|.*-defend.*|.*-melee.*|.*-ranged.*|.*-magic.*|.*-idle.*|.*-die
|
|||||||
|
|
||||||
until [ -z "$1" ]
|
until [ -z "$1" ]
|
||||||
do
|
do
|
||||||
if [ "$1" == "--help" -o "$1" == "-h" ]
|
case $1 in
|
||||||
then
|
-h|--help)
|
||||||
help
|
help
|
||||||
exit
|
exit;;
|
||||||
fi
|
-m|--mask)
|
||||||
|
shift
|
||||||
if [ "$1" == "--mask" -o "$1" == "-m" ]
|
mask="$1"
|
||||||
then
|
shift
|
||||||
shift
|
continue;;
|
||||||
mask="$1"
|
-r|--regex)
|
||||||
shift
|
shift
|
||||||
continue
|
regex="$regex|$1"
|
||||||
fi
|
shift
|
||||||
|
continue;;
|
||||||
if [ "$1" == "--regex" -o "$1" == "-r" ]
|
-a|--anim)
|
||||||
then
|
regex="$regex|$anim"
|
||||||
shift
|
shift
|
||||||
regex="$regex|$1"
|
continue;;
|
||||||
shift
|
-s|--suffix)
|
||||||
continue
|
regex="$regex|$suffix"
|
||||||
fi
|
shift
|
||||||
|
continue;;
|
||||||
if [ "$1" == "--anim" -o "$1" == "-a" ]
|
-f|--format)
|
||||||
then
|
format=1
|
||||||
regex="$regex|$anim"
|
shift
|
||||||
shift
|
continue;;
|
||||||
continue
|
-q|--quiet)
|
||||||
fi
|
quiet=1
|
||||||
|
shift
|
||||||
if [ "$1" == "--suffix" -o "$1" == "-s" ]
|
continue;;
|
||||||
then
|
esac
|
||||||
regex="$regex|$suffix"
|
|
||||||
shift
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" == "--format" -o "$1" == "-f" ]
|
|
||||||
then
|
|
||||||
format=1
|
|
||||||
shift
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" == "--quiet" -o "$1" == "-q" ]
|
|
||||||
then
|
|
||||||
quiet=1
|
|
||||||
shift
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# record all given directories
|
# record all given directories
|
||||||
dir="$dir $1"
|
dir="$dir $1"
|
||||||
@ -87,23 +69,23 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# if no directory, use current
|
# if no directory, use current
|
||||||
if [ "$dir" == "" ]
|
if [ "$dir" = "" ]
|
||||||
then
|
then
|
||||||
dir='.'
|
dir='.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -r $mask ]
|
if [ ! -r $mask ]
|
||||||
then
|
then
|
||||||
echo "$scriptname : cannot access $mask : No such file or directory "
|
echo "$scriptname: cannot access $mask: No such file or directory"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$quiet" == 0 ]
|
if [ "$quiet" = 0 ]
|
||||||
then
|
then
|
||||||
echo "Search 72x72 images not fitting in a hex"
|
echo "Search 72x72 images not fitting in a hex"
|
||||||
echo "in directories : $dir"
|
echo "in directories: $dir"
|
||||||
echo "Using alphamask image : $mask"
|
echo "Using alphamask image: $mask"
|
||||||
echo "Skipping files matching regex: $regex"
|
echo "Skipping files matching regex: $regex"
|
||||||
echo "Pixels out of hex : filename"
|
echo "Pixels out of hex : filename"
|
||||||
fi
|
fi
|
||||||
@ -112,7 +94,7 @@ test_img()
|
|||||||
{
|
{
|
||||||
if [ `identify -format "%wx%h" $img` != '72x72' ]
|
if [ `identify -format "%wx%h" $img` != '72x72' ]
|
||||||
then
|
then
|
||||||
if [ $format == 0 ]
|
if [ $format = 0 ]
|
||||||
then
|
then
|
||||||
px=-1
|
px=-1
|
||||||
else
|
else
|
||||||
@ -125,7 +107,7 @@ test_img()
|
|||||||
|
|
||||||
if [ "$px" != 0 ]
|
if [ "$px" != 0 ]
|
||||||
then
|
then
|
||||||
echo -e "$px\t : $img"
|
echo "$px : $img"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user