summaryrefslogtreecommitdiff
path: root/src/resources/dye/dyepalette.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-13 17:35:36 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-13 17:35:36 +0300
commit22d13b5dab4984d260991fde4e727b1abc8d9b3d (patch)
tree96d2b3375df888709c7fd01a3e28f98d0ab105a4 /src/resources/dye/dyepalette.cpp
parentb842de88ed73ef8df2615014ad2984b136fa4238 (diff)
downloadmanaplus-22d13b5dab4984d260991fde4e727b1abc8d9b3d.tar.gz
manaplus-22d13b5dab4984d260991fde4e727b1abc8d9b3d.tar.bz2
manaplus-22d13b5dab4984d260991fde4e727b1abc8d9b3d.tar.xz
manaplus-22d13b5dab4984d260991fde4e727b1abc8d9b3d.zip
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
Diffstat (limited to 'src/resources/dye/dyepalette.cpp')
-rw-r--r--src/resources/dye/dyepalette.cpp14
1 files changed, 13 insertions, 1 deletions
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
{