diff options
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r-- | tools/editor/editor_node.cpp | 112 |
1 files changed, 86 insertions, 26 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index eef148b405..40dce6cbaa 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -64,6 +64,8 @@ #include "addon_editor_plugin.h" #include "plugins/spatial_editor_plugin.h" #include "plugins/sample_editor_plugin.h" +#include "plugins/texture_editor_plugin.h" +#include "plugins/material_editor_plugin.h" #include "plugins/sample_library_editor_plugin.h" #include "plugins/sample_player_editor_plugin.h" #include "plugins/camera_editor_plugin.h" @@ -72,6 +74,7 @@ #include "plugins/item_list_editor_plugin.h" #include "plugins/stream_editor_plugin.h" #include "plugins/multimesh_editor_plugin.h" +#include "plugins/mesh_instance_editor_plugin.h" #include "plugins/mesh_editor_plugin.h" #include "plugins/theme_editor_plugin.h" @@ -285,6 +288,7 @@ void EditorNode::_notification(int p_what) { get_tree()->get_root()->set_as_audio_listener(false); get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->set_auto_accept_quit(false); + get_tree()->connect("files_dropped",this,"_dropped_files"); //VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),false); //import_monitor->scan_changes(); @@ -372,6 +376,7 @@ void EditorNode::_notification(int p_what) { _menu_option_confirm(DEPENDENCY_LOAD_CHANGED_IMAGES,true); } + waiting_for_sources_changed=true; EditorFileSystem::get_singleton()->scan_sources(); } @@ -409,6 +414,42 @@ void EditorNode::_fs_changed() { void EditorNode::_sources_changed(bool p_exist) { + if (p_exist && bool(EditorSettings::get_singleton()->get("import/automatic_reimport_on_sources_changed"))) { + p_exist=false; + + List<String> changed_sources; + EditorFileSystem::get_singleton()->get_changed_sources(&changed_sources); + + + EditorProgress ep("reimport",TTR("Re-Importing"),changed_sources.size()); + int step_idx=0; + + for(List<String>::Element *E=changed_sources.front();E;E=E->next()) { + + ep.step(TTR("Importing:")+" "+E->get(),step_idx++); + + Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(E->get()); + ERR_CONTINUE(rimd.is_null()); + String editor = rimd->get_editor(); + if (editor.begins_with("texture_")) { + editor="texture"; //compatibility fix for old versions + } + Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor); + ERR_CONTINUE(eip.is_null()); + Error err = eip->import(E->get(),rimd); + if (err!=OK) { + EditorNode::add_io_error("Error Re Importing:\n "+E->get()); + } + + } + + EditorFileSystem::get_singleton()->scan_sources(); + waiting_for_sources_changed=false; + + return; + } + + if (p_exist) { sources_button->set_icon(gui_base->get_icon("DependencyChanged","EditorIcons")); @@ -421,6 +462,8 @@ void EditorNode::_sources_changed(bool p_exist) { } + waiting_for_sources_changed=false; + } void EditorNode::_vp_resized() { @@ -432,13 +475,13 @@ void EditorNode::_rebuild_import_menu() { PopupMenu* p = import_menu->get_popup(); p->clear(); - p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE); - p->add_separator(); + //p->add_item(TTR("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); } - p->add_separator(); - p->add_item(TTR("Re-Import.."), SETTINGS_IMPORT); + //p->add_separator(); + //p->add_item(TTR("Re-Import.."), SETTINGS_IMPORT); } void EditorNode::_node_renamed() { @@ -941,6 +984,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { save.step(TTR("Creating Thumbnail"),3); Image img = VS::get_singleton()->viewport_get_screen_capture(viewport); int preview_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");; + preview_size*=EDSCALE; int width,height; if (img.get_width() > preview_size && img.get_width() >= img.get_height()) { @@ -2151,7 +2195,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String existing; if (extensions.size()) { - existing="new_scene."+extensions.front()->get().to_lower(); + String root_name(get_edited_scene()->get_name()); + existing=root_name+"."+extensions.front()->get().to_lower(); } file->set_current_path(existing); @@ -2345,7 +2390,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { confirmation->get_ok()->set_text(TTR("Quit")); //confirmation->get_cancel()->show(); confirmation->set_text(TTR("Exit the editor?")); - confirmation->popup_centered(Size2(180,70)); + confirmation->popup_centered(Size2(180,70)*EDSCALE); break; } @@ -2678,7 +2723,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (!p_confirmed) { confirmation->get_ok()->set_text(TTR("Yes")); - confirmation->set_text("Open Project Manager? \n(Unsaved changes will be lost)"); + confirmation->set_text(TTR("Open Project Manager? \n(Unsaved changes will be lost)")); confirmation->popup_centered_minsize(); break; } @@ -2688,8 +2733,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { String exec = OS::get_singleton()->get_executable_path(); List<String> args; - //args.push_back ( "-path" ); - //args.push_back (exec.get_base_dir() ); + args.push_back("-path"); + args.push_back(exec.get_base_dir()); args.push_back("-pm"); OS::ProcessID pid=0; @@ -2782,7 +2827,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case SETTINGS_ABOUT: { - about->popup_centered(Size2(500,130)); + about->popup_centered(Size2(500,130)*EDSCALE); } break; case SOURCES_REIMPORT: { @@ -2854,6 +2899,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; + default: { if (p_option>=OBJECT_METHOD_BASE) { @@ -4895,6 +4941,7 @@ Variant EditorNode::drag_resource(const Ref<Resource>& p_res,Control* p_from) { TextureFrame *drag_preview = memnew( TextureFrame ); Label* label=memnew( Label ); + waiting_for_sources_changed=true; // Ref<Texture> preview; { @@ -4996,6 +5043,15 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String>& p_files, Control * } + +void EditorNode::_dropped_files(const Vector<String>& p_files,int p_screen) { + + String cur_path = scenes_dock->get_current_path(); + for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) { + EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); + } +} + void EditorNode::_bind_methods() { @@ -5063,6 +5119,9 @@ 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("_dropped_files",&EditorNode::_dropped_files); + + 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); @@ -5167,7 +5226,7 @@ EditorNode::EditorNode() { //theme->set_icon("folder","EditorFileDialog",Theme::get_default()->get_icon("folder","EditorFileDialog")); //theme->set_color("files_disabled","EditorFileDialog",Color(0,0,0,0.7)); - String global_font = EditorSettings::get_singleton()->get("global/font"); + String global_font = EditorSettings::get_singleton()->get("global/custom_font"); if (global_font!="") { Ref<Font> fnt = ResourceLoader::load(global_font); if (fnt.is_valid()) { @@ -5323,7 +5382,7 @@ EditorNode::EditorNode() { dock_vb->add_child(dock_hb); dock_select = memnew( Control ); - dock_select->set_custom_minimum_size(Size2(128,64)); + dock_select->set_custom_minimum_size(Size2(128,64)*EDSCALE); dock_select->connect("input_event",this,"_dock_select_input"); dock_select->connect("draw",this,"_dock_select_draw"); dock_select->connect("mouse_exit",this,"_dock_popup_exit"); @@ -5338,7 +5397,7 @@ EditorNode::EditorNode() { //dock_select_popoup->set_(Size2(20,20)); for(int i=0;i<DOCK_SLOT_MAX;i++) { - dock_slot[i]->set_custom_minimum_size(Size2(230,220)); + dock_slot[i]->set_custom_minimum_size(Size2(230,220)*EDSCALE); 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)); @@ -5378,7 +5437,7 @@ EditorNode::EditorNode() { srt->add_child(scene_tabs); scene_root_parent = memnew( PanelContainer ); - scene_root_parent->set_custom_minimum_size(Size2(0,80)); + scene_root_parent->set_custom_minimum_size(Size2(0,80)*EDSCALE); //Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer"); @@ -5495,7 +5554,7 @@ EditorNode::EditorNode() { { Control *sp = memnew( Control ); - sp->set_custom_minimum_size(Size2(30,0)); + sp->set_custom_minimum_size(Size2(30,0)*EDSCALE); menu_hb->add_child(sp); } @@ -5684,7 +5743,7 @@ EditorNode::EditorNode() { { Control *sp = memnew( Control ); - sp->set_custom_minimum_size(Size2(30,0)); + sp->set_custom_minimum_size(Size2(30,0)*EDSCALE); menu_hb->add_child(sp); } @@ -5706,7 +5765,7 @@ EditorNode::EditorNode() { { Control *sp = memnew( Control ); - sp->set_custom_minimum_size(Size2(30,0)); + sp->set_custom_minimum_size(Size2(30,0)*EDSCALE); menu_hb->add_child(sp); } @@ -5742,7 +5801,7 @@ EditorNode::EditorNode() { 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->set_size(Size2(175, 70)*EDSCALE); layout_dialog->connect("name_confirmed", this,"_dialog_action"); sources_button = memnew( ToolButton ); @@ -5817,6 +5876,7 @@ EditorNode::EditorNode() { HBoxContainer *prop_editor_hb = memnew( HBoxContainer ); prop_editor_base->add_child(prop_editor_hb); + prop_editor_vb=prop_editor_base; resource_new_button = memnew( ToolButton ); resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it.")); @@ -6180,10 +6240,7 @@ EditorNode::EditorNode() { file_server = memnew( EditorFileServer ); - editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_TEXTURE_2D) ))); - editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_ATLAS) ))); - editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_LARGE) ))); - editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this,EditorTextureImportPlugin::MODE_TEXTURE_3D) ))); + editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this) ))); Ref<EditorSceneImportPlugin> _scene_import = memnew(EditorSceneImportPlugin(this) ); Ref<EditorSceneImporterCollada> _collada_import = memnew( EditorSceneImporterCollada); _scene_import->add_importer(_collada_import); @@ -6222,9 +6279,9 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( MultiMeshEditorPlugin(this) ) ); add_editor_plugin( memnew( MeshInstanceEditorPlugin(this) ) ); add_editor_plugin( memnew( AnimationTreeEditorPlugin(this) ) ); - add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); + //add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); - this is kind of useless at this point add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) ); - add_editor_plugin( memnew( StreamEditorPlugin(this) ) ); + //add_editor_plugin( memnew( StreamEditorPlugin(this) ) ); add_editor_plugin( memnew( StyleBoxEditorPlugin(this) ) ); add_editor_plugin( memnew( ParticlesEditorPlugin(this) ) ); add_editor_plugin( memnew( ResourcePreloaderEditorPlugin(this) ) ); @@ -6243,9 +6300,11 @@ 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,true) ) ); - add_editor_plugin( memnew( ColorRampEditorPlugin(this,false) ) ); + add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) ); add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) ); + add_editor_plugin( memnew( TextureEditorPlugin(this) ) ); + add_editor_plugin( memnew( MaterialEditorPlugin(this) ) ); + add_editor_plugin( memnew( MeshEditorPlugin(this) ) ); for(int i=0;i<EditorPlugins::get_plugin_count();i++) add_editor_plugin( EditorPlugins::create(i,this) ); @@ -6394,6 +6453,7 @@ EditorNode::EditorNode() { _load_docks(); + } |