summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/string.cpp13
-rw-r--r--src/util/string.h3
2 files changed, 10 insertions, 6 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp
index 3eabcbe11..25f573420 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -43,7 +43,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define BSD_ICONV_USED
#endif
-static bool parseHexColorString(const std::string &value, video::SColor &color);
+static bool parseHexColorString(const std::string &value, video::SColor &color,
+ unsigned char default_alpha = 0xff);
static bool parseNamedColorString(const std::string &value, video::SColor &color);
#ifndef _WIN32
@@ -464,12 +465,13 @@ u64 read_seed(const char *str)
return num;
}
-bool parseColorString(const std::string &value, video::SColor &color, bool quiet)
+bool parseColorString(const std::string &value, video::SColor &color, bool quiet,
+ unsigned char default_alpha)
{
bool success;
if (value[0] == '#')
- success = parseHexColorString(value, color);
+ success = parseHexColorString(value, color, default_alpha);
else
success = parseNamedColorString(value, color);
@@ -479,9 +481,10 @@ bool parseColorString(const std::string &value, video::SColor &color, bool quiet
return success;
}
-static bool parseHexColorString(const std::string &value, video::SColor &color)
+static bool parseHexColorString(const std::string &value, video::SColor &color,
+ unsigned char default_alpha)
{
- unsigned char components[] = { 0x00, 0x00, 0x00, 0xff }; // R,G,B,A
+ unsigned char components[] = { 0x00, 0x00, 0x00, default_alpha }; // R,G,B,A
if (value[0] != '#')
return false;
diff --git a/src/util/string.h b/src/util/string.h
index 2840f1192..35b7cfa8a 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -85,7 +85,8 @@ std::string writeFlagString(u32 flags, const FlagDesc *flagdesc, u32 flagmask);
size_t mystrlcpy(char *dst, const char *src, size_t size);
char *mystrtok_r(char *s, const char *sep, char **lasts);
u64 read_seed(const char *str);
-bool parseColorString(const std::string &value, video::SColor &color, bool quiet);
+bool parseColorString(const std::string &value, video::SColor &color, bool quiet,
+ unsigned char default_alpha = 0xff);
/**