diff options
Diffstat (limited to 'editor/editor_plugin.cpp')
-rw-r--r-- | editor/editor_plugin.cpp | 298 |
1 files changed, 146 insertions, 152 deletions
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b5f63dcd43..bce46b719a 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -38,20 +38,19 @@ #include "editor_resource_preview.h" #include "main/main.h" #include "plugins/canvas_item_editor_plugin.h" -#include "plugins/spatial_editor_plugin.h" -#include "scene/3d/camera.h" +#include "plugins/node_3d_editor_plugin.h" +#include "scene/3d/camera_3d.h" #include "scene/gui/popup_menu.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) { - - Vector<Ref<Mesh> > meshes; + Vector<Ref<Mesh>> meshes; for (int i = 0; i < p_meshes.size(); i++) { meshes.push_back(p_meshes[i]); } - Vector<Ref<Texture> > textures = make_mesh_previews(meshes, NULL, p_preview_size); + Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size); Array ret; for (int i = 0; i < textures.size(); i++) { ret.push_back(textures[i]); @@ -60,50 +59,47 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ return ret; } -Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { - +Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { int size = p_preview_size; - RID scenario = VS::get_singleton()->scenario_create(); + RID scenario = RS::get_singleton()->scenario_create(); - RID viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS); - VS::get_singleton()->viewport_set_vflip(viewport, true); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, size, size); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - RID viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + RID viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, size, size); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - RID camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); + RID camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); - RID light = VS::get_singleton()->directional_light_create(); - RID light_instance = VS::get_singleton()->instance_create2(light, scenario); + RID light = RS::get_singleton()->directional_light_create(); + RID light_instance = RS::get_singleton()->instance_create2(light, scenario); - RID light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + RID light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size()); - Vector<Ref<Texture> > textures; + Vector<Ref<Texture2D>> textures; for (int i = 0; i < p_meshes.size(); i++) { - Ref<Mesh> mesh = p_meshes[i]; if (!mesh.is_valid()) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } Transform mesh_xform; - if (p_transforms != NULL) { + if (p_transforms != nullptr) { mesh_xform = (*p_transforms)[i]; } - RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario); - VS::get_singleton()->instance_set_transform(inst, mesh_xform); + RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario); + RS::get_singleton()->instance_set_transform(inst, mesh_xform); AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; @@ -114,7 +110,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } xform.origin = -xform.basis.xform(ofs); //-ofs*m; @@ -122,32 +118,32 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> xform.invert(); xform = mesh_xform * xform; - VS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); - VS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); + RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); - VS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); - VS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); ep.step(TTR("Thumbnail..."), i); Main::iteration(); Main::iteration(); - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_CONTINUE(!img.is_valid() || img->empty()); Ref<ImageTexture> it(memnew(ImageTexture)); it->create_from_image(img); - VS::get_singleton()->free(inst); + RS::get_singleton()->free(inst); textures.push_back(it); } - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); return textures; } @@ -157,17 +153,14 @@ void EditorInterface::set_main_screen_editor(const String &p_name) { } Control *EditorInterface::get_editor_viewport() { - return EditorNode::get_singleton()->get_viewport(); } void EditorInterface::edit_resource(const Ref<Resource> &p_resource) { - EditorNode::get_singleton()->edit_resource(p_resource); } void EditorInterface::open_scene_from_path(const String &scene_path) { - if (EditorNode::get_singleton()->is_changing_scene()) { return; } @@ -176,7 +169,6 @@ void EditorInterface::open_scene_from_path(const String &scene_path) { } void EditorInterface::reload_scene_from_path(const String &scene_path) { - if (EditorNode::get_singleton()->is_changing_scene()) { return; } @@ -184,19 +176,43 @@ void EditorInterface::reload_scene_from_path(const String &scene_path) { EditorNode::get_singleton()->reload_scene(scene_path); } +void EditorInterface::play_main_scene() { + EditorNode::get_singleton()->run_play(); +} + +void EditorInterface::play_current_scene() { + EditorNode::get_singleton()->run_play_current(); +} + +void EditorInterface::play_custom_scene(const String &scene_path) { + EditorNode::get_singleton()->run_play_custom(scene_path); +} + +void EditorInterface::stop_playing_scene() { + EditorNode::get_singleton()->run_stop(); +} + +bool EditorInterface::is_playing_scene() const { + return EditorNode::get_singleton()->is_run_playing(); +} + +String EditorInterface::get_playing_scene() const { + return EditorNode::get_singleton()->get_run_playing_scene(); +} + Node *EditorInterface::get_edited_scene_root() { return EditorNode::get_singleton()->get_edited_scene(); } Array EditorInterface::get_open_scenes() const { - Array ret; Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes(); int scns_amount = scenes.size(); for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) { - if (scenes[idx_scn].root == NULL) + if (scenes[idx_scn].root == nullptr) { continue; + } ret.push_back(scenes[idx_scn].root->get_filename()); } return ret; @@ -219,7 +235,6 @@ String EditorInterface::get_current_path() const { } void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property) { - EditorNode::get_singleton()->push_item(p_obj, p_for_property); } @@ -227,6 +242,10 @@ EditorFileSystem *EditorInterface::get_resource_file_system() { return EditorFileSystem::get_singleton(); } +FileSystemDock *EditorInterface::get_file_system_dock() { + return EditorNode::get_singleton()->get_filesystem_dock(); +} + EditorSelection *EditorInterface::get_selection() { return EditorNode::get_singleton()->get_editor_selection(); } @@ -240,7 +259,6 @@ EditorResourcePreview *EditorInterface::get_resource_previewer() { } Control *EditorInterface::get_base_control() { - return EditorNode::get_singleton()->get_gui_base(); } @@ -257,17 +275,18 @@ EditorInspector *EditorInterface::get_inspector() const { } Error EditorInterface::save_scene() { - if (!get_edited_scene_root()) + if (!get_edited_scene_root()) { return ERR_CANT_CREATE; - if (get_edited_scene_root()->get_filename() == String()) + } + if (get_edited_scene_root()->get_filename() == String()) { return ERR_CANT_CREATE; + } save_scene_as(get_edited_scene_root()->get_filename()); return OK; } void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) { - EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview); } @@ -275,10 +294,13 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) { EditorNode::get_singleton()->set_distraction_free_mode(p_enter); } -EditorInterface *EditorInterface::singleton = NULL; +bool EditorInterface::is_distraction_free_mode_enabled() const { + return EditorNode::get_singleton()->is_distraction_free_mode_enabled(); +} + +EditorInterface *EditorInterface::singleton = nullptr; void EditorInterface::_bind_methods() { - ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorInterface::inspect_object, DEFVAL(String())); ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection); ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings); @@ -287,6 +309,12 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource); ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path); ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path); + ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene); + ClassDB::bind_method(D_METHOD("play_current_scene"), &EditorInterface::play_current_scene); + ClassDB::bind_method(D_METHOD("play_custom_scene", "scene_filepath"), &EditorInterface::play_custom_scene); + ClassDB::bind_method(D_METHOD("stop_playing_scene"), &EditorInterface::stop_playing_scene); + ClassDB::bind_method(D_METHOD("is_playing_scene"), &EditorInterface::is_playing_scene); + ClassDB::bind_method(D_METHOD("get_playing_scene"), &EditorInterface::get_playing_scene); ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes); ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root); ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer); @@ -296,6 +324,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path); + ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock); ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled); ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled); @@ -307,6 +336,9 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor); ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode); + ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled"); } EditorInterface::EditorInterface() { @@ -314,13 +346,11 @@ EditorInterface::EditorInterface() { } /////////////////////////////////////////// -void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { - +void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon); } void EditorPlugin::remove_custom_type(const String &p_type) { - EditorNode::get_editor_data().remove_custom_type(p_type); } @@ -332,25 +362,22 @@ void EditorPlugin::remove_autoload_singleton(const String &p_name) { EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name); } -ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) { - ERR_FAIL_NULL_V(p_control, NULL); +Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) { + ERR_FAIL_NULL_V(p_control, nullptr); return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control); } void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control); } void EditorPlugin::remove_control_from_docks(Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->remove_control_from_dock(p_control); } void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->remove_bottom_panel_item(p_control); } @@ -359,69 +386,56 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C ERR_FAIL_NULL(p_control); switch (p_location) { - case CONTAINER_TOOLBAR: { - EditorNode::get_menu_hb()->add_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_MENU: { - - SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control); + Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: { - - SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); - SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); + Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { - - SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); - SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); + Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { - - SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: { - CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { - CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); } break; case CONTAINER_CANVAS_EDITOR_BOTTOM: { - CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control); } break; case CONTAINER_PROPERTY_EDITOR_BOTTOM: { - EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control); } break; case CONTAINER_PROJECT_SETTING_TAB_LEFT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0); } break; case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1); @@ -433,52 +447,42 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati ERR_FAIL_NULL(p_control); switch (p_location) { - case CONTAINER_TOOLBAR: { - EditorNode::get_menu_hb()->remove_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_MENU: { - - SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control); + Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { - - SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { - - SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control); + Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { - CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { - CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_BOTTOM: { - CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control); } break; case CONTAINER_PROPERTY_EDITOR_BOTTOM: { - EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control); } break; case CONTAINER_PROJECT_SETTING_TAB_LEFT: case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control); } break; @@ -517,9 +521,9 @@ void EditorPlugin::notify_scene_changed(const Node *scn_root) { } void EditorPlugin::notify_main_screen_changed(const String &screen_name) { - - if (screen_name == last_main_screen_name) + if (screen_name == last_main_screen_name) { return; + } emit_signal("main_screen_changed", screen_name); last_main_screen_name = screen_name; @@ -534,7 +538,6 @@ 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); } @@ -542,14 +545,12 @@ bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { } 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); } } 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); } @@ -557,11 +558,10 @@ void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) { // Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport. int EditorPlugin::update_overlays() const { - - if (SpatialEditor::get_singleton()->is_visible()) { + if (Node3DEditor::get_singleton()->is_visible()) { int count = 0; - for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) { - SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i); + for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) { + Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i); if (vp->is_visible()) { vp->update_surface(); count++; @@ -575,8 +575,7 @@ int EditorPlugin::update_overlays() const { } } -bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { - +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); } @@ -585,51 +584,48 @@ bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEv } 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); } } 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); } } -String EditorPlugin::get_name() const { +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"); } return String(); } -const Ref<Texture> EditorPlugin::get_icon() const { +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"); } - return Ref<Texture>(); + return Ref<Texture2D>(); } -bool EditorPlugin::has_main_screen() const { +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"); } return false; } -void EditorPlugin::make_visible(bool p_visible) { +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); } } 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))); @@ -640,15 +636,14 @@ void EditorPlugin::edit(Object *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); } return false; } -Dictionary EditorPlugin::get_state() const { +Dictionary EditorPlugin::get_state() const { if (get_script_instance() && get_script_instance()->has_method("get_state")) { return get_script_instance()->call("get_state"); } @@ -657,14 +652,12 @@ Dictionary EditorPlugin::get_state() const { } 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); } } void EditorPlugin::clear() { - if (get_script_instance() && get_script_instance()->has_method("clear")) { get_script_instance()->call("clear"); } @@ -672,7 +665,6 @@ void EditorPlugin::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"); } @@ -680,28 +672,35 @@ void EditorPlugin::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"); } } void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) { - if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) { - PoolStringArray arr = get_script_instance()->call("get_breakpoints"); - for (int i = 0; i < arr.size(); i++) + PackedStringArray arr = get_script_instance()->call("get_breakpoints"); + for (int i = 0; i < arr.size(); i++) { p_breakpoints->push_back(arr[i]); + } } } -bool EditorPlugin::get_remove_list(List<Node *> *p_list) { +bool EditorPlugin::get_remove_list(List<Node *> *p_list) { return false; } void EditorPlugin::restore_global_state() {} void EditorPlugin::save_global_state() {} +void EditorPlugin::add_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) { + EditorTranslationParser::get_singleton()->add_parser(p_parser, EditorTranslationParser::CUSTOM); +} + +void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) { + EditorTranslationParser::get_singleton()->remove_parser(p_parser, EditorTranslationParser::CUSTOM); +} + void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) { ResourceFormatImporter::get_singleton()->add_importer(p_importer); EditorFileSystem::get_singleton()->call_deferred("scan"); @@ -720,12 +719,12 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte EditorExport::get_singleton()->remove_export_plugin(p_exporter); } -void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) { - SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin); +void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) { + Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin); } -void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) { - SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin); +void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) { + Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin); } void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { @@ -744,8 +743,8 @@ void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_ ResourceImporterScene::get_singleton()->remove_importer(p_importer); } -int find(const PoolStringArray &a, const String &v) { - PoolStringArray::Read r = a.read(); +int find(const PackedStringArray &a, const String &v) { + const String *r = a.ptr(); for (int j = 0; j < a.size(); ++j) { if (r[j] == v) { return j; @@ -773,21 +772,18 @@ void EditorPlugin::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); } } 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); } } bool EditorPlugin::build() { - if (get_script_instance() && get_script_instance()->has_method("build")) { return get_script_instance()->call("build"); } @@ -796,17 +792,14 @@ bool EditorPlugin::build() { } void EditorPlugin::queue_save_layout() const { - EditorNode::get_singleton()->save_layout(); } void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) { - EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item); } void EditorPlugin::hide_bottom_panel() { - EditorNode::get_singleton()->hide_bottom_panel(); } @@ -818,8 +811,15 @@ ScriptCreateDialog *EditorPlugin::get_script_create_dialog() { return EditorNode::get_singleton()->get_script_create_dialog(); } -void EditorPlugin::_bind_methods() { +void EditorPlugin::add_debugger_plugin(const Ref<Script> &p_script) { + EditorDebuggerNode::get_singleton()->add_debugger_plugin(p_script); +} +void EditorPlugin::remove_debugger_plugin(const Ref<Script> &p_script) { + EditorDebuggerNode::get_singleton()->remove_debugger_plugin(p_script); +} + +void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container); ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel); ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock); @@ -842,6 +842,8 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::_get_undo_redo); ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); + ClassDB::bind_method(D_METHOD("add_translation_parser_plugin", "parser"), &EditorPlugin::add_translation_parser_plugin); + ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin); ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin); ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin); ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin); @@ -857,13 +859,15 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface); ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog); + 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); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "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::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); + ClassDB::add_virtual_method(get_class_static(), 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"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "get_plugin_icon")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "get_plugin_icon")); 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"))); @@ -873,7 +877,7 @@ void EditorPlugin::_bind_methods() { 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(Variant::PACKED_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")); @@ -909,16 +913,6 @@ void EditorPlugin::_bind_methods() { BIND_ENUM_CONSTANT(DOCK_SLOT_MAX); } -EditorPlugin::EditorPlugin() : - undo_redo(NULL), - input_event_forwarding_always_enabled(false), - force_draw_over_forwarding_enabled(false), - last_main_screen_name("") { -} - -EditorPlugin::~EditorPlugin() { -} - EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS]; int EditorPlugins::creation_func_count = 0; |