]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/cached-converter.sh
more bugfixes...
[xonotic/xonotic.git] / misc / tools / cached-converter.sh
index f7fd47e2f398049c0ab7e3bcc1a2fe814e23275e..6d6b7684421cc23487dc6428879c19630126138a 100755 (executable)
@@ -4,6 +4,7 @@ set -e
 
 : ${CACHEDIR:=$HOME/.xonotic-cached-converter}
 : ${do_jpeg:=true}
+: ${do_jpeg_if_not_dds:=false}
 : ${jpeg_qual_rgb:=95}
 : ${jpeg_qual_a:=99}
 : ${do_dds:=true}
@@ -168,18 +169,28 @@ for F in "$@"; do
        echo >&2 "Handling $F..."
        conv=false
        keep=false
+
        will_jpeg=$do_jpeg
        will_dds=$do_dds
        case "$F" in
-               textures/*) ;;
-               models/*) ;;
-               maps/*/*) ;;
+               ./textures/*) ;;
+               ./models/*) ;;
+               ./maps/*/*) ;;
                *)
                        # we can't DDS compress the 2D textures, sorry
                        # but JPEG is still fine
                        will_dds=false
                        ;;
        esac
+
+       if $do_jpeg_if_not_dds; then
+               if $will_dds; then
+                       will_jpeg=false
+               else
+                       will_jpeg=true
+               fi
+       fi
+
        case "$F" in
                *_alpha.jpg)
                        # handle in *.jpg case
@@ -205,11 +216,9 @@ for F in "$@"; do
                        if [ -s "$F.hasalpha" ]; then
                                cached "$will_dds"  reduce_rgba_dds    "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
                                cached "$will_jpeg" reduce_rgba_jpeg2  "$F" ""                  "${F%.*}.jpg"     "${F%.*}_alpha.jpg" "$jpeg_qual_rgb" "$jpeg_qual_a"
-                               rm -f "$F" # TGA becomes useless after JPEGging
                        else                                                             
                                cached "$will_dds"  reduce_rgb_dds     "$F" ""                  "dds/${F%.*}.dds" ""                  "$dds_flags"
                                cached "$will_jpeg" reduce_rgb_jpeg    "$F" ""                  "${F%.*}.jpg"     ""                  "$jpeg_qual_rgb"
-                               rm -f "$F" # TGA becomes useless after JPEGging
                        fi
                        rm -f "$F.hasalpha"
                        ;;