From 22d13b5dab4984d260991fde4e727b1abc8d9b3d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 13 Jan 2016 17:35:36 +0300 Subject: In dye palette aAdd support for setting alpha color with colors from GIMP palette. Example: @color1,+25,color2,color3 color1 using alpha channel 0xff color2 and color3 using alpha channel 0x25 --- src/resources/dye/dyepalette.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/resources/dye/dyepalette.cpp') diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index e3b3964ff..19ded4295 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -59,13 +59,25 @@ DyePalette::DyePalette(const std::string &restrict description, #ifndef DYECMD else if (description[0] == '@') { + uint8_t alpha = 255; FOR_EACH (StringVectCIter, it, parts) { const std::string str = *it; + if (str.empty()) + continue; + if (str[0] == '+') + { + if (str.size() != 3) + continue; + alpha = (hexDecode(str[1]) << 4) + hexDecode(str[2]); + continue; + } const DyeColor *const color = PaletteDB::getColor(str); if (color) { - mColors.push_back(*color); + DyeColor color2 = *color; + color2.value[3] = alpha; + mColors.push_back(color2); } else { -- cgit v1.2.3-70-g09d2