diff options
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r-- | tools/editor/editor_node.cpp | 1013 |
1 files changed, 615 insertions, 398 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 4e22592880..79f5e66401 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 */ @@ -55,6 +55,7 @@ #include "bind/core_bind.h" #include "io/zip_io.h" #include "io/config_file.h" +#include "animation_editor.h" // plugins #include "plugins/sprite_frames_editor_plugin.h" @@ -102,6 +103,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 +144,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()); } @@ -161,17 +164,26 @@ void EditorNode::_update_title() { void EditorNode::_unhandled_input(const InputEvent& p_event) { - if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo) { + if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) { switch(p_event.key.scancode) { /*case KEY_F1: if (!p_event.key.mod.shift && !p_event.key.mod.command) - _editor_select(3); + _editor_select(EDITOR_SCRIPT); break;*/ - case KEY_F1: _editor_select(0); break; - case KEY_F2: _editor_select(1); break; - case KEY_F3: _editor_select(2); 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; @@ -289,7 +301,7 @@ void EditorNode::_notification(int p_what) { VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport(),true); VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true); - _editor_select(1); + _editor_select(EDITOR_3D); if (defer_load_scene!="") { @@ -405,7 +417,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); @@ -501,13 +513,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); @@ -519,11 +539,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); @@ -533,7 +553,6 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) { } - void EditorNode::_menu_option(int p_option) { _menu_option_confirm(p_option,false); @@ -575,59 +594,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); } @@ -879,7 +905,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { } } - _editor_select(is2d?0:1); + _editor_select(is2d?EDITOR_2D:EDITOR_3D); VS::get_singleton()->viewport_queue_screen_capture(viewport); save.step("Creating Thumbnail",2); @@ -945,8 +971,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); @@ -1153,75 +1195,6 @@ void EditorNode::_dialog_action(String p_file) { save_translatable_strings(p_file); } break; - case FILE_SAVE_SUBSCENE: { - - List<Node*> selection = editor_selection->get_selected_node_list(); - - if (selection.size()!=1) { - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation requieres a single selected node."); - accept->popup_centered_minsize(); - break; - } - - Node *base = selection.front()->get(); - - Map<Node*,Node*> reown; - reown[editor_data.get_edited_scene_root()]=base; - Node *copy = base->duplicate_and_reown(reown); - if (copy) { - - Ref<PackedScene> sdata = memnew( PackedScene ); - Error err = sdata->pack(copy); - memdelete(copy); - - if (err!=OK) { - - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Couldn't save subscene. Likely dependencies (instances) couldn't be satisfied."); - accept->popup_centered_minsize(); - return; - } - - int flg=0; - if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources")) - flg|=ResourceSaver::FLAG_COMPRESS; - if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative")) - flg|=ResourceSaver::FLAG_RELATIVE_PATHS; - - - err = ResourceSaver::save(p_file,sdata,flg); - if (err!=OK) { - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving scene."); - accept->popup_centered_minsize(); - break; - } - //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type()); - - } else { - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Error duplicating scene to save it."); - accept->popup_centered_minsize(); - break; - - } - - - } break; - case FILE_SAVE_SCENE: case FILE_SAVE_AS_SCENE: { @@ -1281,10 +1254,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.."); @@ -1293,9 +1274,6 @@ void EditorNode::_dialog_action(String p_file) { return; } - } - - if (ml.is_null()) { ml = Ref<TileSet>( memnew( TileSet )); } @@ -1400,6 +1378,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) { @@ -1553,6 +1590,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; } @@ -1701,7 +1742,7 @@ void EditorNode::_edit_current() { //p->add_item("All Methods",OBJECT_CALL_METHOD); - _update_keying(); + update_keying(); } void EditorNode::_resource_created() { @@ -1740,7 +1781,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")); @@ -1967,21 +2008,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; @@ -1999,7 +2040,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)"); @@ -2028,7 +2069,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(); @@ -2132,70 +2173,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { file->set_title("Save Translatable Strings"); file->popup_centered_ratio(); - - } break; - - case FILE_SAVE_SUBSCENE: { - - Node *scene = editor_data.get_edited_scene_root(); - - if (!scene) { - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation can't be done without a scene."); - accept->popup_centered_minsize(); - break; - } - - - List<Node*> selection = editor_selection->get_selected_node_list(); - - if (selection.size()!=1) { - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation requieres a single selected node."); - accept->popup_centered_minsize(); - break; - } - - Node *tocopy = selection.front()->get(); - - if (tocopy!=editor_data.get_edited_scene_root() && tocopy->get_filename()!="") { - - - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation can't be done on instanced scenes."); - accept->popup_centered_minsize(); - break; - } - - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); - - List<String> extensions; - Ref<PackedScene> sd = memnew( PackedScene ); - ResourceSaver::get_recognized_extensions(sd,&extensions); - file->clear_filters(); - for(int i=0;i<extensions.size();i++) { - - file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); - } - - - String existing; - if (extensions.size()) { - existing="new_scene."+extensions.front()->get().to_lower(); - } - file->set_current_path(existing); - - - file->popup_centered_ratio(); - file->set_title("Save Sub-Scene As.."); } break; case FILE_SAVE_OPTIMIZED: { Node *scene = editor_data.get_edited_scene_root(); @@ -2379,6 +2356,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: { @@ -2386,7 +2367,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (!scene) break; - + + String filename = scene->get_filename(); + + if (filename==String()) { + show_warning("Can't reload a scene that was never saved.."); + break; + } + if (unsaved_cache && !p_confirmed) { confirmation->get_ok()->set_text("Revert"); confirmation->set_text("This action cannot be undone. Revert anyway?"); @@ -2394,7 +2382,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { break; } - Error err = load_scene(scene->get_filename()); + + int cur_idx = editor_data.get_edited_scene(); + _remove_edited_scene(); + Error err = load_scene(filename); + editor_data.move_edited_scene_to_index(cur_idx); + get_undo_redo()->clear_history(); + scene_tabs->set_current_tab(cur_idx); } break; @@ -2519,7 +2513,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { case OBJECT_REQUEST_HELP: { if (current) { - _editor_select(3); + _editor_select(EDITOR_SCRIPT); emit_signal("request_help",current->get_type()); } @@ -2608,7 +2602,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); @@ -2733,11 +2727,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { //optimized_presets->popup_centered_ratio(); } break; - case SETTINGS_SHOW_ANIMATION: { - - animation_panel_make_visible( ! animation_panel->is_visible() ); - - } break; case SETTINGS_LOAD_EXPORT_TEMPLATES: { @@ -2987,7 +2976,7 @@ void EditorNode::set_edited_scene(Node *p_scene) { if (get_editor_data().get_edited_scene_root()) { if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root) scene_root->remove_child(get_editor_data().get_edited_scene_root()); - animation_editor->set_root(NULL); + } get_editor_data().set_edited_scene_root(p_scene); @@ -3000,7 +2989,7 @@ void EditorNode::set_edited_scene(Node *p_scene) { if (p_scene) { if (p_scene->get_parent()!=scene_root) scene_root->add_child(p_scene); - animation_editor->set_root(p_scene); + } } @@ -3056,7 +3045,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(""); @@ -3296,9 +3285,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) { int n2d=0,n3d=0; _find_node_types(get_edited_scene(),n2d,n3d); if (n2d>n3d) { - _editor_select(0); + _editor_select(EDITOR_2D); } else if (n3d>n2d) { - _editor_select(1); + _editor_select(EDITOR_3D); } } @@ -3319,6 +3308,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; } @@ -3332,15 +3323,25 @@ 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()); if (get_editor_data().get_edited_scene_root()) { if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root) scene_root->remove_child(get_editor_data().get_edited_scene_root()); - animation_editor->set_root(NULL); + } //print_line("set current 2 "); @@ -3362,7 +3363,7 @@ void EditorNode::set_current_scene(int p_idx) { if (new_scene) { if (new_scene->get_parent()!=scene_root) scene_root->add_child(new_scene); - animation_editor->set_root(new_scene); + } //print_line("set current 4 "); @@ -3410,11 +3411,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; + } } } @@ -3496,7 +3499,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); @@ -3534,16 +3548,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); @@ -3614,7 +3629,7 @@ void EditorNode::_instance_request(const String& p_path){ void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) { - animation_editor->insert_value_key(p_keyed,p_value,p_advance); + AnimationPlayerEditor::singleton->get_key_editor()->insert_value_key(p_keyed,p_value,p_advance); } void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform& p_key) { @@ -3622,16 +3637,16 @@ void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform Spatial *s=sp->cast_to<Spatial>(); if (!s) return; - animation_editor->insert_transform_key(s,p_sub,p_key); + AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s,p_sub,p_key); } -void EditorNode::_update_keying() { +void EditorNode::update_keying() { //print_line("KR: "+itos(p_enabled)); bool valid=false; - if (animation_editor->has_keying()) { + if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) { if (editor_history.get_path_size()>=1) { @@ -3665,6 +3680,7 @@ void EditorNode::_show_messages() { } +#if 0 void EditorNode::animation_panel_make_visible(bool p_visible) { if (!p_visible) { @@ -3677,6 +3693,7 @@ void EditorNode::animation_panel_make_visible(bool p_visible) { settings_menu->get_popup()->set_item_checked(idx,p_visible); } + void EditorNode::animation_editor_make_visible(bool p_visible) { if (p_visible) { @@ -3698,10 +3715,9 @@ void EditorNode::animation_editor_make_visible(bool p_visible) { } animation_editor->set_keying(p_visible); - _update_keying(); } - +#endif void EditorNode::_add_to_recent_scenes(const String& p_scene) { String base="_"+Globals::get_singleton()->get_resource_path().replace("\\","::").replace("/","::"); @@ -3794,24 +3810,26 @@ void EditorNode::_update_recent_scenes() { } -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) { @@ -3857,7 +3875,8 @@ bool EditorNode::_find_editing_changed_scene(Node *p_from) { void EditorNode::add_io_error(const String& p_error) { - + CharString err_ut = p_error.utf8(); + ERR_PRINT(err_ut.get_data()); _load_error_notify(singleton,p_error); } @@ -3930,9 +3949,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); } @@ -3961,87 +3980,6 @@ void EditorNode::progress_end_task_bg(const String& p_task) { } -void EditorNode::_bind_methods() { - - - ObjectTypeDB::bind_method("_menu_option",&EditorNode::_menu_option); - ObjectTypeDB::bind_method("_menu_confirm_current",&EditorNode::_menu_confirm_current); - ObjectTypeDB::bind_method("_dialog_action",&EditorNode::_dialog_action); - ObjectTypeDB::bind_method("_resource_selected",&EditorNode::_resource_selected,DEFVAL("")); - ObjectTypeDB::bind_method("_property_editor_forward",&EditorNode::_property_editor_forward); - ObjectTypeDB::bind_method("_property_editor_back",&EditorNode::_property_editor_back); - ObjectTypeDB::bind_method("_editor_select",&EditorNode::_editor_select); - ObjectTypeDB::bind_method("_node_renamed",&EditorNode::_node_renamed); - ObjectTypeDB::bind_method("edit_node",&EditorNode::edit_node); - ObjectTypeDB::bind_method("_imported",&EditorNode::_imported); - ObjectTypeDB::bind_method("_unhandled_input",&EditorNode::_unhandled_input); - - ObjectTypeDB::bind_method("_get_scene_metadata",&EditorNode::_get_scene_metadata); - ObjectTypeDB::bind_method("set_edited_scene",&EditorNode::set_edited_scene); - ObjectTypeDB::bind_method("open_request",&EditorNode::open_request); - ObjectTypeDB::bind_method("_instance_request",&EditorNode::_instance_request); - ObjectTypeDB::bind_method("_update_keying",&EditorNode::_update_keying); - ObjectTypeDB::bind_method("_property_keyed",&EditorNode::_property_keyed); - ObjectTypeDB::bind_method("_transform_keyed",&EditorNode::_transform_keyed); - ObjectTypeDB::bind_method("_close_messages",&EditorNode::_close_messages); - ObjectTypeDB::bind_method("_show_messages",&EditorNode::_show_messages); - ObjectTypeDB::bind_method("_vp_resized",&EditorNode::_vp_resized); - ObjectTypeDB::bind_method("_quick_opened",&EditorNode::_quick_opened); - ObjectTypeDB::bind_method("_quick_run",&EditorNode::_quick_run); - - ObjectTypeDB::bind_method("_resource_created",&EditorNode::_resource_created); - - ObjectTypeDB::bind_method("_import_action",&EditorNode::_import_action); - //ObjectTypeDB::bind_method("_import",&EditorNode::_import); -// ObjectTypeDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved); - ObjectTypeDB::bind_method("_open_recent_scene",&EditorNode::_open_recent_scene); -// ObjectTypeDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm); - - ObjectTypeDB::bind_method("_save_optimized",&EditorNode::_save_optimized); - ObjectTypeDB::bind_method(_MD("animation_panel_make_visible","enable"),&EditorNode::animation_panel_make_visible); - - ObjectTypeDB::bind_method("stop_child_process",&EditorNode::stop_child_process); - - ObjectTypeDB::bind_method("_sources_changed",&EditorNode::_sources_changed); - ObjectTypeDB::bind_method("_fs_changed",&EditorNode::_fs_changed); - ObjectTypeDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw); - ObjectTypeDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input); - ObjectTypeDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup); - ObjectTypeDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged); - ObjectTypeDB::bind_method("_save_docks",&EditorNode::_save_docks); - ObjectTypeDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit); - ObjectTypeDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left); - ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right); - - 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); - ObjectTypeDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed); - ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited); - ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state); - ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs); - - ObjectTypeDB::bind_method("_prepare_history",&EditorNode::_prepare_history); - ObjectTypeDB::bind_method("_select_history",&EditorNode::_select_history); - - ObjectTypeDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar); - ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box); - - 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); - ObjectTypeDB::bind_method(_MD("get_gui_base"), &EditorNode::get_gui_base); - - ADD_SIGNAL( MethodInfo("play_pressed") ); - ADD_SIGNAL( MethodInfo("pause_pressed") ); - ADD_SIGNAL( MethodInfo("stop_pressed") ); - ADD_SIGNAL( MethodInfo("hide_animation_player_editors") ); - ADD_SIGNAL( MethodInfo("request_help") ); - ADD_SIGNAL( MethodInfo("script_add_function_request",PropertyInfo(Variant::OBJECT,"obj"),PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::STRING_ARRAY,"args")) ); - ADD_SIGNAL( MethodInfo("resource_saved",PropertyInfo(Variant::OBJECT,"obj")) ); - - - -} Ref<Texture> EditorNode::_file_dialog_get_icon(const String& p_path) { @@ -4307,6 +4245,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++) { @@ -4317,7 +4264,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); } } @@ -4331,7 +4278,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()); } } @@ -4345,13 +4292,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() { @@ -4370,15 +4313,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++) { @@ -4398,7 +4352,7 @@ void EditorNode::_load_docks() { if (atidx==-1) //well, it's not anywhere continue; - if (atidx==j) { + if (atidx==i) { node->raise(); continue; } @@ -4413,7 +4367,6 @@ void EditorNode::_load_docks() { dock_slot[i]->add_child(node); dock_slot[i]->show(); } - } VSplitContainer*splits[DOCK_SLOT_MAX/2]={ @@ -4425,14 +4378,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, @@ -4440,9 +4393,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); } @@ -4460,8 +4413,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(); + } + } } @@ -4508,12 +4533,14 @@ void EditorNode::_scene_tab_changed(int p_tab) { editor_data.get_undo_redo().create_action("Switch Scene 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,"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,"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(); @@ -4543,6 +4570,183 @@ void EditorNode::_clear_search_box() { property_editor->update_tree(); } +ToolButton *EditorNode::add_bottom_panel_item(String p_text,Control *p_item) { + + ToolButton *tb = memnew( ToolButton ); + tb->connect("toggled",this,"_bottom_panel_switch",varray(bottom_panel_items.size())); + tb->set_text(p_text); + tb->set_toggle_mode(true); + tb->set_focus_mode(Control::FOCUS_NONE); + bottom_panel_vb->add_child(p_item); + bottom_panel_hb->raise(); + bottom_panel_hb->add_child(tb); + p_item->set_v_size_flags(Control::SIZE_EXPAND_FILL); + p_item->hide(); + BottomPanelItem bpi; + bpi.button=tb; + bpi.control=p_item; + bpi.name=p_text; + bottom_panel_items.push_back(bpi); + + return tb; + +} + +bool EditorNode::are_bottom_panels_hidden() const { + + for(int i=0;i<bottom_panel_items.size();i++) { + if (bottom_panel_items[i].button->is_pressed()) + return false; + } + + return true; +} + +void EditorNode::hide_bottom_panel() { + + _bottom_panel_switch(false,0); + +} + +void EditorNode::make_bottom_panel_item_visible(Control *p_item) { + + for(int i=0;i<bottom_panel_items.size();i++) { + + if (bottom_panel_items[i].control==p_item) { + _bottom_panel_switch(true,i); + break; + } + } +} + +void EditorNode::raise_bottom_panel_item(Control *p_item) { + + for(int i=0;i<bottom_panel_items.size();i++) { + + if (bottom_panel_items[i].control==p_item) { + bottom_panel_items[i].button->raise(); + SWAP( bottom_panel_items[i], bottom_panel_items[bottom_panel_items.size()-1]); + break; + } + } + + for(int i=0;i<bottom_panel_items.size();i++) { + bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch"); + bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i)); + } + +} + +void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) { + + ERR_FAIL_INDEX(p_idx,bottom_panel_items.size()); + + + + if (p_enable) { + for(int i=0;i<bottom_panel_items.size();i++) { + + bottom_panel_items[i].button->set_pressed(i==p_idx); + bottom_panel_items[i].control->set_hidden(i!=p_idx); + } + center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); + center_split->set_collapsed(false); + } else { + for(int i=0;i<bottom_panel_items.size();i++) { + + bottom_panel_items[i].button->set_pressed(false); + bottom_panel_items[i].control->set_hidden(true); + } + center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); + center_split->set_collapsed(true); + } +} + +void EditorNode::_bind_methods() { + + + ObjectTypeDB::bind_method("_menu_option",&EditorNode::_menu_option); + ObjectTypeDB::bind_method("_menu_confirm_current",&EditorNode::_menu_confirm_current); + ObjectTypeDB::bind_method("_dialog_action",&EditorNode::_dialog_action); + ObjectTypeDB::bind_method("_resource_selected",&EditorNode::_resource_selected,DEFVAL("")); + ObjectTypeDB::bind_method("_property_editor_forward",&EditorNode::_property_editor_forward); + ObjectTypeDB::bind_method("_property_editor_back",&EditorNode::_property_editor_back); + ObjectTypeDB::bind_method("_editor_select",&EditorNode::_editor_select); + ObjectTypeDB::bind_method("_node_renamed",&EditorNode::_node_renamed); + ObjectTypeDB::bind_method("edit_node",&EditorNode::edit_node); + ObjectTypeDB::bind_method("_imported",&EditorNode::_imported); + ObjectTypeDB::bind_method("_unhandled_input",&EditorNode::_unhandled_input); + + ObjectTypeDB::bind_method("_get_scene_metadata",&EditorNode::_get_scene_metadata); + ObjectTypeDB::bind_method("set_edited_scene",&EditorNode::set_edited_scene); + ObjectTypeDB::bind_method("open_request",&EditorNode::open_request); + ObjectTypeDB::bind_method("_instance_request",&EditorNode::_instance_request); + ObjectTypeDB::bind_method("update_keying",&EditorNode::update_keying); + ObjectTypeDB::bind_method("_property_keyed",&EditorNode::_property_keyed); + ObjectTypeDB::bind_method("_transform_keyed",&EditorNode::_transform_keyed); + ObjectTypeDB::bind_method("_close_messages",&EditorNode::_close_messages); + ObjectTypeDB::bind_method("_show_messages",&EditorNode::_show_messages); + ObjectTypeDB::bind_method("_vp_resized",&EditorNode::_vp_resized); + ObjectTypeDB::bind_method("_quick_opened",&EditorNode::_quick_opened); + ObjectTypeDB::bind_method("_quick_run",&EditorNode::_quick_run); + + ObjectTypeDB::bind_method("_resource_created",&EditorNode::_resource_created); + + ObjectTypeDB::bind_method("_import_action",&EditorNode::_import_action); + //ObjectTypeDB::bind_method("_import",&EditorNode::_import); +// ObjectTypeDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved); + ObjectTypeDB::bind_method("_open_recent_scene",&EditorNode::_open_recent_scene); +// ObjectTypeDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm); + + ObjectTypeDB::bind_method("_save_optimized",&EditorNode::_save_optimized); + + ObjectTypeDB::bind_method("stop_child_process",&EditorNode::stop_child_process); + + ObjectTypeDB::bind_method("_sources_changed",&EditorNode::_sources_changed); + ObjectTypeDB::bind_method("_fs_changed",&EditorNode::_fs_changed); + ObjectTypeDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw); + ObjectTypeDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input); + ObjectTypeDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup); + ObjectTypeDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged); + ObjectTypeDB::bind_method("_save_docks",&EditorNode::_save_docks); + ObjectTypeDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit); + 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); + ObjectTypeDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed); + ObjectTypeDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited); + ObjectTypeDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state); + ObjectTypeDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs); + + ObjectTypeDB::bind_method("_prepare_history",&EditorNode::_prepare_history); + ObjectTypeDB::bind_method("_select_history",&EditorNode::_select_history); + + 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); + ObjectTypeDB::bind_method(_MD("get_gui_base"), &EditorNode::get_gui_base); + ObjectTypeDB::bind_method(_MD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch); + + + ADD_SIGNAL( MethodInfo("play_pressed") ); + ADD_SIGNAL( MethodInfo("pause_pressed") ); + ADD_SIGNAL( MethodInfo("stop_pressed") ); + ADD_SIGNAL( MethodInfo("request_help") ); + ADD_SIGNAL( MethodInfo("script_add_function_request",PropertyInfo(Variant::OBJECT,"obj"),PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::STRING_ARRAY,"args")) ); + ADD_SIGNAL( MethodInfo("resource_saved",PropertyInfo(Variant::OBJECT,"obj")) ); + + + +} + EditorNode::EditorNode() { EditorHelp::generate_doc(); //before any editor classes are crated @@ -4574,6 +4778,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); @@ -4827,7 +5033,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"); @@ -4857,8 +5063,9 @@ EditorNode::EditorNode() { //scene_root_base->add_child(scene_root); - scene_root->set_meta("_editor_disable_input",true); + //scene_root->set_meta("_editor_disable_input",true); VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport(),true); + scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); @@ -4873,44 +5080,6 @@ EditorNode::EditorNode() { scene_root_parent->add_child(viewport); - PanelContainer *pc = memnew( PanelContainer ); - top_split->add_child(pc); - animation_vb = memnew( VBoxContainer ); - animation_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); - pc->add_child(animation_vb); - animation_panel=pc; - animation_panel->hide(); - - - HBoxContainer *animation_hb = memnew( HBoxContainer); - animation_vb->add_child(animation_hb); - - Label *l= memnew( Label ); - l->set_text("Animation:"); - //l->set_h_size_flags(Control::SIZE_); - animation_hb->add_child(l); - - animation_panel_hb = memnew( HBoxContainer ); - animation_hb->add_child(animation_panel_hb); - animation_panel_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - - - /*pd_anim = memnew( PaneDrag ); - animation_hb->add_child(pd_anim); - pd_anim->connect("dragged",this,"_dragged"); - pd_anim->set_default_cursor_shape(Control::CURSOR_MOVE); - pd_anim->hide();*/ - - anim_close = memnew( TextureButton ); - animation_hb->add_child(anim_close); - anim_close->connect("pressed",this,"animation_panel_make_visible",make_binds(false)); - anim_close->set_normal_texture( anim_close->get_icon("Close","EditorIcons")); - anim_close->set_hover_texture( anim_close->get_icon("CloseHover","EditorIcons")); - anim_close->set_pressed_texture( anim_close->get_icon("Close","EditorIcons")); - - - - PanelContainer *top_region = memnew( PanelContainer ); top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button")); HBoxContainer *left_menu_hb = memnew( HBoxContainer ); @@ -4962,7 +5131,6 @@ EditorNode::EditorNode() { pm_export->set_name("Export"); p->add_child(pm_export); p->add_submenu_item("Convert To..","Export"); - pm_export->add_item("Subscene..",FILE_SAVE_SUBSCENE); pm_export->add_item("Translatable Strings..",FILE_DUMP_STRINGS); pm_export->add_separator(); pm_export->add_item("MeshLibrary..",FILE_EXPORT_MESH_LIBRARY); @@ -4979,7 +5147,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 ); @@ -5037,6 +5209,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"); @@ -5205,17 +5388,25 @@ 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(); - p->add_check_item("Show Animation",SETTINGS_SHOW_ANIMATION,KEY_MASK_CMD+KEY_N); + 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_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); @@ -5370,7 +5561,7 @@ EditorNode::EditorNode() { prop_editor_base->add_child(search_bar); search_bar->hide(); - l = memnew( Label("Search: ") ); + Label *l = memnew( Label("Search: ") ); search_bar->add_child(l); search_box = memnew( LineEdit ); @@ -5397,44 +5588,61 @@ 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"); - log = memnew( EditorLog ); - center_split->add_child(log); - log->connect("close_request",this,"_close_messages"); - log->connect("show_request",this,"_show_messages"); - //left_split->set_dragger_visible(false); + 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(); - old_split_ofs=0; + bottom_panel = memnew( PanelContainer ); + bottom_panel->add_style_override("panel",gui_base->get_stylebox("panelf","Panel")); + center_split->add_child(bottom_panel); + center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); + bottom_panel_vb = memnew( VBoxContainer ); + bottom_panel->add_child(bottom_panel_vb); + //bottom_panel_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); - animation_editor = memnew( AnimationKeyEditor(get_undo_redo(),&editor_history,editor_selection) ); - animation_editor->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,0); - animation_editor->set_margin(MARGIN_BOTTOM,200); - animation_editor->connect("keying_changed",this,"_update_keying"); + bottom_panel_hb = memnew( HBoxContainer ); + bottom_panel_vb->add_child(bottom_panel_hb); - animation_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); - animation_vb->add_child(animation_editor); - center_split->connect("resized",this,"_vp_resized"); + log = memnew( EditorLog ); + + add_bottom_panel_item("Output",log); + + //left_split->set_dragger_visible(false); - animation_editor->hide(); + old_split_ofs=0; + + center_split->connect("resized",this,"_vp_resized"); + /*PanelContainer *bottom_pc = memnew( PanelContainer ); srt->add_child(bottom_pc); bottom_hb = memnew( HBoxContainer ); bottom_pc->add_child(bottom_hb);*/ - center_vb->add_child( log->get_button() ); - log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL); + +// center_vb->add_child( log->get_button() ); +// log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL); //progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -5465,7 +5673,8 @@ EditorNode::EditorNode() { - + orphan_resources = memnew( OrphanResourcesDialog ); + gui_base->add_child(orphan_resources); @@ -5542,7 +5751,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); @@ -5633,7 +5842,7 @@ EditorNode::EditorNode() { file_templates->connect("file_selected", this,"_dialog_action"); property_editor->connect("resource_selected", this,"_resource_selected"); property_editor->connect("property_keyed", this,"_property_keyed"); - animation_editor->connect("resource_selected", this,"_resource_selected"); + //plugin stuff file_server = memnew( EditorFileServer ); @@ -5657,11 +5866,17 @@ 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( AnimationPlayerEditorPlugin(this) ) ); add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) ); add_editor_plugin( memnew( SpatialEditorPlugin(this) ) ); add_editor_plugin( memnew( ScriptEditorPlugin(this) ) ); - add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) ); + + //more visually meaningful to have this later + raise_bottom_panel_item(AnimationPlayerEditor::singleton); + add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) ); add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) ); add_editor_plugin( memnew( ShaderEditorPlugin(this,true) ) ); @@ -5694,7 +5909,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++) @@ -5707,9 +5923,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(); |