summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-05-27 10:56:57 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-05-27 10:56:57 -0300
commit57a78ec06bccbb55a85c73891d88b983b4f01c94 (patch)
treed58a965b25cf92971a8a59c8991b48d76ec68bde
parent70edfcdc8d2b6fa6cd541cb3afb0f4ddd030b4bf (diff)
added conversion from int, string to color
fixes #1971
-rw-r--r--core/variant.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/variant.cpp b/core/variant.cpp
index d7817ac268..034dc2b4fc 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -302,8 +302,8 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) {
case COLOR: {
static const Type valid[] = {
- //STRING,
- //INT,
+ STRING,
+ INT,
NIL,
};
@@ -1653,6 +1653,10 @@ Variant::operator Color() const {
if (type==COLOR)
return *reinterpret_cast<const Color*>(_data._mem);
+ else if (type==STRING)
+ return Color::html( operator String() );
+ else if (type==INT)
+ return Color::hex( operator int() );
else
return Color();
}