diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 18:26:49 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-31 18:26:49 -0300 |
commit | 37f2222dd77d4ebb9c4df1af598635ac73f0bcf6 (patch) | |
tree | 1ebdc8db85dae7cc84111a3b92f2af399fa2671d /modules | |
parent | 6b1849d29b42a624a6f0514067bd8d4e67d68198 (diff) |
-Added Color8(r8,g8,b8,a8) function as well as .r8,.g8,.b8,.a8 members to Color, to deal with colors in the 0-255 range. Closes #2345
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 35 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 251b0ae392..1990afb787 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -98,6 +98,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "load", "inst2dict", "dict2inst", + "Color8", "hash", "print_stack", "instance_from_id", @@ -938,6 +939,33 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_ret=p_args[0]->hash(); } break; + case COLOR8: { + + if (p_arg_count<3) { + r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + r_error.argument=3; + return; + } + if (p_arg_count>4) { + r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; + r_error.argument=4; + return; + } + + VALIDATE_ARG_NUM(0); + VALIDATE_ARG_NUM(1); + VALIDATE_ARG_NUM(2); + + Color color(*p_args[0],*p_args[1],*p_args[2]); + + if (p_arg_count==4) { + VALIDATE_ARG_NUM(3); + color.a=*p_args[3]; + } + + r_ret=color; + + } break; case PRINT_STACK: { @@ -1017,6 +1045,7 @@ bool GDFunctions::is_deterministic(Function p_func) { case TYPE_CONVERT: case TYPE_OF: case TEXT_STR: + case COLOR8: // enable for debug only, otherwise not desirable - case GEN_RANGE: return true; default: @@ -1360,6 +1389,12 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::INT; return mi; } break; + case COLOR8: { + + MethodInfo mi("Color8",PropertyInfo(Variant::INT,"r8"),PropertyInfo(Variant::INT,"g8"),PropertyInfo(Variant::INT,"b8"),PropertyInfo(Variant::INT,"a8")); + mi.return_val.type=Variant::COLOR; + return mi; + } break; case PRINT_STACK: { MethodInfo mi("print_stack"); diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index ad35a628d5..e348689550 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -94,6 +94,7 @@ public: INST2DICT, DICT2INST, HASH, + COLOR8, PRINT_STACK, INSTANCE_FROM_ID, FUNC_MAX |