diff options
author | Thomas--S <Thomas--S@users.noreply.github.com> | 2018-04-23 19:50:50 +0200 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-04-23 18:50:50 +0100 |
commit | 9577a4396aa139a748878a11eec8922ce92de575 (patch) | |
tree | ef2f879b20af3ef260397492dfa24ebdced5c3c7 /src | |
parent | 12a8f8826d54362d70aae8524aa88118f2d84692 (diff) | |
download | minetest-9577a4396aa139a748878a11eec8922ce92de575.tar.gz minetest-9577a4396aa139a748878a11eec8922ce92de575.tar.bz2 minetest-9577a4396aa139a748878a11eec8922ce92de575.zip |
Formspecs: Allow setting alpha value for the box[] element
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/guiFormSpecMenu.cpp | 4 | ||||
-rw-r--r-- | src/gui/guiFormSpecMenu.h | 2 | ||||
-rw-r--r-- | src/util/string.cpp | 13 | ||||
-rw-r--r-- | src/util/string.h | 3 |
4 files changed, 12 insertions, 10 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index e582c30de..12caf39eb 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -1560,7 +1560,7 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element) video::SColor tmp_color; - if (parseColorString(parts[2], tmp_color, false)) { + if (parseColorString(parts[2], tmp_color, false, 0x8C)) { BoxDrawSpec spec(pos, geom, tmp_color); m_boxes.push_back(spec); @@ -2515,8 +2515,6 @@ void GUIFormSpecMenu::drawMenu() for (const GUIFormSpecMenu::BoxDrawSpec &spec : m_boxes) { irr::video::SColor todraw = spec.color; - todraw.setAlpha(140); - core::rect<s32> rect(spec.pos.X,spec.pos.Y, spec.pos.X + spec.geom.X,spec.pos.Y + spec.geom.Y); diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index 51d25a4f5..013ba65cb 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -223,7 +223,7 @@ class GUIFormSpecMenu : public GUIModalMenu struct BoxDrawSpec { - BoxDrawSpec(v2s32 a_pos, v2s32 a_geom,irr::video::SColor a_color): + BoxDrawSpec(v2s32 a_pos, v2s32 a_geom, irr::video::SColor a_color): pos(a_pos), geom(a_geom), color(a_color) 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); /** |