2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_plugin.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2018-01-01 13:40:08 +00:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "editor_plugin.h"
|
2017-01-16 07:04:19 +00:00
|
|
|
|
2017-03-05 13:21:25 +00:00
|
|
|
#include "editor/editor_node.h"
|
|
|
|
#include "editor/editor_settings.h"
|
2016-09-10 18:32:17 +00:00
|
|
|
#include "editor_resource_preview.h"
|
2017-08-28 03:03:34 +00:00
|
|
|
#include "main/main.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "plugins/canvas_item_editor_plugin.h"
|
|
|
|
#include "plugins/spatial_editor_plugin.h"
|
|
|
|
#include "scene/3d/camera.h"
|
|
|
|
#include "scene/gui/popup_menu.h"
|
2017-08-28 03:03:34 +00:00
|
|
|
#include "servers/visual_server.h"
|
|
|
|
Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) {
|
|
|
|
|
|
|
|
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, p_preview_size);
|
|
|
|
Array ret;
|
|
|
|
for (int i = 0; i < textures.size(); i++) {
|
|
|
|
ret.push_back(textures[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, int p_preview_size) {
|
|
|
|
|
|
|
|
int size = p_preview_size;
|
|
|
|
|
|
|
|
RID scenario = VS::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 camera = VS::get_singleton()->camera_create();
|
|
|
|
VS::get_singleton()->viewport_attach_camera(viewport, camera);
|
|
|
|
VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
|
|
|
|
//VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
|
|
|
|
VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
|
|
|
|
|
2017-11-10 02:34:01 +00:00
|
|
|
RID light = VS::get_singleton()->directional_light_create();
|
2017-08-28 03:03:34 +00:00
|
|
|
RID light_instance = VS::get_singleton()->instance_create2(light, scenario);
|
|
|
|
VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
|
|
|
|
|
2017-11-10 02:34:01 +00:00
|
|
|
RID light2 = VS::get_singleton()->directional_light_create();
|
2017-08-28 03:03:34 +00:00
|
|
|
VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
|
|
|
|
//VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
|
|
|
|
RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
|
|
|
|
|
|
|
|
VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
|
|
|
|
|
|
|
|
//sphere = VS::get_singleton()->mesh_create();
|
|
|
|
RID mesh_instance = VS::get_singleton()->instance_create();
|
|
|
|
VS::get_singleton()->instance_set_scenario(mesh_instance, scenario);
|
|
|
|
|
|
|
|
EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
|
|
|
|
|
|
|
|
Vector<Ref<Texture> > 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>());
|
|
|
|
continue;
|
|
|
|
}
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB aabb = mesh->get_aabb();
|
2017-08-28 03:03:34 +00:00
|
|
|
print_line("aabb: " + aabb);
|
|
|
|
Vector3 ofs = aabb.position + aabb.size * 0.5;
|
|
|
|
aabb.position -= ofs;
|
|
|
|
Transform xform;
|
|
|
|
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.25);
|
|
|
|
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.25) * xform.basis;
|
2017-11-17 02:09:00 +00:00
|
|
|
AABB rot_aabb = xform.xform(aabb);
|
2017-08-28 03:03:34 +00:00
|
|
|
print_line("rot_aabb: " + rot_aabb);
|
|
|
|
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
|
2017-09-29 01:07:27 +00:00
|
|
|
if (m == 0) {
|
|
|
|
textures.push_back(Ref<Texture>());
|
2017-08-28 03:03:34 +00:00
|
|
|
continue;
|
2017-09-29 01:07:27 +00:00
|
|
|
}
|
2017-08-28 03:03:34 +00:00
|
|
|
m = 1.0 / m;
|
|
|
|
m *= 0.5;
|
|
|
|
print_line("scale: " + rtos(m));
|
|
|
|
xform.basis.scale(Vector3(m, m, m));
|
|
|
|
xform.origin = -xform.basis.xform(ofs); //-ofs*m;
|
|
|
|
xform.origin.z -= rot_aabb.size.z * 2;
|
|
|
|
RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
|
|
|
|
VS::get_singleton()->instance_set_transform(inst, xform);
|
2018-04-22 17:36:01 +00:00
|
|
|
ep.step(TTR("Thumbnail..."), i);
|
2017-08-28 03:03:34 +00:00
|
|
|
Main::iteration();
|
|
|
|
Main::iteration();
|
|
|
|
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
|
|
|
|
ERR_CONTINUE(!img.is_valid() || img->empty());
|
|
|
|
Ref<ImageTexture> it(memnew(ImageTexture));
|
|
|
|
it->create_from_image(img);
|
|
|
|
|
|
|
|
//print_line("loaded image, size: "+rtos(m)+" dist: "+rtos(dist)+" empty?"+itos(img.empty())+" w: "+itos(it->get_width())+" h: "+itos(it->get_height()));
|
|
|
|
VS::get_singleton()->free(inst);
|
|
|
|
|
|
|
|
textures.push_back(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
VS::get_singleton()->free(mesh_instance);
|
|
|
|
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);
|
|
|
|
|
|
|
|
return textures;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-26 13:32:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->open_request(scene_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorInterface::reload_scene_from_path(const String &scene_path) {
|
|
|
|
|
|
|
|
if (EditorNode::get_singleton()->is_changing_scene()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->reload_scene(scene_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_singleton()->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)
|
|
|
|
continue;
|
|
|
|
ret.push_back(scenes[idx_scn].root->get_filename());
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptEditor *EditorInterface::get_script_editor() {
|
|
|
|
return ScriptEditor::get_singleton();
|
|
|
|
}
|
|
|
|
|
2017-12-20 20:44:16 +00:00
|
|
|
void EditorInterface::select_file(const String &p_file) {
|
|
|
|
return EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
String EditorInterface::get_selected_path() const {
|
|
|
|
return EditorNode::get_singleton()->get_filesystem_dock()->get_selected_path();
|
|
|
|
}
|
|
|
|
|
2017-08-26 13:32:15 +00:00
|
|
|
void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property) {
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->push_item(p_obj, p_for_property);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorFileSystem *EditorInterface::get_resource_file_system() {
|
|
|
|
return EditorFileSystem::get_singleton();
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorSelection *EditorInterface::get_selection() {
|
|
|
|
return EditorNode::get_singleton()->get_editor_selection();
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorSettings *EditorInterface::get_editor_settings() {
|
|
|
|
return EditorSettings::get_singleton();
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorResourcePreview *EditorInterface::get_resource_previewer() {
|
|
|
|
return EditorResourcePreview::get_singleton();
|
|
|
|
}
|
|
|
|
|
|
|
|
Control *EditorInterface::get_base_control() {
|
|
|
|
|
|
|
|
return EditorNode::get_singleton()->get_gui_base();
|
|
|
|
}
|
|
|
|
|
2018-01-30 22:11:07 +00:00
|
|
|
void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
|
|
|
|
EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
|
|
|
|
return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
|
|
|
|
}
|
|
|
|
|
2017-08-26 13:32:15 +00:00
|
|
|
Error EditorInterface::save_scene() {
|
|
|
|
if (!get_edited_scene_root())
|
|
|
|
return ERR_CANT_CREATE;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorInterface *EditorInterface::singleton = NULL;
|
|
|
|
|
|
|
|
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);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
|
|
|
|
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("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);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_editor_viewport"), &EditorInterface::get_editor_viewport);
|
2017-10-11 18:00:01 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
|
2017-12-20 20:44:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("select_file", "p_file"), &EditorInterface::select_file);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path);
|
2017-08-26 13:32:15 +00:00
|
|
|
|
2018-01-30 22:11:07 +00:00
|
|
|
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);
|
|
|
|
|
2017-08-26 13:32:15 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
|
|
|
|
ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorInterface::EditorInterface() {
|
|
|
|
singleton = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::remove_custom_type(const String &p_type) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
EditorNode::get_editor_data().remove_custom_type(p_type);
|
|
|
|
}
|
|
|
|
|
2018-02-14 04:31:38 +00:00
|
|
|
void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) {
|
|
|
|
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::remove_autoload_singleton(const String &p_name) {
|
|
|
|
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
|
2016-02-27 03:32:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
|
2016-02-28 02:10:44 +00:00
|
|
|
|
|
|
|
ERR_FAIL_NULL(p_control);
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
|
2016-02-28 02:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::remove_control_from_docks(Control *p_control) {
|
|
|
|
|
|
|
|
ERR_FAIL_NULL(p_control);
|
|
|
|
EditorNode::get_singleton()->remove_control_from_dock(p_control);
|
|
|
|
}
|
2016-02-27 03:32:00 +00:00
|
|
|
|
2016-02-28 19:58:17 +00:00
|
|
|
void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
|
|
|
|
|
|
|
|
ERR_FAIL_NULL(p_control);
|
|
|
|
EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_location) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
case CONTAINER_TOOLBAR: {
|
|
|
|
|
|
|
|
EditorNode::get_menu_hb()->add_child(p_control);
|
|
|
|
} break;
|
2016-02-27 03:32:00 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
case CONTAINER_SPATIAL_EDITOR_MENU: {
|
|
|
|
|
|
|
|
SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_SPATIAL_EDITOR_SIDE: {
|
|
|
|
|
|
|
|
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
|
2017-03-05 15:44:50 +00:00
|
|
|
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
|
|
|
|
|
|
|
|
SpatialEditor::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: {
|
|
|
|
|
2015-01-11 23:52:42 +00:00
|
|
|
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
|
2017-03-05 15:44:50 +00:00
|
|
|
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
|
2015-01-11 23:52:42 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
|
|
|
|
|
|
|
|
CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
} break;
|
2016-05-23 20:10:26 +00:00
|
|
|
case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
|
|
|
|
|
2018-05-17 06:01:47 +00:00
|
|
|
EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control);
|
2016-05-23 20:10:26 +00:00
|
|
|
|
|
|
|
} break;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-13 21:21:19 +00:00
|
|
|
void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *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);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_SPATIAL_EDITOR_SIDE: {
|
|
|
|
|
|
|
|
SpatialEditor::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);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_CANVAS_EDITOR_MENU: {
|
|
|
|
|
|
|
|
CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case CONTAINER_CANVAS_EDITOR_SIDE: {
|
|
|
|
|
|
|
|
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: {
|
|
|
|
|
2018-05-17 06:01:47 +00:00
|
|
|
EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control);
|
2018-02-13 21:21:19 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) {
|
2018-03-17 01:50:35 +00:00
|
|
|
EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud);
|
2016-08-07 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) {
|
2016-08-07 14:01:22 +00:00
|
|
|
ERR_FAIL_NULL(p_submenu);
|
2017-08-24 20:58:51 +00:00
|
|
|
PopupMenu *submenu = Object::cast_to<PopupMenu>(p_submenu);
|
2016-08-07 14:01:22 +00:00
|
|
|
ERR_FAIL_NULL(submenu);
|
2018-03-17 01:50:35 +00:00
|
|
|
EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
|
2016-08-07 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::remove_tool_menu_item(const String &p_name) {
|
2018-03-17 01:50:35 +00:00
|
|
|
EditorNode::get_singleton()->remove_tool_menu_item(p_name);
|
2016-08-07 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2017-06-08 17:57:35 +00:00
|
|
|
void EditorPlugin::set_input_event_forwarding_always_enabled() {
|
|
|
|
input_event_forwarding_always_enabled = true;
|
|
|
|
EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
|
|
|
|
always_input_forwarding_list->add_plugin(this);
|
|
|
|
}
|
|
|
|
|
2017-10-29 19:32:09 +00:00
|
|
|
void EditorPlugin::set_force_draw_over_forwarding_enabled() {
|
|
|
|
force_draw_over_forwarding_enabled = true;
|
|
|
|
EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
|
|
|
|
always_draw_over_forwarding_list->add_plugin(this);
|
|
|
|
}
|
|
|
|
|
2017-07-06 07:18:20 +00:00
|
|
|
void EditorPlugin::notify_scene_changed(const Node *scn_root) {
|
|
|
|
if (scn_root == NULL) return;
|
|
|
|
emit_signal("scene_changed", scn_root);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
|
|
|
|
|
|
|
|
if (screen_name == last_main_screen_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
emit_signal("main_screen_changed", screen_name);
|
|
|
|
last_main_screen_name = screen_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
|
|
|
|
emit_signal("scene_closed", scene_filepath);
|
|
|
|
}
|
|
|
|
|
2018-01-12 21:43:29 +00:00
|
|
|
void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
|
|
|
|
emit_signal("resource_saved", p_resource);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
|
2014-02-10 01:10:30 +00:00
|
|
|
//??
|
2016-02-28 02:10:44 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
return get_script_instance()->call("create_spatial_gizmo", p_spatial);
|
2016-02-28 02:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Ref<SpatialEditorGizmo>();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 20:33:25 +00:00
|
|
|
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-08 19:28:12 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) {
|
2017-10-15 20:33:25 +00:00
|
|
|
return get_script_instance()->call("forward_canvas_gui_input", p_event);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-10 19:44:03 +00:00
|
|
|
|
2017-10-29 19:32:09 +00:00
|
|
|
void EditorPlugin::forward_draw_over_viewport(Control *p_overlay) {
|
2016-09-10 19:44:03 +00:00
|
|
|
|
2017-10-29 19:32:09 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_viewport")) {
|
|
|
|
get_script_instance()->call("forward_draw_over_viewport", p_overlay);
|
2016-09-10 19:44:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-29 19:32:09 +00:00
|
|
|
void EditorPlugin::forward_force_draw_over_viewport(Control *p_overlay) {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("forward_force_draw_over_viewport")) {
|
|
|
|
get_script_instance()->call("forward_force_draw_over_viewport", 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()) {
|
|
|
|
int count = 0;
|
|
|
|
for (int i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
|
|
|
|
SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
|
|
|
|
if (vp->is_visible()) {
|
|
|
|
vp->update_surface();
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
} else {
|
|
|
|
// This will update the normal viewport itself as well
|
|
|
|
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
|
|
|
|
return 1;
|
|
|
|
}
|
2016-09-10 19:44:03 +00:00
|
|
|
}
|
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-08 19:28:12 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
String EditorPlugin::get_name() const {
|
|
|
|
|
2017-08-11 11:35:38 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) {
|
|
|
|
return get_script_instance()->call("get_plugin_name");
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return String();
|
|
|
|
}
|
2017-12-06 22:27:45 +00:00
|
|
|
const Ref<Texture> 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>();
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
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) {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("make_visible")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
get_script_instance()->call("make_visible", p_visible);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::edit(Object *p_object) {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("edit")) {
|
2017-11-17 15:48:33 +00:00
|
|
|
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);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorPlugin::handles(Object *p_object) const {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("handles")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
return get_script_instance()->call("handles", p_object);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
return Dictionary();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::set_state(const Dictionary &p_state) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("set_state")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
get_script_instance()->call("set_state", p_state);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::clear() {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("clear")) {
|
|
|
|
get_script_instance()->call("clear");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 17:49:58 +00:00
|
|
|
// 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
|
2014-02-10 01:10:30 +00:00
|
|
|
void EditorPlugin::apply_changes() {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("apply_changes")) {
|
|
|
|
get_script_instance()->call("apply_changes");
|
|
|
|
}
|
2016-08-15 17:49:58 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
|
2017-01-11 03:52:51 +00:00
|
|
|
PoolStringArray arr = get_script_instance()->call("get_breakpoints");
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < arr.size(); i++)
|
2014-02-10 01:10:30 +00:00
|
|
|
p_breakpoints->push_back(arr[i]);
|
|
|
|
}
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::restore_global_state() {}
|
|
|
|
void EditorPlugin::save_global_state() {}
|
|
|
|
|
2017-04-08 22:37:31 +00:00
|
|
|
void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
|
|
|
|
ResourceFormatImporter::get_singleton()->add_importer(p_importer);
|
2017-12-09 16:59:01 +00:00
|
|
|
EditorFileSystem::get_singleton()->call_deferred("scan");
|
2017-04-08 22:37:31 +00:00
|
|
|
}
|
|
|
|
|
2017-06-11 09:18:22 +00:00
|
|
|
void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
|
|
|
|
ResourceFormatImporter::get_singleton()->remove_importer(p_importer);
|
2017-12-09 16:59:01 +00:00
|
|
|
EditorFileSystem::get_singleton()->call_deferred("scan");
|
2017-06-11 09:18:22 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 22:38:38 +00:00
|
|
|
void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
|
|
|
|
EditorExport::get_singleton()->add_export_plugin(p_exporter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
|
|
|
|
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
|
|
|
|
}
|
|
|
|
|
2018-05-17 21:02:16 +00:00
|
|
|
void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
|
|
|
|
EditorInspector::add_inspector_plugin(p_plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
|
|
|
|
EditorInspector::remove_inspector_plugin(p_plugin);
|
|
|
|
}
|
|
|
|
|
2017-12-07 18:44:20 +00:00
|
|
|
void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
|
|
|
|
ResourceImporterScene::get_singleton()->add_importer(p_importer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
|
|
|
|
ResourceImporterScene::get_singleton()->remove_importer(p_importer);
|
|
|
|
}
|
|
|
|
|
2015-06-22 03:03:19 +00:00
|
|
|
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
|
|
|
|
|
2016-08-15 17:49:58 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) {
|
|
|
|
get_script_instance()->call("set_window_layout", p_layout);
|
|
|
|
}
|
2015-06-22 03:03:19 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
|
2015-06-22 03:03:19 +00:00
|
|
|
|
2016-08-15 17:49:58 +00:00
|
|
|
if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) {
|
|
|
|
get_script_instance()->call("get_window_layout", p_layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-08 15:55:22 +00:00
|
|
|
bool EditorPlugin::build() {
|
|
|
|
|
|
|
|
if (get_script_instance() && get_script_instance()->has_method("build")) {
|
|
|
|
return get_script_instance()->call("build");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-15 17:49:58 +00:00
|
|
|
void EditorPlugin::queue_save_layout() const {
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->save_layout();
|
2015-06-22 03:03:19 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
|
2016-09-17 14:59:12 +00:00
|
|
|
|
|
|
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorPlugin::hide_bottom_panel() {
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->hide_bottom_panel();
|
|
|
|
}
|
|
|
|
|
2017-08-26 13:32:15 +00:00
|
|
|
EditorInterface *EditorPlugin::get_editor_interface() {
|
|
|
|
return EditorInterface::get_singleton();
|
2016-09-10 20:34:27 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void EditorPlugin::_bind_methods() {
|
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
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);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
|
2018-02-13 21:21:19 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
|
2018-03-17 01:50:35 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"), &EditorPlugin::add_tool_menu_item, DEFVAL(Variant()));
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
|
2018-03-17 01:50:35 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
|
2017-02-13 11:47:24 +00:00
|
|
|
|
2018-02-14 04:31:38 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_autoload_singleton", "name", "path"), &EditorPlugin::add_autoload_singleton);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_autoload_singleton", "name"), &EditorPlugin::remove_autoload_singleton);
|
|
|
|
|
2017-10-29 19:32:09 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);
|
2017-02-13 11:47:24 +00:00
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
|
|
|
|
|
2017-08-09 11:19:41 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::_get_undo_redo);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
|
2017-08-09 11:19:41 +00:00
|
|
|
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);
|
2017-12-07 18:44:20 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin);
|
2018-05-17 21:02:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
|
|
|
|
ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
|
2017-06-08 17:57:35 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
|
2017-10-29 19:32:09 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
|
2017-08-26 13:32:15 +00:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
|
2017-07-06 07:18:20 +00:00
|
|
|
|
2018-01-04 21:07:32 +00:00
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
2017-10-29 19:32:09 +00:00
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
2017-05-20 15:38:03 +00:00
|
|
|
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")));
|
2017-08-29 05:15:46 +00:00
|
|
|
MethodInfo gizmo = MethodInfo(Variant::OBJECT, "create_spatial_gizmo", PropertyInfo(Variant::OBJECT, "for_spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial"));
|
2017-03-05 15:44:50 +00:00
|
|
|
gizmo.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE;
|
|
|
|
gizmo.return_val.hint_string = "EditorSpatialGizmo";
|
|
|
|
ClassDB::add_virtual_method(get_class_static(), gizmo);
|
2017-08-11 11:35:38 +00:00
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
|
2017-12-06 22:27:45 +00:00
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "get_plugin_icon"));
|
2017-03-05 15:44:50 +00:00
|
|
|
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")));
|
2018-01-08 15:55:22 +00:00
|
|
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build"));
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2017-08-29 05:15:46 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
|
|
|
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
|
|
|
|
ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
|
2018-01-12 21:43:29 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
|
2017-07-06 07:18:20 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
|
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
|
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE);
|
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
|
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
|
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE);
|
2017-10-21 18:58:02 +00:00
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM);
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(CONTAINER_PROPERTY_EDITOR_BOTTOM);
|
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UR);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BR);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UL);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BL);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
|
|
|
|
BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorPlugin::EditorPlugin() {
|
|
|
|
undo_redo = NULL;
|
2017-06-08 17:57:35 +00:00
|
|
|
input_event_forwarding_always_enabled = false;
|
2017-10-29 19:32:09 +00:00
|
|
|
force_draw_over_forwarding_enabled = false;
|
2017-07-06 07:18:20 +00:00
|
|
|
last_main_screen_name = "";
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorPlugin::~EditorPlugin() {
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
int EditorPlugins::creation_func_count = 0;
|