summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-01-11 10:36:15 +0100
committerGitHub <noreply@github.com>2017-01-11 10:36:15 +0100
commit57166cd2923cc6d32b37c34f6ca2f32f6941e4a8 (patch)
tree6ac41f0f717267a0164a869be76e941a3caeb9e9 /modules/visual_script
parentbc26f905817945300d397696330d1ab04a1af33c (diff)
parent23381a530bb4a9c8e8c3e883a7d588bf832cd277 (diff)
Merge pull request #7093 from bojidar-bg/named-colors
Add named colors to GDScript/Visual Script/core.
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp26
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h1
2 files changed, 25 insertions, 2 deletions
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index bd2647d928..27242384ac 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -64,6 +64,7 @@ const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX
"str2var",
"var2bytes",
"bytes2var",
+ "color_named",
};
VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::find_function(const String& p_string) {
@@ -164,6 +165,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) {
case LOGIC_MIN:
case FUNC_FUNCREF:
case TYPE_CONVERT:
+ case COLORN:
return 2;
case MATH_LERP:
case MATH_DECTIME:
@@ -368,13 +370,11 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::INT,"ascii");
-
} break;
case TEXT_STR: {
return PropertyInfo(Variant::NIL,"value");
-
} break;
case TEXT_PRINT: {
@@ -406,6 +406,14 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
return PropertyInfo(Variant::POOL_BYTE_ARRAY,"bytes");
} break;
+ case COLORN: {
+
+ if (p_idx==0)
+ return PropertyInfo(Variant::STRING,"name");
+ else
+ return PropertyInfo(Variant::REAL,"alpha");
+
+ } break;
case FUNC_MAX:{}
}
@@ -555,6 +563,9 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons
} break;
+ case COLORN: {
+ t=Variant::COLOR;
+ } break;
case FUNC_MAX:{}
}
@@ -1105,6 +1116,16 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
*r_return=ret;
} break;
+ case VisualScriptBuiltinFunc::COLORN: {
+
+ VALIDATE_ARG_NUM(1);
+
+ Color color = Color::named(*p_inputs[0]);
+ color.a=*p_inputs[1];
+
+ *r_return=String(color);
+
+ } break;
default: {}
}
@@ -1238,5 +1259,6 @@ void register_visual_script_builtin_func_node() {
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str2var",create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2bytes",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>);
VisualScriptLanguage::singleton->add_register_func("functions/built_in/bytes2var",create_builtin_func_node<VisualScriptBuiltinFunc::BYTES_TO_VAR>);
+ VisualScriptLanguage::singleton->add_register_func("functions/built_in/color_named",create_builtin_func_node<VisualScriptBuiltinFunc::COLORN>);
}
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index fba2099598..a285517c7e 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -66,6 +66,7 @@ public:
STR_TO_VAR,
VAR_TO_BYTES,
BYTES_TO_VAR,
+ COLORN,
FUNC_MAX
};