summaryrefslogtreecommitdiff
path: root/tools/editor/editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/editor_plugin.cpp')
-rw-r--r--tools/editor/editor_plugin.cpp141
1 files changed, 85 insertions, 56 deletions
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 4b82d5e59c..2f59b0bd07 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_plugin.h"
+
+#include "scene/gui/popup_menu.h"
#include "scene/3d/camera.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
@@ -76,6 +78,11 @@ Control * EditorPlugin::get_editor_viewport() {
return EditorNode::get_singleton()->get_viewport();
}
+void EditorPlugin::edit_resource(const Ref<Resource>& p_resource){
+
+ EditorNode::get_singleton()->edit_resource(p_resource);
+}
+
void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
switch(p_location) {
@@ -127,6 +134,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
}
}
+void EditorPlugin::add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud) {
+
+ //EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud);
+}
+
+void EditorPlugin::add_tool_submenu_item(const String& p_name, Object *p_submenu) {
+
+ ERR_FAIL_NULL(p_submenu);
+ PopupMenu *submenu = p_submenu->cast_to<PopupMenu>();
+ ERR_FAIL_NULL(submenu);
+ //EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
+}
+
+void EditorPlugin::remove_tool_menu_item(const String& p_name) {
+
+ //EditorNode::get_singleton()->remove_tool_menu_item(p_name);
+}
+
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
@@ -136,15 +161,15 @@ Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
return Ref<SpatialEditorGizmo>();
}
-bool EditorPlugin::forward_canvas_input_event(const Matrix32& p_canvas_xform,const InputEvent& p_event) {
+bool EditorPlugin::forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) {
- if (get_script_instance() && get_script_instance()->has_method("forward_canvas_input_event")) {
- return get_script_instance()->call("forward_canvas_input_event",p_canvas_xform,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_canvas_xform,p_event);
}
return false;
}
-void EditorPlugin::forward_draw_over_canvas(const Matrix32& p_canvas_xform,Control *p_canvas) {
+void EditorPlugin::forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control *p_canvas) {
if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_canvas")) {
get_script_instance()->call("forward_draw_over_canvas",p_canvas_xform,p_canvas);
@@ -155,10 +180,10 @@ void EditorPlugin::update_canvas() {
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
}
-bool EditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) {
+bool EditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) {
- if (get_script_instance() && get_script_instance()->has_method("forward_spatial_input_event")) {
- return get_script_instance()->call("forward_spatial_input_event",p_camera,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);
}
return false;
@@ -248,7 +273,7 @@ void EditorPlugin::apply_changes() {
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
- StringArray arr = get_script_instance()->call("get_breakpoints");
+ PoolStringArray arr = get_script_instance()->call("get_breakpoints");
for(int i=0;i<arr.size();i++)
p_breakpoints->push_back(arr[i]);
}
@@ -341,56 +366,60 @@ EditorFileSystem *EditorPlugin::get_resource_file_system() {
void EditorPlugin::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
- ObjectTypeDB::bind_method(_MD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
- ObjectTypeDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
- ObjectTypeDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
- ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
- ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
- ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
- ObjectTypeDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
-
- ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
- ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
-
- ObjectTypeDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin);
- ObjectTypeDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin);
-
- ObjectTypeDB::bind_method(_MD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer);
- ObjectTypeDB::bind_method(_MD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system);
-
- ObjectTypeDB::bind_method(_MD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
- ObjectTypeDB::bind_method(_MD("update_canvas"),&EditorPlugin::update_canvas);
-
- ObjectTypeDB::bind_method(_MD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
- ObjectTypeDB::bind_method(_MD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
-
- ObjectTypeDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
- 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_canvas_input_event",PropertyInfo(Variant::MATRIX32,"canvas_xform"),PropertyInfo(Variant::INPUT_EVENT,"event")));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("forward_draw_over_canvas",PropertyInfo(Variant::MATRIX32,"canvas_xform"),PropertyInfo(Variant::OBJECT,"canvas:Control")));
- 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")));
+ ClassDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
+ ClassDB::bind_method(_MD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
+ ClassDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
+ ClassDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
+ ClassDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
+ //ClassDB::bind_method(_MD("add_tool_menu_item", "name", "handler", "callback", "ud"),&EditorPlugin::add_tool_menu_item,DEFVAL(Variant()));
+ ClassDB::bind_method(_MD("add_tool_submenu_item", "name", "submenu:PopupMenu"),&EditorPlugin::add_tool_submenu_item);
+ //ClassDB::bind_method(_MD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item);
+ ClassDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
+ ClassDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
+ ClassDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
+
+ ClassDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
+ ClassDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
+
+ ClassDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin);
+ ClassDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin);
+
+ ClassDB::bind_method(_MD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer);
+ ClassDB::bind_method(_MD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system);
+
+ ClassDB::bind_method(_MD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
+ ClassDB::bind_method(_MD("update_canvas"),&EditorPlugin::update_canvas);
+
+ ClassDB::bind_method(_MD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
+ ClassDB::bind_method(_MD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
+
+ ClassDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
+ ClassDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
+ ClassDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
+ ClassDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
+ ClassDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout);
+ ClassDB::bind_method(_MD("edit_resource"),&EditorPlugin::edit_resource);
+
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"forward_canvas_gui_input",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::INPUT_EVENT,"event")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("forward_draw_over_canvas",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::OBJECT,"canvas:Control")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"forward_spatial_gui_input",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event")));
MethodInfo gizmo = MethodInfo(Variant::OBJECT,"create_spatial_gizmo",PropertyInfo(Variant::OBJECT,"for_spatial:Spatial"));
gizmo.return_val.hint=PROPERTY_HINT_RESOURCE_TYPE;
gizmo.return_val.hint_string="EditorSpatialGizmo";
- ObjectTypeDB::add_virtual_method(get_type_static(),gizmo);
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING,"get_name"));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"has_main_screen"));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("make_visible",PropertyInfo(Variant::BOOL,"visible")));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("edit",PropertyInfo(Variant::OBJECT,"object")));
- ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::OBJECT,"object")));
- 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")));
+ ClassDB::add_virtual_method(get_class_static(),gizmo);
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_name"));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"has_main_screen"));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("make_visible",PropertyInfo(Variant::BOOL,"visible")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("edit",PropertyInfo(Variant::OBJECT,"object")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::OBJECT,"object")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::DICTIONARY,"get_state"));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("set_state",PropertyInfo(Variant::DICTIONARY,"state")));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("clear"));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("save_external_data"));
+ ClassDB::add_virtual_method(get_class_static(),MethodInfo("apply_changes"));
+ 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")));
BIND_CONSTANT( CONTAINER_TOOLBAR );
BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_MENU );