summaryrefslogtreecommitdiff
path: root/tools/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r--tools/editor/editor_node.cpp451
1 files changed, 362 insertions, 89 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index d64f620ea4..d664a91c47 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -102,6 +102,7 @@
#include "tools/editor/io_plugins/editor_sample_import_plugin.h"
#include "tools/editor/io_plugins/editor_translation_import_plugin.h"
#include "tools/editor/io_plugins/editor_mesh_import_plugin.h"
+#include "tools/editor/io_plugins/editor_export_scene.h"
#include "plugins/editor_preview_plugins.h"
@@ -142,6 +143,7 @@ void EditorNode::_update_scene_tabs() {
}
scene_tabs->set_current_tab(editor_data.get_edited_scene());
+ scene_tabs->ensure_tab_visible(editor_data.get_edited_scene());
}
@@ -414,7 +416,7 @@ void EditorNode::_rebuild_import_menu()
{
PopupMenu* p = import_menu->get_popup();
p->clear();
- p->add_item("Sub-Scene", FILE_IMPORT_SUBSCENE);
+ p->add_item("Node from scene", FILE_IMPORT_SUBSCENE);
p->add_separator();
for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) {
p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i);
@@ -510,13 +512,21 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool());
+ current_option=RESOURCE_SAVE_AS;
List<String> extensions;
Ref<PackedScene> sd = memnew( PackedScene );
ResourceSaver::get_recognized_extensions(p_resource,&extensions);
file->clear_filters();
+
+ List<String> preferred;
for(int i=0;i<extensions.size();i++) {
+ if (p_resource->is_type("Script") && (extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml")) {
+ //this serves no purpose and confused people
+ continue;
+ }
file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ preferred.push_back(extensions[i]);
}
//file->set_current_path(current_path);
@@ -528,11 +538,11 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
file->set_current_path(p_resource->get_path().replacen("."+ext,"."+extensions.front()->get()));
}
}
- } else {
+ } else if (preferred.size()) {
String existing;
if (extensions.size()) {
- existing="new_"+p_resource->get_type().to_lower()+"."+extensions.front()->get().to_lower();
+ existing="new_"+p_resource->get_type().to_lower()+"."+preferred.front()->get().to_lower();
}
file->set_current_path(existing);
@@ -542,7 +552,6 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) {
}
-
void EditorNode::_menu_option(int p_option) {
_menu_option_confirm(p_option,false);
@@ -584,59 +593,66 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
}
-void EditorNode::_get_scene_metadata() {
+void EditorNode::_get_scene_metadata(const String& p_file) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
- if (scene->has_meta("__editor_plugin_states__")) {
+ Ref<ConfigFile> cf;
+ cf.instance();
- Dictionary md = scene->get_meta("__editor_plugin_states__");
- editor_data.set_editor_states(md);
+ Error err = cf->load(path);
+ if (err!=OK)
+ return; //must not exist
- }
+ List<String> esl;
+ cf->get_section_keys("editor_states",&esl);
- if (scene->has_meta("__editor_run_settings__")) {
+ Dictionary md;
+ for (List<String>::Element *E=esl.front();E;E=E->next()) {
- Dictionary md = scene->get_meta("__editor_run_settings__");
- if (md.has("run_mode"))
- run_settings_dialog->set_run_mode(md["run_mode"]);
- if (md.has("custom_args"))
- run_settings_dialog->set_custom_arguments(md["custom_args"]);
+ Variant st=cf->get_value("editor_states",E->get());
+ if (st.get_type()) {
+ md[E->get()]=st;
+ }
}
+
+ editor_data.set_editor_states(md);
+
}
-void EditorNode::_set_scene_metadata() {
+void EditorNode::_set_scene_metadata(const String& p_file) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
- { /* Editor States */
- Dictionary md = editor_data.get_editor_states();
+ scene->set_meta("__editor_run_settings__",Variant()); //clear it (no point in keeping it)
+ scene->set_meta("__editor_plugin_states__",Variant());
- if (!md.empty()) {
- scene->set_meta("__editor_plugin_states__",md);
- }
- }
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
- { /* Run Settings */
+ Ref<ConfigFile> cf;
+ cf.instance();
+ Dictionary md = editor_data.get_editor_states();
+ List<Variant> keys;
+ md.get_key_list(&keys);
- Dictionary md;
- md["run_mode"]=run_settings_dialog->get_run_mode();
- md["custom_args"]=run_settings_dialog->get_custom_arguments();
- scene->set_meta("__editor_run_settings__",md);
- }
-
+ for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ cf->set_value("editor_states",E->get(),md[E->get()]);
+ }
+ Error err = cf->save(path);
+ ERR_FAIL_COND(err!=OK);
}
@@ -954,8 +970,24 @@ void EditorNode::_save_scene(String p_file) {
}
- _set_scene_metadata();
- Ref<PackedScene> sdata = memnew( PackedScene );
+ _set_scene_metadata(p_file);
+
+
+ Ref<PackedScene> sdata;
+
+ if (ResourceCache::has(p_file)) {
+ // something may be referencing this resource and we are good with that.
+ // we must update it, but also let the previous scene state go, as
+ // old version still work for referencing changes in instanced or inherited scenes
+
+ sdata = Ref<PackedScene>( ResourceCache::get(p_file)->cast_to<PackedScene>() );
+ if (sdata.is_valid())
+ sdata->recreate_state();
+ else
+ sdata.instance();
+ } else {
+ sdata.instance();
+ }
Error err = sdata->pack(scene);
@@ -1221,10 +1253,18 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_EXPORT_TILESET: {
Ref<TileSet> ml;
- if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) {
+ if (FileAccess::exists(p_file)) {
ml=ResourceLoader::load(p_file,"TileSet");
- if (ml.is_null()) {
+ if (!file_export_lib_merge->is_pressed()) {
+ ml->clear();
+ }
+
+ }
+
+ if (ml.is_null()) {
+
+ if (file_export_lib_merge->is_pressed()) {
current_option=-1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
@@ -1233,9 +1273,6 @@ void EditorNode::_dialog_action(String p_file) {
return;
}
- }
-
- if (ml.is_null()) {
ml = Ref<TileSet>( memnew( TileSet ));
}
@@ -1340,6 +1377,65 @@ void EditorNode::_dialog_action(String p_file) {
save_resource_in_path(current_res,p_file);
} break;
+ case SETTINGS_LAYOUT_SAVE: {
+
+ if (p_file.empty())
+ return;
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ if (err==ERR_CANT_OPEN) {
+ config.instance(); // new config
+ } else if (err!=OK) {
+ show_warning("Error trying to save layout!");
+ return;
+ }
+
+ _save_docks_to_config(config, p_file);
+
+ config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ layout_dialog->hide();
+ _update_layouts_menu();
+
+ if (p_file=="Default") {
+ show_warning("Default editor layout overridden.");
+ }
+
+ } break;
+ case SETTINGS_LAYOUT_DELETE: {
+
+ if (p_file.empty())
+ return;
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ if (err!=OK || !config->has_section(p_file)) {
+ show_warning("Layout name not found!");
+ return;
+ }
+
+ // erase
+ List<String> keys;
+ config->get_section_keys(p_file, &keys);
+ for (List<String>::Element *E=keys.front();E;E=E->next()) {
+ config->set_value(p_file, E->get(), Variant());
+ }
+
+ config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+
+ layout_dialog->hide();
+ _update_layouts_menu();
+
+ if (p_file=="Default") {
+ show_warning("Restored Default layout to base settings.");
+ }
+
+ } break;
default: { //save scene?
if (file->get_mode()==FileDialog::MODE_SAVE_FILE) {
@@ -1493,6 +1589,10 @@ void EditorNode::_edit_current() {
scene_tree_dock->set_selected(NULL);
property_editor->edit( NULL );
object_menu->set_disabled(true);
+
+ if (editor_plugin_over)
+ editor_plugin_over->make_visible(false);
+
return;
}
@@ -1680,7 +1780,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("Play","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
//pause_button->set_pressed(false);
play_scene_button->set_pressed(false);
play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
@@ -1907,21 +2007,21 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_QUICK_OPEN_SCENE: {
- quick_open->popup("PackedScene");
+ quick_open->popup("PackedScene", true);
quick_open->set_title("Quick Open Scene..");
} break;
case FILE_QUICK_OPEN_SCRIPT: {
- quick_open->popup("Script");
+ quick_open->popup("Script", true);
quick_open->set_title("Quick Open Script..");
} break;
case FILE_QUICK_OPEN_FILE: {
- quick_open->popup("Resource",false,true);
+ quick_open->popup("Resource", false, true);
quick_open->set_title("Quick Search File..");
} break;
@@ -1939,7 +2039,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_CLOSE: {
- if (!p_confirmed) {
+ if (!p_confirmed && unsaved_cache) {
confirmation->get_ok()->set_text("Yes");
//confirmation->get_cancel()->show();
confirmation->set_text("Close scene? (Unsaved changes will be lost)");
@@ -1968,7 +2068,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
return;
};
// fallthrough to save_as
- } break;
+ };
case FILE_SAVE_AS_SCENE: {
Node *scene = editor_data.get_edited_scene_root();
@@ -2255,6 +2355,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
log->add_message("REDO: "+action);
} break;
+ case TOOLS_ORPHAN_RESOURCES: {
+
+ orphan_resources->show();
+ } break;
case EDIT_REVERT: {
@@ -2484,7 +2588,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
editor_run.stop();
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("Play","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
play_scene_button->set_pressed(false);
play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
//pause_button->set_pressed(false);
@@ -2932,7 +3036,7 @@ Error EditorNode::save_translatable_strings(const String& p_to_file) {
OS::Time time = OS::get_singleton()->get_time();
f->store_line("# Translation Strings Dump.");
f->store_line("# Created By.");
- f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2015 Juan Linietsky, Ariel Manzur.");
+ f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2016 Juan Linietsky, Ariel Manzur.");
f->store_line("# From Scene: ");
f->store_line("# \t"+get_edited_scene()->get_filename());
f->store_line("");
@@ -3195,6 +3299,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) {
//changing_scene=true; //avoid script change from opening editor
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) );
+ editor_data.notify_edited_scene_changed();
+
//changing_scene=false;
}
@@ -3208,8 +3314,18 @@ void EditorNode::set_current_version(uint64_t p_version) {
bool EditorNode::is_changing_scene() const {
return changing_scene;
}
+
+void EditorNode::_clear_undo_history() {
+
+ get_undo_redo()->clear_history();
+}
+
void EditorNode::set_current_scene(int p_idx) {
+ if (editor_data.check_and_update_scene(p_idx)) {
+ call_deferred("_clear_undo_history");
+ }
+
changing_scene=true;
editor_data.save_edited_scene_state(editor_selection,&editor_history,_get_main_scene_state());
@@ -3286,11 +3402,13 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
}
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+ if(!p_set_inherited) {
+ for(int i=0;i<editor_data.get_edited_scene_count();i++) {
- if (editor_data.get_scene_path(i)==p_scene) {
- _scene_tab_changed(i);
- return OK;
+ if (editor_data.get_scene_path(i)==p_scene) {
+ _scene_tab_changed(i);
+ return OK;
+ }
}
}
@@ -3372,7 +3490,18 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
add_io_error(txt);
}
- sdata->set_path(lpath,true); //take over path
+ if (ResourceCache::has(lpath)) {
+ //used from somewhere else? no problem! update state and replace sdata
+ Ref<PackedScene> ps = Ref<PackedScene>( ResourceCache::get(lpath)->cast_to<PackedScene>() );
+ if (ps.is_valid()) {
+ ps->replace_state( sdata->get_state() );
+ ps->set_last_modified_time( sdata->get_last_modified_time() );
+ sdata=ps;
+ }
+
+ } else {
+ sdata->set_path(lpath,true); //take over path
+ }
Node*new_scene=sdata->instance(true);
@@ -3410,16 +3539,17 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
if (p_set_inherited) {
Ref<SceneState> state = sdata->get_state();
- state->set_path(lpath);
+ state->set_path(lpath);
new_scene->set_scene_inherited_state(state);
new_scene->set_filename(String());
- if (new_scene->get_scene_instance_state().is_valid())
- new_scene->get_scene_instance_state()->set_path(String());
+ //if (new_scene->get_scene_instance_state().is_valid())
+ // new_scene->get_scene_instance_state()->set_path(String());
}
+ new_scene->set_scene_instance_state(Ref<SceneState>());
set_edited_scene(new_scene);
- _get_scene_metadata();
+ _get_scene_metadata(p_scene);
/*
editor_data.set_edited_scene_root(new_scene);
@@ -3574,7 +3704,6 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
}
animation_editor->set_keying(p_visible);
- _update_keying();
}
@@ -3675,19 +3804,26 @@ void EditorNode::hide_animation_player_editors() {
emit_signal("hide_animation_player_editors");
}
-void EditorNode::_quick_opened(const String& p_resource) {
+void EditorNode::_quick_opened() {
if (current_option==FILE_QUICK_OPEN_FILE) {
- scenes_dock->open(p_resource);
+ String res_path = quick_open->get_selected();
+
+ scenes_dock->open(res_path);
return;
}
- if (quick_open->get_base_type()=="PackedScene") {
- open_request(p_resource);
- } else {
- load_resource(p_resource);
- }
+ Vector<String> files = quick_open->get_selected_files();
+
+ for (int i = 0; i < files.size(); i++) {
+ String res_path = files[i];
+ if (quick_open->get_base_type()=="PackedScene") {
+ open_request(res_path);
+ } else {
+ load_resource(res_path);
+ }
+ }
}
void EditorNode::_quick_run(const String& p_resource) {
@@ -3807,9 +3943,9 @@ void EditorNode::progress_add_task(const String& p_task,const String& p_label, i
singleton->progress_dialog->add_task(p_task,p_label,p_steps);
}
-void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step) {
+void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw) {
- singleton->progress_dialog->task_step(p_task,p_state,p_step);
+ singleton->progress_dialog->task_step(p_task,p_state,p_step,p_force_redraw);
}
@@ -3890,6 +4026,8 @@ void EditorNode::_bind_methods() {
ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left);
ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
+ ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
+
ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
ObjectTypeDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed);
@@ -3903,6 +4041,7 @@ void EditorNode::_bind_methods() {
ObjectTypeDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar);
ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box);
+ ObjectTypeDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history);
ObjectTypeDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
ObjectTypeDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
@@ -4184,6 +4323,15 @@ void EditorNode::_save_docks() {
Ref<ConfigFile> config;
config.instance();
+ _save_docks_to_config(config, "docks");
+ editor_data.get_plugin_window_layout(config);
+
+ config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
+
+}
+
+void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section) {
+
for(int i=0;i<DOCK_SLOT_MAX;i++) {
String names;
for(int j=0;j<dock_slot[i]->get_tab_count();j++) {
@@ -4194,7 +4342,7 @@ void EditorNode::_save_docks() {
}
if (names!="") {
- config->set_value("docks","dock_"+itos(i+1),names);
+ p_layout->set_value(p_section,"dock_"+itos(i+1),names);
}
}
@@ -4208,7 +4356,7 @@ void EditorNode::_save_docks() {
for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
if (splits[i]->is_visible()) {
- config->set_value("docks","dock_split_"+itos(i+1),splits[i]->get_split_offset());
+ p_layout->set_value(p_section,"dock_split_"+itos(i+1),splits[i]->get_split_offset());
}
}
@@ -4222,13 +4370,9 @@ void EditorNode::_save_docks() {
for(int i=0;i<4;i++) {
- config->set_value("docks","dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset());
+ p_layout->set_value(p_section,"dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset());
}
- editor_data.get_plugin_window_layout(config);
-
- config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
-
}
void EditorNode::save_layout() {
@@ -4247,15 +4391,26 @@ void EditorNode::_load_docks() {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
if (err!=OK) {
- return; //no config
+ //no config
+ if (overridden_default_layout>=0) {
+ _layout_menu_option(overridden_default_layout);
+ }
+ return;
}
+ _load_docks_from_config(config, "docks");
+ editor_data.set_plugin_window_layout(config);
+
+}
+
+void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) {
+
for(int i=0;i<DOCK_SLOT_MAX;i++) {
- if (!config->has_section_key("docks","dock_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_"+itos(i+1)))
continue;
- Vector<String> names = String(config->get_value("docks","dock_"+itos(i+1))).split(",");
+ Vector<String> names = String(p_layout->get_value(p_section,"dock_"+itos(i+1))).split(",");
for(int j=0;j<names.size();j++) {
@@ -4275,7 +4430,7 @@ void EditorNode::_load_docks() {
if (atidx==-1) //well, it's not anywhere
continue;
- if (atidx==j) {
+ if (atidx==i) {
node->raise();
continue;
}
@@ -4290,7 +4445,6 @@ void EditorNode::_load_docks() {
dock_slot[i]->add_child(node);
dock_slot[i]->show();
}
-
}
VSplitContainer*splits[DOCK_SLOT_MAX/2]={
@@ -4302,14 +4456,14 @@ void EditorNode::_load_docks() {
for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
- if (!config->has_section_key("docks","dock_split_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_split_"+itos(i+1)))
continue;
- int ofs = config->get_value("docks","dock_split_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section,"dock_split_"+itos(i+1));
splits[i]->set_split_offset(ofs);
}
- HSplitContainer *h_splits[4]={
+ HSplitContainer*h_splits[4]={
left_l_hsplit,
left_r_hsplit,
main_hsplit,
@@ -4317,9 +4471,9 @@ void EditorNode::_load_docks() {
};
for(int i=0;i<4;i++) {
- if (!config->has_section_key("docks","dock_hsplit_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section,"dock_hsplit_"+itos(i+1)))
continue;
- int ofs = config->get_value("docks","dock_hsplit_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section,"dock_hsplit_"+itos(i+1));
h_splits[i]->set_split_offset(ofs);
}
@@ -4337,8 +4491,80 @@ void EditorNode::_load_docks() {
dock_slot[i]->set_current_tab(0);
}
}
+}
- editor_data.set_plugin_window_layout(config);
+
+void EditorNode::_update_layouts_menu() {
+
+ editor_layouts->clear();
+ overridden_default_layout=-1;
+
+ editor_layouts->set_size(Vector2());
+ editor_layouts->add_item("Save Layout", SETTINGS_LAYOUT_SAVE);
+ editor_layouts->add_item("Delete Layout", SETTINGS_LAYOUT_DELETE);
+ editor_layouts->add_separator();
+ editor_layouts->add_item("Default", SETTINGS_LAYOUT_DEFAULT);
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+ if (err!=OK) {
+ return; //no config
+ }
+
+ List<String> layouts;
+ config.ptr()->get_sections(&layouts);
+
+ for (List<String>::Element *E=layouts.front();E;E=E->next()) {
+
+ String layout=E->get();
+
+ if (layout=="Default") {
+ editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT));
+ overridden_default_layout=editor_layouts->get_item_count();
+ }
+
+ editor_layouts->add_item(layout);
+ }
+
+}
+
+void EditorNode::_layout_menu_option(int p_id) {
+
+ switch (p_id) {
+
+ case SETTINGS_LAYOUT_SAVE: {
+
+ current_option=p_id;
+ layout_dialog->set_title("Save Layout");
+ layout_dialog->get_ok()->set_text("Save");
+ layout_dialog->popup_centered();
+ } break;
+ case SETTINGS_LAYOUT_DELETE: {
+
+ current_option=p_id;
+ layout_dialog->set_title("Delete Layout");
+ layout_dialog->get_ok()->set_text("Delete");
+ layout_dialog->popup_centered();
+ } break;
+ case SETTINGS_LAYOUT_DEFAULT: {
+
+ _load_docks_from_config(default_layout, "docks");
+ _save_docks();
+ } break;
+ default: {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
+ if (err!=OK) {
+ return; //no config
+ }
+
+ _load_docks_from_config(config, editor_layouts->get_item_text(p_id));
+ _save_docks();
+ }
+ }
}
@@ -4386,11 +4612,13 @@ void EditorNode::_scene_tab_changed(int p_tab) {
editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0);
editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab);
editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab);
+ editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",p_tab);
editor_data.get_undo_redo().add_do_method(this,"set_current_version",next_scene_version==0?editor_data.get_undo_redo().get_version()+1:next_scene_version);
editor_data.get_undo_redo().add_undo_method(this,"set_current_version",next_scene_version);
editor_data.get_undo_redo().add_undo_method(this,"set_current_scene",editor_data.get_edited_scene());
editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene());
+ editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_tab,editor_data.get_edited_scene());
editor_data.get_undo_redo().add_undo_method(this,"set_current_version",saved_version);
editor_data.get_undo_redo().commit_action();
@@ -4451,6 +4679,8 @@ EditorNode::EditorNode() {
ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
+ EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
ResourceLoader::set_error_notify_func(this,_load_error_notify);
ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report);
@@ -4704,7 +4934,7 @@ EditorNode::EditorNode() {
scene_tabs=memnew( Tabs );
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_CENTER);
- scene_tabs->set_tab_close_display_policy(Tabs::SHOW_ACTIVE_ONLY);
+ scene_tabs->set_tab_close_display_policy(Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
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");
@@ -4855,7 +5085,11 @@ EditorNode::EditorNode() {
p->add_separator();
p->add_item("Revert Scene",EDIT_REVERT);
p->add_separator();
- p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_Q);
+#ifdef OSX_ENABLED
+ p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q);
+#else
+ p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q);
+#endif
p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q);
recent_scenes = memnew( PopupMenu );
@@ -4913,6 +5147,17 @@ EditorNode::EditorNode() {
p=import_menu->get_popup();
p->connect("item_pressed",this,"_menu_option");
+ tool_menu = memnew( MenuButton );
+ tool_menu->set_tooltip("Miscelaneous project or scene wide tools.");
+ tool_menu->set_text("Tools");
+
+ //tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
+ left_menu_hb->add_child( tool_menu );
+
+ p=tool_menu->get_popup();
+ p->connect("item_pressed",this,"_menu_option");
+ p->add_item("Orphan Resource Explorer",TOOLS_ORPHAN_RESOURCES);
+
export_button = memnew( ToolButton );
export_button->set_tooltip("Export the project to many platforms.");
export_button->set_text("Export");
@@ -5081,17 +5326,27 @@ EditorNode::EditorNode() {
right_menu_hb->add_child( settings_menu );
p=settings_menu->get_popup();
-
//p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
p->add_item("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("item_pressed",this,"_layout_menu_option");
+ p->add_submenu_item("Editor Layout", "Layouts");
+ p->add_separator();
p->add_check_item("Show Animation",SETTINGS_SHOW_ANIMATION,KEY_MASK_CMD+KEY_N);
p->add_separator();
p->add_item("Install Export Templates",SETTINGS_LOAD_EXPORT_TEMPLATES);
p->add_separator();
p->add_item("About",SETTINGS_ABOUT);
+ layout_dialog = memnew( EditorNameDialog );
+ gui_base->add_child(layout_dialog);
+ layout_dialog->set_hide_on_ok(false);
+ layout_dialog->set_size(Size2(175, 70));
+ layout_dialog->connect("name_confirmed", this,"_dialog_action");
sources_button = memnew( ToolButton );
right_menu_hb->add_child(sources_button);
@@ -5273,12 +5528,26 @@ EditorNode::EditorNode() {
scenes_dock = memnew( ScenesDock(this) );
scenes_dock->set_name("FileSystem");
+ scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS);
dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock);
//prop_pallete->add_child(scenes_dock);
scenes_dock->connect("open",this,"open_request");
scenes_dock->connect("instance",this,"_instance_request");
+ const String docks_section = "docks";
+
+ overridden_default_layout=-1;
+ default_layout.instance();
+ default_layout->set_value(docks_section, "dock_3", "Scene");
+ default_layout->set_value(docks_section, "dock_4", "FileSystem");
+ default_layout->set_value(docks_section, "dock_5", "Inspector");
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++)
+ default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0);
+ for(int i=0;i<DOCK_SLOT_MAX/2;i++)
+ default_layout->set_value(docks_section, "dock_split_"+itos(i+1), 0);
+
+ _update_layouts_menu();
log = memnew( EditorLog );
center_split->add_child(log);
@@ -5341,7 +5610,8 @@ EditorNode::EditorNode() {
-
+ orphan_resources = memnew( OrphanResourcesDialog );
+ gui_base->add_child(orphan_resources);
@@ -5418,7 +5688,7 @@ EditorNode::EditorNode() {
about->get_ok()->set_text("Thanks!");
about->set_hide_on_ok(true);
Label *about_text = memnew( Label );
- about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2015 Juan Linietsky, Ariel Manzur.\n");
+ about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2016 Juan Linietsky, Ariel Manzur.\n");
about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20));
gui_base->add_child(about);
about->add_child(about_text);
@@ -5533,6 +5803,7 @@ EditorNode::EditorNode() {
editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin)));
editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin)));
+ editor_import_export->add_export_plugin( Ref<EditorSceneExportPlugin>( memnew(EditorSceneExportPlugin)));
add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) );
add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
@@ -5570,7 +5841,8 @@ EditorNode::EditorNode() {
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( ColorRampEditorPlugin(this,true) ) );
+ add_editor_plugin( memnew( ColorRampEditorPlugin(this,false) ) );
add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) );
for(int i=0;i<EditorPlugins::get_plugin_count();i++)
@@ -5583,9 +5855,10 @@ EditorNode::EditorNode() {
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=OS::get_singleton()->get_frames_drawn();;
+ circle_step_frame=OS::get_singleton()->get_frames_drawn();
circle_step=0;
_rebuild_import_menu();