diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-06 11:19:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 11:19:08 +0100 |
commit | d0e90cf07a4657ccff2b5b7d5640aba9d8df6930 (patch) | |
tree | 566a248b0f7a7dae39042bb79c4e48ed153e674c | |
parent | e92ab159e6fcb0d52c6d13220d373270ab045a60 (diff) | |
parent | c19933eec4a3c2d21a07be823c95f87a2141ca60 (diff) |
Merge pull request #35749 from Chaosus/vst_fix_constants
Fix GlobalConstant/BasicTypeConstant return type in visual scripts
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 86c1080182..36cafeec73 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1842,7 +1842,7 @@ PropertyInfo VisualScriptGlobalConstant::get_input_value_port_info(int p_idx) co PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) const { String name = GlobalConstants::get_global_constant_name(index); - return PropertyInfo(Variant::REAL, name); + return PropertyInfo(Variant::INT, name); } String VisualScriptGlobalConstant::get_caption() const { @@ -2060,7 +2060,7 @@ PropertyInfo VisualScriptBasicTypeConstant::get_input_value_port_info(int p_idx) PropertyInfo VisualScriptBasicTypeConstant::get_output_value_port_info(int p_idx) const { - return PropertyInfo(Variant::INT, "value"); + return PropertyInfo(type, "value"); } String VisualScriptBasicTypeConstant::get_caption() const { @@ -2069,8 +2069,11 @@ String VisualScriptBasicTypeConstant::get_caption() const { } String VisualScriptBasicTypeConstant::get_text() const { - - return Variant::get_type_name(type) + "." + String(name); + if (name == "") { + return Variant::get_type_name(type); + } else { + return Variant::get_type_name(type) + "." + String(name); + } } void VisualScriptBasicTypeConstant::set_basic_type_constant(const StringName &p_which) { @@ -2087,6 +2090,23 @@ StringName VisualScriptBasicTypeConstant::get_basic_type_constant() const { void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) { type = p_which; + + List<StringName> constants; + Variant::get_constants_for_type(type, &constants); + if (constants.size() > 0) { + bool found_name = false; + for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + if (E->get() == name) { + found_name = true; + break; + } + } + if (!found_name) { + name = constants[0]; + } + } else { + name = ""; + } _change_notify(); ports_changed_notify(); } |