diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-10 09:22:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 09:22:25 +0100 |
commit | cc6b49ec0d1d436996db17759ae57feba47443de (patch) | |
tree | 7e9b5162b485e885664419818f23ce0b43bc8ce0 | |
parent | 47f19cc776940469a006aa3f7331166b32d9f7b4 (diff) | |
parent | 386d0fe9887e7cb272aeb05bfe6930bec4114140 (diff) |
Merge pull request #36068 from Chaosus/vst_fix_class_constant
Fix VisualScriptClassConstant to be updated properly
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 36cafeec73..dc49ed72d0 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1935,8 +1935,11 @@ PropertyInfo VisualScriptClassConstant::get_input_value_port_info(int p_idx) con } PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) const { - - return PropertyInfo(Variant::INT, String(base_type) + "." + String(name)); + if (name == "") { + return PropertyInfo(Variant::INT, String(base_type)); + } else { + return PropertyInfo(Variant::INT, String(base_type) + "." + String(name)); + } } String VisualScriptClassConstant::get_caption() const { @@ -1958,6 +1961,22 @@ StringName VisualScriptClassConstant::get_class_constant() { void VisualScriptClassConstant::set_base_type(const StringName &p_which) { base_type = p_which; + List<String> constants; + ClassDB::get_integer_constant_list(base_type, &constants, true); + if (constants.size() > 0) { + bool found_name = false; + for (List<String>::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(); } |