summaryrefslogtreecommitdiff
path: root/core/variant_op.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant_op.cpp')
-rw-r--r--core/variant_op.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index e33b79e63c..204a00e1d5 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1003,7 +1003,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
return;
}
- *str = str->substr(0,idx-1)+chr+str->substr(idx+1,str->length());
+ *str = str->substr(0,idx)+chr+str->substr(idx+1,str->length());
valid=true;
return;
@@ -1352,6 +1352,22 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
valid=true;
v->set_hsv(v->get_h(),v->get_s(),p_value);
return;
+ } else if (*str=="r8" ) {
+ valid=true;
+ v->g=float(p_value)/255.0;
+ return;
+ } else if (*str=="g8" ) {
+ valid=true;
+ v->g=float(p_value)/255.0;
+ return;
+ } else if (*str=="b8" ) {
+ valid=true;
+ v->b=float(p_value)/255.0;
+ return;
+ } else if (*str=="a8" ) {\
+ valid=true;
+ v->a=float(p_value)/255.0;
+ return;
}
} else if (p_index.get_type()==Variant::INT) {
@@ -2195,6 +2211,18 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
} else if (*str=="v" ) {
valid=true;
return v->get_v();
+ } else if (*str=="r8") {
+ valid=true;
+ return v->r*255.0;
+ } else if (*str=="g8" ) {
+ valid=true;
+ return v->g*255.0;
+ } else if (*str=="b8" ) {
+ valid=true;
+ return v->b*255.0;
+ } else if (*str=="a8" ) {
+ valid=true;
+ return v->a*255.0;
}
} else if (p_index.get_type()==Variant::INT) {
@@ -2866,6 +2894,10 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo(Variant::REAL,"h"));
p_list->push_back( PropertyInfo(Variant::REAL,"s"));
p_list->push_back( PropertyInfo(Variant::REAL,"v"));
+ p_list->push_back( PropertyInfo(Variant::INT,"r8"));
+ p_list->push_back( PropertyInfo(Variant::INT,"g8"));
+ p_list->push_back( PropertyInfo(Variant::INT,"b8"));
+ p_list->push_back( PropertyInfo(Variant::INT,"a8"));
} break;
case IMAGE: { } break;