From 743c63670ec2da8db6be3af34f1bbc3322419667 Mon Sep 17 00:00:00 2001 From: Franklin Sobrinho Date: Mon, 15 Aug 2016 14:49:58 -0300 Subject: [PATCH] Expose additional functions for the EditorPlugin class (cherry picked from commit 104653f9ebf5f04c050ad8db5dcf060651ff8bb2) --- tools/editor/editor_plugin.cpp | 28 +++++++++++++++++++++++++--- tools/editor/editor_plugin.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 0d162cbe567..5e671549ef8 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -211,15 +211,22 @@ void EditorPlugin::clear() { } -void EditorPlugin::save_external_data() {} // if editor references external resources/scenes, save them +// 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"); + } +} + +// 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"); } +} - -} // if changes are pending in editor, apply them void EditorPlugin::get_breakpoints(List *p_breakpoints) { if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) { @@ -239,10 +246,21 @@ void EditorPlugin::save_global_state() {} void EditorPlugin::set_window_layout(Ref p_layout) { + if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { + get_script_instance()->call("set_window_layout", p_layout); + } } void EditorPlugin::get_window_layout(Ref p_layout){ + if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) { + get_script_instance()->call("get_window_layout", p_layout); + } +} + +void EditorPlugin::queue_save_layout() const { + + EditorNode::get_singleton()->save_layout(); } EditorSelection* EditorPlugin::get_selection() { @@ -302,6 +320,7 @@ void EditorPlugin::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo); ObjectTypeDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection); ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings); + ObjectTypeDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_input_event",PropertyInfo(Variant::INPUT_EVENT,"event"))); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_spatial_input_event",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event"))); @@ -317,8 +336,11 @@ void EditorPlugin::_bind_methods() { ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::DICTIONARY,"get_state")); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("set_state",PropertyInfo(Variant::DICTIONARY,"state"))); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("clear")); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("save_external_data")); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("apply_changes")); ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING_ARRAY,"get_breakpoints")); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("set_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile"))); + ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("get_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile"))); BIND_CONSTANT( CONTAINER_TOOLBAR ); BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_MENU ); diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index b960a7d5afc..9a9c32357de 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -118,6 +118,7 @@ public: virtual void get_window_layout(Ref p_layout); virtual void edited_scene_changed(){}; // if changes are pending in editor, apply them + void queue_save_layout() const; Control *get_base_control();