summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-05-26 19:01:45 +0200
committerGitHub <noreply@github.com>2018-05-26 19:01:45 +0200
commit8a9e7ab6a627ef3e0a3d872fb24c9dba744a827e (patch)
tree8ca6b4d8393b56252691a10430a2bb62155bfe6b /editor
parent23b4b7d53a8dabf822cf07074c3b72de43cf649c (diff)
parent732a877b21cf41ca649ab09ed57eff426066ffca (diff)
Merge pull request #15489 from willnationsdev/gdnative-hook
Add EditorPlugin.build() build callbacks
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_data.cpp12
-rw-r--r--editor/editor_data.h1
-rw-r--r--editor/editor_node.cpp17
-rw-r--r--editor/editor_plugin.cpp10
-rw-r--r--editor/editor_plugin.h1
5 files changed, 37 insertions, 4 deletions
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 4ac3e33cb9..d41d5c929a 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -420,6 +420,18 @@ void EditorData::paste_object_params(Object *p_object) {
}
}
+bool EditorData::call_build() {
+
+ bool result = true;
+
+ for (int i = 0; i < editor_plugins.size() && result; i++) {
+
+ result &= editor_plugins[i]->build();
+ }
+
+ return result;
+}
+
UndoRedo &EditorData::get_undo_redo() {
return undo_redo;
diff --git a/editor/editor_data.h b/editor/editor_data.h
index f020d07ea7..0452867bf4 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -197,6 +197,7 @@ public:
NodePath get_edited_scene_live_edit_root();
bool check_and_update_scene(int p_idx);
void move_edited_scene_to_index(int p_idx);
+ bool call_build();
void set_plugin_window_layout(Ref<ConfigFile> p_layout);
void get_plugin_window_layout(Ref<ConfigFile> p_layout);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 66966dfb75..4b068f1000 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4271,12 +4271,21 @@ EditorBuildCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS]
bool EditorNode::call_build() {
- for (int i = 0; i < build_callback_count; i++) {
- if (!build_callbacks[i]())
- return false;
+ bool builds_successful = true;
+
+ for (int i = 0; i < build_callback_count && builds_successful; i++) {
+ if (!build_callbacks[i]()) {
+ ERR_PRINT("A Godot Engine build callback failed.");
+ builds_successful = false;
+ }
}
- return true;
+ if (builds_successful && !editor_data.call_build()) {
+ ERR_PRINT("An EditorPlugin build callback failed.");
+ builds_successful = false;
+ }
+
+ return builds_successful;
}
void EditorNode::_inherit_imported(const String &p_action) {
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 24d0592ee7..cc44938c25 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -689,6 +689,15 @@ void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
}
}
+bool EditorPlugin::build() {
+
+ if (get_script_instance() && get_script_instance()->has_method("build")) {
+ return get_script_instance()->call("build");
+ }
+
+ return true;
+}
+
void EditorPlugin::queue_save_layout() const {
EditorNode::get_singleton()->save_layout();
@@ -767,6 +776,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_breakpoints"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build"));
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 8af7f83771..fcc74cb1e9 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -192,6 +192,7 @@ public:
virtual void set_window_layout(Ref<ConfigFile> p_layout);
virtual void get_window_layout(Ref<ConfigFile> p_layout);
virtual void edited_scene_changed() {} // if changes are pending in editor, apply them
+ virtual bool build(); // builds with external tools. Returns true if safe to continue running scene.
EditorInterface *get_editor_interface();