diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-01-30 20:20:33 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-01-30 20:20:33 +0300 |
commit | c19933eec4a3c2d21a07be823c95f87a2141ca60 (patch) | |
tree | 6ba504a020b4b27e6f856e9a2ad58f30c9988d5b | |
parent | 4e7d75ccd350b98bccea517c034b367f52cf127e (diff) |
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(); } |