Ver Fonte

added conversion from int, string to color

fixes #1971
Juan Linietsky há 10 anos atrás
pai
commit
57a78ec06b
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      core/variant.cpp

+ 6 - 2
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();
 }