diff --git a/README.rst b/README.rst index 846481f..ec881ea 100644 --- a/README.rst +++ b/README.rst @@ -70,6 +70,17 @@ colors : * For compatibility, in the current directory as a last resort. This causes a warning message to be printed. + If the colors file contains duplicate entries for the same node, + one with alpha = 255, or absent, and one with alpha < 255, the former + is used without 'drawalpha', and the latter is used with 'drawalpha': + +:: + + # Entry that is used without 'drawalpha': + default:water-source 39 66 106 + # Entry that is used with 'drawalpha': + default:water-source 78 132 212 64 224 + bgcolor: Background color of image, `--bgcolor #ffffff` diff --git a/TileGenerator.cpp b/TileGenerator.cpp index 5bab022..c1ad2b6 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -344,6 +344,28 @@ void TileGenerator::parseColorsStream(std::istream &in, const std::string &filen t = 0; iline >> t; color = ColorEntry(r,g,b,a,t); + if ((m_drawAlpha && a == 0xff) || (!m_drawAlpha && a != 0xff)) { + // If drawing alpha, and the colors file contains both + // an opaque entry and a non-opaque entry for a name, prefer + // the non-opaque entry + // If not drawing alpha, and the colors file contains both + // an opaque entry and a non-opaque entry for a name, prefer + // the opaque entry + // Otherwise, any later entry overrides any previous entry + ColorMap::iterator it = m_colors.find(name); + if (it != m_colors.end()) { + if (m_drawAlpha && (a == 0xff && it->second.a != 0xff)) { + // drawing alpha: don't use opaque color to override + // non-opaque color + continue; + } + if (!m_drawAlpha && (a != 0xff && it->second.a == 0xff)) { + // not drawing alpha: don't use non-opaque color to + // override opaque color + continue; + } + } + } m_colors[name] = color; } if (!in.eof()) { diff --git a/colors.txt b/colors.txt index baf9db9..19b12b0 100644 --- a/colors.txt +++ b/colors.txt @@ -1467,7 +1467,8 @@ mesecons_walllever:wall_lever_on 136 136 136 mesecons_walllever:wall_lever_off 136 136 136 bones:bones 74 74 74 default:glass 192 192 227 64 16 -default:water_flowing 39 66 106 128 224 +default:water_flowing 39 66 106 +default:water_flowing 78 132 212 64 224 default:junglesapling 37 34 14 default:sandstonebrick 160 144 108 default:furnace_active 97 93 91 @@ -1505,7 +1506,8 @@ default:desert_stone 122 74 57 default:tree 66 52 35 default:jungletree 120 106 78 default:cactus 132 143 108 -default:water_source 39 66 106 128 224 +default:water_source 39 66 106 +default:water_source 78 132 212 64 224 default:mese 200 202 0 default:stone_with_coal 91 88 87 default:nyancat 38 16 66