From 06913d53cca101aa3461b4b4e3deb7c4e4b18560 Mon Sep 17 00:00:00 2001 From: nlupugla Date: Sat, 9 Sep 2023 10:30:40 -0400 Subject: [PATCH] Exposed PropertySelector to scripting --- editor/property_selector.cpp | 22 ++++++++++++++++++++++ editor/property_selector.h | 1 + editor/register_editor_types.cpp | 2 ++ 3 files changed, 25 insertions(+) diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 5228db03b958..c16f4f089e13 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -575,7 +575,29 @@ void PropertySelector::set_type_filter(const Vector &p_type_filte type_filter = p_type_filter; } +//Variant::Type isn't exposed, so need a version that takes int +void PropertySelector::set_type_filter_exposable(const Vector &p_type_filter) { + int n_types = p_type_filter.size(); + type_filter.clear(); + type_filter.resize(n_types); + for (int i = 0; i < n_types; i++) { + type_filter.push_back(static_cast(p_type_filter[i])); + } +} + void PropertySelector::_bind_methods() { + ClassDB::bind_method(D_METHOD("select_method_from_base_type", "base", "current", "virtuals_only"), &PropertySelector::select_method_from_base_type); + ClassDB::bind_method(D_METHOD("select_method_from_script", "script", "current"), &PropertySelector::select_method_from_script); + ClassDB::bind_method(D_METHOD("select_method_from_basic_type", "type", "current"), &PropertySelector::select_method_from_basic_type); + ClassDB::bind_method(D_METHOD("select_method_from_instance", "instance", "current"), &PropertySelector::select_method_from_instance); + + ClassDB::bind_method(D_METHOD("select_property_from_base_type", "base", "current"), &PropertySelector::select_property_from_base_type); + ClassDB::bind_method(D_METHOD("select_property_from_script", "script", "current"), &PropertySelector::select_property_from_instance); + ClassDB::bind_method(D_METHOD("select_property_from_basic_type", "type", "current"), &PropertySelector::select_property_from_basic_type); + ClassDB::bind_method(D_METHOD("select_property_from_instance", "instance", "current"), &PropertySelector::select_property_from_instance); + + ClassDB::bind_method(D_METHOD("set_type_filter", "type_filter"), &PropertySelector::set_type_filter_exposable); + ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"))); } diff --git a/editor/property_selector.h b/editor/property_selector.h index b162ee6cfdc7..a38a6c73900d 100644 --- a/editor/property_selector.h +++ b/editor/property_selector.h @@ -78,6 +78,7 @@ class PropertySelector : public ConfirmationDialog { void select_property_from_instance(Object *p_instance, const String &p_current = ""); void set_type_filter(const Vector &p_type_filter); + void set_type_filter_exposable(const Vector &p_type_filter); PropertySelector(); }; diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index a636d8c1f2ce..46bc52d116e3 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -126,6 +126,7 @@ #include "editor/plugins/version_control_editor_plugin.h" #include "editor/plugins/visual_shader_editor_plugin.h" #include "editor/plugins/voxel_gi_editor_plugin.h" +#include "editor/property_selector.h" #include "editor/register_exporters.h" void register_editor_types() { @@ -174,6 +175,7 @@ void register_editor_types() { GDREGISTER_CLASS(EditorResourcePicker); GDREGISTER_CLASS(EditorScriptPicker); GDREGISTER_ABSTRACT_CLASS(EditorUndoRedoManager); + GDREGISTER_CLASS(PropertySelector); GDREGISTER_ABSTRACT_CLASS(FileSystemDock); GDREGISTER_VIRTUAL_CLASS(EditorFileSystemImportFormatSupportQuery);