diff options
Diffstat (limited to 'editor')
168 files changed, 2255 insertions, 4581 deletions
diff --git a/editor/SCsub b/editor/SCsub index 4fa287c33b..6a4b06a97a 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -76,22 +76,11 @@ if env['tools']: # Fonts flist = glob.glob(path + "/../thirdparty/fonts/*.ttf") - flist.append(glob.glob(path + "/../thirdparty/fonts/*.otf")) + flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf")) + flist.sort() env.Depends('#editor/builtin_fonts.gen.h', flist) env.CommandNoCache('#editor/builtin_fonts.gen.h', flist, run_in_subprocess(editor_builders.make_fonts_header)) - # Authors - env.Depends('#editor/authors.gen.h', "../AUTHORS.md") - env.CommandNoCache('#editor/authors.gen.h', "../AUTHORS.md", run_in_subprocess(editor_builders.make_authors_header)) - - # Donors - env.Depends('#editor/donors.gen.h', "../DONORS.md") - env.CommandNoCache('#editor/donors.gen.h', "../DONORS.md", run_in_subprocess(editor_builders.make_donors_header)) - - # License - env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"]) - env.CommandNoCache('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(editor_builders.make_license_header)) - env.add_source_files(env.editor_sources, "*.cpp") env.add_source_files(env.editor_sources, ["#thirdparty/misc/clipper.cpp"]) diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 197599442b..04977dbb47 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_bezier_editor.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_bezier_editor.h" float AnimationBezierTrackEdit::_bezier_h_to_pixel(float p_h) { diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index 544690844a..1c701cc8f4 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_bezier_editor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_BEZIER_EDITOR_H #define ANIMATION_BEZIER_EDITOR_H diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 4c4830ad7a..ac28fb9b99 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -30,11 +30,11 @@ #include "animation_track_editor.h" #include "animation_track_editor_plugins.h" +#include "core/os/keyboard.h" #include "editor/animation_bezier_editor.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" -#include "os/keyboard.h" #include "scene/main/viewport.h" #include "servers/audio/audio_stream.h" diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 0692c88bea..deefe6c6fd 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_track_editor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_TRACK_EDITOR_H #define ANIMATION_TRACK_EDITOR_H diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 590621816e..a0ce8dd0a6 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_track_editor_plugins.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_track_editor_plugins.h" #include "editor/audio_stream_preview.h" #include "editor_resource_preview.h" diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h index 59604412d9..dd8ff7c8c9 100644 --- a/editor/animation_track_editor_plugins.h +++ b/editor/animation_track_editor_plugins.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_track_editor_plugins.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_TRACK_EDITOR_PLUGINS_H #define ANIMATION_TRACK_EDITOR_PLUGINS_H diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 6e6a7d7935..c5759ac076 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* audio_stream_preview.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "audio_stream_preview.h" ///////////////////// diff --git a/editor/audio_stream_preview.h b/editor/audio_stream_preview.h index cfe1667e9d..1a8f2eaa15 100644 --- a/editor/audio_stream_preview.h +++ b/editor/audio_stream_preview.h @@ -1,7 +1,37 @@ +/*************************************************************************/ +/* audio_stream_preview.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 AUDIO_STREAM_PREVIEW_H #define AUDIO_STREAM_PREVIEW_H -#include "os/thread.h" +#include "core/os/thread.h" #include "scene/main/node.h" #include "servers/audio/audio_stream.h" diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2fecf24d7d..80bc73bc12 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -30,10 +30,10 @@ #include "code_editor.h" +#include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor_node.h" #include "editor_settings.h" -#include "os/keyboard.h" #include "scene/gui/margin_container.h" #include "scene/gui/separator.h" #include "scene/resources/dynamic_font.h" diff --git a/editor/collada/collada.h b/editor/collada/collada.h index 7535162f74..b777fa04c2 100644 --- a/editor/collada/collada.h +++ b/editor/collada/collada.h @@ -33,9 +33,9 @@ #ifndef COLLADA_H #define COLLADA_H -#include "io/xml_parser.h" -#include "map.h" -#include "project_settings.h" +#include "core/io/xml_parser.h" +#include "core/map.h" +#include "core/project_settings.h" #include "scene/resources/material.h" class Collada { diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index da73a3930a..18c4dd85a1 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -30,10 +30,10 @@ #include "connections_dialog.h" +#include "core/print_string.h" #include "editor_node.h" #include "editor_settings.h" #include "plugins/script_editor_plugin.h" -#include "print_string.h" #include "scene/gui/label.h" #include "scene/gui/popup_menu.h" @@ -341,8 +341,7 @@ ConnectDialog::ConnectDialog() { vbc_right->add_margin_child(TTR("Add Extra Call Argument:"), add_bind_hb); - bind_editor = memnew(PropertyEditor); - bind_editor->hide_top_label(); + bind_editor = memnew(EditorInspector); vbc_right->add_margin_child(TTR("Extra Call Arguments:"), bind_editor, true); @@ -650,8 +649,8 @@ void ConnectionsDock::_handle_signal_menu_option(int option) { _open_connection_dialog(*item); } break; case DISCONNECT_ALL: { - StringName signalName = item->get_metadata(0).operator Dictionary()["name"]; - disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from the \"") + signalName + "\" signal?"); + StringName signal_name = item->get_metadata(0).operator Dictionary()["name"]; + disconnect_all_dialog->set_text(vformat(TTR("Are you sure you want to remove all connections from the \"%s\" signal?"), signal_name)); disconnect_all_dialog->popup_centered(); } break; } diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 932ff693e4..c2fd1f1d09 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -35,7 +35,8 @@ #ifndef CONNECTIONS_DIALOG_H #define CONNECTIONS_DIALOG_H -#include "editor/property_editor.h" +#include "core/undo_redo.h" +#include "editor/editor_inspector.h" #include "editor/scene_tree_editor.h" #include "scene/gui/button.h" #include "scene/gui/check_button.h" @@ -44,7 +45,6 @@ #include "scene/gui/menu_button.h" #include "scene/gui/popup.h" #include "scene/gui/tree.h" -#include "undo_redo.h" class PopupMenu; class ConnectDialogBinds; @@ -62,7 +62,7 @@ class ConnectDialog : public ConfirmationDialog { SceneTreeEditor *tree; ConfirmationDialog *error; - PropertyEditor *bind_editor; + EditorInspector *bind_editor; OptionButton *type_list; CheckButton *deferred; CheckButton *oneshot; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 8433f4ff7b..8bef94d8a8 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -30,12 +30,12 @@ #include "create_dialog.h" -#include "class_db.h" +#include "core/class_db.h" +#include "core/os/keyboard.h" +#include "core/print_string.h" #include "editor_help.h" #include "editor_node.h" #include "editor_settings.h" -#include "os/keyboard.h" -#include "print_string.h" #include "scene/gui/box_container.h" void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) { @@ -244,17 +244,17 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type); String to_select_type = *to_select ? (*to_select)->get_text(0) : ""; to_select_type = to_select_type.split(" ")[0]; - bool current_item_is_preffered; + bool current_item_is_preferred; if (cpp_type) { - current_item_is_preffered = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(to_select_type, preferred_search_result_type); + current_item_is_preferred = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type; } else { - current_item_is_preffered = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type); + current_item_is_preferred = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type; } if (*to_select && p_type.length() < (*to_select)->get_text(0).length()) { - current_item_is_preffered = true; + current_item_is_preferred = true; } - if (((!*to_select || current_item_is_preffered) && is_search_subsequence) || search_box->get_text() == p_type) { + if (((!*to_select || current_item_is_preferred) && is_search_subsequence) || search_box->get_text() == p_type) { *to_select = item; } } @@ -497,7 +497,11 @@ Object *CreateDialog::instance_selected() { if (custom != String()) { if (ScriptServer::is_global_class(custom)) { - return EditorNode::get_editor_data().script_class_instance(custom); + Object *obj = EditorNode::get_editor_data().script_class_instance(custom); + Node *n = Object::cast_to<Node>(obj); + if (n) + n->set_name(custom); + return obj; } return EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom); } else { diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 62ae14c988..9f04d40763 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -30,9 +30,9 @@ #include "dependency_editor.h" +#include "core/io/resource_loader.h" +#include "core/os/file_access.h" #include "editor_node.h" -#include "io/resource_loader.h" -#include "os/file_access.h" #include "scene/gui/margin_container.h" void DependencyEditor::_notification(int p_what) { diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index fe1cf3484e..599f46d6d9 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -30,15 +30,15 @@ #include "doc_data.h" -#include "engine.h" -#include "global_constants.h" -#include "io/compression.h" -#include "io/marshalls.h" -#include "os/dir_access.h" -#include "project_settings.h" +#include "core/engine.h" +#include "core/global_constants.h" +#include "core/io/compression.h" +#include "core/io/marshalls.h" +#include "core/os/dir_access.h" +#include "core/project_settings.h" +#include "core/script_language.h" +#include "core/version.h" #include "scene/resources/theme.h" -#include "script_language.h" -#include "version.h" void DocData::merge_from(const DocData &p_data) { @@ -382,7 +382,11 @@ void DocData::generate(bool p_basic_types) { PropertyInfo arginfo = EV->get().arguments[i]; ArgumentDoc argument; argument.name = arginfo.name; - argument.type = Variant::get_type_name(arginfo.type); + if (arginfo.type == Variant::OBJECT && arginfo.class_name != StringName()) { + argument.type = arginfo.class_name.operator String(); + } else { + argument.type = Variant::get_type_name(arginfo.type); + } signal.arguments.push_back(argument); } @@ -501,7 +505,7 @@ void DocData::generate(bool p_basic_types) { ad.name = arginfo.name; if (arginfo.type == Variant::NIL) - ad.type = "var"; + ad.type = "Variant"; else ad.type = Variant::get_type_name(arginfo.type); @@ -514,7 +518,7 @@ void DocData::generate(bool p_basic_types) { if (mi.return_val.type == Variant::NIL) { if (mi.return_val.name != "") - method.return_type = "var"; + method.return_type = "Variant"; } else { method.return_type = Variant::get_type_name(mi.return_val.type); } diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h index c7b70b5fb9..6633c123e6 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc/doc_data.h @@ -31,9 +31,9 @@ #ifndef DOC_DATA_H #define DOC_DATA_H -#include "io/xml_parser.h" -#include "map.h" -#include "variant.h" +#include "core/io/xml_parser.h" +#include "core/map.h" +#include "core/variant.h" class DocData { public: diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index adbe23dcd5..86fd9b436b 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -30,9 +30,9 @@ #include "doc_dump.h" -#include "os/file_access.h" +#include "core/os/file_access.h" +#include "core/version.h" #include "scene/main/node.h" -#include "version.h" static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { @@ -142,7 +142,7 @@ void DocDump::dump(const String &p_file) { if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) type_name = arginfo.hint_string; else if (arginfo.type == Variant::NIL) - type_name = "var"; + type_name = "Variant"; else type_name = Variant::get_type_name(arginfo.type); diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h index 48cf1a587b..99398b5d96 100644 --- a/editor/doc/doc_dump.h +++ b/editor/doc/doc_dump.h @@ -31,7 +31,7 @@ #ifndef DOC_DUMP_H #define DOC_DUMP_H -#include "class_db.h" +#include "core/class_db.h" class DocDump { public: diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index d99908a3c3..6af45f26ae 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -30,10 +30,10 @@ #include "editor_asset_installer.h" +#include "core/io/zip_io.h" +#include "core/os/dir_access.h" +#include "core/os/file_access.h" #include "editor_node.h" -#include "io/zip_io.h" -#include "os/dir_access.h" -#include "os/file_access.h" void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool p_first) { diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 9c775be87e..96110b61ab 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -30,10 +30,10 @@ #include "editor_audio_buses.h" +#include "core/io/resource_saver.h" +#include "core/os/keyboard.h" #include "editor_node.h" #include "filesystem_dock.h" -#include "io/resource_saver.h" -#include "os/keyboard.h" #include "servers/audio_server.h" void EditorAudioBus::_notification(int p_what) { diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index d12c85861b..1374c8c9aa 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -30,9 +30,9 @@ #include "editor_autoload_settings.h" +#include "core/global_constants.h" +#include "core/project_settings.h" #include "editor_node.h" -#include "global_constants.h" -#include "project_settings.h" #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" diff --git a/editor/editor_builders.py b/editor/editor_builders.py index 6c2f9e298e..fa037980c2 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -146,267 +146,5 @@ def make_translations_header(target, source, env): g.close() - -def make_authors_header(target, source, env): - - sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"] - sections_id = ["dev_founders", "dev_lead", "dev_manager", "dev_names"] - - src = source[0] - dst = target[0] - f = open_utf8(src, "r") - g = open_utf8(dst, "w") - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_AUTHORS_H\n") - g.write("#define _EDITOR_AUTHORS_H\n") - - current_section = "" - reading = False - - def close_section(): - g.write("\t0\n") - g.write("};\n") - - for line in f: - if reading: - if line.startswith(" "): - g.write("\t\"" + escape_string(line.strip()) + "\",\n") - continue - if line.startswith("## "): - if reading: - close_section() - reading = False - for i in range(len(sections)): - if line.strip().endswith(sections[i]): - current_section = escape_string(sections_id[i]) - reading = True - g.write("static const char *" + current_section + "[] = {\n") - break - - if reading: - close_section() - - g.write("#endif\n") - - g.close() - f.close() - -def make_donors_header(target, source, env): - - sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors", "Gold donors", "Silver donors", "Bronze donors"] - sections_id = ["donor_s_plat", "donor_s_gold", "donor_s_mini", "donor_gold", "donor_silver", "donor_bronze"] - - src = source[0] - dst = target[0] - f = open_utf8(src, "r") - g = open_utf8(dst, "w") - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_DONORS_H\n") - g.write("#define _EDITOR_DONORS_H\n") - - current_section = "" - reading = False - - def close_section(): - g.write("\t0\n") - g.write("};\n") - - for line in f: - if reading >= 0: - if line.startswith(" "): - g.write("\t\"" + escape_string(line.strip()) + "\",\n") - continue - if line.startswith("## "): - if reading: - close_section() - reading = False - for i in range(len(sections)): - if line.strip().endswith(sections[i]): - current_section = escape_string(sections_id[i]) - reading = True - g.write("static const char *" + current_section + "[] = {\n") - break - - if reading: - close_section() - - g.write("#endif\n") - - g.close() - f.close() - - -def make_license_header(target, source, env): - - src_copyright = source[0] - src_license = source[1] - dst = target[0] - f = open_utf8(src_license, "r") - fc = open_utf8(src_copyright, "r") - g = open_utf8(dst, "w") - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_LICENSE_H\n") - g.write("#define _EDITOR_LICENSE_H\n") - g.write("static const char *about_license =") - - for line in f: - escaped_string = escape_string(line.strip()) - g.write("\n\t\"" + escaped_string + "\\n\"") - - g.write(";\n") - - tp_current = 0 - tp_file = "" - tp_comment = "" - tp_copyright = "" - tp_license = "" - - tp_licensename = "" - tp_licensebody = "" - - tp = [] - tp_licensetext = [] - for line in fc: - if line.startswith("#"): - continue - - if line.startswith("Files:"): - tp_file = line[6:].strip() - tp_current = 1 - elif line.startswith("Comment:"): - tp_comment = line[8:].strip() - tp_current = 2 - elif line.startswith("Copyright:"): - tp_copyright = line[10:].strip() - tp_current = 3 - elif line.startswith("License:"): - if tp_current != 0: - tp_license = line[8:].strip() - tp_current = 4 - else: - tp_licensename = line[8:].strip() - tp_current = 5 - elif line.startswith(" "): - if tp_current == 1: - tp_file += "\n" + line.strip() - elif tp_current == 3: - tp_copyright += "\n" + line.strip() - elif tp_current == 5: - if line.strip() == ".": - tp_licensebody += "\n" - else: - tp_licensebody += line[1:] - else: - if tp_current != 0: - if tp_current == 5: - tp_licensetext.append([tp_licensename, tp_licensebody]) - - tp_licensename = "" - tp_licensebody = "" - else: - added = False - for i in tp: - if i[0] == tp_comment: - i[1].append([tp_file, tp_copyright, tp_license]) - added = True - break - if not added: - tp.append([tp_comment,[[tp_file, tp_copyright, tp_license]]]) - - tp_file = [] - tp_comment = "" - tp_copyright = [] - tp_license = "" - tp_current = 0 - - tp_licensetext.append([tp_licensename, tp_licensebody]) - - about_thirdparty = "" - about_tp_copyright_count = "" - about_tp_license = "" - about_tp_copyright = "" - about_tp_file = "" - - for i in tp: - about_thirdparty += "\t\"" + i[0] + "\",\n" - about_tp_copyright_count += str(len(i[1])) + ", " - for j in i[1]: - file_body = "" - copyright_body = "" - for k in j[0].split("\n"): - if file_body != "": - file_body += "\\n\"\n" - escaped_string = escape_string(k.strip()) - file_body += "\t\"" + escaped_string - for k in j[1].split("\n"): - if copyright_body != "": - copyright_body += "\\n\"\n" - escaped_string = escape_string(k.strip()) - copyright_body += "\t\"" + escaped_string - - about_tp_file += "\t" + file_body + "\",\n" - about_tp_copyright += "\t" + copyright_body + "\",\n" - about_tp_license += "\t\"" + j[2] + "\",\n" - - about_license_name = "" - about_license_body = "" - - for i in tp_licensetext: - body = "" - for j in i[1].split("\n"): - if body != "": - body += "\\n\"\n" - escaped_string = escape_string(j.strip()) - body += "\t\"" + escaped_string - - about_license_name += "\t\"" + i[0] + "\",\n" - about_license_body += "\t" + body + "\",\n" - - g.write("static const char *about_thirdparty[] = {\n") - g.write(about_thirdparty) - g.write("\t0\n") - g.write("};\n") - g.write("#define THIRDPARTY_COUNT " + str(len(tp)) + "\n") - - g.write("static const int about_tp_copyright_count[] = {\n\t") - g.write(about_tp_copyright_count) - g.write("0\n};\n") - - g.write("static const char *about_tp_file[] = {\n") - g.write(about_tp_file) - g.write("\t0\n") - g.write("};\n") - - g.write("static const char *about_tp_copyright[] = {\n") - g.write(about_tp_copyright) - g.write("\t0\n") - g.write("};\n") - - g.write("static const char *about_tp_license[] = {\n") - g.write(about_tp_license) - g.write("\t0\n") - g.write("};\n") - - g.write("static const char *about_license_name[] = {\n") - g.write(about_license_name) - g.write("\t0\n") - g.write("};\n") - g.write("#define LICENSE_COUNT " + str(len(tp_licensetext)) + "\n") - - g.write("static const char *about_license_body[] = {\n") - g.write(about_license_body) - g.write("\t0\n") - g.write("};\n") - - g.write("#endif\n") - - g.close() - fc.close() - f.close() - - if __name__ == '__main__': subprocess_main(globals()) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 69c120bb3c..6187c6b318 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -30,12 +30,12 @@ #include "editor_data.h" +#include "core/io/resource_loader.h" +#include "core/os/dir_access.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" #include "editor_node.h" #include "editor_settings.h" -#include "io/resource_loader.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "project_settings.h" #include "scene/resources/packed_scene.h" void EditorHistory::cleanup_history() { diff --git a/editor/editor_data.h b/editor/editor_data.h index 285769aa78..9f5d3e2a15 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -31,12 +31,12 @@ #ifndef EDITOR_DATA_H #define EDITOR_DATA_H +#include "core/list.h" +#include "core/pair.h" +#include "core/undo_redo.h" #include "editor/editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" -#include "list.h" -#include "pair.h" #include "scene/resources/texture.h" -#include "undo_redo.h" class EditorHistory { diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index c094b2b559..6f80b6bea4 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -30,11 +30,11 @@ #include "editor_dir_dialog.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" #include "editor/editor_file_system.h" #include "editor/editor_settings.h" #include "editor_scale.h" -#include "os/keyboard.h" -#include "os/os.h" void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) { updating = true; diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 7c19e7de38..a9dc7accfe 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -31,8 +31,8 @@ #ifndef EDITOR_DIR_DIALOG_H #define EDITOR_DIR_DIALOG_H +#include "core/os/dir_access.h" #include "editor/editor_file_system.h" -#include "os/dir_access.h" #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index e46fe96885..455c889224 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -30,20 +30,20 @@ #include "editor_export.h" +#include "core/io/config_file.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/io/zip_io.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" +#include "core/script_language.h" +#include "core/version.h" #include "editor/editor_file_system.h" #include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" -#include "io/config_file.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "io/zip_io.h" -#include "os/file_access.h" -#include "project_settings.h" #include "scene/resources/scene_format_text.h" -#include "script_language.h" #include "thirdparty/misc/md5.h" -#include "version.h" static int _get_pad(int p_alignment, int p_n) { @@ -667,7 +667,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & String remap = F->get(); String feature = remap.get_slice(".", 1); - if (feature == "fallback" || features.has(feature)) { + if (features.has(feature)) { remap_features.insert(feature); } } @@ -1457,7 +1457,6 @@ void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<Edito if (p_features.has("bptc")) { if (p_preset->has("texture_format/no_bptc_fallbacks")) { p_features.erase("s3tc"); - p_features.erase("fallback"); } } } diff --git a/editor/editor_export.h b/editor/editor_export.h index b984d66a1b..420f383f95 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -31,8 +31,8 @@ #ifndef EDITOR_EXPORT_H #define EDITOR_EXPORT_H -#include "os/dir_access.h" -#include "resource.h" +#include "core/os/dir_access.h" +#include "core/resource.h" #include "scene/main/node.h" #include "scene/main/timer.h" #include "scene/resources/texture.h" diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index d240f4ed25..3659a06bb7 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -29,14 +29,14 @@ /*************************************************************************/ #include "editor_file_dialog.h" +#include "core/os/file_access.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" +#include "core/print_string.h" #include "dependency_editor.h" #include "editor_resource_preview.h" #include "editor_scale.h" #include "editor_settings.h" -#include "os/file_access.h" -#include "os/keyboard.h" -#include "os/os.h" -#include "print_string.h" #include "scene/gui/center_container.h" #include "scene/gui/label.h" #include "scene/gui/margin_container.h" diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index b1f8f1108c..61eeff9162 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -31,7 +31,7 @@ #ifndef EDITORFILEDIALOG_H #define EDITORFILEDIALOG_H -#include "os/dir_access.h" +#include "core/os/dir_access.h" #include "scene/gui/box_container.h" #include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 9562a8c63c..351ca6f435 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -30,16 +30,16 @@ #include "editor_file_system.h" +#include "core/io/resource_import.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" +#include "core/os/os.h" +#include "core/project_settings.h" +#include "core/variant_parser.h" #include "editor_node.h" #include "editor_resource_preview.h" #include "editor_settings.h" -#include "io/resource_import.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "os/os.h" -#include "project_settings.h" -#include "variant_parser.h" EditorFileSystem *EditorFileSystem::singleton = NULL; diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 75ca79932f..f2f72eddbd 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -31,11 +31,11 @@ #ifndef EDITOR_FILE_SYSTEM_H #define EDITOR_FILE_SYSTEM_H -#include "os/dir_access.h" -#include "os/thread.h" -#include "os/thread_safe.h" +#include "core/os/dir_access.h" +#include "core/os/thread.h" +#include "core/os/thread_safe.h" +#include "core/set.h" #include "scene/main/node.h" -#include "set.h" class FileAccess; struct EditorProgressBG; diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8e0d92267c..ea99c882e4 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -68,6 +68,7 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p m_name->add_fallback(FontArabic); \ m_name->add_fallback(FontHebrew); \ m_name->add_fallback(FontThai); \ + m_name->add_fallback(FontHindi); \ m_name->add_fallback(FontJapanese); \ m_name->add_fallback(FontFallback); @@ -204,6 +205,12 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontThai->set_font_ptr(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); FontThai->set_force_autohinter(true); //just looks better..i think? + Ref<DynamicFontData> FontHindi; + FontHindi.instance(); + FontHindi->set_hinting(font_hinting); + FontHindi->set_font_ptr(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size); + FontHindi->set_force_autohinter(true); //just looks better..i think? + /* Hack */ Ref<DynamicFontData> dfmono; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 5a0a49d577..8d371714cf 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -30,11 +30,11 @@ #include "editor_help.h" +#include "core/os/keyboard.h" #include "doc_data_compressed.gen.h" #include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" -#include "os/keyboard.h" #define CONTRIBUTE_URL "http://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html" #define CONTRIBUTE2_URL "https://github.com/godotengine/godot-docs" @@ -225,7 +225,6 @@ bool EditorHelpSearch::IncrementalSearch::work(uint64_t slot) { void EditorHelpSearch::_update_search() { search_options->clear(); - search_options->set_hide_root(true); String term = search_box->get_text(); if (term.length() < 2) @@ -307,6 +306,7 @@ EditorHelpSearch::EditorHelpSearch() { search_box->connect("text_changed", this, "_text_changed"); search_box->connect("gui_input", this, "_sbox_input"); search_options = memnew(Tree); + search_options->set_hide_root(true); vbc->add_margin_child(TTR("Matches:"), search_options, true); get_ok()->set_text(TTR("Open")); get_ok()->set_disabled(true); @@ -397,6 +397,16 @@ void EditorHelpIndex::_notification(int p_what) { //_update_icons search_box->set_right_icon(get_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); + + bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines"); + Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color"); + + if (enable_rl) { + class_list->add_constant_override("draw_relationship_lines", 1); + class_list->add_color_override("relationship_line_color", rl_color); + } else { + class_list->add_constant_override("draw_relationship_lines", 0); + } } } @@ -410,7 +420,6 @@ void EditorHelpIndex::_update_class_list() { class_list->clear(); tree_item_map.clear(); TreeItem *root = class_list->create_item(); - class_list->set_hide_root(true); String filter = search_box->get_text().strip_edges(); String to_select = ""; @@ -489,10 +498,21 @@ EditorHelpIndex::EditorHelpIndex() { class_list = memnew(Tree); vbc->add_margin_child(TTR("Class List:") + " ", class_list, true); + class_list->set_hide_root(true); class_list->set_v_size_flags(SIZE_EXPAND_FILL); class_list->connect("item_activated", this, "_tree_item_selected"); + bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines"); + Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color"); + + if (enable_rl) { + class_list->add_constant_override("draw_relationship_lines", 1); + class_list->add_color_override("relationship_line_color", rl_color); + } else { + class_list->add_constant_override("draw_relationship_lines", 0); + } + get_ok()->set_text(TTR("Open")); set_title(TTR("Search Classes")); } diff --git a/editor/editor_initialize_ssl.cpp b/editor/editor_initialize_ssl.cpp index aedbfb7bd7..9f7537cc9a 100644 --- a/editor/editor_initialize_ssl.cpp +++ b/editor/editor_initialize_ssl.cpp @@ -31,8 +31,8 @@ #include "editor_initialize_ssl.h" #include "certs_compressed.gen.h" -#include "io/compression.h" -#include "io/stream_peer_ssl.h" +#include "core/io/compression.h" +#include "core/io/stream_peer_ssl.h" void editor_initialize_certificates() { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 852e1930d2..929028c499 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -38,7 +38,6 @@ // TODO: // arrays and dictionary -// replace property editor in sectionedpropertyeditor Size2 EditorProperty::get_minimum_size() const { @@ -1138,7 +1137,6 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { return; #ifdef TOOLS_ENABLED - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { @@ -1167,7 +1165,6 @@ void EditorInspectorSection::unfold() { _test_unfold(); #ifdef TOOLS_ENABLED - object->editor_set_section_unfold(section, true); vbox->show(); update(); @@ -1180,8 +1177,8 @@ void EditorInspectorSection::fold() { if (!vbox_added) return; //kinda pointless -#ifdef TOOLS_ENABLED +#ifdef TOOLS_ENABLED object->editor_set_section_unfold(section, false); vbox->hide(); update(); @@ -1202,7 +1199,6 @@ EditorInspectorSection::EditorInspectorSection() { foldable = false; vbox = memnew(VBoxContainer); vbox_added = false; - //add_child(vbox); } EditorInspectorSection::~EditorInspectorSection() { @@ -1607,12 +1603,6 @@ void EditorInspector::update_tree() { doc_hint = descr; } -#if 0 - if (p.name == selected_property) { - - item->select(1); - } -#endif for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) { Ref<EditorInspectorPlugin> ped = E->get(); bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage); @@ -1812,12 +1802,6 @@ void EditorInspector::_filter_changed(const String &p_text) { update_tree(); } -void EditorInspector::set_subsection_selectable(bool p_selectable) { -} - -void EditorInspector::set_property_selectable(bool p_selectable) { -} - void EditorInspector::set_use_folding(bool p_enable) { use_folding = p_enable; update_tree(); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index ebe2124a40..dccbdb9a73 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -349,9 +349,6 @@ public: void set_use_filter(bool p_use); void register_text_enter(Node *p_line_edit); - void set_subsection_selectable(bool p_selectable); - void set_property_selectable(bool p_selectable); - void set_use_folding(bool p_enable); bool is_using_folding(); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index b3ec717d85..3fc35810df 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -31,10 +31,10 @@ #include "editor_log.h" #include "core/os/keyboard.h" +#include "core/version.h" #include "editor_node.h" #include "scene/gui/center_container.h" #include "scene/resources/dynamic_font.h" -#include "version.h" void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) { diff --git a/editor/editor_log.h b/editor/editor_log.h index 8d0310d914..78a5671d29 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -36,7 +36,7 @@ #include "scene/gui/rich_text_label.h" #include "scene/gui/texture_button.h" //#include "scene/gui/empty_control.h" -#include "os/thread.h" +#include "core/os/thread.h" #include "pane_drag.h" #include "scene/gui/box_container.h" #include "scene/gui/panel_container.h" diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp index bacb288273..1ef61802c4 100644 --- a/editor/editor_name_dialog.cpp +++ b/editor/editor_name_dialog.cpp @@ -30,8 +30,8 @@ #include "editor_name_dialog.h" -#include "class_db.h" -#include "os/keyboard.h" +#include "core/class_db.h" +#include "core/os/keyboard.h" void EditorNameDialog::_line_gui_input(const Ref<InputEvent> &p_event) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 353dce5b20..7359cf598a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1174,6 +1174,16 @@ void EditorNode::_dialog_action(String p_file) { int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing; if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + bool same_open_scene = false; + for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + if (editor_data.get_scene_path(i) == p_file && i != scene_idx) + same_open_scene = true; + } + + if (same_open_scene) { + show_warning(TTR("Can't overwrite scene that is still open!")); + return; + } _save_default_environment(); _save_scene_with_preview(p_file, scene_idx); @@ -2068,7 +2078,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case RUN_PROJECT_DATA_FOLDER: { - OS::get_singleton()->shell_open(OS::get_singleton()->get_user_data_dir()); + OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir()); } break; case FILE_QUIT: case RUN_PROJECT_MANAGER: { @@ -2204,11 +2214,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SETTINGS_EDITOR_DATA_FOLDER: { - OS::get_singleton()->shell_open(EditorSettings::get_singleton()->get_data_dir()); + OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_data_dir()); } break; case SETTINGS_EDITOR_CONFIG_FOLDER: { - OS::get_singleton()->shell_open(EditorSettings::get_singleton()->get_settings_dir()); + OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_settings_dir()); } break; case SETTINGS_MANAGE_EXPORT_TEMPLATES: { @@ -2747,6 +2757,8 @@ void EditorNode::set_current_scene(int p_idx) { Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history); _edit_current(); + _update_title(); + call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up } @@ -5634,10 +5646,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(SkeletonIKEditorPlugin(this))); add_editor_plugin(memnew(PhysicalBonePlugin(this))); - // 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)); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 1ebddbe2b0..6c385abf9b 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -31,15 +31,15 @@ #ifndef EDITOR_PLUGIN_H #define EDITOR_PLUGIN_H +#include "core/io/config_file.h" +#include "core/undo_redo.h" #include "editor/editor_inspector.h" #include "editor/import/editor_import_plugin.h" #include "editor/import/resource_importer_scene.h" #include "editor/script_create_dialog.h" -#include "io/config_file.h" #include "scene/gui/tool_button.h" #include "scene/main/node.h" #include "scene/resources/texture.h" -#include "undo_redo.h" /** @author Juan Linietsky <reduzio@gmail.com> diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 68f8ed6d94..ef0b61e882 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -30,11 +30,11 @@ #include "editor_plugin_settings.h" +#include "core/io/config_file.h" +#include "core/os/file_access.h" +#include "core/os/main_loop.h" +#include "core/project_settings.h" #include "editor_node.h" -#include "io/config_file.h" -#include "os/file_access.h" -#include "os/main_loop.h" -#include "project_settings.h" #include "scene/gui/margin_container.h" void EditorPluginSettings::_notification(int p_what) { diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index 194fac6b92..fe14f87cfc 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -31,11 +31,11 @@ #ifndef EDITORPLUGINSETTINGS_H #define EDITORPLUGINSETTINGS_H +#include "core/undo_redo.h" #include "editor/plugin_config_dialog.h" #include "editor_data.h" #include "property_editor.h" #include "scene/gui/dialogs.h" -#include "undo_redo.h" class EditorPluginSettings : public VBoxContainer { diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index f57c863bcf..b57e3826c6 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -30,9 +30,9 @@ #include "editor_profiler.h" +#include "core/os/os.h" #include "editor_scale.h" #include "editor_settings.h" -#include "os/os.h" void EditorProfiler::_make_metric_ptrs(Metric &m) { @@ -100,8 +100,6 @@ void EditorProfiler::clear() { updating_frame = false; hover_metric = -1; seeking = false; - - _update_plot(); } static String _get_percent_txt(float p_value, float p_total) { @@ -169,7 +167,7 @@ void EditorProfiler::_update_plot() { int w = graph->get_size().width; int h = graph->get_size().height; - bool reset_texture = graph_texture.is_null(); + bool reset_texture = false; int desired_len = w * h * 4; @@ -437,6 +435,7 @@ void EditorProfiler::_activate_pressed() { void EditorProfiler::_clear_pressed() { clear(); + _update_plot(); } void EditorProfiler::_notification(int p_what) { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 3c3df6b8ef..069b9147ce 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -651,6 +651,7 @@ public: int h = bsize * 2 + 1; int vofs = (rect.size.height - h) / 2; + Color color = get_color("highlight_color", "Editor"); for (int i = 0; i < 2; i++) { Point2 ofs(4, vofs); @@ -667,7 +668,8 @@ public: uint32_t idx = i * 10 + j; bool on = value & (1 << idx); Rect2 rect = Rect2(o, Size2(bsize, bsize)); - draw_rect(rect, Color(0, 0, 0, on ? 0.8 : 0.3)); + color.a = on ? 0.6 : 0.2; + draw_rect(rect, color); flag_rects.push_back(rect); } } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 23dbb026dd..9982a31b7b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* editor_properties_array_dict.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "editor_properties_array_dict.h" #include "editor/editor_scale.h" #include "editor_properties.h" diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index a8ddb02e9d..d2bd849f30 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* editor_properties_array_dict.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 EDITOR_PROPERTIES_ARRAY_DICT_H #define EDITOR_PROPERTIES_ARRAY_DICT_H diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index bc56a95b47..edfee595ea 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -30,13 +30,13 @@ #include "editor_resource_preview.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/message_queue.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" #include "editor_scale.h" #include "editor_settings.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "message_queue.h" -#include "os/file_access.h" -#include "project_settings.h" bool EditorResourcePreviewGenerator::handles(const String &p_type) const { diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 74841b1a1e..434b26e901 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -31,8 +31,8 @@ #ifndef EDITORRESOURCEPREVIEW_H #define EDITORRESOURCEPREVIEW_H -#include "os/semaphore.h" -#include "os/thread.h" +#include "core/os/semaphore.h" +#include "core/os/thread.h" #include "scene/main/node.h" #include "scene/resources/texture.h" diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index bbd18306a2..ad5cf49f3f 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -30,8 +30,8 @@ #include "editor_run.h" +#include "core/project_settings.h" #include "editor_settings.h" -#include "project_settings.h" EditorRun::Status EditorRun::get_status() const { @@ -196,8 +196,8 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li void EditorRun::stop() { if (status != STATUS_STOP && pid != 0) { - const int max_wait_msec = GLOBAL_DEF("editor/stop_max_wait_msec", 10000); - OS::get_singleton()->kill(pid, max_wait_msec); + + OS::get_singleton()->kill(pid); } status = STATUS_STOP; diff --git a/editor/editor_run.h b/editor/editor_run.h index 8da607e6dc..df2324efd7 100644 --- a/editor/editor_run.h +++ b/editor/editor_run.h @@ -31,7 +31,7 @@ #ifndef EDITOR_RUN_H #define EDITOR_RUN_H -#include "os/os.h" +#include "core/os/os.h" #include "scene/main/node.h" class EditorRun { public: diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h index 027fdd428d..892d5151a0 100644 --- a/editor/editor_run_script.h +++ b/editor/editor_run_script.h @@ -31,8 +31,8 @@ #ifndef EDITOR_RUN_SCRIPT_H #define EDITOR_RUN_SCRIPT_H +#include "core/reference.h" #include "editor_plugin.h" -#include "reference.h" class EditorNode; class EditorScript : public Reference { diff --git a/editor/editor_scale.cpp b/editor/editor_scale.cpp index 365ea95e3e..ba1607b408 100644 --- a/editor/editor_scale.cpp +++ b/editor/editor_scale.cpp @@ -30,7 +30,7 @@ #include "editor_scale.h" -#include "os/os.h" +#include "core/os/os.h" static float scale = 1.0; diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 72050cd79b..9d3ab59116 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* editor_sectioned_inspector.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "editor_sectioned_inspector.h" #include "editor_scale.h" class SectionedInspectorFilter : public Object { diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index 75b51a1581..30d5cd3038 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* editor_sectioned_inspector.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 EDITOR_SECTIONED_INSPECTOR_H #define EDITOR_SECTIONED_INSPECTOR_H diff --git a/editor/editor_settings.h b/editor/editor_settings.h index e5b61abf54..8165c36e67 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -31,13 +31,13 @@ #ifndef EDITOR_SETTINGS_H #define EDITOR_SETTINGS_H -#include "object.h" +#include "core/object.h" #include "core/io/config_file.h" -#include "os/thread_safe.h" -#include "resource.h" +#include "core/os/thread_safe.h" +#include "core/resource.h" +#include "core/translation.h" #include "scene/gui/shortcut.h" -#include "translation.h" class EditorPlugin; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index b2c9f9865a..b5353a071c 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -29,9 +29,9 @@ /*************************************************************************/ #include "editor_spin_slider.h" +#include "core/math/expression.h" +#include "core/os/input.h" #include "editor_scale.h" -#include "math/expression.h" -#include "os/input.h" String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { return rtos(get_value()); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 6c9d1568fa..52611367f6 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -30,14 +30,14 @@ #include "export_template_manager.h" +#include "core/io/json.h" +#include "core/io/zip_io.h" +#include "core/os/dir_access.h" #include "core/os/input.h" #include "core/os/keyboard.h" +#include "core/version.h" #include "editor_node.h" #include "editor_scale.h" -#include "io/json.h" -#include "io/zip_io.h" -#include "os/dir_access.h" -#include "version.h" void ExportTemplateManager::_update_template_list() { diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp index 02e647b733..0e328247ac 100644 --- a/editor/file_type_cache.cpp +++ b/editor/file_type_cache.cpp @@ -30,8 +30,8 @@ #include "file_type_cache.h" -#include "os/file_access.h" -#include "project_settings.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" FileTypeCache *FileTypeCache::singleton = NULL; diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h index 33b50cb1c4..aa2d78f763 100644 --- a/editor/file_type_cache.h +++ b/editor/file_type_cache.h @@ -31,7 +31,7 @@ #ifndef FILE_TYPE_CACHE_H #define FILE_TYPE_CACHE_H -#include "object.h" +#include "core/object.h" class FileTypeCache : Object { diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 28b1095256..d6e89d0573 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -31,7 +31,7 @@ #include "editor_file_server.h" #include "../editor_settings.h" -#include "io/marshalls.h" +#include "core/io/marshalls.h" //#define DEBUG_PRINT(m_p) print_line(m_p) //#define DEBUG_TIME(m_what) printf("MS: %s - %lu\n", m_what, OS::get_singleton()->get_ticks_usec()); diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index d73c78ee70..8e32c3c82f 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -31,11 +31,11 @@ #ifndef EDITOR_FILE_SERVER_H #define EDITOR_FILE_SERVER_H -#include "io/file_access_network.h" -#include "io/packet_peer.h" -#include "io/tcp_server.h" -#include "object.h" -#include "os/thread.h" +#include "core/io/file_access_network.h" +#include "core/io/packet_peer.h" +#include "core/io/tcp_server.h" +#include "core/object.h" +#include "core/os/thread.h" class EditorFileServer : public Object { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index cb38c2f85e..3a55966e7b 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -30,14 +30,14 @@ #include "filesystem_dock.h" +#include "core/io/resource_loader.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 "editor_node.h" #include "editor_settings.h" -#include "io/resource_loader.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "os/os.h" -#include "project_settings.h" #include "scene/main/viewport.h" bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths) { diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index fbbe87fc16..40be645bf7 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -44,8 +44,8 @@ #include "scene/gui/tree.h" #include "scene/main/timer.h" -#include "os/dir_access.h" -#include "os/thread.h" +#include "core/os/dir_access.h" +#include "core/os/thread.h" #include "create_dialog.h" diff --git a/editor/groups_editor.h b/editor/groups_editor.h index 461cf0f8c2..7705b3b6fb 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -31,6 +31,7 @@ #ifndef GROUPS_EDITOR_H #define GROUPS_EDITOR_H +#include "core/undo_redo.h" #include "editor/scene_tree_editor.h" #include "scene/gui/button.h" #include "scene/gui/dialogs.h" @@ -39,7 +40,6 @@ #include "scene/gui/popup.h" #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" -#include "undo_redo.h" /** @author Juan Linietsky <reduzio@gmail.com> diff --git a/editor/icons/icon_c_p_u_particles_2_d.svg b/editor/icons/icon_c_p_u_particles_2_d.svg new file mode 100644 index 0000000000..926e675fee --- /dev/null +++ b/editor/icons/icon_c_p_u_particles_2_d.svg @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + version="1.1" + viewBox="0 0 16 16" + id="svg6" + sodipodi:docname="icon_c_p_u_particles_2_d.svg" + inkscape:version="0.92.3 (2405546, 2018-03-11)"> + <metadata + id="metadata12"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1741" + inkscape:window-height="753" + id="namedview8" + showgrid="false" + inkscape:zoom="14.75" + inkscape:cx="-5.6949153" + inkscape:cy="7.7288136" + inkscape:window-x="67" + inkscape:window-y="27" + inkscape:window-maximized="0" + inkscape:current-layer="svg6" /> + <path + style="fill:#a3b6f3;fill-opacity:0.99215686" + d="m 4.5587261,0.60940813 c -0.4226244,0 -0.7617187,0.3410473 -0.7617187,0.76367177 v 0.5078126 c 0,0.1028478 0.020058,0.199689 0.056641,0.2890624 H 2.6602887 c -0.4226245,0 -0.7617188,0.3390944 -0.7617188,0.7617188 v 0.921875 C 1.8581419,3.8469787 1.821771,3.8301112 1.7794293,3.8301112 H 1.2716168 c -0.42262448,0 -0.76367188,0.3410475 -0.76367188,0.7636719 v 0.3730468 c 0,0.4226245 0.3410474,0.7617188 0.76367188,0.7617188 h 0.5078125 c 0.042396,0 0.078663,-0.016851 0.1191406,-0.023437 v 4.4531248 c -0.040428,-0.0066 -0.076799,-0.02344 -0.1191406,-0.02344 H 1.2716168 c -0.42262448,0 -0.76367188,0.341047 -0.76367188,0.763672 v 0.373047 c 0,0.422625 0.3410474,0.761718 0.76367188,0.761718 h 0.5078125 c 0.042396,0 0.078663,-0.01685 0.1191406,-0.02344 v 1.125 c 0,0.422624 0.3390944,0.763672 0.7617188,0.763672 h 1.1367187 v 0.457031 c 0,0.422624 0.3390943,0.763672 0.7617187,0.763672 H 4.931773 c 0.4226244,0 0.7636719,-0.341048 0.7636719,-0.763672 v -0.457031 h 4.4062501 v 0.457031 c 0,0.422624 0.339094,0.763672 0.761719,0.763672 h 0.373047 c 0.422624,0 0.763671,-0.341048 0.763671,-0.763672 v -0.457031 h 1.269532 c 0.422625,0 0.763672,-0.341048 0.763672,-0.763672 v -1.111328 c 0.01774,0.0012 0.03272,0.0098 0.05078,0.0098 h 0.507812 c 0.422624,0 0.763672,-0.339093 0.763672,-0.761718 v -0.373047 c 0,-0.422624 -0.341048,-0.763672 -0.763672,-0.763672 h -0.507812 c -0.01803,0 -0.03307,0.0085 -0.05078,0.0098 V 5.7187831 c 0.01774,0.00122 0.03272,0.00977 0.05078,0.00977 h 0.507812 c 0.422624,0 0.763672,-0.3390943 0.763672,-0.7617188 V 4.5937831 c 0,-0.4226244 -0.341048,-0.7636719 -0.763672,-0.7636719 h -0.507812 c -0.01803,0 -0.03307,0.00855 -0.05078,0.00977 V 2.9316737 c 0,-0.4226244 -0.341047,-0.7617187 -0.763672,-0.7617188 h -1.328125 c 0.03658,-0.089375 0.05859,-0.1862118 0.05859,-0.2890624 V 1.3730799 c 0,-0.42262437 -0.341047,-0.76367177 -0.763671,-0.76367177 h -0.373047 c -0.422625,0 -0.761719,0.3410474 -0.761719,0.76367177 v 0.5078126 c 0,0.1028478 0.02006,0.1996891 0.05664,0.2890624 H 5.6368511 C 5.6734361,2.08058 5.6954449,1.9837431 5.6954449,1.8808925 V 1.3730799 c 0,-0.42262437 -0.3410475,-0.76367177 -0.7636719,-0.76367177 z M 7.7970074,2.9668299 A 3.279661,3.6440678 0 0 1 11.009898,5.9062831 2.1864407,2.1864407 0 0 1 12.89857,8.0683925 2.1864407,2.1864407 0 0 1 10.71107,10.25394 H 4.8809918 A 2.1864407,2.1864407 0 0 1 2.6954449,8.0683925 2.1864407,2.1864407 0 0 1 4.5802105,5.9043299 3.279661,3.6440678 0 0 1 7.7970074,2.9668299 Z M 4.8809918,10.982455 A 0.72881355,0.72881355 0 0 1 5.6095074,11.710971 0.72881355,0.72881355 0 0 1 4.8809918,12.44144 0.72881355,0.72881355 0 0 1 4.1524761,11.710971 0.72881355,0.72881355 0 0 1 4.8809918,10.982455 Z m 5.8300782,0 A 0.72881355,0.72881355 0 0 1 11.441539,11.710971 0.72881355,0.72881355 0 0 1 10.71107,12.44144 0.72881355,0.72881355 0 0 1 9.9825543,11.710971 0.72881355,0.72881355 0 0 1 10.71107,10.982455 Z M 7.7970074,11.710971 A 0.72881355,0.72881355 0 0 1 8.525523,12.44144 0.72881355,0.72881355 0 0 1 7.7970074,13.169955 0.72881355,0.72881355 0 0 1 7.0684918,12.44144 0.72881355,0.72881355 0 0 1 7.7970074,11.710971 Z" + id="rect822" + inkscape:connector-curvature="0" /> + <g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Layer 1" /> +</svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index d4bd4f85e6..31c1886d32 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -30,9 +30,9 @@ #include "editor_import_collada.h" +#include "core/os/os.h" #include "editor/collada/collada.h" #include "editor/editor_node.h" -#include "os/os.h" #include "scene/3d/camera.h" #include "scene/3d/light.h" #include "scene/3d/mesh_instance.h" diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 92d83158ef..b850c0605b 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -31,7 +31,7 @@ #ifndef EDITOR_IMPORT_PLUGIN_H #define EDITOR_IMPORT_PLUGIN_H -#include "io/resource_import.h" +#include "core/io/resource_import.h" class EditorImportPlugin : public ResourceImporter { GDCLASS(EditorImportPlugin, Reference) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 4d5c292847..85383fd69d 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -29,10 +29,10 @@ /*************************************************************************/ #include "editor_scene_importer_gltf.h" -#include "io/json.h" -#include "math_defs.h" -#include "os/file_access.h" -#include "os/os.h" +#include "core/io/json.h" +#include "core/math/math_defs.h" +#include "core/os/file_access.h" +#include "core/os/os.h" #include "scene/3d/camera.h" #include "scene/3d/mesh_instance.h" #include "scene/animation/animation_player.h" @@ -793,7 +793,7 @@ Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, ret.resize(ret_size); { for (int i = 0; i < ret_size; i++) { - ret.write[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]); + ret.write[i] = Quat(attribs_ptr[i * 4 + 0], attribs_ptr[i * 4 + 1], attribs_ptr[i * 4 + 2], attribs_ptr[i * 4 + 3]).normalized(); } } return ret; @@ -1793,17 +1793,24 @@ template <> struct EditorSceneImporterGLTFInterpolate<Quat> { Quat lerp(const Quat &a, const Quat &b, float c) const { + ERR_FAIL_COND_V(a.is_normalized() == false, Quat()); + ERR_FAIL_COND_V(b.is_normalized() == false, Quat()); - return a.slerp(b, c); + return a.slerp(b, c).normalized(); } Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, float c) { + ERR_FAIL_COND_V(p1.is_normalized() == false, Quat()); + ERR_FAIL_COND_V(p2.is_normalized() == false, Quat()); - return p1.slerp(p2, c); + return p1.slerp(p2, c).normalized(); } Quat bezier(Quat start, Quat control_1, Quat control_2, Quat end, float t) { - return start.slerp(end, t); + ERR_FAIL_COND_V(start.is_normalized() == false, Quat()); + ERR_FAIL_COND_V(end.is_normalized() == false, Quat()); + + return start.slerp(end, t).normalized(); } }; @@ -1869,9 +1876,9 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); T from = p_values[idx * 3 + 1]; - T c1 = from + p_values[idx * 3 + 0]; - T to = p_values[idx * 3 + 3]; - T c2 = to + p_values[idx * 3 + 2]; + T c1 = from + p_values[idx * 3 + 2]; + T to = p_values[idx * 3 + 4]; + T c2 = to + p_values[idx * 3 + 3]; return interp.bezier(from, c1, c2, to, c); @@ -1945,7 +1952,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye Vector3 base_scale = Vector3(1, 1, 1); if (!track.rotation_track.values.size()) { - base_rot = state.nodes[E->key()]->rotation; + base_rot = state.nodes[E->key()]->rotation.normalized(); } if (!track.translation_track.values.size()) { @@ -1991,6 +1998,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye xform = skeleton->get_bone_rest(bone).affine_inverse() * xform; rot = xform.basis.get_rotation_quat(); + rot.normalize(); scale = xform.basis.get_scale(); pos = xform.origin; } diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 7b330936f6..917d6d1bcc 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -30,10 +30,10 @@ #include "resource_importer_bitmask.h" #include "core/image.h" +#include "core/io/config_file.h" +#include "core/io/image_loader.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" -#include "io/config_file.h" -#include "io/image_loader.h" #include "scene/resources/bit_mask.h" #include "scene/resources/texture.h" diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index f3537df819..1b97152099 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -31,8 +31,8 @@ #ifndef RESOURCE_IMPORTER_BITMASK_H #define RESOURCE_IMPORTER_BITMASK_H -#include "image.h" -#include "io/resource_import.h" +#include "core/image.h" +#include "core/io/resource_import.h" class StreamBitMap; diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index cf850eef03..e7f9e1afe6 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -30,10 +30,10 @@ #include "resource_importer_csv_translation.h" -#include "compressed_translation.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "translation.h" +#include "core/compressed_translation.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" +#include "core/translation.h" String ResourceImporterCSVTranslation::get_importer_name() const { diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index f5f230c6bd..370c182f65 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -31,7 +31,7 @@ #ifndef RESOURCEIMPORTERCSVTRANSLATION_H #define RESOURCEIMPORTERCSVTRANSLATION_H -#include "io/resource_import.h" +#include "core/io/resource_import.h" class ResourceImporterCSVTranslation : public ResourceImporter { GDCLASS(ResourceImporterCSVTranslation, ResourceImporter) diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp index b6a67c0cd3..923a9a20ec 100644 --- a/editor/import/resource_importer_image.cpp +++ b/editor/import/resource_importer_image.cpp @@ -1,8 +1,38 @@ +/*************************************************************************/ +/* resource_importer_image.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "resource_importer_image.h" -#include "io/image_loader.h" -#include "io/resource_saver.h" -#include "os/file_access.h" +#include "core/io/image_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" #include "scene/resources/texture.h" String ResourceImporterImage::get_importer_name() const { diff --git a/editor/import/resource_importer_image.h b/editor/import/resource_importer_image.h index 5aadd00a35..d282ac482d 100644 --- a/editor/import/resource_importer_image.h +++ b/editor/import/resource_importer_image.h @@ -1,8 +1,38 @@ +/*************************************************************************/ +/* resource_importer_image.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 RESOURCE_IMPORTER_IMAGE_H #define RESOURCE_IMPORTER_IMAGE_H -#include "image.h" -#include "io/resource_import.h" +#include "core/image.h" +#include "core/io/resource_import.h" class ResourceImporterImage : public ResourceImporter { GDCLASS(ResourceImporterImage, ResourceImporter) diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 211bb7bcc9..a0ed27c72c 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -1,11 +1,41 @@ +/*************************************************************************/ +/* resource_importer_layered_texture.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "resource_importer_layered_texture.h" #include "resource_importer_texture.h" +#include "core/io/config_file.h" +#include "core/io/image_loader.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" -#include "io/config_file.h" -#include "io/image_loader.h" #include "scene/resources/texture.h" String ResourceImporterLayeredTexture::get_importer_name() const { @@ -52,6 +82,7 @@ String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const { void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_COLOR_CORRECT ? 0 : 1)); diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index ec73b2624d..a4b83bf56c 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -1,8 +1,38 @@ +/*************************************************************************/ +/* resource_importer_layered_texture.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 RESOURCE_IMPORTER_LAYERED_TEXTURE_H #define RESOURCE_IMPORTER_LAYERED_TEXTURE_H -#include "image.h" -#include "io/resource_import.h" +#include "core/image.h" +#include "core/io/resource_import.h" class StreamTexture; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 3f101cd04d..b18bbc8ce9 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -30,8 +30,8 @@ #include "resource_importer_obj.h" -#include "io/resource_saver.h" -#include "os/file_access.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" #include "scene/3d/mesh_instance.h" #include "scene/3d/spatial.h" #include "scene/resources/mesh.h" diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index f544811eb0..6d72cb4909 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -30,8 +30,8 @@ #include "resource_importer_scene.h" +#include "core/io/resource_saver.h" #include "editor/editor_node.h" -#include "io/resource_saver.h" #include "scene/resources/packed_scene.h" #include "scene/3d/collision_shape.h" diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 2bde9432fc..b046e2e975 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -31,7 +31,7 @@ #ifndef RESOURCEIMPORTERSCENE_H #define RESOURCEIMPORTERSCENE_H -#include "io/resource_import.h" +#include "core/io/resource_import.h" #include "scene/resources/animation.h" #include "scene/resources/mesh.h" #include "scene/resources/shape.h" diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index d03395c070..acca1725d7 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -30,10 +30,10 @@ #include "resource_importer_texture.h" +#include "core/io/config_file.h" +#include "core/io/image_loader.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" -#include "io/config_file.h" -#include "io/image_loader.h" #include "scene/resources/texture.h" void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) { @@ -164,11 +164,19 @@ bool ResourceImporterTexture::get_option_visibility(const String &p_option, cons if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VIDEO_RAM) { return false; } - } else if (p_option == "compress/no_bptc_if_rgb" || p_option == "compress/hdr_mode") { + } else if (p_option == "compress/hdr_mode") { int compress_mode = int(p_options["compress/mode"]); if (compress_mode != COMPRESS_VIDEO_RAM) { return false; } + } else if (p_option == "compress/bptc_ldr") { + int compress_mode = int(p_options["compress/mode"]); + if (compress_mode != COMPRESS_VIDEO_RAM) { + return false; + } + if (!ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) { + return false; + } } return true; @@ -193,8 +201,8 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "LDR Fallback,Force RGBE,RGBE Fallback"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Enabled,Force RGBE"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Enabled,RGBA Only"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset == PRESET_2D_PIXEL ? false : true)); @@ -353,7 +361,6 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { int compress_mode = p_options["compress/mode"]; - int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"]; float lossy = p_options["compress/lossy_quality"]; int repeat = p_options["flags/repeat"]; bool filter = p_options["flags/filter"]; @@ -365,11 +372,11 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String bool invert_color = p_options["process/invert_color"]; bool stream = p_options["stream"]; int size_limit = p_options["size_limit"]; - bool force_rgbe = int(p_options["compress/hdr_mode"]) == 1; - bool rgbe_fallback = int(p_options["compress/hdr_mode"]) == 2; bool hdr_as_srgb = p_options["process/HDR_as_SRGB"]; int normal = p_options["compress/normal_map"]; float scale = p_options["svg/scale"]; + bool force_rgbe = p_options["compress/hdr_mode"]; + int bptc_ldr = p_options["compress/bptc_ldr"]; Ref<Image> image; image.instance(); @@ -424,8 +431,8 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String int width = image->get_width(); image->lock(); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { image->set_pixel(i, j, image->get_pixel(i, j).inverted()); } } @@ -442,59 +449,55 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String //Android, GLES 2.x bool ok_on_pc = false; - bool encode_bptc = false; bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995); - bool no_ldr_compression = (is_hdr && rgbe_fallback); + bool is_ldr = (image->get_format() >= Image::FORMAT_L8 && image->get_format() <= Image::FORMAT_RGBA5551); + bool can_bptc = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc"); + bool can_s3tc = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc"); - if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) { + if (can_bptc) { + Image::DetectChannels channels = image->get_detected_channels(); + if (is_hdr) { - encode_bptc = true; + if (channels == Image::DETECTED_LA || channels == Image::DETECTED_RGBA) { + can_bptc = false; + } + } else if (is_ldr) { - if (no_bptc_if_rgb && !is_hdr) { - Image::DetectChannels channels = image->get_detected_channels(); - if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) { - encode_bptc = false; + //handle "RGBA Only" setting + if (bptc_ldr == 1 && channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) { + can_bptc = false; } } } - if (encode_bptc) { - - _save_stex(image, p_save_path + ".bptc.stex", compress_mode, lossy, Image::COMPRESS_BPTC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); - r_platform_variants->push_back("bptc"); - ok_on_pc = true; + if (!can_bptc && is_hdr && !force_rgbe) { + //convert to ldr if this can't be stored hdr + image->convert(Image::FORMAT_RGBA8); } - if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc") && !no_ldr_compression) { - - _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); + if (can_bptc || can_s3tc) { + _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("s3tc"); ok_on_pc = true; } - if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2") && !no_ldr_compression) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("etc2"); } - if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc") && !no_ldr_compression) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("etc"); } - if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc") && !no_ldr_compression) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("pvrtc"); } - if (is_hdr && rgbe_fallback) { - _save_stex(image, p_save_path + ".fallback.stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, true, detect_normal, force_normal); - r_platform_variants->push_back("fallback"); - ok_on_pc = true; - } - if (!ok_on_pc) { EditorNode::add_io_error("Warning, no suitable PC VRAM compression enabled in Project Settings. This texture will not display correcly on PC."); } diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index fd6f75c3f4..b49b29874d 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -31,8 +31,8 @@ #ifndef RESOURCEIMPORTTEXTURE_H #define RESOURCEIMPORTTEXTURE_H -#include "image.h" -#include "io/resource_import.h" +#include "core/image.h" +#include "core/io/resource_import.h" class StreamTexture; diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index d04f29ea5e..55f4cc7439 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -30,9 +30,9 @@ #include "resource_importer_wav.h" -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "os/file_access.h" +#include "core/io/marshalls.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" #include "scene/resources/audio_stream_sample.h" String ResourceImporterWAV::get_importer_name() const { diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index f78ab09e9b..a630ff732e 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -31,7 +31,7 @@ #ifndef RESOURCEIMPORTWAV_H #define RESOURCEIMPORTWAV_H -#include "io/resource_import.h" +#include "core/io/resource_import.h" class ResourceImporterWAV : public ResourceImporter { GDCLASS(ResourceImporterWAV, ResourceImporter) diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 0335053162..9145a66510 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -36,6 +36,12 @@ void InspectorDock::_menu_option(int p_option) { switch (p_option) { + case EXPAND_ALL: { + _menu_expandall(); + } break; + case COLLAPSE_ALL: { + _menu_collapseall(); + } break; case RESOURCE_MAKE_BUILT_IN: { _unref_resource(); } break; diff --git a/editor/output_strings.h b/editor/output_strings.h index 0729971704..4833f2067e 100644 --- a/editor/output_strings.h +++ b/editor/output_strings.h @@ -31,7 +31,7 @@ #ifndef OUTPUT_STRINGS_H #define OUTPUT_STRINGS_H -#include "map.h" +#include "core/map.h" #include "scene/gui/control.h" #include "scene/gui/scroll_bar.h" diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 5373015654..4b1e710705 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -1,6 +1,36 @@ +/*************************************************************************/ +/* animation_blend_space_1d_editor.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_blend_space_1d_editor.h" -#include "os/keyboard.h" +#include "core/os/keyboard.h" #include "scene/animation/animation_blend_tree.h" StringName AnimationNodeBlendSpace1DEditor::get_blend_position_path() const { diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h index 278357b9c7..ca6135406c 100644 --- a/editor/plugins/animation_blend_space_1d_editor.h +++ b/editor/plugins/animation_blend_space_1d_editor.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_blend_space_1d_editor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_BLEND_SPACE_1D_EDITOR_H #define ANIMATION_BLEND_SPACE_1D_EDITOR_H diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 2d240b5a5c..c4f8cdc3d7 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -1,10 +1,40 @@ +/*************************************************************************/ +/* animation_blend_space_2d_editor.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_blend_space_2d_editor.h" #include "core/io/resource_loader.h" +#include "core/math/delaunay.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" -#include "math/delaunay.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/animation/animation_blend_tree.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index 0bf1e25d7a..613289e4d8 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_blend_space_2d_editor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_BLEND_SPACE_2D_EDITOR_H #define ANIMATION_BLEND_SPACE_2D_EDITOR_H diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index dbb5fa578b..4d27a5cea4 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -1,10 +1,40 @@ +/*************************************************************************/ +/* animation_blend_tree_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_blend_tree_editor_plugin.h" #include "core/io/resource_loader.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_inspector.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index 35ecc32979..9616e8b5da 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_blend_tree_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_BLEND_TREE_EDITOR_PLUGIN_H #define ANIMATION_BLEND_TREE_EDITOR_PLUGIN_H diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 9ab5436de8..bd7b58f65a 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -30,12 +30,12 @@ #include "animation_player_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/keyboard.h" +#include "core/project_settings.h" #include "editor/animation_track_editor.h" #include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/keyboard.h" -#include "project_settings.h" // For onion skinning #include "editor/plugins/canvas_item_editor_plugin.h" diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 3a65cb9b38..d00c06bd12 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1,10 +1,40 @@ +/*************************************************************************/ +/* animation_state_machine_editor.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_state_machine_editor.h" #include "core/io/resource_loader.h" +#include "core/math/delaunay.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" -#include "math/delaunay.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/animation/animation_blend_tree.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 49d08607cf..7b8a4a0e94 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_state_machine_editor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_STATE_MACHINE_EDITOR_H #define ANIMATION_STATE_MACHINE_EDITOR_H diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 19921ef54f..24787a78e9 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_tree_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "animation_tree_editor_plugin.h" #include "animation_blend_space_1d_editor.h" @@ -5,10 +35,10 @@ #include "animation_blend_tree_editor_plugin.h" #include "animation_state_machine_editor.h" #include "core/io/resource_loader.h" +#include "core/math/delaunay.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" -#include "math/delaunay.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/animation/animation_blend_tree.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index b12054bb62..be8848d600 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_tree_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ANIMATION_TREE_EDITOR_PLUGIN_H #define ANIMATION_TREE_EDITOR_PLUGIN_H diff --git a/editor/plugins/animation_tree_player_editor_plugin.cpp b/editor/plugins/animation_tree_player_editor_plugin.cpp index 36d10ab99e..c79e3a436d 100644 --- a/editor/plugins/animation_tree_player_editor_plugin.cpp +++ b/editor/plugins/animation_tree_player_editor_plugin.cpp @@ -31,9 +31,9 @@ #include "animation_tree_player_editor_plugin.h" #include "core/io/resource_loader.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" #include "scene/main/viewport.h" diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 454a5d72f2..06ca5833e2 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "audio_stream_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/project_settings.h" #include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" void AudioStreamEditor::_notification(int p_what) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 72248b62a3..7fe9f429b0 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -30,15 +30,15 @@ #include "canvas_item_editor_plugin.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" +#include "core/print_string.h" +#include "core/project_settings.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/script_editor_debugger.h" -#include "os/input.h" -#include "os/keyboard.h" -#include "print_string.h" -#include "project_settings.h" #include "scene/2d/light_2d.h" #include "scene/2d/particles_2d.h" #include "scene/2d/polygon_2d.h" @@ -55,6 +55,7 @@ #define MAX_ZOOM 100 #define RULER_WIDTH 15 * EDSCALE +#define SCALE_HANDLE_DISTANCE 25 class SnapDialog : public ConfirmationDialog { @@ -335,10 +336,11 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) return; - if (k->get_control()) - return; + if (k->get_scancode() == KEY_CONTROL || k->get_scancode() == KEY_ALT || k->get_scancode() == KEY_SHIFT) { + viewport->update(); + } - if (k->is_pressed() && !k->is_echo()) { + if (k->is_pressed() && !k->get_control() && !k->is_echo()) { if ((snap_grid || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) { // Multiply the grid size grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); @@ -667,7 +669,7 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retreive_lock List<CanvasItem *> selection; for (Map<Node *, Object *>::Element *E = editor_selection->get_selection().front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key()); - if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (!retreive_locked || !canvas_item->has_meta("_edit_lock_"))) { + if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retreive_locked || !canvas_item->has_meta("_edit_lock_"))) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { selection.push_back(canvas_item); @@ -1267,7 +1269,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { if (drag_type == DRAG_NONE) { if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { drag_selection = _get_edited_canvas_items(); - if (drag_selection.size() > 0 && ((b->get_control() && tool == TOOL_SELECT) || tool == TOOL_ROTATE)) { + if (drag_selection.size() > 0 && ((b->get_control() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE)) { drag_type = DRAG_ROTATE; drag_from = transform.affine_inverse().xform(b->get_position()); CanvasItem *canvas_item = drag_selection[0]; @@ -1615,6 +1617,89 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { return false; } +bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { + + Ref<InputEventMouseButton> b = p_event; + Ref<InputEventMouseMotion> m = p_event; + + // Drag resize handles + if (drag_type == DRAG_NONE) { + if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed() && ((b->get_alt() && b->get_control()) || tool == TOOL_SCALE)) { + List<CanvasItem *> selection = _get_edited_canvas_items(); + if (selection.size() == 1) { + CanvasItem *canvas_item = selection[0]; + + Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + + Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); + Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_X; + } + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) { + drag_type = DRAG_SCALE_Y; + } + if (drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + drag_from = transform.affine_inverse().xform(b->get_position()); + drag_selection = List<CanvasItem *>(); + drag_selection.push_back(canvas_item); + _save_canvas_item_state(drag_selection); + return true; + } + } + } + } + + if (drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + // Resize the node + if (m.is_valid()) { + _restore_canvas_item_state(drag_selection, true); + CanvasItem *canvas_item = drag_selection[0]; + + drag_to = transform.affine_inverse().xform(m->get_position()); + + bool uniform = m->get_shift(); + Point2 offset = drag_to - drag_from; + Size2 scale = canvas_item->call("get_scale"); + float ratio = scale.y / scale.x; + if (drag_type == DRAG_SCALE_X) { + scale.x += offset.x / SCALE_HANDLE_DISTANCE; + if (uniform) { + scale.y = scale.x * ratio; + } + canvas_item->call("set_scale", scale); + + } else if (drag_type == DRAG_SCALE_Y) { + scale.y -= offset.y / SCALE_HANDLE_DISTANCE; + if (uniform) { + scale.x = scale.y / ratio; + } + canvas_item->call("set_scale", scale); + } + } + + // Confirm resize + if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) { + _commit_canvas_item_state(drag_selection, TTR("Scale CanvasItem")); + drag_type = DRAG_NONE; + viewport->update(); + return true; + } + + // Cancel a drag + if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) { + _restore_canvas_item_state(drag_selection); + drag_type = DRAG_NONE; + viewport->update(); + return true; + } + } + return false; +} + bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseMotion> m = p_event; @@ -1624,8 +1709,8 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { //Start moving the nodes if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { List<CanvasItem *> selection = _get_edited_canvas_items(); - if ((b->get_alt() || tool == TOOL_MOVE) && selection.size() > 0) { - drag_type = DRAG_ALL; + if (((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) && selection.size() > 0) { + drag_type = DRAG_MOVE; drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = selection; _save_canvas_item_state(drag_selection); @@ -1634,7 +1719,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } } - if (drag_type == DRAG_ALL) { + if (drag_type == DRAG_MOVE) { // Move the nodes if (m.is_valid()) { _restore_canvas_item_state(drag_selection, true); @@ -1674,7 +1759,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } // Confirm the move (only if it was moved) - if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && (drag_type == DRAG_ALL)) { + if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && (drag_type == DRAG_MOVE)) { if (transform.affine_inverse().xform(b->get_position()) != drag_from) { _commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true); } @@ -1858,22 +1943,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { // Retrieve the bones _get_bones_at_pos(click, selection); - for (int i = 0; i < selection.size(); i++) { - if (editor_selection->is_selected(selection[i].item)) { - // Drag the node(s) if requested - List<CanvasItem *> selection = _get_edited_canvas_items(); - - drag_type = DRAG_ALL; - drag_selection = selection; - drag_from = click; - _save_canvas_item_state(drag_selection); - - return true; - } - } - - if (!selection.empty()) + if (!selection.empty()) { canvas_item = selection[0].item; + } if (!canvas_item) { // Start a box selection @@ -1894,7 +1966,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { // Drag the node(s) if requested List<CanvasItem *> selection = _get_edited_canvas_items(); - drag_type = DRAG_ALL; + drag_type = DRAG_MOVE; drag_selection = selection; drag_from = click; _save_canvas_item_state(drag_selection); @@ -2019,6 +2091,8 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { //printf("Open scene on double click\n"); } else if ((accepted = _gui_input_anchors(p_event))) { //printf("Anchors\n"); + } else if ((accepted = _gui_input_scale(p_event))) { + //printf("Set scale\n"); } else if ((accepted = _gui_input_pivot(p_event))) { //printf("Set pivot\n"); } else if ((accepted = _gui_input_resize(p_event))) { @@ -2073,7 +2147,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { case DRAG_BOTTOM_LEFT: c = CURSOR_BDIAGSIZE; break; - case DRAG_ALL: + case DRAG_MOVE: c = CURSOR_MOVE; break; case DRAG_PAN: @@ -2301,6 +2375,188 @@ void CanvasItemEditor::_draw_grid() { } } +void CanvasItemEditor::_draw_control_helpers(Control *control) { + Transform2D xform = transform * control->get_global_transform_with_canvas(); + RID ci = viewport->get_canvas_item(); + if (tool == TOOL_SELECT && show_helpers && !Object::cast_to<Container>(control->get_parent())) { + // Draw the helpers + Color color_base = Color(0.8, 0.8, 0.8, 0.5); + + float anchors_values[4]; + anchors_values[0] = control->get_anchor(MARGIN_LEFT); + anchors_values[1] = control->get_anchor(MARGIN_TOP); + anchors_values[2] = control->get_anchor(MARGIN_RIGHT); + anchors_values[3] = control->get_anchor(MARGIN_BOTTOM); + + // Draw the anchors + Vector2 anchors[4]; + Vector2 anchors_pos[4]; + for (int i = 0; i < 4; i++) { + anchors[i] = Vector2((i % 2 == 0) ? anchors_values[i] : anchors_values[(i + 1) % 4], (i % 2 == 1) ? anchors_values[i] : anchors_values[(i + 1) % 4]); + anchors_pos[i] = xform.xform(_anchor_to_position(control, anchors[i])); + } + + // Get which anchor is dragged + int dragged_anchor = -1; + switch (drag_type) { + case DRAG_ANCHOR_ALL: + case DRAG_ANCHOR_TOP_LEFT: + dragged_anchor = 0; + break; + case DRAG_ANCHOR_TOP_RIGHT: + dragged_anchor = 1; + break; + case DRAG_ANCHOR_BOTTOM_RIGHT: + dragged_anchor = 2; + break; + case DRAG_ANCHOR_BOTTOM_LEFT: + dragged_anchor = 3; + break; + default: + break; + } + + if (dragged_anchor >= 0) { + // Draw the 4 lines when dragged + bool snapped; + Color color_snapped = Color(0.64, 0.93, 0.67, 0.5); + + Vector2 corners_pos[4]; + for (int i = 0; i < 4; i++) { + corners_pos[i] = xform.xform(_anchor_to_position(control, Vector2((i == 0 || i == 3) ? ANCHOR_BEGIN : ANCHOR_END, (i <= 1) ? ANCHOR_BEGIN : ANCHOR_END))); + } + + Vector2 line_starts[4]; + Vector2 line_ends[4]; + for (int i = 0; i < 4; i++) { + float anchor_val = (i >= 2) ? ANCHOR_END - anchors_values[i] : anchors_values[i]; + line_starts[i] = Vector2::linear_interpolate(corners_pos[i], corners_pos[(i + 1) % 4], anchor_val); + line_ends[i] = Vector2::linear_interpolate(corners_pos[(i + 3) % 4], corners_pos[(i + 2) % 4], anchor_val); + snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; + viewport->draw_line(line_starts[i], line_ends[i], snapped ? color_snapped : color_base, (i == dragged_anchor || (i + 3) % 4 == dragged_anchor) ? 2 : 1); + } + + // Display the percentages next to the lines + float percent_val; + percent_val = anchors_values[(dragged_anchor + 2) % 4] - anchors_values[dragged_anchor]; + percent_val = (dragged_anchor >= 2) ? -percent_val : percent_val; + _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Margin)((dragged_anchor + 1) % 4)); + + percent_val = anchors_values[(dragged_anchor + 3) % 4] - anchors_values[(dragged_anchor + 1) % 4]; + percent_val = ((dragged_anchor + 1) % 4 >= 2) ? -percent_val : percent_val; + _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Margin)(dragged_anchor)); + + percent_val = anchors_values[(dragged_anchor + 1) % 4]; + percent_val = ((dragged_anchor + 1) % 4 >= 2) ? ANCHOR_END - percent_val : percent_val; + _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Margin)(dragged_anchor)); + + percent_val = anchors_values[dragged_anchor]; + percent_val = (dragged_anchor >= 2) ? ANCHOR_END - percent_val : percent_val; + _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Margin)((dragged_anchor + 1) % 4)); + } + + Rect2 anchor_rects[4]; + anchor_rects[0] = Rect2(anchors_pos[0] - anchor_handle->get_size(), anchor_handle->get_size()); + anchor_rects[1] = Rect2(anchors_pos[1] - Vector2(0.0, anchor_handle->get_size().y), Point2(-anchor_handle->get_size().x, anchor_handle->get_size().y)); + anchor_rects[2] = Rect2(anchors_pos[2], -anchor_handle->get_size()); + anchor_rects[3] = Rect2(anchors_pos[3] - Vector2(anchor_handle->get_size().x, 0.0), Point2(anchor_handle->get_size().x, -anchor_handle->get_size().y)); + + for (int i = 0; i < 4; i++) { + anchor_handle->draw_rect(ci, anchor_rects[i]); + } + + // Draw the margin values and the node width/height when dragging control side + float ratio = 0.33; + Transform2D parent_transform = xform * control->get_transform().affine_inverse(); + float node_pos_in_parent[4]; + + Rect2 parent_rect = control->get_parent_anchorable_rect(); + + node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * parent_rect.size.width + control->get_margin(MARGIN_LEFT) + parent_rect.position.x; + node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * parent_rect.size.height + control->get_margin(MARGIN_TOP) + parent_rect.position.y; + node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * parent_rect.size.width + control->get_margin(MARGIN_RIGHT) + parent_rect.position.x; + node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * parent_rect.size.height + control->get_margin(MARGIN_BOTTOM) + parent_rect.position.y; + + Point2 start, end; + switch (drag_type) { + case DRAG_LEFT: + case DRAG_TOP_LEFT: + case DRAG_BOTTOM_LEFT: + _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); + case DRAG_MOVE: + start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio)); + end = start - Vector2(control->get_margin(MARGIN_LEFT), 0); + _draw_margin_at_position(control->get_margin(MARGIN_LEFT), parent_transform.xform((start + end) / 2), MARGIN_TOP); + viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); + break; + default: + break; + } + switch (drag_type) { + case DRAG_RIGHT: + case DRAG_TOP_RIGHT: + case DRAG_BOTTOM_RIGHT: + _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); + case DRAG_MOVE: + start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio)); + end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0); + _draw_margin_at_position(control->get_margin(MARGIN_RIGHT), parent_transform.xform((start + end) / 2), MARGIN_BOTTOM); + viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); + break; + default: + break; + } + switch (drag_type) { + case DRAG_TOP: + case DRAG_TOP_LEFT: + case DRAG_TOP_RIGHT: + _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT); + case DRAG_MOVE: + start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]); + end = start - Vector2(0, control->get_margin(MARGIN_TOP)); + _draw_margin_at_position(control->get_margin(MARGIN_TOP), parent_transform.xform((start + end) / 2), MARGIN_LEFT); + viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); + break; + default: + break; + } + switch (drag_type) { + case DRAG_BOTTOM: + case DRAG_BOTTOM_LEFT: + case DRAG_BOTTOM_RIGHT: + _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT); + case DRAG_MOVE: + start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]); + end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM)); + _draw_margin_at_position(control->get_margin(MARGIN_BOTTOM), parent_transform.xform((start + end) / 2), MARGIN_RIGHT); + viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); + break; + default: + break; + } + + switch (drag_type) { + //Draw the ghost rect if the node if rotated/scaled + case DRAG_LEFT: + case DRAG_TOP_LEFT: + case DRAG_TOP: + case DRAG_TOP_RIGHT: + case DRAG_RIGHT: + case DRAG_BOTTOM_RIGHT: + case DRAG_BOTTOM: + case DRAG_BOTTOM_LEFT: + case DRAG_MOVE: + if (control->get_rotation() != 0.0 || control->get_scale() != Vector2(1, 1)) { + Rect2 rect = Rect2(Vector2(node_pos_in_parent[0], node_pos_in_parent[1]), control->get_size()); + viewport->draw_rect(parent_transform.xform(rect), color_base, false); + } + break; + default: + break; + } + } +} + void CanvasItemEditor::_draw_selection() { Ref<Texture> pivot_icon = get_icon("EditorPivot", "EditorIcons"); Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons"); @@ -2317,7 +2573,7 @@ void CanvasItemEditor::_draw_selection() { // Draw the previous position if we are dragging the node if (show_helpers && - (drag_type == DRAG_ALL || drag_type == DRAG_ROTATE || + (drag_type == DRAG_MOVE || drag_type == DRAG_ROTATE || drag_type == DRAG_LEFT || drag_type == DRAG_RIGHT || drag_type == DRAG_TOP || drag_type == DRAG_BOTTOM || drag_type == DRAG_TOP_LEFT || drag_type == DRAG_TOP_RIGHT || drag_type == DRAG_BOTTOM_LEFT || drag_type == DRAG_BOTTOM_RIGHT)) { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; @@ -2359,199 +2615,26 @@ void CanvasItemEditor::_draw_selection() { } } else { - Transform2D transform = Transform2D(xform.get_rotation(), xform.get_origin()); - viewport->draw_set_transform_matrix(transform); + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -(position_icon->get_size() / 2)); - viewport->draw_set_transform_matrix(Transform2D()); + viewport->draw_set_transform_matrix(viewport->get_transform()); } - if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks + if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks // Draw the pivot if (canvas_item->_edit_get_pivot() != Vector2() || drag_type == DRAG_PIVOT || tool == TOOL_EDIT_PIVOT) { // This is not really clean :/ viewport->draw_texture(pivot_icon, (xform.xform(canvas_item->_edit_get_pivot()) - (pivot_icon->get_size() / 2)).floor()); } + // Draw control-related helpers Control *control = Object::cast_to<Control>(canvas_item); if (control) { - if (tool == TOOL_SELECT && show_helpers && !Object::cast_to<Container>(control->get_parent())) { - // Draw the helpers - Color color_base = Color(0.8, 0.8, 0.8, 0.5); - - float anchors_values[4]; - anchors_values[0] = control->get_anchor(MARGIN_LEFT); - anchors_values[1] = control->get_anchor(MARGIN_TOP); - anchors_values[2] = control->get_anchor(MARGIN_RIGHT); - anchors_values[3] = control->get_anchor(MARGIN_BOTTOM); - - // Draw the anchors - Vector2 anchors[4]; - Vector2 anchors_pos[4]; - for (int i = 0; i < 4; i++) { - anchors[i] = Vector2((i % 2 == 0) ? anchors_values[i] : anchors_values[(i + 1) % 4], (i % 2 == 1) ? anchors_values[i] : anchors_values[(i + 1) % 4]); - anchors_pos[i] = xform.xform(_anchor_to_position(control, anchors[i])); - } - - // Get which anchor is dragged - int dragged_anchor = -1; - switch (drag_type) { - case DRAG_ANCHOR_ALL: - case DRAG_ANCHOR_TOP_LEFT: - dragged_anchor = 0; - break; - case DRAG_ANCHOR_TOP_RIGHT: - dragged_anchor = 1; - break; - case DRAG_ANCHOR_BOTTOM_RIGHT: - dragged_anchor = 2; - break; - case DRAG_ANCHOR_BOTTOM_LEFT: - dragged_anchor = 3; - break; - default: - break; - } - - if (dragged_anchor >= 0) { - // Draw the 4 lines when dragged - bool snapped; - Color color_snapped = Color(0.64, 0.93, 0.67, 0.5); - - Vector2 corners_pos[4]; - for (int i = 0; i < 4; i++) { - corners_pos[i] = xform.xform(_anchor_to_position(control, Vector2((i == 0 || i == 3) ? ANCHOR_BEGIN : ANCHOR_END, (i <= 1) ? ANCHOR_BEGIN : ANCHOR_END))); - } - - Vector2 line_starts[4]; - Vector2 line_ends[4]; - for (int i = 0; i < 4; i++) { - float anchor_val = (i >= 2) ? ANCHOR_END - anchors_values[i] : anchors_values[i]; - line_starts[i] = Vector2::linear_interpolate(corners_pos[i], corners_pos[(i + 1) % 4], anchor_val); - line_ends[i] = Vector2::linear_interpolate(corners_pos[(i + 3) % 4], corners_pos[(i + 2) % 4], anchor_val); - snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; - viewport->draw_line(line_starts[i], line_ends[i], snapped ? color_snapped : color_base, (i == dragged_anchor || (i + 3) % 4 == dragged_anchor) ? 2 : 1); - } - - // Display the percentages next to the lines - float percent_val; - percent_val = anchors_values[(dragged_anchor + 2) % 4] - anchors_values[dragged_anchor]; - percent_val = (dragged_anchor >= 2) ? -percent_val : percent_val; - _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Margin)((dragged_anchor + 1) % 4)); - - percent_val = anchors_values[(dragged_anchor + 3) % 4] - anchors_values[(dragged_anchor + 1) % 4]; - percent_val = ((dragged_anchor + 1) % 4 >= 2) ? -percent_val : percent_val; - _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Margin)(dragged_anchor)); - - percent_val = anchors_values[(dragged_anchor + 1) % 4]; - percent_val = ((dragged_anchor + 1) % 4 >= 2) ? ANCHOR_END - percent_val : percent_val; - _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Margin)(dragged_anchor)); - - percent_val = anchors_values[dragged_anchor]; - percent_val = (dragged_anchor >= 2) ? ANCHOR_END - percent_val : percent_val; - _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Margin)((dragged_anchor + 1) % 4)); - } - - Rect2 anchor_rects[4]; - anchor_rects[0] = Rect2(anchors_pos[0] - anchor_handle->get_size(), anchor_handle->get_size()); - anchor_rects[1] = Rect2(anchors_pos[1] - Vector2(0.0, anchor_handle->get_size().y), Point2(-anchor_handle->get_size().x, anchor_handle->get_size().y)); - anchor_rects[2] = Rect2(anchors_pos[2], -anchor_handle->get_size()); - anchor_rects[3] = Rect2(anchors_pos[3] - Vector2(anchor_handle->get_size().x, 0.0), Point2(anchor_handle->get_size().x, -anchor_handle->get_size().y)); - - for (int i = 0; i < 4; i++) { - anchor_handle->draw_rect(ci, anchor_rects[i]); - } - - // Draw the margin values and the node width/height when dragging control side - float ratio = 0.33; - Transform2D parent_transform = xform * control->get_transform().affine_inverse(); - float node_pos_in_parent[4]; - - Rect2 parent_rect = control->get_parent_anchorable_rect(); - - node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * parent_rect.size.width + control->get_margin(MARGIN_LEFT) + parent_rect.position.x; - node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * parent_rect.size.height + control->get_margin(MARGIN_TOP) + parent_rect.position.y; - node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * parent_rect.size.width + control->get_margin(MARGIN_RIGHT) + parent_rect.position.x; - node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * parent_rect.size.height + control->get_margin(MARGIN_BOTTOM) + parent_rect.position.y; - - Point2 start, end; - switch (drag_type) { - case DRAG_LEFT: - case DRAG_TOP_LEFT: - case DRAG_BOTTOM_LEFT: - _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); - case DRAG_ALL: - start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio)); - end = start - Vector2(control->get_margin(MARGIN_LEFT), 0); - _draw_margin_at_position(control->get_margin(MARGIN_LEFT), parent_transform.xform((start + end) / 2), MARGIN_TOP); - viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); - break; - default: - break; - } - switch (drag_type) { - case DRAG_RIGHT: - case DRAG_TOP_RIGHT: - case DRAG_BOTTOM_RIGHT: - _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); - case DRAG_ALL: - start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio)); - end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0); - _draw_margin_at_position(control->get_margin(MARGIN_RIGHT), parent_transform.xform((start + end) / 2), MARGIN_BOTTOM); - viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); - break; - default: - break; - } - switch (drag_type) { - case DRAG_TOP: - case DRAG_TOP_LEFT: - case DRAG_TOP_RIGHT: - _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT); - case DRAG_ALL: - start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]); - end = start - Vector2(0, control->get_margin(MARGIN_TOP)); - _draw_margin_at_position(control->get_margin(MARGIN_TOP), parent_transform.xform((start + end) / 2), MARGIN_LEFT); - viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); - break; - default: - break; - } - switch (drag_type) { - case DRAG_BOTTOM: - case DRAG_BOTTOM_LEFT: - case DRAG_BOTTOM_RIGHT: - _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT); - case DRAG_ALL: - start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]); - end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM)); - _draw_margin_at_position(control->get_margin(MARGIN_BOTTOM), parent_transform.xform((start + end) / 2), MARGIN_RIGHT); - viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, 1); - break; - default: - break; - } - - switch (drag_type) { - //Draw the ghost rect if the node if rotated/scaled - case DRAG_LEFT: - case DRAG_TOP_LEFT: - case DRAG_TOP: - case DRAG_TOP_RIGHT: - case DRAG_RIGHT: - case DRAG_BOTTOM_RIGHT: - case DRAG_BOTTOM: - case DRAG_BOTTOM_LEFT: - case DRAG_ALL: - if (control->get_rotation() != 0.0 || control->get_scale() != Vector2(1, 1)) { - Rect2 rect = Rect2(Vector2(node_pos_in_parent[0], node_pos_in_parent[1]), control->get_size()); - viewport->draw_rect(parent_transform.xform(rect), color_base, false); - } - break; - default: - break; - } - } + _draw_control_helpers(control); } + // Draw the resize handles if (tool == TOOL_SELECT && canvas_item->_edit_use_rect()) { Rect2 rect = canvas_item->_edit_get_rect(); Vector2 endpoints[4] = { @@ -2561,7 +2644,6 @@ void CanvasItemEditor::_draw_selection() { xform.xform(rect.position + Vector2(0, rect.size.y)) }; for (int i = 0; i < 4; i++) { - // Draw the resize handles int prev = (i + 3) % 4; int next = (i + 1) % 4; @@ -2576,6 +2658,46 @@ void CanvasItemEditor::_draw_selection() { select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor()); } } + + // Draw the rescale handles + bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL); + bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); + if ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) { + + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + + Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); + bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom; + + if (drag_type == DRAG_SCALE_X) { + scale_factor.x += offset.x; + if (uniform) { + scale_factor.y += offset.x; + } + } else if (drag_type == DRAG_SCALE_Y) { + scale_factor.y -= offset.y; + if (uniform) { + scale_factor.x -= offset.y; + } + } + + //scale_factor *= zoom; + + viewport->draw_set_transform_matrix(simple_xform); + Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + Color x_axis_color(1.0, 0.4, 0.4, 0.6); + viewport->draw_rect(x_handle_rect, x_axis_color); + viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), x_axis_color); + + Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); + Color y_axis_color(0.4, 1.0, 0.4, 0.6); + viewport->draw_rect(y_handle_rect, y_axis_color); + viewport->draw_line(Point2(), Point2(0, -scale_factor.y * EDSCALE), y_axis_color); + + viewport->draw_set_transform_matrix(viewport->get_transform()); + } } } @@ -2750,15 +2872,16 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans _draw_invisible_nodes_positions(p_node->get_child(i), parent_xform, canvas_xform); } - if (canvas_item && !canvas_item->_edit_use_rect() && !editor_selection->is_selected(canvas_item)) { + if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || (canvas_item->has_meta("_edit_lock_") && canvas_item->get_meta("_edit_lock_")))) { Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons"); - Transform2D transform = Transform2D(xform.get_rotation(), xform.get_origin()); - viewport->draw_set_transform_matrix(transform); + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized(); + Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -position_icon->get_size() / 2, Color(1.0, 1.0, 1.0, 0.5)); - viewport->draw_set_transform_matrix(Transform2D()); + viewport->draw_set_transform_matrix(viewport->get_transform()); } } @@ -3086,6 +3209,7 @@ void CanvasItemEditor::_notification(int p_what) { select_button->set_icon(get_icon("ToolSelect", "EditorIcons")); list_select_button->set_icon(get_icon("ListSelect", "EditorIcons")); move_button->set_icon(get_icon("ToolMove", "EditorIcons")); + scale_button->set_icon(get_icon("ToolScale", "EditorIcons")); rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons")); snap_button->set_icon(get_icon("Snap", "EditorIcons")); snap_config_menu->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); @@ -3394,7 +3518,7 @@ void CanvasItemEditor::_button_toggle_snap(bool p_status) { void CanvasItemEditor::_button_tool_select(int p_index) { - ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, rotate_button, pivot_button, pan_button }; + ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, scale_button, rotate_button, pivot_button, pan_button }; for (int i = 0; i < TOOL_MAX; i++) { tb[i]->set_pressed(i == p_index); } @@ -4286,6 +4410,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q)); select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection")); + hb->add_child(memnew(VSeparator)); + move_button = memnew(ToolButton); hb->add_child(move_button); move_button->set_toggle_mode(true); @@ -4293,6 +4419,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTR("Move Mode"), KEY_W)); move_button->set_tooltip(TTR("Move Mode")); + scale_button = memnew(ToolButton); + hb->add_child(scale_button); + scale_button->set_toggle_mode(true); + scale_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SCALE)); + scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTR("Scale Mode"), KEY_S)); + scale_button->set_tooltip(TTR("Scale Mode")); + rotate_button = memnew(ToolButton); hb->add_child(rotate_button); rotate_button->set_toggle_mode(true); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 2c943385ad..61d77581d3 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -77,6 +77,7 @@ class CanvasItemEditor : public VBoxContainer { TOOL_SELECT, TOOL_LIST_SELECT, TOOL_MOVE, + TOOL_SCALE, TOOL_ROTATE, TOOL_EDIT_PIVOT, TOOL_PAN, @@ -188,7 +189,9 @@ class CanvasItemEditor : public VBoxContainer { DRAG_ANCHOR_BOTTOM_RIGHT, DRAG_ANCHOR_BOTTOM_LEFT, DRAG_ANCHOR_ALL, - DRAG_ALL, + DRAG_MOVE, + DRAG_SCALE_X, + DRAG_SCALE_Y, DRAG_ROTATE, DRAG_PIVOT, DRAG_V_GUIDE, @@ -298,17 +301,19 @@ class CanvasItemEditor : public VBoxContainer { List<PoseClipboard> pose_clipboard; ToolButton *select_button; - ToolButton *list_select_button; + ToolButton *move_button; + ToolButton *scale_button; ToolButton *rotate_button; + ToolButton *list_select_button; + ToolButton *pivot_button; + ToolButton *pan_button; + ToolButton *snap_button; MenuButton *snap_config_menu; PopupMenu *smartsnap_config_popup; - ToolButton *pivot_button; - ToolButton *pan_button; - ToolButton *lock_button; ToolButton *unlock_button; @@ -408,6 +413,7 @@ class CanvasItemEditor : public VBoxContainer { void _draw_guides(); void _draw_focus(); void _draw_grid(); + void _draw_control_helpers(Control *control); void _draw_selection(); void _draw_axis(); void _draw_bones(); @@ -420,6 +426,7 @@ class CanvasItemEditor : public VBoxContainer { bool _gui_input_anchors(const Ref<InputEvent> &p_event); bool _gui_input_move(const Ref<InputEvent> &p_event); bool _gui_input_open_scene_on_double_click(const Ref<InputEvent> &p_event); + bool _gui_input_scale(const Ref<InputEvent> &p_event); bool _gui_input_pivot(const Ref<InputEvent> &p_event); bool _gui_input_resize(const Ref<InputEvent> &p_event); bool _gui_input_rotate(const Ref<InputEvent> &p_event); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 5109379add..805a7d3835 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -31,10 +31,10 @@ #include "collision_polygon_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/file_access.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "editor/editor_settings.h" -#include "os/file_access.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/3d/camera.h" #include "spatial_editor_plugin.h" diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_editor_plugin.cpp index b32f927249..8d3ebc5052 100644 --- a/editor/plugins/cpu_particles_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_editor_plugin.cpp @@ -1,4 +1,35 @@ +/*************************************************************************/ +/* cpu_particles_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "cpu_particles_editor_plugin.h" + #include "editor/plugins/spatial_editor_plugin.h" void CPUParticlesEditor::_node_removed(Node *p_node) { diff --git a/editor/plugins/cpu_particles_editor_plugin.h b/editor/plugins/cpu_particles_editor_plugin.h index f47d17104d..16fb0bab0c 100644 --- a/editor/plugins/cpu_particles_editor_plugin.h +++ b/editor/plugins/cpu_particles_editor_plugin.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* cpu_particles_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 CPU_PARTICLES_EDITOR_PLUGIN_H #define CPU_PARTICLES_EDITOR_PLUGIN_H diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index f5bdf77973..79169d3183 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -31,9 +31,9 @@ #include "curve_editor_plugin.h" #include "canvas_item_editor_plugin.h" -#include "core_string_names.h" -#include "os/input.h" -#include "os/keyboard.h" +#include "core/core_string_names.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" CurveEditor::CurveEditor() { _selected_point = -1; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 9acbceec92..72a746e95b 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -30,12 +30,12 @@ #include "editor_preview_plugins.h" +#include "core/io/file_access_memory.h" +#include "core/io/resource_loader.h" +#include "core/os/os.h" #include "editor/editor_node.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/bit_mask.h" #include "scene/resources/dynamic_font.h" #include "scene/resources/material.h" diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index f75fb0d109..7b5de9c009 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "item_list_editor_plugin.h" -#include "io/resource_loader.h" +#include "core/io/resource_loader.h" bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) { @@ -278,25 +278,27 @@ void ItemListEditor::_add_pressed() { void ItemListEditor::_delete_pressed() { - TreeItem *ti = tree->get_selected(); - - if (!ti) + if (selected_idx == -1) return; - if (ti->get_parent() != tree->get_root()) + String current_selected = (String)property_editor->get_selected_path(); + + if (current_selected == "") return; - int idx = ti->get_text(0).to_int(); + // FIXME: Currently relying on selecting a *property* to derive what item to delete + // e.g. you select "1/enabled" to delete item 1. + // This should be fixed so that you can delete by selecting the item section header, + // or a delete button on that header. - if (selected_idx == -1) - return; + int idx = current_selected.get_slice("/", 0).to_int(); item_plugins[selected_idx]->erase(idx); } void ItemListEditor::_edit_items() { - dialog->popup_centered(Vector2(300, 400)); + dialog->popup_centered(Vector2(300, 400) * EDSCALE); } void ItemListEditor::edit(Node *p_item_list) { @@ -382,13 +384,9 @@ ItemListEditor::ItemListEditor() { hbc->add_child(del_button); del_button->connect("pressed", this, "_delete_button"); - property_editor = memnew(PropertyEditor); - property_editor->hide_top_label(); - property_editor->set_subsection_selectable(true); + property_editor = memnew(EditorInspector); vbc->add_child(property_editor); property_editor->set_v_size_flags(SIZE_EXPAND_FILL); - - tree = property_editor->get_property_tree(); } ItemListEditor::~ItemListEditor() { diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index d6a071b9b9..3dc3775f83 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -32,9 +32,9 @@ #define ITEM_LIST_EDITOR_PLUGIN_H #include "canvas_item_editor_plugin.h" +#include "editor/editor_inspector.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" - #include "scene/gui/menu_button.h" #include "scene/gui/option_button.h" #include "scene/gui/popup_menu.h" @@ -210,7 +210,7 @@ class ItemListEditor : public HBoxContainer { ToolButton *toolbar_button; AcceptDialog *dialog; - PropertyEditor *property_editor; + EditorInspector *property_editor; Tree *tree; Button *add_button; Button *del_button; diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 3351e5918f..4f8a307cc1 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -31,8 +31,8 @@ #include "light_occluder_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/file_access.h" #include "editor/editor_settings.h" -#include "os/file_access.h" void LightOccluder2DEditor::_notification(int p_what) { diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 27a16fd3dd..5e59a73061 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -28,397 +28,9 @@ /* 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. - #include "material_editor_plugin.h" -#include "scene/3d/particles.h" - -#if 0 - -#include "scene/main/viewport.h" - -void MaterialEditor::_gui_input(InputEvent p_event) { - - -} - -void MaterialEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_PHYSICS_PROCESS) { - - } - - - if (p_what==NOTIFICATION_READY) { - - //get_scene()->connect("node_removed",this,"_node_removed"); - - if (first_enter) { - //it's in propertyeditor so.. could be moved around - - light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1","EditorIcons")); - light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off","EditorIcons")); - light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2","EditorIcons")); - light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off","EditorIcons")); - - sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff","EditorIcons")); - sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere","EditorIcons")); - box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff","EditorIcons")); - box_switch->set_pressed_texture(get_icon("MaterialPreviewCube","EditorIcons")); - - first_enter=false; - } - - } - - if (p_what==NOTIFICATION_DRAW) { - - - Ref<Texture> checkerboard = get_icon("Checkerboard","EditorIcons"); - Size2 size = get_size(); - - draw_texture_rect(checkerboard,Rect2(Point2(),size),true); - - } -} - - - -void MaterialEditor::edit(Ref<Material> p_material) { - - material=p_material; - - if (!material.is_null()) { - sphere_mesh->surface_set_material(0,material); - box_mesh->surface_set_material(0,material); - } else { - - hide(); - } - -} - - -void MaterialEditor::_button_pressed(Node* p_button) { - - if (p_button==light_1_switch) { - light1->set_enabled(!light_1_switch->is_pressed()); - } - - if (p_button==light_2_switch) { - light2->set_enabled(!light_2_switch->is_pressed()); - } - - if (p_button==box_switch) { - box_instance->show(); - sphere_instance->hide(); - box_switch->set_pressed(true); - sphere_switch->set_pressed(false); - } - - if (p_button==sphere_switch) { - box_instance->hide(); - sphere_instance->show(); - box_switch->set_pressed(false); - sphere_switch->set_pressed(true); - } - -} - -void MaterialEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_gui_input"),&MaterialEditor::_gui_input); - ClassDB::bind_method(D_METHOD("_button_pressed"),&MaterialEditor::_button_pressed); - -} - -MaterialEditor::MaterialEditor() { - - viewport = memnew( Viewport ); - Ref<World> world; - world.instance(); - viewport->set_world(world); //use own world - add_child(viewport); - viewport->set_disable_input(true); - - camera = memnew( Camera ); - camera->set_transform(Transform(Matrix3(),Vector3(0,0,3))); - camera->set_perspective(45,0.1,10); - viewport->add_child(camera); - - light1 = memnew( DirectionalLight ); - light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0))); - viewport->add_child(light1); - - light2 = memnew( DirectionalLight ); - light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1))); - light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7)); - light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7)); - viewport->add_child(light2); - - sphere_instance = memnew( MeshInstance ); - viewport->add_child(sphere_instance); - - box_instance = memnew( MeshInstance ); - viewport->add_child(box_instance); - - Transform box_xform; - box_xform.basis.rotate(Vector3(1,0,0),Math::deg2rad(25)); - box_xform.basis = box_xform.basis * Matrix3().rotated(Vector3(0,1,0),Math::deg2rad(25)); - box_xform.basis.scale(Vector3(0.8,0.8,0.8)); - box_instance->set_transform(box_xform); - - { - - sphere_mesh.instance(); - - - int lats=32; - int lons=32; - float radius=1.0; - - PoolVector<Vector3> vertices; - PoolVector<Vector3> normals; - PoolVector<Vector2> uvs; - PoolVector<float> tangents; - Matrix3 tt = Matrix3(Vector3(0,1,0),Math_PI*0.5); - - for(int i = 1; i <= lats; i++) { - double lat0 = Math_PI * (-0.5 + (double) (i - 1) / lats); - double z0 = Math::sin(lat0); - double zr0 = Math::cos(lat0); - - double lat1 = Math_PI * (-0.5 + (double) i / lats); - double z1 = Math::sin(lat1); - double zr1 = Math::cos(lat1); - - for(int j = lons; j >= 1; j--) { - - double lng0 = 2 * Math_PI * (double) (j - 1) / lons; - double x0 = Math::cos(lng0); - double y0 = Math::sin(lng0); - - double lng1 = 2 * Math_PI * (double) (j) / lons; - double x1 = Math::cos(lng1); - double y1 = Math::sin(lng1); - - - Vector3 v[4]={ - Vector3(x1 * zr0, z0, y1 *zr0), - Vector3(x1 * zr1, z1, y1 *zr1), - Vector3(x0 * zr1, z1, y0 *zr1), - Vector3(x0 * zr0, z0, y0 *zr0) - }; - -#define ADD_POINT(m_idx) \ - normals.push_back(v[m_idx]); \ - vertices.push_back(v[m_idx] * radius); \ - { \ - Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \ - uv /= Math_PI; \ - uv *= 4.0; \ - uv = uv * 0.5 + Vector2(0.5, 0.5); \ - uvs.push_back(uv); \ - } \ - { \ - Vector3 t = tt.xform(v[m_idx]); \ - tangents.push_back(t.x); \ - tangents.push_back(t.y); \ - tangents.push_back(t.z); \ - tangents.push_back(1.0); \ - } - - - - ADD_POINT(0); - ADD_POINT(1); - ADD_POINT(2); - - ADD_POINT(2); - ADD_POINT(3); - ADD_POINT(0); - } - } - - Array arr; - arr.resize(VS::ARRAY_MAX); - arr[VS::ARRAY_VERTEX]=vertices; - arr[VS::ARRAY_NORMAL]=normals; - arr[VS::ARRAY_TANGENT]=tangents; - arr[VS::ARRAY_TEX_UV]=uvs; - - sphere_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr); - - sphere_instance->set_mesh(sphere_mesh); - - } - { - - - box_mesh.instance(); - - PoolVector<Vector3> vertices; - PoolVector<Vector3> normals; - PoolVector<float> tangents; - PoolVector<Vector3> uvs; - - int vtx_idx=0; -#define ADD_VTX(m_idx) \ - ; \ - vertices.push_back(face_points[m_idx]); \ - normals.push_back(normal_points[m_idx]); \ - tangents.push_back(normal_points[m_idx][1]); \ - tangents.push_back(normal_points[m_idx][2]); \ - tangents.push_back(normal_points[m_idx][0]); \ - tangents.push_back(1.0); \ - uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0)); \ - vtx_idx++;\ - - for (int i=0;i<6;i++) { - - - Vector3 face_points[4]; - Vector3 normal_points[4]; - float uv_points[8]={0,0,0,1,1,1,1,0}; - - for (int j=0;j<4;j++) { - - float v[3]; - v[0]=1.0; - v[1]=1-2*((j>>1)&1); - v[2]=v[1]*(1-2*(j&1)); - - for (int k=0;k<3;k++) { - - if (i<3) - face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1); - else - face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1); - } - normal_points[j]=Vector3(); - normal_points[j][i%3]=(i>=3?-1:1); - } - - //tri 1 - ADD_VTX(0); - ADD_VTX(1); - ADD_VTX(2); - //tri 2 - ADD_VTX(2); - ADD_VTX(3); - ADD_VTX(0); - - } - - - - Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_NORMAL]= normals ; - d[VisualServer::ARRAY_TANGENT]= tangents ; - d[VisualServer::ARRAY_TEX_UV]= uvs ; - d[VisualServer::ARRAY_VERTEX]= vertices ; - - PoolVector<int> indices; - indices.resize(vertices.size()); - for(int i=0;i<vertices.size();i++) - indices.set(i,i); - d[VisualServer::ARRAY_INDEX]=indices; - - box_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d); - box_instance->set_mesh(box_mesh); - box_instance->hide(); - - - - } - - set_custom_minimum_size(Size2(1,150)*EDSCALE); - - HBoxContainer *hb = memnew( HBoxContainer ); - add_child(hb); - hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); - - VBoxContainer *vb_shape = memnew( VBoxContainer ); - hb->add_child(vb_shape); - - sphere_switch = memnew( TextureButton ); - sphere_switch->set_toggle_mode(true); - sphere_switch->set_pressed(true); - vb_shape->add_child(sphere_switch); - sphere_switch->connect("pressed",this,"_button_pressed",varray(sphere_switch)); - - box_switch = memnew( TextureButton ); - box_switch->set_toggle_mode(true); - box_switch->set_pressed(false); - vb_shape->add_child(box_switch); - box_switch->connect("pressed",this,"_button_pressed",varray(box_switch)); - - hb->add_spacer(); - - VBoxContainer *vb_light = memnew( VBoxContainer ); - hb->add_child(vb_light); - - light_1_switch = memnew( TextureButton ); - light_1_switch->set_toggle_mode(true); - vb_light->add_child(light_1_switch); - light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch)); - - light_2_switch = memnew( TextureButton ); - light_2_switch->set_toggle_mode(true); - vb_light->add_child(light_2_switch); - light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch)); - - first_enter=true; - -} - - -void MaterialEditorPlugin::edit(Object *p_object) { - - Material * s = Object::cast_to<Material>(p_object); - if (!s) - return; - - material_editor->edit(Ref<Material>(s)); -} - -bool MaterialEditorPlugin::handles(Object *p_object) const { - - return p_object->is_type("Material"); -} - -void MaterialEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - material_editor->show(); - //material_editor->set_process(true); - } else { - - material_editor->hide(); - //material_editor->set_process(false); - } - -} - -MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) { - - editor=p_node; - material_editor = memnew( MaterialEditor ); - add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,material_editor); - material_editor->hide(); - - - -} - - -MaterialEditorPlugin::~MaterialEditorPlugin() -{ -} -#endif +#include "scene/resources/particles_material.h" String SpatialMaterialConversionPlugin::converts_to() const { @@ -429,7 +41,7 @@ bool SpatialMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) c Ref<SpatialMaterial> mat = p_resource; return mat.is_valid(); } -Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) { +Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { Ref<SpatialMaterial> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); @@ -475,7 +87,7 @@ bool ParticlesMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) Ref<ParticlesMaterial> mat = p_resource; return mat.is_valid(); } -Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) { +Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { Ref<ParticlesMaterial> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); @@ -513,7 +125,7 @@ bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource Ref<CanvasItemMaterial> mat = p_resource; return mat.is_valid(); } -Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) { +Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { Ref<CanvasItemMaterial> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 80a5c535b8..c06d95e700 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -32,84 +32,13 @@ #define MATERIAL_EDITOR_PLUGIN_H #include "editor/property_editor.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" -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" -#include "scene/resources/material.h" - -class MaterialEditor : public Control { - - GDCLASS(MaterialEditor, Control); - - - Viewport *viewport; - MeshInstance *sphere_instance; - MeshInstance *box_instance; - DirectionalLight *light1; - DirectionalLight *light2; - Camera *camera; - - Ref<Mesh> sphere_mesh; - Ref<Mesh> box_mesh; - - TextureButton *sphere_switch; - TextureButton *box_switch; - - TextureButton *light_1_switch; - TextureButton *light_2_switch; - - - Ref<Material> material; - - - void _button_pressed(Node* p_button); - bool first_enter; - -protected: - void _notification(int p_what); - void _gui_input(InputEvent p_event); - static void _bind_methods(); -public: - - void edit(Ref<Material> p_material); - MaterialEditor(); -}; - - -class MaterialEditorPlugin : public EditorPlugin { - - GDCLASS( MaterialEditorPlugin, EditorPlugin ); - - MaterialEditor *material_editor; - EditorNode *editor; - -public: - - virtual String get_name() const { return "Material"; } - 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); - - MaterialEditorPlugin(EditorNode *p_node); - ~MaterialEditorPlugin(); - -}; - -#endif class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin { GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin) public: virtual String converts_to() const; virtual bool handles(const Ref<Resource> &p_resource) const; - virtual Ref<Resource> convert(const Ref<Resource> &p_resource); + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; class ParticlesMaterialConversionPlugin : public EditorResourceConversionPlugin { @@ -117,7 +46,7 @@ class ParticlesMaterialConversionPlugin : public EditorResourceConversionPlugin public: virtual String converts_to() const; virtual bool handles(const Ref<Resource> &p_resource) const; - virtual Ref<Resource> convert(const Ref<Resource> &p_resource); + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin { @@ -125,7 +54,7 @@ class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin public: virtual String converts_to() const; virtual bool handles(const Ref<Resource> &p_resource) const; - virtual Ref<Resource> convert(const Ref<Resource> &p_resource); + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index ae5d510502..5dcbca2ed6 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -31,9 +31,9 @@ #include "particles_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" -#include "io/image_loader.h" -#include "scene/3d/particles.h" +#include "core/io/image_loader.h" #include "scene/gui/separator.h" +#include "scene/resources/particles_material.h" void Particles2DEditorPlugin::edit(Object *p_object) { diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h index 2b6123141b..71ca8ef499 100644 --- a/editor/plugins/particles_2d_editor_plugin.h +++ b/editor/plugins/particles_2d_editor_plugin.h @@ -34,7 +34,6 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "scene/2d/collision_polygon_2d.h" - #include "scene/2d/particles_2d.h" #include "scene/gui/box_container.h" #include "scene/gui/file_dialog.h" diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 3c381158a4..6b41946918 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -29,9 +29,12 @@ /*************************************************************************/ #include "particles_editor_plugin.h" + +#include "core/io/resource_loader.h" #include "editor/plugins/spatial_editor_plugin.h" -#include "io/resource_loader.h" #include "scene/3d/cpu_particles.h" +#include "scene/resources/particles_material.h" + bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals) { bool use_normals = emission_fill->get_selected() == 1; diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h index 622ce6e8a9..830d30d98f 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/particles_editor_plugin.h @@ -43,6 +43,7 @@ class ParticlesEditorBase : public Control { GDCLASS(ParticlesEditorBase, Control) + protected: Spatial *base_node; Panel *panel; diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 33e182faef..96c1ad2f2b 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -31,9 +31,9 @@ #include "path_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/file_access.h" +#include "core/os/keyboard.h" #include "editor/editor_settings.h" -#include "os/file_access.h" -#include "os/keyboard.h" void Path2DEditor::_notification(int p_what) { diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 618c70d1a1..df6c40ed02 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "path_editor_plugin.h" -#include "os/keyboard.h" +#include "core/os/keyboard.h" #include "scene/resources/curve.h" #include "spatial_editor_plugin.h" @@ -57,7 +57,7 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const { return n; } -Variant PathSpatialGizmo::get_handle_value(int p_idx) const { +Variant PathSpatialGizmo::get_handle_value(int p_idx) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) @@ -215,8 +215,8 @@ void PathSpatialGizmo::redraw() { clear(); - Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material"); - Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material"); + Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material", this); + Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material", this); Ref<SpatialMaterial> handles_material = gizmo_plugin->get_material("handles"); Ref<Curve3D> c = path->get_curve(); @@ -641,24 +641,8 @@ String PathSpatialGizmoPlugin::get_name() const { PathSpatialGizmoPlugin::PathSpatialGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); - - Ref<SpatialMaterial> path_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - path_color.a = 0.8; - path_material->set_albedo(path_color); - path_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - path_material->set_line_width(3); - path_material->set_cull_mode(SpatialMaterial::CULL_DISABLED); - path_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - - Ref<SpatialMaterial> path_thin_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + create_material("path_material", path_color); path_color.a = 0.4; - path_thin_material->set_albedo(path_color); - path_thin_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - path_thin_material->set_line_width(1); - path_thin_material->set_cull_mode(SpatialMaterial::CULL_DISABLED); - path_thin_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - - add_material("path_material", path_material); - add_material("path_thin_material", path_thin_material); + create_material("path_thin_material", path_color); create_handle_material("handles"); } diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h index 61f309e794..c77b2a41cc 100644 --- a/editor/plugins/path_editor_plugin.h +++ b/editor/plugins/path_editor_plugin.h @@ -45,7 +45,7 @@ class PathSpatialGizmo : public EditorSpatialGizmo { public: virtual String get_handle_name(int p_idx) const; - virtual Variant get_handle_value(int p_idx) const; + virtual Variant get_handle_value(int p_idx); virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point); virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); diff --git a/editor/plugins/physical_bone_plugin.cpp b/editor/plugins/physical_bone_plugin.cpp index 42f1adcadf..1c3c000808 100644 --- a/editor/plugins/physical_bone_plugin.cpp +++ b/editor/plugins/physical_bone_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/physical_bone_plugin.h b/editor/plugins/physical_bone_plugin.h index 9e7a50307a..e03d342709 100644 --- a/editor/plugins/physical_bone_plugin.h +++ b/editor/plugins/physical_bone_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index a437cd5362..e0c8cf41ff 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -31,10 +31,10 @@ #include "polygon_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/file_access.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "editor/editor_settings.h" -#include "os/file_access.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/2d/skeleton_2d.h" Node2D *Polygon2DEditor::_get_node() const { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index c6e8ec1a2b..da6aa48f9c 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "resource_preloader_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/project_settings.h" #include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { } diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index af3c09afc5..aac58507f2 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* root_motion_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "root_motion_editor_plugin.h" #include "editor/editor_node.h" #include "scene/main/viewport.h" diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h index 84af47872f..2b5492350b 100644 --- a/editor/plugins/root_motion_editor_plugin.h +++ b/editor/plugins/root_motion_editor_plugin.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* root_motion_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 ROOT_MOTION_EDITOR_PLUGIN_H #define ROOT_MOTION_EDITOR_PLUGIN_H diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1bb7c98114..f25ca4786e 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -504,6 +504,13 @@ void ScriptEditor::_open_recent_script(int p_idx) { return; } // if it's a path then its most likely a deleted file not help + } else if (path.find("::") != -1) { + // built-in script + Ref<Script> script = ResourceLoader::load(path); + if (script.is_valid()) { + edit(script, true); + return; + } } else if (!path.is_resource_file()) { _help_class_open(path); return; @@ -862,7 +869,7 @@ void ScriptEditor::_file_dialog_action(String p_file) { if (extensions.find(p_file.get_extension())) { Ref<Script> scr = ResourceLoader::load(p_file); if (!scr.is_valid()) { - editor->show_warning(TTR("Error could not load file."), TTR("Error!")); + editor->show_warning(TTR("Error: could not load file."), TTR("Error!")); file_dialog_option = -1; return; } @@ -939,7 +946,7 @@ void ScriptEditor::_menu_option(int p_option) { switch (p_option) { case FILE_NEW: { - script_create_dialog->config("Node", ".gd"); + script_create_dialog->config("Node", "new_script"); script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE); } break; case FILE_NEW_TEXTFILE: { @@ -1692,7 +1699,6 @@ void ScriptEditor::_update_script_names() { if (restoring_layout) return; - waiting_update_names = false; Set<Ref<Script> > used; Node *edited = EditorNode::get_singleton()->get_edited_scene(); if (edited) { @@ -1743,7 +1749,7 @@ void ScriptEditor::_update_script_names() { } break; case DISPLAY_DIR_AND_NAME: { if (!path.get_base_dir().get_file().empty()) { - sd.name = path.get_base_dir().get_file() + "/" + name; + sd.name = path.get_base_dir().get_file().plus_file(name); } else { sd.name = name; } @@ -1794,8 +1800,8 @@ void ScriptEditor::_update_script_names() { new_cur_tab = i; } } - tab_container->call_deferred("set_current_tab", new_prev_tab); - tab_container->call_deferred("set_current_tab", new_cur_tab); + tab_container->set_current_tab(new_prev_tab); + tab_container->set_current_tab(new_cur_tab); _sort_list_on_update = false; } @@ -1816,8 +1822,12 @@ void ScriptEditor::_update_script_names() { } } - _update_members_overview(); - _update_help_overview(); + if (!waiting_update_names) { + _update_members_overview(); + _update_help_overview(); + } else { + waiting_update_names = false; + } _update_members_overview_visibility(); _update_help_overview_visibility(); _update_script_colors(); @@ -2014,6 +2024,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra _go_to_tab(tab_container->get_tab_count() - 1); } + _sort_list_on_update = true; _update_script_names(); _save_layout(); se->connect("name_changed", this, "_update_script_names"); @@ -2103,8 +2114,6 @@ void ScriptEditor::_editor_play() { debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true); debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false); debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true); - - //debugger_gui->start_listening(Globals::get_singleton()->get("debug/debug_port")); } void ScriptEditor::_editor_pause() { @@ -2588,6 +2597,7 @@ void ScriptEditor::_help_class_open(const String &p_class) { eh->go_to_class(p_class, 0); eh->connect("go_to_help", this, "_help_class_goto"); _add_recent_script(p_class); + _sort_list_on_update = true; _update_script_names(); _save_layout(); } @@ -2617,6 +2627,7 @@ void ScriptEditor::_help_class_goto(const String &p_desc) { eh->go_to_help(p_desc); eh->connect("go_to_help", this, "_help_class_goto"); _add_recent_script(eh->get_class()); + _sort_list_on_update = true; _update_script_names(); _save_layout(); } diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 737f17358b..120755b5af 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -31,6 +31,7 @@ #ifndef SCRIPT_EDITOR_PLUGIN_H #define SCRIPT_EDITOR_PLUGIN_H +#include "core/script_language.h" #include "editor/code_editor.h" #include "editor/editor_help.h" #include "editor/editor_plugin.h" @@ -44,7 +45,6 @@ #include "scene/gui/tree.h" #include "scene/main/timer.h" #include "scene/resources/text_file.h" -#include "script_language.h" class ScriptEditorQuickOpen : public ConfirmationDialog { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 4e7047ee38..82c2e07940 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -30,10 +30,10 @@ #include "script_text_editor.h" +#include "core/os/keyboard.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/script_editor_debugger.h" -#include "os/keyboard.h" Vector<String> ScriptTextEditor::get_functions() { @@ -1475,9 +1475,9 @@ ScriptTextEditor::ScriptTextEditor() { convert_case->set_name("convert_case"); edit_menu->get_popup()->add_child(convert_case); edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case"); - convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE); - convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE); - convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE); + convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase"), KEY_MASK_SHIFT | KEY_F4), EDIT_TO_UPPERCASE); + convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase"), KEY_MASK_SHIFT | KEY_F5), EDIT_TO_LOWERCASE); + convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F6), EDIT_CAPITALIZE); convert_case->connect("id_pressed", this, "_edit_option"); highlighters["Standard"] = NULL; @@ -1549,10 +1549,11 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), 0); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_C); + ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL | KEY_SPACE); #else ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_B); -#endif ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD | KEY_SPACE); +#endif ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CMD | KEY_MASK_ALT | KEY_T); ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent To Spaces"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Y); ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent To Tabs"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X); @@ -1567,23 +1568,24 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/goto_next_breakpoint", TTR("Goto Next Breakpoint"), KEY_MASK_CMD | KEY_PERIOD); ED_SHORTCUT("script_text_editor/goto_previous_breakpoint", TTR("Goto Previous Breakpoint"), KEY_MASK_CMD | KEY_COMMA); - ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Convert To Uppercase"), KEY_MASK_SHIFT | KEY_F4); - ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Convert To Lowercase"), KEY_MASK_SHIFT | KEY_F3); - ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F2); - ED_SHORTCUT("script_text_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_MASK_CMD | KEY_G); ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_G); + ED_SHORTCUT("script_text_editor/replace", TTR("Replace..."), KEY_MASK_ALT | KEY_MASK_CMD | KEY_F); #else ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_F3); ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3); -#endif ED_SHORTCUT("script_text_editor/replace", TTR("Replace..."), KEY_MASK_CMD | KEY_R); +#endif ED_SHORTCUT("script_text_editor/find_in_files", TTR("Find in files..."), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F); +#ifdef OSX_ENABLED + ED_SHORTCUT("script_text_editor/goto_function", TTR("Goto Function..."), KEY_MASK_CTRL | KEY_MASK_CMD | KEY_J); +#else ED_SHORTCUT("script_text_editor/goto_function", TTR("Goto Function..."), KEY_MASK_ALT | KEY_MASK_CMD | KEY_F); +#endif ED_SHORTCUT("script_text_editor/goto_line", TTR("Goto Line..."), KEY_MASK_CMD | KEY_L); #ifdef OSX_ENABLED diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp index 314db4198d..50deb80668 100644 --- a/editor/plugins/skeleton_editor_plugin.cpp +++ b/editor/plugins/skeleton_editor_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/skeleton_editor_plugin.h b/editor/plugins/skeleton_editor_plugin.h index 0ab94c15b5..aac3e06063 100644 --- a/editor/plugins/skeleton_editor_plugin.h +++ b/editor/plugins/skeleton_editor_plugin.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_editor_plugin.cpp index 2d343d3edd..c605548a6b 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_editor_plugin.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/skeleton_ik_editor_plugin.h b/editor/plugins/skeleton_ik_editor_plugin.h index e645bea39a..3e412305c9 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.h +++ b/editor/plugins/skeleton_ik_editor_plugin.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* skeleton_ik_editor_plugin.h */ +/* skeleton_ik_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 */ diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 906c51b9f6..e86424ee51 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -30,23 +30,25 @@ #include "spatial_editor_plugin.h" -#include "camera_matrix.h" +#include "core/math/camera_matrix.h" #include "core/os/input.h" - +#include "core/os/keyboard.h" +#include "core/print_string.h" +#include "core/project_settings.h" +#include "core/sort.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/script_editor_debugger.h" #include "editor/spatial_editor_gizmos.h" -#include "os/keyboard.h" -#include "print_string.h" -#include "project_settings.h" #include "scene/3d/camera.h" +#include "scene/3d/collision_shape.h" +#include "scene/3d/mesh_instance.h" +#include "scene/3d/physics_body.h" #include "scene/3d/visual_instance.h" #include "scene/resources/packed_scene.h" #include "scene/resources/surface_tool.h" -#include "sort.h" #define DISTANCE_DEFAULT 4 @@ -274,7 +276,7 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) { _select(sp, clicked_wants_append, true); } -void SpatialEditorViewport::_select(Spatial *p_node, bool p_append, bool p_single) { +void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { if (!p_append) { editor_selection->clear(); @@ -307,7 +309,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, Node *edited_scene = get_tree()->get_edited_scene_root(); ObjectID closest = 0; - Spatial *item = NULL; + Node *item = NULL; float closest_dist = 1e20; int selected_handle = -1; @@ -340,20 +342,15 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, continue; if (dist < closest_dist) { - //make sure that whathever is selected is editable - while (spat && spat != edited_scene && spat->get_owner() != edited_scene && !edited_scene->is_editable_instance(spat->get_owner())) { - spat = Object::cast_to<Spatial>(spat->get_owner()); + item = Object::cast_to<Node>(spat); + while (item->get_owner() && item->get_owner() != edited_scene && !edited_scene->is_editable_instance(item->get_owner())) { + item = item->get_owner(); } - if (spat) { - item = spat; - closest = spat->get_instance_id(); - closest_dist = dist; - selected_handle = handle; - } else { - ERR_PRINT("Bug?"); - } + closest = item->get_instance_id(); + closest_dist = dist; + selected_handle = handle; } } @@ -499,7 +496,7 @@ void SpatialEditorViewport::_select_region() { } Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); - Vector<Spatial *> selected; + Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -509,12 +506,12 @@ void SpatialEditorViewport::_select_region() { if (!sp) continue; - Spatial *root_sp = sp; - while (root_sp && root_sp != edited_scene && root_sp->get_owner() != edited_scene && !edited_scene->is_editable_instance(root_sp->get_owner())) { - root_sp = Object::cast_to<Spatial>(root_sp->get_owner()); + Node *item = Object::cast_to<Node>(sp); + while (item->get_owner() && item->get_owner() != edited_scene && !edited_scene->is_editable_instance(item->get_owner())) { + item = item->get_owner(); } - if (selected.find(root_sp) != -1) continue; + if (selected.find(item) != -1) continue; Ref<EditorSpatialGizmo> seg = sp->get_gizmo(); @@ -522,7 +519,7 @@ void SpatialEditorViewport::_select_region() { continue; if (seg->intersect_frustum(camera, frustum)) { - selected.push_back(root_sp); + selected.push_back(item); } } @@ -3914,8 +3911,9 @@ void _update_all_gizmos(Node *p_node) { } } -void SpatialEditor::update_all_gizmos() { - _update_all_gizmos(SceneTree::get_singleton()->get_root()); +void SpatialEditor::update_all_gizmos(Node *p_node) { + if (!p_node) p_node = SceneTree::get_singleton()->get_root(); + _update_all_gizmos(p_node); } Object *SpatialEditor::_get_editor_data(Object *p_what) { @@ -4468,6 +4466,7 @@ void SpatialEditor::_init_indicators() { VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF); + origin_enabled = true; grid_enabled = true; last_grid_snap = 1; } @@ -5381,7 +5380,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { ED_SHORTCUT("spatial_editor/tool_move", TTR("Tool Move"), KEY_W); ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Tool Rotate"), KEY_E); ED_SHORTCUT("spatial_editor/tool_scale", TTR("Tool Scale"), KEY_R); - ED_SHORTCUT("spatial_editor/snap_to_floor", TTR("Snap To Floor"), KEY_PAGEDOWN); ED_SHORTCUT("spatial_editor/freelook_toggle", TTR("Toggle Freelook"), KEY_MASK_SHIFT + KEY_F); @@ -5392,7 +5390,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { hbc_menu->add_child(transform_menu); p = transform_menu->get_popup(); - p->add_shortcut(ED_SHORTCUT("spatial_editor/snap_to_floor", TTR("Snap object to floor")), MENU_SNAP_TO_FLOOR); + p->add_shortcut(ED_SHORTCUT("spatial_editor/snap_to_floor", TTR("Snap object to floor"), KEY_PAGEDOWN), MENU_SNAP_TO_FLOOR); p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap...")), MENU_TRANSFORM_CONFIGURE_SNAP); p->add_separator(); p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog...")), MENU_TRANSFORM_DIALOG); @@ -5664,7 +5662,7 @@ SpatialEditorPlugin::~SpatialEditorPlugin() { void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { - Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.5)); + Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); Vector<Ref<SpatialMaterial> > mats; @@ -5706,7 +5704,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) { - Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.5)); + Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); Vector<Ref<SpatialMaterial> > icons; @@ -5719,7 +5717,7 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Color color = instanced ? instanced_color : p_albedo; if (!selected) { - color.a *= 0.3; + color.a *= 0.85; } icon->set_albedo(color); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 5850c0dbf1..0e35ba8517 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -127,9 +127,7 @@ public: virtual void redraw(); virtual void free(); - //TODO remove (?) virtual bool is_editable() const; - virtual bool can_draw() const; void set_hidden(bool p_hidden); void set_plugin(EditorSpatialGizmoPlugin *p_gizmo); @@ -226,7 +224,7 @@ private: void _compute_edit(const Point2 &p_point); void _clear_selected(); void _select_clicked(bool p_append, bool p_single); - void _select(Spatial *p_node, bool p_append, bool p_single); + void _select(Node *p_node, bool p_append, bool p_single); ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false); void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false); Vector3 _get_ray_pos(const Vector2 &p_pos) const; @@ -677,7 +675,7 @@ public: Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; } void update_transform_gizmo(); - void update_all_gizmos(); + void update_all_gizmos(Node *p_node = NULL); void snap_selected_nodes_to_floor(); void select_gizmo_highlight_axis(int p_axis); void set_custom_camera(Node *p_camera) { custom_camera = p_camera; } diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index fcbbee2b9c..30246147c2 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "sprite_frames_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/project_settings.h" #include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" #include "scene/3d/sprite_3d.h" void SpriteFramesEditor::_gui_input(Ref<InputEvent> p_event) { diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index e891850870..140d37fdb5 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "texture_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/project_settings.h" #include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "project_settings.h" void TextureEditor::_gui_input(Ref<InputEvent> p_event) { } diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 4a9cbfe535..33e1f7c6a3 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -31,8 +31,8 @@ #include "texture_region_editor_plugin.h" #include "core/core_string_names.h" -#include "os/input.h" -#include "os/keyboard.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "scene/gui/check_box.h" /** @@ -356,8 +356,6 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { undo_redo->add_do_method(atlas_tex.ptr(), "set_region", atlas_tex->get_region()); undo_redo->add_undo_method(atlas_tex.ptr(), "set_region", rect_prev); } else if (node_ninepatch) { - // FIXME: Is this intentional? - } else if (node_ninepatch) { undo_redo->add_do_method(node_ninepatch, "set_region_rect", node_ninepatch->get_region_rect()); undo_redo->add_undo_method(node_ninepatch, "set_region_rect", rect_prev); } else if (obj_styleBox.is_valid()) { @@ -521,6 +519,10 @@ void TextureRegionEditor::_set_snap_mode(int p_mode) { else hb_grid->hide(); + if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) { + _update_autoslice(); + } + edit_draw->update(); } @@ -562,7 +564,8 @@ void TextureRegionEditor::_zoom_in() { } void TextureRegionEditor::_zoom_reset() { - if (draw_zoom == 1) return; + if (draw_zoom == 1) + return; draw_zoom = 1; edit_draw->update(); } @@ -585,25 +588,91 @@ void TextureRegionEditor::apply_rect(const Rect2 &rect) { atlas_tex->set_region(rect); } -void TextureRegionEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_PROCESS: { - if (node_sprite) { - if (node_sprite->is_region()) { +void TextureRegionEditor::_update_autoslice() { + autoslice_is_dirty = false; + autoslice_cache.clear(); - set_process(false); - EditorNode::get_singleton()->make_bottom_panel_item_visible(this); + Ref<Texture> texture = NULL; + if (node_sprite) + texture = node_sprite->get_texture(); + else if (node_ninepatch) + texture = node_ninepatch->get_texture(); + else if (obj_styleBox.is_valid()) + texture = obj_styleBox->get_texture(); + else if (atlas_tex.is_valid()) + texture = atlas_tex->get_atlas(); + + if (texture.is_null()) { + return; + } + + for (int y = 0; y < texture->get_height(); y++) { + for (int x = 0; x < texture->get_width(); x++) { + if (texture->is_pixel_opaque(x, y)) { + bool found = false; + for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { + Rect2 grown = E->get().grow(1.5); + if (grown.has_point(Point2(x, y))) { + E->get().expand_to(Point2(x, y)); + E->get().expand_to(Point2(x + 1, y + 1)); + x = E->get().position.x + E->get().size.x - 1; + bool merged = true; + while (merged) { + merged = false; + bool queue_erase = false; + for (List<Rect2>::Element *F = autoslice_cache.front(); F; F = F->next()) { + if (queue_erase) { + autoslice_cache.erase(F->prev()); + queue_erase = false; + } + if (F == E) + continue; + if (E->get().grow(1).intersects(F->get())) { + E->get().expand_to(F->get().position); + E->get().expand_to(F->get().position + F->get().size); + if (F->prev()) { + F = F->prev(); + autoslice_cache.erase(F->next()); + } else { + queue_erase = true; + // Can't delete the first rect in the list. + } + merged = true; + } + } + } + found = true; + break; + } + } + if (!found) { + Rect2 new_rect(x, y, 1, 1); + autoslice_cache.push_back(new_rect); } - } else { - set_process(false); } - } break; - case NOTIFICATION_THEME_CHANGED: + } + } + cache_map[texture->get_rid()] = autoslice_cache; +} + +void TextureRegionEditor::_notification(int p_what) { + switch (p_what) { case NOTIFICATION_READY: { zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons")); zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons")); zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons")); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) { + _update_autoslice(); + } + } break; + case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + // This happens when the user leaves the Editor and returns, + // he/she could have changed the textures, so the cache is cleared + cache_map.clear(); + _edit_region(); + } break; } } @@ -709,57 +778,15 @@ void TextureRegionEditor::_edit_region() { return; } - autoslice_cache.clear(); - Ref<Image> i; - i.instance(); - if (i->load(texture->get_path()) == OK) { - BitMap bm; - bm.create_from_image_alpha(i); - for (int y = 0; y < i->get_height(); y++) { - for (int x = 0; x < i->get_width(); x++) { - if (bm.get_bit(Point2(x, y))) { - bool found = false; - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 grown = E->get().grow(1.5); - if (grown.has_point(Point2(x, y))) { - E->get().expand_to(Point2(x, y)); - E->get().expand_to(Point2(x + 1, y + 1)); - x = E->get().position.x + E->get().size.x - 1; - bool merged = true; - while (merged) { - merged = false; - bool queue_erase = false; - for (List<Rect2>::Element *F = autoslice_cache.front(); F; F = F->next()) { - if (queue_erase) { - autoslice_cache.erase(F->prev()); - queue_erase = false; - } - if (F == E) - continue; - if (E->get().grow(1).intersects(F->get())) { - E->get().expand_to(F->get().position); - E->get().expand_to(F->get().position + F->get().size); - if (F->prev()) { - F = F->prev(); - autoslice_cache.erase(F->next()); - } else { - queue_erase = true; - //Can't delete the first rect in the list. - } - merged = true; - } - } - } - found = true; - break; - } - } - if (!found) { - Rect2 new_rect(x, y, 1, 1); - autoslice_cache.push_back(new_rect); - } - } - } + if (cache_map.has(texture->get_rid())) { + autoslice_cache = cache_map[texture->get_rid()]; + autoslice_is_dirty = false; + return; + } else { + if (is_visible() && snap_mode == SNAP_AUTOSLICE) { + _update_autoslice(); + } else { + autoslice_is_dirty = true; } } diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index 670cc86bbb..61ef769f89 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -92,7 +92,9 @@ class TextureRegionEditor : public Control { Rect2 rect_prev; float prev_margin; int edited_margin; + Map<RID, List<Rect2> > cache_map; List<Rect2> autoslice_cache; + bool autoslice_is_dirty; bool drag; bool creating; @@ -110,6 +112,7 @@ class TextureRegionEditor : public Control { void _zoom_reset(); void _zoom_out(); void apply_rect(const Rect2 &rect); + void _update_autoslice(); protected: void _notification(int p_what); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 92b95963f9..acee1a6942 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -30,8 +30,8 @@ #include "theme_editor_plugin.h" -#include "os/file_access.h" -#include "version.h" +#include "core/os/file_access.h" +#include "core/version.h" void ThemeEditor::edit(const Ref<Theme> &p_theme) { diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 34dd36692c..a0adbfccff 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -31,10 +31,10 @@ #include "tile_map_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/gui/split_container.h" void TileMapEditor::_notification(int p_what) { @@ -238,8 +238,8 @@ void TileMapEditor::_create_set_cell_undo(const Vector2 &p_vec, const CellOp &p_ cell_new["transpose"] = p_cell_new.tr; cell_new["auto_coord"] = p_cell_new.ac; - undo_redo->add_undo_method(node, "set_celld", p_vec, cell_old); - undo_redo->add_do_method(node, "set_celld", p_vec, cell_new); + undo_redo->add_undo_method(node, "_set_celld", p_vec, cell_old); + undo_redo->add_do_method(node, "_set_celld", p_vec, cell_new); } void TileMapEditor::_start_undo(const String &p_action) { @@ -457,36 +457,38 @@ void TileMapEditor::_update_palette() { palette->select(0); } - if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE) { + if (sel_tile != TileMap::INVALID_CELL) { + if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE) { - const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile); + const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile); - Vector<Vector2> entries; - for (const Map<Vector2, uint16_t>::Element *E = tiles.front(); E; E = E->next()) { - entries.push_back(E->key()); - } - entries.sort(); + Vector<Vector2> entries; + for (const Map<Vector2, uint16_t>::Element *E = tiles.front(); E; E = E->next()) { + entries.push_back(E->key()); + } + entries.sort(); - Ref<Texture> tex = tileset->tile_get_texture(sel_tile); + Ref<Texture> tex = tileset->tile_get_texture(sel_tile); - for (int i = 0; i < entries.size(); i++) { + for (int i = 0; i < entries.size(); i++) { - manual_palette->add_item(String()); + manual_palette->add_item(String()); - if (tex.is_valid()) { + if (tex.is_valid()) { - Rect2 region = tileset->tile_get_region(sel_tile); - int spacing = tileset->autotile_get_spacing(sel_tile); - region.size = tileset->autotile_get_size(sel_tile); // !! - region.position += (region.size + Vector2(spacing, spacing)) * entries[i]; + Rect2 region = tileset->tile_get_region(sel_tile); + int spacing = tileset->autotile_get_spacing(sel_tile); + region.size = tileset->autotile_get_size(sel_tile); // !! + region.position += (region.size + Vector2(spacing, spacing)) * entries[i]; - if (!region.has_no_area()) - manual_palette->set_item_icon_region(manual_palette->get_item_count() - 1, region); + if (!region.has_no_area()) + manual_palette->set_item_icon_region(manual_palette->get_item_count() - 1, region); - manual_palette->set_item_icon(manual_palette->get_item_count() - 1, tex); - } + manual_palette->set_item_icon(manual_palette->get_item_count() - 1, tex); + } - manual_palette->set_item_metadata(manual_palette->get_item_count() - 1, entries[i]); + manual_palette->set_item_metadata(manual_palette->get_item_count() - 1, entries[i]); + } } } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 55a04a51b3..a6a256f0d6 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -498,7 +498,7 @@ void TileSetEditor::_on_tileset_toolbar_button_pressed(int p_index) { } break; case TOOL_TILESET_REMOVE_TEXTURE: { if (get_current_texture().is_valid()) { - cd->set_text(TTR("Remove Selected Textue and ALL TILES wich uses it?")); + cd->set_text(TTR("Remove selected texture and ALL TILES which use it?")); cd->popup_centered(Size2(300, 60)); } else { err_dialog->set_text(TTR("You haven't selected a texture to remove.")); @@ -581,7 +581,7 @@ void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) { texture_list->select(texture_list->get_item_count() - 1); _on_texture_list_selected(texture_list->get_item_count() - 1); if (invalid_count > 0) { - err_dialog->set_text(String::num(invalid_count, 0) + TTR(" file(s) was not added because was already on the list.")); + err_dialog->set_text(vformat(TTR("%s file(s) were not added because was already on the list."), String::num(invalid_count, 0))); err_dialog->popup_centered(Size2(300, 60)); } } @@ -1715,16 +1715,18 @@ void TileSetEditor::draw_polygon_shapes() { Vector<Vector2> polygon; Vector<Color> colors; + Vector2 anchor = WORKSPACE_MARGIN; + anchor += tileset->tile_get_region(get_current_tile()).position; for (int j = 0; j < shape->get_polygon().size(); j++) { - polygon.push_back(shape->get_polygon()[j]); + polygon.push_back(shape->get_polygon()[j] + anchor); colors.push_back(c_bg); } workspace->draw_polygon(polygon, colors); for (int j = 0; j < shape->get_polygon().size() - 1; j++) { - workspace->draw_line(shape->get_polygon()[j], shape->get_polygon()[j + 1], c_border, 1, true); + workspace->draw_line(shape->get_polygon()[j] + anchor, shape->get_polygon()[j + 1] + anchor, c_border, 1, true); } - workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1], shape->get_polygon()[0], c_border, 1, true); + workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1] + anchor, shape->get_polygon()[0] + anchor, c_border, 1, true); if (shape == edited_occlusion_shape) { draw_handles = true; } @@ -1788,10 +1790,11 @@ void TileSetEditor::draw_polygon_shapes() { Vector<Vector2> polygon; Vector<Color> colors; - + Vector2 anchor = WORKSPACE_MARGIN; + anchor += tileset->tile_get_region(get_current_tile()).position; PoolVector<Vector2> vertices = shape->get_vertices(); for (int j = 0; j < shape->get_polygon(0).size(); j++) { - polygon.push_back(vertices[shape->get_polygon(0)[j]]); + polygon.push_back(vertices[shape->get_polygon(0)[j]] + anchor); colors.push_back(c_bg); } workspace->draw_polygon(polygon, colors); @@ -1799,7 +1802,7 @@ void TileSetEditor::draw_polygon_shapes() { if (shape->get_polygon_count() > 0) { PoolVector<Vector2> vertices = shape->get_vertices(); for (int j = 0; j < shape->get_polygon(0).size() - 1; j++) { - workspace->draw_line(vertices[shape->get_polygon(0)[j]], vertices[shape->get_polygon(0)[j + 1]], c_border, 1, true); + workspace->draw_line(vertices[shape->get_polygon(0)[j]] + anchor, vertices[shape->get_polygon(0)[j + 1]] + anchor, c_border, 1, true); } if (shape == edited_navigation_shape) { draw_handles = true; @@ -1954,6 +1957,8 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) { void TileSetEditor::select_coord(const Vector2 &coord) { current_shape = PoolVector2Array(); + if (get_current_tile() == -1) + return; Rect2 current_tile_region = tileset->tile_get_region(get_current_tile()); current_tile_region.position += WORKSPACE_MARGIN; if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { @@ -2038,8 +2043,10 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) { anchor += tileset->tile_get_region(get_current_tile()).position; anchor += WORKSPACE_MARGIN; Rect2 region(anchor, tile_size); - if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) + if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { region.position = tileset->tile_get_region(get_current_tile()).position + WORKSPACE_MARGIN; + region.size = tileset->tile_get_region(get_current_tile()).size; + } if (tools[TOOL_GRID_SNAP]->is_pressed()) { p.x = Math::snap_scalar_seperation(snap_offset.x, snap_step.x, p.x, snap_separation.x); @@ -2254,6 +2261,9 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value tileset_editor->workspace_overlay->update(); } return v; + } else if (name == "tileset_script") { + tileset->set_script(p_value); + return true; } tileset_editor->err_dialog->set_text(TTR("This property can't be changed.")); @@ -2302,6 +2312,9 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const } else if (name == "selected_occlusion") { r_ret = tileset_editor->edited_occlusion_shape; v = true; + } else if (name == "tileset_script") { + r_ret = tileset->get_script(); + v = true; } return v; } @@ -2346,6 +2359,9 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_OCCLUSION && tileset_editor->edited_occlusion_shape.is_valid()) { p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_occlusion", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_occlusion_shape->get_class())); } + if (!tileset.is_null()) { + p_list->push_back(PropertyInfo(Variant::OBJECT, "tileset_script", PROPERTY_HINT_RESOURCE_TYPE, "Script")); + } } TilesetEditorContext::TilesetEditorContext(TileSetEditor *p_tileset_editor) { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 63e89b78ea..cefed193ca 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1,10 +1,40 @@ +/*************************************************************************/ +/* visual_shader_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 "visual_shader_editor_plugin.h" #include "core/io/resource_loader.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_properties.h" -#include "os/input.h" -#include "os/keyboard.h" #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index f86374ff6b..49a51ede8f 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* visual_shader_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 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 VISUAL_SHADER_EDITOR_PLUGIN_H #define VISUAL_SHADER_EDITOR_PLUGIN_H diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index f735ef97db..29a780961e 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -30,10 +30,10 @@ #include "progress_dialog.h" +#include "core/message_queue.h" +#include "core/os/os.h" #include "editor_scale.h" #include "main/main.h" -#include "message_queue.h" -#include "os/os.h" void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) { diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 019d5d382c..aba89a87ee 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -30,17 +30,17 @@ #include "project_export.h" -#include "compressed_translation.h" +#include "core/compressed_translation.h" +#include "core/io/image_loader.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/dir_access.h" +#include "core/os/file_access.h" +#include "core/os/os.h" +#include "core/project_settings.h" #include "editor_data.h" #include "editor_node.h" #include "editor_settings.h" -#include "io/image_loader.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "os/os.h" -#include "project_settings.h" #include "scene/gui/box_container.h" #include "scene/gui/margin_container.h" #include "scene/gui/scroll_container.h" @@ -723,6 +723,25 @@ void ProjectExportDialog::_open_export_template_manager() { hide(); } +void ProjectExportDialog::_validate_export_path(const String &p_path) { + // Disable export via OK button or Enter key if LineEdit has an empty filename + bool invalid_path = (p_path.get_file().get_basename() == ""); + + // Check if state change before needlessly messing with signals + if (invalid_path && export_project->get_ok()->is_disabled()) + return; + if (!invalid_path && !export_project->get_ok()->is_disabled()) + return; + + if (invalid_path) { + export_project->get_ok()->set_disabled(true); + export_project->get_line_edit()->disconnect("text_entered", export_project, "_file_entered"); + } else { + export_project->get_ok()->set_disabled(false); + export_project->get_line_edit()->connect("text_entered", export_project, "_file_entered"); + } +} + void ProjectExportDialog::_export_project() { Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); @@ -732,12 +751,19 @@ void ProjectExportDialog::_export_project() { export_project->set_access(FileDialog::ACCESS_FILESYSTEM); export_project->clear_filters(); - export_project->set_current_file(default_filename); String extension = platform->get_binary_extension(current); - if (extension != String()) { export_project->add_filter("*." + extension + " ; " + platform->get_name() + " Export"); + export_project->set_current_file(default_filename + "." + extension); + } else { + export_project->set_current_file(default_filename); + } + + // Ensure that signal is connected if previous attempt left it disconnected with _validate_export_path + if (!export_project->get_line_edit()->is_connected("text_entered", export_project, "_file_entered")) { + export_project->get_ok()->set_disabled(false); + export_project->get_line_edit()->connect("text_entered", export_project, "_file_entered"); } export_project->set_mode(FileDialog::MODE_SAVE_FILE); @@ -746,7 +772,7 @@ void ProjectExportDialog::_export_project() { void ProjectExportDialog::_export_project_to_path(const String &p_path) { // Save this name for use in future exports (but drop the file extension) - default_filename = p_path.get_basename().get_file(); + default_filename = p_path.get_file().get_basename(); EditorSettings::get_singleton()->set_project_metadata("export_options", "default_filename", default_filename); Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); @@ -785,11 +811,13 @@ void ProjectExportDialog::_bind_methods() { ClassDB::bind_method("_export_pck_zip", &ProjectExportDialog::_export_pck_zip); ClassDB::bind_method("_export_pck_zip_selected", &ProjectExportDialog::_export_pck_zip_selected); ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager); + ClassDB::bind_method("_validate_export_path", &ProjectExportDialog::_validate_export_path); ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project); ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path); ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed); ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed); } + ProjectExportDialog::ProjectExportDialog() { set_title(TTR("Export")); @@ -942,6 +970,9 @@ ProjectExportDialog::ProjectExportDialog() { get_cancel()->set_text(TTR("Close")); get_ok()->set_text(TTR("Export PCK/Zip")); export_button = add_button(TTR("Export Project"), !OS::get_singleton()->get_swap_ok_cancel(), "export"); + export_button->connect("pressed", this, "_export_project"); + // Disable initially before we select a valid preset + export_button->set_disabled(true); export_pck_zip = memnew(FileDialog); export_pck_zip->add_filter("*.zip ; ZIP File"); @@ -981,7 +1012,7 @@ ProjectExportDialog::ProjectExportDialog() { export_project->set_access(FileDialog::ACCESS_FILESYSTEM); add_child(export_project); export_project->connect("file_selected", this, "_export_project_to_path"); - export_button->connect("pressed", this, "_export_project"); + export_project->get_line_edit()->connect("text_changed", this, "_validate_export_path"); export_debug = memnew(CheckButton); export_debug->set_text(TTR("Export With Debug")); @@ -997,10 +1028,14 @@ ProjectExportDialog::ProjectExportDialog() { editor_icons = "EditorIcons"; - default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", String()); - + default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", ""); + // If no default set, use project name if (default_filename == "") { + // If no project name defined, use a sane default default_filename = ProjectSettings::get_singleton()->get("application/config/name"); + if (default_filename == "") { + default_filename = "UnnamedProject"; + } } } diff --git a/editor/project_export.h b/editor/project_export.h index 1f8723febd..552c6d7faf 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -136,6 +136,7 @@ private: void _export_pck_zip(); void _export_pck_zip_selected(const String &p_path); + void _validate_export_path(const String &p_path); void _export_project(); void _export_project_to_path(const String &p_path); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 3a6a73d3cc..f494c84efa 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -30,18 +30,21 @@ #include "project_manager.h" +#include "core/io/config_file.h" +#include "core/io/resource_saver.h" +#include "core/io/stream_peer_ssl.h" +#include "core/io/zip_io.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/translation.h" +#include "core/version.h" +#include "core/version_hash.gen.h" #include "editor_initialize_ssl.h" #include "editor_scale.h" #include "editor_settings.h" #include "editor_themes.h" -#include "io/config_file.h" -#include "io/resource_saver.h" -#include "io/stream_peer_ssl.h" -#include "io/zip_io.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "os/keyboard.h" -#include "os/os.h" #include "scene/gui/center_container.h" #include "scene/gui/line_edit.h" #include "scene/gui/margin_container.h" @@ -49,9 +52,6 @@ #include "scene/gui/separator.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tool_button.h" -#include "translation.h" -#include "version.h" -#include "version_hash.gen.h" class ProjectDialog : public ConfirmationDialog { @@ -1751,7 +1751,11 @@ ProjectManager::ProjectManager() { } break; } +#ifndef OSX_ENABLED + // The macOS platform implementation uses its own hiDPI window resizing code + // TODO: Resize windows on hiDPI displays on Windows and Linux and remove the line below OS::get_singleton()->set_window_size(OS::get_singleton()->get_window_size() * MAX(1, EDSCALE)); +#endif } FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index a7c336eb16..1baf606e7b 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1750,12 +1750,9 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { globals_editor = memnew(SectionedInspector); props_base->add_child(globals_editor); globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); - globals_editor->get_inspector()->set_property_selectable(true); - //globals_editor->hide_top_label(); globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); globals_editor->register_search_box(search_box); globals_editor->get_inspector()->connect("property_selected", this, "_item_selected"); - //globals_editor->get_inspector()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); globals_editor->get_inspector()->connect("property_edited", this, "_settings_prop_edited"); globals_editor->get_inspector()->connect("restart_requested", this, "_editor_restart_request"); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index d9812f7425..1c2eedfc9c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1910,6 +1910,7 @@ void CustomPropertyEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("variant_field_changed", PropertyInfo(Variant::STRING, "field"))); ADD_SIGNAL(MethodInfo("resource_edit_request")); } + CustomPropertyEditor::CustomPropertyEditor() { read_only = false; @@ -2034,2691 +2035,8 @@ CustomPropertyEditor::CustomPropertyEditor() { property_select = NULL; } -bool PropertyEditor::_might_be_in_instance() { - - if (!obj) - return false; - - Node *node = Object::cast_to<Node>(obj); - - Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); - - bool might_be = false; - - while (node) { - - if (node->get_scene_instance_state().is_valid()) { - might_be = true; - break; - } - if (node == edited_scene) { - if (node->get_scene_inherited_state().is_valid()) { - might_be = true; - break; - } - might_be = false; - break; - } - node = node->get_owner(); - } - - return might_be; -} - -bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_prop, Variant &value) { - - Node *node = Object::cast_to<Node>(obj); - - if (!node) - return false; - - Node *orig = node; - - Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); - - bool found = false; - - while (node) { - - Ref<SceneState> ss; - - if (node == edited_scene) { - ss = node->get_scene_inherited_state(); - - } else { - ss = node->get_scene_instance_state(); - } - - if (ss.is_valid()) { - - NodePath np = node->get_path_to(orig); - int node_idx = ss->find_node_by_path(np); - if (node_idx >= 0) { - bool lfound = false; - Variant lvar; - lvar = ss->get_property_value(node_idx, p_prop, lfound); - if (lfound) { - - found = true; - value = lvar; - } - } - } - if (node == edited_scene) { - //just in case - break; - } - node = node->get_owner(); - } - - return found; -} - -bool PropertyEditor::_is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage) { - - { - Node *node = Object::cast_to<Node>(obj); - if (!node) - return false; - - Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); - bool found_state = false; - - while (node) { - - Ref<SceneState> ss; - - if (node == edited_scene) { - ss = node->get_scene_inherited_state(); - - } else { - ss = node->get_scene_instance_state(); - } - - if (ss.is_valid()) { - found_state = true; - } - if (node == edited_scene) { - //just in case - break; - } - node = node->get_owner(); - } - - if (!found_state) - return false; //pointless to check if we are not comparing against anything. - } - - if (p_orig.get_type() == Variant::NIL) { - - //special cases - if (p_current.is_zero() && p_usage & PROPERTY_USAGE_STORE_IF_NONZERO) - return false; - if (p_current.is_one() && p_usage & PROPERTY_USAGE_STORE_IF_NONONE) - return false; - } - - if (p_current.get_type() == Variant::REAL && p_orig.get_type() == Variant::REAL) { - float a = p_current; - float b = p_orig; - - return Math::abs(a - b) > CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error - } - - return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig)); -} - -bool PropertyEditor::_is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item) { - bool mbi = _might_be_in_instance(); - if (mbi) { - Variant vorig; - Dictionary d = 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(p_name, vorig) || usage) { - Variant v = obj->get(p_name); - - if (_is_property_different(v, vorig, usage)) { - return true; - } - } - } - return false; -} - -TreeItem *PropertyEditor::find_item(TreeItem *p_item, const String &p_name) { - - if (!p_item) - return NULL; - - String name = p_item->get_metadata(1); - - if (name == p_name) { - - return p_item; - } - - TreeItem *c = p_item->get_children(); - - while (c) { - - TreeItem *found = find_item(c, p_name); - if (found) - return found; - c = c->get_next(); - } - - return NULL; -} - -void PropertyEditor::_changed_callback(Object *p_changed, const char *p_prop) { - - _changed_callbacks(p_changed, p_prop); -} - -void PropertyEditor::_changed_callbacks(Object *p_changed, const String &p_prop) { - - if (p_changed != obj) - return; - - if (changing) - return; - - if (p_prop == String()) - update_tree_pending = true; - else { - - pending[p_prop] = p_prop; - } -} - -void PropertyEditor::update_property(const String &p_prop) { - - if (obj) - _changed_callbacks(obj, p_prop); -} - -void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p_name, int p_hint, const String &p_hint_text) { - - switch (p_type) { - - case Variant::BOOL: { - - p_item->set_checked(1, obj->get(p_name)); - } break; - case Variant::REAL: - case Variant::INT: { - - if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_3D_RENDER) { - tree->update(); - break; - } - - if (p_hint == PROPERTY_HINT_FLAGS) { - Vector<String> values = p_hint_text.split(","); - String flags; - int val = obj->get(p_name); - for (int i = 0; i < values.size(); i++) { - - String v = values[i]; - if (v == "") - continue; - if (!(val & (1 << i))) - continue; - - if (flags != "") - flags += ", "; - flags += v; - } - p_item->set_text(1, flags); - break; - } - - if (p_hint == PROPERTY_HINT_EXP_EASING) { - - p_item->set_text(1, String::num(obj->get(p_name), 2)); - break; - } - - if (p_type == Variant::REAL) { - p_item->set_range(1, obj->get(p_name)); - - } else { - /* FIXME: Why are both statements equal? */ - p_item->set_range(1, obj->get(p_name)); - } - - p_item->set_editable(1, !read_only); - - } break; - case Variant::STRING: - - if (p_hint == PROPERTY_HINT_TYPE_STRING) { - - p_item->set_text(1, obj->get(p_name)); - } - - if (p_hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE || - p_hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE || - p_hint == PROPERTY_HINT_METHOD_OF_INSTANCE || - p_hint == PROPERTY_HINT_METHOD_OF_SCRIPT || - p_hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE || - p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE || - p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE || - p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) { - - p_item->set_text(1, obj->get(p_name)); - } - - if (p_hint == PROPERTY_HINT_ENUM) { - - Vector<String> strings = p_hint_text.split(","); - String current = obj->get(p_name); - int idx = 0; - for (int x = 0; x < strings.size(); x++) { - if (strings[x] == current) { - idx = x; - break; - } - } - p_item->set_text(1, p_hint_text); - p_item->set_range(1, idx); - break; - } - - case Variant::VECTOR3: - case Variant::QUAT: - case Variant::VECTOR2: - case Variant::AABB: - case Variant::RECT2: - case Variant::TRANSFORM2D: - case Variant::BASIS: - case Variant::TRANSFORM: { - - p_item->set_text(1, obj->get(p_name)); - - } break; - case Variant::COLOR: { - - tree->update(); - - } break; - case Variant::NODE_PATH: { - - p_item->set_text(1, obj->get(p_name)); - } break; - case Variant::OBJECT: { - - Ref<EncodedObjectAsID> encoded = obj->get(p_name); //for debugger and remote tools - - if (encoded.is_valid()) { - - p_item->set_text(1, "Object: " + itos(encoded->get_object_id())); - p_item->set_icon(1, Ref<Texture>()); - p_item->set_custom_as_button(1, true); - - } else if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) { - p_item->set_text(1, "<null>"); - p_item->set_icon(1, Ref<Texture>()); - p_item->set_custom_as_button(1, false); - - Dictionary d = p_item->get_metadata(0); - int hint = d.has("hint") ? d["hint"].operator int() : -1; - String hint_text = d.has("hint_text") ? d["hint_text"] : ""; - if (hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Texture") { - p_item->set_icon(1, NULL); - } - - } else { - p_item->set_custom_as_button(1, true); - RES res = obj->get(p_name).operator RefPtr(); - if (res->is_class("Texture")) { - int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); - Vector2 size(res->call("get_width"), res->call("get_height")); - if (size.width < size.height) { - tw = MAX((size.width / size.height) * tw, 1); - } - p_item->set_icon_max_width(1, tw); - p_item->set_icon(1, res); - p_item->set_text(1, ""); - - } else if (res->get_name() != "") { - - p_item->set_text(1, res->get_name()); - } else if (res->get_path() != "" && !res->get_path().begins_with("local://")) { - p_item->set_text(1, res->get_path().get_file()); - } else { - p_item->set_text(1, "<" + res->get_class() + ">"); - }; - - if (res.is_valid() && res->get_path().is_resource_file()) { - p_item->set_tooltip(1, res->get_path()); - } else if (res.is_valid()) { - p_item->set_tooltip(1, res->get_name() + " (" + res->get_class() + ")"); - } - - if (has_icon(res->get_class(), "EditorIcons")) { - - p_item->set_icon(0, get_icon(res->get_class(), "EditorIcons")); - } else { - - Dictionary d = p_item->get_metadata(0); - int hint = d.has("hint") ? d["hint"].operator int() : -1; - String hint_text = d.has("hint_text") ? d["hint_text"] : ""; - if (hint == PROPERTY_HINT_RESOURCE_TYPE) { - - if (has_icon(hint_text, "EditorIcons")) { - - p_item->set_icon(0, get_icon(hint_text, "EditorIcons")); - - } else { - p_item->set_icon(0, get_icon("Object", "EditorIcons")); - } - } - } - - if (res->is_class("Script")) { - p_item->set_text(1, res->get_path().get_file()); - } else if (!res->is_class("Texture")) { - //texture already previews via itself - EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", p_item->get_instance_id()); - } - } - - } break; - default: {}; - } -} - -void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) { - - bool has_reload = false; - int found = -1; - bool is_disabled = false; - - for (int i = 0; i < item->get_button_count(1); i++) { - - if (item->get_button_id(1, i) == 3) { - found = i; - is_disabled = item->is_button_disabled(1, i); - break; - } - } - - if (_is_instanced_node_with_original_property_different(p_name, item)) { - has_reload = true; - } - - if (obj->call("property_can_revert", p_name).operator bool()) { - - has_reload = true; - } - - if (!has_reload && !obj->get_script().is_null()) { - Ref<Script> scr = obj->get_script(); - Variant orig_value; - if (scr->get_property_default_value(p_name, orig_value)) { - if (orig_value != obj->get(p_name)) { - has_reload = true; - } - } - } - - if (found != -1 && !has_reload) { - - if (!is_disabled) { - item->erase_button(1, found); - if (item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { - item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true); - } - } - } else if (found == -1 && has_reload) { - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - } else if (found != -1 && has_reload && is_disabled) { - item->erase_button(1, found); - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - } -} - -bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const { - - Dictionary d = p_item_data; - - if (d.has("type")) { - - int type = d["type"]; - if (type == Variant::OBJECT && d.has("hint") && d.has("hint_text") && int(d["hint"]) == PROPERTY_HINT_RESOURCE_TYPE) { - - String allowed_type = d["hint_text"]; - - 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(); - if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) { - return true; - } - } - } - - if (drag_data.has("type") && String(drag_data["type"]) == "files") { - - Vector<String> files = drag_data["files"]; - - if (files.size() == 1) { - String file = files[0]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); - - if (ftype != "") { - - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { - String at = allowed_type.get_slice(",", i).strip_edges(); - if (ClassDB::is_parent_class(ftype, at)) { - return true; - } - } - } - } - } - } - } - - return false; -} -void PropertyEditor::_mark_drop_fields(TreeItem *p_at) { - - if (_is_drop_valid(get_viewport()->gui_get_drag_data(), p_at->get_metadata(0))) - p_at->set_custom_bg_color(1, get_color("accent_color", "Editor"), true); - - if (p_at->get_children()) { - _mark_drop_fields(p_at->get_children()); - } - - if (p_at->get_next()) { - _mark_drop_fields(p_at->get_next()); - } -} - -Variant PropertyEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - - TreeItem *item = tree->get_item_at_position(p_point); - if (!item) - return Variant(); - - Dictionary d = item->get_metadata(0); - if (!d.has("name")) - return Variant(); - - int col = tree->get_column_at_position(p_point); - if (col == 0) { - - Dictionary dp; - dp["type"] = "obj_property"; - dp["object"] = obj; - dp["property"] = d["name"]; - dp["value"] = obj->get(d["name"]); - - Label *label = memnew(Label); - label->set_text(d["name"]); - set_drag_preview(label); - return dp; - } - - Variant val = obj->get(d["name"]); - - if (val.get_type() == Variant::OBJECT) { - RES res = val; - if (res.is_valid()) { - - custom_editor->hide_menu(); - return EditorNode::get_singleton()->drag_resource(res, p_from); - } - } - - return Variant(); -} - -bool PropertyEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - - TreeItem *item = tree->get_item_at_position(p_point); - if (!item) - return false; - - int col = tree->get_column_at_position(p_point); - if (col != 1) - return false; - - return _is_drop_valid(p_data, item->get_metadata(0)); -} -void PropertyEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - - TreeItem *item = tree->get_item_at_position(p_point); - if (!item) - return; - - int col = tree->get_column_at_position(p_point); - if (col != 1) - return; - - if (!_is_drop_valid(p_data, item->get_metadata(0))) - return; - - Dictionary d = item->get_metadata(0); - - if (!d.has("name")) - return; - - String name = d["name"]; - - Dictionary drag_data = p_data; - if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - Ref<Resource> res = drag_data["resource"]; - if (res.is_valid()) { - _edit_set(name, res); - return; - } - } - - if (drag_data.has("type") && String(drag_data["type"]) == "files") { - - Vector<String> files = drag_data["files"]; - - if (files.size() == 1) { - String file = files[0]; - RES res = ResourceLoader::load(file); - if (res.is_valid()) { - _edit_set(name, res); - return; - } - } - } -} - -void PropertyEditor::_clear_drop_fields(TreeItem *p_at) { - - Dictionary d = p_at->get_metadata(0); - - if (d.has("type")) { - - int type = d["type"]; - if (type == Variant::OBJECT) { - p_at->clear_custom_bg_color(1); - } - } - - if (p_at->get_children()) { - _clear_drop_fields(p_at->get_children()); - } - - if (p_at->get_next()) { - _clear_drop_fields(p_at->get_next()); - } -} - -void PropertyEditor::_notification(int p_what) { - - if (p_what == NOTIFICATION_ENTER_TREE) { - - get_tree()->connect("node_removed", this, "_node_removed"); - } - if (p_what == NOTIFICATION_EXIT_TREE) { - - get_tree()->disconnect("node_removed", this, "_node_removed"); - edit(NULL); - } - - if (p_what == NOTIFICATION_DRAG_BEGIN) { - - if (is_visible_in_tree() && tree->get_root()) { - _mark_drop_fields(tree->get_root()); - } - } - - if (p_what == NOTIFICATION_DRAG_END) { - if (is_visible_in_tree() && tree->get_root()) { - _clear_drop_fields(tree->get_root()); - } - } - - if (p_what == NOTIFICATION_PHYSICS_PROCESS) { - - if (refresh_countdown > 0) { - refresh_countdown -= get_physics_process_delta_time(); - if (refresh_countdown <= 0) { - TreeItem *root = tree->get_root(); - _refresh_item(root); - } - } - - changing = true; - - if (update_tree_pending) { - - update_tree(); - update_tree_pending = false; - - } else { - - const String *k = NULL; - while ((k = pending.next(k))) { - - TreeItem *item = find_item(tree->get_root(), *k); - if (!item) - continue; - - _check_reload_status(*k, item); - - Dictionary d = item->get_metadata(0); - set_item_text(item, d["type"], d["name"], d["hint"], d["hint_text"]); - } - } - - pending.clear(); - - changing = false; - } - - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - update_tree(); - } -} - -TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root, TreeItem *category) { - - TreeItem *item = NULL; - - if (p_path == "") { - - item = category ? category : root; - } else if (item_paths.has(p_path)) { - - item = item_paths.get(p_path); - } else { - - TreeItem *parent = get_parent_node(p_path.left(p_path.find_last("/")), item_paths, root, NULL); - item = tree->create_item(parent); - - String name = (p_path.find("/") != -1) ? p_path.right(p_path.find_last("/") + 1) : p_path; - item->set_text(0, capitalize_paths ? name.capitalize() : name); - item->set_tooltip(0, p_path); - if (item->get_parent() != root) { - item->set_icon(0, get_icon("Folder", "EditorIcons")); - } - - item->set_editable(0, false); - if (!subsection_selectable) { - item->set_expand_right(0, true); - } - item->set_selectable(0, subsection_selectable); - item->set_editable(1, false); - item->set_selectable(1, subsection_selectable); - - if (use_folding) { - if (!obj->editor_is_section_unfolded(p_path)) { - updating_folding = true; - item->set_collapsed(true); - updating_folding = false; - } - item->set_metadata(0, p_path); - foldable_property_cache.push_back(p_path); - } - - if (item->get_parent() == root) { - - item->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); - item->set_custom_bg_color(1, get_color("prop_subsection", "Editor")); - } - - item_paths[p_path] = item; - } - - return item; -} - -void PropertyEditor::_refresh_item(TreeItem *p_item) { - - if (!p_item) - return; - - String name = p_item->get_metadata(1); - - if (name != String()) { - - _check_reload_status(name, p_item); - Dictionary d = p_item->get_metadata(0); - set_item_text(p_item, d["type"], d["name"], d["hint"], d["hint_text"]); - } - - TreeItem *c = p_item->get_children(); - - while (c) { - - _refresh_item(c); - - c = c->get_next(); - } -} - -void PropertyEditor::refresh() { - - if (refresh_countdown > 0) - return; - refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"); -} - -void PropertyEditor::update_tree() { - - tree->clear(); - foldable_property_cache.clear(); - - if (!obj) - return; - - HashMap<String, TreeItem *> item_path; - - TreeItem *root = tree->create_item(NULL); - tree->set_hide_root(true); - - List<PropertyInfo> plist; - obj->get_property_list(&plist, true); - - bool draw_red = false; - - { - Node *nod = Object::cast_to<Node>(obj); - Node *es = EditorNode::get_singleton()->get_edited_scene(); - if (nod && es != nod && nod->get_owner() != es) { - draw_red = true; - } - } - - Color sscolor = get_color("prop_subsection", "Editor"); - - TreeItem *current_category = NULL; - - String filter = search_box ? search_box->get_text() : ""; - String group; - String group_base; - - for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) { - - PropertyInfo &p = I->get(); - - //make sure the property can be edited - - if (p.usage & PROPERTY_USAGE_GROUP) { - - group = p.name; - group_base = p.hint_string; - - continue; - - } else if (p.usage & PROPERTY_USAGE_CATEGORY) { - - group = ""; - group_base = ""; - - if (!show_categories) - continue; - - List<PropertyInfo>::Element *N = I->next(); - bool valid = true; - //if no properties in category, skip - while (N) { - if (N->get().usage & PROPERTY_USAGE_EDITOR) - break; - if (N->get().usage & PROPERTY_USAGE_CATEGORY) { - valid = false; - break; - } - N = N->next(); - } - if (!valid) - continue; //empty, ignore - TreeItem *sep = tree->create_item(root); - current_category = sep; - String type = p.name; - - if (has_icon(type, "EditorIcons")) - sep->set_icon(0, get_icon(type, "EditorIcons")); - else - sep->set_icon(0, get_icon("Object", "EditorIcons")); - - sep->set_text(0, type); - sep->set_expand_right(0, true); - sep->set_selectable(0, false); - sep->set_selectable(1, false); - sep->set_custom_bg_color(0, get_color("prop_category", "Editor")); - sep->set_custom_bg_color(1, get_color("prop_category", "Editor")); - sep->set_text_align(0, TreeItem::ALIGN_CENTER); - sep->set_disable_folding(true); - - if (use_doc_hints) { - StringName type = p.name; - if (!class_descr_cache.has(type)) { - - String descr; - DocData *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type); - if (E) { - descr = E->get().brief_description; - } - class_descr_cache[type] = descr.word_wrap(80); - } - - sep->set_tooltip(0, TTR("Class:") + " " + p.name + (class_descr_cache[type] == "" ? "" : "\n\n" + class_descr_cache[type])); - } - continue; - - } else if (!(p.usage & PROPERTY_USAGE_EDITOR)) - continue; - - if (hide_script && p.name == "script") - continue; - - String basename = p.name; - if (group != "") { - if (group_base != "") { - if (basename.begins_with(group_base)) { - basename = basename.replace_first(group_base, ""); - } else if (group_base.begins_with(basename)) { - //keep it, this is used pretty often - } else { - group = ""; //no longer using group base, clear - } - } - } - - if (group != "") { - basename = group + "/" + basename; - } - - String name = (basename.find("/") != -1) ? basename.right(basename.find_last("/") + 1) : basename; - - if (capitalize_paths) { - int dot = name.find("."); - if (dot != -1) { - String ov = name.right(dot); - name = name.substr(0, dot); - name = name.camelcase_to_underscore().capitalize(); - name += ov; - - } else { - name = name.camelcase_to_underscore().capitalize(); - } - } - - String path = basename.left(basename.find_last("/")); - - if (use_filter && filter != "") { - - String cat = path; - - if (capitalize_paths) - cat = cat.capitalize(); - - if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name)) - continue; - } - - TreeItem *parent = get_parent_node(path, item_path, root, current_category); - int level = 0; - if (parent != root) { - level++; - TreeItem *parent_lev = parent; - while (parent_lev->get_parent() != root) { - parent_lev = parent_lev->get_parent(); - level++; - } - } - if (level > 4) - level = 4; - - Color col = sscolor; - col.a = (level / 4.0) * 0.7; - - TreeItem *item = tree->create_item(parent); - - if (level > 0) { - item->set_custom_bg_color(0, col); - } - item->set_editable(0, false); - item->set_selectable(0, property_selectable); - - if (p.usage & PROPERTY_USAGE_CHECKABLE) { - - item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_selectable(0, true); - item->set_editable(0, true); - item->set_checked(0, p.usage & PROPERTY_USAGE_CHECKED); - } - - item->set_text(0, name); - item->set_tooltip(0, p.name); - - if (name.find(".") != -1) { - Color textcol = get_color("font_color", "Tree"); - textcol.a *= 0.5; - //override :D - item->set_custom_color(0, textcol); - item->set_custom_color(1, textcol); - - Color iconcol(1, 1, 1, 0.6); - item->set_icon_color(0, iconcol); - item->set_icon_color(1, iconcol); - } - - if (use_doc_hints) { - - StringName classname = obj->get_class_name(); - StringName propname = p.name; - String descr; - bool found = false; - - Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(classname); - if (E) { - Map<StringName, String>::Element *F = E->get().find(propname); - if (F) { - found = true; - descr = F->get(); - } - } - - if (!found) { - DocData *dd = EditorHelp::get_doc_data(); - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(classname); - while (E && descr == String()) { - for (int i = 0; i < E->get().properties.size(); i++) { - if (E->get().properties[i].name == propname.operator String()) { - descr = E->get().properties[i].description.strip_edges().word_wrap(80); - break; - } - } - if (!E->get().inherits.empty()) { - E = dd->class_list.find(E->get().inherits); - } else { - break; - } - } - descr_cache[classname][propname] = descr; - } - - item->set_tooltip(0, TTR("Property:") + " " + p.name + (descr == "" ? "" : "\n\n" + descr)); - } - - Dictionary d; - d["name"] = p.name; - d["type"] = (int)p.type; - d["hint"] = (int)p.hint; - d["hint_text"] = p.hint_string; - d["usage"] = (int)p.usage; - - item->set_metadata(0, d); - item->set_metadata(1, p.name); - - if (draw_red) - item->set_custom_color(0, get_color("error_color", "Editor")); - - if (p.name == selected_property) { - - item->select(1); - } - - switch (p.type) { - - case Variant::BOOL: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK); - item->set_text(1, TTR("On")); - item->set_tooltip(1, obj->get(p.name) ? "True" : "False"); - item->set_checked(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("bool", "EditorIcons")); - item->set_editable(1, !read_only); - - } break; - case Variant::REAL: - case Variant::INT: { - - if (p.hint == PROPERTY_HINT_EXP_EASING) { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_text(1, String::num(obj->get(p.name), 2)); - item->set_editable(1, !read_only); - if (show_type_icons) - item->set_icon(0, get_icon("Curve", "EditorIcons")); - - break; - } - - if (p.hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p.hint == PROPERTY_HINT_LAYERS_2D_RENDER || p.hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p.hint == PROPERTY_HINT_LAYERS_3D_RENDER) { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - item->set_custom_draw(1, this, "_draw_flags"); - break; - } - - if (p.hint == PROPERTY_HINT_FLAGS) { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - - Vector<String> values = p.hint_string.split(","); - String flags; - int val = obj->get(p.name); - for (int i = 0; i < values.size(); i++) { - - String v = values[i]; - if (v == "") - continue; - if (!(val & (1 << i))) - continue; - - if (flags != "") - flags += ", "; - flags += v; - } - item->set_text(1, flags); - break; - } - - if (p.hint == PROPERTY_HINT_ENUM) - item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); - else - item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE_EXPRESSION); - - if (p.hint == PROPERTY_HINT_SPRITE_FRAME || p.hint == PROPERTY_HINT_RANGE || p.hint == PROPERTY_HINT_EXP_RANGE) { - - int c = p.hint_string.get_slice_count(","); - float min = 0, max = 100, step = p.type == Variant::REAL ? .01 : 1; - if (c >= 1) { - - min = p.hint_string.get_slice(",", 0).to_double(); - } - if (c >= 2) { - - max = p.hint_string.get_slice(",", 1).to_double(); - } - - if (p.hint != PROPERTY_HINT_SPRITE_FRAME && c >= 3) { - - step = p.hint_string.get_slice(",", 2).to_double(); - } - - item->set_range_config(1, min, max, step, p.hint == PROPERTY_HINT_EXP_RANGE); - } else if (p.hint == PROPERTY_HINT_ENUM) { - - item->set_text(1, p.hint_string); - if (show_type_icons) - item->set_icon(0, get_icon("Enum", "EditorIcons")); - item->set_range(1, obj->get(p.name)); - item->set_editable(1, !read_only); - break; - } else if (p.hint == PROPERTY_HINT_OBJECT_ID) { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - - String type = p.hint_string; - if (type == "") - type = "Object"; - - ObjectID id = obj->get(p.name); - if (id != 0) { - item->set_text(1, type + " ID: " + itos(id)); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - } else { - item->set_text(1, TTR("[Empty]")); - } - - if (has_icon(p.hint_string, "EditorIcons")) { - type = p.hint_string; - } else { - type = "Object"; - } - - item->set_icon(0, get_icon(type, "EditorIcons")); - - break; - - } else { - if (p.type == Variant::REAL) { - - item->set_range_config(1, -16777216, 16777216, 0.001); - } else { - - item->set_range_config(1, -2147483647, 2147483647, 1); - } - }; - - if (p.type == Variant::REAL) { - if (show_type_icons) - item->set_icon(0, get_icon("float", "EditorIcons")); - item->set_range(1, obj->get(p.name)); - - } else { - if (show_type_icons) - item->set_icon(0, get_icon("int", "EditorIcons")); - item->set_range(1, obj->get(p.name)); - } - - item->set_editable(1, !read_only); - - } break; - case Variant::STRING: { - - switch (p.hint) { - - case PROPERTY_HINT_DIR: - case PROPERTY_HINT_FILE: - case PROPERTY_HINT_GLOBAL_DIR: - case PROPERTY_HINT_GLOBAL_FILE: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); - item->set_editable(1, !read_only); - if (show_type_icons) - item->set_icon(0, get_icon("File", "EditorIcons")); - item->set_text(1, obj->get(p.name)); - item->add_button(1, get_icon("Folder", "EditorIcons")); - - } break; - case PROPERTY_HINT_ENUM: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); - Vector<String> strings = p.hint_string.split(","); - String current = obj->get(p.name); - int idx = 0; - for (int x = 0; x < strings.size(); x++) { - if (strings[x] == current) { - idx = x; - break; - } - } - item->set_text(1, p.hint_string); - item->set_range(1, idx); - item->set_editable(1, !read_only); - if (show_type_icons) - item->set_icon(0, get_icon("Enum", "EditorIcons")); - - } break; - case PROPERTY_HINT_METHOD_OF_VARIANT_TYPE: ///< a property of a type - case PROPERTY_HINT_METHOD_OF_BASE_TYPE: ///< a method of a base type - case PROPERTY_HINT_METHOD_OF_INSTANCE: ///< a method of an instance - case PROPERTY_HINT_METHOD_OF_SCRIPT: ///< a method of a script & base - case PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE: ///< a property of a type - case PROPERTY_HINT_PROPERTY_OF_BASE_TYPE: ///< a property of a base type - case PROPERTY_HINT_PROPERTY_OF_INSTANCE: ///< a property of an instance - case PROPERTY_HINT_PROPERTY_OF_SCRIPT: ///< a property of a script & base - case PROPERTY_HINT_TYPE_STRING: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - if (show_type_icons) - item->set_icon(0, get_icon("String", "EditorIcons")); - item->set_text(1, obj->get(p.name)); - - } break; - - default: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); - item->set_editable(1, !read_only); - if (show_type_icons) - item->set_icon(0, get_icon("String", "EditorIcons")); - item->set_text(1, obj->get(p.name)); - if (p.hint == PROPERTY_HINT_MULTILINE_TEXT) - item->add_button(1, get_icon("MultiLine", "EditorIcons")); - - } break; - } - - } break; - case Variant::ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - String type_name = "Array"; - String type_name_suffix = ""; - - String hint = p.hint_string; - while (hint.begins_with(itos(Variant::ARRAY) + ":")) { - type_name += "<Array"; - type_name_suffix += ">"; - hint = hint.right(2); - } - if (hint.find(":") >= 0) { - int colon_pos = hint.find(":"); - String hint_string = hint.right(colon_pos + 1); - hint = hint.left(colon_pos); - - PropertyHint property_hint = PROPERTY_HINT_NONE; - - if (hint.find("/") >= 0) { - int slash_pos = hint.find("/"); - property_hint = PropertyHint(hint.right(slash_pos + 1).to_int()); - hint = hint.left(slash_pos); - } - - if (property_hint == PROPERTY_HINT_RESOURCE_TYPE) { - type_name += "<" + hint_string; - } else { - type_name += "<" + Variant::get_type_name(Variant::Type(hint.to_int())); - } - type_name_suffix += ">"; - } - type_name += type_name_suffix; - - if (v.is_array()) - item->set_text(1, type_name + "(" + itos(v.call("size")) + ")"); - else - item->set_text(1, type_name + "()"); - - if (show_type_icons) - item->set_icon(0, get_icon("PoolByteArray", "EditorIcons")); - - } break; - case Variant::DICTIONARY: { - - Variant v = obj->get(p.name); - - item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); - item->set_text(1, String("Dictionary{") + itos(v.call("size")) + "}"); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - if (show_type_icons) - item->set_icon(0, get_icon("Dictionary", "EditorIcons")); - - } break; - - case Variant::POOL_INT_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "IntArray[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "IntArray[]"); - if (show_type_icons) - item->set_icon(0, get_icon("PoolIntArray", "EditorIcons")); - - } break; - case Variant::POOL_REAL_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "FloatArray[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "FloatArray[]"); - if (show_type_icons) - item->set_icon(0, get_icon("PoolRealArray", "EditorIcons")); - - } break; - case Variant::POOL_STRING_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "String[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "String[]"); - if (show_type_icons) - item->set_icon(0, get_icon("PoolStringArray", "EditorIcons")); - - } break; - case Variant::POOL_BYTE_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "Byte[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "Byte[]"); - if (show_type_icons) - item->set_icon(0, get_icon("PoolByteArray", "EditorIcons")); - - } break; - case Variant::POOL_VECTOR2_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "Vector2[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "Vector2[]"); - if (show_type_icons) - item->set_icon(0, get_icon("Vector2", "EditorIcons")); - - } break; - case Variant::POOL_VECTOR3_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "Vector3[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "Vector3[]"); - if (show_type_icons) - item->set_icon(0, get_icon("Vector3", "EditorIcons")); - - } break; - case Variant::POOL_COLOR_ARRAY: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->add_button(1, get_icon("EditResource", "EditorIcons")); - - Variant v = obj->get(p.name); - if (v.is_array()) - item->set_text(1, "Color[" + itos(v.call("size")) + "]"); - else - item->set_text(1, "Color[]"); - if (show_type_icons) - item->set_icon(0, get_icon("Color", "EditorIcons")); - - } break; - case Variant::VECTOR2: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Vector2", "EditorIcons")); - - } break; - case Variant::RECT2: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Rect2", "EditorIcons")); - - } break; - case Variant::VECTOR3: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Vector3", "EditorIcons")); - - } break; - case Variant::TRANSFORM2D: - case Variant::BASIS: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - - } break; - case Variant::TRANSFORM: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Transform", "EditorIcons")); - - } break; - case Variant::PLANE: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Plane", "EditorIcons")); - - } break; - case Variant::AABB: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, "AABB"); - if (show_type_icons) - item->set_icon(0, get_icon("AABB", "EditorIcons")); - - } break; - - case Variant::QUAT: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, true); - item->set_text(1, obj->get(p.name)); - if (show_type_icons) - item->set_icon(0, get_icon("Quat", "EditorIcons")); - - } break; - case Variant::COLOR: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - item->set_custom_draw(1, this, "_draw_transparency"); - if (show_type_icons) - item->set_icon(0, get_icon("Color", "EditorIcons")); - - } break; - - case Variant::NODE_PATH: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); - item->set_editable(1, !read_only); - item->set_text(1, obj->get(p.name)); - item->add_button(1, get_icon("CopyNodePath", "EditorIcons")); - if (show_type_icons) - item->set_icon(0, get_icon("NodePath", "EditorIcons")); - - } break; - case Variant::OBJECT: { - - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - String type; - if (p.hint == PROPERTY_HINT_RESOURCE_TYPE) - type = p.hint_string; - - RES res = obj->get(p.name).operator RefPtr(); - if (type.begins_with("RES:") && type != "RES:") { // Remote resources - res = ResourceLoader::load(type.substr(4, type.length())); - } - Ref<EncodedObjectAsID> encoded = obj->get(p.name); //for debugger and remote tools - - if (encoded.is_valid()) { - - item->set_text(1, "Object: " + itos(encoded->get_object_id())); - item->set_icon(1, Ref<Texture>()); - item->set_custom_as_button(1, true); - item->set_editable(1, true); - - } else if (obj->get(p.name).get_type() == Variant::NIL || res.is_null()) { - - item->set_text(1, "<null>"); - item->set_icon(1, Ref<Texture>()); - item->set_custom_as_button(1, false); - - } else if (res.is_valid()) { - - item->set_custom_as_button(1, true); - - if (res->is_class("Texture")) { - int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); - Vector2 size(res->call("get_width"), res->call("get_height")); - if (size.width < size.height) { - tw = MAX((size.width / size.height) * tw, 1); - } - item->set_icon_max_width(1, tw); - item->set_icon(1, res); - item->set_text(1, ""); - - } else if (res->get_name() != "") { - - item->set_text(1, res->get_name()); - } else if (res->get_path() != "" && !res->get_path().begins_with("local://")) { - item->set_text(1, res->get_path().get_file()); - - } else { - item->set_text(1, "<" + res->get_class() + ">"); - } - - if (has_icon(res->get_class(), "EditorIcons")) { - type = res->get_class(); - } - - if (res.is_valid() && res->get_path().is_resource_file()) { - item->set_tooltip(1, res->get_path()); - } else if (res.is_valid()) { - item->set_tooltip(1, res->get_name() + " (" + res->get_class() + ")"); - } - if (res->is_class("Script")) { - item->set_text(1, res->get_path().get_file()); - } else if (!res->is_class("Texture")) { - //texture already previews via itself - EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", item->get_instance_id()); - } - } - - if (type != String()) { - if (type.find(",") != -1) - type = type.get_slice(",", 0); - if (has_icon(type, "EditorIcons")) - item->set_icon(0, get_icon(type, "EditorIcons")); - else - item->set_icon(0, get_icon("Object", "EditorIcons")); - } - - } break; - default: {}; - } - - if (keying) { - - if (p.hint == PROPERTY_HINT_SPRITE_FRAME) { - - item->add_button(1, get_icon("KeyNext", "EditorIcons"), 5); - } else { - item->add_button(1, get_icon("Key", "EditorIcons"), 2); - } - } - - bool has_reload = false; - - if (_is_instanced_node_with_original_property_different(p.name, item)) { - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - has_reload = true; - } - - if (obj->call("property_can_revert", p.name).operator bool()) { - - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - has_reload = true; - } - - if (!has_reload && !obj->get_script().is_null()) { - Ref<Script> scr = obj->get_script(); - Variant orig_value; - if (scr->get_property_default_value(p.name, orig_value)) { - if (orig_value != obj->get(p.name)) { - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - has_reload = true; - } - } - } - - if (_might_be_in_instance() && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { - item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true); - } - } -} - -void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) { - - TreeItem *ti = Object::cast_to<TreeItem>(t); - if (!ti) - return; - - Color color = obj->get(ti->get_metadata(1)); - Ref<Texture> arrow = tree->get_icon("select_option"); - - // make a little space between consecutive color fields - Rect2 area = p_rect; - area.position.y += 1; - area.size.height -= 2; - area.size.width -= arrow->get_size().width + 5; - tree->draw_texture_rect(get_icon("GuiMiniCheckerboard", "EditorIcons"), area, true); - tree->draw_rect(area, color); -} - -void PropertyEditor::_item_folded(Object *item_obj) { - - if (updating_folding) - return; - - TreeItem *item = Object::cast_to<TreeItem>(item_obj); - - obj->editor_set_section_unfold(item->get_metadata(0), !item->is_collapsed()); -} - -void PropertyEditor::_item_selected() { - - TreeItem *item = tree->get_selected(); - ERR_FAIL_COND(!item); - selected_property = item->get_metadata(1); -} - -void PropertyEditor::_item_rmb_edited() { - _custom_editor_request(true); -} - -void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { - - if (autoclear) { - TreeItem *item = tree->get_selected(); - if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) { - - item->set_checked(0, true); - } - } - - if (!undo_redo || Object::cast_to<ArrayPropertyEdit>(obj) || Object::cast_to<DictionaryPropertyEdit>(obj)) { //kind of hacky - - obj->set(p_name, p_value); - if (p_refresh_all) - _changed_callbacks(obj, ""); - else - _changed_callbacks(obj, p_name); - - emit_signal(_prop_edited, p_name); - - } else if (Object::cast_to<MultiNodeEdit>(obj)) { - - Object::cast_to<MultiNodeEdit>(obj)->set_property_field(p_name, p_value, p_changed_field); - _changed_callbacks(obj, p_name); - emit_signal(_prop_edited, p_name); - } else { - - undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS); - undo_redo->add_do_property(obj, p_name, p_value); - undo_redo->add_undo_property(obj, p_name, obj->get(p_name)); - - if (p_refresh_all) { - undo_redo->add_do_method(this, "_changed_callback", obj, ""); - undo_redo->add_undo_method(this, "_changed_callback", obj, ""); - } else { - - undo_redo->add_do_method(this, "_changed_callback", obj, p_name); - undo_redo->add_undo_method(this, "_changed_callback", obj, p_name); - } - - Resource *r = Object::cast_to<Resource>(obj); - if (r) { - if (!r->is_edited() && String(p_name) != "resource/edited") { - undo_redo->add_do_method(r, "set_edited", true); - undo_redo->add_undo_method(r, "set_edited", false); - } - - if (String(p_name) == "resource_local_to_scene") { - bool prev = obj->get(p_name); - bool next = p_value; - if (next) { - undo_redo->add_do_method(this, "setup_local_to_scene"); - } - if (prev) { - undo_redo->add_undo_method(this, "setup_local_to_scene"); - } - } - } - undo_redo->add_do_method(this, "emit_signal", _prop_edited, p_name); - undo_redo->add_undo_method(this, "emit_signal", _prop_edited, p_name); - undo_redo->commit_action(); - } -} - -void PropertyEditor::_item_edited() { - - TreeItem *item = tree->get_edited(); - if (!item) - return; //it all happened too fast.. - - Dictionary d = item->get_metadata(0); - - String name = d["name"]; - - if (tree->get_edited_column() == 0) { - //property checked - if (autoclear) { - if (!item->is_checked(0)) { - obj->set(name, Variant()); - update_property(name); - } else { - Variant::CallError ce; - obj->set(name, Variant::construct(Variant::Type(int(d["type"])), NULL, 0, ce)); - } - } else { - emit_signal("property_toggled", name, item->is_checked(0)); - } - return; - } - - if (autoclear && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && item->get_cell_mode(1) != TreeItem::CELL_MODE_CUSTOM) { - item->set_checked(0, true); - } - - int type = d["type"]; - int hint = d["hint"]; - int usage = d["usage"]; - bool refresh_all = usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED; - - String hint_text = d["hint_text"]; - switch (type) { - - case Variant::NIL: { - - } break; - case Variant::BOOL: { - - item->set_tooltip(1, item->is_checked(1) ? "True" : "False"); - _edit_set(name, item->is_checked(1), refresh_all); - } break; - case Variant::INT: - case Variant::REAL: { - - if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) - break; - if (hint == PROPERTY_HINT_EXP_EASING) - break; - if (hint == PROPERTY_HINT_FLAGS) - break; - - if (type == Variant::INT) - _edit_set(name, int64_t(round(item->get_range(1))), refresh_all); - else - _edit_set(name, item->get_range(1), refresh_all); - } break; - case Variant::STRING: { - - if (hint == PROPERTY_HINT_ENUM) { - - int idx = item->get_range(1); - - Vector<String> strings = hint_text.split(","); - String txt; - if (idx >= 0 && idx < strings.size()) { - - txt = strings[idx]; - } - - _edit_set(name, txt, refresh_all); - } else { - _edit_set(name, item->get_text(1), refresh_all); - } - } break; - - // math types - case Variant::VECTOR3: { - - } break; - case Variant::PLANE: { - - } break; - case Variant::QUAT: { - - } break; - case Variant::AABB: { - - } break; - case Variant::BASIS: { - - } break; - case Variant::TRANSFORM: { - - } break; - case Variant::COLOR: { - - } break; - - case Variant::NODE_PATH: { - _edit_set(name, NodePath(item->get_text(1)), refresh_all); - - } break; - case Variant::OBJECT: { - if (!item->is_custom_set_as_button(1)) - break; - - Ref<EncodedObjectAsID> encoded = obj->get(name); //for debugger and remote tools - - if (encoded.is_valid()) { - - emit_signal("object_id_selected", encoded->get_object_id()); - } - - RES res = obj->get(name); - if (res.is_valid()) { - emit_signal("resource_selected", res.get_ref_ptr(), name); - } - - } break; - - case Variant::DICTIONARY: { - - } break; - - // arrays - case Variant::POOL_BYTE_ARRAY: { - - } break; - case Variant::POOL_INT_ARRAY: { - - } break; - case Variant::POOL_REAL_ARRAY: { - - } break; - case Variant::POOL_STRING_ARRAY: { - - } break; - case Variant::POOL_VECTOR3_ARRAY: { - - } break; - case Variant::POOL_COLOR_ARRAY: { - - } break; - }; -} - -void PropertyEditor::_resource_edit_request() { - - RES res = custom_editor->get_variant(); - if (res.is_null()) - return; - - String name = custom_editor->get_name(); - - emit_signal("resource_selected", res.get_ref_ptr(), name); -} - -void PropertyEditor::_custom_editor_edited() { - - if (!obj) - return; - - _edit_set(custom_editor->get_name(), custom_editor->get_variant()); -} - -void PropertyEditor::_custom_editor_edited_field(const String &p_field_name) { - - ERR_FAIL_COND(p_field_name == ""); - - if (!obj) - return; - - _edit_set(custom_editor->get_name(), custom_editor->get_variant(), false, p_field_name); -} - -void PropertyEditor::_custom_editor_request(bool p_arrow) { - - TreeItem *item = tree->get_edited(); - ERR_FAIL_COND(!item); - Dictionary d = item->get_metadata(0); - - String name = d["name"]; - Variant::Type type = Variant::NIL; - if (d.has("type")) - type = (Variant::Type)((int)(d["type"])); - - Variant v = obj->get(name); - int hint = d.has("hint") ? d["hint"].operator int() : -1; - String hint_text = d.has("hint_text") ? d["hint_text"] : ""; - Rect2 where = tree->get_custom_popup_rect(); - custom_editor->set_position(where.position); - - if (custom_editor->edit(obj, name, type, v, hint, hint_text)) { - custom_editor->popup(); - } -} - -void PropertyEditor::edit(Object *p_object) { - - if (obj == p_object) - return; - if (obj) { - - obj->remove_change_receptor(this); - } - - obj = p_object; - - evaluator->edit(p_object); - - update_tree(); - - if (obj) { - - obj->add_change_receptor(this); - } -} - -void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame) { - - TreeItem *ti = Object::cast_to<TreeItem>(p_item); - ERR_FAIL_COND(!ti); - - ti->call_deferred("set_range", 1, p_frame); - obj->call_deferred("set", prop, 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); - - Dictionary d = ti->get_metadata(0); - - if (p_button == 2) { - - if (!d.has("name")) - return; - String prop = d["name"]; - emit_signal("property_keyed", prop, obj->get(prop), false); - } else if (p_button == 5) { - if (!d.has("name")) - return; - String prop = d["name"]; - emit_signal("property_keyed", prop, obj->get(prop), true); - call_deferred("_set_range_def", ti, prop, ti->get_range(p_column) + 1.0); - } else if (p_button == 3) { - - if (!d.has("name")) - return; - - String prop = d["name"]; - - Variant vorig; - - if (_might_be_in_instance() && _get_instanced_node_original_property(prop, vorig)) { - - _edit_set(prop, vorig.duplicate(true)); // Set, making sure to duplicate arrays properly - return; - } - - if (obj->call("property_can_revert", prop).operator bool()) { - Variant rev = obj->call("property_get_revert", prop); - _edit_set(prop, rev); - } - - if (!obj->get_script().is_null()) { - Ref<Script> scr = obj->get_script(); - Variant orig_value; - if (scr->get_property_default_value(prop, orig_value)) { - _edit_set(prop, orig_value); - } - } - - } else { - - Dictionary d = ti->get_metadata(0); - if (!d.has("type")) - return; - if (!d.has("hint")) - return; - if (!d.has("name")) - return; - if (!d.has("hint_text")) - return; - - int t = d["type"]; - int h = d["hint"]; - String n = d["name"]; - String ht = d["hint_text"]; - - if (t == Variant::NODE_PATH) { - - Variant v = obj->get(n); - Rect2 where = tree->get_item_rect(ti, 1); - where.position -= tree->get_scroll(); - where.position += tree->get_global_position() + Point2(where.size.width, 0); - for (int i = ti->get_button_count(p_column) - 1; i >= p_button; i--) - where.position.x -= ti->get_button(p_column, i)->get_width(); - custom_editor->set_position(where.position); - custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); - custom_editor->popup(); - - } else if (t == Variant::STRING) { - - Variant v = obj->get(n); - custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); - 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); - where.position -= tree->get_scroll(); - where.position += tree->get_global_position() + Point2(where.size.width, 0); - for (int i = ti->get_button_count(p_column) - 1; i >= p_button; i--) - where.position.x -= ti->get_button(p_column, i)->get_width(); - custom_editor->set_position(where.position); - custom_editor->popup(); - } else { - custom_editor->popup_centered_ratio(); - } - - } else if (t == Variant::OBJECT) { - - RES r = obj->get(n); - if (r.is_valid()) { - - emit_signal("resource_selected", r, n); - } - } else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) { - - emit_signal("object_id_selected", obj->get(n)); - - } 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) { - - Variant v = obj->get(n); - - if (v.get_type() != t) { - Variant::CallError ce; - v = Variant::construct(Variant::Type(t), NULL, 0, ce); - } - - Ref<ArrayPropertyEdit> ape = memnew(ArrayPropertyEdit); - ape->edit(obj, n, ht, Variant::Type(t)); - EditorNode::get_singleton()->push_item(ape.ptr()); - - } else if (t == Variant::DICTIONARY) { - - Variant v = obj->get(n); - - if (v.get_type() != t) { - Variant::CallError ce; - v = Variant::construct(Variant::Type(t), NULL, 0, ce); - } - - Ref<DictionaryPropertyEdit> dpe = memnew(DictionaryPropertyEdit); - dpe->edit(obj, n); - EditorNode::get_singleton()->push_item(dpe.ptr()); - } - } -} - -void PropertyEditor::_node_removed(Node *p_node) { - - if (p_node == obj) { - edit(NULL); - } -} - -void PropertyEditor::set_keying(bool p_active) { - - if (keying == p_active) - return; - - keying = p_active; - update_tree(); -} - -void PropertyEditor::_draw_flags(Object *p_object, const Rect2 &p_rect) { - - TreeItem *ti = Object::cast_to<TreeItem>(p_object); - if (!ti) - return; - - Dictionary d = ti->get_metadata(0); - - if (!d.has("name")) - return; - - uint32_t f = obj->get(d["name"]); - - int bsize = (p_rect.size.height * 80 / 100) / 2; - - int h = bsize * 2 + 1; - int vofs = (p_rect.size.height - h) / 2; - - for (int i = 0; i < 2; i++) { - - Point2 ofs(4, vofs); - if (i == 1) - ofs.y += bsize + 1; - - ofs += p_rect.position; - for (int j = 0; j < 10; j++) { - - Point2 o = ofs + Point2(j * (bsize + 1), 0); - if (j >= 5) - o.x += 1; - - uint32_t idx = i * 10 + j; - bool on = f & (1 << idx); - tree->draw_rect(Rect2(o, Size2(bsize, bsize)), Color(0, 0, 0, on ? 0.8 : 0.3)); - } - } -} - -void PropertyEditor::_filter_changed(const String &p_text) { - - update_tree(); -} - -void PropertyEditor::_resource_preview_done(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud) { - - if (p_preview.is_null()) - return; //don't bother with empty preview - - ObjectID id = p_ud; - Object *obj = ObjectDB::get_instance(id); - - if (!obj) - return; - - TreeItem *ti = Object::cast_to<TreeItem>(obj); - - ERR_FAIL_COND(!ti); - - int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); - - ti->set_icon(1, p_preview); //should be scaled I think? - ti->set_icon_max_width(1, tw); - ti->set_text(1, ""); -} -void PropertyEditor::_bind_methods() { - - ClassDB::bind_method("_item_edited", &PropertyEditor::_item_edited); - ClassDB::bind_method("_item_selected", &PropertyEditor::_item_selected); - ClassDB::bind_method("_item_rmb_edited", &PropertyEditor::_item_rmb_edited); - ClassDB::bind_method("_item_folded", &PropertyEditor::_item_folded); - ClassDB::bind_method("_custom_editor_request", &PropertyEditor::_custom_editor_request); - ClassDB::bind_method("_custom_editor_edited", &PropertyEditor::_custom_editor_edited); - ClassDB::bind_method("_custom_editor_edited_field", &PropertyEditor::_custom_editor_edited_field, DEFVAL("")); - ClassDB::bind_method("_resource_edit_request", &PropertyEditor::_resource_edit_request); - ClassDB::bind_method("_node_removed", &PropertyEditor::_node_removed); - ClassDB::bind_method("_edit_button", &PropertyEditor::_edit_button); - ClassDB::bind_method("_changed_callback", &PropertyEditor::_changed_callbacks); - ClassDB::bind_method("_draw_flags", &PropertyEditor::_draw_flags); - ClassDB::bind_method("_set_range_def", &PropertyEditor::_set_range_def); - ClassDB::bind_method("_filter_changed", &PropertyEditor::_filter_changed); - ClassDB::bind_method("update_tree", &PropertyEditor::update_tree); - ClassDB::bind_method("_resource_preview_done", &PropertyEditor::_resource_preview_done); - ClassDB::bind_method("refresh", &PropertyEditor::refresh); - ClassDB::bind_method("_draw_transparency", &PropertyEditor::_draw_transparency); - ClassDB::bind_method("edit", &PropertyEditor::edit); - - ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw); - ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw); - ClassDB::bind_method(D_METHOD("drop_data_fw"), &PropertyEditor::drop_data_fw); - - ADD_SIGNAL(MethodInfo("property_toggled", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::BOOL, "value"))); - ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop"))); - ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id"))); - ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"))); - ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property"))); -} - -Tree *PropertyEditor::get_property_tree() { - - return tree; -} - -Label *PropertyEditor::get_top_label() { - - return top_label; -} - -void PropertyEditor::hide_top_label() { - - top_label->hide(); - tree->set_begin(Point2(0, 0)); -} - -String PropertyEditor::get_selected_path() const { - - TreeItem *ti = tree->get_selected(); - if (!ti) - return ""; - - Dictionary d = ti->get_metadata(0); - - if (d.has("name")) - return d["name"]; - else - return ""; -} - -bool PropertyEditor::is_capitalize_paths_enabled() const { - - return capitalize_paths; -} - -void PropertyEditor::set_enable_capitalize_paths(bool p_capitalize) { - - capitalize_paths = p_capitalize; - update_tree_pending = true; -} - -void PropertyEditor::set_autoclear(bool p_enable) { - - autoclear = p_enable; -} - -void PropertyEditor::set_show_categories(bool p_show) { - - show_categories = p_show; - update_tree(); -} - -void PropertyEditor::set_use_filter(bool p_use) { - - if (p_use == use_filter) - return; - - use_filter = p_use; - update_tree(); -} - -void PropertyEditor::register_text_enter(Node *p_line_edit) { - - ERR_FAIL_NULL(p_line_edit); - search_box = Object::cast_to<LineEdit>(p_line_edit); - - if (search_box) - search_box->connect("text_changed", this, "_filter_changed"); -} - -void PropertyEditor::set_property_selectable(bool p_selectable) { - property_selectable = p_selectable; - update_tree(); -} - -void PropertyEditor::set_subsection_selectable(bool p_selectable) { - - if (p_selectable == subsection_selectable) - return; - - subsection_selectable = p_selectable; - update_tree(); -} - -void PropertyEditor::set_use_folding(bool p_enable) { - - use_folding = p_enable; - tree->set_hide_folding(false); -} - -void PropertyEditor::collapse_all_folding() { - if (!obj) - return; - for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { - obj->editor_set_section_unfold(E->get(), false); - } - update_tree(); -} - -void PropertyEditor::expand_all_folding() { - - if (!obj) - return; - for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { - obj->editor_set_section_unfold(E->get(), true); - } - update_tree(); -} - -PropertyEditor::PropertyEditor() { - - _prop_edited = "property_edited"; - - hide_script = true; - use_folding = false; - - undo_redo = NULL; - obj = NULL; - search_box = NULL; - changing = false; - update_tree_pending = false; - - top_label = memnew(Label); - top_label->set_text(TTR("Properties:")); - top_label->set_anchor(MARGIN_RIGHT, ANCHOR_END); - top_label->set_begin(Point2(10, 0)); - top_label->set_end(Point2(0, 12)); - - add_child(top_label); - - tree = memnew(Tree); - tree->set_anchor(MARGIN_RIGHT, ANCHOR_END); - tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); - tree->set_begin(Point2(0, 19)); - tree->set_end(Point2(0, 0)); - - tree->set_columns(2); - tree->set_column_expand(0, true); - tree->set_column_min_width(0, 30); - tree->set_column_expand(1, true); - tree->set_column_min_width(1, 18); - add_child(tree); - - tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED); - tree->connect("item_rmb_edited", this, "_item_rmb_edited"); - tree->connect("cell_selected", this, "_item_selected"); - tree->connect("item_collapsed", this, "_item_folded"); - - tree->set_drag_forwarding(this); - - set_physics_process(true); - - custom_editor = memnew(CustomPropertyEditor); - custom_editor->set_pass_on_modal_close_click(false); - add_child(custom_editor); - - tree->connect("custom_popup_edited", this, "_custom_editor_request"); - tree->connect("button_pressed", this, "_edit_button"); - custom_editor->connect("variant_changed", this, "_custom_editor_edited"); - custom_editor->connect("variant_field_changed", this, "_custom_editor_edited_field"); - custom_editor->connect("resource_edit_request", this, "_resource_edit_request", make_binds(), CONNECT_DEFERRED); - tree->set_hide_folding(true); - - evaluator = memnew(PropertyValueEvaluator); - tree->set_value_evaluator(evaluator); - custom_editor->set_value_evaluator(evaluator); - - capitalize_paths = true; - autoclear = false; - tree->set_column_titles_visible(false); - tree->add_constant_override("button_margin", 0); - - keying = false; - read_only = false; - show_categories = false; - refresh_countdown = 0; - use_doc_hints = false; - updating_folding = true; - use_filter = false; - subsection_selectable = false; - property_selectable = false; - show_type_icons = false; // TODO: need to reimplement it to work with the new inspector -} - -PropertyEditor::~PropertyEditor() { - memdelete(evaluator); -} - ///////////////////////////// -class SectionedPropertyEditorFilter : public Object { - - GDCLASS(SectionedPropertyEditorFilter, Object); - - Object *edited; - String section; - bool allow_sub; - - bool _set(const StringName &p_name, const Variant &p_value) { - - if (!edited) - return false; - - String name = p_name; - if (section != "") { - name = section + "/" + name; - } - - bool valid; - edited->set(name, p_value, &valid); - return valid; - } - - bool _get(const StringName &p_name, Variant &r_ret) const { - - if (!edited) - return false; - - String name = p_name; - if (section != "") { - name = section + "/" + name; - } - - bool valid = false; - - r_ret = edited->get(name, &valid); - return valid; - } - void _get_property_list(List<PropertyInfo> *p_list) const { - - if (!edited) - return; - - List<PropertyInfo> pinfo; - edited->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - - PropertyInfo pi = E->get(); - int sp = pi.name.find("/"); - - if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff - continue; - - if (sp == -1) { - pi.name = "global/" + pi.name; - } - - if (pi.name.begins_with(section + "/")) { - pi.name = pi.name.replace_first(section + "/", ""); - if (!allow_sub && pi.name.find("/") != -1) - continue; - p_list->push_back(pi); - } - } - } - - bool property_can_revert(const String &p_name) { - - return edited->call("property_can_revert", section + "/" + p_name); - } - - Variant property_get_revert(const String &p_name) { - - return edited->call("property_get_revert", section + "/" + p_name); - } - -protected: - static void _bind_methods() { - - ClassDB::bind_method("property_can_revert", &SectionedPropertyEditorFilter::property_can_revert); - ClassDB::bind_method("property_get_revert", &SectionedPropertyEditorFilter::property_get_revert); - } - -public: - void set_section(const String &p_section, bool p_allow_sub) { - - section = p_section; - allow_sub = p_allow_sub; - _change_notify(); - } - - void set_edited(Object *p_edited) { - edited = p_edited; - _change_notify(); - } - - SectionedPropertyEditorFilter() { - edited = NULL; - } -}; - -void SectionedPropertyEditor::_bind_methods() { - - ClassDB::bind_method("_section_selected", &SectionedPropertyEditor::_section_selected); - ClassDB::bind_method("_search_changed", &SectionedPropertyEditor::_search_changed); - - ClassDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list); -} - -void SectionedPropertyEditor::_section_selected() { - - if (!sections->get_selected()) - return; - - filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL); -} - -void SectionedPropertyEditor::set_current_section(const String &p_section) { - - if (section_map.has(p_section)) { - section_map[p_section]->select(0); - } -} - -String SectionedPropertyEditor::get_current_section() const { - - if (sections->get_selected()) - return sections->get_selected()->get_metadata(0); - else - return ""; -} - -String SectionedPropertyEditor::get_full_item_path(const String &p_item) { - - String base = get_current_section(); - - if (base != "") - return base + "/" + p_item; - else - return p_item; -} - -void SectionedPropertyEditor::edit(Object *p_object) { - - if (!p_object) { - obj = -1; - sections->clear(); - - filter->set_edited(NULL); - editor->edit(NULL); - - return; - } - - ObjectID id = p_object->get_instance_id(); - - if (obj != id) { - - obj = id; - update_category_list(); - - filter->set_edited(p_object); - editor->edit(filter); - - if (sections->get_root()->get_children()) { - sections->get_root()->get_children()->select(0); - } - } else { - - update_category_list(); - } -} - -void SectionedPropertyEditor::update_category_list() { - - String selected_category = get_current_section(); - sections->clear(); - - Object *o = ObjectDB::get_instance(obj); - - if (!o) - return; - - List<PropertyInfo> pinfo; - o->get_property_list(&pinfo); - - section_map.clear(); - - TreeItem *root = sections->create_item(); - section_map[""] = root; - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - - PropertyInfo pi = E->get(); - - if (pi.usage & PROPERTY_USAGE_CATEGORY) - continue; - else if (!(pi.usage & PROPERTY_USAGE_EDITOR)) - continue; - - if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene") - continue; - - if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1) - continue; - - int sp = pi.name.find("/"); - if (sp == -1) - pi.name = "Global/" + pi.name; - - Vector<String> sectionarr = pi.name.split("/"); - String metasection; - - int sc = MIN(2, sectionarr.size() - 1); - - for (int i = 0; i < sc; i++) { - - TreeItem *parent = section_map[metasection]; - parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); - - if (i > 0) { - metasection += "/" + sectionarr[i]; - } else { - metasection = sectionarr[i]; - } - - if (!section_map.has(metasection)) { - TreeItem *ms = sections->create_item(parent); - section_map[metasection] = ms; - ms->set_text(0, sectionarr[i].capitalize()); - ms->set_metadata(0, metasection); - ms->set_selectable(0, false); - } - - if (i == sc - 1) { - //if it has children, make selectable - section_map[metasection]->set_selectable(0, true); - } - } - } - - if (section_map.has(selected_category)) { - section_map[selected_category]->select(0); - } - - editor->update_tree(); -} - -void SectionedPropertyEditor::register_search_box(LineEdit *p_box) { - - search_box = p_box; - editor->register_text_enter(p_box); - search_box->connect("text_changed", this, "_search_changed"); -} - -void SectionedPropertyEditor::_search_changed(const String &p_what) { - - update_category_list(); -} - -PropertyEditor *SectionedPropertyEditor::get_property_editor() { - - return editor; -} - -SectionedPropertyEditor::SectionedPropertyEditor() { - - obj = -1; - - search_box = NULL; - - add_constant_override("autohide", 1); // Fixes the dragger always showing up - - VBoxContainer *left_vb = memnew(VBoxContainer); - left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE); - add_child(left_vb); - - sections = memnew(Tree); - sections->set_v_size_flags(SIZE_EXPAND_FILL); - sections->set_hide_root(true); - - left_vb->add_child(sections, true); - - VBoxContainer *right_vb = memnew(VBoxContainer); - right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE); - right_vb->set_h_size_flags(SIZE_EXPAND_FILL); - add_child(right_vb); - - filter = memnew(SectionedPropertyEditorFilter); - editor = memnew(PropertyEditor); - editor->set_v_size_flags(SIZE_EXPAND_FILL); - right_vb->add_child(editor, true); - - editor->get_property_tree()->set_column_titles_visible(false); - - editor->hide_top_label(); - - sections->connect("cell_selected", this, "_section_selected"); -} - -SectionedPropertyEditor::~SectionedPropertyEditor() { - - memdelete(filter); -} - double PropertyValueEvaluator::eval(const String &p_text) { // If range value contains a comma replace it with dot (issue #6028) diff --git a/editor/property_editor.h b/editor/property_editor.h index 7d8fa22f3f..7d7ab912ea 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -175,180 +175,6 @@ public: CustomPropertyEditor(); }; -class PropertyEditor : public Control { - - GDCLASS(PropertyEditor, Control); - - Tree *tree; - Label *top_label; - LineEdit *search_box; - - PropertyValueEvaluator *evaluator; - - Object *obj; - - StringName _prop_edited; - - bool capitalize_paths; - bool changing; - bool update_tree_pending; - bool autoclear; - bool keying; - bool read_only; - bool show_categories; - bool show_type_icons; - float refresh_countdown; - bool use_doc_hints; - bool use_filter; - bool subsection_selectable; - bool hide_script; - bool use_folding; - bool property_selectable; - bool updating_folding; - - List<String> foldable_property_cache; - HashMap<String, String> pending; - String selected_property; - - Map<StringName, Map<StringName, String> > descr_cache; - Map<StringName, String> class_descr_cache; - - CustomPropertyEditor *custom_editor; - - void _resource_edit_request(); - void _custom_editor_edited(); - void _custom_editor_edited_field(const String &p_field_name); - void _custom_editor_request(bool p_arrow); - - void _item_selected(); - void _item_rmb_edited(); - void _item_edited(); - TreeItem *get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root, TreeItem *category); - - void set_item_text(TreeItem *p_item, int p_type, const String &p_name, int p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = ""); - - TreeItem *find_item(TreeItem *p_item, const String &p_name); - - virtual void _changed_callback(Object *p_changed, const char *p_prop); - virtual void _changed_callbacks(Object *p_changed, const String &p_prop); - - void _check_reload_status(const String &p_name, TreeItem *item); - - void _edit_button(Object *p_item, int p_column, int p_button); - - void _node_removed(Node *p_node); - - friend class ProjectExportDialog; - void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all = false, const String &p_changed_field = ""); - void _draw_flags(Object *p_object, const Rect2 &p_rect); - - bool _might_be_in_instance(); - bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value); - bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage = 0); - bool _is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item); - - void _refresh_item(TreeItem *p_item); - void _set_range_def(Object *p_item, String prop, float p_frame); - - void _filter_changed(const String &p_text); - - void _mark_drop_fields(TreeItem *p_at); - void _clear_drop_fields(TreeItem *p_at); - - bool _is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const; - 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); - - void _resource_preview_done(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud); - void _draw_transparency(Object *t, const Rect2 &p_rect); - void _item_folded(Object *item_obj); - - UndoRedo *undo_redo; - -protected: - void _notification(int p_what); - static void _bind_methods(); - -public: - void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } - - String get_selected_path() const; - - Tree *get_property_tree(); - Label *get_top_label(); - void hide_top_label(); - void update_tree(); - void update_property(const String &p_prop); - - void refresh(); - - void edit(Object *p_object); - - void set_keying(bool p_active); - void set_read_only(bool p_read_only) { - read_only = p_read_only; - custom_editor->set_read_only(p_read_only); - } - - bool is_capitalize_paths_enabled() const; - void set_enable_capitalize_paths(bool p_capitalize); - void set_autoclear(bool p_enable); - - void set_show_categories(bool p_show); - void set_use_doc_hints(bool p_enable) { use_doc_hints = p_enable; } - void set_hide_script(bool p_hide) { hide_script = p_hide; } - - void set_use_filter(bool p_use); - void register_text_enter(Node *p_line_edit); - - void set_subsection_selectable(bool p_selectable); - void set_property_selectable(bool p_selectable); - - void set_use_folding(bool p_enable); - - void collapse_all_folding(); - void expand_all_folding(); - - PropertyEditor(); - ~PropertyEditor(); -}; - -class SectionedPropertyEditorFilter; - -class SectionedPropertyEditor : public HSplitContainer { - - GDCLASS(SectionedPropertyEditor, HSplitContainer); - - ObjectID obj; - - Tree *sections; - SectionedPropertyEditorFilter *filter; - - Map<String, TreeItem *> section_map; - PropertyEditor *editor; - LineEdit *search_box; - - static void _bind_methods(); - void _section_selected(); - - void _search_changed(const String &p_what); - -public: - void register_search_box(LineEdit *p_box); - PropertyEditor *get_property_editor(); - void edit(Object *p_object); - String get_full_item_path(const String &p_item); - - void set_current_section(const String &p_section); - String get_current_section() const; - - void update_category_list(); - - SectionedPropertyEditor(); - ~SectionedPropertyEditor(); -}; - class PropertyValueEvaluator : public ValueEvaluator { GDCLASS(PropertyValueEvaluator, ValueEvaluator); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index dae1bdeeb0..c9eba33f35 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -30,8 +30,8 @@ #include "property_selector.h" +#include "core/os/keyboard.h" #include "editor_scale.h" -#include "os/keyboard.h" void PropertySelector::_text_changed(const String &p_newtext) { diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 57a2b0d97f..b1c847570c 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -30,11 +30,11 @@ #include "pvrtc_compress.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" +#include "core/os/os.h" #include "editor_settings.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "os/os.h" #include "scene/resources/texture.h" static void (*_base_image_compress_pvrtc2_func)(Image *) = NULL; diff --git a/editor/pvrtc_compress.h b/editor/pvrtc_compress.h index cdd2f0d242..0396837623 100644 --- a/editor/pvrtc_compress.h +++ b/editor/pvrtc_compress.h @@ -31,7 +31,7 @@ #ifndef PVRTC_COMPRESS_H #define PVRTC_COMPRESS_H -#include "image.h" +#include "core/image.h" void _pvrtc_register_compressors(); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index d2101f1e00..497596a508 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -30,7 +30,7 @@ #include "quick_open.h" -#include "os/keyboard.h" +#include "core/os/keyboard.h" void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { diff --git a/editor/quick_open.h b/editor/quick_open.h index ecc6af0c53..ffea6b52bd 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -31,8 +31,8 @@ #ifndef EDITOR_QUICK_OPEN_H #define EDITOR_QUICK_OPEN_H +#include "core/pair.h" #include "editor_file_system.h" -#include "pair.h" #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" class EditorQuickOpen : public ConfirmationDialog { diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index d617089142..47e1ae0dab 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -30,12 +30,12 @@ #include "rename_dialog.h" +#include "core/print_string.h" #include "editor_node.h" #include "editor_settings.h" #include "editor_themes.h" #include "modules/regex/regex.h" #include "plugins/script_editor_plugin.h" -#include "print_string.h" #include "scene/gui/control.h" #include "scene/gui/label.h" #include "scene/gui/tab_container.h" @@ -220,21 +220,21 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und Label *lbl_count_step = memnew(Label); lbl_count_step->set_text(TTR("Step")); - lbl_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); + lbl_count_step->set_tooltip(TTR("Amount by which counter is incremented for each node")); hbc_count_options->add_child(lbl_count_step); spn_count_step = memnew(SpinBox); - spn_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); + spn_count_step->set_tooltip(TTR("Amount by which counter is incremented for each node")); spn_count_step->set_step(1); hbc_count_options->add_child(spn_count_step); Label *lbl_count_padding = memnew(Label); lbl_count_padding->set_text(TTR("Padding")); - lbl_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); + lbl_count_padding->set_tooltip(TTR("Minimum number of digits for the counter.\nMissing digits are padded with leading zeros.")); hbc_count_options->add_child(lbl_count_padding); spn_count_padding = memnew(SpinBox); - spn_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); + spn_count_padding->set_tooltip(TTR("Minimum number of digits for the counter.\nMissing digits are padded with leading zeros.")); spn_count_padding->set_step(1); hbc_count_options->add_child(spn_count_padding); diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index c5ebc30c0c..fa558660a4 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -37,8 +37,8 @@ #include "scene/gui/option_button.h" #include "scene/gui/spin_box.h" +#include "core/undo_redo.h" #include "editor/scene_tree_editor.h" -#include "undo_redo.h" /** @author Blazej Floch diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index da8bfdbbd2..3a6864b052 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -30,7 +30,7 @@ #include "reparent_dialog.h" -#include "print_string.h" +#include "core/print_string.h" #include "scene/gui/box_container.h" #include "scene/gui/label.h" diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 39250ab391..9461f39aeb 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -224,7 +224,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node String new_name = parent->validate_child_name(instanced_scene); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name); - editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name)); + editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name))); } editor_data->get_undo_redo().commit_action(); @@ -354,9 +354,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (path == "") { String root_path = editor_data->get_edited_scene_root()->get_filename(); if (root_path == "") { - path = "res://" + selected->get_name(); + path = String("res://").plus_file(selected->get_name()); } else { - path = root_path.get_base_dir() + "/" + selected->get_name(); + path = root_path.get_base_dir().plus_file(selected->get_name()); } } @@ -400,8 +400,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(E->get(), "set_script", empty); editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing); - editor_data->get_undo_redo().add_do_method(E->get(), "set_meta", "_editor_icon", get_icon(E->get()->get_class(), "EditorIcons")); - editor_data->get_undo_redo().add_undo_method(E->get(), "set_meta", "_editor_icon", E->get()->get_meta("_editor_icon")); + if (E->get()->has_meta("_editor_icon")) { + editor_data->get_undo_redo().add_do_method(E->get(), "set_meta", "_editor_icon", get_icon(E->get()->get_class(), "EditorIcons")); + editor_data->get_undo_redo().add_undo_method(E->get(), "set_meta", "_editor_icon", E->get()->get_meta("_editor_icon")); + } } } @@ -533,7 +535,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); 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())); + editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(dup->get_name()))); } editor_data->get_undo_redo().commit_action(); @@ -718,6 +720,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { node->set_scene_instance_load_placeholder(false); menu->set_item_checked(placeholder_item_idx, false); } + + SpatialEditor::get_singleton()->update_all_gizmos(node); + scene_tree->update_tree(); } } @@ -1424,7 +1429,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } editor_data->get_undo_redo().add_do_method(sed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc); - editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)) + "/" + new_name), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); + editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).plus_file(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index()); if (p_keep_global_xform) { if (Object::cast_to<Node2D>(node)) @@ -1656,7 +1661,7 @@ void SceneTreeDock::_create() { String new_name = parent->validate_child_name(child); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", edited_scene->get_path_to(parent), child->get_class(), new_name); - editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name)); + editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name))); } else { @@ -1811,6 +1816,13 @@ void SceneTreeDock::_new_scene_from(String p_file) { return; } + if (EditorNode::get_singleton()->is_scene_open(p_file)) { + accept->get_ok()->set_text(TTR("OK")); + accept->set_text(TTR("Can't overwrite scene that is still open!")); + accept->popup_centered_minsize(); + return; + } + Node *base = selection.front()->get(); Map<Node *, Node *> reown; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index a916ae23f6..a45773003a 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -30,11 +30,11 @@ #include "scene_tree_editor.h" +#include "core/message_queue.h" +#include "core/print_string.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor_node.h" -#include "message_queue.h" -#include "print_string.h" #include "scene/gui/label.h" #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index c4f63f5736..e575fb986a 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -31,12 +31,12 @@ #ifndef SCENE_TREE_EDITOR_H #define SCENE_TREE_EDITOR_H +#include "core/undo_redo.h" #include "editor_data.h" #include "editor_settings.h" #include "scene/gui/button.h" #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" -#include "undo_redo.h" /** @author Juan Linietsky <reduzio@gmail.com> */ diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 24c4ba4cb7..be255ba4aa 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -30,13 +30,13 @@ #include "script_create_dialog.h" +#include "core/io/resource_saver.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" +#include "core/script_language.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" #include "editor_file_system.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "project_settings.h" -#include "script_language.h" void ScriptCreateDialog::_notification(int p_what) { @@ -56,6 +56,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_ class_name->deselect(); parent_name->set_text(p_base_name); parent_name->deselect(); + if (p_base_path != "") { initial_bp = p_base_path.get_basename(); file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension()); @@ -359,7 +360,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { is_path_valid = false; is_new_script_created = true; - String p = p_path; + String p = p_path.strip_edges(); if (p == "") { _msg_path_valid(false, TTR("Path is empty")); @@ -367,6 +368,12 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { return; } + if (p.get_file().get_basename() == "") { + _msg_path_valid(false, TTR("Filename is empty")); + _update_dialog(); + return; + } + p = ProjectSettings::get_singleton()->localize_path(p); if (!p.begins_with("res://")) { _msg_path_valid(false, TTR("Path is not local")); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 9db53fe5f5..7a97531932 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -30,11 +30,12 @@ #include "script_editor_debugger.h" +#include "core/project_settings.h" +#include "core/ustring.h" #include "editor_node.h" #include "editor_profiler.h" #include "editor_settings.h" #include "main/performance.h" -#include "project_settings.h" #include "property_editor.h" #include "scene/gui/dialogs.h" #include "scene/gui/label.h" @@ -47,7 +48,6 @@ #include "scene/gui/texture_button.h" #include "scene/gui/tree.h" #include "scene/resources/packed_scene.h" -#include "ustring.h" class ScriptEditorDebuggerVariables : public Object { @@ -396,7 +396,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da dobreak->set_disabled(false); docontinue->set_disabled(true); emit_signal("breaked", false, false, Variant()); - //tabs->set_current_tab(0); profiler->set_enabled(true); profiler->disable_seeking(); inspector->edit(NULL); @@ -712,27 +711,65 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da bool warning = err[9]; bool e; String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e); - String txt = time + " - " + (err[8].is_zero() ? String(err[7]) : String(err[8])); + String txt = err[8].is_zero() ? String(err[7]) : String(err[8]); - String tooltip = TTR("Type:") + String(warning ? TTR("Warning") : TTR("Error")); - tooltip += "\n" + TTR("Description:") + " " + String(err[8]); - tooltip += "\n" + TTR("Time:") + " " + time; - tooltip += "\nC " + TTR("Error:") + " " + String(err[7]); - tooltip += "\nC " + TTR("Source:") + " " + String(err[5]) + ":" + String(err[6]); - tooltip += "\nC " + TTR("Function:") + " " + String(err[4]); + TreeItem *r = error_tree->get_root(); + if (!r) { + r = error_tree->create_item(); + } - error_list->add_item(txt, EditorNode::get_singleton()->get_gui_base()->get_icon(warning ? "Warning" : "Error", "EditorIcons")); - error_list->set_item_tooltip(error_list->get_item_count() - 1, tooltip); + TreeItem *error = error_tree->create_item(r); + error->set_collapsed(true); - int scc = p_data[1]; + error->set_icon(0, get_icon(warning ? "Warning" : "Error", "EditorIcons")); + error->set_text(0, time); + error->set_text_align(0, TreeItem::ALIGN_LEFT); + + error->set_text(1, txt); + + String source(err[5]); + bool source_is_project_file = source.begins_with("res://"); + if (source_is_project_file) + source = source.get_file(); + + txt = source + ":" + String(err[6]); + String method = err[4]; + if (method.length() > 0) + txt += " @ " + method + "()"; - Array stack; - stack.resize(scc); - for (int i = 0; i < scc; i++) { - stack[i] = p_data[2 + i]; + TreeItem *c_info = error_tree->create_item(error); + c_info->set_text(0, "<" + TTR(source_is_project_file ? "Source" : "C Source") + ">"); + c_info->set_text(1, txt); + c_info->set_text_align(0, TreeItem::ALIGN_LEFT); + + if (source_is_project_file) { + Array meta; + meta.push_back(source); + meta.push_back(err[6]); + error->set_metadata(0, meta); + c_info->set_metadata(0, meta); } - error_list->set_item_metadata(error_list->get_item_count() - 1, stack); + int scc = p_data[1]; + + for (int i = 0; i < scc; i += 3) { + String script = p_data[2 + i]; + String method = p_data[3 + i]; + int line = p_data[4 + i]; + TreeItem *stack_trace = error_tree->create_item(error); + + Array meta; + meta.push_back(script); + meta.push_back(line); + stack_trace->set_metadata(0, meta); + + if (i == 0) { + stack_trace->set_text(0, "<" + TTR("Stack Trace") + ">"); + stack_trace->set_text_align(0, TreeItem::ALIGN_LEFT); + error->set_metadata(0, meta); + } + stack_trace->set_text(1, script.get_file() + ":" + itos(line) + " @ " + method + "()"); + } if (warning) warning_count++; @@ -970,8 +1007,8 @@ void ScriptEditorDebugger::_notification(int p_what) { //scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons")); le_set->connect("pressed", this, "_live_edit_set"); le_clear->connect("pressed", this, "_live_edit_clear"); - error_list->connect("item_selected", this, "_error_selected"); - error_stack->connect("item_selected", this, "_error_stack_selected"); + error_tree->connect("item_selected", this, "_error_selected"); + error_tree->connect("item_activated", this, "_error_activated"); vmem_refresh->set_icon(get_icon("Reload", "EditorIcons")); reason->add_color_override("font_color", get_color("error_color", "Editor")); @@ -1017,19 +1054,19 @@ void ScriptEditorDebugger::_notification(int p_what) { if (error_count != last_error_count || warning_count != last_warning_count) { if (error_count == 0 && warning_count == 0) { - error_split->set_name(TTR("Errors")); + error_tree->set_name(TTR("Errors")); debugger_button->set_text(TTR("Debugger")); debugger_button->set_icon(Ref<Texture>()); - tabs->set_tab_icon(error_split->get_index(), Ref<Texture>()); + tabs->set_tab_icon(error_tree->get_index(), Ref<Texture>()); } else { - error_split->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); + error_tree->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); if (error_count == 0) { debugger_button->set_icon(get_icon("Warning", "EditorIcons")); - tabs->set_tab_icon(error_split->get_index(), get_icon("Warning", "EditorIcons")); + tabs->set_tab_icon(error_tree->get_index(), get_icon("Warning", "EditorIcons")); } else { debugger_button->set_icon(get_icon("Error", "EditorIcons")); - tabs->set_tab_icon(error_split->get_index(), get_icon("Error", "EditorIcons")); + tabs->set_tab_icon(error_tree->get_index(), get_icon("Error", "EditorIcons")); } } last_error_count = error_count; @@ -1060,8 +1097,7 @@ void ScriptEditorDebugger::_notification(int p_what) { inspect_scene_tree->clear(); le_set->set_disabled(true); le_clear->set_disabled(false); - error_list->clear(); - error_stack->clear(); + error_tree->clear(); error_count = 0; warning_count = 0; profiler_signature.clear(); @@ -1659,45 +1695,26 @@ void ScriptEditorDebugger::reload_scripts() { } } -void ScriptEditorDebugger::_error_selected(int p_idx) { - - error_stack->clear(); - Array st = error_list->get_item_metadata(p_idx); - for (int i = 0; i < st.size(); i += 3) { - - String script = st[i]; - String func = st[i + 1]; - int line = st[i + 2]; - Array md; - md.push_back(st[i]); - md.push_back(st[i + 1]); - md.push_back(st[i + 2]); - - String str = func; - String tooltip_str = TTR("Function:") + " " + func; - if (script.length() > 0) { - str += " in " + script.get_file(); - tooltip_str = TTR("File:") + " " + script + "\n" + tooltip_str; - if (line > 0) { - str += ":line " + itos(line); - tooltip_str += "\n" + TTR("Line:") + " " + itos(line); - } - } +void ScriptEditorDebugger::_error_activated() { + TreeItem *selected = error_tree->get_selected(); - error_stack->add_item(str); - error_stack->set_item_metadata(error_stack->get_item_count() - 1, md); - error_stack->set_item_tooltip(error_stack->get_item_count() - 1, tooltip_str); + TreeItem *ci = selected->get_children(); + if (ci) { + selected->set_collapsed(!selected->is_collapsed()); } } -void ScriptEditorDebugger::_error_stack_selected(int p_idx) { +void ScriptEditorDebugger::_error_selected() { + TreeItem *selected = error_tree->get_selected(); - Array arr = error_stack->get_item_metadata(p_idx); - if (arr.size() != 3) + Array meta = selected->get_metadata(0); + + if (meta.size() == 0) { return; + } - Ref<Script> s = ResourceLoader::load(arr[0]); - emit_signal("goto_script_line", s, int(arr[2]) - 1); + Ref<Script> s = ResourceLoader::load(meta[0]); + emit_signal("goto_script_line", s, int(meta[1]) - 1); } void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) { @@ -1754,27 +1771,24 @@ void ScriptEditorDebugger::_clear_remote_objects() { void ScriptEditorDebugger::_clear_errors_list() { - error_list->clear(); + error_tree->clear(); error_count = 0; warning_count = 0; _notification(NOTIFICATION_PROCESS); } // Right click on specific file(s) or folder(s). -void ScriptEditorDebugger::_error_list_item_rmb_selected(int p_item, const Vector2 &p_pos) { +void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { item_menu->clear(); item_menu->set_size(Size2(1, 1)); - // Allow specific actions only on one item. - bool single_item_selected = error_list->get_selected_items().size() == 1; - - if (single_item_selected) { + if (error_tree->is_anything_selected()) { item_menu->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), ITEM_MENU_COPY_ERROR); } if (item_menu->get_item_count() > 0) { - item_menu->set_position(error_list->get_global_position() + p_pos); + item_menu->set_position(error_tree->get_global_position() + p_pos); item_menu->popup(); } } @@ -1784,10 +1798,30 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { switch (p_option) { case ITEM_MENU_COPY_ERROR: { - String title = error_list->get_item_text(error_list->get_current()); - String desc = error_list->get_item_tooltip(error_list->get_current()); + TreeItem *ti = error_tree->get_selected(); + while (ti->get_parent() != error_tree->get_root()) + ti = ti->get_parent(); + + String type; + + if (ti->get_icon(0) == get_icon("Warning", "EditorIcons")) { + type = "W "; + } else if (ti->get_icon(0) == get_icon("Error", "EditorIcons")) { + type = "E "; + } + + String text = ti->get_text(0) + " "; + int rpad_len = text.length(); + + text = type + text + ti->get_text(1) + "\n"; + TreeItem *ci = ti->get_children(); + while (ci) { + text += " " + ci->get_text(0).rpad(rpad_len) + ci->get_text(1) + "\n"; + ci = ci->get_next(); + } + + OS::get_singleton()->set_clipboard(text); - OS::get_singleton()->set_clipboard(title + "\n----------\n" + desc); } break; case ITEM_MENU_SAVE_REMOTE_NODE: { @@ -1826,12 +1860,12 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_live_edit_clear"), &ScriptEditorDebugger::_live_edit_clear); ClassDB::bind_method(D_METHOD("_error_selected"), &ScriptEditorDebugger::_error_selected); - ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected); + ClassDB::bind_method(D_METHOD("_error_activated"), &ScriptEditorDebugger::_error_activated); ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate); ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked); ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list); - ClassDB::bind_method(D_METHOD("_error_list_item_rmb_selected"), &ScriptEditorDebugger::_error_list_item_rmb_selected); + ClassDB::bind_method(D_METHOD("_error_tree_item_rmb_selected"), &ScriptEditorDebugger::_error_tree_item_rmb_selected); ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &ScriptEditorDebugger::_item_menu_id_pressed); ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused); @@ -1946,10 +1980,8 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { stack_dump->connect("cell_selected", this, "_stack_dump_frame_selected"); sc->add_child(stack_dump); - inspector = memnew(PropertyEditor); + inspector = memnew(EditorInspector); inspector->set_h_size_flags(SIZE_EXPAND_FILL); - inspector->hide_top_label(); - inspector->get_property_tree()->set_column_title(0, TTR("Variable")); inspector->set_enable_capitalize_paths(false); inspector->set_read_only(true); inspector->connect("object_id_selected", this, "_scene_tree_property_select_object"); @@ -1967,44 +1999,35 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { } { //errors - - error_split = memnew(HSplitContainer); - VBoxContainer *errvb = memnew(VBoxContainer); HBoxContainer *errhb = memnew(HBoxContainer); - errvb->set_h_size_flags(SIZE_EXPAND_FILL); - Label *velb = memnew(Label(TTR("Errors:"))); - velb->set_h_size_flags(SIZE_EXPAND_FILL); - errhb->add_child(velb); + errhb->set_name(TTR("Errors")); - clearbutton = memnew(Button); - clearbutton->set_text(TTR("Clear")); - clearbutton->connect("pressed", this, "_clear_errors_list"); - errhb->add_child(clearbutton); - errvb->add_child(errhb); + error_tree = memnew(Tree); + error_tree->set_columns(2); - error_list = memnew(ItemList); - error_list->set_v_size_flags(SIZE_EXPAND_FILL); - error_list->set_h_size_flags(SIZE_EXPAND_FILL); - error_list->connect("item_rmb_selected", this, "_error_list_item_rmb_selected"); - error_list->set_allow_rmb_select(true); - error_list->set_autoscroll_to_bottom(true); + error_tree->set_column_expand(0, false); + error_tree->set_column_min_width(0, 140); - item_menu = memnew(PopupMenu); - item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); - error_list->add_child(item_menu); + error_tree->set_column_expand(1, true); - errvb->add_child(error_list); + error_tree->set_select_mode(Tree::SELECT_ROW); + error_tree->set_hide_root(true); + error_tree->set_h_size_flags(SIZE_EXPAND_FILL); + error_tree->set_allow_rmb_select(true); + error_tree->connect("item_rmb_selected", this, "_error_tree_item_rmb_selected"); + errhb->add_child(error_tree); - error_split->add_child(errvb); + item_menu = memnew(PopupMenu); + item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); + error_tree->add_child(item_menu); - errvb = memnew(VBoxContainer); - errvb->set_h_size_flags(SIZE_EXPAND_FILL); - error_stack = memnew(ItemList); - errvb->add_margin_child(TTR("Stack Trace (if applicable):"), error_stack, true); - error_split->add_child(errvb); + clearbutton = memnew(Button); + clearbutton->set_text(TTR("Clear")); + clearbutton->set_v_size_flags(0); + clearbutton->connect("pressed", this, "_clear_errors_list"); + errhb->add_child(clearbutton); - error_split->set_name(TTR("Errors")); - tabs->add_child(error_split); + tabs->add_child(errhb); } { // remote scene tree @@ -2180,7 +2203,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { ScriptEditorDebugger::~ScriptEditorDebugger() { - //inspector->edit(NULL); memdelete(variables); ppeer->set_stream_peer(Ref<StreamPeer>()); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index ce705aa35b..017619e56f 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -33,12 +33,12 @@ #include "core/io/packet_peer.h" #include "core/io/tcp_server.h" -#include "property_editor.h" +#include "editor/editor_inspector.h" +#include "editor/property_editor.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" class Tree; -class PropertyEditor; class EditorNode; class ScriptEditorDebuggerVariables; class LineEdit; @@ -88,8 +88,7 @@ class ScriptEditorDebugger : public Control { Set<ObjectID> unfold_cache; HSplitContainer *error_split; - ItemList *error_list; - ItemList *error_stack; + Tree *error_tree; Tree *inspect_scene_tree; Button *clearbutton; PopupMenu *item_menu; @@ -130,7 +129,7 @@ class ScriptEditorDebugger : public Control { LineEdit *vmem_total; Tree *stack_dump; - PropertyEditor *inspector; + EditorInspector *inspector; Ref<TCP_Server> server; Ref<StreamPeerTCP> connection; @@ -179,8 +178,8 @@ class ScriptEditorDebugger : public Control { void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE); void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value); - void _error_selected(int p_idx); - void _error_stack_selected(int p_idx); + void _error_activated(); + void _error_selected(); void _profiler_activate(bool p_enable); void _profiler_seeked(); @@ -191,7 +190,7 @@ class ScriptEditorDebugger : public Control { void _clear_remote_objects(); void _clear_errors_list(); - void _error_list_item_rmb_selected(int p_item, const Vector2 &p_pos); + void _error_tree_item_rmb_selected(const Vector2 &p_pos); void _item_menu_id_pressed(int p_option); protected: diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 4ebba73cb3..97cdd43fee 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -30,11 +30,11 @@ #include "settings_config_dialog.h" +#include "core/os/keyboard.h" +#include "core/project_settings.h" #include "editor_file_system.h" #include "editor_node.h" #include "editor_settings.h" -#include "os/keyboard.h" -#include "project_settings.h" #include "scene/gui/margin_container.h" #include "script_editor_debugger.h" diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 64638cdb1e..3097f0d0b9 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -30,12 +30,32 @@ #include "spatial_editor_gizmos.h" -#include "geometry.h" -#include "quick_hull.h" -#include "scene/3d/camera.h" +#include "core/math/geometry.h" +#include "core/math/quick_hull.h" +#include "scene/3d/audio_stream_player_3d.h" +#include "scene/3d/baked_lightmap.h" +#include "scene/3d/collision_polygon.h" +#include "scene/3d/collision_shape.h" +#include "scene/3d/gi_probe.h" +#include "scene/3d/light.h" +#include "scene/3d/listener.h" +#include "scene/3d/mesh_instance.h" +#include "scene/3d/navigation_mesh.h" +#include "scene/3d/particles.h" +#include "scene/3d/physics_joint.h" +#include "scene/3d/portal.h" +#include "scene/3d/position_3d.h" +#include "scene/3d/ray_cast.h" +#include "scene/3d/reflection_probe.h" +#include "scene/3d/room_instance.h" #include "scene/3d/soft_body.h" +#include "scene/3d/spring_arm.h" +#include "scene/3d/sprite_3d.h" +#include "scene/3d/vehicle_body.h" +#include "scene/3d/visibility_notifier.h" #include "scene/resources/box_shape.h" #include "scene/resources/capsule_shape.h" +#include "scene/resources/concave_polygon_shape.h" #include "scene/resources/convex_polygon_shape.h" #include "scene/resources/cylinder_shape.h" #include "scene/resources/plane_shape.h" @@ -44,17 +64,8 @@ #include "scene/resources/sphere_shape.h" #include "scene/resources/surface_tool.h" -// Keep small children away from this file. -// It's so ugly it will eat them alive - -// The previous comment is kept only for historical reasons. -// No children will be harmed by the viewing of this file... hopefully. - #define HANDLE_HALF_SIZE 9.5 -bool EditorSpatialGizmo::can_draw() const { - return is_editable(); -} bool EditorSpatialGizmo::is_editable() const { ERR_FAIL_COND_V(!spatial_node, false); @@ -898,7 +909,6 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); p_gizmo->add_unscaled_billboard(icon, 0.05); } @@ -929,8 +939,6 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(points, material, true); - p_gizmo->add_collision_segments(points); - p_gizmo->add_unscaled_billboard(icon, 0.05); Vector<Vector3> handles; @@ -972,38 +980,14 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(points, material); + float ra = 16 * Math_PI * 2.0 / 64.0; + Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w; + Vector<Vector3> handles; handles.push_back(Vector3(0, 0, -r)); - - Vector<Vector3> collision_segments; - - for (int i = 0; i < 64; i++) { - - float ra = i * Math_PI * 2.0 / 64.0; - float rb = (i + 1) * Math_PI * 2.0 / 64.0; - Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w; - Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w; - - collision_segments.push_back(Vector3(a.x, a.y, -d)); - collision_segments.push_back(Vector3(b.x, b.y, -d)); - - if (i % 16 == 0) { - - collision_segments.push_back(Vector3(a.x, a.y, -d)); - collision_segments.push_back(Vector3()); - } - - if (i == 16) { - - handles.push_back(Vector3(a.x, a.y, -d)); - } - } - - collision_segments.push_back(Vector3(0, 0, -r)); - collision_segments.push_back(Vector3()); + handles.push_back(Vector3(a.x, a.y, -d)); p_gizmo->add_handles(handles, get_material("handles")); - p_gizmo->add_collision_segments(collision_segments); p_gizmo->add_unscaled_billboard(icon, 0.05); } } @@ -1139,7 +1123,6 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) } p_gizmo->add_lines(points, material); - p_gizmo->add_collision_segments(points); Vector<Vector3> handles; float ha = Math::deg2rad(player->get_emission_angle()); @@ -1334,7 +1317,6 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); p_gizmo->add_unscaled_billboard(icon, 0.05); p_gizmo->add_handles(handles, get_material("handles")); @@ -1377,7 +1359,6 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); } } @@ -1722,8 +1703,16 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { return; Skeleton *sk(physical_bone->find_skeleton_parent()); + if (!sk) + return; + PhysicalBone *pb(sk->get_physical_bone(physical_bone->get_bone_id())); + if (!pb) + return; + PhysicalBone *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id())); + if (!pbp) + return; Vector<Vector3> points; @@ -2105,12 +2094,10 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Vector<Vector3> points; soft_body->get_mesh()->generate_debug_mesh_indices(points); - soft_body->get_mesh()->clear_cache(); Ref<Material> material = get_material("shape_material", p_gizmo); p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); p_gizmo->add_handles(points, get_material("handles")); p_gizmo->add_collision_triangles(tm); } @@ -2427,7 +2414,6 @@ void ParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Ref<Material> icon = get_material("particles_icon", p_gizmo); p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); if (p_gizmo->is_selected()) { Ref<Material> solid_material = get_material("particles_solid_material", p_gizmo); @@ -2612,7 +2598,6 @@ void ReflectionProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_unscaled_billboard(icon, 0.05); - p_gizmo->add_collision_segments(lines); p_gizmo->add_handles(handles, get_material("handles")); } @@ -2727,7 +2712,6 @@ void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); lines.clear(); @@ -2897,7 +2881,6 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } p_gizmo->add_lines(lines, material); - p_gizmo->add_collision_segments(lines); Vector<Vector3> handles; @@ -3488,6 +3471,14 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } } + if (Object::cast_to<ConcavePolygonShape>(*s)) { + + Ref<ConcavePolygonShape> cs = s; + Ref<ArrayMesh> mesh = cs->get_debug_mesh()->duplicate(); + mesh->surface_set_material(0, material); + p_gizmo->add_mesh(mesh); + } + if (Object::cast_to<RayShape>(*s)) { Ref<RayShape> rs = s; diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 6f29e9d999..371e3bc689 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -32,27 +32,7 @@ #define SPATIAL_EDITOR_GIZMOS_H #include "editor/plugins/spatial_editor_plugin.h" -#include "scene/3d/audio_stream_player_3d.h" -#include "scene/3d/baked_lightmap.h" #include "scene/3d/camera.h" -#include "scene/3d/collision_polygon.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/gi_probe.h" -#include "scene/3d/light.h" -#include "scene/3d/listener.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation_mesh.h" -#include "scene/3d/particles.h" -#include "scene/3d/physics_joint.h" -#include "scene/3d/portal.h" -#include "scene/3d/position_3d.h" -#include "scene/3d/ray_cast.h" -#include "scene/3d/reflection_probe.h" -#include "scene/3d/room_instance.h" -#include "scene/3d/spring_arm.h" -#include "scene/3d/sprite_3d.h" -#include "scene/3d/vehicle_body.h" -#include "scene/3d/visibility_notifier.h" class Camera; |