diff options
Diffstat (limited to 'editor')
39 files changed, 294 insertions, 3795 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index d49b240c80..a9dc81dc54 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1093,12 +1093,7 @@ void CodeTextEditor::update_editor_settings() { void CodeTextEditor::set_error(const String &p_error) { - if (p_error != "") { - error->set_text(p_error); - error->show(); - } else { - error->hide(); - } + error->set_text(p_error); } void CodeTextEditor::_update_font() { @@ -1223,12 +1218,10 @@ CodeTextEditor::CodeTextEditor() { error = memnew(Label); status_bar->add_child(error); - error->hide(); error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right 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_audio_buses.cpp b/editor/editor_audio_buses.cpp index 1f72a59a14..9df952b017 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -403,12 +403,13 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) { Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y); - delete_popup->set_position(get_global_position() + pos); - delete_popup->popup(); + bus_popup->set_position(get_global_position() + pos); + bus_popup->set_item_disabled(1, get_index() == 0); + bus_popup->popup(); } } -void EditorAudioBus::_delete_pressed(int p_option) { +void EditorAudioBus::_bus_popup_pressed(int p_option) { if (p_option == 1) { emit_signal("delete_request"); @@ -604,7 +605,7 @@ void EditorAudioBus::_bind_methods() { ClassDB::bind_method("_effect_selected", &EditorAudioBus::_effect_selected); ClassDB::bind_method("_effect_add", &EditorAudioBus::_effect_add); ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input); - ClassDB::bind_method("_delete_pressed", &EditorAudioBus::_delete_pressed); + ClassDB::bind_method("_bus_popup_pressed", &EditorAudioBus::_bus_popup_pressed); ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw); ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw); ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw); @@ -735,11 +736,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) { effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } - delete_popup = bus_options->get_popup(); - delete_popup->add_item(TTR("Duplicate")); - delete_popup->add_item(TTR("Delete")); - add_child(delete_popup); - delete_popup->connect("index_pressed", this, "_delete_pressed"); + bus_popup = bus_options->get_popup(); + bus_popup->add_item(TTR("Duplicate")); + bus_popup->add_item(TTR("Delete")); + bus_popup->connect("index_pressed", this, "_bus_popup_pressed"); delete_effect_popup = memnew(PopupMenu); delete_effect_popup->add_item(TTR("Delete Effect")); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index ef7f5e0adf..9d80ff67d1 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -66,7 +66,7 @@ class EditorAudioBus : public PanelContainer { OptionButton *send; PopupMenu *effect_options; - PopupMenu *delete_popup; + PopupMenu *bus_popup; PopupMenu *delete_effect_popup; Button *solo; @@ -78,7 +78,7 @@ class EditorAudioBus : public PanelContainer { bool updating_bus; void _gui_input(const Ref<InputEvent> &p_event); - void _delete_pressed(int p_option); + void _bus_popup_pressed(int p_option); void _name_changed(const String &p_new_name); void _name_focus_exit() { _name_changed(track_name->get_text()); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 86f31d7589..29417709a3 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -893,6 +893,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < methods.size(); i++) { + bool is_vararg = methods[i].qualifiers.find("vararg") != -1; + class_desc->push_cell(); method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overridden if description @@ -916,7 +918,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (methods[i].description != "") class_desc->pop(); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? "( " : "("); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); @@ -936,17 +938,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); } - if (methods[i].qualifiers.find("vararg") != -1) { + if (is_vararg) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); - class_desc->add_text(","); + if (methods[i].arguments.size()) + class_desc->add_text(", "); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(" ... "); + class_desc->add_text("..."); class_desc->pop(); class_desc->pop(); } class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? " )" : ")"); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { @@ -1313,6 +1316,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < methods.size(); i++) { + bool is_vararg = methods[i].qualifiers.find("vararg") != -1; + method_line[methods[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); @@ -1323,7 +1328,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_text(methods[i].name); class_desc->pop(); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? "( " : "("); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); @@ -1343,8 +1348,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); } + if (is_vararg) { + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + if (methods[i].arguments.size()) + class_desc->add_text(", "); + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->add_text("..."); + class_desc->pop(); + class_desc->pop(); + } + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? " )" : ")"); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f5c714fc60..8cc1bb9b07 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 "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 <stdio.h> -// 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" 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<Ref<Resource> > changed; List<Ref<Resource> > cached; ResourceCache::get_cached_resources(&cached); - //this should probably be done in a thread.. + // FIXME: This should be done in a thread. for (List<Ref<Resource> >::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<Ref<Resource> >::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<Resource> &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<Resource> &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<Resource> &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<RES, bool> &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, bool> 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<EditorImport::Conflict> conflicts; - EditorImport::check_conflicts(src,dst,&conflicts); - - bool conflicted=false; - for (List<EditorImport::Conflict>::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; @@ -1152,9 +982,6 @@ void EditorNode::_dialog_action(String p_file) { //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: { Ref<Script> scr = ResourceLoader::load(p_file, "Script", true); @@ -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<Resource>(current_res)); - - //top_pallete->set_current_tab(1); } else if (is_node) { Node *current_node = Object::cast_to<Node>(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<String> 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)); @@ -2567,25 +2218,26 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { update_menu->get_popup()->set_item_checked(0, true); update_menu->get_popup()->set_item_checked(1, false); OS::get_singleton()->set_low_processor_usage_mode(false); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_ALWAYS); } break; case SETTINGS_UPDATE_CHANGES: { update_menu->get_popup()->set_item_checked(0, false); update_menu->get_popup()->set_item_checked(1, true); OS::get_singleton()->set_low_processor_usage_mode(true); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES); } break; case SETTINGS_UPDATE_SPINNER_HIDE: { + update_menu->set_icon(gui_base->get_icon("Collapse", "EditorIcons")); update_menu->get_popup()->toggle_item_checked(3); + bool checked = update_menu->get_popup()->is_item_checked(3); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_spinner_hide", checked); } break; case SETTINGS_PREFERENCES: { 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 +2250,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<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); @@ -2609,7 +2259,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 +2288,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 +2596,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 +2647,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 +2655,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;i<editor_table.size();i++) { - if (editor_plugin_screen==editor_table[i]) { - current=i; - break; - } - } - - - if (idx<2 && current<2) { - //only set tab for 2D and 3D - _editor_select(idx); - //print_line(" setting main tab: "+itos(p_state["main_tab"])); - } - } -#else - if (get_edited_scene()) { int current = -1; @@ -3114,7 +2679,6 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { } } } -#endif if (p_state.has("scene_tree_offset")) scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_value(p_state["scene_tree_offset"]); @@ -3123,16 +2687,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 +2724,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 +2732,6 @@ void EditorNode::set_current_scene(int p_idx) { if (Object::cast_to<Popup>(new_scene)) Object::cast_to<Popup>(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 +2740,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 +2795,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 +2804,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 +2817,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 +2877,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 +2888,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<SceneState> 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<SceneState>()); 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 +2910,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 +2918,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 +2963,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 +2984,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 +3021,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<EditorOptimizedSaver> 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 +3060,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;i<import_monitor->get_changes().size();i++) { - - if (fn==import_monitor->get_changes()[i]) - return true; - } - } - - for(int i=0;i<p_from->get_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 +3100,9 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorPlugin>(); ClassDB::register_class<EditorImportPlugin>(); - // ClassDB::register_class<EditorExportPlugin>(); - // ClassDB::register_class<EditorScenePostImport>(); ClassDB::register_class<EditorScript>(); ClassDB::register_class<EditorSelection>(); ClassDB::register_class<EditorFileDialog>(); - //ClassDB::register_type<EditorImportExport>(); ClassDB::register_class<EditorSettings>(); ClassDB::register_class<EditorSpatialGizmo>(); ClassDB::register_class<EditorResourcePreview>(); @@ -3718,8 +3112,10 @@ void EditorNode::register_editor_types() { ClassDB::register_virtual_class<ScriptEditor>(); ClassDB::register_virtual_class<EditorInterface>(); - //ClassDB::register_type<EditorImporter>(); - //ClassDB::register_type<EditorPostImport>(); + // FIXME: Is this stuff obsolete, or should it be ported to new APIs? + //ClassDB::register_class<EditorExportPlugin>(); + //ClassDB::register_class<EditorScenePostImport>(); + //ClassDB::register_type<EditorImportExport>(); } void EditorNode::unregister_editor_types() { @@ -4157,21 +3553,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<ConfigFile> p_layout, const String &p_section) { for (int i = 0; i < DOCK_SLOT_MAX; i++) { @@ -4419,27 +3800,20 @@ void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &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 +3994,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 +4126,14 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control * void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) { + /* String cur_path = filesystem_dock->get_current_path(); - // for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) { - // EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); - // } + for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) { + EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); + } + */ } + void EditorNode::_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 +4321,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 +4337,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 +4377,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 +4556,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 +4579,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 +4600,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 +4631,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 +4638,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 +4719,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<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer"); - //scene_root_parent->add_style_override("panel",sp); - - /*scene_root_parent->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END ); - scene_root_parent->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END ); - 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<World2D>( 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 +4741,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 +4756,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 +4803,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 +4836,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 +4867,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 +4924,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 +4931,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 +4965,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); @@ -5668,16 +4985,16 @@ EditorNode::EditorNode() { p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES); p->add_separator(); p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE); - p->set_item_checked(1, true); + int update_mode = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES); + int hide_spinner = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_spinner_hide", false); + _menu_option(update_mode); + if (hide_spinner) { + _menu_option(SETTINGS_UPDATE_SPINNER_HIDE); + } 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 +5056,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 +5118,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 +5161,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 +5189,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 +5204,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 +5263,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 +5304,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 +5317,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 +5335,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 +5353,7 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator(Ref<EditorPackedScenePreviewPlugin>(memnew(EditorPackedScenePreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorMaterialPreviewPlugin>(memnew(EditorMaterialPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorScriptPreviewPlugin>(memnew(EditorScriptPreviewPlugin))); + // FIXME: Needs to be rewritten for AudioStream in Godot 3.0+ //resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin ))); resource_preview->add_preview_generator(Ref<EditorMeshPreviewPlugin>(memnew(EditorMeshPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorBitmapPreviewPlugin>(memnew(EditorBitmapPreviewPlugin))); @@ -6087,7 +5366,6 @@ EditorNode::EditorNode() { editor_plugins_over = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList); - //force_top_viewport(true); _edit_current(); current = NULL; @@ -6095,32 +5373,10 @@ 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")); @@ -6129,7 +5385,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 +5405,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<EditorImporterCollada>( memnew(EditorImporterCollada ))); - EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed"); EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed"); @@ -6183,9 +5433,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<ImageTexture> 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 +5443,6 @@ EditorNode::EditorNode() { import_dock->initialize_import_options(); { - _initializing_addons = true; Vector<String> addons; if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) { diff --git a/editor/editor_node.h b/editor/editor_node.h index ceb35aad0a..8a02b16ca2 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 <reduzio@gmail.com> */ @@ -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<ResourceImportMetadata> 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> 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<ToolButton *> main_editor_buttons; Vector<EditorPlugin *> 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<String> &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<FileDialog *> file_dialogs; @@ -580,7 +551,6 @@ private: void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section); void _load_docks_from_config(Ref<ConfigFile> 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 08ee8c3c9e..5b73d83691 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> 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<ConfigFile> 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<ConfigFile> 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<ConfigFile> 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<ShortCut> 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 06d12917fd..a0a52621a0 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<Ref<Mesh> 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<EditorPostImport> 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 43d6c22bcc..5b71f51b0f 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<Resource> &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<Resource> &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 index c01c2de6b7..c01c2de6b7 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp diff --git a/editor/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index fa768ec96a..fa768ec96a 100644 --- a/editor/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 5520d196e0..c6fa796226 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -48,6 +48,9 @@ void CollisionPolygonEditor::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { + if (!node) { + return; + } if (node->get_depth() != prev_depth) { _polygon_draw(); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index ce6eefd694..1842717cc0 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<Texture> 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<Texture> 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<Texture> 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<Texture> 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<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { - print_line("**Generating for mesh finally??"); Ref<Mesh> mesh = p_from; ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>()); 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<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { return Ref<Texture>(); 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<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); - 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 7e7d36eb1e..2ce35390a5 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 751f39e55d..2afcf6a341 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 a0a91f53a6..218354a918 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 2a6474023c..0000000000 --- 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<RichTextLabel>(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<Node>(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 2665db2993..0000000000 --- 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 <reduzio@gmail.com> -*/ - -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 f6f776f670..0000000000 --- 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<Sample>& p_sample,Ref<ImageTexture> &p_texture) { - - - PoolVector<uint8_t> data = p_sample->get_data(); - - PoolVector<uint8_t> img; - int w = p_texture->get_width(); - int h = p_texture->get_height(); - img.resize(w*h*3); - PoolVector<uint8_t>::Write imgdata = img.write(); - uint8_t * imgw = imgdata.ptr(); - PoolVector<uint8_t>::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<w;i++) { - - float max[2]={-1e10,-1e10}; - float min[2]={1e10,1e10}; - int from = i*len/w; - int to = (i+1)*len/w; - if (to>=len) - to=len-1; - - for(int j=from;j<to;j++) { - - while(j>ima_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 (v<min[0]) - min[0]=v; - } - - for(int j=0;j<h;j++) { - float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; - if (v>min[0] && v<max[0]) { - imgofs[0]=255; - imgofs[1]=150; - imgofs[2]=80; - } else { - imgofs[0]=0; - imgofs[1]=0; - imgofs[2]=0; - } - } - } - } else { - for(int i=0;i<w;i++) { - // i trust gcc will optimize this loop - float max[2]={-1e10,-1e10}; - float min[2]={1e10,1e10}; - int c=stereo?2:1; - int from = uint64_t(i)*len/w; - int to = (uint64_t(i)+1)*len/w; - if (to>=len) - to=len-1; - - if (_16) { - const int16_t*src =(const int16_t*)sdata; - - for(int j=0;j<c;j++) { - - for(int k=from;k<=to;k++) { - - float v = src[uint64_t(k)*c+j]/32768.0; - if (v>max[j]) - max[j]=v; - if (v<min[j]) - min[j]=v; - } - - } - } else { - - const int8_t*src =(const int8_t*)sdata; - - for(int j=0;j<c;j++) { - - for(int k=from;k<=to;k++) { - - float v = src[uint64_t(k)*c+j]/128.0; - if (v>max[j]) - max[j]=v; - if (v<min[j]) - min[j]=v; - } - - } - } - - if (!stereo) { - for(int j=0;j<h;j++) { - float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; - if (v>min[0] && v<max[0]) { - imgofs[0]=255; - imgofs[1]=150; - imgofs[2]=80; - } else { - imgofs[0]=0; - imgofs[1]=0; - imgofs[2]=0; - } - } - } else { - - for(int j=0;j<h;j++) { - - int half; - float v; - if (j<(h/2)) { - half=0; - v = (j/(float)(h/2)) * 2.0 - 1.0; - } else { - half=1; - v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; - } - - uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; - if (v>min[half] && v<max[half]) { - imgofs[0]=255; - imgofs[1]=150; - imgofs[2]=80; - } else { - imgofs[0]=0; - imgofs[1]=0; - imgofs[2]=0; - } - } - - } - - } - } - - imgdata = PoolVector<uint8_t>::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<Sample> 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<SampleLibrary>(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<ImageTexture>( 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<Sample>(p_object); - if (!s) - return; - - sample_editor->edit(Ref<Sample>(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 8f93026c92..0000000000 --- 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<ImageTexture> peakdisplay; - Ref<Sample> sample; - Ref<SampleLibrary> 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<Sample>& p_sample,Ref<ImageTexture> &p_texture); - void edit(Ref<Sample> 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 761301610e..0000000000 --- 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<TreeItem>(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<Variant>(),true); - } - - if (p_what==NOTIFICATION_DRAW) { - - } -} - -void SampleLibraryEditor::_file_load_request(const PoolVector<String>& p_path) { - - - for(int i=0;i<p_path.size();i++) { - - String path = p_path[i]; - Ref<Sample> 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<TreeItem>(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<TreeItem>(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<Sample> 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<StringName> names; - sample_library->get_sample_list(&names); - names.sort_custom<StringName::AlphCompare>(); - - for(List<StringName>::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<Sample> smp = sample_library->get_sample(E->get()); - - // Preview/edit - Ref<ImageTexture> 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<SampleLibrary> 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> sample = r; - - if (sample.is_valid()) { - - return true; - } - } - - - if (String(d["type"])=="files") { - - Vector<String> files = d["files"]; - - if (files.size()==0) - return false; - - for(int i=0;i<files.size();i++) { - String file = files[0]; - String ftype = EditorFileSystem::get_singleton()->get_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> 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<String> 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<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions); - for(int i=0;i<extensions.size();i++) - file->add_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<SampleLibrary>(p_object); - if (!s) - return; - - sample_library_editor->edit(Ref<SampleLibrary>(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 0244fa66ed..0000000000 --- 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<SampleLibrary> 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<String>& 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<SampleLibrary> 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 821c7ecc01..0000000000 --- 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<SampleLibrary> sl = node->call("get_sample_library"); - if (sl.is_null()) { - samples->add_item("<NO SAMPLE LIBRARY>"); - return; //no sample library; - } - - List<StringName> samplenames; - sl->get_sample_list(&samplenames); - samplenames.sort_custom<StringName::AlphCompare>(); - for(List<StringName>::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<Node>(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 5c1b25aaa2..0000000000 --- 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 <reduzio@gmail.com> -*/ - -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 a6db0f6e59..9b83d4e483 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 251416f853..5a57efd941 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<Shader> ShaderTextEditor::get_edited_shader() const { diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp index 7ad32464af..3f8f2488dc 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 e7cab50d8d..159c752ee6 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 <reduzio@gmail.com> */ -#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.cpp b/editor/project_manager.cpp index 0d57fe05b9..9cb110a2ca 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -805,7 +805,8 @@ void ProjectManager::_load_recent_projects() { Error err = img->load(appicon.replace_first("res://", path + "/")); if (err == OK) { - img->resize(64, 64); + Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); + img->resize(default_icon->get_width(), default_icon->get_height()); Ref<ImageTexture> it = memnew(ImageTexture); it->create_from_image(img); icon = it; diff --git a/editor/project_manager.h b/editor/project_manager.h index 181d3cc5d9..11fd3b2e01 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 b4457cfbb5..3352ea22de 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<StringName> ep; - EditorImportExport::get_singleton()->get_export_platforms(&ep); - ep.sort_custom<StringName::AlphCompare>(); - - for(List<StringName>::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 4390a23d60..6deb9e1d46 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<InputEvent> &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 f175e4c8e4..a6a29bb66c 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<ResourceImportMetadata> rimd = r->get_import_metadata(); - Ref<EditorImportPlugin> 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<Node>(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<String> 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<String> p_names) { -//// -//// field_names=p_names; -//// for (int i=0;i<p_names.size();i++) { -//// field_values.push_back(v.get(p_names[i])); -//// } -////} - void CustomPropertyEditor::_file_selected(String p_file) { switch (type) { @@ -1093,11 +1016,6 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { ERR_FAIL_INDEX(p_idx, inheritors_array.size()); - //List<String> 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<InputEvent> &p_ev) { Ref<InputEventMouseMotion> mm = p_ev; @@ -1433,7 +1324,6 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &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<InputEvent> &p_ev) { v = val; easing_draw->update(); - //emit_signal("variant_changed"); emit_signal("variant_changed"); } - // if (p_ev.type == Ref<InputEvent>::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<SceneState> 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<SceneState> 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<Resource> 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<String> 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, HashMap<String, TreeIte item = item_paths.get(p_path); } else { - //printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() ); TreeItem *parent = get_parent_node(p_path.left(p_path.find_last("/")), item_paths, root, NULL); item = tree->create_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;i<p_item->get_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<Script> scr = obj->get_script(); - Variant orig_value; - if (scr->get_property_default_value(name,orig_value)) { - if (orig_value!=obj->get(name)) { - has_reload=true; - } - } - } - - if (!has_reload && found!=-1) { - p_item->erase_button(1,found); - } else if (has_reload && found==-1) { - p_item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3); - } -#endif Dictionary d = p_item->get_metadata(0); set_item_text(p_item, d["type"], d["name"], d["hint"], d["hint_text"]); } @@ -2874,45 +2657,6 @@ void PropertyEditor::update_tree() { TreeItem *root = tree->create_item(NULL); tree->set_hide_root(true); - /* - TreeItem *title = tree->create_item(root); - - title->set_custom_bg_color(0,get_color("prop_section","Editor")); - title->set_text(0,"Property"); // todo, fetch name if ID exists in database - title->set_editable(0,false); - title->set_selectable(0,false); - title->set_custom_bg_color(1,get_color("prop_section","Editor")); - title->set_text(1,"Value"); // todo, fetch name if ID exists in database - title->set_editable(1,false); - title->set_selectable(1,false); -*/ - - /* - if (Object::cast_to<Node>() || Object::cast_to<Resource>(obj)) { - TreeItem *type = tree->create_item(root); - - type->set_text(0,"Type"); // todo, fetch name if ID exists in database - type->set_text(1,obj->get_type()); // todo, fetch name if ID exists in database - if (has_icon(obj->get_type(),"EditorIcons")) - type->set_icon(1,get_icon(obj->get_type(),"EditorIcons") ); - else - type->set_icon(1,get_icon("Object","EditorIcons") ); - - type->set_selectable(0,false); - type->set_selectable(1,false); - - - TreeItem *name = tree->create_item(root); - - name->set_text(0,"Name"); // todo, fetch name if ID exists in database - if (obj->is_type("Resource")) - name->set_text(1,Object::cast_to<Resource>(obj)->get_name()); - else if (obj->is_type("Node")) - name->set_text(1,Object::cast_to<Node>(obj)->get_name()); - name->set_selectable(0,false); - name->set_selectable(1,false); - } -*/ List<PropertyInfo> plist; obj->get_property_list(&plist, true); @@ -3003,9 +2747,8 @@ void PropertyEditor::update_tree() { sep->set_tooltip(0, TTR("Class:") + " " + p.name + ":\n\n" + class_descr_cache[type]); } - //sep->set_custom_color(0,Color(1,1,1)); - continue; + } else if (!(p.usage & PROPERTY_USAGE_EDITOR)) continue; @@ -3057,12 +2800,7 @@ void PropertyEditor::update_tree() { continue; } - //printf("property %s\n",basename.ascii().get_data()); TreeItem *parent = get_parent_node(path, item_path, root, current_category); - /* - if (parent->get_parent()==root) - parent=root; - */ int level = 0; if (parent != root) { level++; @@ -3082,7 +2820,6 @@ void PropertyEditor::update_tree() { if (level > 0) { item->set_custom_bg_color(0, col); - //item->set_custom_bg_color(1,col); } item->set_editable(0, false); item->set_selectable(0, property_selectable); @@ -3144,7 +2881,6 @@ void PropertyEditor::update_tree() { item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr); } } - //EditorHelp::get_doc_data(); Dictionary d; d["name"] = p.name; @@ -3164,7 +2900,6 @@ void PropertyEditor::update_tree() { item->select(1); } - //printf("property %s type %i\n",p.name.ascii().get_data(),p.type); switch (p.type) { case Variant::BOOL: { @@ -3204,7 +2939,6 @@ void PropertyEditor::update_tree() { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, !read_only); - //item->set_icon( 0, get_icon("Curve","EditorIcons")); Vector<String> values = p.hint_string.split(","); String flags; @@ -3251,7 +2985,6 @@ void PropertyEditor::update_tree() { item->set_range_config(1, min, max, step, p.hint == PROPERTY_HINT_EXP_RANGE); } else if (p.hint == PROPERTY_HINT_ENUM) { - //int c = p.hint_string.get_slice_count(","); item->set_text(1, p.hint_string); if (show_type_icons) item->set_icon(0, get_icon("Enum", "EditorIcons")); @@ -3260,7 +2993,6 @@ void PropertyEditor::update_tree() { break; } else if (p.hint == PROPERTY_HINT_OBJECT_ID) { - //int c = p.hint_string.get_slice_count(","); item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); String type = p.hint_string; @@ -3591,7 +3323,6 @@ void PropertyEditor::update_tree() { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, !read_only); - //item->set_text(1,obj->get(p.name)); item->set_custom_draw(1, this, "_draw_transparency"); if (show_type_icons) item->set_icon(0, get_icon("Color", "EditorIcons")); @@ -3610,7 +3341,6 @@ void PropertyEditor::update_tree() { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, !read_only); - //item->add_button(1, get_icon("EditResource", "EditorIcons")); String type; if (p.hint == PROPERTY_HINT_RESOURCE_TYPE) type = p.hint_string; @@ -3675,15 +3405,12 @@ void PropertyEditor::update_tree() { if (type != String()) { if (type.find(",") != -1) type = type.get_slice(",", 0); - //printf("prop %s , type %s\n",p.name.ascii().get_data(),p.hint_string.ascii().get_data()); if (has_icon(type, "EditorIcons")) item->set_icon(0, get_icon(type, "EditorIcons")); else item->set_icon(0, get_icon("Object", "EditorIcons")); } - //item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) ); - } break; default: {}; } @@ -3710,7 +3437,6 @@ void PropertyEditor::update_tree() { Variant v = obj->get(p.name); if (_is_property_different(v, vorig, usage)) { - //print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")"); item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); has_reload = true; } @@ -3942,9 +3668,8 @@ void PropertyEditor::_item_edited() { case Variant::TRANSFORM: { } break; - case Variant::COLOR: { - //_edit_set(name,item->get_custom_bg_color(0)); + } break; case Variant::NODE_PATH: { @@ -4030,7 +3755,6 @@ void PropertyEditor::_custom_editor_request(bool p_arrow) { ERR_FAIL_COND(!item); Dictionary d = item->get_metadata(0); - //int type=d["type"]; String name = d["name"]; Variant::Type type = Variant::NIL; if (d.has("type")) @@ -4078,6 +3802,7 @@ void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame) } void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { + TreeItem *ti = Object::cast_to<TreeItem>(p_item); ERR_FAIL_COND(!ti); @@ -4095,7 +3820,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { return; String prop = d["name"]; emit_signal("property_keyed", prop, obj->get(prop), true); - //set_range(p_column, ti->get_range(p_column)+1.0 ); call_deferred("_set_range_def", ti, prop, ti->get_range(p_column) + 1.0); } else if (p_button == 3) { @@ -4156,7 +3880,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { Variant v = obj->get(n); custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); - //Rect2 where=tree->get_custom_popup_rect(); if (h == PROPERTY_HINT_FILE || h == PROPERTY_HINT_DIR || h == PROPERTY_HINT_GLOBAL_DIR || h == PROPERTY_HINT_GLOBAL_FILE) { Rect2 where = tree->get_item_rect(ti, 1); @@ -4178,7 +3901,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { } else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) { emit_signal("object_id_selected", obj->get(n)); - print_line("OBJ ID SELECTED"); } else if (t == Variant::ARRAY || t == Variant::POOL_INT_ARRAY || t == Variant::POOL_REAL_ARRAY || t == Variant::POOL_STRING_ARRAY || t == Variant::POOL_VECTOR2_ARRAY || t == Variant::POOL_VECTOR3_ARRAY || t == Variant::POOL_COLOR_ARRAY || t == Variant::POOL_BYTE_ARRAY) { @@ -4200,7 +3922,6 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { void PropertyEditor::_node_removed(Node *p_node) { if (p_node == obj) { - edit(NULL); } } @@ -4432,8 +4153,6 @@ PropertyEditor::PropertyEditor() { tree->set_column_min_width(0, 30); tree->set_column_expand(1, true); tree->set_column_min_width(1, 18); - - //tree->set_hide_root(true); add_child(tree); tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED); @@ -4502,7 +4221,6 @@ class SectionedPropertyEditorFilter : public Object { bool valid; edited->set(name, p_value, &valid); - //_change_notify(p_name.operator String().utf8().get_data()); return valid; } @@ -4819,8 +4537,7 @@ void PropertyValueEvaluator::edit(Object *p_obj) { } String PropertyValueEvaluator::_build_script(const String &p_text) { - String script_text = - "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n"; + String script_text = "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n"; return script_text; } diff --git a/editor/property_editor.h b/editor/property_editor.h index 3dd09268ec..2ba6058bdf 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -31,6 +31,7 @@ #define PROPERTY_EDITOR_H #include "editor/editor_file_dialog.h" +#include "editor/scene_tree_editor.h" #include "scene/gui/button.h" #include "scene/gui/check_box.h" #include "scene/gui/check_button.h" @@ -43,7 +44,6 @@ #include "scene/gui/text_edit.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tree.h" -#include "scene_tree_editor.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -66,9 +66,8 @@ class CustomPropertyEditor : public Popup { OBJ_MENU_MAKE_UNIQUE = 3, OBJ_MENU_COPY = 4, OBJ_MENU_PASTE = 5, - OBJ_MENU_REIMPORT = 6, - OBJ_MENU_NEW_SCRIPT = 7, - OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8, + OBJ_MENU_NEW_SCRIPT = 6, + OBJ_MENU_SHOW_IN_FILE_SYSTEM = 7, TYPE_BASE_ID = 100 }; @@ -120,7 +119,6 @@ class CustomPropertyEditor : public Popup { void _text_edit_changed(); void _file_selected(String p_file); - void _scroll_modified(double p_value); void _modified(String p_string); void _range_modified(double p_value); void _focus_enter(); @@ -168,7 +166,6 @@ class PropertyEditor : public Control { Tree *tree; Label *top_label; - //Object *object; LineEdit *search_box; PropertyValueEvaluator *evaluator; diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp deleted file mode 100644 index dcff3bcd73..0000000000 --- a/editor/resources_dock.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/*************************************************************************/ -/* resources_dock.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 "resources_dock.h" - -#include "editor_file_system.h" -#include "editor_node.h" -#include "editor_settings.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "project_settings.h" -#include "project_settings_editor.h" - -void ResourcesDock::_tool_selected(int p_tool) { - - current_action = p_tool; - - switch (p_tool) { - - case TOOL_NEW: { - - create_dialog->popup_centered_ratio(); - } break; - case TOOL_OPEN: { - editor->open_resource(); - - } break; - case TOOL_SAVE: { - - TreeItem *ti = resources->get_selected(); - if (!ti) - break; - Ref<Resource> current_res = ti->get_metadata(0); - - if (current_res->get_path() != "" && current_res->get_path().find("::") == -1) { - _file_action(current_res->get_path()); - break; - }; - - }; /* fallthrough */ - case TOOL_SAVE_AS: { - - TreeItem *ti = resources->get_selected(); - if (!ti) - break; - - save_resource_as(ti->get_metadata(0)); - - } break; - case TOOL_MAKE_LOCAL: { - - TreeItem *ti = resources->get_selected(); - if (!ti) - break; - Ref<Resource> current_res = ti->get_metadata(0); - current_res->set_path(""); - _update_name(ti); - } break; - case TOOL_COPY: { - - TreeItem *ti = resources->get_selected(); - if (!ti) - break; - Ref<Resource> current_res = ti->get_metadata(0); - EditorSettings::get_singleton()->set_resource_clipboard(current_res); - - } break; - case TOOL_PASTE: { - - add_resource(EditorSettings::get_singleton()->get_resource_clipboard()); - } break; - } -} - -void ResourcesDock::_notification(int p_what) { - - switch (p_what) { - - case NOTIFICATION_ENTER_TREE: { - - button_new->set_icon(get_icon("New", "EditorIcons")); - button_open->set_icon(get_icon("Folder", "EditorIcons")); - button_save->set_icon(get_icon("Save", "EditorIcons")); - button_tools->set_icon(get_icon("Tools", "EditorIcons")); - - } break; - } -} - -void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_resource) { - - editor->get_editor_data().apply_changes_in_editors(); - int flg = 0; - if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources")) - flg |= ResourceSaver::FLAG_COMPRESS; - /* - if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative")) - flg|=ResourceSaver::FLAG_RELATIVE_PATHS; - */ - - String path = ProjectSettings::get_singleton()->localize_path(p_path); - Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); - - if (err != OK) { - accept->set_text(TTR("Error saving resource!")); - 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); -} - -void ResourcesDock::save_resource_as(const Ref<Resource> &p_resource) { - - current_action = TOOL_SAVE_AS; - - RES res(p_resource); - - List<String> extensions; - ResourceSaver::get_recognized_extensions(res, &extensions); - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); - - if (p_resource->get_path() != "" && p_resource->get_path().find("::") == -1) { - - file->set_current_path(p_resource->get_path()); - } else { - - String existing; - if (extensions.size()) { - existing = "new_" + res->get_class().to_lower() + "." + extensions.front()->get().to_lower(); - } - - file->set_current_file(existing); - } - - file->clear_filters(); - for (int i = 0; i < extensions.size(); i++) { - - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - } - - file->popup_centered_ratio(); -} - -void ResourcesDock::_file_action(const String &p_path) { - - switch (current_action) { - - case TOOL_OPEN: { - - } break; - case TOOL_SAVE: - case TOOL_SAVE_AS: { - - TreeItem *ti = resources->get_selected(); - if (!ti) - break; - Ref<Resource> current_res = ti->get_metadata(0); - - RES res(current_res); - - save_resource(p_path, res); - - _update_name(ti); - - } break; - } -} - -void ResourcesDock::_update_name(TreeItem *item) { - - Ref<Resource> res = item->get_metadata(0); - - if (res->get_name() != "") - item->set_text(0, res->get_name()); - else if (res->get_path() != "" && res->get_path().find("::") == -1) - item->set_text(0, res->get_path().get_file()); - else - item->set_text(0, res->get_class() + " (" + itos(res->get_instance_id()) + ")"); -} - -void ResourcesDock::remove_resource(const Ref<Resource> &p_resource) { - - TreeItem *root = resources->get_root(); - ERR_FAIL_COND(!root); - - TreeItem *existing = root->get_children(); - - while (existing) { - - Ref<Resource> r = existing->get_metadata(0); - if (r == p_resource) { - //existing->move_to_top(); - memdelete(existing); - return; - } - existing = existing->get_next(); - } -} - -void ResourcesDock::add_resource(const Ref<Resource> &p_resource) { - - if (block_add) - return; - if (!p_resource.is_valid()) - return; - - TreeItem *root = resources->get_root(); - ERR_FAIL_COND(!root); - - TreeItem *existing = root->get_children(); - - while (existing) { - - Ref<Resource> r = existing->get_metadata(0); - if (r == p_resource) { - //existing->move_to_top(); - existing->select(0); - resources->ensure_cursor_is_visible(); - return; // existing - } - existing = existing->get_next(); - } - - TreeItem *res = resources->create_item(root); - res->set_metadata(0, p_resource); - - if (has_icon(p_resource->get_class(), "EditorIcons")) { - res->set_icon(0, get_icon(p_resource->get_class(), "EditorIcons")); - } - - _update_name(res); - res->add_button(0, get_icon("Del", "EditorIcons")); - res->move_to_top(); - res->select(0); - resources->ensure_cursor_is_visible(); -} - -void ResourcesDock::_resource_selected() { - - TreeItem *sel = resources->get_selected(); - ERR_FAIL_COND(!sel); - - Ref<Resource> r = sel->get_metadata(0); - if (r.is_null()) - return; - block_add = true; - editor->push_item(r.ptr()); - block_add = false; -} - -void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) { - - TreeItem *ti = Object::cast_to<TreeItem>(p_item); - ERR_FAIL_COND(!ti); - - call_deferred("remove_resource", ti->get_metadata(0)); -} - -void ResourcesDock::_create() { - - Object *c = create_dialog->instance_selected(); - - ERR_FAIL_COND(!c); - Resource *r = Object::cast_to<Resource>(c); - ERR_FAIL_COND(!r); - - REF res(r); - - editor->push_item(c); -} - -void ResourcesDock::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_tool_selected"), &ResourcesDock::_tool_selected); - ClassDB::bind_method(D_METHOD("_create"), &ResourcesDock::_create); - ClassDB::bind_method(D_METHOD("_resource_selected"), &ResourcesDock::_resource_selected); - ClassDB::bind_method(D_METHOD("_delete"), &ResourcesDock::_delete); - ClassDB::bind_method(D_METHOD("remove_resource"), &ResourcesDock::remove_resource); - ClassDB::bind_method(D_METHOD("_file_action"), &ResourcesDock::_file_action); -} - -void ResourcesDock::cleanup() { - - resources->clear(); - resources->create_item(); //root -} - -ResourcesDock::ResourcesDock(EditorNode *p_editor) { - - editor = p_editor; - - VBoxContainer *vbc = this; - - HBoxContainer *hbc = memnew(HBoxContainer); - vbc->add_child(hbc); - - Button *b; - b = memnew(ToolButton); - b->set_tooltip(TTR("Create New Resource")); - b->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW)); - hbc->add_child(b); - button_new = b; - - b = memnew(ToolButton); - b->set_tooltip(TTR("Open Resource")); - b->connect("pressed", this, "_tool_selected", make_binds(TOOL_OPEN)); - hbc->add_child(b); - button_open = b; - - MenuButton *mb = memnew(MenuButton); - mb->set_tooltip(TTR("Save Resource")); - mb->get_popup()->add_item(TTR("Save Resource"), TOOL_SAVE); - mb->get_popup()->add_item(TTR("Save Resource As.."), TOOL_SAVE_AS); - mb->get_popup()->connect("id_pressed", this, "_tool_selected"); - hbc->add_child(mb); - button_save = mb; - - hbc->add_spacer(); - - mb = memnew(MenuButton); - mb->set_tooltip(TTR("Resource Tools")); - mb->get_popup()->add_item(TTR("Make Local"), TOOL_MAKE_LOCAL); - mb->get_popup()->add_item(TTR("Copy"), TOOL_COPY); - mb->get_popup()->add_item(TTR("Paste"), TOOL_PASTE); - mb->get_popup()->connect("id_pressed", this, "_tool_selected"); - hbc->add_child(mb); - button_tools = mb; - - resources = memnew(Tree); - vbc->add_child(resources); - resources->set_v_size_flags(SIZE_EXPAND_FILL); - resources->create_item(); //root - resources->set_hide_root(true); - resources->connect("cell_selected", this, "_resource_selected"); - resources->connect("button_pressed", this, "_delete"); - - create_dialog = memnew(CreateDialog); - add_child(create_dialog); - create_dialog->set_base_type("Resource"); - create_dialog->connect("create", this, "_create"); - accept = memnew(AcceptDialog); - add_child(accept); - - file = memnew(EditorFileDialog); - add_child(file); - file->connect("file_selected", this, "_file_action"); - - block_add = false; -} diff --git a/editor/resources_dock.h b/editor/resources_dock.h deleted file mode 100644 index e5470b1a3c..0000000000 --- a/editor/resources_dock.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************/ -/* resources_dock.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 RESOURCES_DOCK_H -#define RESOURCES_DOCK_H - -#include "create_dialog.h" -#include "editor_file_dialog.h" -#include "scene/gui/box_container.h" -#include "scene/gui/button.h" -#include "scene/gui/control.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/label.h" -#include "scene/gui/menu_button.h" -#include "scene/gui/tool_button.h" -#include "scene/gui/tree.h" - -class EditorNode; - -class ResourcesDock : public VBoxContainer { - - GDCLASS(ResourcesDock, VBoxContainer); - - enum { - TOOL_NEW, - TOOL_OPEN, - TOOL_SAVE, - TOOL_SAVE_AS, - TOOL_MAKE_LOCAL, - TOOL_COPY, - TOOL_PASTE, - TOOL_MAX - }; - - EditorNode *editor; - - Button *button_new; - Button *button_open; - Button *button_save; - Button *button_tools; - - CreateDialog *create_dialog; - - AcceptDialog *accept; - EditorFileDialog *file; - Tree *resources; - bool block_add; - int current_action; - - void _file_action(const String &p_path); - - void _delete(Object *p_item, int p_column, int p_id); - void _resource_selected(); - void _update_name(TreeItem *item); - void _tool_selected(int p_tool); - void _create(); - -protected: - void _notification(int p_what); - static void _bind_methods(); - -public: - void add_resource(const Ref<Resource> &p_resource); - void remove_resource(const Ref<Resource> &p_resource); - void save_resource(const String &p_path, const Ref<Resource> &p_resource); - void save_resource_as(const Ref<Resource> &p_resource); - - void cleanup(); - - ResourcesDock(EditorNode *p_editor); -}; - -#endif // RESOURCES_DOCK_H diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c3eb7240d4..859c41f0d0 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -29,20 +29,20 @@ /*************************************************************************/ #include "scene_tree_dock.h" -#include "animation_editor.h" #include "core/io/resource_saver.h" +#include "core/os/keyboard.h" +#include "core/project_settings.h" +#include "editor/animation_editor.h" +#include "editor/editor_node.h" +#include "editor/editor_settings.h" +#include "editor/multi_node_edit.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" -#include "editor_node.h" -#include "editor_settings.h" -#include "multi_node_edit.h" -#include "os/keyboard.h" -#include "project_settings.h" +#include "editor/script_editor_debugger.h" #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" -#include "script_editor_debugger.h" void SceneTreeDock::_nodes_drag_begin() { @@ -106,7 +106,6 @@ void SceneTreeDock::instance(const String &p_file) { if (!parent || !edited_scene) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("OK :(")); accept->set_text(TTR("No parent to instance a child at.")); accept->popup_centered_minsize(); @@ -152,7 +151,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]); if (!sdata.is_valid()) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("Ugh")); accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i])); accept->popup_centered_minsize(); @@ -163,7 +161,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!instanced_scene) { current_option = -1; - //accept->get_cancel()->hide(); accept->get_ok()->set_text(TTR("Ugh")); accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i])); accept->popup_centered_minsize(); @@ -195,8 +192,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node return; } - //instanced_scene->generate_instance_state(); - editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)")); for (int i = 0; i < instances.size(); i++) { @@ -275,10 +270,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { switch (p_tool) { case TOOL_NEW: { - /* - if (!_validate_no_foreign()) - break; - */ create_dialog->popup_create(true); } break; case TOOL_INSTANCE: { @@ -286,24 +277,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *scene = edited_scene; if (!scene) { - EditorNode::get_singleton()->new_inherited_scene(); - - /* should be legal now - 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_minsize(); - */ - break; } - /* - if (!_validate_no_foreign()) - break; - */ - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); @@ -313,7 +289,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - //file->set_current_path(current_path); file->popup_centered_ratio(); } break; @@ -321,43 +296,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { create_dialog->popup_create(false); } break; - case TOOL_CONNECT: { - - Node *current = scene_tree->get_selected(); - if (!current) - break; - - /* - if (!_validate_no_foreign()) - break; - connect_dialog->popup_centered_ratio(); - connect_dialog->set_node(current); - */ - - } break; - case TOOL_GROUP: { - - Node *current = scene_tree->get_selected(); - if (!current) - break; - /* - if (!_validate_no_foreign()) - break; - groups_editor->set_current(current); - groups_editor->popup_centered_ratio(); - */ - } break; case TOOL_ATTACH_SCRIPT: { Node *selected = scene_tree->get_selected(); if (!selected) break; - /* - if (!_validate_no_foreign()) - break; - */ - Ref<Script> existing = selected->get_script(); if (existing.is_valid()) editor->push_item(existing.ptr()); @@ -391,7 +335,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (scene_tree->get_selected() == edited_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 on the tree root.")); accept->popup_centered_minsize(); @@ -467,8 +410,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (selection.size() == 0) break; - List<Node *> reselect; - editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)")); editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); @@ -510,9 +451,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name()); editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + dup->get_name())); - - //parent->add_child(dup); - //reselect.push_back(dup); } editor_data->get_undo_redo().commit_action(); @@ -529,7 +467,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (editor_selection->is_selected(edited_scene)) { current_option = -1; - //confirmation->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("This operation can't be done on the tree root.")); accept->popup_centered_minsize(); @@ -860,7 +797,6 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) { node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); ERR_FAIL_COND_V(!node, NULL); node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder()); - //node->generate_instance_state(); } else { Object *obj = ClassDB::instance(p_node->get_class()); ERR_FAIL_COND_V(!obj, NULL); @@ -1149,8 +1085,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { Node *new_parent = scene_root->get_node(p_path); ERR_FAIL_COND(!new_parent); - //ok all valid - List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.empty()) @@ -1180,11 +1114,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } validate = validate->get_parent(); } - //ok all valid - List<Node *> selection = editor_selection->get_selected_node_list(); - if (p_nodes.size() == 0) return; //nothing to reparent @@ -1285,7 +1216,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V perform_node_renames(NULL, &path_renames); editor_data->get_undo_redo().commit_action(); - //node->set_owner(owner); } void SceneTreeDock::_script_created(Ref<Script> p_script) { @@ -1361,7 +1291,6 @@ void SceneTreeDock::_delete_confirm() { if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == n) editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", n); editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners); - //editor_data->get_undo_redo().add_undo_method(n,"set_owner",n->get_owner()); editor_data->get_undo_redo().add_undo_reference(n); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); @@ -1392,8 +1321,6 @@ void SceneTreeDock::_selection_changed() { button_create_script->hide(); button_clear_script->hide(); } - - //tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2); } void SceneTreeDock::_create() { @@ -1557,16 +1484,6 @@ void SceneTreeDock::_import_subscene() { import_subscene_dialog->move(parent, edited_scene); editor_data->get_undo_redo().clear_history(); //no undo for now.. - - /* - editor_data->get_undo_redo().create_action("Import Subscene"); - editor_data->get_undo_redo().add_do_method(parent,"add_child",ss); - //editor_data->get_undo_redo().add_do_method(editor_selection,"clear"); - //editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",child); - editor_data->get_undo_redo().add_do_reference(ss); - editor_data->get_undo_redo().add_undo_method(parent,"remove_child",ss); - editor_data->get_undo_redo().commit_action(); -*/ } void SceneTreeDock::_new_scene_from(String p_file) { @@ -1601,10 +1518,6 @@ void SceneTreeDock::_new_scene_from(String p_file) { 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; - */ err = ResourceSaver::save(p_file, sdata, flg); if (err != OK) { @@ -1704,7 +1617,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { if (_has_visible_children(to_node)) { to_pos = 0; } else { - for (int i = to_node->get_index() + 1; i < to_node->get_parent()->get_child_count(); i++) { Node *c = to_node->get_parent()->get_child(i); if (_is_node_visible(c)) { @@ -1718,26 +1630,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { to_node = to_node->get_parent(); } -#if 0 - //quite complicated, look for next visible in tree - upper_sibling=_find_last_visible(upper_sibling); - - if (upper_sibling->get_parent()==to_node->get_parent()) { - //just insert over this node because nothing is above at an upper level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - } else { - to_pos=-1; //insert last in whathever is up - to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up - } - - - } else { - //just insert over this node because nothing is above at the same level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - } -#endif } } @@ -1857,9 +1749,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->add_separator(); menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); - //menu->add_separator(); moved to their own dock - //menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP); - //menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT); menu->add_separator(); menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); @@ -1945,7 +1834,6 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false)); ClassDB::bind_method(D_METHOD("_create"), &SceneTreeDock::_create); - //ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created); ClassDB::bind_method(D_METHOD("_node_reparent"), &SceneTreeDock::_node_reparent); ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners); ClassDB::bind_method(D_METHOD("_node_selected"), &SceneTreeDock::_node_selected); @@ -2062,14 +1950,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel add_child(create_dialog); create_dialog->connect("create", this, "_create"); - //groups_editor = memnew( GroupsEditor ); - //add_child(groups_editor); - //groups_editor->set_undo_redo(&editor_data->get_undo_redo()); - - //connect_dialog = memnew( ConnectionsDialog(p_editor) ); - //add_child(connect_dialog); - //connect_dialog->set_undoredo(&editor_data->get_undo_redo()); - script_create_dialog = memnew(ScriptCreateDialog); add_child(script_create_dialog); script_create_dialog->connect("script_created", this, "_script_created"); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 5a6bc94125..618159f5c9 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -30,12 +30,13 @@ #ifndef SCENE_TREE_DOCK_H #define SCENE_TREE_DOCK_H -#include "connections_dialog.h" -#include "create_dialog.h" -#include "editor_data.h" -#include "editor_sub_scene.h" -#include "groups_editor.h" -#include "reparent_dialog.h" +#include "editor/connections_dialog.h" +#include "editor/create_dialog.h" +#include "editor/editor_data.h" +#include "editor/editor_sub_scene.h" +#include "editor/groups_editor.h" +#include "editor/reparent_dialog.h" +#include "editor/script_create_dialog.h" #include "scene/animation/animation_player.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" @@ -45,7 +46,7 @@ #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" #include "scene_tree_editor.h" -#include "script_create_dialog.h" + class EditorNode; class SceneTreeDock : public VBoxContainer { @@ -57,8 +58,6 @@ class SceneTreeDock : public VBoxContainer { TOOL_NEW, TOOL_INSTANCE, TOOL_REPLACE, - TOOL_CONNECT, - TOOL_GROUP, TOOL_ATTACH_SCRIPT, TOOL_CLEAR_SCRIPT, TOOL_MOVE_UP, @@ -104,8 +103,6 @@ class SceneTreeDock : public VBoxContainer { EditorData *editor_data; EditorSelection *editor_selection; - //GroupsEditor *groups_editor; - //ConnectionsDialog *connect_dialog; ScriptCreateDialog *script_create_dialog; AcceptDialog *accept; ConfirmationDialog *delete_dialog; diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 45d622c9d2..2de63054b3 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -3557,14 +3557,6 @@ SpatialEditorGizmos::SpatialEditorGizmos() { listener_line_mesh->surface_set_material(0, mat); } - sample_player_icon = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - sample_player_icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - sample_player_icon->set_cull_mode(SpatialMaterial::CULL_DISABLED); - sample_player_icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED); - sample_player_icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - sample_player_icon->set_albedo(Color(1, 1, 1, 0.9)); - sample_player_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons")); - room_material = create_line_material(Color(1.0, 0.6, 0.9)); portal_material = create_line_material(Color(1.0, 0.8, 0.6)); raycast_material = create_line_material(Color(1.0, 0.8, 0.6)); |