summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_export.cpp18
-rw-r--r--editor/editor_export.h4
-rw-r--r--editor/editor_inspector.cpp49
-rw-r--r--editor/editor_inspector.h7
-rw-r--r--editor/editor_plugin.cpp155
-rw-r--r--editor/editor_plugin.h26
-rw-r--r--editor/editor_resource_preview.cpp35
-rw-r--r--editor/editor_resource_preview.h6
-rw-r--r--editor/editor_run_script.cpp16
-rw-r--r--editor/editor_run_script.h1
-rw-r--r--editor/editor_translation_parser.cpp23
-rw-r--r--editor/editor_translation_parser.h5
-rw-r--r--editor/import/editor_import_plugin.cpp170
-rw-r--r--editor/import/editor_import_plugin.h13
-rw-r--r--editor/import/resource_importer_scene.cpp39
-rw-r--r--editor/import/resource_importer_scene.h7
-rw-r--r--editor/plugins/node_3d_editor_gizmos.cpp238
-rw-r--r--editor/plugins/node_3d_editor_gizmos.h37
-rw-r--r--editor/plugins/script_editor_plugin.cpp19
-rw-r--r--editor/plugins/script_editor_plugin.h5
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp7
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h2
-rw-r--r--editor/property_editor.cpp33
-rw-r--r--editor/property_editor.h4
24 files changed, 487 insertions, 432 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index b374f56f6d..91c3c51c4d 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -624,21 +624,15 @@ Vector<String> EditorExportPlugin::get_ios_project_static_libs() const {
}
void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) {
- if (get_script_instance()) {
- get_script_instance()->call("_export_file", p_path, p_type, p_features);
- }
+ GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features);
}
void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) {
- if (get_script_instance()) {
- get_script_instance()->call("_export_begin", p_features, p_debug, p_path, p_flags);
- }
+ GDVIRTUAL_CALL(_export_begin, p_features, p_debug, p_path, p_flags);
}
void EditorExportPlugin::_export_end_script() {
- if (get_script_instance()) {
- get_script_instance()->call("_export_end");
- }
+ GDVIRTUAL_CALL(_export_end);
}
void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
@@ -663,9 +657,9 @@ void EditorExportPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code);
ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip);
- BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "features")));
- BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::PACKED_STRING_ARRAY, "features"), PropertyInfo(Variant::BOOL, "is_debug"), PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags")));
- BIND_VMETHOD(MethodInfo("_export_end"));
+ GDVIRTUAL_BIND(_export_file, "path", "type", "features");
+ GDVIRTUAL_BIND(_export_begin, "features", "is_debug", "path", "flags");
+ GDVIRTUAL_BIND(_export_end);
}
EditorExportPlugin::EditorExportPlugin() {
diff --git a/editor/editor_export.h b/editor/editor_export.h
index c9401df9c2..b681f52330 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -349,6 +349,10 @@ protected:
static void _bind_methods();
+ GDVIRTUAL3(_export_file, String, String, Vector<String>)
+ GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
+ GDVIRTUAL0(_export_end)
+
public:
Vector<String> get_ios_frameworks() const;
Vector<String> get_ios_embedded_frameworks() const;
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index b3ce11028b..8d2edd3000 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -379,9 +379,7 @@ StringName EditorProperty::get_edited_property() {
}
void EditorProperty::update_property() {
- if (get_script_instance()) {
- get_script_instance()->call("_update_property");
- }
+ GDVIRTUAL_CALL(_update_property);
}
void EditorProperty::set_read_only(bool p_read_only) {
@@ -766,7 +764,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
call_deferred(SNAME("emit_changed"), property, object->get(property).operator int64_t() + 1, "", false);
}
- call_deferred(SNAME("_update_property"));
+ call_deferred(SNAME("update_property"));
}
}
if (delete_rect.has_point(mpos)) {
@@ -925,6 +923,7 @@ void EditorProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &EditorProperty::_gui_input);
ClassDB::bind_method(D_METHOD("get_tooltip_text"), &EditorProperty::get_tooltip_text);
+ ClassDB::bind_method(D_METHOD("update_property"), &EditorProperty::update_property);
ClassDB::bind_method(D_METHOD("add_focusable", "control"), &EditorProperty::add_focusable);
ClassDB::bind_method(D_METHOD("set_bottom_editor", "editor"), &EditorProperty::set_bottom_editor);
@@ -948,7 +947,7 @@ void EditorProperty::_bind_methods() {
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::STRING_NAME, "property"), PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "focusable_idx")));
- BIND_VMETHOD(MethodInfo("_update_property"));
+ GDVIRTUAL_BIND(_update_property)
}
EditorProperty::EditorProperty() {
@@ -1003,43 +1002,31 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St
}
bool EditorInspectorPlugin::can_handle(Object *p_object) {
- if (get_script_instance()) {
- return get_script_instance()->call("_can_handle", p_object);
+ bool success;
+ if (GDVIRTUAL_CALL(_can_handle, p_object, success)) {
+ return success;
}
return false;
}
void EditorInspectorPlugin::parse_begin(Object *p_object) {
- if (get_script_instance()) {
- get_script_instance()->call("_parse_begin", p_object);
- }
+ GDVIRTUAL_CALL(_parse_begin);
}
void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) {
- if (get_script_instance()) {
- get_script_instance()->call("_parse_category", p_object, p_parse_category);
- }
+ GDVIRTUAL_CALL(_parse_category, p_object, p_parse_category);
}
bool EditorInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
- if (get_script_instance()) {
- Variant arg[6] = {
- p_object, p_type, p_path, p_hint, p_hint_text, p_usage
- };
- const Variant *argptr[6] = {
- &arg[0], &arg[1], &arg[2], &arg[3], &arg[4], &arg[5]
- };
-
- Callable::CallError err;
- return get_script_instance()->call("_parse_property", (const Variant **)&argptr, 6, err);
+ bool ret;
+ if (GDVIRTUAL_CALL(_parse_property, p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide, ret)) {
+ return ret;
}
return false;
}
void EditorInspectorPlugin::parse_end() {
- if (get_script_instance()) {
- get_script_instance()->call("_parse_end");
- }
+ GDVIRTUAL_CALL(_parse_end);
}
void EditorInspectorPlugin::_bind_methods() {
@@ -1047,11 +1034,11 @@ void EditorInspectorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_property_editor", "property", "editor"), &EditorInspectorPlugin::add_property_editor);
ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties);
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_handle", PropertyInfo(Variant::OBJECT, "object")));
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_parse_begin"));
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_parse_category", PropertyInfo(Variant::STRING, "category")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_parse_property", PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "hint"), PropertyInfo(Variant::STRING, "hint_text"), PropertyInfo(Variant::INT, "usage")));
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_parse_end"));
+ GDVIRTUAL_BIND(_can_handle, "object")
+ GDVIRTUAL_BIND(_parse_begin)
+ GDVIRTUAL_BIND(_parse_category, "object", "category")
+ GDVIRTUAL_BIND(_parse_property, "object", "type", "name", "hint_type", "hint_string", "usage_flags", "wide");
+ GDVIRTUAL_BIND(_parse_end)
}
////////////////////////////////////////////////
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 3c9ba9f39d..8cb4f1fbef 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -102,6 +102,7 @@ private:
Map<StringName, Variant> cache;
+ GDVIRTUAL0(_update_property)
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -192,6 +193,12 @@ class EditorInspectorPlugin : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL1RC(bool, _can_handle, Variant)
+ GDVIRTUAL0(_parse_begin)
+ GDVIRTUAL2(_parse_category, Object *, String)
+ GDVIRTUAL7R(bool, _parse_property, Object *, int, String, int, String, int, bool)
+ GDVIRTUAL0(_parse_end)
+
public:
void add_custom_control(Control *control);
void add_property_editor(const String &p_for_property, Control *p_prop);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 98b5ec7d56..73ea4fb5ef 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -558,22 +558,19 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
}
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_canvas_gui_input")) {
- return get_script_instance()->call("_forward_canvas_gui_input", p_event);
+ bool success;
+ if (GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success)) {
+ return success;
}
return false;
}
void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_canvas_draw_over_viewport")) {
- get_script_instance()->call("_forward_canvas_draw_over_viewport", p_overlay);
- }
+ GDVIRTUAL_CALL(_forward_canvas_draw_over_viewport, p_overlay);
}
void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_canvas_force_draw_over_viewport")) {
- get_script_instance()->call("_forward_canvas_force_draw_over_viewport", p_overlay);
- }
+ GDVIRTUAL_CALL(_forward_canvas_force_draw_over_viewport, p_overlay);
}
// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
@@ -596,110 +593,101 @@ int EditorPlugin::update_overlays() const {
}
bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_spatial_gui_input")) {
- return get_script_instance()->call("_forward_spatial_gui_input", p_camera, p_event);
+ bool success;
+
+ if (GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success)) {
+ return success;
}
return false;
}
void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_spatial_draw_over_viewport")) {
- get_script_instance()->call("_forward_spatial_draw_over_viewport", p_overlay);
- }
+ GDVIRTUAL_CALL(_forward_3d_draw_over_viewport, p_overlay);
}
void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
- if (get_script_instance() && get_script_instance()->has_method("_forward_spatial_force_draw_over_viewport")) {
- get_script_instance()->call("_forward_spatial_force_draw_over_viewport", p_overlay);
- }
+ GDVIRTUAL_CALL(_forward_3d_force_draw_over_viewport, p_overlay);
}
String EditorPlugin::get_name() const {
- if (get_script_instance() && get_script_instance()->has_method("_get_plugin_name")) {
- return get_script_instance()->call("_get_plugin_name");
+ String name;
+ if (GDVIRTUAL_CALL(_get_plugin_name, name)) {
+ return name;
}
return String();
}
const Ref<Texture2D> EditorPlugin::get_icon() const {
- if (get_script_instance() && get_script_instance()->has_method("_get_plugin_icon")) {
- return get_script_instance()->call("_get_plugin_icon");
+ Ref<Texture2D> icon;
+ if (GDVIRTUAL_CALL(_get_plugin_icon, icon)) {
+ return icon;
}
return Ref<Texture2D>();
}
bool EditorPlugin::has_main_screen() const {
- if (get_script_instance() && get_script_instance()->has_method("_has_main_screen")) {
- return get_script_instance()->call("_has_main_screen");
+ bool success;
+ if (GDVIRTUAL_CALL(_has_main_screen, success)) {
+ return success;
}
return false;
}
void EditorPlugin::make_visible(bool p_visible) {
- if (get_script_instance() && get_script_instance()->has_method("_make_visible")) {
- get_script_instance()->call("_make_visible", p_visible);
- }
+ GDVIRTUAL_CALL(_make_visible, p_visible);
}
void EditorPlugin::edit(Object *p_object) {
- if (get_script_instance() && get_script_instance()->has_method("_edit")) {
- if (p_object->is_class("Resource")) {
- get_script_instance()->call("_edit", Ref<Resource>(Object::cast_to<Resource>(p_object)));
- } else {
- get_script_instance()->call("_edit", p_object);
- }
+ if (p_object->is_class("Resource")) {
+ GDVIRTUAL_CALL(_edit, Ref<Resource>(Object::cast_to<Resource>(p_object)));
+ } else {
+ GDVIRTUAL_CALL(_edit, p_object);
}
}
bool EditorPlugin::handles(Object *p_object) const {
- if (get_script_instance() && get_script_instance()->has_method("_handles")) {
- return get_script_instance()->call("_handles", p_object);
+ bool success;
+ if (GDVIRTUAL_CALL(_handles, p_object, success)) {
+ return success;
}
return false;
}
Dictionary EditorPlugin::get_state() const {
- if (get_script_instance() && get_script_instance()->has_method("_get_state")) {
- return get_script_instance()->call("_get_state");
+ Dictionary state;
+ if (GDVIRTUAL_CALL(_get_state, state)) {
+ return state;
}
return Dictionary();
}
void EditorPlugin::set_state(const Dictionary &p_state) {
- if (get_script_instance() && get_script_instance()->has_method("_set_state")) {
- get_script_instance()->call("_set_state", p_state);
- }
+ GDVIRTUAL_CALL(_set_state, p_state);
}
void EditorPlugin::clear() {
- if (get_script_instance() && get_script_instance()->has_method("_clear")) {
- get_script_instance()->call("_clear");
- }
+ GDVIRTUAL_CALL(_clear);
}
// if editor references external resources/scenes, save them
void EditorPlugin::save_external_data() {
- if (get_script_instance() && get_script_instance()->has_method("_save_external_data")) {
- get_script_instance()->call("_save_external_data");
- }
+ GDVIRTUAL_CALL(_save_external_data);
}
// if changes are pending in editor, apply them
void EditorPlugin::apply_changes() {
- if (get_script_instance() && get_script_instance()->has_method("_apply_changes")) {
- get_script_instance()->call("_apply_changes");
- }
+ GDVIRTUAL_CALL(_apply_changes);
}
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
- if (get_script_instance() && get_script_instance()->has_method("_get_breakpoints")) {
- PackedStringArray arr = get_script_instance()->call("_get_breakpoints");
+ PackedStringArray arr;
+ if (GDVIRTUAL_CALL(_get_breakpoints, arr)) {
for (int i = 0; i < arr.size(); i++) {
p_breakpoints->push_back(arr[i]);
}
@@ -796,37 +784,28 @@ int find(const PackedStringArray &a, const String &v) {
void EditorPlugin::enable_plugin() {
// Called when the plugin gets enabled in project settings, after it's added to the tree.
// You can implement it to register autoloads.
- if (get_script_instance() && get_script_instance()->has_method("_enable_plugin")) {
- get_script_instance()->call("_enable_plugin");
- }
+ GDVIRTUAL_CALL(_enable_plugin);
}
void EditorPlugin::disable_plugin() {
// Last function called when the plugin gets disabled in project settings.
// Implement it to cleanup things from the project, such as unregister autoloads.
-
- if (get_script_instance() && get_script_instance()->has_method("_disable_plugin")) {
- get_script_instance()->call("_disable_plugin");
- }
+ GDVIRTUAL_CALL(_disable_plugin);
}
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
- if (get_script_instance() && get_script_instance()->has_method("_set_window_layout")) {
- get_script_instance()->call("_set_window_layout", p_layout);
- }
+ GDVIRTUAL_CALL(_set_window_layout, p_layout);
}
void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
- if (get_script_instance() && get_script_instance()->has_method("_get_window_layout")) {
- get_script_instance()->call("_get_window_layout", p_layout);
- }
+ GDVIRTUAL_CALL(_get_window_layout, p_layout);
}
bool EditorPlugin::build() {
- if (get_script_instance() && get_script_instance()->has_method("_build")) {
- return get_script_instance()->call("_build");
+ bool success;
+ if (GDVIRTUAL_CALL(_build, success)) {
+ return success;
}
-
return true;
}
@@ -915,29 +894,29 @@ void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_debugger_plugin", "script"), &EditorPlugin::add_debugger_plugin);
ClassDB::bind_method(D_METHOD("remove_debugger_plugin", "script"), &EditorPlugin::remove_debugger_plugin);
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
- BIND_VMETHOD(MethodInfo("_forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- BIND_VMETHOD(MethodInfo("_forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
- BIND_VMETHOD(MethodInfo("_forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- BIND_VMETHOD(MethodInfo("_forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_plugin_name"));
- BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "_get_plugin_icon"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_main_screen"));
- BIND_VMETHOD(MethodInfo("_make_visible", PropertyInfo(Variant::BOOL, "visible")));
- BIND_VMETHOD(MethodInfo("_edit", PropertyInfo(Variant::OBJECT, "object")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_handles", PropertyInfo(Variant::OBJECT, "object")));
- BIND_VMETHOD(MethodInfo(Variant::DICTIONARY, "_get_state"));
- BIND_VMETHOD(MethodInfo("_set_state", PropertyInfo(Variant::DICTIONARY, "state")));
- BIND_VMETHOD(MethodInfo("_clear"));
- BIND_VMETHOD(MethodInfo("_save_external_data"));
- BIND_VMETHOD(MethodInfo("_apply_changes"));
- BIND_VMETHOD(MethodInfo(Variant::PACKED_STRING_ARRAY, "_get_breakpoints"));
- BIND_VMETHOD(MethodInfo("_set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
- BIND_VMETHOD(MethodInfo("_get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_build"));
- BIND_VMETHOD(MethodInfo("_enable_plugin"));
- BIND_VMETHOD(MethodInfo("_disable_plugin"));
+ GDVIRTUAL_BIND(_forward_canvas_gui_input, "event");
+ GDVIRTUAL_BIND(_forward_canvas_draw_over_viewport, "viewport_control");
+ GDVIRTUAL_BIND(_forward_canvas_force_draw_over_viewport, "viewport_control");
+ GDVIRTUAL_BIND(_forward_3d_gui_input, "viewport_camera", "event");
+ GDVIRTUAL_BIND(_forward_3d_draw_over_viewport, "viewport_control");
+ GDVIRTUAL_BIND(_forward_3d_force_draw_over_viewport, "viewport_control");
+ GDVIRTUAL_BIND(_get_plugin_name);
+ GDVIRTUAL_BIND(_get_plugin_icon);
+ GDVIRTUAL_BIND(_has_main_screen);
+ GDVIRTUAL_BIND(_make_visible, "visible");
+ GDVIRTUAL_BIND(_edit, "object");
+ GDVIRTUAL_BIND(_handles, "object");
+ GDVIRTUAL_BIND(_get_state);
+ GDVIRTUAL_BIND(_set_state, "state");
+ GDVIRTUAL_BIND(_clear);
+ GDVIRTUAL_BIND(_save_external_data);
+ GDVIRTUAL_BIND(_apply_changes);
+ GDVIRTUAL_BIND(_get_breakpoints);
+ GDVIRTUAL_BIND(_set_window_layout, "configuration");
+ GDVIRTUAL_BIND(_get_window_layout, "configuration");
+ GDVIRTUAL_BIND(_build);
+ GDVIRTUAL_BIND(_enable_plugin);
+ GDVIRTUAL_BIND(_disable_plugin);
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index d665278144..169106d901 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -39,9 +39,9 @@
#include "editor/import/editor_import_plugin.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/script_create_dialog.h"
+#include "scene/3d/camera_3d.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
-
class EditorNode;
class Node3D;
class Camera3D;
@@ -148,6 +148,30 @@ protected:
void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon);
void remove_custom_type(const String &p_type);
+ GDVIRTUAL1R(bool, _forward_canvas_gui_input, Ref<InputEvent>)
+ GDVIRTUAL1(_forward_canvas_draw_over_viewport, Control *)
+ GDVIRTUAL1(_forward_canvas_force_draw_over_viewport, Control *)
+ GDVIRTUAL2R(bool, _forward_3d_gui_input, Camera3D *, Ref<InputEvent>)
+ GDVIRTUAL1(_forward_3d_draw_over_viewport, Control *)
+ GDVIRTUAL1(_forward_3d_force_draw_over_viewport, Control *)
+ GDVIRTUAL0RC(String, _get_plugin_name)
+ GDVIRTUAL0RC(Ref<Texture2D>, _get_plugin_icon)
+ GDVIRTUAL0RC(bool, _has_main_screen)
+ GDVIRTUAL1(_make_visible, bool)
+ GDVIRTUAL1(_edit, Variant)
+ GDVIRTUAL1RC(bool, _handles, Variant)
+ GDVIRTUAL0RC(Dictionary, _get_state)
+ GDVIRTUAL1(_set_state, Dictionary)
+ GDVIRTUAL0(_clear)
+ GDVIRTUAL0(_save_external_data)
+ GDVIRTUAL0(_apply_changes)
+ GDVIRTUAL0RC(Vector<String>, _get_breakpoints)
+ GDVIRTUAL1(_set_window_layout, Ref<ConfigFile>)
+ GDVIRTUAL1(_get_window_layout, Ref<ConfigFile>)
+ GDVIRTUAL0R(bool, _build)
+ GDVIRTUAL0(_enable_plugin)
+ GDVIRTUAL0(_disable_plugin)
+
public:
enum CustomControlContainer {
CONTAINER_TOOLBAR,
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 7f4ee7848f..8fc1345f3e 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -40,22 +40,25 @@
#include "editor_settings.h"
bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
- if (get_script_instance() && get_script_instance()->has_method("_handles")) {
- return get_script_instance()->call("_handles", p_type);
+ bool success;
+ if (GDVIRTUAL_CALL(_handles, p_type, success)) {
+ return success;
}
ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::_handles needs to be overridden.");
}
Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
- if (get_script_instance() && get_script_instance()->has_method("_generate")) {
- return get_script_instance()->call("_generate", p_from, p_size);
+ Ref<Texture2D> preview;
+ if (GDVIRTUAL_CALL(_generate, p_from, p_size, preview)) {
+ return preview;
}
ERR_FAIL_V_MSG(Ref<Texture2D>(), "EditorResourcePreviewGenerator::_generate needs to be overridden.");
}
Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const {
- if (get_script_instance() && get_script_instance()->has_method("_generate_from_path")) {
- return get_script_instance()->call("_generate_from_path", p_path, p_size);
+ Ref<Texture2D> preview;
+ if (GDVIRTUAL_CALL(_generate_from_path, p_path, p_size, preview)) {
+ return preview;
}
RES res = ResourceLoader::load(p_path);
@@ -66,27 +69,29 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &
}
bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const {
- if (get_script_instance() && get_script_instance()->has_method("_generate_small_preview_automatically")) {
- return get_script_instance()->call("_generate_small_preview_automatically");
+ bool success;
+ if (GDVIRTUAL_CALL(_generate_small_preview_automatically, success)) {
+ return success;
}
return false;
}
bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
- if (get_script_instance() && get_script_instance()->has_method("_can_generate_small_preview")) {
- return get_script_instance()->call("_can_generate_small_preview");
+ bool success;
+ if (GDVIRTUAL_CALL(_can_generate_small_preview, success)) {
+ return success;
}
return false;
}
void EditorResourcePreviewGenerator::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_handles", PropertyInfo(Variant::STRING, "type")));
- BIND_VMETHOD(MethodInfo(CLASS_INFO(Texture2D), "_generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size")));
- BIND_VMETHOD(MethodInfo(CLASS_INFO(Texture2D), "_generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_generate_small_preview_automatically"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_generate_small_preview"));
+ GDVIRTUAL_BIND(_handles, "type");
+ GDVIRTUAL_BIND(_generate, "resource", "size");
+ GDVIRTUAL_BIND(_generate_from_path, "path", "size");
+ GDVIRTUAL_BIND(_generate_small_preview_automatically);
+ GDVIRTUAL_BIND(_can_generate_small_preview);
}
EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() {
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index 67f83220d0..ea16c8fde0 100644
--- a/editor/editor_resource_preview.h
+++ b/editor/editor_resource_preview.h
@@ -43,6 +43,12 @@ class EditorResourcePreviewGenerator : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL1RC(bool, _handles, String)
+ GDVIRTUAL2RC(Ref<Texture2D>, _generate, RES, Vector2i)
+ GDVIRTUAL2RC(Ref<Texture2D>, _generate_from_path, String, Vector2i)
+ GDVIRTUAL0RC(bool, _generate_small_preview_automatically)
+ GDVIRTUAL0RC(bool, _can_generate_small_preview)
+
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index 83ce50a9f9..27923ef413 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -60,18 +60,8 @@ Node *EditorScript::get_scene() {
}
void EditorScript::_run() {
- Ref<Script> s = get_script();
- ERR_FAIL_COND(!s.is_valid());
- if (!get_script_instance()) {
- EditorNode::add_io_error(TTR("Couldn't instance script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the 'tool' keyword?"));
- return;
- }
-
- Callable::CallError ce;
- ce.error = Callable::CallError::CALL_OK;
- get_script_instance()->call("_run", nullptr, 0, ce);
- if (ce.error != Callable::CallError::CALL_OK) {
- EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?"));
+ if (!GDVIRTUAL_CALL(_run)) {
+ EditorNode::add_io_error(TTR("Couldn't run editor script, did you forget to override the '_run' method?"));
}
}
@@ -83,7 +73,7 @@ void EditorScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
- BIND_VMETHOD(MethodInfo("_run"));
+ GDVIRTUAL_BIND(_run);
}
EditorScript::EditorScript() {
diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h
index c8412c3c92..6c7e37774d 100644
--- a/editor/editor_run_script.h
+++ b/editor/editor_run_script.h
@@ -41,6 +41,7 @@ class EditorScript : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL0(_run)
public:
void add_root_node(Node *p_node);
diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp
index 27d428e682..df47b2d988 100644
--- a/editor/editor_translation_parser.cpp
+++ b/editor/editor_translation_parser.cpp
@@ -38,15 +38,10 @@
EditorTranslationParser *EditorTranslationParser::singleton = nullptr;
Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) {
- if (!get_script_instance()) {
- return ERR_UNAVAILABLE;
- }
-
- if (get_script_instance()->has_method("_parse_file")) {
- Array ids;
- Array ids_ctx_plural;
- get_script_instance()->call("_parse_file", p_path, ids, ids_ctx_plural);
+ Array ids;
+ Array ids_ctx_plural;
+ if (GDVIRTUAL_CALL(_parse_file, p_path, ids, ids_ctx_plural)) {
// Add user's extracted translatable messages.
for (int i = 0; i < ids.size(); i++) {
r_ids->append(ids[i]);
@@ -71,12 +66,8 @@ Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<Str
}
void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const {
- if (!get_script_instance()) {
- return;
- }
-
- if (get_script_instance()->has_method("_get_recognized_extensions")) {
- Array extensions = get_script_instance()->call("_get_recognized_extensions");
+ Vector<String> extensions;
+ if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) {
for (int i = 0; i < extensions.size(); i++) {
r_extensions->push_back(extensions[i]);
}
@@ -86,8 +77,8 @@ void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_ex
}
void EditorTranslationParserPlugin::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_parse_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::ARRAY, "msgids"), PropertyInfo(Variant::ARRAY, "msgids_context_plural")));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_recognized_extensions"));
+ GDVIRTUAL_BIND(_parse_file, "path", "msgids", "msgids_context_plural");
+ GDVIRTUAL_BIND(_get_recognized_extensions);
}
/////////////////////////
diff --git a/editor/editor_translation_parser.h b/editor/editor_translation_parser.h
index 7013bbb8c4..242ba33b55 100644
--- a/editor/editor_translation_parser.h
+++ b/editor/editor_translation_parser.h
@@ -32,7 +32,9 @@
#define EDITOR_TRANSLATION_PARSER_H
#include "core/error/error_list.h"
+#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
+#include "core/object/script_language.h"
class EditorTranslationParserPlugin : public RefCounted {
GDCLASS(EditorTranslationParserPlugin, RefCounted);
@@ -40,6 +42,9 @@ class EditorTranslationParserPlugin : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL3(_parse_file, String, Array, Array)
+ GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions)
+
public:
virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural);
virtual void get_recognized_extensions(List<String> *r_extensions) const;
diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp
index 8660289c40..d219f6e325 100644
--- a/editor/import/editor_import_plugin.cpp
+++ b/editor/import/editor_import_plugin.cpp
@@ -35,102 +35,131 @@ EditorImportPlugin::EditorImportPlugin() {
}
String EditorImportPlugin::get_importer_name() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_importer_name")), "");
- return get_script_instance()->call("_get_importer_name");
+ String ret;
+ if (GDVIRTUAL_CALL(_get_importer_name, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(String(), "Unimplemented _get_importer_name in add-on.");
}
String EditorImportPlugin::get_visible_name() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_visible_name")), "");
- return get_script_instance()->call("_get_visible_name");
+ String ret;
+ if (GDVIRTUAL_CALL(_get_visible_name, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(String(), "Unimplemented _get_visible_name in add-on.");
}
void EditorImportPlugin::get_recognized_extensions(List<String> *p_extensions) const {
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("_get_recognized_extensions")));
- Array extensions = get_script_instance()->call("_get_recognized_extensions");
- for (int i = 0; i < extensions.size(); i++) {
- p_extensions->push_back(extensions[i]);
+ Vector<String> extensions;
+
+ if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) {
+ for (int i = 0; i < extensions.size(); i++) {
+ p_extensions->push_back(extensions[i]);
+ }
}
+ ERR_FAIL_MSG("Unimplemented _get_recognized_extensions in add-on.");
}
String EditorImportPlugin::get_preset_name(int p_idx) const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_preset_name")), "");
- return get_script_instance()->call("_get_preset_name", p_idx);
+ String ret;
+ if (GDVIRTUAL_CALL(_get_preset_name, p_idx, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(String(), "Unimplemented _get_preset_name in add-on.");
}
int EditorImportPlugin::get_preset_count() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_preset_count")), 0);
- return get_script_instance()->call("_get_preset_count");
+ int ret;
+ if (GDVIRTUAL_CALL(_get_preset_count, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(-1, "Unimplemented _get_preset_count in add-on.");
}
String EditorImportPlugin::get_save_extension() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_save_extension")), "");
- return get_script_instance()->call("_get_save_extension");
+ String ret;
+ if (GDVIRTUAL_CALL(_get_save_extension, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(String(), "Unimplemented _get_save_extension in add-on.");
}
String EditorImportPlugin::get_resource_type() const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_resource_type")), "");
- return get_script_instance()->call("_get_resource_type");
+ String ret;
+ if (GDVIRTUAL_CALL(_get_resource_type, ret)) {
+ return ret;
+ }
+ ERR_FAIL_V_MSG(String(), "Unimplemented _get_resource_type in add-on.");
}
float EditorImportPlugin::get_priority() const {
- if (!(get_script_instance() && get_script_instance()->has_method("_get_priority"))) {
- return ResourceImporter::get_priority();
+ float ret;
+ if (GDVIRTUAL_CALL(_get_priority, ret)) {
+ return ret;
}
- return get_script_instance()->call("_get_priority");
+ ERR_FAIL_V_MSG(-1, "Unimplemented _get_priority in add-on.");
}
int EditorImportPlugin::get_import_order() const {
- if (!(get_script_instance() && get_script_instance()->has_method("_get_import_order"))) {
- return ResourceImporter::get_import_order();
+ int ret;
+ if (GDVIRTUAL_CALL(_get_import_order, ret)) {
+ return ret;
}
- return get_script_instance()->call("_get_import_order");
+ ERR_FAIL_V_MSG(-1, "Unimplemented _get_import_order in add-on.");
}
void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
- ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("_get_import_options")));
Array needed;
needed.push_back("name");
needed.push_back("default_value");
- Array options = get_script_instance()->call("_get_import_options", p_preset);
- for (int i = 0; i < options.size(); i++) {
- Dictionary d = options[i];
- ERR_FAIL_COND(!d.has_all(needed));
- String name = d["name"];
- Variant default_value = d["default_value"];
-
- PropertyHint hint = PROPERTY_HINT_NONE;
- if (d.has("property_hint")) {
- hint = (PropertyHint)d["property_hint"].operator int64_t();
- }
-
- String hint_string;
- if (d.has("hint_string")) {
- hint_string = d["hint_string"];
+ Array options;
+ if (GDVIRTUAL_CALL(_get_import_options, p_preset, options)) {
+ for (int i = 0; i < options.size(); i++) {
+ Dictionary d = options[i];
+ ERR_FAIL_COND(!d.has_all(needed));
+ String name = d["name"];
+ Variant default_value = d["default_value"];
+
+ PropertyHint hint = PROPERTY_HINT_NONE;
+ if (d.has("property_hint")) {
+ hint = (PropertyHint)d["property_hint"].operator int64_t();
+ }
+
+ String hint_string;
+ if (d.has("hint_string")) {
+ hint_string = d["hint_string"];
+ }
+
+ uint32_t usage = PROPERTY_USAGE_DEFAULT;
+ if (d.has("usage")) {
+ usage = d["usage"];
+ }
+
+ ImportOption option(PropertyInfo(default_value.get_type(), name, hint, hint_string, usage), default_value);
+ r_options->push_back(option);
}
-
- uint32_t usage = PROPERTY_USAGE_DEFAULT;
- if (d.has("usage")) {
- usage = d["usage"];
- }
-
- ImportOption option(PropertyInfo(default_value.get_type(), name, hint, hint_string, usage), default_value);
- r_options->push_back(option);
}
+
+ ERR_FAIL_MSG("Unimplemented _get_import_options in add-on.");
}
bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_option_visibility")), true);
Dictionary d;
Map<StringName, Variant>::Element *E = p_options.front();
while (E) {
d[E->key()] = E->get();
E = E->next();
}
- return get_script_instance()->call("_get_option_visibility", p_option, d);
+ bool visible;
+ if (GDVIRTUAL_CALL(_get_option_visibility, p_option, d, visible)) {
+ return visible;
+ }
+
+ ERR_FAIL_V_MSG(false, "Unimplemented _get_option_visibility in add-on.");
}
Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
- ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_import")), ERR_UNAVAILABLE);
Dictionary options;
Array platform_variants, gen_files;
@@ -139,28 +168,33 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
options[E->key()] = E->get();
E = E->next();
}
- Error err = (Error)get_script_instance()->call("_import", p_source_file, p_save_path, options, platform_variants, gen_files).operator int64_t();
- for (int i = 0; i < platform_variants.size(); i++) {
- r_platform_variants->push_back(platform_variants[i]);
- }
- for (int i = 0; i < gen_files.size(); i++) {
- r_gen_files->push_back(gen_files[i]);
+ int err;
+ if (GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err)) {
+ Error ret_err = Error(err);
+
+ for (int i = 0; i < platform_variants.size(); i++) {
+ r_platform_variants->push_back(platform_variants[i]);
+ }
+ for (int i = 0; i < gen_files.size(); i++) {
+ r_gen_files->push_back(gen_files[i]);
+ }
+ return ret_err;
}
- return err;
+ ERR_FAIL_V_MSG(ERR_METHOD_NOT_FOUND, "Unimplemented _import in add-on.");
}
void EditorImportPlugin::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_importer_name"));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_visible_name"));
- BIND_VMETHOD(MethodInfo(Variant::INT, "_get_preset_count"));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_preset_name", PropertyInfo(Variant::INT, "preset")));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_recognized_extensions"));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_import_options", PropertyInfo(Variant::INT, "preset")));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_save_extension"));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_resource_type"));
- BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_get_priority"));
- BIND_VMETHOD(MethodInfo(Variant::INT, "_get_import_order"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_get_option_visibility", PropertyInfo(Variant::STRING, "option"), PropertyInfo(Variant::DICTIONARY, "options")));
- BIND_VMETHOD(MethodInfo(Variant::INT, "_import", PropertyInfo(Variant::STRING, "source_file"), PropertyInfo(Variant::STRING, "save_path"), PropertyInfo(Variant::DICTIONARY, "options"), PropertyInfo(Variant::ARRAY, "platform_variants"), PropertyInfo(Variant::ARRAY, "gen_files")));
+ GDVIRTUAL_BIND(_get_importer_name)
+ GDVIRTUAL_BIND(_get_visible_name)
+ GDVIRTUAL_BIND(_get_preset_count)
+ GDVIRTUAL_BIND(_get_preset_name, "preset_index")
+ GDVIRTUAL_BIND(_get_recognized_extensions)
+ GDVIRTUAL_BIND(_get_import_options, "preset_index")
+ GDVIRTUAL_BIND(_get_save_extension)
+ GDVIRTUAL_BIND(_get_resource_type)
+ GDVIRTUAL_BIND(_get_priority)
+ GDVIRTUAL_BIND(_get_import_order)
+ GDVIRTUAL_BIND(_get_option_visibility, "option_name", "options")
+ GDVIRTUAL_BIND(_import, "source_file", "save_path", "options", "platform_variants", "gen_files");
}
diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h
index 345a40e96d..49c959ab44 100644
--- a/editor/import/editor_import_plugin.h
+++ b/editor/import/editor_import_plugin.h
@@ -39,6 +39,19 @@ class EditorImportPlugin : public ResourceImporter {
protected:
static void _bind_methods();
+ GDVIRTUAL0RC(String, _get_importer_name)
+ GDVIRTUAL0RC(String, _get_visible_name)
+ GDVIRTUAL0RC(int, _get_preset_count)
+ GDVIRTUAL1RC(String, _get_preset_name, int)
+ GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions)
+ GDVIRTUAL1RC(Array, _get_import_options, int)
+ GDVIRTUAL0RC(String, _get_save_extension)
+ GDVIRTUAL0RC(String, _get_resource_type)
+ GDVIRTUAL0RC(float, _get_priority)
+ GDVIRTUAL0RC(int, _get_import_order)
+ GDVIRTUAL2RC(bool, _get_option_visibility, StringName, Dictionary)
+ GDVIRTUAL5RC(int, _import, String, String, Dictionary, Array, Array)
+
public:
EditorImportPlugin();
virtual String get_importer_name() const override;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 492fa3f965..2b03ad928c 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -51,16 +51,17 @@
#include "scene/resources/world_margin_shape_3d.h"
uint32_t EditorSceneImporter::get_import_flags() const {
- if (get_script_instance()) {
- return get_script_instance()->call("_get_import_flags");
+ int ret;
+ if (GDVIRTUAL_CALL(_get_import_flags, ret)) {
+ return ret;
}
ERR_FAIL_V(0);
}
void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
- if (get_script_instance()) {
- Array arr = get_script_instance()->call("_get_extensions");
+ Vector<String> arr;
+ if (GDVIRTUAL_CALL(_get_extensions, arr)) {
for (int i = 0; i < arr.size(); i++) {
r_extensions->push_back(arr[i]);
}
@@ -71,16 +72,18 @@ void EditorSceneImporter::get_extensions(List<String> *r_extensions) const {
}
Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
- if (get_script_instance()) {
- return get_script_instance()->call("_import_scene", p_path, p_flags, p_bake_fps);
+ Object *ret;
+ if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, p_bake_fps, ret)) {
+ return Object::cast_to<Node>(ret);
}
ERR_FAIL_V(nullptr);
}
Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) {
- if (get_script_instance()) {
- return get_script_instance()->call("_import_animation", p_path, p_flags);
+ Ref<Animation> ret;
+ if (GDVIRTUAL_CALL(_import_animation, p_path, p_flags, p_bake_fps, ret)) {
+ return ret;
}
ERR_FAIL_V(nullptr);
@@ -101,15 +104,10 @@ void EditorSceneImporter::_bind_methods() {
ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_scene_from_other_importer);
ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_animation_from_other_importer);
- BIND_VMETHOD(MethodInfo(Variant::INT, "_get_import_flags"));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_extensions"));
-
- MethodInfo mi = MethodInfo(Variant::OBJECT, "_import_scene", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags"), PropertyInfo(Variant::INT, "bake_fps"));
- mi.return_val.class_name = "Node";
- BIND_VMETHOD(mi);
- mi = MethodInfo(Variant::OBJECT, "_import_animation", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags"), PropertyInfo(Variant::INT, "bake_fps"));
- mi.return_val.class_name = "Animation";
- BIND_VMETHOD(mi);
+ GDVIRTUAL_BIND(_get_import_flags);
+ GDVIRTUAL_BIND(_get_extensions);
+ GDVIRTUAL_BIND(_import_scene, "path", "flags", "bake_fps");
+ GDVIRTUAL_BIND(_import_animation, "path", "flags", "bake_fps");
BIND_CONSTANT(IMPORT_SCENE);
BIND_CONSTANT(IMPORT_ANIMATION);
@@ -120,13 +118,14 @@ void EditorSceneImporter::_bind_methods() {
/////////////////////////////////
void EditorScenePostImport::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::OBJECT, "_post_import", PropertyInfo(Variant::OBJECT, "scene")));
+ GDVIRTUAL_BIND(_post_import, "scene")
ClassDB::bind_method(D_METHOD("get_source_file"), &EditorScenePostImport::get_source_file);
}
Node *EditorScenePostImport::post_import(Node *p_scene) {
- if (get_script_instance()) {
- return get_script_instance()->call("_post_import", p_scene);
+ Object *ret;
+ if (GDVIRTUAL_CALL(_post_import, p_scene, ret)) {
+ return Object::cast_to<Node>(ret);
}
return p_scene;
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 781beff689..542959be02 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -51,6 +51,11 @@ protected:
Node *import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps);
Ref<Animation> import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps);
+ GDVIRTUAL0RC(int, _get_import_flags)
+ GDVIRTUAL0RC(Vector<String>, _get_extensions)
+ GDVIRTUAL3R(Object *, _import_scene, String, uint32_t, uint32_t)
+ GDVIRTUAL3R(Ref<Animation>, _import_animation, String, uint32_t, uint32_t)
+
public:
enum ImportFlags {
IMPORT_SCENE = 1,
@@ -77,6 +82,8 @@ class EditorScenePostImport : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL1R(Object *, _post_import, Node *)
+
public:
String get_source_file() const;
virtual Node *post_import(Node *p_scene);
diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp
index a42f94ed3d..5d1b4d8ead 100644
--- a/editor/plugins/node_3d_editor_gizmos.cpp
+++ b/editor/plugins/node_3d_editor_gizmos.cpp
@@ -105,9 +105,7 @@ void EditorNode3DGizmo::clear() {
}
void EditorNode3DGizmo::redraw() {
- if (get_script_instance() && get_script_instance()->has_method("_redraw")) {
- get_script_instance()->call("_redraw");
- } else {
+ if (!GDVIRTUAL_CALL(_redraw)) {
ERR_FAIL_COND(!gizmo_plugin);
gizmo_plugin->redraw(this);
}
@@ -118,8 +116,9 @@ void EditorNode3DGizmo::redraw() {
}
String EditorNode3DGizmo::get_handle_name(int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) {
- return get_script_instance()->call("_get_handle_name", p_id);
+ String ret;
+ if (GDVIRTUAL_CALL(_get_handle_name, p_id, ret)) {
+ return ret;
}
ERR_FAIL_COND_V(!gizmo_plugin, "");
@@ -127,8 +126,9 @@ String EditorNode3DGizmo::get_handle_name(int p_id) const {
}
bool EditorNode3DGizmo::is_handle_highlighted(int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) {
- return get_script_instance()->call("_is_handle_highlighted", p_id);
+ bool success;
+ if (GDVIRTUAL_CALL(_is_handle_highlighted, p_id, success)) {
+ return success;
}
ERR_FAIL_COND_V(!gizmo_plugin, false);
@@ -136,8 +136,9 @@ bool EditorNode3DGizmo::is_handle_highlighted(int p_id) const {
}
Variant EditorNode3DGizmo::get_handle_value(int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) {
- return get_script_instance()->call("_get_handle_value", p_id);
+ Variant value;
+ if (GDVIRTUAL_CALL(_get_handle_value, p_id, value)) {
+ return value;
}
ERR_FAIL_COND_V(!gizmo_plugin, Variant());
@@ -145,8 +146,7 @@ Variant EditorNode3DGizmo::get_handle_value(int p_id) const {
}
void EditorNode3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) {
- if (get_script_instance() && get_script_instance()->has_method("_set_handle")) {
- get_script_instance()->call("_set_handle", p_id, p_camera, p_point);
+ if (GDVIRTUAL_CALL(_set_handle, p_id, p_camera, p_point)) {
return;
}
@@ -155,8 +155,7 @@ void EditorNode3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p
}
void EditorNode3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) {
- if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) {
- get_script_instance()->call("_commit_handle", p_id, p_restore, p_cancel);
+ if (GDVIRTUAL_CALL(_commit_handle, p_id, p_restore, p_cancel)) {
return;
}
@@ -165,8 +164,9 @@ void EditorNode3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p
}
int EditorNode3DGizmo::subgizmos_intersect_ray(Camera3D *p_camera, const Vector2 &p_point) const {
- if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) {
- return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point);
+ int id;
+ if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, p_camera, p_point, id)) {
+ return id;
}
ERR_FAIL_COND_V(!gizmo_plugin, -1);
@@ -174,12 +174,14 @@ int EditorNode3DGizmo::subgizmos_intersect_ray(Camera3D *p_camera, const Vector2
}
Vector<int> EditorNode3DGizmo::subgizmos_intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) const {
- if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) {
- Array frustum;
- for (int i = 0; i < p_frustum.size(); i++) {
- frustum[i] = p_frustum[i];
- }
- return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum);
+ TypedArray<Plane> frustum;
+ frustum.resize(p_frustum.size());
+ for (int i = 0; i < p_frustum.size(); i++) {
+ frustum[i] = p_frustum[i];
+ }
+ Vector<int> ret;
+ if (GDVIRTUAL_CALL(_subgizmos_intersect_frustum, p_camera, frustum, ret)) {
+ return ret;
}
ERR_FAIL_COND_V(!gizmo_plugin, Vector<int>());
@@ -187,8 +189,9 @@ Vector<int> EditorNode3DGizmo::subgizmos_intersect_frustum(const Camera3D *p_cam
}
Transform3D EditorNode3DGizmo::get_subgizmo_transform(int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) {
- return get_script_instance()->call("_get_subgizmo_transform", p_id);
+ Transform3D ret;
+ if (GDVIRTUAL_CALL(_get_subgizmo_transform, p_id, ret)) {
+ return ret;
}
ERR_FAIL_COND_V(!gizmo_plugin, Transform3D());
@@ -196,8 +199,7 @@ Transform3D EditorNode3DGizmo::get_subgizmo_transform(int p_id) const {
}
void EditorNode3DGizmo::set_subgizmo_transform(int p_id, Transform3D p_transform) {
- if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) {
- get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform);
+ if (GDVIRTUAL_CALL(_set_subgizmo_transform, p_id, p_transform)) {
return;
}
@@ -206,18 +208,13 @@ void EditorNode3DGizmo::set_subgizmo_transform(int p_id, Transform3D p_transform
}
void EditorNode3DGizmo::commit_subgizmos(const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) {
- if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) {
- Array ids;
- for (int i = 0; i < p_ids.size(); i++) {
- ids[i] = p_ids[i];
- }
-
- Array restore;
- for (int i = 0; i < p_restore.size(); i++) {
- restore[i] = p_restore[i];
- }
+ TypedArray<Transform3D> restore;
+ restore.resize(p_restore.size());
+ for (int i = 0; i < p_restore.size(); i++) {
+ restore[i] = p_restore[i];
+ }
- get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel);
+ if (GDVIRTUAL_CALL(_commit_subgizmos, p_ids, restore, p_cancel)) {
return;
}
@@ -837,26 +834,19 @@ void EditorNode3DGizmo::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_subgizmo_selected"), &EditorNode3DGizmo::is_subgizmo_selected);
ClassDB::bind_method(D_METHOD("get_subgizmo_selection"), &EditorNode3DGizmo::get_subgizmo_selection);
- BIND_VMETHOD(MethodInfo("_redraw"));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", PropertyInfo(Variant::INT, "id")));
-
- MethodInfo hvget(Variant::NIL, "_get_handle_value", PropertyInfo(Variant::INT, "id"));
- hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
- BIND_VMETHOD(hvget);
+ GDVIRTUAL_BIND(_redraw);
+ GDVIRTUAL_BIND(_get_handle_name, "id");
+ GDVIRTUAL_BIND(_is_handle_highlighted, "id");
- BIND_VMETHOD(MethodInfo("_set_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
- MethodInfo cm = MethodInfo("_commit_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
- cm.default_arguments.push_back(false);
- BIND_VMETHOD(cm);
+ GDVIRTUAL_BIND(_get_handle_value, "id");
+ GDVIRTUAL_BIND(_set_handle, "id", "camera", "point");
+ GDVIRTUAL_BIND(_commit_handle, "id", "restore", "cancel");
- BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
- BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum")));
- BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform")));
- MethodInfo cs = MethodInfo("_commit_subgizmos", PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
- cs.default_arguments.push_back(false);
- BIND_VMETHOD(cs);
+ GDVIRTUAL_BIND(_subgizmos_intersect_ray, "camera", "point");
+ GDVIRTUAL_BIND(_subgizmos_intersect_frustum, "camera", "frustum");
+ GDVIRTUAL_BIND(_set_subgizmo_transform, "id", "transform");
+ GDVIRTUAL_BIND(_get_subgizmo_transform, "id");
+ GDVIRTUAL_BIND(_commit_subgizmos, "ids", "restores", "cancel");
}
EditorNode3DGizmo::EditorNode3DGizmo() {
@@ -1042,11 +1032,6 @@ Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) {
}
void EditorNode3DGizmoPlugin::_bind_methods() {
-#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo")
-
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D")));
- BIND_VMETHOD(MethodInfo(GIZMO_REF, "_create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D")));
-
ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1)));
ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant()));
@@ -1054,45 +1039,42 @@ void EditorNode3DGizmoPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>()));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_gizmo_name"));
- BIND_VMETHOD(MethodInfo(Variant::INT, "_get_priority"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_be_hidden"));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_selectable_when_hidden"));
-
- BIND_VMETHOD(MethodInfo("_redraw", GIZMO_REF));
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "id")));
+ GDVIRTUAL_BIND(_has_gizmo, "for_node_3d");
+ GDVIRTUAL_BIND(_create_gizmo, "for_node_3d");
- MethodInfo hvget(Variant::NIL, "_get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "id"));
- hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
- BIND_VMETHOD(hvget);
+ GDVIRTUAL_BIND(_get_gizmo_name);
+ GDVIRTUAL_BIND(_get_priority);
+ GDVIRTUAL_BIND(_can_be_hidden);
+ GDVIRTUAL_BIND(_is_selectable_when_hidden);
- BIND_VMETHOD(MethodInfo("_set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
- MethodInfo cm = MethodInfo("_commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
- cm.default_arguments.push_back(false);
- BIND_VMETHOD(cm);
+ GDVIRTUAL_BIND(_redraw, "gizmo");
+ GDVIRTUAL_BIND(_get_handle_name, "gizmo", "handle_id");
+ GDVIRTUAL_BIND(_is_handle_highlighted, "gizmo", "handle_id");
+ GDVIRTUAL_BIND(_get_handle_value, "gizmo", "handle_id");
- BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point")));
- BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum")));
- BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id")));
- BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform")));
- MethodInfo cs = MethodInfo("_commit_subgizmos", GIZMO_REF, PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel"));
- cs.default_arguments.push_back(false);
- BIND_VMETHOD(cs);
+ GDVIRTUAL_BIND(_set_handle, "gizmo", "handle_id", "camera", "screen_pos");
+ GDVIRTUAL_BIND(_commit_handle, "gizmo", "handle_id", "restore", "cancel");
-#undef GIZMO_REF
+ GDVIRTUAL_BIND(_subgizmos_intersect_ray, "gizmo", "camera", "screen_pos");
+ GDVIRTUAL_BIND(_subgizmos_intersect_frustum, "gizmo", "camera", "frustum_planes");
+ GDVIRTUAL_BIND(_get_subgizmo_transform, "gizmo", "subgizmo_id");
+ GDVIRTUAL_BIND(_set_subgizmo_transform, "gizmo", "subgizmo_id", "transform");
+ GDVIRTUAL_BIND(_commit_subgizmos, "gizmo", "ids", "restores", "cancel");
+ ;
}
bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
- if (get_script_instance() && get_script_instance()->has_method("_has_gizmo")) {
- return get_script_instance()->call("_has_gizmo", p_spatial);
+ bool success;
+ if (GDVIRTUAL_CALL(_has_gizmo, p_spatial, success)) {
+ return success;
}
return false;
}
Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
- if (get_script_instance() && get_script_instance()->has_method("_create_gizmo")) {
- return get_script_instance()->call("_create_gizmo", p_spatial);
+ Ref<EditorNode3DGizmo> ret;
+ if (GDVIRTUAL_CALL(_create_gizmo, p_spatial, ret)) {
+ return ret;
}
Ref<EditorNode3DGizmo> ref;
@@ -1103,106 +1085,100 @@ Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial)
}
bool EditorNode3DGizmoPlugin::can_be_hidden() const {
- if (get_script_instance() && get_script_instance()->has_method("_can_be_hidden")) {
- return get_script_instance()->call("_can_be_hidden");
+ bool ret;
+ if (GDVIRTUAL_CALL(_can_be_hidden, ret)) {
+ return ret;
}
return true;
}
bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const {
- if (get_script_instance() && get_script_instance()->has_method("_is_selectable_when_hidden")) {
- return get_script_instance()->call("_is_selectable_when_hidden");
+ bool ret;
+ if (GDVIRTUAL_CALL(_is_selectable_when_hidden, ret)) {
+ return ret;
}
return false;
}
void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
- if (get_script_instance() && get_script_instance()->has_method("_redraw")) {
- Ref<EditorNode3DGizmo> ref(p_gizmo);
- get_script_instance()->call("_redraw", ref);
- }
+ GDVIRTUAL_CALL(_redraw, p_gizmo);
}
bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) {
- return get_script_instance()->call("_is_handle_highlighted", p_gizmo, p_id);
+ bool ret;
+ if (GDVIRTUAL_CALL(_is_handle_highlighted, Ref<EditorNode3DGizmo>(p_gizmo), p_id, ret)) {
+ return ret;
}
return false;
}
String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) {
- return get_script_instance()->call("_get_handle_name", p_gizmo, p_id);
+ String ret;
+ if (GDVIRTUAL_CALL(_get_handle_name, Ref<EditorNode3DGizmo>(p_gizmo), p_id, ret)) {
+ return ret;
}
return "";
}
Variant EditorNode3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) {
- return get_script_instance()->call("_get_handle_value", p_gizmo, p_id);
+ Variant ret;
+ if (GDVIRTUAL_CALL(_get_handle_value, Ref<EditorNode3DGizmo>(p_gizmo), p_id, ret)) {
+ return ret;
}
return Variant();
}
void EditorNode3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) {
- if (get_script_instance() && get_script_instance()->has_method("_set_handle")) {
- get_script_instance()->call("_set_handle", p_gizmo, p_id, p_camera, p_point);
- }
+ GDVIRTUAL_CALL(_set_handle, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_camera, p_point);
}
void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) {
- if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) {
- get_script_instance()->call("_commit_handle", p_gizmo, p_id, p_restore, p_cancel);
- }
+ GDVIRTUAL_CALL(_commit_handle, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_restore, p_cancel);
}
int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const {
- if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) {
- return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point);
+ int ret;
+ if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, p_point, ret)) {
+ return ret;
}
return -1;
}
Vector<int> EditorNode3DGizmoPlugin::subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const {
- if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) {
- Array frustum;
- for (int i = 0; i < p_frustum.size(); i++) {
- frustum[i] = p_frustum[i];
- }
- return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum);
+ TypedArray<Transform3D> frustum;
+ frustum.resize(p_frustum.size());
+ for (int i = 0; i < p_frustum.size(); i++) {
+ frustum[i] = p_frustum[i];
+ }
+ Vector<int> ret;
+ if (GDVIRTUAL_CALL(_subgizmos_intersect_frustum, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, frustum, ret)) {
+ return ret;
}
return Vector<int>();
}
Transform3D EditorNode3DGizmoPlugin::get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const {
- if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) {
- return get_script_instance()->call("_get_subgizmo_transform", p_id);
+ Transform3D ret;
+ if (GDVIRTUAL_CALL(_get_subgizmo_transform, Ref<EditorNode3DGizmo>(p_gizmo), p_id, ret)) {
+ return ret;
}
return Transform3D();
}
void EditorNode3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) {
- if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) {
- get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform);
- }
+ GDVIRTUAL_CALL(_set_subgizmo_transform, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_transform);
}
void EditorNode3DGizmoPlugin::commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) {
- if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) {
- Array ids;
- for (int i = 0; i < p_ids.size(); i++) {
- ids[i] = p_ids[i];
- }
-
- Array restore;
- for (int i = 0; i < p_restore.size(); i++) {
- restore[i] = p_restore[i];
- }
-
- get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel);
+ TypedArray<Transform3D> restore;
+ restore.resize(p_restore.size());
+ for (int i = 0; i < p_restore.size(); i++) {
+ restore[i] = p_restore[i];
}
+
+ GDVIRTUAL_CALL(_commit_subgizmos, Ref<EditorNode3DGizmo>(p_gizmo), p_ids, restore, p_cancel);
}
void EditorNode3DGizmoPlugin::set_state(int p_state) {
diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h
index 2cc0951557..415ed5da5c 100644
--- a/editor/plugins/node_3d_editor_gizmos.h
+++ b/editor/plugins/node_3d_editor_gizmos.h
@@ -33,10 +33,10 @@
#include "core/templates/local_vector.h"
#include "core/templates/ordered_hash_map.h"
+#include "scene/3d/camera_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/skeleton_3d.h"
-class Camera3D;
class Timer;
class EditorNode3DGizmoPlugin;
@@ -79,6 +79,19 @@ protected:
EditorNode3DGizmoPlugin *gizmo_plugin;
+ GDVIRTUAL0(_redraw)
+ GDVIRTUAL1RC(String, _get_handle_name, int)
+ GDVIRTUAL1RC(bool, _is_handle_highlighted, int)
+
+ GDVIRTUAL1RC(Variant, _get_handle_value, int)
+ GDVIRTUAL3(_set_handle, int, const Camera3D *, Vector2)
+ GDVIRTUAL3(_commit_handle, int, Variant, bool)
+
+ GDVIRTUAL2RC(int, _subgizmos_intersect_ray, const Camera3D *, Vector2)
+ GDVIRTUAL2RC(Vector<int>, _subgizmos_intersect_frustum, const Camera3D *, TypedArray<Plane>)
+ GDVIRTUAL1RC(Transform3D, _get_subgizmo_transform, int)
+ GDVIRTUAL2(_set_subgizmo_transform, int, Transform3D)
+ GDVIRTUAL3(_commit_subgizmos, Vector<int>, TypedArray<Transform3D>, bool)
public:
void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1));
void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1));
@@ -145,6 +158,28 @@ protected:
virtual bool has_gizmo(Node3D *p_spatial);
virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial);
+ GDVIRTUAL1RC(bool, _has_gizmo, Node3D *)
+ GDVIRTUAL1RC(Ref<EditorNode3DGizmo>, _create_gizmo, Node3D *)
+
+ GDVIRTUAL0RC(String, _get_gizmo_name)
+ GDVIRTUAL0RC(int, _get_priority)
+ GDVIRTUAL0RC(bool, _can_be_hidden)
+ GDVIRTUAL0RC(bool, _is_selectable_when_hidden)
+
+ GDVIRTUAL1(_redraw, Ref<EditorNode3DGizmo>)
+ GDVIRTUAL2RC(String, _get_handle_name, Ref<EditorNode3DGizmo>, int)
+ GDVIRTUAL2RC(bool, _is_handle_highlighted, Ref<EditorNode3DGizmo>, int)
+ GDVIRTUAL2RC(Variant, _get_handle_value, Ref<EditorNode3DGizmo>, int)
+
+ GDVIRTUAL4(_set_handle, Ref<EditorNode3DGizmo>, int, const Camera3D *, Vector2)
+ GDVIRTUAL4(_commit_handle, Ref<EditorNode3DGizmo>, int, Variant, bool)
+
+ GDVIRTUAL3RC(int, _subgizmos_intersect_ray, Ref<EditorNode3DGizmo>, const Camera3D *, Vector2)
+ GDVIRTUAL3RC(Vector<int>, _subgizmos_intersect_frustum, Ref<EditorNode3DGizmo>, const Camera3D *, TypedArray<Plane>)
+ GDVIRTUAL2RC(Transform3D, _get_subgizmo_transform, Ref<EditorNode3DGizmo>, int)
+ GDVIRTUAL3(_set_subgizmo_transform, Ref<EditorNode3DGizmo>, int, Transform3D)
+ GDVIRTUAL4(_commit_subgizmos, Ref<EditorNode3DGizmo>, Vector<int>, TypedArray<Transform3D>, bool)
+
public:
void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 5c1e557286..567cd33305 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -54,17 +54,17 @@
/*** SYNTAX HIGHLIGHTER ****/
String EditorSyntaxHighlighter::_get_name() const {
- ScriptInstance *si = get_script_instance();
- if (si && si->has_method("_get_name")) {
- return si->call("_get_name");
+ String ret;
+ if (GDVIRTUAL_CALL(_get_name, ret)) {
+ return ret;
}
return "Unnamed";
}
Array EditorSyntaxHighlighter::_get_supported_languages() const {
- ScriptInstance *si = get_script_instance();
- if (si && si->has_method("_get_supported_languages")) {
- return si->call("_get_supported_languages");
+ Array ret;
+ if (GDVIRTUAL_CALL(_get_supported_languages, ret)) {
+ return ret;
}
return Array();
}
@@ -81,9 +81,8 @@ Ref<EditorSyntaxHighlighter> EditorSyntaxHighlighter::_create() const {
void EditorSyntaxHighlighter::_bind_methods() {
ClassDB::bind_method(D_METHOD("_get_edited_resource"), &EditorSyntaxHighlighter::_get_edited_resource);
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_name"));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_supported_languages"));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_supported_extentions"));
+ GDVIRTUAL_BIND(_get_name)
+ GDVIRTUAL_BIND(_get_supported_languages)
}
////
@@ -223,8 +222,6 @@ void ScriptEditorBase::_bind_methods() {
// TODO: This signal is no use for VisualScript.
ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text")));
ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text")));
-
- BIND_VMETHOD(MethodInfo("_add_syntax_highlighter", PropertyInfo(Variant::OBJECT, "highlighter")));
}
static bool _is_built_in_script(Script *p_script) {
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index e322828b6c..a1474c5f66 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -56,6 +56,9 @@ private:
protected:
static void _bind_methods();
+ GDVIRTUAL0RC(String, _get_name)
+ GDVIRTUAL0RC(Array, _get_supported_languages)
+
public:
virtual String _get_name() const;
virtual Array _get_supported_languages() const;
@@ -74,7 +77,7 @@ private:
public:
virtual void _update_cache() override;
- virtual Dictionary _get_line_syntax_highlighting(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
+ virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
virtual String _get_name() const override { return TTR("Standard"); }
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index d84ed4828c..4ed9f712c1 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -70,14 +70,15 @@ const int MAX_FLOAT_CONST_DEFS = sizeof(float_constant_defs) / sizeof(FloatConst
///////////////////
Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
- if (get_script_instance()) {
- return get_script_instance()->call("_create_editor", p_parent_resource, p_node);
+ Object *ret;
+ if (GDVIRTUAL_CALL(_create_editor, p_parent_resource, p_node, ret)) {
+ return Object::cast_to<Control>(ret);
}
return nullptr;
}
void VisualShaderNodePlugin::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::OBJECT, "_create_editor", PropertyInfo(Variant::OBJECT, "parent_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::OBJECT, "for_node", PROPERTY_HINT_RESOURCE_TYPE, "VisualShaderNode")));
+ GDVIRTUAL_BIND(_create_editor, "parent_resource", "visual_shader_node");
}
///////////////////
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index fbfe1197a3..9f24c5af72 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -47,6 +47,8 @@ class VisualShaderNodePlugin : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL2RC(Object *, _create_editor, RES, Ref<VisualShaderNode>)
+
public:
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node);
};
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 7338588d56..6ea9b9dfae 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -59,42 +59,33 @@
#include "scene/scene_string_names.h"
void EditorResourceConversionPlugin::_bind_methods() {
- MethodInfo mi;
- mi.name = "_convert";
- mi.return_val.type = Variant::OBJECT;
- mi.return_val.class_name = "Resource";
- mi.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE;
- mi.return_val.hint_string = "Resource";
- mi.arguments.push_back(mi.return_val);
- mi.arguments[0].name = "resource";
-
- BIND_VMETHOD(mi)
-
- mi.name = "_handles";
- mi.return_val = PropertyInfo(Variant::BOOL, "");
-
- BIND_VMETHOD(MethodInfo(Variant::STRING, "_converts_to"));
+ GDVIRTUAL_BIND(_converts_to);
+ GDVIRTUAL_BIND(_handles, "resource");
+ GDVIRTUAL_BIND(_convert, "resource");
}
String EditorResourceConversionPlugin::converts_to() const {
- if (get_script_instance()) {
- return get_script_instance()->call("_converts_to");
+ String ret;
+ if (GDVIRTUAL_CALL(_converts_to, ret)) {
+ return ret;
}
return "";
}
bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const {
- if (get_script_instance()) {
- return get_script_instance()->call("_handles", p_resource);
+ bool ret;
+ if (GDVIRTUAL_CALL(_handles, p_resource, ret)) {
+ return ret;
}
return false;
}
Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const {
- if (get_script_instance()) {
- return get_script_instance()->call("_convert", p_resource);
+ RES ret;
+ if (GDVIRTUAL_CALL(_convert, p_resource, ret)) {
+ return ret;
}
return Ref<Resource>();
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 8a587b50b0..23771b7494 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -56,6 +56,10 @@ class EditorResourceConversionPlugin : public RefCounted {
protected:
static void _bind_methods();
+ GDVIRTUAL0RC(String, _converts_to)
+ GDVIRTUAL1RC(bool, _handles, RES)
+ GDVIRTUAL1RC(RES, _convert, RES)
+
public:
virtual String converts_to() const;
virtual bool handles(const Ref<Resource> &p_resource) const;