summaryrefslogtreecommitdiff
path: root/navit/navit_layout_car_generatedarkxml.sh
diff options
context:
space:
mode:
Diffstat (limited to 'navit/navit_layout_car_generatedarkxml.sh')
-rwxr-xr-xnavit/navit_layout_car_generatedarkxml.sh121
1 files changed, 67 insertions, 54 deletions
diff --git a/navit/navit_layout_car_generatedarkxml.sh b/navit/navit_layout_car_generatedarkxml.sh
index 9c3aa70ca..16a6ce04b 100755
--- a/navit/navit_layout_car_generatedarkxml.sh
+++ b/navit/navit_layout_car_generatedarkxml.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# This script automatically converts the rgb colors used for the polygons in the
+# This script automatically converts the rgb colors used for the layers in
# navit_layout_car_shipped.xml to the values appropriate for the dark layout in
# navit_layout_car_dark_shipped.xml.
# It's a bit of a mess, but gets the job done.
@@ -14,78 +14,91 @@ ifd=navit_layout_car_dark_shipped.xml
# Temporary dark output file
ofd=$ifd.new
-# Create new temporary dark output file
-[ -f $ofd ] && rm -f $ofd
-touch $ofd
+# Iterate over all layers in dark input file
+grep \<layer\ name=\" $ifd | cut -d\" -f2 | while read -r layer
+do
-# Init: not in polygons layer
-inpolygons=false
-getpolygons=false
+ echo $layer
-# Read dark input file
-while read -r l
-do
+ # Create new temporary dark output file
+ [ -f $ofd ] && rm -f $ofd
+ touch $ofd
- # Check to see if inside polygons layer - open tag
- if [[ $l =~ .*\<layer\ name=\"polygons\"\>.* ]]; then
- inpolygons=true
- getpolygons=true
- fi
+ # Init: not in layer
+ inlayer=false
+ getlayer=false
- # Check to see if inside polygons layer - close tag
- if [[ $l =~ .*\</layer\>.* ]]; then
- inpolygons=false
- fi
+ # Read dark input file
+ while read -r l
+ do
- # Trigger once when polygons open tag found in dark input file
- if [ $getpolygons == true ]; then
+ # Check to see if inside layer - open tag
+ if [[ $l =~ .*\<layer\ name=\"$layer\"\>.* ]]; then
+ inlayer=true
+ getlayer=true
+ fi
- getpolygons=false # Just triggered
- inpolygons=false # Now used for light input file
+ # Check to see if inside layer - close tag
+ if [[ $l =~ .*\</layer\>.* ]]; then
+ inlayer=false
+ fi
- # Insert data from light input file
- while read -r l
- do
+ # Trigger once when open tag found in dark input file
+ if [ $getlayer == true ]; then
- # Check to see if inside polygons layer
- if [[ $l =~ .*\<layer\ name=\"polygons\"\>.* ]]; then
- inpolygons=true
- fi
+ getlayer=false # Just triggered
+ inlayer=false # Now used for light input file
- if [[ $l =~ .*\</layer\>.* ]]; then
- inpolygons=false
- fi
+ # Insert data from light input file
+ while read -r l
+ do
- # Inside polygons layer
- if [ $inpolygons == true ]; then
+ # Check to see if inside layer - open tag
+ if [[ $l =~ .*\<layer\ name=\"$layer\"\>.* ]]; then
+ inlayer=true
+ fi
- if [[ $l =~ .*color=\"#[0-9a-fA-F]{6}.* ]]; then # Contains rgb(a) color
- coll=$(echo $l | cut -d# -f2 | cut -c-6) # Get rgb color and convert
- cold=$( printf '%02x' $(echo $(printf "%d" 0x${coll:0:2})/16+16 | bc))
- cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:2:2})/10+14 | bc))
- cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:4:2})/8+12 | bc))
- l=$(echo $l | sed "s/#$coll/#$cold/") # Replace color
+ # Check to see if inside layer - close tag
+ if [[ $l =~ .*\</layer\>.* ]]; then
+ inlayer=false
fi
- l=$(echo $l | sed "s/<text /<text color=\"#55c4bd\" background_color=\"#000000\" /") # Add text color
+ # Inside layer
+ if [ $inlayer == true ]; then
- echo $l >> $ofd # (Modified) line from light input file to dark output file
+ # Modify color
+ if [[ $l =~ .*color=\"#[0-9a-fA-F]{6}.* ]]; then # Contains rgb(a) color
+ coll=$(echo $l | cut -d# -f2 | cut -c-6) # Get rgb color and convert
+ cold=$( printf '%02x' $(echo $(printf "%d" 0x${coll:0:2})/16+16 | bc))
+ cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:2:2})/10+14 | bc))
+ cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:4:2})/8+12 | bc))
+ l=$(echo $l | sed "s/#$coll/#$cold/") # Replace color
+ fi
- fi
+ # Misc. modifications
+ l=$(echo $l | sed -r "s/_bk\./_wh\./") # Black to white icons
+ l=$(echo $l | sed -r "s/(<text )/\1color=\"#55c4bd\" background_color=\"#000000\" /") # Add text color
+ l=$(echo $l | sed -r "s/(<circle color=\"#[0-9a-fA-F]{6,8}\" )/\1background_color=\"#000000\" /") # Add circle bg color
+
+ echo $l >> $ofd # Modified line from light input file to dark output file
+
+ fi
+
+ done < $ifl # Read light input file
+ inlayer=true # Done inserting, still in layer in dark input file
- done < $ifl # Read light input file
- inpolygons=true # Done inserting, still in polygons layer in dark input file
+ else
- else
+ # Outside layer
+ if [ $inlayer == false ]; then
+ echo $l >> $ofd # Just copy as-is to dark output file
+ fi
- # Outside polygons layer
- if [ $inpolygons == false ]; then
- echo $l >> $ofd # Just copy as-is to dark output file
fi
- fi
+ done < $ifd # Read dark input file
-done < $ifd # Read dark input file
+ cp $ofd $ifd # Replace
+ rm -f $ofd # Clean up
-cp $ofd $ifd # Replace
-rm -f $ofd # Clean up
+done # Next layer in dark input file