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.cpp749
1 files changed, 480 insertions, 269 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6b23a02275..56b62cdf6e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -30,6 +30,7 @@
#include "editor_node.h"
#include "animation_editor.h"
+#include "authors.h"
#include "bind/core_bind.h"
#include "class_db.h"
#include "core/io/resource_loader.h"
@@ -72,10 +73,10 @@
#include "plugins/collision_polygon_2d_editor_plugin.h"
#include "plugins/collision_polygon_editor_plugin.h"
#include "plugins/collision_shape_2d_editor_plugin.h"
-#include "plugins/color_ramp_editor_plugin.h"
#include "plugins/cube_grid_theme_editor_plugin.h"
#include "plugins/curve_editor_plugin.h"
#include "plugins/gi_probe_editor_plugin.h"
+#include "plugins/gradient_editor_plugin.h"
#include "plugins/gradient_texture_editor_plugin.h"
#include "plugins/item_list_editor_plugin.h"
#include "plugins/light_occluder_2d_editor_plugin.h"
@@ -173,12 +174,13 @@ void EditorNode::_update_title() {
OS::get_singleton()->set_window_title(title);
}
-void EditorNode::_unhandled_input(const InputEvent &p_event) {
+void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) {
if (Node::get_viewport()->get_modal_stack_top())
return; //ignore because of modal window
- if (p_event.type == InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
+ Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && !gui_base->get_viewport()->gui_has_modal_stack()) {
if (ED_IS_SHORTCUT("editor/next_tab", p_event)) {
int next_tab = editor_data.get_edited_scene() + 1;
@@ -194,28 +196,20 @@ void EditorNode::_unhandled_input(const InputEvent &p_event) {
filesystem_dock->focus_on_filter();
}
- switch (p_event.key.scancode) {
-
- /*case KEY_F1:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_SCRIPT);
- break;*/
- case KEY_F1:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_2D);
- break;
- case KEY_F2:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_3D);
- break;
- case KEY_F3:
- if (!p_event.key.mod.shift && !p_event.key.mod.command)
- _editor_select(EDITOR_SCRIPT);
- break;
- /* case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
- case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break;
- //case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break;
- case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/
+ if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
+ _editor_select(EDITOR_2D);
+ } else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
+ _editor_select(EDITOR_3D);
+ } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
+ _editor_select(EDITOR_SCRIPT);
+ } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
+ emit_signal("request_help_search", "");
+ } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event)) {
+ _editor_select(EDITOR_ASSETLIB);
+ } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
+ _editor_select_next();
+ } else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) {
+ _editor_select_prev();
}
}
}
@@ -276,28 +270,9 @@ void EditorNode::_notification(int p_what) {
update_menu->set_icon(gui_base->get_icon("Progress" + itos(circle_step + 1), "EditorIcons"));
}
}
-
editor_selection->update();
- {
- uint32_t p32 = 0; //AudioServer::get_singleton()->read_output_peak()>>8;
-
- float peak = p32 == 0 ? -80 : Math::linear2db(p32 / 65535.0);
-
- if (peak < -80)
- peak = -80;
- float vu = audio_vu->get_value();
-
- if (peak > vu) {
- audio_vu->set_value(peak);
- } else {
- float new_vu = vu - get_process_delta_time() * 70.0;
- if (new_vu < -80)
- new_vu = -80;
- if (new_vu != -80 && vu != -80)
- audio_vu->set_value(new_vu);
- }
- }
+ scene_root->set_size_override(true, Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height")));
ResourceImporterTexture::get_singleton()->update_imports();
}
@@ -356,11 +331,25 @@ void EditorNode::_notification(int p_what) {
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
_menu_option_confirm(FILE_QUIT, false);
- };
+ }
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true)));
+ Ref<Theme> theme = create_editor_theme();
+ theme_base->set_theme(theme);
+ gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
+ play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
+ scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
+ scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
+ if (bool(EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true))) {
+ scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
+ } else {
+ scene_tabs->set_min_width(0);
+ }
+ _update_scene_tabs();
}
}
@@ -454,6 +443,30 @@ void EditorNode::_node_renamed() {
property_editor->update_tree();
}
+void EditorNode::_editor_select_next() {
+
+ int editor = _get_current_main_editor();
+
+ if (editor == editor_table.size() - 1) {
+ editor = 0;
+ } else {
+ editor++;
+ }
+ _editor_select(editor);
+}
+
+void EditorNode::_editor_select_prev() {
+
+ int editor = _get_current_main_editor();
+
+ if (editor == 0) {
+ editor = editor_table.size() - 1;
+ } else {
+ editor--;
+ }
+ _editor_select(editor);
+}
+
Error EditorNode::load_resource(const String &p_scene) {
RES res = ResourceLoader::load(p_scene);
@@ -820,56 +833,54 @@ void EditorNode::_save_scene_with_preview(String p_file) {
}
save.step(TTR("Creating Thumbnail"), 1);
//current view?
- int screen = -1;
- for (int i = 0; i < editor_table.size(); i++) {
- if (editor_plugin_screen == editor_table[i]) {
- screen = i;
- break;
- }
+
+ Ref<Image> img;
+ if (is2d) {
+ img = scene_root->get_texture()->get_data();
+ } else {
+ img = SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
}
- _editor_select(is2d ? EDITOR_2D : EDITOR_3D);
+ if (img.is_valid()) {
+ save.step(TTR("Creating Thumbnail"), 2);
+ save.step(TTR("Creating Thumbnail"), 3);
- save.step(TTR("Creating Thumbnail"), 2);
- save.step(TTR("Creating Thumbnail"), 3);
-#if 0
- Image img = VS::get_singleton()->viewport_texture(scree_capture(viewport);
- int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
- preview_size*=EDSCALE;
- int width,height;
- if (img.get_width() > preview_size && img.get_width() >= img.get_height()) {
+ int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
+ preview_size *= EDSCALE;
+ int width, height;
+ if (img->get_width() > preview_size && img->get_width() >= img->get_height()) {
- width=preview_size;
- height = img.get_height() * preview_size / img.get_width();
- } else if (img.get_height() > preview_size && img.get_height() >= img.get_width()) {
+ width = preview_size;
+ height = img->get_height() * preview_size / img->get_width();
+ } else if (img->get_height() > preview_size && img->get_height() >= img->get_width()) {
- height=preview_size;
- width = img.get_width() * preview_size / img.get_height();
- } else {
+ height = preview_size;
+ width = img->get_width() * preview_size / img->get_height();
+ } else {
- width=img.get_width();
- height=img.get_height();
- }
+ width = img->get_width();
+ height = img->get_height();
+ }
- img.convert(Image::FORMAT_RGB8);
- img.resize(width,height);
+ img->convert(Image::FORMAT_RGB8);
+ img->resize(width, height);
+ img->flip_y();
- String pfile = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/last_scene_preview.png");
- img.save_png(pfile);
- Vector<uint8_t> imgdata = FileAccess::get_file_as_array(pfile);
+ //save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5
+ String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
+ String cache_base = GlobalConfig::get_singleton()->globalize_path(p_file).md5_text();
+ cache_base = temp_path.plus_file("resthumb-" + cache_base);
- //print_line("img data is "+itos(imgdata.size()));
+ //does not have it, try to load a cached thumbnail
- if (editor_data.get_edited_scene_import_metadata().is_null())
- editor_data.set_edited_scene_import_metadata(Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) ) );
- editor_data.get_edited_scene_import_metadata()->set_option("thumbnail",imgdata);
-#endif
- //tamanio tel thumbnail
- if (screen != -1) {
- _editor_select(screen);
+ String file = cache_base + ".png";
+
+ img->save_png(file);
}
+
save.step(TTR("Saving Scene"), 4);
_save_scene(p_file);
+ EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
}
void EditorNode::_save_scene(String p_file, int idx) {
@@ -887,6 +898,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
editor_data.apply_changes_in_editors();
+ _save_default_environment();
_set_scene_metadata(p_file, idx);
@@ -948,7 +960,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
_dialog_display_file_error(p_file, err);
}
-};
+}
void EditorNode::_import_action(const String &p_action) {
#if 0
@@ -1081,6 +1093,7 @@ void EditorNode::_dialog_action(String p_file) {
GlobalConfig::get_singleton()->set("application/main_scene", p_file);
GlobalConfig::get_singleton()->save();
//would be nice to show the project manager opened with the highlighted field..
+ _run(false, ""); // automatically run the project
} break;
case FILE_SAVE_OPTIMIZED: {
@@ -1111,6 +1124,7 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
+ _save_default_environment();
_save_scene_with_preview(p_file);
}
@@ -1120,6 +1134,7 @@ void EditorNode::_dialog_action(String p_file) {
if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
+ _save_default_environment();
_save_scene_with_preview(p_file);
_call_build();
_run(true);
@@ -1373,6 +1388,17 @@ void EditorNode::_property_editor_back() {
_edit_current();
}
+void EditorNode::_save_default_environment() {
+
+ Ref<Environment> fallback = get_tree()->get_root()->get_world()->get_fallback_environment();
+
+ if (fallback.is_valid() && fallback->get_path().is_resource_file()) {
+ Map<RES, bool> processed;
+ _find_and_save_edited_subresources(fallback.ptr(), processed, 0);
+ save_resource_in_path(fallback, fallback->get_path());
+ }
+}
+
void EditorNode::_imported(Node *p_node) {
/*
@@ -1451,11 +1477,16 @@ void EditorNode::_edit_current() {
Node *current_node = current_obj->cast_to<Node>();
ERR_FAIL_COND(!current_node);
- ERR_FAIL_COND(!current_node->is_inside_tree());
+ // ERR_FAIL_COND(!current_node->is_inside_tree());
property_editor->edit(current_node);
- node_dock->set_node(current_node);
- scene_tree_dock->set_selected(current_node);
+ if (current_node->is_inside_tree()) {
+ node_dock->set_node(current_node);
+ scene_tree_dock->set_selected(current_node);
+ } else {
+ node_dock->set_node(NULL);
+ scene_tree_dock->set_selected(NULL);
+ }
object_menu->get_popup()->clear();
//top_pallete->set_current_tab(0);
@@ -1651,7 +1682,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
current_option = -1;
//accept->get_cancel()->hide();
- pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in later in \"Project Settings\" under the 'application' category."));
+ pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
pick_main_scene->popup_centered_minsize();
return;
}
@@ -1949,17 +1980,20 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
} // else: ignore new scenes
}
+
+ _save_default_environment();
} break;
case FILE_SAVE_BEFORE_RUN: {
if (!p_confirmed) {
- accept->get_ok()->set_text(TTR("Yes"));
- accept->set_text(TTR("This scene has never been saved. Save before running?"));
- accept->popup_centered_minsize();
+ confirmation->get_cancel()->set_text(TTR("No"));
+ confirmation->get_ok()->set_text(TTR("Yes"));
+ confirmation->set_text(TTR("This scene has never been saved. Save before running?"));
+ confirmation->popup_centered_minsize();
break;
}
_menu_option(FILE_SAVE_AS_SCENE);
- _menu_option_confirm(FILE_SAVE_AND_RUN, true);
+ _menu_option_confirm(FILE_SAVE_AND_RUN, false);
} break;
case FILE_SAVE_OPTIMIZED: {
@@ -2382,6 +2416,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_PLAY_SCENE: {
+
+ _save_default_environment();
_menu_option_confirm(RUN_STOP, true);
_call_build();
_run(true);
@@ -2434,28 +2470,28 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case RUN_FILE_SERVER: {
//file_server
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_FILE_SERVER));
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER));
if (ischecked) {
file_server->stop();
run_native->set_deploy_dumb(false);
- //debug_button->set_icon(gui_base->get_icon("FileServer","EditorIcons"));
- //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),"Enable File Server");
+ //debug_menu->set_icon(gui_base->get_icon("FileServer","EditorIcons"));
+ //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Enable File Server");
} else {
file_server->start();
run_native->set_deploy_dumb(true);
- //debug_button->set_icon(gui_base->get_icon("FileServerActive","EditorIcons"));
- //debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server");
+ //debug_menu->set_icon(gui_base->get_icon("FileServerActive","EditorIcons"));
+ //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server");
}
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_FILE_SERVER), !ischecked);
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked);
} break;
case RUN_LIVE_DEBUG: {
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG));
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG));
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked);
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked);
ScriptEditor::get_singleton()->get_debugger()->set_live_debugging(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked);
@@ -2463,23 +2499,23 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
/*case RUN_DEPLOY_DUMB_CLIENTS: {
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),!ischecked);
+ bool ischecked = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS));
+ debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),!ischecked);
run_native->set_deploy_dumb(!ischecked);
} break;*/
case RUN_DEPLOY_REMOTE_DEBUG: {
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked);
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked);
run_native->set_deploy_debug_remote(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked);
} break;
case RUN_DEBUG_COLLISONS: {
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS));
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS), !ischecked);
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS));
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS), !ischecked);
run_native->set_debug_collisions(!ischecked);
editor_run.set_debug_collisions(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked);
@@ -2487,8 +2523,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_DEBUG_NAVIGATION: {
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION));
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked);
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION));
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked);
run_native->set_debug_navigation(!ischecked);
editor_run.set_debug_navigation(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked);
@@ -2496,8 +2532,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_RELOAD_SCRIPTS: {
- bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS));
- debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked);
+ bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS));
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked);
ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked);
@@ -2559,8 +2595,25 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
file->popup_centered_ratio();
} break;
- case SETTINGS_ABOUT: {
-
+ case HELP_CLASSES: {
+ emit_signal("request_help_index", "");
+ } break;
+ case HELP_SEARCH: {
+ emit_signal("request_help_search", "");
+ } break;
+ case HELP_DOCS: {
+ OS::get_singleton()->shell_open("http://docs.godotengine.org/");
+ } break;
+ case HELP_QA: {
+ OS::get_singleton()->shell_open("https://godotengine.org/qa/");
+ } break;
+ case HELP_ISSUES: {
+ OS::get_singleton()->shell_open("https://github.com/godotengine/godot/issues");
+ } break;
+ case HELP_COMMUNITY: {
+ OS::get_singleton()->shell_open("https://godotengine.org/community");
+ } break;
+ case HELP_ABOUT: {
about->popup_centered_minsize(Size2(500, 130) * EDSCALE);
} break;
case SOURCES_REIMPORT: {
@@ -2689,6 +2742,14 @@ void EditorNode::_editor_select(int p_which) {
editor_plugin_screen = new_editor;
editor_plugin_screen->make_visible(true);
editor_plugin_screen->selected_notify();
+
+ if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) {
+ if (p_which == EDITOR_SCRIPT) {
+ set_distraction_free_mode(script_distraction);
+ } else {
+ set_distraction_free_mode(scene_distraction);
+ }
+ }
}
void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
@@ -2698,7 +2759,9 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
ToolButton *tb = memnew(ToolButton);
tb->set_toggle_mode(true);
tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
- tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons"));
+ tb->set_text(p_editor->get_name());
+ tb->set_icon(p_editor->get_base_control()->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);
singleton->editor_table.push_back(p_editor);
@@ -3558,7 +3621,7 @@ bool EditorNode::is_scene_in_use(const String &p_path) {
void EditorNode::register_editor_types() {
ClassDB::register_class<EditorPlugin>();
- // ClassDB::register_class<EditorImportPlugin>();
+ ClassDB::register_class<EditorImportPlugin>();
// ClassDB::register_class<EditorExportPlugin>();
// ClassDB::register_class<EditorScenePostImport>();
ClassDB::register_class<EditorScript>();
@@ -3678,11 +3741,13 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) {
warning->popup_centered_minsize();
}
-void EditorNode::_dock_select_input(const InputEvent &p_input) {
+void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
+
+ Ref<InputEventMouse> me = p_input;
- if (p_input.type == InputEvent::MOUSE_BUTTON || p_input.type == InputEvent::MOUSE_MOTION) {
+ if (me.is_valid()) {
- Vector2 point(p_input.mouse_motion.x, p_input.mouse_motion.y);
+ Vector2 point = me->get_position();
int nrect = -1;
for (int i = 0; i < DOCK_SLOT_MAX; i++) {
@@ -3700,7 +3765,9 @@ void EditorNode::_dock_select_input(const InputEvent &p_input) {
if (nrect == -1)
return;
- if (p_input.type == InputEvent::MOUSE_BUTTON && p_input.mouse_button.button_index == 1 && p_input.mouse_button.pressed && dock_popup_selected != nrect) {
+ Ref<InputEventMouseButton> mb = me;
+
+ if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed() && dock_popup_selected != nrect) {
Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
if (dock) {
dock_slot[dock_popup_selected]->remove_child(dock);
@@ -3790,7 +3857,7 @@ void EditorNode::_dock_select_draw() {
unusable.a = 0.1;
Rect2 unr(s.x * 2, 0, s.x * 2, s.y * 2);
- unr.pos += Vector2(2, 5);
+ unr.position += Vector2(2, 5);
unr.size -= Vector2(4, 7);
dock_select->draw_rect(unr, unusable);
@@ -3843,7 +3910,7 @@ void EditorNode::_dock_select_draw() {
Rect2 r(ofs, s);
dock_select_rect[i] = r;
- r.pos += Vector2(2, 5);
+ r.position += Vector2(2, 5);
r.size -= Vector2(4, 7);
if (i == dock_select_rect_over) {
@@ -4211,7 +4278,47 @@ void EditorNode::_scene_tab_closed(int p_tab) {
}
}
+void EditorNode::_scene_tab_hover(int p_tab) {
+ if (bool(EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true)) == false) {
+ return;
+ }
+ int current_tab = scene_tabs->get_current_tab();
+
+ if (p_tab == current_tab || p_tab < 0) {
+ tab_preview_panel->hide();
+ } else {
+ String path = editor_data.get_scene_path(p_tab);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(path, this, "_thumbnail_done", p_tab);
+ }
+}
+
+void EditorNode::_scene_tab_exit() {
+ tab_preview_panel->hide();
+}
+
+void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) {
+ Ref<InputEventMouseButton> mb = p_input;
+
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed() && scene_tabs->get_hovered_tab() >= 0) {
+ _scene_tab_closed(scene_tabs->get_hovered_tab());
+ }
+ }
+}
+
+void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
+ int p_tab = p_udata.operator signed int();
+ if (p_preview.is_valid()) {
+ Rect2 rect = scene_tabs->get_tab_rect(p_tab);
+ rect.position += scene_tabs->get_global_position();
+ tab_preview->set_texture(p_preview);
+ tab_preview_panel->set_position(rect.position + Vector2(0, rect.size.height));
+ tab_preview_panel->show();
+ }
+}
+
void EditorNode::_scene_tab_changed(int p_tab) {
+ tab_preview_panel->hide();
//print_line("set current 1 ");
bool unsaved = (saved_version != editor_data.get_undo_redo().get_version());
@@ -4382,7 +4489,25 @@ bool EditorNode::get_docks_visible() const {
void EditorNode::_toggle_distraction_free_mode() {
- set_distraction_free_mode(distraction_free->is_pressed());
+ if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) {
+ int screen = -1;
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_plugin_screen == editor_table[i]) {
+ screen = i;
+ break;
+ }
+ }
+
+ if (screen == EDITOR_SCRIPT) {
+ script_distraction = !script_distraction;
+ set_distraction_free_mode(script_distraction);
+ } else {
+ scene_distraction = !scene_distraction;
+ set_distraction_free_mode(scene_distraction);
+ }
+ } else {
+ set_distraction_free_mode(distraction_free->is_pressed());
+ }
}
void EditorNode::set_distraction_free_mode(bool p_enter) {
@@ -4437,8 +4562,9 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
{
//todo make proper previews
Ref<ImageTexture> pic = gui_base->get_icon("FileBig", "EditorIcons");
- Image img = pic->get_data();
- img.resize(48, 48); //meh
+ Ref<Image> img = pic->get_data();
+ img = img->duplicate();
+ img->resize(48, 48); //meh
Ref<ImageTexture> resized_pic = Ref<ImageTexture>(memnew(ImageTexture));
resized_pic->create_from_image(img);
preview = resized_pic;
@@ -4682,6 +4808,22 @@ void EditorNode::_dim_timeout() {
}
}
+void EditorNode::_check_gui_base_size() {
+ if (gui_base->get_size().width > 1200 * EDSCALE) {
+ for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) {
+ ToolButton *btn = singleton->main_editor_button_vb->get_child(i)->cast_to<ToolButton>();
+ if (btn == singleton->distraction_free) continue;
+ btn->set_text(btn->get_name());
+ }
+ } else {
+ for (int i = 0; i < singleton->main_editor_button_vb->get_child_count(); i++) {
+ ToolButton *btn = singleton->main_editor_button_vb->get_child(i)->cast_to<ToolButton>();
+ if (btn == singleton->distraction_free) continue;
+ btn->set_text("");
+ }
+ }
+}
+
void EditorNode::open_export_template_manager() {
export_template_manager->popup_manager();
@@ -4743,6 +4885,10 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("set_current_version", &EditorNode::set_current_version);
ClassDB::bind_method("_scene_tab_changed", &EditorNode::_scene_tab_changed);
ClassDB::bind_method("_scene_tab_closed", &EditorNode::_scene_tab_closed);
+ ClassDB::bind_method("_scene_tab_hover", &EditorNode::_scene_tab_hover);
+ ClassDB::bind_method("_scene_tab_exit", &EditorNode::_scene_tab_exit);
+ ClassDB::bind_method("_scene_tab_input", &EditorNode::_scene_tab_input);
+ ClassDB::bind_method("_thumbnail_done", &EditorNode::_thumbnail_done);
ClassDB::bind_method("_scene_tab_script_edited", &EditorNode::_scene_tab_script_edited);
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
ClassDB::bind_method("_update_scene_tabs", &EditorNode::_update_scene_tabs);
@@ -4764,11 +4910,14 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported);
ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported);
ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout);
+ ClassDB::bind_method(D_METHOD("_check_gui_base_size"), &EditorNode::_check_gui_base_size);
ADD_SIGNAL(MethodInfo("play_pressed"));
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
ADD_SIGNAL(MethodInfo("request_help"));
+ ADD_SIGNAL(MethodInfo("request_help_search"));
+ ADD_SIGNAL(MethodInfo("request_help_index"));
ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::POOL_STRING_ARRAY, "args")));
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
}
@@ -4783,6 +4932,7 @@ EditorNode::EditorNode() {
Resource::_get_local_scene_func = _resource_get_edited_scene;
VisualServer::get_singleton()->textures_keep_original(true);
+ VisualServer::get_singleton()->set_debug_generate_wireframes(true);
EditorHelp::generate_doc(); //before any editor classes are crated
SceneState::set_disable_placeholders(true);
@@ -4806,6 +4956,9 @@ EditorNode::EditorNode() {
_initializing_addons = false;
docks_visible = true;
+ scene_distraction = false;
+ script_distraction = false;
+
FileAccess::set_backup_save(true);
TranslationServer::get_singleton()->set_enabled(false);
@@ -4893,17 +5046,19 @@ EditorNode::EditorNode() {
ClassDB::set_class_enabled("CollisionShape2D", true);
ClassDB::set_class_enabled("CollisionPolygon2D", true);
- Control *theme_base = memnew(Control);
+ theme_base = memnew(Control);
add_child(theme_base);
theme_base->set_area_as_parent_rect();
gui_base = memnew(Panel);
theme_base->add_child(gui_base);
gui_base->set_area_as_parent_rect();
+ gui_base->connect("item_rect_changed", this, "_check_gui_base_size");
Ref<Theme> theme = create_editor_theme();
theme_base->set_theme(theme);
gui_base->set_theme(create_custom_theme());
+ gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles"));
resource_preview = memnew(EditorResourcePreview);
add_child(resource_preview);
@@ -4918,6 +5073,7 @@ EditorNode::EditorNode() {
main_vbox = memnew(VBoxContainer);
gui_base->add_child(main_vbox);
main_vbox->set_area_as_parent_rect(8);
+ main_vbox->set_margin(MARGIN_TOP, 5);
#if 0
PanelContainer *top_dark_panel = memnew( PanelContainer );
@@ -5054,7 +5210,7 @@ EditorNode::EditorNode() {
dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_slot[i]->set_popup(dock_select_popoup);
dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i));
- //dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT);
+ dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT);
}
dock_drag_timer = memnew(Timer);
@@ -5077,24 +5233,50 @@ EditorNode::EditorNode() {
main_editor_tabs->connect("tab_changed",this,"_editor_select");
main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER);
*/
+ tab_preview_panel = memnew(Panel);
+ tab_preview_panel->set_size(Size2(100, 100) * EDSCALE);
+ tab_preview_panel->hide();
+ tab_preview_panel->set_self_modulate(Color(1, 1, 1, 0.7));
+ gui_base->add_child(tab_preview_panel);
+
+ tab_preview = memnew(TextureRect);
+ tab_preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
+ tab_preview->set_size(Size2(96, 96) * EDSCALE);
+ tab_preview->set_position(Point2(2, 2) * EDSCALE);
+ tab_preview_panel->add_child(tab_preview);
+
scene_tabs = memnew(Tabs);
+ scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles"));
+ scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles"));
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_LEFT);
scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
+ scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE);
scene_tabs->connect("tab_changed", this, "_scene_tab_changed");
scene_tabs->connect("right_button_pressed", this, "_scene_tab_script_edited");
scene_tabs->connect("tab_close", this, "_scene_tab_closed");
+ scene_tabs->connect("tab_hover", this, "_scene_tab_hover");
+ scene_tabs->connect("mouse_exited", this, "_scene_tab_exit");
+ scene_tabs->connect("gui_input", this, "_scene_tab_input");
- // MarginContainer *st_mc = memnew( MarginContainer );
- // st_mc->add_child(scene_tabs);
- srt->add_child(scene_tabs);
+ HBoxContainer *tabbar_container = memnew(HBoxContainer);
+ scene_tabs->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+
+ srt->add_child(tabbar_container);
+ tabbar_container->add_child(scene_tabs);
+ distraction_free = memnew(ToolButton);
+ tabbar_container->add_child(distraction_free);
+ distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11));
+ distraction_free->connect("pressed", this, "_toggle_distraction_free_mode");
+ distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
+ distraction_free->set_toggle_mode(true);
scene_root_parent = memnew(PanelContainer);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
- scene_root_parent->add_style_override("panel", gui_base->get_stylebox("EditorPanel", "EditorStyles"));
+ scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
- // Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel_full","PanelContainer");
- // scene_root_parent->add_style_override("panel",sp);
+ //Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer");
+ //scene_root_parent->add_style_override("panel",sp);
/*scene_root_parent->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
scene_root_parent->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
@@ -5124,17 +5306,46 @@ EditorNode::EditorNode() {
scene_root_parent->add_child(viewport);
PanelContainer *top_region = memnew(PanelContainer);
- top_region->add_style_override("panel", memnew(StyleBoxEmpty));
+ top_region->add_style_override("panel", gui_base->get_stylebox("MenuPanel", "EditorStyles"));
HBoxContainer *left_menu_hb = memnew(HBoxContainer);
top_region->add_child(left_menu_hb);
menu_hb->add_child(top_region);
PopupMenu *p;
+ project_menu = memnew(MenuButton);
+ project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
+ project_menu->set_text(TTR("Project"));
+ project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ left_menu_hb->add_child(project_menu);
+
+ p = project_menu->get_popup();
+ p->connect("id_pressed", this, "_menu_option");
+ p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
+ p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
+
+ PopupMenu *tool_menu = memnew(PopupMenu);
+ tool_menu->set_name("Tools");
+ tool_menu->connect("id_pressed", this, "_menu_option");
+ p->add_child(tool_menu);
+ p->add_submenu_item(TTR("Tools"), "Tools");
+ tool_menu->add_item(TTR("Orphan Resource Explorer"), TOOLS_ORPHAN_RESOURCES);
+ p->add_separator();
+ p->add_item(TTR("Project Settings"), RUN_SETTINGS);
+ p->add_separator();
+
+#ifdef OSX_ENABLED
+ p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q);
+#else
+ p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Q);
+#endif
+ p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q);
+
file_menu = memnew(MenuButton);
file_menu->set_text(TTR("Scene"));
//file_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
left_menu_hb->add_child(file_menu);
+ file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
prev_scene = memnew(ToolButton);
prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
@@ -5182,18 +5393,7 @@ EditorNode::EditorNode() {
p->add_shortcut(ED_SHORTCUT("editor/undo", TTR("Undo"), KEY_MASK_CMD + KEY_Z), EDIT_UNDO, true);
p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Z), EDIT_REDO, true);
p->add_separator();
- p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
- p->add_separator();
- p->add_item(TTR("Project Settings"), RUN_SETTINGS);
- p->add_separator();
p->add_item(TTR("Revert Scene"), EDIT_REVERT);
- p->add_separator();
-#ifdef OSX_ENABLED
- p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q);
-#else
- p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Q);
-#endif
- p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q);
recent_scenes = memnew(PopupMenu);
recent_scenes->set_name("RecentScenes");
@@ -5207,17 +5407,11 @@ EditorNode::EditorNode() {
}
PanelContainer *editor_region = memnew(PanelContainer);
- editor_region->add_style_override("panel", memnew(StyleBoxEmpty));
main_editor_button_vb = memnew(HBoxContainer);
editor_region->add_child(main_editor_button_vb);
- menu_hb->add_child(editor_region);
- distraction_free = memnew(ToolButton);
- main_editor_button_vb->add_child(distraction_free);
- distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11));
- distraction_free->connect("pressed", this, "_toggle_distraction_free_mode");
- distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
- distraction_free->set_toggle_mode(true);
+ menu_hb->add_spacer();
+ menu_hb->add_child(editor_region);
//menu_hb->add_spacer();
#if 0
@@ -5248,25 +5442,66 @@ EditorNode::EditorNode() {
menu_panel->add_child( resource_menu );
#endif
- tool_menu = memnew(MenuButton);
- tool_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
- tool_menu->set_text(TTR("Tools"));
+ debug_menu = memnew(MenuButton);
+ debug_menu->set_text(TTR("Debug"));
+ debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ left_menu_hb->add_child(debug_menu);
+ p = debug_menu->get_popup();
+ p->set_hide_on_item_selection(false);
+ p->add_check_item(TTR("Deploy with Remote Debug"), RUN_DEPLOY_REMOTE_DEBUG);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
+ p->add_check_item(TTR("Small Deploy with Network FS"), RUN_FILE_SERVER);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is enabled, export or deploy will produce a minimal executable.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploy will use the USB cable for faster performance. This option speeds up testing for games with a large footprint."));
+ p->add_separator();
+ p->add_check_item(TTR("Visible Collision Shapes"), RUN_DEBUG_COLLISONS);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("Collision shapes and raycast nodes (for 2D and 3D) will be visible on the running game if this option is turned on."));
+ p->add_check_item(TTR("Visible Navigation"), RUN_DEBUG_NAVIGATION);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
+ p->add_separator();
+ p->add_check_item(TTR("Sync Scene Changes"), RUN_LIVE_DEBUG);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
+ p->add_check_item(TTR("Sync Script Changes"), RUN_RELOAD_SCRIPTS);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
+ p->connect("id_pressed", this, "_menu_option");
- //tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
- left_menu_hb->add_child(tool_menu);
+ menu_hb->add_spacer();
- p = tool_menu->get_popup();
- p->connect("id_pressed", this, "_menu_option");
- p->add_item(TTR("Orphan Resource Explorer"), TOOLS_ORPHAN_RESOURCES);
+ settings_menu = memnew(MenuButton);
+ left_menu_hb->add_child(settings_menu);
+ settings_menu->set_text(TTR("Editor"));
+ settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ //settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END);
+ p = settings_menu->get_popup();
- export_button = memnew(ToolButton);
- export_button->set_tooltip(TTR("Export the project to many platforms."));
- export_button->set_text(TTR("Export"));
- export_button->connect("pressed", this, "_menu_option", varray(FILE_EXPORT_PROJECT));
- export_button->set_focus_mode(Control::FOCUS_NONE);
- left_menu_hb->add_child(export_button);
+ //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
+ p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES);
+ //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS);
+ p->add_separator();
+ editor_layouts = memnew(PopupMenu);
+ editor_layouts->set_name("Layouts");
+ p->add_child(editor_layouts);
+ editor_layouts->connect("id_pressed", this, "_layout_menu_option");
+ p->add_submenu_item(TTR("Editor Layout"), "Layouts");
+ p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREN);
+ p->add_separator();
+ p->add_item(TTR("Manage Export Templates"), SETTINGS_MANAGE_EXPORT_TEMPLATES);
- menu_hb->add_spacer();
+ // Help Menu
+ MenuButton *help_menu = memnew(MenuButton);
+ left_menu_hb->add_child(help_menu);
+ help_menu->set_text(TTR("Help"));
+ help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles"));
+ p = help_menu->get_popup();
+ p->connect("id_pressed", this, "_menu_option");
+ p->add_icon_item(gui_base->get_icon("ClassList", "EditorIcons"), TTR("Classes"), HELP_CLASSES);
+ p->add_icon_item(gui_base->get_icon("Help", "EditorIcons"), TTR("Search"), HELP_SEARCH);
+ p->add_separator();
+ p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS);
+ p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Q&A"), HELP_QA);
+ p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Issue Tracker"), HELP_ISSUES);
+ p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Community"), HELP_COMMUNITY);
+ p->add_separator();
+ p->add_icon_item(gui_base->get_icon("GodotDocs", "EditorIcons"), TTR("About"), HELP_ABOUT);
//Separator *s1 = memnew( VSeparator );
//menu_panel->add_child(s1);
@@ -5274,20 +5509,18 @@ EditorNode::EditorNode() {
//s1->set_size(Point2(10,15));
play_cc = memnew(CenterContainer);
- // play_cc->add_style_override("bg",gui_base->get_stylebox("panel","PanelContainer"));
-
play_cc->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
- gui_base->add_child(play_cc);
+ menu_hb->add_child(play_cc);
play_cc->set_area_as_parent_rect();
play_cc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 10);
play_cc->set_margin(MARGIN_TOP, 5);
- top_region = memnew(PanelContainer);
- top_region->add_style_override("panel", gui_base->get_stylebox("panel", "ButtonGroup"));
- play_cc->add_child(top_region);
+ play_button_panel = memnew(PanelContainer);
+ play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
+ play_cc->add_child(play_button_panel);
HBoxContainer *play_hb = memnew(HBoxContainer);
- top_region->add_child(play_hb);
+ play_button_panel->add_child(play_hb);
play_button = memnew(ToolButton);
play_hb->add_child(play_button);
@@ -5348,33 +5581,6 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
- debug_button = memnew(MenuButton);
- debug_button->set_flat(true);
- play_hb->add_child(debug_button);
- //debug_button->set_toggle_mode(true);
- debug_button->set_focus_mode(Control::FOCUS_NONE);
- debug_button->set_icon(gui_base->get_icon("Remote", "EditorIcons"));
- //debug_button->connect("pressed", this,"_menu_option",make_binds(RUN_LIVE_DEBUG));
- debug_button->set_tooltip(TTR("Debug options"));
-
- p = debug_button->get_popup();
- p->set_hide_on_item_selection(false);
- p->add_check_item(TTR("Deploy with Remote Debug"), RUN_DEPLOY_REMOTE_DEBUG);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
- p->add_check_item(TTR("Small Deploy with Network FS"), RUN_FILE_SERVER);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is enabled, export or deploy will produce a minimal executable.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploy will use the USB cable for faster performance. This option speeds up testing for games with a large footprint."));
- p->add_separator();
- p->add_check_item(TTR("Visible Collision Shapes"), RUN_DEBUG_COLLISONS);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("Collision shapes and raycast nodes (for 2D and 3D) will be visible on the running game if this option is turned on."));
- p->add_check_item(TTR("Visible Navigation"), RUN_DEBUG_NAVIGATION);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
- p->add_separator();
- p->add_check_item(TTR("Sync Scene Changes"), RUN_LIVE_DEBUG);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->add_check_item(TTR("Sync Script Changes"), RUN_RELOAD_SCRIPTS);
- p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->connect("id_pressed", this, "_menu_option");
-
/*
run_settings_button = memnew( ToolButton );
//menu_hb->add_child(run_settings_button);
@@ -5394,65 +5600,24 @@ EditorNode::EditorNode() {
*/
progress_hb = memnew(BackgroundProgress);
- menu_hb->add_child(progress_hb);
+ //menu_hb->add_child(progress_hb);
{
Control *sp = memnew(Control);
sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- menu_hb->add_child(sp);
+ //menu_hb->add_child(sp);
}
- PanelContainer *vu_cont = memnew(PanelContainer);
- vu_cont->add_style_override("panel", memnew(StyleBoxEmpty));
-
- // CenterContainer *vu_cont = memnew( CenterContainer );
- menu_hb->add_child(vu_cont);
-
- audio_vu = memnew(TextureProgress);
- CenterContainer *vu_cc = memnew(CenterContainer);
- vu_cc->add_child(audio_vu);
- vu_cont->add_child(vu_cc);
- audio_vu->set_under_texture(gui_base->get_icon("VuEmpty", "EditorIcons"));
- audio_vu->set_progress_texture(gui_base->get_icon("VuFull", "EditorIcons"));
- audio_vu->set_max(24);
- audio_vu->set_min(-80);
- audio_vu->set_step(0.01);
- audio_vu->set_value(0);
-
{
Control *sp = memnew(Control);
sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- menu_hb->add_child(sp);
+ //menu_hb->add_child(sp);
}
top_region = memnew(PanelContainer);
- top_region->add_style_override("panel", memnew(StyleBoxEmpty));
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
- top_region->add_child(right_menu_hb);
- menu_hb->add_child(top_region);
-
- settings_menu = memnew(MenuButton);
- settings_menu->set_text(TTR("Settings"));
- //settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- right_menu_hb->add_child(settings_menu);
- p = settings_menu->get_popup();
-
- //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
- p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES);
- //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS);
- p->add_separator();
- editor_layouts = memnew(PopupMenu);
- editor_layouts->set_name("Layouts");
- p->add_child(editor_layouts);
- editor_layouts->connect("id_pressed", this, "_layout_menu_option");
- p->add_submenu_item(TTR("Editor Layout"), "Layouts");
-
- p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREN);
-
- p->add_separator();
- p->add_item(TTR("Manage Export Templates"), SETTINGS_MANAGE_EXPORT_TEMPLATES);
- p->add_separator();
- p->add_item(TTR("About"), SETTINGS_ABOUT);
+ //top_region->add_child(right_menu_hb);
+ menu_hb->add_child(right_menu_hb);
layout_dialog = memnew(EditorNameDialog);
gui_base->add_child(layout_dialog);
@@ -5460,16 +5625,11 @@ EditorNode::EditorNode() {
layout_dialog->set_size(Size2(175, 70) * EDSCALE);
layout_dialog->connect("name_confirmed", this, "_dialog_action");
- sources_button = memnew(ToolButton);
- right_menu_hb->add_child(sources_button);
- sources_button->set_icon(gui_base->get_icon("DependencyOk", "EditorIcons"));
- sources_button->connect("pressed", this, "_menu_option", varray(SOURCES_REIMPORT));
- sources_button->set_tooltip(TTR("Alerts when an external resource has changed."));
-
update_menu = memnew(MenuButton);
update_menu->set_tooltip(TTR("Spins when the editor window repaints!"));
right_menu_hb->add_child(update_menu);
update_menu->set_icon(gui_base->get_icon("Progress1", "EditorIcons"));
+ update_menu->get_popup()->connect("id_pressed", this, "_menu_option");
p = update_menu->get_popup();
p->add_check_item(TTR("Update Always"), SETTINGS_UPDATE_ALWAYS);
p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES);
@@ -5592,7 +5752,7 @@ EditorNode::EditorNode() {
search_button = memnew(ToolButton);
search_button->set_toggle_mode(true);
search_button->set_pressed(false);
- search_button->set_icon(gui_base->get_icon("Search", "EditorIcons"));
+ search_button->set_icon(gui_base->get_icon("Zoom", "EditorIcons"));
prop_editor_hb->add_child(search_button);
search_button->connect("toggled", this, "_toggle_search_bar");
@@ -5682,7 +5842,7 @@ EditorNode::EditorNode() {
_update_layouts_menu();
bottom_panel = memnew(PanelContainer);
- bottom_panel->add_style_override("panel", gui_base->get_stylebox("EditorPanel", "EditorStyles"));
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles"));
center_split->add_child(bottom_panel);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
@@ -5787,14 +5947,49 @@ EditorNode::EditorNode() {
about->get_ok()->set_text(TTR("Thanks!"));
about->set_hide_on_ok(true);
gui_base->add_child(about);
+ VBoxContainer *vbc = memnew(VBoxContainer);
HBoxContainer *hbc = memnew(HBoxContainer);
- about->add_child(hbc);
+ hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ hbc->set_alignment(BoxContainer::ALIGN_CENTER);
+ about->add_child(vbc);
+ vbc->add_child(hbc);
Label *about_text = memnew(Label);
- about_text->set_text(VERSION_FULL_NAME "\n(c) 2008-2017 Juan Linietsky, Ariel Manzur.\n");
+ about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + TTR("Godot Engine contributors") + "\n");
TextureRect *logo = memnew(TextureRect);
logo->set_texture(gui_base->get_icon("Logo", "EditorIcons"));
hbc->add_child(logo);
hbc->add_child(about_text);
+ TabContainer *tc = memnew(TabContainer);
+ tc->set_custom_minimum_size(Vector2(740, 300));
+ vbc->add_child(tc);
+ ScrollContainer *dev_base = memnew(ScrollContainer);
+ dev_base->set_name(TTR("Developers"));
+ tc->add_child(dev_base);
+ HBoxContainer *dev_hbc = memnew(HBoxContainer);
+ dev_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ dev_base->add_child(dev_hbc);
+ for (int i = 0; i < 3; i++) {
+ Label *dev_label = memnew(Label);
+ dev_label->set_h_size_flags(Control::SIZE_EXPAND);
+ dev_label->set_v_size_flags(Control::SIZE_FILL);
+ dev_hbc->add_child(dev_label);
+ }
+ int dev_name_index = 0;
+ int dev_name_column = 0;
+ const int dev_index_max = AUTHORS_COUNT / 3 + (AUTHORS_COUNT % 3 == 0 ? 0 : 1);
+ String dev_name = "";
+ const char **dev_names_ptr = dev_names;
+ while (*dev_names_ptr) {
+ dev_name += String::utf8(*dev_names_ptr++);
+ if (++dev_name_index == dev_index_max || !*dev_names_ptr) {
+ dev_hbc->get_child(dev_name_column)->cast_to<Label>()->set_text(dev_name);
+ dev_name_column++;
+ dev_name = "";
+ dev_name_index = 0;
+ } else {
+ dev_name += "\n";
+ }
+ }
warning = memnew(AcceptDialog);
gui_base->add_child(warning);
@@ -5854,7 +6049,6 @@ EditorNode::EditorNode() {
file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
object_menu->get_popup()->connect("id_pressed", this, "_menu_option");
- update_menu->get_popup()->connect("id_pressed", this, "_menu_option");
settings_menu->get_popup()->connect("id_pressed", this, "_menu_option");
file->connect("file_selected", this, "_dialog_action");
@@ -5912,13 +6106,13 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
- //add_editor_plugin( memnew( PathEditorPlugin(this) ) );
+ add_editor_plugin(memnew(PathEditorPlugin(this)));
//add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) );
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin(this)));
- add_editor_plugin(memnew(ColorRampEditorPlugin(this)));
+ add_editor_plugin(memnew(GradientEditorPlugin(this)));
add_editor_plugin(memnew(GradientTextureEditorPlugin(this)));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveTextureEditorPlugin(this)));
@@ -5934,14 +6128,13 @@ EditorNode::EditorNode() {
plugin_init_callbacks[i]();
}
- /*resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorPackedScenePreviewPlugin>( memnew(EditorPackedScenePreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorMaterialPreviewPlugin>( memnew(EditorMaterialPreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorScriptPreviewPlugin>( memnew(EditorScriptPreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorMeshPreviewPlugin>( memnew(EditorMeshPreviewPlugin )));
- resource_preview->add_preview_generator( Ref<EditorBitmapPreviewPlugin>( memnew(EditorBitmapPreviewPlugin )));
-*/
+ resource_preview->add_preview_generator(Ref<EditorTexturePreviewPlugin>(memnew(EditorTexturePreviewPlugin)));
+ resource_preview->add_preview_generator(Ref<EditorPackedScenePreviewPlugin>(memnew(EditorPackedScenePreviewPlugin)));
+ resource_preview->add_preview_generator(Ref<EditorMaterialPreviewPlugin>(memnew(EditorMaterialPreviewPlugin)));
+ resource_preview->add_preview_generator(Ref<EditorScriptPreviewPlugin>(memnew(EditorScriptPreviewPlugin)));
+ //resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin )));
+ resource_preview->add_preview_generator(Ref<EditorMeshPreviewPlugin>(memnew(EditorMeshPreviewPlugin)));
+ resource_preview->add_preview_generator(Ref<EditorBitmapPreviewPlugin>(memnew(EditorBitmapPreviewPlugin)));
circle_step_msec = OS::get_singleton()->get_ticks_msec();
circle_step_frame = Engine::get_singleton()->get_frames_drawn();
@@ -5949,6 +6142,7 @@ EditorNode::EditorNode() {
editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
+ editor_plugins_force_input_forwarding = memnew(EditorPluginList);
//force_top_viewport(true);
_edit_current();
@@ -6082,6 +6276,14 @@ EditorNode::EditorNode() {
_dim_timer->set_wait_time(0.01666f);
_dim_timer->connect("timeout", this, "_dim_timeout");
add_child(_dim_timer);
+
+ ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F2);
+ ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F3);
+ ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F4);
+ ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1);
+ ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library"));
+ ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor"));
+ ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor"));
}
EditorNode::~EditorNode() {
@@ -6089,6 +6291,7 @@ EditorNode::~EditorNode() {
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
+ memdelete(editor_plugins_force_input_forwarding);
memdelete(file_server);
EditorSettings::destroy();
}
@@ -6111,7 +6314,7 @@ void EditorPluginList::edit(Object *p_object) {
}
}
-bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) {
+bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event) {
bool discard = false;
@@ -6124,10 +6327,14 @@ bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, cons
return discard;
}
-bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const InputEvent &p_event) {
+bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {
+ if ((!serve_when_force_input_enabled) && plugins_list[i]->is_input_event_forwarding_always_enabled()) {
+ continue;
+ }
+
if (plugins_list[i]->forward_spatial_gui_input(p_camera, p_event)) {
discard = true;
}
@@ -6143,6 +6350,10 @@ void EditorPluginList::forward_draw_over_canvas(const Transform2D &p_canvas_xfor
}
}
+void EditorPluginList::add_plugin(EditorPlugin *p_plugin) {
+ plugins_list.push_back(p_plugin);
+}
+
bool EditorPluginList::empty() {
return plugins_list.empty();
}