From 565600e8445a3073e4188a1a2bde1f47dd299c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 26 Aug 2017 17:46:49 +0200 Subject: [PATCH] Cleanup tons of obsolete commented out code Mostly in EditorNode, dropping some obsolete editor plugins and also a cleanup of ProjectSettings/EditorSettings. --- core/io/resource_format_binary.cpp | 21 +- editor/code_editor.cpp | 1 - editor/editor_node.cpp | 989 ++---------------- editor/editor_node.h | 76 +- editor/editor_settings.cpp | 36 +- .../io_plugins/editor_scene_import_plugin.cpp | 8 - .../animation_player_editor_plugin.cpp | 5 - .../asset_library_editor_plugin.cpp | 0 .../asset_library_editor_plugin.h | 0 editor/plugins/editor_preview_plugins.cpp | 18 +- editor/plugins/editor_preview_plugins.h | 3 +- editor/plugins/material_editor_plugin.cpp | 6 +- editor/plugins/material_editor_plugin.h | 7 +- editor/plugins/rich_text_editor_plugin.cpp | 151 --- editor/plugins/rich_text_editor_plugin.h | 90 -- editor/plugins/sample_editor_plugin.cpp | 452 -------- editor/plugins/sample_editor_plugin.h | 93 -- .../plugins/sample_library_editor_plugin.cpp | 547 ---------- editor/plugins/sample_library_editor_plugin.h | 108 -- .../plugins/sample_player_editor_plugin.cpp | 202 ---- editor/plugins/sample_player_editor_plugin.h | 91 -- editor/plugins/script_editor_plugin.cpp | 17 +- editor/plugins/shader_editor_plugin.cpp | 13 +- editor/plugins/shader_graph_editor_plugin.cpp | 4 +- editor/plugins/shader_graph_editor_plugin.h | 9 +- editor/project_manager.h | 2 +- editor/project_settings_editor.cpp | 90 +- editor/project_settings_editor.h | 15 +- editor/property_editor.cpp | 331 +----- editor/property_editor.h | 9 +- editor/resources_dock.cpp | 378 ------- editor/resources_dock.h | 99 -- editor/scene_tree_dock.cpp | 134 +-- editor/scene_tree_dock.h | 19 +- editor/spatial_editor_gizmos.cpp | 8 - scene/register_scene_types.cpp | 236 ++--- scene/resources/gibberish_stream.cpp | 337 ------ scene/resources/gibberish_stream.h | 118 --- scene/resources/material.cpp | 1 + 39 files changed, 338 insertions(+), 4386 deletions(-) rename editor/{ => plugins}/asset_library_editor_plugin.cpp (100%) rename editor/{ => plugins}/asset_library_editor_plugin.h (100%) delete mode 100644 editor/plugins/rich_text_editor_plugin.cpp delete mode 100644 editor/plugins/rich_text_editor_plugin.h delete mode 100644 editor/plugins/sample_editor_plugin.cpp delete mode 100644 editor/plugins/sample_editor_plugin.h delete mode 100644 editor/plugins/sample_library_editor_plugin.cpp delete mode 100644 editor/plugins/sample_library_editor_plugin.h delete mode 100644 editor/plugins/sample_player_editor_plugin.cpp delete mode 100644 editor/plugins/sample_player_editor_plugin.h delete mode 100644 editor/resources_dock.cpp delete mode 100644 editor/resources_dock.h delete mode 100644 scene/resources/gibberish_stream.cpp delete mode 100644 scene/resources/gibberish_stream.h diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index b8e0bbf557f7..0977b03e2f52 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -28,12 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_format_binary.h" -#include "image.h" -#include "io/file_access_compressed.h" -#include "io/marshalls.h" -#include "os/dir_access.h" -#include "project_settings.h" -#include "version.h" + +#include "core/image.h" +#include "core/io/file_access_compressed.h" +#include "core/io/marshalls.h" +#include "core/os/dir_access.h" +#include "core/project_settings.h" +#include "core/version.h" + //#define print_bl(m_what) print_line(m_what) #define print_bl(m_what) @@ -1798,7 +1800,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } ERR_FAIL_COND_V(err, err); - FileAccessRef _fref(f); relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS; skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; @@ -1810,7 +1811,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p takeover_paths = false; local_path = p_path.get_base_dir(); - //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create _find_resources(p_resource, true); @@ -1836,7 +1836,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p return ERR_CANT_CREATE; } - //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed save_unicode_string(p_resource->get_class()); uint64_t md_at = f->get_pos(); f->store_64(0); //offset to impoty metadata @@ -1875,7 +1874,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p f->store_32(strings.size()); //string table size for (int i = 0; i < strings.size(); i++) { - //print_bl("saving string: "+strings[i]); save_unicode_string(strings[i]); } @@ -1944,9 +1942,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } Vector ofs_table; - //int saved_idx=0; - //now actually save the resources + //now actually save the resources for (List::Element *E = resources.front(); E; E = E->next()) { ResourceData &rd = E->get(); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d49b240c800b..889c750cf925 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1228,7 +1228,6 @@ CodeTextEditor::CodeTextEditor() { error->set_valign(Label::VALIGN_CENTER); error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9)); error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch - //status_bar->add_spacer(); Label *line_txt = memnew(Label); status_bar->add_child(line_txt); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f5c714fc60a2..c07055114d1d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -29,102 +29,96 @@ /*************************************************************************/ #include "editor_node.h" -#include "animation_editor.h" -#include "bind/core_bind.h" -#include "class_db.h" +#include "core/bind/core_bind.h" +#include "core/class_db.h" +#include "core/io/config_file.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "editor_file_system.h" -#include "editor_help.h" -#include "editor_settings.h" -#include "editor_themes.h" -#include "io/config_file.h" -#include "io/stream_peer_ssl.h" -#include "io/zip_io.h" +#include "core/io/stream_peer_ssl.h" +#include "core/io/zip_io.h" +#include "core/message_queue.h" +#include "core/os/file_access.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" +#include "core/path_remap.h" +#include "core/print_string.h" +#include "core/project_settings.h" +#include "core/translation.h" +#include "core/version.h" #include "main/input_default.h" -#include "message_queue.h" -#include "os/file_access.h" -#include "os/input.h" -#include "os/keyboard.h" -#include "os/os.h" -#include "path_remap.h" -#include "print_string.h" -#include "project_settings.h" -#include "pvrtc_compress.h" -#include "register_exporters.h" #include "scene/resources/packed_scene.h" #include "servers/physics_2d_server.h" -#include "translation.h" -#include "version.h" -#include -// plugins -#include "asset_library_editor_plugin.h" -#include "import/resource_importer_csv_translation.h" -#include "import/resource_importer_obj.h" -#include "import/resource_importer_scene.h" -#include "import/resource_importer_texture.h" -#include "import/resource_importer_wav.h" -#include "plugins/animation_player_editor_plugin.h" -#include "plugins/animation_tree_editor_plugin.h" -#include "plugins/baked_light_editor_plugin.h" -#include "plugins/camera_editor_plugin.h" -#include "plugins/canvas_item_editor_plugin.h" -#include "plugins/collision_polygon_2d_editor_plugin.h" -#include "plugins/collision_polygon_editor_plugin.h" -#include "plugins/collision_shape_2d_editor_plugin.h" -#include "plugins/cube_grid_theme_editor_plugin.h" -#include "plugins/curve_editor_plugin.h" -#include "plugins/gi_probe_editor_plugin.h" -#include "plugins/gradient_editor_plugin.h" -#include "plugins/item_list_editor_plugin.h" -#include "plugins/light_occluder_2d_editor_plugin.h" -#include "plugins/line_2d_editor_plugin.h" -#include "plugins/material_editor_plugin.h" -#include "plugins/mesh_editor_plugin.h" -#include "plugins/mesh_instance_editor_plugin.h" -#include "plugins/multimesh_editor_plugin.h" -#include "plugins/navigation_polygon_editor_plugin.h" -#include "plugins/particles_2d_editor_plugin.h" -#include "plugins/particles_editor_plugin.h" -#include "plugins/path_2d_editor_plugin.h" -#include "plugins/path_editor_plugin.h" -#include "plugins/polygon_2d_editor_plugin.h" -#include "plugins/resource_preloader_editor_plugin.h" -#include "plugins/rich_text_editor_plugin.h" -#include "plugins/sample_editor_plugin.h" -#include "plugins/sample_library_editor_plugin.h" -#include "plugins/sample_player_editor_plugin.h" -#include "plugins/script_editor_plugin.h" -#include "plugins/script_text_editor.h" -#include "plugins/shader_editor_plugin.h" -#include "plugins/shader_graph_editor_plugin.h" -#include "plugins/spatial_editor_plugin.h" -#include "plugins/sprite_frames_editor_plugin.h" -#include "plugins/stream_editor_plugin.h" -#include "plugins/style_box_editor_plugin.h" -#include "plugins/texture_editor_plugin.h" -#include "plugins/texture_region_editor_plugin.h" -#include "plugins/theme_editor_plugin.h" -#include "plugins/tile_map_editor_plugin.h" -#include "plugins/tile_set_editor_plugin.h" -// end -#include "editor_settings.h" -#include "import/editor_import_collada.h" -#include "import/editor_scene_importer_gltf.h" -#include "io_plugins/editor_bitmask_import_plugin.h" -#include "io_plugins/editor_export_scene.h" -#include "io_plugins/editor_font_import_plugin.h" -#include "io_plugins/editor_mesh_import_plugin.h" -#include "io_plugins/editor_sample_import_plugin.h" -#include "io_plugins/editor_scene_import_plugin.h" -#include "io_plugins/editor_scene_importer_fbxconv.h" -#include "io_plugins/editor_texture_import_plugin.h" -#include "io_plugins/editor_translation_import_plugin.h" -#include "editor_audio_buses.h" -#include "editor_initialize_ssl.h" -#include "plugins/editor_preview_plugins.h" -#include "script_editor_debugger.h" +#include "editor/animation_editor.h" +#include "editor/editor_audio_buses.h" +#include "editor/editor_file_system.h" +#include "editor/editor_help.h" +#include "editor/editor_initialize_ssl.h" +#include "editor/editor_settings.h" +#include "editor/editor_settings.h" +#include "editor/editor_themes.h" +#include "editor/import/editor_import_collada.h" +#include "editor/import/editor_scene_importer_gltf.h" +#include "editor/import/resource_importer_csv_translation.h" +#include "editor/import/resource_importer_obj.h" +#include "editor/import/resource_importer_scene.h" +#include "editor/import/resource_importer_texture.h" +#include "editor/import/resource_importer_wav.h" +#include "editor/io_plugins/editor_bitmask_import_plugin.h" +#include "editor/io_plugins/editor_export_scene.h" +#include "editor/io_plugins/editor_font_import_plugin.h" +#include "editor/io_plugins/editor_mesh_import_plugin.h" +#include "editor/io_plugins/editor_scene_import_plugin.h" +#include "editor/io_plugins/editor_scene_importer_fbxconv.h" +#include "editor/io_plugins/editor_texture_import_plugin.h" +#include "editor/io_plugins/editor_translation_import_plugin.h" +#include "editor/plugins/animation_player_editor_plugin.h" +#include "editor/plugins/animation_tree_editor_plugin.h" +#include "editor/plugins/asset_library_editor_plugin.h" +#include "editor/plugins/baked_light_editor_plugin.h" +#include "editor/plugins/camera_editor_plugin.h" +#include "editor/plugins/canvas_item_editor_plugin.h" +#include "editor/plugins/collision_polygon_2d_editor_plugin.h" +#include "editor/plugins/collision_polygon_editor_plugin.h" +#include "editor/plugins/collision_shape_2d_editor_plugin.h" +#include "editor/plugins/cube_grid_theme_editor_plugin.h" +#include "editor/plugins/curve_editor_plugin.h" +#include "editor/plugins/editor_preview_plugins.h" +#include "editor/plugins/gi_probe_editor_plugin.h" +#include "editor/plugins/gradient_editor_plugin.h" +#include "editor/plugins/item_list_editor_plugin.h" +#include "editor/plugins/light_occluder_2d_editor_plugin.h" +#include "editor/plugins/line_2d_editor_plugin.h" +#include "editor/plugins/material_editor_plugin.h" +#include "editor/plugins/mesh_editor_plugin.h" +#include "editor/plugins/mesh_instance_editor_plugin.h" +#include "editor/plugins/multimesh_editor_plugin.h" +#include "editor/plugins/navigation_polygon_editor_plugin.h" +#include "editor/plugins/particles_2d_editor_plugin.h" +#include "editor/plugins/particles_editor_plugin.h" +#include "editor/plugins/path_2d_editor_plugin.h" +#include "editor/plugins/path_editor_plugin.h" +#include "editor/plugins/polygon_2d_editor_plugin.h" +#include "editor/plugins/resource_preloader_editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" +#include "editor/plugins/script_text_editor.h" +#include "editor/plugins/shader_editor_plugin.h" +#include "editor/plugins/shader_graph_editor_plugin.h" +#include "editor/plugins/spatial_editor_plugin.h" +#include "editor/plugins/sprite_frames_editor_plugin.h" +#include "editor/plugins/stream_editor_plugin.h" +#include "editor/plugins/style_box_editor_plugin.h" +#include "editor/plugins/texture_editor_plugin.h" +#include "editor/plugins/texture_region_editor_plugin.h" +#include "editor/plugins/theme_editor_plugin.h" +#include "editor/plugins/tile_map_editor_plugin.h" +#include "editor/plugins/tile_set_editor_plugin.h" +#include "editor/pvrtc_compress.h" +#include "editor/register_exporters.h" +#include "editor/script_editor_debugger.h" + +#include EditorNode *EditorNode::singleton = NULL; @@ -223,18 +217,6 @@ void EditorNode::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { -//force the whole tree viewport -#if 0 - { - Rect2 grect = scene_root_base->get_global_rect(); - Rect2 grectsrp = scene_root_parent->get_global_rect(); - if (grect!=grectsrp) { - scene_root_parent->set_position(grect.pos); - scene_root_parent->set_size(grect.size); - } - } - -#endif if (opening_prev && !confirmation->is_visible()) opening_prev = false; @@ -249,8 +231,6 @@ void EditorNode::_notification(int p_what) { last_checked_version = editor_data.get_undo_redo().get_version(); } - //get_root_node()->set_rect(viewport->get_global_rect()); - //update the circle uint64_t frame = Engine::get_singleton()->get_frames_drawn(); uint32_t tick = OS::get_singleton()->get_ticks_msec(); @@ -280,14 +260,10 @@ void EditorNode::_notification(int p_what) { Engine::get_singleton()->set_editor_hint(true); get_tree()->get_root()->set_disable_3d(true); - //MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata"); 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(); } if (p_what == NOTIFICATION_EXIT_TREE) { @@ -302,25 +278,6 @@ void EditorNode::_notification(int p_what) { _editor_select(EDITOR_3D); _update_debug_options(); - - /* - if (defer_optimize!="") { - Error ok = save_optimized_copy(defer_optimize,defer_optimize_preset); - defer_optimize_preset=""; - if (ok!=OK) - OS::get_singleton()->set_exit_code(255); - get_scene()->quit(); - } -*/ - - /* // moved to "_sources_changed" - if (export_defer.platform!="") { - - project_export_settings->export_platform(export_defer.platform,export_defer.path,export_defer.debug,export_defer.password,true); - export_defer.platform=""; - } - - */ } if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { @@ -391,13 +348,12 @@ void EditorNode::_fs_changed() { } { - //reload changed resources List > changed; List > cached; ResourceCache::get_cached_resources(&cached); - //this should probably be done in a thread.. + // FIXME: This should be done in a thread. for (List >::Element *E = cached.front(); E; E = E->next()) { if (!E->get()->editor_can_reload_from_file()) @@ -410,7 +366,6 @@ void EditorNode::_fs_changed() { if (E->get()->get_import_path() != String()) { //imported resource uint64_t mt = FileAccess::get_modified_time(E->get()->get_import_path()); - print_line("testing modified: " + E->get()->get_import_path() + " " + itos(mt) + " vs " + itos(E->get()->get_import_last_modified_time())); if (mt != E->get()->get_import_last_modified_time()) { print_line("success"); @@ -427,11 +382,8 @@ void EditorNode::_fs_changed() { } if (changed.size()) { - //EditorProgress ep("reload_res","Reload Modified Resources",changed.size()); int idx = 0; for (List >::Element *E = changed.front(); E; E = E->next()) { - - //ep.step(E->get()->get_path(),idx++); E->get()->reload_from_file(); } } @@ -521,8 +473,6 @@ void EditorNode::open_resource(const String &p_type) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - //file->set_current_path(current_path); - file->popup_centered_ratio(); current_option = RESOURCE_LOAD; } @@ -533,10 +483,6 @@ void EditorNode::save_resource_in_path(const Ref &p_resource, const St int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; - /* - if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative")) - flg|=ResourceSaver::FLAG_RELATIVE_PATHS; - */ String path = ProjectSettings::get_singleton()->localize_path(p_path); Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); @@ -546,7 +492,6 @@ void EditorNode::save_resource_in_path(const Ref &p_resource, const St accept->popup_centered_minsize(); return; } - //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type()); ((Resource *)p_resource.ptr())->set_path(path); emit_signal("resource_saved", p_resource); @@ -582,8 +527,6 @@ void EditorNode::save_resource_as(const Ref &p_resource, const String preferred.push_back(extensions[i]); } - //file->set_current_path(current_path); - if (p_at_path != String()) { file->set_current_dir(p_at_path); @@ -632,7 +575,6 @@ void EditorNode::_dialog_display_file_error(String p_file, Error p_error) { if (p_error) { current_option = -1; - //accept->"()->hide(); accept->get_ok()->set_text(TTR("I see..")); switch (p_error) { @@ -736,8 +678,6 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map &processed, i bool subchanged = _find_and_save_edited_subresources(p_res.ptr(), processed, flags); - //print_line("checking if edited: "+p_res->get_type()+" :: "+p_res->get_name()+" :: "+p_res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged)); - if (p_res->get_path().is_resource_file()) { if (changed || subchanged) { //save @@ -782,8 +722,6 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map RES res = v; if (_find_and_save_resource(res, processed, flags)) ret_changed = true; - - //_find_resources(v); } } break; @@ -836,11 +774,11 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { void EditorNode::_save_scene_with_preview(String p_file) { - int c2d = 0; - int c3d = 0; - EditorProgress save("save", TTR("Saving Scene"), 4); save.step(TTR("Analyzing"), 0); + + int c2d = 0; + int c3d = 0; _find_node_types(editor_data.get_edited_scene_root(), c2d, c3d); RID viewport; @@ -911,7 +849,6 @@ void EditorNode::_save_scene(String p_file, int idx) { if (!scene) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("This operation can't be done without a tree root.")); accept->popup_centered_minsize(); @@ -943,7 +880,6 @@ void EditorNode::_save_scene(String p_file, int idx) { if (err != OK) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied.")); accept->popup_centered_minsize(); @@ -958,10 +894,6 @@ void EditorNode::_save_scene(String p_file, int idx) { int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; - /* - if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative")) - flg|=ResourceSaver::FLAG_RELATIVE_PATHS; - */ flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; err = ResourceSaver::save(p_file, sdata, flg); @@ -970,7 +902,6 @@ void EditorNode::_save_scene(String p_file, int idx) { editor_data.save_editor_external_data(); if (err == OK) { scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file)); - //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type()); if (idx < 0 || idx == editor_data.get_edited_scene()) set_current_version(editor_data.get_undo_redo().get_version()); else @@ -1019,106 +950,6 @@ void EditorNode::_mark_unsaved_scenes() { _update_scene_tabs(); } -void EditorNode::_import_action(const String &p_action) { -#if 0 - import_confirmation->hide(); - - if (p_action=="re-import") { - _import(_tmp_import_path); - } - if (p_action=="update") { - - Node *src = EditorImport::import_scene(_tmp_import_path); - - if (!src) { - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error importing scene."); - accept->popup_centered(Size2(300,70)); - return; - } - - //as soon as the scene is imported, version hashes must be generated for comparison against saved scene - EditorImport::generate_version_hashes(src); - - - Node *dst = SceneLoader::load(editor_data.get_imported_scene(ProjectSettings::get_singleton()->localize_path(_tmp_import_path))); - - if (!dst) { - - memdelete(src); - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error load scene to update."); - accept->popup_centered(Size2(300,70)); - return; - } - - List conflicts; - EditorImport::check_conflicts(src,dst,&conflicts); - - bool conflicted=false; - for (List::Element *E=conflicts.front();E;E=E->next()) { - - - if (E->get().status==EditorImport::Conflict::STATUS_CONFLICT) { - - conflicted=true; - break; - } - } - - if (conflicted) { - import_conflicts_dialog->popup(src,dst,conflicts); - return; - } - - _import_with_conflicts(src,dst,conflicts); - //not conflicted, just reimport! - - } -#endif -} - -void EditorNode::_import(const String &p_file) { - -#if 0 - Node *new_scene = EditorImport::import_scene(p_file); - - if (!new_scene) { - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error importing scene."); - accept->popup_centered(Size2(300,70)); - return; - } - - //as soon as the scene is imported, version hashes must be generated for comparison against saved scene - EditorImport::generate_version_hashes(new_scene); - - Node *old_scene = edited_scene; - _hide_top_editors(); - set_edited_scene(NULL); - editor_data.clear_editor_states(); - if (old_scene) { - memdelete(old_scene); - } - - set_edited_scene(new_scene); - scene_tree_dock->set_selected(new_scene); - //_get_scene_metadata(); - - editor_data.get_undo_redo().clear_history(); - saved_version=editor_data.get_undo_redo().get_version(); - _update_title(); - -#endif -} - void EditorNode::_dialog_action(String p_file) { switch (current_option) { @@ -1129,7 +960,6 @@ void EditorNode::_dialog_action(String p_file) { if (res.is_null()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text("ok :("); accept->set_text(TTR("Failed to load resource.")); return; @@ -1151,9 +981,6 @@ void EditorNode::_dialog_action(String p_file) { ProjectSettings::get_singleton()->save(); //would be nice to show the project manager opened with the highlighted field.. _run(false, ""); // automatically run the project - } break; - case FILE_SAVE_OPTIMIZED: { - } break; case FILE_RUN_SCRIPT: { @@ -1186,7 +1013,6 @@ void EditorNode::_dialog_action(String p_file) { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { - //_save_scene(p_file); _save_default_environment(); _save_scene_with_preview(p_file); @@ -1199,7 +1025,6 @@ void EditorNode::_dialog_action(String p_file) { case FILE_SAVE_AND_RUN: { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { - //_save_scene(p_file); _save_default_environment(); _save_scene_with_preview(p_file); _call_build(); @@ -1215,7 +1040,6 @@ void EditorNode::_dialog_action(String p_file) { if (ml.is_null()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Can't load MeshLibrary for merging!")); accept->popup_centered_minsize(); @@ -1248,7 +1072,6 @@ void EditorNode::_dialog_action(String p_file) { if (ml.is_null()) { if (file_export_lib_merge->is_pressed()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Can't load TileSet for merging!")); accept->popup_centered_minsize(); @@ -1274,10 +1097,6 @@ void EditorNode::_dialog_action(String p_file) { } } break; - // case SETTINGS_LOAD_EXPORT_TEMPLATES: { - - // } break; - case RESOURCE_SAVE: case RESOURCE_SAVE_AS: { @@ -1353,8 +1172,6 @@ void EditorNode::_dialog_action(String p_file) { default: { //save scene? if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { - - //_save_scene(p_file); _save_scene_with_preview(p_file); } @@ -1465,20 +1282,6 @@ void EditorNode::_save_default_environment() { } } -void EditorNode::_imported(Node *p_node) { - - /* - Node *scene = editor_data.get_edited_scene_root(); - add_edited_scene(p_node); - - if (scene) { - String path = scene->get_filename(); - p_node->set_filename(path); - memdelete(scene); - } -*/ -} - void EditorNode::_hide_top_editors() { _display_top_editors(false); @@ -1536,14 +1339,10 @@ void EditorNode::_edit_current() { node_dock->set_node(NULL); object_menu->set_disabled(false); EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path()); - //resources_dock->add_resource(Ref(current_res)); - - //top_pallete->set_current_tab(1); } else if (is_node) { Node *current_node = Object::cast_to(current_obj); ERR_FAIL_COND(!current_node); - // ERR_FAIL_COND(!current_node->is_inside_tree()); property_editor->edit(current_node); if (current_node->is_inside_tree()) { @@ -1555,14 +1354,10 @@ void EditorNode::_edit_current() { } object_menu->get_popup()->clear(); - //top_pallete->set_current_tab(0); - } else { property_editor->edit(current_obj); node_dock->set_node(NULL); - //scene_tree_dock->set_selected(current_node); - //object_menu->get_popup()->clear(); } /* Take care of PLUGIN EDITOR */ @@ -1617,15 +1412,6 @@ void EditorNode::_edit_current() { _hide_top_editors(); } - /* - if (!plugin || plugin->has_main_screen()) { - // remove the OVER plugin if exists - if (editor_plugin_over) - editor_plugin_over->make_visible(false); - editor_plugin_over=NULL; - } -*/ - /* Take care of OBJECT MENU */ object_menu->set_disabled(false); @@ -1670,9 +1456,6 @@ void EditorNode::_edit_current() { } } - //p->add_separator(); - //p->add_item("All Methods",OBJECT_CALL_METHOD); - update_keying(); } @@ -1709,7 +1492,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { play_button->set_pressed(false); 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")); play_custom_scene_button->set_pressed(false); @@ -1725,7 +1507,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (!scene) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("There is no defined scene to run.")); accept->popup_centered_minsize(); @@ -1734,8 +1515,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (scene->get_filename() == "") { current_option = -1; - //accept->get_cancel()->hide(); - /**/ _menu_option_confirm(FILE_SAVE_BEFORE_RUN, false); return; } @@ -1752,7 +1531,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (main_scene == "") { current_option = -1; - //accept->get_cancel()->hide(); pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); pick_main_scene->popup_centered_minsize(); return; @@ -1761,7 +1539,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (!FileAccess::exists(main_scene)) { current_option = -1; - //accept->get_cancel()->hide(); pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); pick_main_scene->popup_centered_minsize(); return; @@ -1770,7 +1547,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") { current_option = -1; - //accept->get_cancel()->hide(); pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); pick_main_scene->popup_centered_minsize(); return; @@ -1788,14 +1564,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (scene->get_filename() == "") { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Current scene was never saved, please save it prior to running.")); accept->popup_centered_minsize(); return; } - //_save_scene(scene->get_filename()); _save_scene_with_preview(scene->get_filename()); } } @@ -1821,7 +1595,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (error != OK) { current_option = -1; - //confirmation->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("Could not start subprocess!")); accept->popup_centered_minsize(); @@ -1846,23 +1619,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) { void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { - //print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed)); if (!p_confirmed) //this may be a hack.. current_option = (MenuOptions)p_option; switch (p_option) { case FILE_NEW_SCENE: { - // TODO: Drop such obsolete commented code - /* - if (!p_confirmed) { - confirmation->get_ok()->set_text("Yes"); - //confirmation->get_cancel()->show(); - confirmation->set_text("Start a New Scene? (Current will be lost)"); - confirmation->popup_centered_minsize(); - break; - }*/ - int idx = editor_data.add_edited_scene(-1); _scene_tab_changed(idx); editor_data.clear_editor_states(); @@ -1871,9 +1633,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_NEW_INHERITED_SCENE: case FILE_OPEN_SCENE: { - //print_tree(); file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - //not for now? List extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); @@ -1882,7 +1642,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - //file->set_current_path(current_path); Node *scene = editor_data.get_edited_scene_root(); if (scene) { file->set_current_path(scene->get_filename()); @@ -2012,44 +1771,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { _menu_option_confirm(FILE_SAVE_AND_RUN, false); } break; - case FILE_SAVE_OPTIMIZED: { -#if 0 - 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 tree root."); - accept->popup_centered(Size2(300,70)); - break; - } - - - - //file->set_current_path(current_path); - - String cpath; - if (scene->get_filename()!="") { - cpath = scene->get_filename(); - - String fn = cpath.substr(0,cpath.length() - cpath.extension().size()); - String ext=cpath.extension(); - cpath=fn+".optimized.scn"; - optimized_save->set_optimized_scene(cpath); - optimized_save->popup_centered(Size2(500,143)); - } else { - current_option=-1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Please save the scene first."); - accept->popup_centered(Size2(300,70)); - break; - - } -#endif - } break; - case FILE_EXPORT_PROJECT: { project_export->popup_export(); @@ -2105,7 +1826,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!editor_data.get_edited_scene_root()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("This operation can't be done without a selected node.")); accept->popup_centered_minsize(); @@ -2194,61 +1914,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { scene_tabs->set_current_tab(cur_idx); } break; - -#if 0 - case NODE_EXTERNAL_INSTANCE: { - - - if (!edited_scene) { - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("This operation can't be done without a selected node."); - accept->popup_centered(Size2(300,70)); - break; - } - - Node *parent = scene_tree_editor->get_selected(); - - if (!parent) { - - 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 selected node."); - accept->popup_centered(Size2(300,70)); - break; - } - - Node*instanced_scene=SceneLoader::load(external_file,true); - - if (!instanced_scene) { - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("Ugh"); - accept->set_text("Error loading scene from "+external_file); - accept->popup_centered(Size2(300,70)); - return; - } - - instanced_scene->generate_instance_state(); - instanced_scene->set_filename( ProjectSettings::get_singleton()->localize_path(external_file) ); - - editor_data.get_undo_redo().create_action("Instance Scene"); - editor_data.get_undo_redo().add_do_method(parent,"add_child",instanced_scene); - editor_data.get_undo_redo().add_do_method(instanced_scene,"set_owner",edited_scene); - editor_data.get_undo_redo().add_do_reference(instanced_scene); - editor_data.get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene); - editor_data.get_undo_redo().commit_action(); - - //parent->add_child(instanced_scene); - //instanced_scene->set_owner(edited_scene); - _last_instanced_scene=instanced_scene; - - } break; -#endif case RESOURCE_NEW: { create_dialog->popup_create(true); @@ -2403,7 +2068,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); play_custom_scene_button->set_pressed(false); play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); - //pause_button->set_pressed(false); if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) { for (int i = 0; i < bottom_panel_items.size(); i++) { if (bottom_panel_items[i].control == log) { @@ -2492,19 +2156,14 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case RUN_FILE_SERVER: { - //file_server bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER)); if (ischecked) { file_server->stop(); run_native->set_deploy_dumb(false); - //debug_menu->set_icon(gui_base->get_icon("FileServer","EditorIcons")); - //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Enable File Server"); } else { file_server->start(); run_native->set_deploy_dumb(true); - //debug_menu->set_icon(gui_base->get_icon("FileServerActive","EditorIcons")); - //debug_menu->get_popup()->set_item_text( debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server"); } debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER), !ischecked); @@ -2519,14 +2178,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked); } break; - - /*case RUN_DEPLOY_DUMB_CLIENTS: { - - bool ischecked = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS)); - debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(RUN_DEPLOY_DUMB_CLIENTS),!ischecked); - run_native->set_deploy_dumb(!ischecked); - - } break;*/ case RUN_DEPLOY_REMOTE_DEBUG: { bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG)); @@ -2582,10 +2233,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { settings_config_dialog->popup_edit_settings(); } break; - case SETTINGS_OPTIMIZED_PRESETS: { - - //optimized_presets->popup_centered_ratio(); - } break; case SETTINGS_MANAGE_EXPORT_TEMPLATES: { export_template_manager->popup_manager(); @@ -2598,9 +2245,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SETTINGS_PICK_MAIN_SCENE: { - //print_tree(); file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - //not for now? List extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); @@ -2609,7 +2254,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - //file->set_current_path(current_path); Node *scene = editor_data.get_edited_scene_root(); if (scene) { file->set_current_path(scene->get_filename()); @@ -2639,56 +2283,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_ABOUT: { about->popup_centered_minsize(Size2(780, 500) * EDSCALE); } break; - case SOURCES_REIMPORT: { - - //reimport_dialog->popup_reimport(); - } break; - case DEPENDENCY_LOAD_CHANGED_IMAGES: { - - } break; - case DEPENDENCY_UPDATE_IMPORTED: { - - /* - bool editing_changed = _find_editing_changed_scene(get_edited_scene()); - - import_reload_fn=""; - - if (editing_changed) { - if (unsaved_cache && !bool(EDITOR_DEF("import/ask_save_before_reimport",false))) { - if (!p_confirmed) { - - - confirmation->get_ok()->set_text("Open"); - //confirmation->get_cancel()->show(); - confirmation->set_text("Current scene changed, save and re-import ?"); - confirmation->popup_centered(Size2(300,70)); - break; - - } - } - - Node *scene = get_edited_scene(); - - if (scene->get_filename()=="") { - - current_option=-1; - //accept->get_cancel()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Can't import if edited scene was not saved."); //i don't think this code will ever run - accept->popup_centered(Size2(300,70)); - break; - - } - - - import_reload_fn = scene->get_filename(); - _save_scene(import_reload_fn); - - } - -*/ - - } break; default: { @@ -2997,18 +2591,9 @@ void EditorNode::_remove_edited_scene() { editor_data.get_undo_redo().clear_history(); _update_title(); _update_scene_tabs(); - - /* - if (editor_data.get_edited_scene_count()==1) { - //make new scene appear saved - set_current_version(editor_data.get_undo_redo().get_version()); - unsaved_cache=false; - } - */ } void EditorNode::_remove_scene(int index) { - //printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene()); if (editor_data.get_edited_scene() == index) { //Scene to remove is current scene @@ -3057,7 +2642,6 @@ Dictionary EditorNode::_get_main_scene_state() { state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value(); state["saved_version"] = saved_version; state["node_filter"] = scene_tree_dock->get_filter(); - //print_line(" getting main tab: "+itos(state["main_tab"])); return state; } @@ -3066,32 +2650,8 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { if (get_edited_scene() != p_for_scene && p_for_scene != NULL) return; //not for this scene - //print_line("set current 7 "); changing_scene = false; -#if 0 - if (p_state.has("main_tab")) { - int idx = p_state["main_tab"]; - - - print_line("comes with tab: "+itos(idx)); - int current=-1; - for(int i=0;iget_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_value(p_state["scene_tree_offset"]); @@ -3123,16 +2682,12 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { if (p_state.has("node_filter")) scene_tree_dock->set_filter(p_state["node_filter"]); - //print_line("set current 8 "); //this should only happen at the very end - //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; } void EditorNode::set_current_version(uint64_t p_version) { @@ -3164,8 +2719,6 @@ void EditorNode::set_current_scene(int p_idx) { scene_root->remove_child(get_editor_data().get_edited_scene_root()); } - //print_line("set current 2 "); - editor_selection->clear(); editor_data.set_edited_scene(p_idx); @@ -3174,8 +2727,6 @@ void EditorNode::set_current_scene(int p_idx) { if (Object::cast_to(new_scene)) Object::cast_to(new_scene)->show(); //show popups - //print_line("set current 3 "); - scene_tree_dock->set_edited_scene(new_scene); if (get_tree()) get_tree()->set_edited_scene_root(new_scene); @@ -3184,25 +2735,11 @@ void EditorNode::set_current_scene(int p_idx) { if (new_scene->get_parent() != scene_root) scene_root->add_child(new_scene); } - //print_line("set current 4 "); Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history); _edit_current(); - /*if (!unsaved) { - saved_version=editor_data.get_undo_redo().get_version(); - if (p_backwards) - saved_version--; - else - saved_version++; - print_line("was saved, updating version"); - } else { - saved_version=state["saved_version"]; - }*/ - //_set_main_scene_state(state); - call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up - //print_line("set current 6 "); } bool EditorNode::is_scene_open(const String &p_path) { @@ -3253,7 +2790,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (!lpath.begins_with("res://")) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("Ugh")); accept->set_text(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path.")); accept->popup_centered_minsize(); @@ -3263,8 +2799,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b int prev = editor_data.get_edited_scene(); int idx = editor_data.add_edited_scene(-1); - //print_line("load scene callback"); - //set_current_scene(idx); if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count() == 2) { _remove_edited_scene(); @@ -3278,7 +2812,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (!sdata.is_valid()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("Ugh")); accept->set_text(TTR("Error loading scene.")); accept->popup_centered_minsize(); @@ -3339,7 +2872,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b sdata.unref(); current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("Ugh")); accept->set_text(TTR("Error loading scene.")); accept->popup_centered_minsize(); @@ -3351,46 +2883,18 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b return ERR_FILE_NOT_FOUND; } - //guess not needed in the end? - //new_scene->clear_internal_tree_resource_paths(); //make sure no internal tree paths to internal resources exist - - /* - Node *old_scene = edited_scene; - _hide_top_editors(); - set_edited_scene(NULL); - editor_data.clear_editor_states(); - if (old_scene) { - if (!opening_prev && old_scene->get_filename()!="") { - previous_scenes.push_back(old_scene->get_filename()); - } - memdelete(old_scene); - } -*/ - if (p_set_inherited) { Ref state = sdata->get_state(); 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()); - */ } new_scene->set_scene_instance_state(Ref()); set_edited_scene(new_scene); _get_scene_metadata(p_scene); - /* - editor_data.set_edited_scene_root(new_scene); - scene_tree_dock->set_selected(new_scene, true); - property_editor->edit(new_scene); - editor_data.set_edited_scene_root(new_scene); -*/ - - //editor_data.get_undo_redo().clear_history(); saved_version = editor_data.get_undo_redo().get_version(); _update_title(); _update_scene_tabs(); @@ -3401,8 +2905,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); - //top_pallete->set_current_tab(0); //always go to scene - push_item(new_scene); return OK; @@ -3411,8 +2913,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b void EditorNode::open_request(const String &p_path) { load_scene(p_path); // as it will be opened in separate tab - //external_file=p_path; - //_menu_option_confirm(FILE_EXTERNAL_OPEN_SCENE,false); } void EditorNode::request_instance_scene(const String &p_path) { @@ -3458,8 +2958,6 @@ void EditorNode::_transform_keyed(Object *sp, const String &p_sub, const Transfo void EditorNode::update_keying() { - //print_line("KR: "+itos(p_enabled)); - bool valid = false; if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) { @@ -3481,57 +2979,15 @@ void EditorNode::update_keying() { void EditorNode::_close_messages() { - //left_split->set_dragger_visible(false); old_split_ofs = center_split->get_split_offset(); center_split->set_split_offset(0); - //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,0); } void EditorNode::_show_messages() { - //left_split->set_dragger_visible(true); center_split->set_split_offset(old_split_ofs); - //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP)); } -#if 0 -void EditorNode::animation_panel_make_visible(bool p_visible) { - - if (!p_visible) { - animation_panel->hide(); - } else { - animation_panel->show(); - } - - int idx = settings_menu->get_popup()->get_item_index(SETTINGS_SHOW_ANIMATION); - settings_menu->get_popup()->set_item_checked(idx,p_visible); -} - - -void EditorNode::animation_editor_make_visible(bool p_visible) { - - if (p_visible) { - - animation_editor->show(); - animation_vb->get_parent_control()->minimum_size_changed(); - //pd_anim->show(); - top_split->set_collapsed(false); - - //scene_root_parent->set_margin(MARGIN_TOP,animation_editor->get_margin(MARGIN_BOTTOM)); - } else { - //pd_anim->hide(); - animation_editor->hide(); - //scene_root_parent->set_margin(MARGIN_TOP,0); - if (!animation_vb->get_parent_control()) - return; - animation_vb->get_parent_control()->minimum_size_changed(); - top_split->set_collapsed(true); - } - - animation_editor->set_keying(p_visible); - -} -#endif void EditorNode::_add_to_recent_scenes(const String &p_scene) { String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); @@ -3560,44 +3016,6 @@ void EditorNode::_open_recent_scene(int p_idx) { load_scene(path); } -void EditorNode::_save_optimized() { - -//save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset()); -#if 0 - String path = optimized_save->get_optimized_scene(); - - uint32_t flags=0; - - String platform="all"; - Ref saver=editor_data.get_optimized_saver(optimized_save->get_preset()); - - if (saver->is_bundle_scenes_enabled()) - flags|=SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES; - if (saver->is_bundle_resources_enabled()) - flags|=SceneSaver::FLAG_BUNDLE_RESOURCES; - if (saver->is_remove_editor_data_enabled()) - flags|=SceneSaver::FLAG_OMIT_EDITOR_PROPERTIES; - if (saver->is_big_endian_data_enabled()) - flags|=SceneSaver::FLAG_SAVE_BIG_ENDIAN; - - platform=saver->get_target_platform(); - - Error err = SceneSaver::save(path,get_edited_scene(),flags,saver); - - if (err) { - - //accept->"()->hide(); - accept->get_ok()->set_text("I see.."); - accept->set_text("Error saving optimized scene: "+path); - accept->popup_centered(Size2(300,70)); - return; - - } - - project_settings->add_remapped_path(ProjectSettings::get_singleton()->localize_path(get_edited_scene()->get_filename()),ProjectSettings::get_singleton()->localize_path(path),platform); -#endif -} - void EditorNode::_update_recent_scenes() { String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); @@ -3637,33 +3055,7 @@ void EditorNode::notify_child_process_exited() { editor_run.stop(); } -bool EditorNode::_find_editing_changed_scene(Node *p_from) { - /* - if (!p_from) - return false; - - if (p_from->get_filename()!="") { - - StringName fn = p_from->get_filename(); - for(int i=0;iget_changes().size();i++) { - - if (fn==import_monitor->get_changes()[i]) - return true; - } - } - - for(int i=0;iget_child_count();i++) { - - if (_find_editing_changed_scene(p_from->get_child(i))) - return true; - } -*/ - return false; -} - 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); } @@ -3703,12 +3095,9 @@ void EditorNode::register_editor_types() { ClassDB::register_class(); ClassDB::register_class(); - // ClassDB::register_class(); - // ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - //ClassDB::register_type(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -3718,8 +3107,10 @@ void EditorNode::register_editor_types() { ClassDB::register_virtual_class(); ClassDB::register_virtual_class(); - //ClassDB::register_type(); - //ClassDB::register_type(); + // FIXME: Is this stuff obsolete, or should it be ported to new APIs? + //ClassDB::register_class(); + //ClassDB::register_class(); + //ClassDB::register_type(); } void EditorNode::unregister_editor_types() { @@ -4157,21 +3548,6 @@ void EditorNode::_update_dock_slots_visibility() { } } -void EditorNode::_update_top_menu_visibility() { - - return; // I think removing top menu is too much - /* - if (distraction_free->is_pressed()) { - play_cc->hide(); - menu_hb->hide(); - scene_tabs->hide(); - } else { - play_cc->show(); - menu_hb->show(); - scene_tabs->show(); - }*/ -} - void EditorNode::_load_docks_from_config(Ref p_layout, const String &p_section) { for (int i = 0; i < DOCK_SLOT_MAX; i++) { @@ -4419,27 +3795,20 @@ void EditorNode::_thumbnail_done(const String &p_path, const Ref &p_pre void EditorNode::_scene_tab_changed(int p_tab) { tab_preview_panel->hide(); - //print_line("set current 1 "); bool unsaved = (saved_version != editor_data.get_undo_redo().get_version()); - //print_line("version: "+itos(editor_data.get_undo_redo().get_version())+", saved "+itos(saved_version)); if (p_tab == editor_data.get_edited_scene()) return; //pointless uint64_t next_scene_version = editor_data.get_scene_version(p_tab); - //print_line("scene tab changed???"); editor_data.get_undo_redo().create_action(TTR("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,"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(); } @@ -4620,7 +3989,6 @@ void EditorNode::set_distraction_free_mode(bool p_enter) { } else { set_docks_visible(true); } - _update_top_menu_visibility(); } bool EditorNode::get_distraction_free_mode() const { @@ -4753,11 +4121,14 @@ Variant EditorNode::drag_files_and_dirs(const Vector &p_files, Control * void EditorNode::_dropped_files(const Vector &p_files, int p_screen) { + /* String cur_path = filesystem_dock->get_current_path(); - // for(int i=0;iget_import_plugin_count();i++) { - // EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); - // } + for(int i=0;iget_import_plugin_count();i++) { + EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); + } + */ } + void EditorNode::_file_access_close_error_notify(const String &p_str) { add_io_error("Unable to write to file '" + p_str + "', file in use, locked or lacking permissions."); @@ -4945,7 +4316,6 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_editor_select", &EditorNode::_editor_select); ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed); ClassDB::bind_method("edit_node", &EditorNode::edit_node); - ClassDB::bind_method("_imported", &EditorNode::_imported); ClassDB::bind_method("_unhandled_input", &EditorNode::_unhandled_input); ClassDB::bind_method("_get_scene_metadata", &EditorNode::_get_scene_metadata); @@ -4962,14 +4332,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_quick_run", &EditorNode::_quick_run); ClassDB::bind_method("_resource_created", &EditorNode::_resource_created); - - ClassDB::bind_method("_import_action", &EditorNode::_import_action); - //ClassDB::bind_method("_import",&EditorNode::_import); - //ClassDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved); ClassDB::bind_method("_open_recent_scene", &EditorNode::_open_recent_scene); - //ClassDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm); - - ClassDB::bind_method("_save_optimized", &EditorNode::_save_optimized); ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process); @@ -5009,8 +4372,6 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files); ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode); - // ClassDB::bind_method(D_METHOD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin); - //ClassDB::bind_method(D_METHOD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch); @@ -5190,7 +4551,6 @@ EditorNode::EditorNode() { menu_hb = memnew(HBoxContainer); main_vbox->add_child(menu_hb); - //left left_l_hsplit = memnew(HSplitContainer); main_vbox->add_child(left_l_hsplit); @@ -5214,19 +4574,14 @@ EditorNode::EditorNode() { left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]); dock_slot[DOCK_SLOT_LEFT_BR] = memnew(TabContainer); left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BR]); - //left_r_vsplit->hide(); - //dock_slot[DOCK_SLOT_LEFT_UR]->hide(); - //dock_slot[DOCK_SLOT_LEFT_BR]->hide(); main_hsplit = memnew(HSplitContainer); left_r_hsplit->add_child(main_hsplit); - //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); VBoxContainer *center_vb = memnew(VBoxContainer); main_hsplit->add_child(center_vb); center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); center_split = memnew(VSplitContainer); - //main_hsplit->add_child(center_split); center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); center_split->set_collapsed(false); center_vb->add_child(center_split); @@ -5240,9 +4595,6 @@ EditorNode::EditorNode() { right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]); dock_slot[DOCK_SLOT_RIGHT_BL] = memnew(TabContainer); right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BL]); - //right_l_vsplit->hide(); - //dock_slot[DOCK_SLOT_RIGHT_UL]->hide(); - //dock_slot[DOCK_SLOT_RIGHT_BL]->hide(); right_r_vsplit = memnew(VSplitContainer); right_hsplit->add_child(right_r_vsplit); @@ -5274,7 +4626,6 @@ EditorNode::EditorNode() { dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons")); dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_left->connect("pressed", this, "_dock_move_left"); - //dock_tab_move_left->set_h_size_flags(Control::SIZE_EXPAND_FILL); dock_hb->add_child(dock_tab_move_left); dock_hb->add_spacer(); dock_tab_move_right = memnew(ToolButton); @@ -5282,7 +4633,6 @@ EditorNode::EditorNode() { dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_right->connect("pressed", this, "_dock_move_right"); - //dock_tab_move_right->set_h_size_flags(Control::SIZE_EXPAND_FILL); dock_hb->add_child(dock_tab_move_right); dock_vb->add_child(dock_hb); @@ -5364,36 +4714,20 @@ EditorNode::EditorNode() { scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); - // sc->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); - //Ref sp = scene_root_parent->get_stylebox("panel","TabContainer"); - //scene_root_parent->add_style_override("panel",sp); - - /*scene_root_parent->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END ); - scene_root_parent->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END ); - scene_root_parent->set_begin( Point2( 0, 0) ); - scene_root_parent->set_end( Point2( 0,80 ) );*/ srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); scene_root = memnew(Viewport); scene_root->set_disable_3d(true); - //scene_root_base->add_child(scene_root); - //scene_root->set_meta("_editor_disable_input",true); VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); - //scene_root->set_size_override(true,Size2(ProjectSettings::get_singleton()->get("display/width"),ProjectSettings::get_singleton()->get("display/height"))); - - //scene_root->set_world_2d( Ref( memnew( World2D )) ); viewport = memnew(VBoxContainer); viewport->set_v_size_flags(Control::SIZE_EXPAND_FILL); viewport->add_constant_override("separation", 0); - /*for(int i=0;i<4;i++) { - viewport->set_margin(Margin(i),sp->get_margin(Margin(i))); - }*/ scene_root_parent->add_child(viewport); PanelContainer *top_region = memnew(PanelContainer); @@ -5402,9 +4736,14 @@ EditorNode::EditorNode() { top_region->add_child(left_menu_hb); menu_hb->add_child(top_region); + { + Control *sp = memnew(Control); + sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE); + menu_hb->add_child(sp); + } + file_menu = memnew(MenuButton); file_menu->set_text(TTR("Scene")); - //file_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); left_menu_hb->add_child(file_menu); file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); @@ -5412,7 +4751,6 @@ EditorNode::EditorNode() { prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); prev_scene->set_tooltip(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); - //left_menu_hb->add_child( prev_scene ); prev_scene->connect("pressed", this, "_menu_option", make_binds(FILE_OPEN_PREV)); gui_base->add_child(prev_scene); prev_scene->set_position(Point2(3, 24)); @@ -5460,11 +4798,6 @@ EditorNode::EditorNode() { p->add_child(recent_scenes); recent_scenes->connect("id_pressed", this, "_open_recent_scene"); - { - Control *sp = memnew(Control); - sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE); - menu_hb->add_child(sp); - } p->add_separator(); p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q); @@ -5498,7 +4831,6 @@ EditorNode::EditorNode() { PanelContainer *editor_region = memnew(PanelContainer); main_editor_button_vb = memnew(HBoxContainer); editor_region->add_child(main_editor_button_vb); - menu_hb->add_spacer(); menu_hb->add_child(editor_region); @@ -5530,12 +4862,9 @@ EditorNode::EditorNode() { left_menu_hb->add_child(settings_menu); settings_menu->set_text(TTR("Editor")); settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - //settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END); p = settings_menu->get_popup(); - //p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES); p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES); - //p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS); p->add_separator(); editor_layouts = memnew(PopupMenu); editor_layouts->set_name("Layouts"); @@ -5590,7 +4919,6 @@ EditorNode::EditorNode() { pause_button->set_toggle_mode(true); pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); pause_button->set_focus_mode(Control::FOCUS_NONE); - //pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE)); pause_button->set_tooltip(TTR("Pause the scene")); pause_button->set_disabled(true); play_hb->add_child(pause_button); @@ -5598,7 +4926,6 @@ EditorNode::EditorNode() { stop_button = memnew(ToolButton); play_hb->add_child(stop_button); - //stop_button->set_toggle_mode(true); stop_button->set_focus_mode(Control::FOCUS_NONE); stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP)); @@ -5633,23 +4960,8 @@ EditorNode::EditorNode() { play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); progress_hb = memnew(BackgroundProgress); - //menu_hb->add_child(progress_hb); - { - Control *sp = memnew(Control); - sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE); - //menu_hb->add_child(sp); - } - - { - Control *sp = memnew(Control); - sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE); - //menu_hb->add_child(sp); - } - - top_region = memnew(PanelContainer); HBoxContainer *right_menu_hb = memnew(HBoxContainer); - //top_region->add_child(right_menu_hb); menu_hb->add_child(right_menu_hb); layout_dialog = memnew(EditorNameDialog); @@ -5673,11 +4985,6 @@ EditorNode::EditorNode() { scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data)); scene_tree_dock->set_name(TTR("Scene")); dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock); -#if 0 - resources_dock = memnew( ResourcesDock(this) ); - resources_dock->set_name("Resources"); - dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock); -#endif dock_slot[DOCK_SLOT_LEFT_BR]->hide(); VBoxContainer *prop_editor_base = memnew(VBoxContainer); @@ -5739,8 +5046,8 @@ EditorNode::EditorNode() { editor_history_menu->get_popup()->connect("id_pressed", this, "_select_history"); prop_editor_hb = memnew(HBoxContainer); //again... - prop_editor_base->add_child(prop_editor_hb); + editor_path = memnew(EditorPath(&editor_history)); editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); prop_editor_hb->add_child(editor_path); @@ -5801,7 +5108,6 @@ EditorNode::EditorNode() { bool use_single_dock_column = (OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200); node_dock = memnew(NodeDock); - //node_dock->set_undoredo(&editor_data.get_undo_redo()); if (use_single_dock_column) { dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock); } else { @@ -5845,31 +5151,17 @@ EditorNode::EditorNode() { bottom_panel_vb = memnew(VBoxContainer); bottom_panel->add_child(bottom_panel_vb); - //bottom_panel_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); bottom_panel_hb = memnew(HBoxContainer); bottom_panel_vb->add_child(bottom_panel_hb); log = memnew(EditorLog); - add_bottom_panel_item(TTR("Output"), log); - //left_split->set_dragger_visible(false); - 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); - - //progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - orphan_resources = memnew(OrphanResourcesDialog); gui_base->add_child(orphan_resources); @@ -5887,23 +5179,9 @@ EditorNode::EditorNode() { gui_base->add_child(accept); accept->connect("confirmed", this, "_menu_confirm_current"); - //optimized_save = memnew( OptimizedSaveDialog(&editor_data) ); - //gui_base->add_child(optimized_save); - //optimized_save->connect("confirmed",this,"_save_optimized"); - project_export = memnew(ProjectExportDialog); gui_base->add_child(project_export); - //project_export_settings = memnew( ProjectExportDialog(this) ); - //gui_base->add_child(project_export_settings); - - //optimized_presets = memnew( OptimizedPresetsDialog(&editor_data) ); - //gui_base->add_child(optimized_presets); - //optimized_presets->connect("confirmed",this,"_presets_optimized"); - - //import_subscene = memnew( EditorSubScene ); - //gui_base->add_child(import_subscene); - dependency_error = memnew(DependencyErrorDialog); gui_base->add_child(dependency_error); @@ -5916,14 +5194,6 @@ EditorNode::EditorNode() { project_settings = memnew(ProjectSettingsEditor(&editor_data)); gui_base->add_child(project_settings); - import_confirmation = memnew(ConfirmationDialog); - import_confirmation->get_ok()->set_text(TTR("Re-Import")); - import_confirmation->add_button(TTR("Update"), !OS::get_singleton()->get_swap_ok_cancel(), "update"); - import_confirmation->get_label()->set_align(Label::ALIGN_CENTER); - import_confirmation->connect("confirmed", this, "_import_action", make_binds("re-import")); - import_confirmation->connect("custom_action", this, "_import_action"); - gui_base->add_child(import_confirmation); - run_settings_dialog = memnew(RunSettingsDialog); gui_base->add_child(run_settings_dialog); @@ -5983,9 +5253,6 @@ EditorNode::EditorNode() { gui_base->add_child(file_script); file_script->connect("file_selected", this, "_dialog_action"); - //reimport_dialog = memnew( EditorReImportDialog ); - //gui_base->add_child(reimport_dialog); - property_forward->connect("pressed", this, "_property_editor_forward"); property_back->connect("pressed", this, "_property_editor_back"); @@ -6027,10 +5294,9 @@ EditorNode::EditorNode() { raise_bottom_panel_item(AnimationPlayerEditor::singleton); add_editor_plugin(memnew(ShaderEditorPlugin(this))); - /* add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) ); - add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) ); + // FIXME: Disabled for Godot 3.0 as made incompatible, it needs to be ported to the new API. + //add_editor_plugin(memnew(ShaderGraphEditorPlugin(this))); - add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/ add_editor_plugin(memnew(CameraEditorPlugin(this))); add_editor_plugin(memnew(ThemeEditorPlugin(this))); add_editor_plugin(memnew(MultiMeshEditorPlugin(this))); @@ -6041,7 +5307,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(ParticlesEditorPlugin(this))); add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this))); add_editor_plugin(memnew(ItemListEditorPlugin(this))); - //add_editor_plugin( memnew( RichTextEditorPlugin(this) ) ); add_editor_plugin(memnew(CollisionPolygonEditorPlugin(this))); add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this))); add_editor_plugin(memnew(TileSetEditorPlugin(this))); @@ -6060,9 +5325,12 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this))); add_editor_plugin(memnew(CurveEditorPlugin(this))); add_editor_plugin(memnew(TextureEditorPlugin(this))); - add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); - //add_editor_plugin( memnew( MaterialEditorPlugin(this) ) ); add_editor_plugin(memnew(MeshEditorPlugin(this))); + add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); + + // FIXME: Disabled as (according to reduz) users were complaining that it gets in the way + // Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored. + //add_editor_plugin(memnew(MaterialEditorPlugin(this))); for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) add_editor_plugin(EditorPlugins::create(i, this)); @@ -6075,6 +5343,7 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator(Ref(memnew(EditorPackedScenePreviewPlugin))); resource_preview->add_preview_generator(Ref(memnew(EditorMaterialPreviewPlugin))); resource_preview->add_preview_generator(Ref(memnew(EditorScriptPreviewPlugin))); + // FIXME: Needs to be rewritten for AudioStream in Godot 3.0+ //resource_preview->add_preview_generator( Ref( memnew(EditorSamplePreviewPlugin ))); resource_preview->add_preview_generator(Ref(memnew(EditorMeshPreviewPlugin))); resource_preview->add_preview_generator(Ref(memnew(EditorBitmapPreviewPlugin))); @@ -6087,7 +5356,6 @@ EditorNode::EditorNode() { editor_plugins_over = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList); - //force_top_viewport(true); _edit_current(); current = NULL; @@ -6095,33 +5363,12 @@ EditorNode::EditorNode() { Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor ScriptServer::set_scripting_enabled(false); // no scripting by default if editor - //ProjectSettings::get_singleton()->set("render/room_cull_enabled",false); - reference_resource_mem = true; save_external_resources_mem = true; set_process(true); OS::get_singleton()->set_low_processor_usage_mode(true); - if (0) { //not sure if i want this to happen after all - - //store project name in ssettings - String project_name; - //figure it out from path - project_name = ProjectSettings::get_singleton()->get_resource_path().replace("\\", "/"); - print_line("path: " + project_name); - if (project_name.length() && project_name[project_name.length() - 1] == '/') - project_name = project_name.substr(0, project_name.length() - 1); - - project_name = project_name.replace("/", "::"); - - if (project_name != "") { - EditorSettings::get_singleton()->set("projects/" + project_name, ProjectSettings::get_singleton()->get_resource_path()); - EditorSettings::get_singleton()->raise_order("projects/" + project_name); - EditorSettings::get_singleton()->save(); - } - } - open_imported = memnew(ConfirmationDialog); open_imported->get_ok()->set_text(TTR("Open Anyway")); new_inherited_button = open_imported->add_button(TTR("New Inherited"), !OS::get_singleton()->get_swap_ok_cancel(), "inherit"); @@ -6129,7 +5376,6 @@ EditorNode::EditorNode() { open_imported->connect("custom_action", this, "_inherit_imported"); gui_base->add_child(open_imported); - //edited_scene=NULL; saved_version = 1; unsaved_cache = true; _last_instanced_scene = NULL; @@ -6150,17 +5396,12 @@ EditorNode::EditorNode() { set_process_unhandled_input(true); _playing_edited = false; - //Panel *errors = memnew( Panel ); load_errors = memnew(RichTextLabel); - //load_errors->set_readonly(true); load_error_dialog = memnew(AcceptDialog); load_error_dialog->add_child(load_errors); load_error_dialog->set_title(TTR("Load Errors")); - //load_error_dialog->set_child_rect(load_errors); gui_base->add_child(load_error_dialog); - //EditorImport::add_importer( Ref( memnew(EditorImporterCollada ))); - EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed"); EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed"); @@ -6183,9 +5424,6 @@ EditorNode::EditorNode() { pick_main_scene->get_ok()->set_text(TTR("Select")); pick_main_scene->connect("confirmed", this, "_menu_option", varray(SETTINGS_PICK_MAIN_SCENE)); - //Ref it = gui_base->get_icon("logo","Icons"); - //OS::get_singleton()->set_icon( it->get_data() ); - for (int i = 0; i < _init_callbacks.size(); i++) _init_callbacks[i](); @@ -6196,7 +5434,6 @@ EditorNode::EditorNode() { import_dock->initialize_import_options(); { - _initializing_addons = true; Vector addons; if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) { diff --git a/editor/editor_node.h b/editor/editor_node.h index ceb35aad0a77..8a02b16ca211 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -35,16 +35,35 @@ #include "editor/create_dialog.h" #include "editor/editor_about.h" #include "editor/editor_data.h" +#include "editor/editor_export.h" +#include "editor/editor_log.h" +#include "editor/editor_name_dialog.h" #include "editor/editor_path.h" +#include "editor/editor_plugin.h" +#include "editor/editor_reimport_dialog.h" +#include "editor/editor_resource_preview.h" #include "editor/editor_run.h" +#include "editor/editor_run_native.h" +#include "editor/editor_run_script.h" +#include "editor/editor_scale.h" +#include "editor/editor_sub_scene.h" #include "editor/export_template_manager.h" +#include "editor/fileserver/editor_file_server.h" #include "editor/filesystem_dock.h" #include "editor/groups_editor.h" #include "editor/import_dock.h" #include "editor/node_dock.h" +#include "editor/pane_drag.h" +#include "editor/progress_dialog.h" +#include "editor/project_export.h" +#include "editor/project_settings_editor.h" #include "editor/property_editor.h" +#include "editor/quick_open.h" #include "editor/reparent_dialog.h" +#include "editor/run_settings_dialog.h" +#include "editor/scene_tree_dock.h" #include "editor/scene_tree_editor.h" +#include "editor/script_create_dialog.h" #include "editor/settings_config_dialog.h" #include "scene/gui/center_container.h" #include "scene/gui/control.h" @@ -56,38 +75,12 @@ #include "scene/gui/separator.h" #include "scene/gui/split_container.h" #include "scene/gui/tab_container.h" +#include "scene/gui/tabs.h" #include "scene/gui/texture_progress.h" #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" - -#include "editor/pane_drag.h" - -#include "editor/editor_log.h" -#include "editor/editor_run_script.h" -#include "editor/project_export.h" -#include "editor/project_settings_editor.h" -#include "editor/resources_dock.h" -#include "editor/run_settings_dialog.h" -#include "editor/scene_tree_dock.h" -#include "editor/script_create_dialog.h" - -#include "editor/editor_name_dialog.h" -#include "editor/editor_plugin.h" -#include "editor/editor_run_native.h" -#include "editor/editor_sub_scene.h" -#include "editor/project_export.h" -#include "editor/quick_open.h" -#include "editor_export.h" -#include "editor_reimport_dialog.h" -#include "scene/gui/tabs.h" - -#include "editor_resource_preview.h" -#include "fileserver/editor_file_server.h" #include "scene/gui/viewport_container.h" -#include "progress_dialog.h" - -#include "editor_scale.h" /** @author Juan Linietsky */ @@ -170,7 +163,6 @@ private: RUN_SETTINGS, RUN_PROJECT_MANAGER, RUN_FILE_SERVER, - //RUN_DEPLOY_DUMB_CLIENTS, RUN_LIVE_DEBUG, RUN_DEBUG_COLLISONS, RUN_DEBUG_NAVIGATION, @@ -181,7 +173,6 @@ private: SETTINGS_UPDATE_SPINNER_HIDE, SETTINGS_EXPORT_PREFERENCES, SETTINGS_PREFERENCES, - SETTINGS_OPTIMIZED_PRESETS, SETTINGS_LAYOUT_SAVE, SETTINGS_LAYOUT_DELETE, SETTINGS_LAYOUT_DEFAULT, @@ -189,9 +180,6 @@ private: SETTINGS_PICK_MAIN_SCENE, SETTINGS_TOGGLE_FULLSCREN, SETTINGS_HELP, - SOURCES_REIMPORT, - DEPENDENCY_LOAD_CHANGED_IMAGES, - DEPENDENCY_UPDATE_IMPORTED, SCENE_TAB_CLOSE, HELP_CLASSES, @@ -209,11 +197,8 @@ private: TOOL_MENU_BASE = 1000 }; - //Node *edited_scene; //scene being edited Viewport *scene_root; //root of the scene being edited - //Ref scene_import_metadata; - PanelContainer *scene_root_parent; Control *theme_base; Control *gui_base; @@ -247,7 +232,6 @@ private: HBoxContainer *bottom_hb; Control *vp_base; PaneDrag *pd; - //PaneDrag *pd_anim; CenterContainer *play_cc; HBoxContainer *menu_hb; @@ -269,19 +253,16 @@ private: ToolButton *play_custom_scene_button; ToolButton *search_button; TextureProgress *audio_vu; - //MenuButton *fileserver_menu; RichTextLabel *load_errors; AcceptDialog *load_error_dialog; - //Control *scene_root_base; Ref theme; PopupMenu *recent_scenes; Button *property_back; Button *property_forward; SceneTreeDock *scene_tree_dock; - //ResourcesDock *resources_dock; PropertyEditor *property_editor; NodeDock *node_dock; ImportDock *import_dock; @@ -294,7 +275,6 @@ private: CreateDialog *create_dialog; - //CallDialog *call_dialog; ConfirmationDialog *confirmation; ConfirmationDialog *save_confirmation; ConfirmationDialog *import_confirmation; @@ -308,7 +288,6 @@ private: PopupMenu *editor_layouts; EditorNameDialog *layout_dialog; - //OptimizedPresetsDialog *optimized_presets; EditorSettingsDialog *settings_config_dialog; RunSettingsDialog *run_settings_dialog; ProjectSettingsEditor *project_settings; @@ -343,8 +322,6 @@ private: Vector main_editor_buttons; Vector editor_table; - // EditorReImportDialog *reimport_dialog; - ProgressDialog *progress_dialog; BackgroundProgress *progress_hb; @@ -402,7 +379,6 @@ private: EditorData editor_data; EditorRun editor_run; EditorSelection *editor_selection; - // ProjectExport *project_export; ProjectExportDialog *project_export; EditorResourcePreview *resource_preview; @@ -434,7 +410,6 @@ private: void _dialog_display_file_error(String p_file, Error p_error); int current_option; - //void _animation_visibility_toggle(); void _resource_created(); void _resource_selected(const RES &p_res, const String &p_property = ""); void _menu_option(int p_option); @@ -450,7 +425,6 @@ private: void _fs_changed(); void _sources_changed(bool p_exist); - void _imported(Node *p_node); void _node_renamed(); void _editor_select_next(); @@ -491,7 +465,6 @@ private: void _update_recent_scenes(); void _open_recent_scene(int p_idx); void _dropped_files(const Vector &p_files, int p_screen); - //void _open_recent_scene_confirm(); String _recent_scene; bool convert_old; @@ -502,8 +475,6 @@ private: bool has_main_screen() const { return true; } - bool _find_editing_changed_scene(Node *p_from); - String import_reload_fn; Set file_dialogs; @@ -580,7 +551,6 @@ private: void _save_docks_to_config(Ref p_layout, const String &p_section); void _load_docks_from_config(Ref p_layout, const String &p_section); void _update_dock_slots_visibility(); - void _update_top_menu_visibility(); void _update_layouts_menu(); void _layout_menu_option(int p_id); @@ -701,10 +671,6 @@ public: static EditorLog *get_log() { return singleton->log; } Control *get_viewport(); - //void animation_editor_make_visible(bool p_visible); - //void hide_animation_player_editors(); - //void animation_panel_make_visible(bool p_visible); - void set_edited_scene(Node *p_scene); Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } @@ -860,4 +826,4 @@ struct EditorProgressBG { ~EditorProgressBG() { EditorNode::progress_end_task_bg(task); } }; -#endif +#endif // EDITOR_NODE_H diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 08ee8c3c9e81..5b73d8369105 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -29,23 +29,23 @@ /*************************************************************************/ #include "editor_settings.h" -#include "editor_node.h" -#include "io/compression.h" -#include "io/config_file.h" -#include "io/file_access_memory.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "io/translation_loader_po.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "os/keyboard.h" -#include "os/os.h" -#include "project_settings.h" +#include "core/io/compression.h" +#include "core/io/config_file.h" +#include "core/io/file_access_memory.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/io/translation_loader_po.h" +#include "core/os/dir_access.h" +#include "core/os/file_access.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" +#include "core/project_settings.h" +#include "core/version.h" +#include "editor/editor_node.h" +#include "editor/translations.gen.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "scene/main/viewport.h" -#include "translations.gen.h" -#include "version.h" Ref EditorSettings::singleton = NULL; @@ -93,6 +93,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { emit_signal("settings_changed"); return true; } + bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { _THREAD_SAFE_METHOD_ @@ -272,7 +273,6 @@ void EditorSettings::create() { String config_path; String config_dir; - //String config_file="editor_settings.xml"; Ref extra_config = memnew(ConfigFile); String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); @@ -644,7 +644,6 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { set("text_editor/files/maximum_recent_files", 20); hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0"); - //set("docks/scene_tree/display_old_action_buttons",false); set("docks/scene_tree/start_create_dialog_fully_expanded", false); set("docks/scene_tree/draw_relationship_lines", false); set("docks/scene_tree/relationship_line_color", Color::html("464646")); @@ -705,8 +704,6 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { set("filesystem/on_save/compress_binary_resources", true); set("filesystem/on_save/save_modified_external_resources", true); - //set("filesystem/on_save/save_paths_as_relative",false); - //set("filesystem/on_save/save_paths_without_extension",false); set("text_editor/tools/create_signal_callbacks", true); @@ -1151,7 +1148,6 @@ void EditorSettings::_bind_methods() { EditorSettings::EditorSettings() { - //singleton=this; last_order = 0; optimize_save = true; save_changed_setting = true; @@ -1181,8 +1177,6 @@ EditorSettings::EditorSettings() { } EditorSettings::~EditorSettings() { - - //singleton=NULL; } Ref ED_GET_SHORTCUT(const String &p_path) { diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp index 06d12917fd4f..a0a52621a096 100644 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/editor/io_plugins/editor_scene_import_plugin.cpp @@ -2095,14 +2095,6 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map return p_node; } -#if 0 - -Error EditorImport::import_scene(const String& p_path,const String& p_dest_path,const String& p_resource_path,uint32_t p_flags,ImageFormat p_image_format,ImageCompression p_image_compression,uint32_t p_image_flags,float p_quality,uint32_t animation_flags,Node **r_scene,Ref p_post_import) { - - -} -#endif - void EditorSceneImportPlugin::_tag_import_paths(Node *p_scene,Node *p_node) { if (p_scene!=p_node && p_node->get_owner()!=p_scene) diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 43d6c22bcc12..5b71f51b0f66 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -367,10 +367,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref &p_resou int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; - /* - if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative")) - flg |= ResourceSaver::FLAG_RELATIVE_PATHS; - */ String path = ProjectSettings::get_singleton()->localize_path(p_path); Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); @@ -380,7 +376,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref &p_resou accept->popup_centered_minsize(); return; } - //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type()); ((Resource *)p_resource.ptr())->set_path(path); editor->emit_signal("resource_saved", p_resource); diff --git a/editor/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp similarity index 100% rename from editor/asset_library_editor_plugin.cpp rename to editor/plugins/asset_library_editor_plugin.cpp diff --git a/editor/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h similarity index 100% rename from editor/asset_library_editor_plugin.h rename to editor/plugins/asset_library_editor_plugin.h diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index ce6eefd69404..1842717cc0c1 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -29,14 +29,13 @@ /*************************************************************************/ #include "editor_preview_plugins.h" +#include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "io/file_access_memory.h" #include "io/resource_loader.h" #include "os/os.h" -#include "scene/resources/material.h" -//#include "scene/resources/sample.h" -#include "editor/editor_scale.h" #include "scene/resources/bit_mask.h" +#include "scene/resources/material.h" #include "scene/resources/mesh.h" bool EditorTexturePreviewPlugin::handles(const String &p_type) const { @@ -239,7 +238,6 @@ Ref EditorMaterialPreviewPlugin::generate(const RES &p_from) { VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - //print_line("queue capture!"); preview_done = false; VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant()); @@ -454,9 +452,7 @@ Ref EditorScriptPreviewPlugin::generate(const RES &p_from) { while (_is_text_char(code[pos])) { pos++; } - ///print_line("from "+itos(i)+" to "+itos(pos)); String word = code.substr(i, pos - i); - //print_line("found word: "+word); if (keywords.has(word)) in_keyword = true; @@ -502,6 +498,8 @@ Ref EditorScriptPreviewPlugin::generate(const RES &p_from) { EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() { } /////////////////////////////////////////////////////////////////// + +// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+ #if 0 bool EditorSamplePreviewPlugin::handles(const String& p_type) const { @@ -766,10 +764,9 @@ Ref EditorSamplePreviewPlugin::generate(const RES& p_from) { } EditorSamplePreviewPlugin::EditorSamplePreviewPlugin() { - - } #endif + /////////////////////////////////////////////////////////////////////////// void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) { @@ -788,14 +785,12 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const { Ref EditorMeshPreviewPlugin::generate(const RES &p_from) { - print_line("**Generating for mesh finally??"); Ref mesh = p_from; ERR_FAIL_COND_V(mesh.is_null(), Ref()); VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); Rect3 aabb = mesh->get_aabb(); - print_line("mesh aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; @@ -807,14 +802,12 @@ Ref EditorMeshPreviewPlugin::generate(const RES &p_from) { return Ref(); m = 1.0 / m; m *= 0.5; - //print_line("scale: "+rtos(m)); xform.basis.scale(Vector3(m, m, m)); xform.origin = -xform.basis.xform(ofs); //-ofs*m; xform.origin.z -= rot_aabb.size.z * 2; VS::get_singleton()->instance_set_transform(mesh_instance, xform); VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - //print_line("queue capture!"); preview_done = false; VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant()); @@ -826,7 +819,6 @@ Ref EditorMeshPreviewPlugin::generate(const RES &p_from) { Ref img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref()); - print_line("captured! " + itos(img->get_width()) + "x" + itos(img->get_height())); VS::get_singleton()->instance_set_base(mesh_instance, RID()); int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index 7e7d36eb1e3e..2ce35390a55a 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -97,6 +97,7 @@ public: EditorScriptPreviewPlugin(); }; +// FIXME: Needs to be rewritten for AudioStream in Godot 3.0+ #if 0 class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator { public: @@ -106,8 +107,8 @@ public: EditorSamplePreviewPlugin(); }; - #endif + class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator) diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 751f39e55d12..2afcf6a341f4 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -27,12 +27,14 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + +// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way +// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored. +#if 0 #include "material_editor_plugin.h" #include "scene/main/viewport.h" -#if 0 - void MaterialEditor::_gui_input(InputEvent p_event) { diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index a0a91f53a648..218354a918fe 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -30,6 +30,10 @@ #ifndef MATERIAL_EDITOR_PLUGIN_H #define MATERIAL_EDITOR_PLUGIN_H +// FIXME: Disabled as (according to reduz) users were complaining that it gets in the way +// Waiting for PropertyEditor rewrite (planned for 3.1) to be refactored. +#if 0 + #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "scene/3d/camera.h" @@ -37,7 +41,6 @@ #include "scene/3d/mesh_instance.h" #include "scene/resources/material.h" -#if 0 class MaterialEditor : public Control { GDCLASS(MaterialEditor, Control); @@ -97,5 +100,5 @@ public: }; -#endif // MATERIAL_EDITOR_PLUGIN_H #endif +#endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/rich_text_editor_plugin.cpp b/editor/plugins/rich_text_editor_plugin.cpp deleted file mode 100644 index 2a6474023cb7..000000000000 --- a/editor/plugins/rich_text_editor_plugin.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************/ -/* rich_text_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "rich_text_editor_plugin.h" - -#include "canvas_item_editor_plugin.h" -#include "os/file_access.h" - -void RichTextEditor::_notification(int p_what) { - - switch (p_what) { - - case NOTIFICATION_FIXED_PROCESS: { - - } break; - } -} -void RichTextEditor::_node_removed(Node *p_node) { - - if (p_node == node) { - node = NULL; - hide(); - } -} - -void RichTextEditor::_file_selected(const String &p_path) { - - CharString cs; - FileAccess *fa = FileAccess::open(p_path, FileAccess::READ); - if (!fa) { - ERR_FAIL(); - } - - while (!fa->eof_reached()) - cs.push_back(fa->get_8()); - cs.push_back(0); - memdelete(fa); - - String bbcode; - bbcode.parse_utf8(&cs[0]); - node->parse_bbcode(bbcode); -} - -void RichTextEditor::_menu_option(int p_option) { - - switch (p_option) { - - case PARSE_BBCODE: { - - file_dialog->popup_centered_ratio(); - } break; - case CLEAR: { - - node->clear(); - - } break; - } -} - -void RichTextEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_menu_option"), &RichTextEditor::_menu_option); - ClassDB::bind_method(D_METHOD("_file_selected"), &RichTextEditor::_file_selected); -} - -void RichTextEditor::edit(Node *p_rich_text) { - - node = Object::cast_to(p_rich_text); -} -RichTextEditor::RichTextEditor() { - - options = memnew(MenuButton); - //add_child(options); - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); - options->set_area_as_parent_rect(); - - options->set_text("RichText"); - options->get_popup()->add_item(TTR("Parse BBCode"), PARSE_BBCODE); - options->get_popup()->add_item(TTR("Clear"), CLEAR); - - options->get_popup()->connect("id_pressed", this, "_menu_option"); - file_dialog = memnew(EditorFileDialog); - add_child(file_dialog); - file_dialog->add_filter("*.txt"); - file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); - file_dialog->connect("file_selected", this, "_file_selected"); -} - -void RichTextEditorPlugin::edit(Object *p_object) { - - rich_text_editor->edit(Object::cast_to(p_object)); -} - -bool RichTextEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("RichTextLabel"); -} - -void RichTextEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - rich_text_editor->options->show(); - } else { - - rich_text_editor->options->hide(); - rich_text_editor->edit(NULL); - } -} - -RichTextEditorPlugin::RichTextEditorPlugin(EditorNode *p_node) { - - editor = p_node; - rich_text_editor = memnew(RichTextEditor); - editor->get_viewport()->add_child(rich_text_editor); - - rich_text_editor->set_margin(MARGIN_LEFT, 184); - rich_text_editor->set_margin(MARGIN_RIGHT, 230); - rich_text_editor->set_margin(MARGIN_TOP, 0); - rich_text_editor->set_margin(MARGIN_BOTTOM, 10); - - rich_text_editor->options->hide(); -} - -RichTextEditorPlugin::~RichTextEditorPlugin() { -} diff --git a/editor/plugins/rich_text_editor_plugin.h b/editor/plugins/rich_text_editor_plugin.h deleted file mode 100644 index 2665db299376..000000000000 --- a/editor/plugins/rich_text_editor_plugin.h +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************/ -/* rich_text_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef RICH_TEXT_EDITOR_PLUGIN_H -#define RICH_TEXT_EDITOR_PLUGIN_H - -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/rich_text_label.h" - -/** - @author Juan Linietsky -*/ - -class RichTextEditor : public Control { - - GDCLASS(RichTextEditor, Control); - - friend class RichTextEditorPlugin; - - enum { - - PARSE_BBCODE, - CLEAR - }; - - Panel *panel; - MenuButton *options; - RichTextLabel *node; - EditorFileDialog *file_dialog; - - void _file_selected(const String &p_path); - void _menu_option(int p_option); - -protected: - void _notification(int p_what); - void _node_removed(Node *p_node); - static void _bind_methods(); - -public: - void edit(Node *p_rich_text); - RichTextEditor(); -}; - -class RichTextEditorPlugin : public EditorPlugin { - - GDCLASS(RichTextEditorPlugin, EditorPlugin); - - RichTextEditor *rich_text_editor; - EditorNode *editor; - -public: - virtual String get_name() const { return "RichText"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); - - RichTextEditorPlugin(EditorNode *p_node); - ~RichTextEditorPlugin(); -}; - -#endif // RICH_TEXT_EDITOR_PLUGIN_H diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp deleted file mode 100644 index f6f776f67002..000000000000 --- a/editor/plugins/sample_editor_plugin.cpp +++ /dev/null @@ -1,452 +0,0 @@ -/*************************************************************************/ -/* sample_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "sample_editor_plugin.h" - -#if 0 -#include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" - - - - -void SampleEditor::_gui_input(InputEvent p_event) { - - -} - -void SampleEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_FIXED_PROCESS) { - - } - - if (p_what==NOTIFICATION_ENTER_TREE) { - play->set_icon( get_icon("Play","EditorIcons") ); - stop->set_icon( get_icon("Stop","EditorIcons") ); - } - - if (p_what==NOTIFICATION_READY) { - - //get_scene()->connect("node_removed",this,"_node_removed"); - - } - - if (p_what==NOTIFICATION_DRAW) { - - } -} - -void SampleEditor::_play_pressed() { - - player->play("default",true); - stop->set_pressed(false); - play->set_pressed(true); -} -void SampleEditor::_stop_pressed() { - - player->stop_all(); - play->set_pressed(false); -} - -void SampleEditor::generate_preview_texture(const Ref& p_sample,Ref &p_texture) { - - - PoolVector data = p_sample->get_data(); - - PoolVector img; - int w = p_texture->get_width(); - int h = p_texture->get_height(); - img.resize(w*h*3); - PoolVector::Write imgdata = img.write(); - uint8_t * imgw = imgdata.ptr(); - PoolVector::Read sampledata = data.read(); - const uint8_t *sdata=sampledata.ptr(); - - bool stereo = p_sample->is_stereo(); - bool _16=p_sample->get_format()==Sample::FORMAT_PCM16; - int len = p_sample->get_length(); - - if (len<1) - return; - - if (p_sample->get_format()==Sample::FORMAT_IMA_ADPCM) { - - - struct IMA_ADPCM_State { - - int16_t step_index; - int32_t predictor; - /* values at loop point */ - int16_t loop_step_index; - int32_t loop_predictor; - int32_t last_nibble; - int32_t loop_pos; - int32_t window_ofs; - const uint8_t *ptr; - } ima_adpcm; - - ima_adpcm.step_index=0; - ima_adpcm.predictor=0; - ima_adpcm.loop_step_index=0; - ima_adpcm.loop_predictor=0; - ima_adpcm.last_nibble=-1; - ima_adpcm.loop_pos=0x7FFFFFFF; - ima_adpcm.window_ofs=0; - ima_adpcm.ptr=NULL; - - - for(int i=0;i=len) - to=len-1; - - for(int j=from;jima_adpcm.last_nibble) { - - static const int16_t _ima_adpcm_step_table[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 - }; - - static const int8_t _ima_adpcm_index_table[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8 - }; - - int16_t nibble,diff,step; - - ima_adpcm.last_nibble++; - const uint8_t *src_ptr=sdata; - - int ofs = ima_adpcm.last_nibble>>1; - - if (stereo) - ofs*=2; - - nibble = (ima_adpcm.last_nibble&1)? - (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF); - - step=_ima_adpcm_step_table[ima_adpcm.step_index]; - - ima_adpcm.step_index += _ima_adpcm_index_table[nibble]; - if (ima_adpcm.step_index<0) - ima_adpcm.step_index=0; - if (ima_adpcm.step_index>88) - ima_adpcm.step_index=88; - - diff = step >> 3 ; - if (nibble & 1) - diff += step >> 2 ; - if (nibble & 2) - diff += step >> 1 ; - if (nibble & 4) - diff += step ; - if (nibble & 8) - diff = -diff ; - - ima_adpcm.predictor+=diff; - if (ima_adpcm.predictor<-0x8000) - ima_adpcm.predictor=-0x8000; - else if (ima_adpcm.predictor>0x7FFF) - ima_adpcm.predictor=0x7FFF; - - - /* store loop if there */ - if (ima_adpcm.last_nibble==ima_adpcm.loop_pos) { - - ima_adpcm.loop_step_index = ima_adpcm.step_index; - ima_adpcm.loop_predictor = ima_adpcm.predictor; - } - - } - - float v=ima_adpcm.predictor/32767.0; - if (v>max[0]) - max[0]=v; - if (vmin[0] && v=len) - to=len-1; - - if (_16) { - const int16_t*src =(const int16_t*)sdata; - - for(int j=0;jmax[j]) - max[j]=v; - if (vmax[j]) - max[j]=v; - if (vmin[0] && vmin[half] && v::Write(); - - - p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB8,img)); - -} - -void SampleEditor::_update_sample() { - - player->stop_all(); - - generate_preview_texture(sample,peakdisplay); - info_label->set_text(TTR("Length:")+" "+String::num(sample->get_length()/(float)sample->get_mix_rate(),2)+"s"); - - if (library->has_sample("default")) - library->remove_sample("default"); - - library->add_sample("default",sample); -} - - - -void SampleEditor::edit(Ref p_sample) { - - sample=p_sample; - - if (!sample.is_null()) - _update_sample(); - else { - - hide(); - set_fixed_process(false); - } - -} - - - -void SampleEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_gui_input"),&SampleEditor::_gui_input); - ClassDB::bind_method(D_METHOD("_play_pressed"),&SampleEditor::_play_pressed); - ClassDB::bind_method(D_METHOD("_stop_pressed"),&SampleEditor::_stop_pressed); - -} - -SampleEditor::SampleEditor() { - - player = memnew(SamplePlayer); - add_child(player); - add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); - library = Ref(memnew(SampleLibrary)); - player->set_sample_library(library); - sample_texframe = memnew( TextureRect ); - add_child(sample_texframe); - sample_texframe->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5); - sample_texframe->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5); - sample_texframe->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30); - sample_texframe->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5); - - info_label = memnew( Label ); - sample_texframe->add_child(info_label); - info_label->set_area_as_parent_rect(); - info_label->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,-15); - info_label->set_margin(MARGIN_BOTTOM,-4); - info_label->set_margin(MARGIN_RIGHT,-4); - info_label->set_align(Label::ALIGN_RIGHT); - - - play = memnew( Button ); - - play->set_position(Point2( 5, 5 )); - play->set_size( Size2(1,1 ) ); - play->set_toggle_mode(true); - add_child(play); - - stop = memnew( Button ); - - stop->set_position(Point2( 35, 5 )); - stop->set_size( Size2(1,1 ) ); - stop->set_toggle_mode(true); - add_child(stop); - - peakdisplay=Ref( memnew( ImageTexture) ); - peakdisplay->create( EDITOR_DEF("editors/sample_editor/preview_width",512),EDITOR_DEF("editors/sample_editor/preview_height",128),Image::FORMAT_RGB8); - sample_texframe->set_expand(true); - sample_texframe->set_texture(peakdisplay); - - play->connect("pressed", this,"_play_pressed"); - stop->connect("pressed", this,"_stop_pressed"); - - set_custom_minimum_size(Size2(1,150)*EDSCALE); - -} - - -void SampleEditorPlugin::edit(Object *p_object) { - - Sample * s = Object::cast_to(p_object); - if (!s) - return; - - sample_editor->edit(Ref(s)); -} - -bool SampleEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("Sample"); -} - -void SampleEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - sample_editor->show(); - //sample_editor->set_process(true); - } else { - - sample_editor->hide(); - //sample_editor->set_process(false); - } - -} - -SampleEditorPlugin::SampleEditorPlugin(EditorNode *p_node) { - - editor=p_node; - sample_editor = memnew( SampleEditor ); - add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,sample_editor); - sample_editor->hide(); - - - -} - - -SampleEditorPlugin::~SampleEditorPlugin() -{ -} - -#endif diff --git a/editor/plugins/sample_editor_plugin.h b/editor/plugins/sample_editor_plugin.h deleted file mode 100644 index 8f93026c9266..000000000000 --- a/editor/plugins/sample_editor_plugin.h +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************/ -/* sample_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef SAMPLE_EDITOR_PLUGIN_H -#define SAMPLE_EDITOR_PLUGIN_H - -#if 0 -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/audio/sample_player.h" -#include "scene/resources/sample.h" -#include "scene/resources/sample_library.h" - - -class SampleEditor : public Panel { - - GDCLASS(SampleEditor, Panel ); - - - SamplePlayer *player; - Label *info_label; - Ref peakdisplay; - Ref sample; - Ref library; - TextureRect *sample_texframe; - Button *stop; - Button *play; - - void _play_pressed(); - void _stop_pressed(); - void _update_sample(); - -protected: - void _notification(int p_what); - void _gui_input(InputEvent p_event); - static void _bind_methods(); -public: - - static void generate_preview_texture(const Ref& p_sample,Ref &p_texture); - void edit(Ref p_sample); - SampleEditor(); -}; - - -class SampleEditorPlugin : public EditorPlugin { - - GDCLASS( SampleEditorPlugin, EditorPlugin ); - - SampleEditor *sample_editor; - EditorNode *editor; - -public: - - virtual String get_name() const { return "Sample"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - - SampleEditorPlugin(EditorNode *p_node); - ~SampleEditorPlugin(); - -}; - -#endif - -#endif // SAMPLE_EDITOR_PLUGIN_H diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp deleted file mode 100644 index 761301610e37..000000000000 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/*************************************************************************/ -/* sample_library_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#if 0 -#include "sample_library_editor_plugin.h" - -#include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" -#include "sample_editor_plugin.h" -#include "scene/main/viewport.h" - - -void SampleLibraryEditor::_gui_input(InputEvent p_event) { - - -} - -void SampleLibraryEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_PROCESS) { - if (is_playing && !player->is_active()) { - TreeItem *tl=Object::cast_to(last_sample_playing); - tl->set_button(0,0,get_icon("Play","EditorIcons")); - is_playing = false; - set_process(false); - } - } - - if (p_what==NOTIFICATION_ENTER_TREE) { - load->set_icon( get_icon("Folder","EditorIcons") ); - load->set_tooltip(TTR("Open Sample File(s)")); - } - - if (p_what==NOTIFICATION_READY) { - - //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector(),true); - } - - if (p_what==NOTIFICATION_DRAW) { - - } -} - -void SampleLibraryEditor::_file_load_request(const PoolVector& p_path) { - - - for(int i=0;i sample = ResourceLoader::load(path,"Sample"); - if (sample.is_null()) { - dialog->set_text(TTR("ERROR: Couldn't load sample!")); - dialog->set_title(TTR("Error!")); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text(TTR("Close")); - dialog->popup_centered_minsize(); - return; ///beh should show an error i guess - } - String basename = path.get_file().get_basename(); - String name=basename; - int counter=0; - while(sample_library->has_sample(name)) { - counter++; - name=basename+"_"+itos(counter); - } - - undo_redo->create_action(TTR("Add Sample")); - undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample); - undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); - } -} - -void SampleLibraryEditor::_load_pressed() { - - file->popup_centered_ratio(); - -} - -void SampleLibraryEditor::_button_pressed(Object *p_item,int p_column, int p_id) { - - TreeItem *ti=Object::cast_to(p_item); - String name = ti->get_text(0); - - if (p_column==0) { // Play/Stop - - String btn_type; - if(!is_playing) { - is_playing = true; - btn_type = TTR("Stop"); - player->play(name,true); - last_sample_playing = p_item; - set_process(true); - } else { - player->stop_all(); - if(last_sample_playing != p_item){ - TreeItem *tl=Object::cast_to(last_sample_playing); - tl->set_button(p_column,0,get_icon("Play","EditorIcons")); - btn_type = TTR("Stop"); - player->play(name,true); - last_sample_playing = p_item; - } else { - btn_type = TTR("Play"); - is_playing = false; - } - } - ti->set_button(p_column,0,get_icon(btn_type,"EditorIcons")); - } else if (p_column==1) { // Edit - - get_tree()->get_root()->get_child(0)->call("_resource_selected",sample_library->get_sample(name)); - } else if (p_column==5) { // Delete - - ti->select(0); - _delete_pressed(); - } - - -} - - - - - -void SampleLibraryEditor::_item_edited() { - - if (!tree->get_selected()) - return; - - TreeItem *s = tree->get_selected(); - - if (tree->get_selected_column()==0) { // Name - // renamed - String old_name=s->get_metadata(0); - String new_name=s->get_text(0); - if (old_name==new_name) - return; - - if (new_name=="" || new_name.find("\\")!=-1 || new_name.find("/")!=-1 || sample_library->has_sample(new_name)) { - - s->set_text(0,old_name); - return; - } - - Ref samp = sample_library->get_sample(old_name); - undo_redo->create_action(TTR("Rename Sample")); - undo_redo->add_do_method(sample_library.operator->(),"remove_sample",old_name); - undo_redo->add_do_method(sample_library.operator->(),"add_sample",new_name,samp); - undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",new_name); - undo_redo->add_undo_method(sample_library.operator->(),"add_sample",old_name,samp); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); - - } else if (tree->get_selected_column()==3) { // Volume dB - - StringName n = s->get_text(0); - sample_library->sample_set_volume_db(n,s->get_range(3)); - - } else if (tree->get_selected_column()==4) { // Pitch scale - - StringName n = s->get_text(0); - sample_library->sample_set_pitch_scale(n,s->get_range(4)); - - } - - -} - -void SampleLibraryEditor::_delete_pressed() { - - if (!tree->get_selected()) - return; - - String to_remove = tree->get_selected()->get_text(0); - undo_redo->create_action(TTR("Delete Sample")); - undo_redo->add_do_method(sample_library.operator->(),"remove_sample",to_remove); - undo_redo->add_undo_method(sample_library.operator->(),"add_sample",to_remove,sample_library->get_sample(to_remove)); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); -} - - -void SampleLibraryEditor::_update_library() { - - player->stop_all(); - - tree->clear(); - tree->set_hide_root(true); - TreeItem *root = tree->create_item(NULL); - - List names; - sample_library->get_sample_list(&names); - names.sort_custom(); - - for(List::Element *E=names.front();E;E=E->next()) { - - TreeItem *ti = tree->create_item(root); - - // Name + Play/Stop - ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING); - ti->set_editable(0,true); - ti->set_selectable(0,true); - ti->set_text(0,E->get()); - ti->set_metadata(0,E->get()); - ti->add_button(0,get_icon("Play","EditorIcons")); - - Ref smp = sample_library->get_sample(E->get()); - - // Preview/edit - Ref preview( memnew( ImageTexture )); - preview->create(128,16,Image::FORMAT_RGB8); - SampleEditor::generate_preview_texture(smp,preview); - ti->set_cell_mode(1,TreeItem::CELL_MODE_ICON); - ti->set_selectable(1,false); - ti->set_editable(1,false); - ti->set_icon(1,preview); - ti->add_button(1,get_icon("Edit","EditorIcons")); - - // Format - ti->set_cell_mode(2,TreeItem::CELL_MODE_STRING); - ti->set_editable(2,false); - ti->set_selectable(2,false); - ti->set_text(2,String()+(smp->get_format()==Sample::FORMAT_PCM16?TTR("16 Bits")+", ":(smp->get_format()==Sample::FORMAT_PCM8?TTR("8 Bits")+", ":"IMA-ADPCM,"))+(smp->is_stereo()?TTR("Stereo"):TTR("Mono"))); - - // Volume dB - ti->set_cell_mode(3,TreeItem::CELL_MODE_RANGE); - ti->set_range_config(3,-60,24,0.01); - ti->set_selectable(3,true); - ti->set_editable(3,true); - ti->set_range(3,sample_library->sample_get_volume_db(E->get())); - - // Pitch scale - ti->set_cell_mode(4,TreeItem::CELL_MODE_RANGE); - ti->set_range_config(4,0.01,100,0.01); - ti->set_selectable(4,true); - ti->set_editable(4,true); - ti->set_range(4,sample_library->sample_get_pitch_scale(E->get())); - - // Delete - ti->set_cell_mode(5,TreeItem::CELL_MODE_STRING); - ti->add_button(5,get_icon("Remove","EditorIcons")); - - } - - //player->add_sample("default",sample); -} - - - -void SampleLibraryEditor::edit(Ref p_sample_library) { - - sample_library=p_sample_library; - - - if (!sample_library.is_null()) { - player->set_sample_library(sample_library); - _update_library(); - } else { - - hide(); - } - -} - -Variant SampleLibraryEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) { - - TreeItem*ti =tree->get_item_at_pos(p_point); - if (!ti) - return Variant(); - - String name = ti->get_metadata(0); - - RES res = sample_library->get_sample(name); - if (!res.is_valid()) - return Variant(); - - return EditorNode::get_singleton()->drag_resource(res,p_from); - - -} - -bool SampleLibraryEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const { - - - - Dictionary d = p_data; - - if (!d.has("type")) - return false; - - if (d.has("from") && (Object*)(d["from"])==tree) - return false; - - if (String(d["type"])=="resource" && d.has("resource")) { - RES r=d["resource"]; - - Ref sample = r; - - if (sample.is_valid()) { - - return true; - } - } - - - if (String(d["type"])=="files") { - - Vector files = d["files"]; - - if (files.size()==0) - return false; - - for(int i=0;iget_file_type(file); - - if (ftype!="Sample") { - return false; - } - - } - - return true; - - } - return false; -} - -void SampleLibraryEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) { - - if (!can_drop_data_fw(p_point,p_data,p_from)) - return; - - Dictionary d = p_data; - - if (!d.has("type")) - return; - - - if (String(d["type"])=="resource" && d.has("resource")) { - RES r=d["resource"]; - - Ref sample = r; - - if (sample.is_valid()) { - - String basename; - if (sample->get_name()!="") { - basename=sample->get_name(); - } else if (sample->get_path().is_resource_file()) { - basename = sample->get_path().get_basename(); - } else { - basename="Sample"; - } - - String name=basename; - int counter=0; - while(sample_library->has_sample(name)) { - counter++; - name=basename+"_"+itos(counter); - } - - undo_redo->create_action(TTR("Add Sample")); - undo_redo->add_do_method(sample_library.operator->(),"add_sample",name,sample); - undo_redo->add_undo_method(sample_library.operator->(),"remove_sample",name); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); - } - } - - - if (String(d["type"])=="files") { - - PoolVector files = d["files"]; - - _file_load_request(files); - - } - -} - - -void SampleLibraryEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_gui_input"),&SampleLibraryEditor::_gui_input); - ClassDB::bind_method(D_METHOD("_load_pressed"),&SampleLibraryEditor::_load_pressed); - ClassDB::bind_method(D_METHOD("_item_edited"),&SampleLibraryEditor::_item_edited); - ClassDB::bind_method(D_METHOD("_delete_pressed"),&SampleLibraryEditor::_delete_pressed); - ClassDB::bind_method(D_METHOD("_file_load_request"),&SampleLibraryEditor::_file_load_request); - ClassDB::bind_method(D_METHOD("_update_library"),&SampleLibraryEditor::_update_library); - ClassDB::bind_method(D_METHOD("_button_pressed"),&SampleLibraryEditor::_button_pressed); - - ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SampleLibraryEditor::get_drag_data_fw); - ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SampleLibraryEditor::can_drop_data_fw); - ClassDB::bind_method(D_METHOD("drop_data_fw"), &SampleLibraryEditor::drop_data_fw); - -} - -SampleLibraryEditor::SampleLibraryEditor() { - - player = memnew(SamplePlayer); - add_child(player); - add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); - - - load = memnew( Button ); - load->set_position(Point2( 5, 5 )); - load->set_size( Size2(1,1 ) ); - add_child(load); - - file = memnew( EditorFileDialog ); - add_child(file); - List extensions; - ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions); - for(int i=0;iadd_filter("*."+extensions[i]); - file->set_mode(EditorFileDialog::MODE_OPEN_FILES); - - tree = memnew( Tree ); - tree->set_columns(6); - add_child(tree); - tree->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5); - tree->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,-5); - tree->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30); - tree->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,-5); - tree->set_column_titles_visible(true); - tree->set_column_title(0,TTR("Name")); - tree->set_column_title(1,TTR("Preview")); - tree->set_column_title(2,TTR("Format")); - tree->set_column_title(3,"dB"); - tree->set_column_title(4,TTR("Pitch")); - tree->set_column_title(5,""); - - tree->set_column_min_width(1,150); - tree->set_column_min_width(2,100); - tree->set_column_min_width(3,50); - tree->set_column_min_width(4,50); - tree->set_column_min_width(5,32); - tree->set_column_expand(1,false); - tree->set_column_expand(2,false); - tree->set_column_expand(3,false); - tree->set_column_expand(4,false); - tree->set_column_expand(5,false); - - tree->set_drag_forwarding(this); - - dialog = memnew( ConfirmationDialog ); - add_child( dialog ); - - tree->connect("button_pressed",this,"_button_pressed"); - load->connect("pressed", this,"_load_pressed"); - file->connect("files_selected", this,"_file_load_request"); - tree->connect("item_edited", this,"_item_edited"); - - is_playing = false; -} - - -void SampleLibraryEditorPlugin::edit(Object *p_object) { - - sample_library_editor->set_undo_redo(&get_undo_redo()); - SampleLibrary * s = Object::cast_to(p_object); - if (!s) - return; - - sample_library_editor->edit(Ref(s)); -} - -bool SampleLibraryEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("SampleLibrary"); -} - -void SampleLibraryEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - //sample_library_editor->show(); - button->show(); - editor->make_bottom_panel_item_visible(sample_library_editor); - //sample_library_editor->set_process(true); - } else { - - if (sample_library_editor->is_visible_in_tree()) - editor->hide_bottom_panel(); - button->hide(); - - //sample_library_editor->set_process(false); - } - -} - -SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) { - - editor=p_node; - sample_library_editor = memnew( SampleLibraryEditor ); - - //editor->get_viewport()->add_child(sample_library_editor); - sample_library_editor->set_custom_minimum_size(Size2(0,250)); - button=p_node->add_bottom_panel_item("SampleLibrary",sample_library_editor); - button->hide(); - - //sample_library_editor->set_area_as_parent_rect(); - //sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END); - //sample_library_editor->set_margin( MARGIN_TOP, 120 ); - //sample_library_editor->hide(); - - - -} - - -SampleLibraryEditorPlugin::~SampleLibraryEditorPlugin() -{ -} -#endif diff --git a/editor/plugins/sample_library_editor_plugin.h b/editor/plugins/sample_library_editor_plugin.h deleted file mode 100644 index 0244fa66edd4..000000000000 --- a/editor/plugins/sample_library_editor_plugin.h +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************/ -/* sample_library_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef SAMPLE_LIBRARY_EDITOR_PLUGIN_H -#define SAMPLE_LIBRARY_EDITOR_PLUGIN_H - -#if 0 -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/audio/sample_player.h" -#include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/tree.h" -#include "scene/resources/sample.h" - - -class SampleLibraryEditor : public Panel { - - GDCLASS(SampleLibraryEditor, Panel ); - - - - SamplePlayer *player; - Ref sample_library; - Button *load; - Tree *tree; - bool is_playing; - Object *last_sample_playing; - - EditorFileDialog *file; - - ConfirmationDialog *dialog; - - - void _load_pressed(); - void _file_load_request(const PoolVector& p_path); - void _delete_pressed(); - void _update_library(); - void _item_edited(); - - UndoRedo *undo_redo; - - void _button_pressed(Object *p_item,int p_column, int p_id); - - Variant get_drag_data_fw(const Point2& p_point,Control* p_from); - bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const; - void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); - -protected: - void _notification(int p_what); - void _gui_input(InputEvent p_event); - static void _bind_methods(); -public: - - void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; } - void edit(Ref p_sample); - SampleLibraryEditor(); -}; - -class SampleLibraryEditorPlugin : public EditorPlugin { - - GDCLASS( SampleLibraryEditorPlugin, EditorPlugin ); - - SampleLibraryEditor *sample_library_editor; - EditorNode *editor; - Button *button; - -public: - - virtual String get_name() const { return "SampleLibrary"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - - SampleLibraryEditorPlugin(EditorNode *p_node); - ~SampleLibraryEditorPlugin(); - -}; - -#endif -#endif // SAMPLE_LIBRARY_EDITOR_PLUGIN_H diff --git a/editor/plugins/sample_player_editor_plugin.cpp b/editor/plugins/sample_player_editor_plugin.cpp deleted file mode 100644 index 821c7ecc01ca..000000000000 --- a/editor/plugins/sample_player_editor_plugin.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*************************************************************************/ -/* sample_player_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#if 0 -#include "sample_player_editor_plugin.h" - -#include "scene/resources/sample_library.h" - - -void SamplePlayerEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - play->set_icon( get_icon("Play","EditorIcons") ); - stop->set_icon( get_icon("Stop","EditorIcons") ); - } - -} - -void SamplePlayerEditor::_node_removed(Node *p_node) { - - if(p_node==node) { - node=NULL; - hide(); - } - -} - -void SamplePlayerEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_play"),&SamplePlayerEditor::_play); - ClassDB::bind_method(D_METHOD("_stop"),&SamplePlayerEditor::_stop); - -} - - -void SamplePlayerEditor::_play() { - - if (!node) - return; - if (samples->get_item_count()<=0) - return; - - node->call("play",samples->get_item_text( samples->get_selected() )); - stop->set_pressed(false); - play->set_pressed(true); -} - -void SamplePlayerEditor::_stop() { - - if (!node) - return; - if (samples->get_item_count()<=0) - return; - - node->call("stop_all"); - print_line("STOP ALL!!"); - stop->set_pressed(true); - play->set_pressed(false); - -} - - -void SamplePlayerEditor::_update_sample_library() { - - samples->clear(); - Ref sl = node->call("get_sample_library"); - if (sl.is_null()) { - samples->add_item(""); - return; //no sample library; - } - - List samplenames; - sl->get_sample_list(&samplenames); - samplenames.sort_custom(); - for(List::Element *E=samplenames.front();E;E=E->next()) { - samples->add_item(E->get()); - } - -} - -void SamplePlayerEditor::edit(Node *p_sample_player) { - - node=p_sample_player; - if (node) { - _update_sample_library(); - } - -} -SamplePlayerEditor::SamplePlayerEditor() { - - - play = memnew( Button ); - - play->set_position(Point2( 5, 5 )); - play->set_toggle_mode(true); - play->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-250); - play->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-230); - play->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); - play->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0); - - add_child(play); - - stop = memnew( Button ); - - stop->set_position(Point2( 35, 5 )); - stop->set_toggle_mode(true); - stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-220); - stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-200); - stop->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); - stop->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0); - add_child(stop); - - samples = memnew( OptionButton ); - samples->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,-190); - samples->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,-5); - samples->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); - samples->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0); - add_child(samples); - - play->connect("pressed", this,"_play"); - stop->connect("pressed", this,"_stop"); - -} - - -void SamplePlayerEditorPlugin::edit(Object *p_object) { - - sample_player_editor->edit(Object::cast_to(p_object)); -} - -bool SamplePlayerEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("SamplePlayer2D") || p_object->is_class("SamplePlayer") || p_object->is_class("SpatialSamplePlayer"); -} - -void SamplePlayerEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - sample_player_editor->show(); - sample_player_editor->set_fixed_process(true); - } else { - - sample_player_editor->hide(); - sample_player_editor->set_fixed_process(false); - sample_player_editor->edit(NULL); - } - -} - -SamplePlayerEditorPlugin::SamplePlayerEditorPlugin(EditorNode *p_node) { - - editor=p_node; - sample_player_editor = memnew( SamplePlayerEditor ); - editor->get_viewport()->add_child(sample_player_editor); - - sample_player_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); - sample_player_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); - sample_player_editor->set_margin(MARGIN_LEFT,-250); - sample_player_editor->set_margin(MARGIN_RIGHT,0); - sample_player_editor->set_margin(MARGIN_TOP,0); - sample_player_editor->set_margin(MARGIN_BOTTOM,10); - - - sample_player_editor->hide(); - - - -} - - -SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin() -{ -} - -#endif diff --git a/editor/plugins/sample_player_editor_plugin.h b/editor/plugins/sample_player_editor_plugin.h deleted file mode 100644 index 5c1b25aaa23b..000000000000 --- a/editor/plugins/sample_player_editor_plugin.h +++ /dev/null @@ -1,91 +0,0 @@ -/*************************************************************************/ -/* sample_player_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef SAMPLE_PLAYER_EDITOR_PLUGIN_H -#define SAMPLE_PLAYER_EDITOR_PLUGIN_H - -#if 0 - -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/3d/spatial_sample_player.h" -#include "scene/audio/sample_player.h" -#include "scene/gui/option_button.h" - -/** - @author Juan Linietsky -*/ - -class SamplePlayerEditor : public Control { - - GDCLASS(SamplePlayerEditor, Control ); - - Panel *panel; - Button * play; - Button * stop; - OptionButton *samples; - Node *node; - - - void _update_sample_library(); - void _play(); - void _stop(); - -protected: - void _notification(int p_what); - void _node_removed(Node *p_node); - static void _bind_methods(); -public: - - void edit(Node *p_sample_player); - SamplePlayerEditor(); -}; - -class SamplePlayerEditorPlugin : public EditorPlugin { - - GDCLASS( SamplePlayerEditorPlugin, EditorPlugin ); - - SamplePlayerEditor *sample_player_editor; - EditorNode *editor; - -public: - - virtual String get_name() const { return "SamplePlayer"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - - SamplePlayerEditorPlugin(EditorNode *p_node); - ~SamplePlayerEditorPlugin(); - -}; - -#endif -#endif // SAMPLE_PLAYER_EDITOR_PLUGIN_H diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a6db0f6e590b..9b83d4e48350 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -29,18 +29,19 @@ /*************************************************************************/ #include "script_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" +#include "core/project_settings.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "editor/node_dock.h" #include "editor/script_editor_debugger.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "node_dock.h" -#include "os/file_access.h" -#include "os/input.h" -#include "os/keyboard.h" -#include "os/os.h" -#include "project_settings.h" #include "scene/main/viewport.h" + /*** SCRIPT EDITOR ****/ void ScriptEditorBase::_bind_methods() { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 251416f8532d..5a57efd941f4 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -29,20 +29,17 @@ /*************************************************************************/ #include "shader_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/property_editor.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/keyboard.h" -#include "os/os.h" #include "scene/resources/shader_graph.h" #include "servers/visual/shader_types.h" -#include "spatial_editor_plugin.h" -/*** SETTINGS EDITOR ****/ - -/*** SCRIPT EDITOR ****/ +/*** SHADER SCRIPT EDITOR ****/ Ref ShaderTextEditor::get_edited_shader() const { diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp index 7ad32464af73..3f8f2488dc1a 100644 --- a/editor/plugins/shader_graph_editor_plugin.cpp +++ b/editor/plugins/shader_graph_editor_plugin.cpp @@ -27,9 +27,11 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "shader_graph_editor_plugin.h" +// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin, +// it needs to be ported to the new shader language. #if 0 +#include "shader_graph_editor_plugin.h" #include "canvas_item_editor_plugin.h" #include "os/keyboard.h" diff --git a/editor/plugins/shader_graph_editor_plugin.h b/editor/plugins/shader_graph_editor_plugin.h index e7cab50d8de5..159c752ee6fc 100644 --- a/editor/plugins/shader_graph_editor_plugin.h +++ b/editor/plugins/shader_graph_editor_plugin.h @@ -30,6 +30,10 @@ #ifndef SHADER_GRAPH_EDITOR_PLUGIN_H #define SHADER_GRAPH_EDITOR_PLUGIN_H +// FIXME: Godot 3.0 broke compatibility with ShaderGraphEditorPlugin, +// it needs to be ported to the new shader language. +#if 0 + #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/property_editor.h" @@ -39,11 +43,11 @@ #include "scene/gui/tree.h" #include "scene/resources/shader.h" #include "scene/resources/shader_graph.h" + /** @author Juan Linietsky */ -#if 0 class GraphColorRampEdit : public Control { GDCLASS(GraphColorRampEdit,Control); @@ -238,5 +242,6 @@ public: ~ShaderGraphEditorPlugin(); }; + #endif -#endif +#endif // SHADER_GRAPH_EDITOR_PLUGIN_H diff --git a/editor/project_manager.h b/editor/project_manager.h index 181d3cc5d933..11fd3b2e01ed 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -30,7 +30,7 @@ #ifndef PROJECT_MANAGER_H #define PROJECT_MANAGER_H -#include "editor/asset_library_editor_plugin.h" +#include "editor/plugins/asset_library_editor_plugin.h" #include "scene/gui/dialogs.h" #include "scene/gui/file_dialog.h" #include "scene/gui/scroll_container.h" diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index b4457cfbb55b..3352ea22de9c 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -29,13 +29,13 @@ /*************************************************************************/ #include "project_settings_editor.h" -#include "editor_node.h" -#include "global_constants.h" -#include "os/keyboard.h" -#include "project_settings.h" +#include "core/global_constants.h" +#include "core/os/keyboard.h" +#include "core/project_settings.h" +#include "core/translation.h" +#include "editor/editor_node.h" #include "scene/gui/margin_container.h" #include "scene/gui/tab_container.h" -#include "translation.h" ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL; @@ -184,8 +184,6 @@ void ProjectSettingsEditor::_device_input_add() { int idx = edit_idx; Variant old_val = ProjectSettings::get_singleton()->get(name); Array arr = old_val; - // ie.device = device_id->get_value(); - // ie.type = add_type; switch (add_type) { @@ -619,7 +617,6 @@ void ProjectSettingsEditor::_update_actions() { continue; TreeItem *item = input_editor->create_item(root); - //item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); item->set_text(0, name); item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) { @@ -627,7 +624,6 @@ void ProjectSettingsEditor::_update_actions() { item->set_editable(0, true); } item->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); - //item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED); Array actions = ProjectSettings::get_singleton()->get(pi.name); @@ -748,19 +744,7 @@ void ProjectSettingsEditor::_item_add() { } String catname = category->get_text().strip_edges(); - /*if (!catname.is_valid_identifier()) { - message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _"); - message->popup_centered(Size2(300,100)); - return; - }*/ - String propname = property->get_text().strip_edges(); - /*if (!propname.is_valid_identifier()) { - message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _"); - message->popup_centered(Size2(300,100)); - return; - }*/ - String name = catname != "" ? catname + "/" + propname : propname; undo_redo->create_action(TTR("Add Global Property")); @@ -882,13 +866,6 @@ void ProjectSettingsEditor::_save() { message->popup_centered(Size2(300, 100) * EDSCALE); } -void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) { - - String full_item = globals_editor->get_full_item_path(p_name); - - _settings_changed(); -} - void ProjectSettingsEditor::_settings_changed() { timer->start(); @@ -1357,7 +1334,6 @@ void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettingsEditor::_add_item, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettingsEditor::_device_input_add); ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettingsEditor::_press_a_key_confirm); - ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettingsEditor::_settings_prop_edited); ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettingsEditor::_copy_to_platform); ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettingsEditor::_update_translations); ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettingsEditor::_translation_delete); @@ -1391,12 +1367,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container = memnew(TabContainer); tab_container->set_tab_align(TabContainer::ALIGN_LEFT); add_child(tab_container); - //set_child_rect(tab_container); - - //tab_container->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 15 ); - //tab_container->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 15 ); - //tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 ); - //tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 ); VBoxContainer *props_base = memnew(VBoxContainer); props_base->set_alignment(BoxContainer::ALIGN_BEGIN); @@ -1478,21 +1448,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { globals_editor->register_search_box(search_box); globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected"); globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); - globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited"); - - /* - Button *save = memnew( Button ); - props_base->add_child(save); - - save->set_anchor(MARGIN_LEFT,ANCHOR_END); - save->set_anchor(MARGIN_RIGHT,ANCHOR_END); - save->set_anchor(MARGIN_TOP,ANCHOR_END); - save->set_anchor(MARGIN_BOTTOM,ANCHOR_END); - save->set_begin( Point2(80,28) ); - save->set_end( Point2(10,20) ); - save->set_text("Save"); - save->connect("pressed",this,"_save"); -*/ + globals_editor->get_property_editor()->connect("property_edited", this, "_settings_changed"); Button *del = memnew(Button); hbc->add_child(del); @@ -1506,16 +1462,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { popup_copy_to_feature->set_disabled(true); add_prop_bar->add_child(popup_copy_to_feature); - /*List ep; - EditorImportExport::get_singleton()->get_export_platforms(&ep); - ep.sort_custom(); - - for(List::Element *E=ep.front();E;E=E->next()) { - - popup_copy_to_feature->get_popup()->add_item( E->get() ); - - }*/ - popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform"); popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show"); @@ -1524,7 +1470,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { message = memnew(ConfirmationDialog); add_child(message); - //message->get_cancel()->hide(); message->set_hide_on_ok(true); Control *input_base = memnew(Control); @@ -1591,7 +1536,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { hbc = memnew(HBoxContainer); device_input->add_child(hbc); - //device_input->set_child_rect(hbc); VBoxContainer *vbc_left = memnew(VBoxContainer); hbc->add_child(vbc_left); @@ -1616,18 +1560,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { device_index = memnew(OptionButton); vbc_right->add_child(device_index); - /* - save = memnew( Button ); - input_base->add_child(save); - save->set_anchor(MARGIN_LEFT,ANCHOR_END); - save->set_anchor(MARGIN_RIGHT,ANCHOR_END); - save->set_anchor(MARGIN_TOP,ANCHOR_END); - save->set_anchor(MARGIN_BOTTOM,ANCHOR_END); - save->set_begin( Point2(80,28) ); - save->set_end( Point2(10,20) ); - save->set_text("Save"); - save->connect("pressed",this,"_save"); -*/ setting = false; //translations @@ -1739,14 +1671,4 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { add_child(timer); updating_translations = false; - - /* - Control * es = memnew( Control ); - es->set_name("Export"); - tab_container->add_child(es); - export_settings = memnew( ProjectExportSettings ); - es->add_child(export_settings); - export_settings->set_area_as_parent_rect(); - export_settings->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 ); -*/ } diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 4390a23d6074..6deb9e1d465e 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -30,17 +30,16 @@ #ifndef PROJECT_SETTINGS_H #define PROJECT_SETTINGS_H -#include "editor_autoload_settings.h" -#include "editor_data.h" -#include "editor_plugin_settings.h" -#include "property_editor.h" +#include "core/undo_redo.h" +#include "editor/editor_autoload_settings.h" +#include "editor/editor_data.h" +#include "editor/editor_plugin_settings.h" +#include "editor/property_editor.h" #include "scene/gui/dialogs.h" #include "scene/gui/tab_container.h" -#include "undo_redo.h" - -//#include "project_export_settings.h" class ProjectSettingsEditor : public AcceptDialog { + GDCLASS(ProjectSettingsEditor, AcceptDialog); enum InputType { @@ -122,10 +121,8 @@ class ProjectSettingsEditor : public AcceptDialog { void _press_a_key_confirm(); void _show_last_added(const Ref &p_event, const String &p_name); - void _settings_prop_edited(const String &p_name); void _settings_changed(); - //ProjectExportSettings *export_settings; void _copy_to_platform(int p_which); void _translation_file_open(); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f175e4c8e4da..a6a29bb66c3f 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -29,24 +29,24 @@ /*************************************************************************/ #include "property_editor.h" -#include "array_property_edit.h" -#include "class_db.h" -#include "create_dialog.h" -#include "editor_export.h" -#include "editor_file_system.h" -#include "editor_help.h" -#include "editor_node.h" -#include "editor_settings.h" -#include "io/image_loader.h" -#include "io/marshalls.h" -#include "io/resource_loader.h" -#include "multi_node_edit.h" -#include "os/input.h" -#include "os/keyboard.h" -#include "pair.h" -#include "print_string.h" -#include "project_settings.h" -#include "property_selector.h" +#include "core/class_db.h" +#include "core/io/image_loader.h" +#include "core/io/marshalls.h" +#include "core/io/resource_loader.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" +#include "core/pair.h" +#include "core/print_string.h" +#include "core/project_settings.h" +#include "editor/array_property_edit.h" +#include "editor/create_dialog.h" +#include "editor/editor_export.h" +#include "editor/editor_file_system.h" +#include "editor/editor_help.h" +#include "editor/editor_node.h" +#include "editor/editor_settings.h" +#include "editor/multi_node_edit.h" +#include "editor/property_selector.h" #include "scene/gui/label.h" #include "scene/main/viewport.h" #include "scene/resources/font.h" @@ -59,11 +59,6 @@ void CustomPropertyEditor::_notification(int p_what) { RID ci = get_canvas_item(); get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size())); - /* - if (v.get_type()==Variant::COLOR) { - - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v ); - }*/ } if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) { hide(); @@ -202,17 +197,6 @@ void CustomPropertyEditor::_menu_option(int p_which) { emit_signal("variant_changed"); } break; - case OBJ_MENU_REIMPORT: { - - RES r = v; - /* if (r.is_valid() && r->get_import_metadata().is_valid()) { - Ref rimd = r->get_import_metadata(); - Ref eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); - if (eip.is_valid()) { - eip->import_dialog(r->get_path()); - } - }*/ - } break; case OBJ_MENU_NEW_SCRIPT: { if (Object::cast_to(owner)) @@ -515,8 +499,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: text_edit->show(); text_edit->set_text(v); - //action_buttons[0]; - int button_margin = get_constant("button_margin", "Dialogs"); int margin = get_constant("margin", "Dialogs"); @@ -531,7 +513,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } else if (hint == PROPERTY_HINT_TYPE_STRING) { - /* FIXME: This is repeated twice, with slightly different behavior! Which one? Check line 644 */ if (!create_dialog) { create_dialog = memnew(CreateDialog); create_dialog->connect("create", this, "_create_dialog_callback"); @@ -648,14 +629,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: updating = false; return false; - } else if (hint == PROPERTY_HINT_TYPE_STRING) { - if (!create_dialog) { - /* FIXME: ... and here. See line 529 */ - create_dialog = memnew(CreateDialog); - create_dialog->connect("create", this, "_create_dialog_callback"); - add_child(create_dialog); - } - } else { List names; names.push_back("string:"); @@ -822,39 +795,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_pick_color(v); color_picker->set_focus_on_line_edit(); - /* - int ofs=80; - int m=10; - int h=20; - Color c=v; - float values[4]={c.r,c.g,c.b,c.a}; - for (int i=0;i<4;i++) { - int y=m+i*h; - - value_editor[i]->show(); - value_label[i]->show(); - value_label[i]->set_position(Point2(ofs,y)); - scroll[i]->set_min(0); - scroll[i]->set_max(1.0); - scroll[i]->set_page(0); - scroll[i]->set_position(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0))); - scroll[i]->set_val(values[i]); - scroll[i]->set_size(Size2(120,1)); - scroll[i]->show(); - value_editor[i]->set_position(Point2(ofs+140,y)); - value_editor[i]->set_size(Size2(40,h)); - value_editor[i]->set_text( String::num(values[i],2 )); - - } - - value_label[0]->set_text("R"); - value_label[1]->set_text("G"); - value_label[2]->set_text("B"); - value_label[3]->set_text("A"); - - Size2 new_size = value_editor[3]->get_position() + value_editor[3]->get_size() + Point2(10,10); - set_size( new_size ); - */ } break; @@ -930,18 +870,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), "Make Unique", OBJ_MENU_MAKE_UNIQUE); RES r = v; if (r.is_valid() && r->get_path().is_resource_file()) { - /*if (r->get_import_metadata().is_valid()) { - menu->add_separator(); - menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT); - }*/ menu->add_separator(); menu->add_item(TTR("Show in File System"), OBJ_MENU_SHOW_IN_FILE_SYSTEM); } - /*if (r.is_valid() && r->get_path().is_resource_file()) { - menu->set_item_tooltip(1,r->get_path()); - } else if (r.is_valid()) { - menu->set_item_tooltip(1,r->get_name()+" ("+r->get_type()+")"); - }*/ } else { } @@ -1007,14 +938,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return true; } -////void CustomPropertyEditor::_save_properties_values(List p_names) { -//// -//// field_names=p_names; -//// for (int i=0;i inheritors; - //ClassDB::get_inheriters_from(hint_text,&inheritors); - //inheritors.push_front(hint_text); - - //ERR_FAIL_INDEX( p_idx, inheritors.size() ); String intype = inheritors_array[p_idx]; Object *obj = ClassDB::instance(intype); @@ -1382,33 +1300,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } } -void CustomPropertyEditor::_scroll_modified(double p_value) { - - if (updating) - return; - /* - switch(type) { - - case Variant::COLOR: { - - for (int i=0;i<4;i++) { - - value_editor[i]->set_text( String::num(scroll[i]->get_val(),2) ); - } - Color c; - c.r=scroll[0]->get_val(); - c.g=scroll[1]->get_val(); - c.b=scroll[2]->get_val(); - c.a=scroll[3]->get_val(); - v=c; - update(); - emit_signal("variant_changed"); - } break; - default: {} - } - */ -} - void CustomPropertyEditor::_drag_easing(const Ref &p_ev) { Ref mm = p_ev; @@ -1433,7 +1324,6 @@ void CustomPropertyEditor::_drag_easing(const Ref &p_ev) { val = Math::log(val) / Math::log((float)2.0); //logspace val += rel * 0.05; - // val = Math::pow(2.0f, val); if (sg) @@ -1441,11 +1331,8 @@ void CustomPropertyEditor::_drag_easing(const Ref &p_ev) { v = val; easing_draw->update(); - //emit_signal("variant_changed"); emit_signal("variant_changed"); } - // if (p_ev.type == Ref::MOUSE_BUTTON && p_ev->get_button_index() == BUTTON_LEFT) { - // } } void CustomPropertyEditor::_draw_easing() { @@ -1456,7 +1343,6 @@ void CustomPropertyEditor::_draw_easing() { Rect2 r(Point2(), s); r = r.grow(3); get_stylebox("normal", "LineEdit")->draw(ci, r); - //VisualServer::get_singleton()->canvas_item_add int points = 48; @@ -1508,6 +1394,7 @@ void CustomPropertyEditor::_modified(String p_string) { if (updating) return; + updating = true; switch (type) { case Variant::INT: { @@ -1704,20 +1591,7 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::COLOR: { - /* - for (int i=0;i<4;i++) { - scroll[i]->set_val( value_editor[i]->get_text().to_double() ); - } - Color c; - c.r=value_editor[0]->get_text().to_double(); - c.g=value_editor[1]->get_text().to_double(); - c.b=value_editor[2]->get_text().to_double(); - c.a=value_editor[3]->get_text().to_double(); - v=c; - update(); - emit_signal("variant_changed"); - */ } break; case Variant::NODE_PATH: { @@ -1870,7 +1744,6 @@ void CustomPropertyEditor::_bind_methods() { ClassDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit); ClassDB::bind_method("_modified", &CustomPropertyEditor::_modified); ClassDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified); - ClassDB::bind_method("_scroll_modified", &CustomPropertyEditor::_scroll_modified); ClassDB::bind_method("_action_pressed", &CustomPropertyEditor::_action_pressed); ClassDB::bind_method("_file_selected", &CustomPropertyEditor::_file_selected); ClassDB::bind_method("_type_create_selected", &CustomPropertyEditor::_type_create_selected); @@ -1914,7 +1787,6 @@ CustomPropertyEditor::CustomPropertyEditor() { scroll[i]->set_max(1.0); scroll[i]->set_step(0.01); add_child(scroll[i]); - scroll[i]->connect("value_changed", this, "_scroll_modified"); } checks20gc = memnew(GridContainer); @@ -1968,7 +1840,6 @@ CustomPropertyEditor::CustomPropertyEditor() { error = memnew(ConfirmationDialog); error->set_title(TTR("Error!")); add_child(error); - //error->get_cancel()->hide(); scene_tree = memnew(SceneTreeDialog); add_child(scene_tree); @@ -1984,7 +1855,6 @@ CustomPropertyEditor::CustomPropertyEditor() { easing_draw->hide(); easing_draw->connect("draw", this, "_draw_easing"); easing_draw->connect("gui_input", this, "_drag_easing"); - //easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent()); easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE); type_button = memnew(MenuButton); @@ -2056,8 +1926,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p bool found = false; - //print_line("for prop - "+String(p_prop)); - while (node) { Ref ss; @@ -2068,13 +1936,11 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p } else { ss = node->get_scene_instance_state(); } - //print_line("at - "+String(edited_scene->get_path_to(node))); if (ss.is_valid()) { NodePath np = node->get_path_to(orig); int node_idx = ss->find_node_by_path(np); - //print_line("\t valid, nodeidx "+itos(node_idx)); if (node_idx >= 0) { bool lfound = false; Variant lvar; @@ -2083,7 +1949,6 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_p found = true; value = lvar; - //print_line("\t found value "+String(value)); } } } @@ -2107,8 +1972,6 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); bool found_state = false; - //print_line("for prop - "+String(p_prop)); - while (node) { Ref ss; @@ -2247,8 +2110,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p break; } - //p_item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE ); - if (p_type == Variant::REAL) { p_item->set_range(1, obj->get(p_name)); @@ -2310,7 +2171,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p case Variant::COLOR: { tree->update(); - //p_item->set_text(1,obj->get(p_name)); } break; case Variant::NODE_PATH: { @@ -2424,17 +2284,7 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) if (_get_instanced_node_original_property(p_name, vorig) || usage) { Variant v = obj->get(p_name); - bool changed = _is_property_different(v, vorig, usage); - - //if ((found!=-1 && !is_disabled)!=changed) { - - if (changed) { - - has_reload = true; - } else { - } - - //} + bool has_reload = _is_property_different(v, vorig, usage); } } @@ -2453,7 +2303,6 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) } } - //print_line("found: "+itos(found)+" has reload: "+itos(has_reload)+" is_disabled "+itos(is_disabled)); if (found != -1 && !has_reload) { if (!is_disabled) { @@ -2481,14 +2330,11 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction String allowed_type = d["hint_text"]; - print_line("allowed type " + allowed_type); - Dictionary drag_data = p_drag_data; if (drag_data.has("type") && String(drag_data["type"]) == "resource") { Ref res = drag_data["resource"]; for (int i = 0; i < allowed_type.get_slice_count(","); i++) { String at = allowed_type.get_slice(",", i).strip_edges(); - print_line("RES vs " + at); if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) { return true; } @@ -2499,18 +2345,14 @@ bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Diction Vector files = drag_data["files"]; - print_line("fileS: " + String(Variant(files))); if (files.size() == 1) { String file = files[0]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); - print_line("file: " + file); - print_line("type: " + ftype); if (ftype != "") { for (int i = 0; i < allowed_type.get_slice_count(","); i++) { String at = allowed_type.get_slice(",", i).strip_edges(); - print_line("FILE vs " + at); if (ClassDB::is_parent_class(ftype, at)) { return true; } @@ -2733,7 +2575,6 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMapcreate_item(parent); @@ -2783,64 +2624,6 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) { if (name != String()) { _check_reload_status(name, p_item); -#if 0 - bool has_reload=false; - - int found=-1; - for(int i=0;iget_button_count(1);i++) { - - if (p_item->get_button_id(1,i)==3) { - found=i; - break; - } - } - - if (_might_be_in_instance()) { - - Variant vorig; - Dictionary d=p_item->get_metadata(0); - int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0; - - - if (_get_instanced_node_original_property(name,vorig) || usage) { - Variant v = obj->get(name); - - - bool changed = _is_property_different(v,vorig,usage); - - if ((found!=-1)!=changed) { - - if (changed) { - - has_reload=true; - - } else { - - //p_item->erase_button(1,found); - } - - } - - } - - } - - if (!has_reload && !obj->get_script().is_null()) { - Ref