summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp125
1 files changed, 109 insertions, 16 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index a32ade3b71..0252358a27 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -269,6 +269,7 @@ void EditorNode::_notification(int p_what) {
Engine::get_singleton()->set_editor_hint(true);
+ get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage
get_tree()->get_root()->set_disable_3d(true);
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
@@ -289,6 +290,7 @@ void EditorNode::_notification(int p_what) {
_editor_select(EDITOR_3D);
_update_debug_options();
+ _load_docks();
}
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
@@ -336,7 +338,13 @@ void EditorNode::_notification(int p_what) {
//_update_icons
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
- main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons"));
+ Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon();
+
+ if (icon.is_valid()) {
+ main_editor_buttons[i]->set_icon(icon);
+ } else if (singleton->gui_base->has_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")) {
+ main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons"));
+ }
}
play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
@@ -1392,6 +1400,16 @@ void EditorNode::_property_editor_back() {
_edit_current();
}
+void EditorNode::_menu_collapseall() {
+
+ property_editor->collapse_all_folding();
+}
+
+void EditorNode::_menu_expandall() {
+
+ property_editor->expand_all_folding();
+}
+
void EditorNode::_save_default_environment() {
Ref<Environment> fallback = get_tree()->get_root()->get_world()->get_fallback_environment();
@@ -1486,7 +1504,7 @@ void EditorNode::_edit_current() {
if (FileAccess::exists(base_path + ".import")) {
editable_warning = TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow.");
} else {
- if (!get_edited_scene() || get_edited_scene()->get_filename() != base_path) {
+ if ((!get_edited_scene() || get_edited_scene()->get_filename() != base_path) && ResourceLoader::get_resource_type(base_path) == "PackedScene") {
editable_warning = TTR("This resource belongs to a scene that was instanced or inherited.\nChanges to it will not be kept when saving the current scene.");
}
}
@@ -1596,6 +1614,9 @@ void EditorNode::_edit_current() {
PopupMenu *p = object_menu->get_popup();
p->clear();
+ p->add_shortcut(ED_SHORTCUT("property_editor/expand_all", TTR("Expand all properties")), EXPAND_ALL);
+ p->add_shortcut(ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse all properties")), COLLAPSE_ALL);
+ p->add_separator();
p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Params")), OBJECT_COPY_PARAMS);
p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Params")), OBJECT_PASTE_PARAMS);
p->add_separator();
@@ -1662,7 +1683,6 @@ void EditorNode::_resource_selected(const RES &p_res, const String &p_property)
void EditorNode::_run(bool p_current, const String &p_custom) {
if (editor_run.get_status() == EditorRun::STATUS_PLAY) {
-
play_button->set_pressed(!_playing_edited);
play_scene_button->set_pressed(_playing_edited);
return;
@@ -1794,6 +1814,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
play_button->set_pressed(true);
play_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
}
+ stop_button->set_disabled(false);
_playing_edited = p_current;
}
@@ -2226,6 +2247,14 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_set_editing_top_editors(current);
} break;
+ case COLLAPSE_ALL: {
+ _menu_collapseall();
+
+ } break;
+ case EXPAND_ALL: {
+ _menu_expandall();
+
+ } break;
case RUN_PLAY: {
_menu_option_confirm(RUN_STOP, true);
_run(false);
@@ -2257,6 +2286,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
+ stop_button->set_disabled(true);
+
if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) {
for (int i = 0; i < bottom_panel_items.size(); i++) {
if (bottom_panel_items[i].control == log) {
@@ -2648,7 +2679,14 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
tb->set_toggle_mode(true);
tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
tb->set_text(p_editor->get_name());
- tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
+ Ref<Texture> icon = p_editor->get_icon();
+
+ if (icon.is_valid()) {
+ tb->set_icon(icon);
+ } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) {
+ tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
+ }
+
tb->set_name(p_editor->get_name());
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_vb->add_child(tb);
@@ -3110,6 +3148,10 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
push_item(new_scene);
+ if (!restoring_scenes) {
+ save_layout();
+ }
+
return OK;
}
@@ -3322,6 +3364,8 @@ void EditorNode::register_editor_types() {
ClassDB::register_virtual_class<EditorInterface>();
ClassDB::register_class<EditorExportPlugin>();
ClassDB::register_class<EditorResourceConversionPlugin>();
+ ClassDB::register_class<EditorSceneImporter>();
+
// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
ClassDB::register_class<EditorScenePostImport>();
@@ -3630,6 +3674,7 @@ void EditorNode::_save_docks() {
config.instance();
_save_docks_to_config(config, "docks");
+ _save_open_scenes_to_config(config, "EditorNode");
editor_data.get_plugin_window_layout(config);
config->save(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg"));
@@ -3680,6 +3725,18 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p
}
}
+void EditorNode::_save_open_scenes_to_config(Ref<ConfigFile> p_layout, const String &p_section) {
+ Array scenes;
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ String path = editor_data.get_scene_path(i);
+ if (path == "") {
+ continue;
+ }
+ scenes.push_back(path);
+ }
+ p_layout->set_value(p_section, "open_scenes", scenes);
+}
+
void EditorNode::save_layout() {
dock_drag_timer->start();
@@ -3704,6 +3761,7 @@ void EditorNode::_load_docks() {
}
_load_docks_from_config(config, "docks");
+ _load_open_scenes_from_config(config, "EditorNode");
editor_data.set_plugin_window_layout(config);
}
@@ -3850,6 +3908,25 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
}
}
+void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
+ if (!bool(EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false))) {
+ return;
+ }
+
+ if (!p_layout->has_section(p_section) || !p_layout->has_section_key(p_section, "open_scenes")) {
+ return;
+ }
+
+ restoring_scenes = true;
+
+ Array scenes = p_layout->get_value(p_section, "open_scenes");
+ for (int i = 0; i < scenes.size(); i++) {
+ load_scene(scenes[i]);
+ }
+
+ restoring_scenes = false;
+}
+
void EditorNode::_update_layouts_menu() {
editor_layouts->clear();
@@ -3948,6 +4025,8 @@ void EditorNode::_scene_tab_closed(int p_tab) {
} else {
_discard_changes();
}
+
+ save_layout();
_update_scene_tabs();
}
@@ -4645,6 +4724,7 @@ EditorNode::EditorNode() {
changing_scene = false;
_initializing_addons = false;
docks_visible = true;
+ restoring_scenes = false;
scene_distraction = false;
script_distraction = false;
@@ -4957,6 +5037,7 @@ EditorNode::EditorNode() {
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
scene_root = memnew(Viewport);
+ scene_root->set_usage(Viewport::USAGE_2D);
scene_root->set_disable_3d(true);
VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
@@ -5204,6 +5285,7 @@ EditorNode::EditorNode() {
stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons"));
stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP));
stop_button->set_tooltip(TTR("Stop the scene."));
+ stop_button->set_disabled(true);
stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_F8));
run_native = memnew(EditorRunNative);
@@ -5262,13 +5344,14 @@ EditorNode::EditorNode() {
}
scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data));
- scene_tree_dock->set_name(TTR("Scene"));
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock);
+ dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(scene_tree_dock->get_index(), TTR("Scene"));
dock_slot[DOCK_SLOT_LEFT_BR]->hide();
VBoxContainer *prop_editor_base = memnew(VBoxContainer);
- prop_editor_base->set_name(TTR("Inspector")); // Properties?
+ prop_editor_base->set_name("Inspector");
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(prop_editor_base);
+ dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(prop_editor_base->get_index(), TTR("Inspector"));
HBoxContainer *prop_editor_hb = memnew(HBoxContainer);
@@ -5376,11 +5459,11 @@ EditorNode::EditorNode() {
property_editor = memnew(PropertyEditor);
property_editor->set_autoclear(true);
property_editor->set_show_categories(true);
- property_editor->set_use_folding(true);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
property_editor->set_use_doc_hints(true);
property_editor->set_hide_script(false);
property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true)));
+ property_editor->set_use_folding(!bool(EDITOR_DEF("interface/editor/disable_inspector_folding", false)));
property_editor->hide_top_label();
property_editor->register_text_enter(search_box);
@@ -5391,28 +5474,31 @@ EditorNode::EditorNode() {
import_dock = memnew(ImportDock);
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(import_dock);
- import_dock->set_name(TTR("Import"));
+ dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(import_dock->get_index(), TTR("Import"));
bool use_single_dock_column = (OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200);
node_dock = memnew(NodeDock);
if (use_single_dock_column) {
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock);
+ dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(node_dock->get_index(), TTR("Node"));
} else {
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock);
+ dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(node_dock->get_index(), TTR("Node"));
}
filesystem_dock = memnew(FileSystemDock(this));
- filesystem_dock->set_name(TTR("FileSystem"));
filesystem_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
if (use_single_dock_column) {
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(filesystem_dock);
+ dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(filesystem_dock->get_index(), TTR("FileSystem"));
left_r_vsplit->hide();
dock_slot[DOCK_SLOT_LEFT_UR]->hide();
dock_slot[DOCK_SLOT_LEFT_BR]->hide();
} else {
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock);
+ dock_slot[DOCK_SLOT_LEFT_UR]->set_tab_title(filesystem_dock->get_index(), TTR("FileSystem"));
}
filesystem_dock->connect("open", this, "open_request");
filesystem_dock->connect("instance", this, "_instance_request");
@@ -5421,9 +5507,9 @@ EditorNode::EditorNode() {
overridden_default_layout = -1;
default_layout.instance();
- default_layout->set_value(docks_section, "dock_3", TTR("FileSystem"));
- default_layout->set_value(docks_section, "dock_5", TTR("Scene") + "," + TTR("Import"));
- default_layout->set_value(docks_section, "dock_6", TTR("Inspector") + "," + TTR("Node"));
+ default_layout->set_value(docks_section, "dock_3", "FileSystem");
+ default_layout->set_value(docks_section, "dock_5", "Scene,Import");
+ default_layout->set_value(docks_section, "dock_6", "Inspector,Node");
for (int i = 0; i < DOCK_SLOT_MAX / 2; i++)
default_layout->set_value(docks_section, "dock_hsplit_" + itos(i + 1), 0);
@@ -5624,6 +5710,7 @@ EditorNode::EditorNode() {
editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
+ editor_plugins_force_over = memnew(EditorPluginList);
editor_plugins_force_input_forwarding = memnew(EditorPluginList);
_edit_current();
@@ -5716,8 +5803,6 @@ EditorNode::EditorNode() {
_initializing_addons = false;
}
- _load_docks();
-
FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify);
waiting_for_first_scan = true;
@@ -5748,6 +5833,7 @@ EditorNode::~EditorNode() {
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
+ memdelete(editor_plugins_force_over);
memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
memdelete(progress_hb);
@@ -5801,10 +5887,17 @@ bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
return discard;
}
-void EditorPluginList::forward_draw_over_canvas(Control *p_canvas) {
+void EditorPluginList::forward_draw_over_viewport(Control *p_overlay) {
+
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->forward_draw_over_viewport(p_overlay);
+ }
+}
+
+void EditorPluginList::forward_force_draw_over_viewport(Control *p_overlay) {
for (int i = 0; i < plugins_list.size(); i++) {
- plugins_list[i]->forward_draw_over_canvas(p_canvas);
+ plugins_list[i]->forward_force_draw_over_viewport(p_overlay);
}
}