diff options
57 files changed, 687 insertions, 202 deletions
diff --git a/SConstruct b/SConstruct index 7ef4d646a7..cb1e9fd567 100644 --- a/SConstruct +++ b/SConstruct @@ -74,6 +74,7 @@ env_base.android_gradle_plugins = [] env_base.android_gradle_classpath = [] env_base.android_java_dirs = [] env_base.android_res_dirs = [] +env_base.android_asset_dirs = [] env_base.android_aidl_dirs = [] env_base.android_jni_dirs = [] env_base.android_default_config = [] @@ -99,6 +100,7 @@ env_base.__class__.android_add_flat_dir = methods.android_add_flat_dir env_base.__class__.android_add_dependency = methods.android_add_dependency env_base.__class__.android_add_java_dir = methods.android_add_java_dir env_base.__class__.android_add_res_dir = methods.android_add_res_dir +env_base.__class__.android_add_asset_dir = methods.android_add_asset_dir env_base.__class__.android_add_aidl_dir = methods.android_add_aidl_dir env_base.__class__.android_add_jni_dir = methods.android_add_jni_dir env_base.__class__.android_add_default_config = methods.android_add_default_config diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 8d85e78226..fcbb22b5de 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -30,6 +30,7 @@ #include "http_client.h" #include "io/stream_peer_ssl.h" +#include "version.h" const char *HTTPClient::_methods[METHOD_MAX] = { "GET", @@ -121,16 +122,30 @@ Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; } bool add_clen = p_body.size() > 0; + bool add_uagent = true; + bool add_accept = true; for (int i = 0; i < p_headers.size(); i++) { request += p_headers[i] + "\r\n"; - if (add_clen && p_headers[i].find("Content-Length:") == 0) { + if (add_clen && p_headers[i].findn("Content-Length:") == 0) { add_clen = false; } + if (add_uagent && p_headers[i].findn("User-Agent:") == 0) { + add_uagent = false; + } + if (add_accept && p_headers[i].findn("Accept:") == 0) { + add_accept = false; + } } if (add_clen) { request += "Content-Length: " + itos(p_body.size()) + "\r\n"; // Should it add utf8 encoding? } + if (add_uagent) { + request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")\r\n"; + } + if (add_accept) { + request += "Accept: */*\r\n"; + } request += "\r\n"; CharString cs = request.utf8(); @@ -173,17 +188,31 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str } else { request += "Host: " + conn_host + ":" + itos(conn_port) + "\r\n"; } + bool add_uagent = true; + bool add_accept = true; bool add_clen = p_body.length() > 0; for (int i = 0; i < p_headers.size(); i++) { request += p_headers[i] + "\r\n"; - if (add_clen && p_headers[i].find("Content-Length:") == 0) { + if (add_clen && p_headers[i].findn("Content-Length:") == 0) { add_clen = false; } + if (add_uagent && p_headers[i].findn("User-Agent:") == 0) { + add_uagent = false; + } + if (add_accept && p_headers[i].findn("Accept:") == 0) { + add_accept = false; + } } if (add_clen) { request += "Content-Length: " + itos(p_body.utf8().length()) + "\r\n"; // Should it add utf8 encoding? } + if (add_uagent) { + request += "User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")\r\n"; + } + if (add_accept) { + request += "Accept: */*\r\n"; + } request += "\r\n"; request += p_body; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 20001bb9a6..f0c0268f31 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -182,8 +182,22 @@ public: static _ALWAYS_INLINE_ float abs(float g) { return absf(g); } static _ALWAYS_INLINE_ int abs(int g) { return g > 0 ? g : -g; } - static _ALWAYS_INLINE_ double fposmod(double p_x, double p_y) { return (p_x >= 0) ? Math::fmod(p_x, p_y) : p_y - Math::fmod(-p_x, p_y); } - static _ALWAYS_INLINE_ float fposmod(float p_x, float p_y) { return (p_x >= 0) ? Math::fmod(p_x, p_y) : p_y - Math::fmod(-p_x, p_y); } + static _ALWAYS_INLINE_ double fposmod(double p_x, double p_y) { + double value = Math::fmod(p_x, p_y); + if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) { + value += p_y; + } + value += 0.0; + return value; + } + static _ALWAYS_INLINE_ float fposmod(float p_x, float p_y) { + float value = Math::fmod(p_x, p_y); + if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) { + value += p_y; + } + value += 0.0; + return value; + } static _ALWAYS_INLINE_ double deg2rad(double p_y) { return p_y * Math_PI / 180.0; } static _ALWAYS_INLINE_ float deg2rad(float p_y) { return p_y * Math_PI / 180.0; } diff --git a/core/project_settings.cpp b/core/project_settings.cpp index a7bfc8895b..7f9f4b638a 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -870,6 +870,10 @@ void ProjectSettings::set_custom_property_info(const String &p_prop, const Prope custom_prop_info[p_prop].name = p_prop; } +const Map<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info() const { + return custom_prop_info; +} + void ProjectSettings::set_disable_feature_overrides(bool p_disable) { disable_feature_overrides = p_disable; diff --git a/core/project_settings.h b/core/project_settings.h index b01e7855aa..66f3ed954e 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -137,6 +137,7 @@ public: Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true); Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); + const Map<StringName, PropertyInfo> &get_custom_property_info() const; Vector<String> get_optimizer_presets() const; diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 0473e2cc71..3955f222f9 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -169,6 +169,10 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) ERR_FAIL(); } + if (allow_focus_steal_pid) { + OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid); + } + packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var(2); packet_peer_stream->put_var(p_can_continue); @@ -1070,6 +1074,10 @@ void ScriptDebuggerRemote::profiling_set_frame_times(float p_frame_time, float p physics_frame_time = p_physics_frame_time; } +void ScriptDebuggerRemote::set_allow_focus_steal_pid(OS::ProcessID p_pid) { + allow_focus_steal_pid = p_pid; +} + ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL; ScriptDebuggerRemote::ScriptDebuggerRemote() : @@ -1091,6 +1099,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() : n_errors_dropped(0), last_msec(0), msec_count(0), + allow_focus_steal_pid(0), locking(false), poll_every(0), request_scene_tree(NULL), diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index cc12d978d6..b68fc4f9c9 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -34,6 +34,7 @@ #include "io/packet_peer.h" #include "io/stream_peer_tcp.h" #include "list.h" +#include "os/os.h" #include "script_language.h" class ScriptDebuggerRemote : public ScriptDebugger { @@ -98,6 +99,8 @@ class ScriptDebuggerRemote : public ScriptDebugger { uint64_t last_msec; uint64_t msec_count; + OS::ProcessID allow_focus_steal_pid; + bool locking; //hack to avoid a deadloop static void _print_handler(void *p_this, const String &p_string, bool p_error); @@ -171,6 +174,8 @@ public: virtual void profiling_end(); virtual void profiling_set_frame_times(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time); + void set_allow_focus_steal_pid(OS::ProcessID p_pid); + ScriptDebuggerRemote(); ~ScriptDebuggerRemote(); }; diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index b9945f3f73..f5fbf8e313 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -235,6 +235,13 @@ <description> </description> </method> + <method name="get_script_create_dialog"> + <return type="ScriptCreateDialog"> + </return> + <description> + Gets the Editor's dialogue used for making scripts. Note that users can configure it before use. + </description> + </method> <method name="get_state" qualifiers="virtual"> <return type="Dictionary"> </return> diff --git a/doc/classes/EditorScenePostImport.xml b/doc/classes/EditorScenePostImport.xml index 664ea33dd6..f95c26c2b0 100644 --- a/doc/classes/EditorScenePostImport.xml +++ b/doc/classes/EditorScenePostImport.xml @@ -1,20 +1,56 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="EditorScenePostImport" inherits="Reference" category="Core" version="3.1"> <brief_description> + Post process scenes after import </brief_description> <description> + The imported scene can be automatically modified right after import by specifying a 'custom script' that inherits from this class. The [method post_import]-method receives the imported scene's root-node and returns the modified version of the scene </description> <tutorials> + http://docs.godotengine.org/en/latest/learning/workflow/assets/importing_scenes.html?highlight=post%20import </tutorials> <demos> + [codeblock] +tool # needed so it runs in editor +extends EditorScenePostImport + +# This sample changes all node names + +# get called right after the scene is imported and gets the root-node +func post_import(scene): + # change all node names to "modified_[oldnodename]" + iterate(scene) + return scene # remember to return the imported scene + +func iterate(node): + if node!=null: + node.name = "modified_"+node.name + for child in node.get_children(): + iterate(child) +[/codeblock] </demos> <methods> + <method name="get_source_file" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the source-file-path which got imported (e.g. [code]res://scene.dae[/code] ) + </description> + </method> + <method name="get_source_folder" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the resource-folder the imported scene-file is located in + </description> + </method> <method name="post_import" qualifiers="virtual"> - <return type="void"> + <return type="Object"> </return> <argument index="0" name="scene" type="Object"> </argument> <description> + Gets called after the scene got imported and has to return the modified version of the scene </description> </method> </methods> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml new file mode 100644 index 0000000000..f09d282026 --- /dev/null +++ b/doc/classes/ScriptCreateDialog.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ScriptCreateDialog" inherits="ConfirmationDialog" category="Core" version="3.1"> + <brief_description> + The Editor's popup dialog for creating new [Script] files. + </brief_description> + <description> + The ScriptCreateDialog creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling a [method popup]() method. + [codeblock] + func _ready(): + dialog.config("Node", "res://new_node.gd") # for in-engine types + dialog.config("\"res://base_node.gd\"", "res://derived_node.gd") # for script types + dialog.popup_centered() + [/codeblock] + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="config"> + <return type="void"> + </return> + <argument index="0" name="inherits" type="String"> + The dialog's "Inherits" field content. + </argument> + <argument index="1" name="path" type="String"> + The dialog's "Path" field content. + </argument> + <description> + Prefills required fields to configure the ScriptCreateDialog for use. + </description> + </method> + </methods> + <signals> + <signal name="script_created"> + <argument index="0" name="script" type="Object"> + </argument> + <description> + Emitted when the user clicks the OK button. + </description> + </signal> + </signals> + <constants> + </constants> +</class> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index ee9b7383e5..36408663f6 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -132,6 +132,13 @@ <description> </description> </method> + <method name="get_breakpoints" qualifiers="const"> + <return type="Array"> + </return> + <description> + Return an array containing the line number of each breakpoint. + </description> + </method> <method name="get_keyword_color" qualifiers="const"> <return type="Color"> </return> @@ -220,6 +227,12 @@ Insert a given text at the cursor position. </description> </method> + <method name="is_breakpoint_gutter_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> <method name="is_folded" qualifiers="const"> <return type="bool"> </return> @@ -265,6 +278,13 @@ Perform redo operation. </description> </method> + <method name="remove_breakpoints"> + <return type="void"> + </return> + <description> + Removes all the breakpoints (without firing "breakpoint_toggled" signal). + </description> + </method> <method name="search" qualifiers="const"> <return type="PoolIntArray"> </return> @@ -302,6 +322,14 @@ Select all the text. </description> </method> + <method name="set_breakpoint_gutter_enabled"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> <method name="set_line_as_hidden"> <return type="void"> </return> @@ -344,6 +372,9 @@ </method> </methods> <members> + <member name="breakpoint_gutter" type="bool" setter="set_breakpoint_gutter_enabled" getter="is_breakpoint_gutter_enabled"> + If [code]true[/code] the breakpoint gutter is visible. + </member> <member name="caret_blink" type="bool" setter="cursor_set_blink_enabled" getter="cursor_get_blink_enabled"> If [code]true[/code] the caret (visual cursor) blinks. </member> diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 293684f48e..42d5ea120e 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* animation_track_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_track_editor.h" #include "animation_track_editor_plugins.h" #include "editor/animation_bezier_editor.h" @@ -25,6 +55,7 @@ public: ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector); + ClassDB::bind_method("get_root_path", &AnimationTrackKeyEdit::get_root_path); } //PopupDialog *ke_dialog; @@ -612,6 +643,10 @@ public: _change_notify(); } + Node *get_root_path() { + return root_path; + } + AnimationTrackKeyEdit() { hidden = true; key_ofs = 0; @@ -714,6 +749,7 @@ void AnimationTimelineEdit::_notification(int p_what) { len_hb->set_position(Vector2(get_size().width - get_buttons_width(), 0)); len_hb->set_size(Size2(get_buttons_width(), get_size().height)); } + if (p_what == NOTIFICATION_DRAW) { int key_range = get_size().width - get_buttons_width() - get_name_limit(); @@ -1665,7 +1701,7 @@ void AnimationTrackEdit::_path_entered(const String &p_text) { String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (check_rect.has_point(p_pos)) { - return TTR("Toggle this track on/off"); + return TTR("Toggle this track on/off."); } if (path_rect.has_point(p_pos)) { @@ -1673,7 +1709,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } if (update_mode_rect.has_point(p_pos)) { - return TTR("Update Mode (How this property is set)."); + return TTR("Update Mode (How this property is set)"); } if (interp_mode_rect.has_point(p_pos)) { @@ -1681,11 +1717,11 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } if (loop_mode_rect.has_point(p_pos)) { - return TTR("Loop Wrap Mode (Interpolate end with beginning on loop"); + return TTR("Loop Wrap Mode (Interpolate end with beginning on loop)"); } if (remove_rect.has_point(p_pos)) { - return TTR("Remove this track"); + return TTR("Remove this track."); } if (p_pos.x >= timeline->get_name_limit() && p_pos.x <= (get_size().width - timeline->get_buttons_width())) { @@ -2437,12 +2473,16 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { if (animation.is_valid()) { animation->connect("changed", this, "_animation_changed"); + hscroll->show(); + edit->set_disabled(false); step->set_block_signals(true); step->set_value(animation->get_step()); step->set_block_signals(false); step->set_read_only(false); snap->set_disabled(false); } else { + hscroll->hide(); + edit->set_disabled(true); step->set_block_signals(true); step->set_value(0); step->set_block_signals(false); @@ -3418,7 +3458,6 @@ MenuButton *AnimationTrackEditor::get_edit_menu() { void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - zoom_icon->set_texture(get_icon("Zoom", "EditorIcons")); snap->set_icon(get_icon("Snap", "EditorIcons")); view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); @@ -3431,7 +3470,6 @@ void AnimationTrackEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - update_keying(); EditorNode::get_singleton()->update_keying(); emit_signal("keying_changed"); @@ -4810,9 +4848,10 @@ AnimationTrackEditor::AnimationTrackEditor() { timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE); hscroll = memnew(HScrollBar); - timeline_vbox->add_child(hscroll); hscroll->share(timeline); + hscroll->hide(); hscroll->connect("value_changed", this, "_update_scroll"); + timeline_vbox->add_child(hscroll); timeline->set_hscroll(hscroll); track_vbox = memnew(VBoxContainer); @@ -4855,6 +4894,7 @@ AnimationTrackEditor::AnimationTrackEditor() { step->set_step(0.01); step->set_hide_slider(true); step->set_custom_minimum_size(Size2(100, 0) * EDSCALE); + step->set_tooltip(TTR("Animation step value.")); bottom_hb->add_child(step); step->connect("value_changed", this, "_update_step"); step->set_read_only(true); @@ -4877,6 +4917,8 @@ AnimationTrackEditor::AnimationTrackEditor() { edit = memnew(MenuButton); edit->set_text(TTR("Edit")); edit->set_flat(false); + edit->set_disabled(true); + edit->set_tooltip(TTR("Animation properties.")); edit->get_popup()->add_item(TTR("Copy Tracks"), EDIT_COPY_TRACKS); edit->get_popup()->add_item(TTR("Paste Tracks"), EDIT_PASTE_TRACKS); edit->get_popup()->add_separator(); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 665ce7658f..6aec6135f1 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -95,7 +95,7 @@ void FindReplaceBar::_notification(int p_what) { set_process_unhandled_input(is_visible_in_tree()); if (is_visible_in_tree()) { - call_deferred("_update_size"); + _update_size(); } } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { @@ -775,7 +775,7 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line")); text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink")); text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed")); - text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter")); + text_editor->set_breakpoint_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter")); text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding")); text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding")); text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/word_wrap")); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 36978e37a5..a8cbf52cd2 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -262,13 +262,17 @@ void CreateDialog::_update_search() { if (base_type == "Node" && type.begins_with("Editor")) continue; // do not show editor nodes - if (base_type == "Resource" && ClassDB::is_parent_class(type, "PluginScript")) - // PluginScript must be initialized before use, which is not possible here - continue; - if (!ClassDB::can_instance(type)) continue; // can't create what can't be instanced + bool skip = false; + for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) { + if (ClassDB::is_parent_class(type, E->get())) + skip = true; + } + if (skip) + continue; + if (search_box->get_text() == "") { add_type(type, types, root, &to_select); } else { @@ -706,4 +710,7 @@ CreateDialog::CreateDialog() { help_bit = memnew(EditorHelpBit); vbc->add_margin_child(TTR("Description:"), help_bit); help_bit->connect("request_hide", this, "_closed"); + + type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here + type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix. } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index da17dcbe89..f8eec231a4 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -58,6 +58,7 @@ class CreateDialog : public ConfirmationDialog { String preferred_search_result_type; EditorHelpBit *help_bit; List<StringName> type_list; + Set<StringName> type_blacklist; void _item_selected(); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 79746dcb5a..d8ce2bc024 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1572,7 +1572,7 @@ void EditorInspector::_clear() { void EditorInspector::refresh() { - if (refresh_countdown > 0) + if (refresh_countdown > 0 || changing) return; refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"); } @@ -1773,9 +1773,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } undo_redo->add_do_method(this, "emit_signal", _prop_edited, p_name); undo_redo->add_undo_method(this, "emit_signal", _prop_edited, p_name); - changing++; undo_redo->commit_action(); - changing--; } if (editor_property_map.has(p_name)) { @@ -1785,9 +1783,17 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } } -void EditorInspector::_property_changed(const String &p_path, const Variant &p_value) { +void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, bool changing) { + + // The "changing" variable must be true for properties that trigger events as typing occurs, + // like "text_changed" signal. eg: Text property of Label, Button, RichTextLabel, etc. + if (changing) + this->changing++; _edit_set(p_path, p_value, false, ""); + + if (changing) + this->changing--; } void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) { @@ -1961,8 +1967,8 @@ void EditorInspector::_changed_callback(Object *p_changed, const char *p_prop) { void EditorInspector::_bind_methods() { + ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed, DEFVAL(false)); ClassDB::bind_method("_multiple_properties_changed", &EditorInspector::_multiple_properties_changed); - ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed); ClassDB::bind_method("_property_changed_update_all", &EditorInspector::_property_changed_update_all); ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change); @@ -1974,6 +1980,7 @@ void EditorInspector::_bind_methods() { ClassDB::bind_method("_property_selected", &EditorInspector::_property_selected); ClassDB::bind_method("_resource_selected", &EditorInspector::_resource_selected); ClassDB::bind_method("_object_id_selected", &EditorInspector::_object_id_selected); + ClassDB::bind_method("refresh", &EditorInspector::refresh); ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop"))); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 2a88be656a..383cb458ec 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -245,7 +245,7 @@ class EditorInspector : public ScrollContainer { bool read_only; bool keying; - int refresh_countdown; + float refresh_countdown; bool update_tree_pending; StringName _prop_edited; StringName property_selected; @@ -256,7 +256,7 @@ class EditorInspector : public ScrollContainer { void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field); - void _property_changed(const String &p_path, const Variant &p_value); + void _property_changed(const String &p_path, const Variant &p_value, bool changing = false); void _property_changed_update_all(const String &p_path, const Variant &p_value); void _multiple_properties_changed(Vector<String> p_paths, Array p_values); void _property_keyed(const String &p_path); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6084332dfb..2ac0364778 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3033,6 +3033,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorInspectorPlugin>(); ClassDB::register_class<EditorProperty>(); ClassDB::register_class<AnimationTrackEditPlugin>(); + ClassDB::register_class<ScriptCreateDialog>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? ClassDB::register_class<EditorScenePostImport>(); @@ -4395,6 +4396,8 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process); + ClassDB::bind_method("get_script_create_dialog", &EditorNode::get_script_create_dialog); + ClassDB::bind_method("_sources_changed", &EditorNode::_sources_changed); ClassDB::bind_method("_fs_changed", &EditorNode::_fs_changed); ClassDB::bind_method("_dock_select_draw", &EditorNode::_dock_select_draw); diff --git a/editor/editor_node.h b/editor/editor_node.h index 4241520b30..a5f975784c 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -598,6 +598,7 @@ public: EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } EditorInspector *get_inspector() { return inspector_dock->get_inspector(); } Container *get_inspector_dock_addon_area() { return inspector_dock->get_addon_area(); } + ScriptCreateDialog *get_script_create_dialog() { return scene_tree_dock->get_script_create_dialog(); } ProjectSettingsEditor *get_project_settings() { return project_settings; } diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 1582b54c8d..843267d673 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -719,6 +719,10 @@ EditorInterface *EditorPlugin::get_editor_interface() { return EditorInterface::get_singleton(); } +ScriptCreateDialog *EditorPlugin::get_script_create_dialog() { + return EditorNode::get_singleton()->get_script_create_dialog(); +} + void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container); @@ -755,6 +759,7 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled); ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface); + ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index fcc74cb1e9..72e21b2f7f 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -34,6 +34,7 @@ #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" @@ -195,6 +196,7 @@ public: virtual bool build(); // builds with external tools. Returns true if safe to continue running scene. EditorInterface *get_editor_interface(); + ScriptCreateDialog *get_script_create_dialog(); int update_overlays() const; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9902d8d3e7..064569dea0 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -50,7 +50,7 @@ void EditorPropertyText::_text_changed(const String &p_string) { if (updating) return; - emit_signal("property_changed", get_edited_property(), p_string); + emit_signal("property_changed", get_edited_property(), p_string, true); } void EditorPropertyText::update_property() { @@ -78,12 +78,12 @@ EditorPropertyText::EditorPropertyText() { void EditorPropertyMultilineText::_big_text_changed() { text->set_text(big_text->get_text()); - emit_signal("property_changed", get_edited_property(), big_text->get_text()); + emit_signal("property_changed", get_edited_property(), big_text->get_text(), true); } void EditorPropertyMultilineText::_text_changed() { - emit_signal("property_changed", get_edited_property(), text->get_text()); + emit_signal("property_changed", get_edited_property(), text->get_text(), true); } void EditorPropertyMultilineText::_open_big_text() { @@ -1522,8 +1522,15 @@ EditorPropertyColor::EditorPropertyColor() { void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { + NodePath path = p_path; Node *base_node = Object::cast_to<Node>(get_edited_object()); - emit_signal("property_changed", get_edited_property(), base_node->get_path().rel_path_to(p_path)); + if (base_node == NULL && get_edited_object()->has_method("get_root_path")) { + base_node = get_edited_object()->call("get_root_path"); + } + if (base_node) { // for AnimationTrackKeyEdit + path = base_node->get_path().rel_path_to(p_path); + } + emit_signal("property_changed", get_edited_property(), path); update_property(); } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 0852a42794..f212b60c8c 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -56,6 +56,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } else { grabbing_spinner_attempt = true; + grabbing_spinner_dist_cache = 0; grabbing_spinner = false; grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position(); } @@ -69,13 +70,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos); update(); } else { - Rect2 gr = get_global_rect(); - value_input->set_text(get_text_value()); - value_input->set_position(gr.position); - value_input->set_size(gr.size); - value_input->call_deferred("show_modal"); - value_input->call_deferred("grab_focus"); - value_input->call_deferred("select_all"); + _focus_entered(); } grabbing_spinner = false; @@ -89,21 +84,27 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { if (grabbing_spinner_attempt) { - if (!grabbing_spinner) { + double diff_x = mm->get_relative().x; + if (mm->get_shift() && grabbing_spinner) { + diff_x *= 0.1; + } + grabbing_spinner_dist_cache += diff_x; + + if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4) { Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED); grabbing_spinner = true; + } else { + if (mm->get_control() || updown_offset != -1) { + set_value(Math::round(get_value())); + if (ABS(grabbing_spinner_dist_cache) > 6) { + set_value(get_value() + SGN(grabbing_spinner_dist_cache)); + grabbing_spinner_dist_cache = 0; + } + } else { + set_value(get_value() + get_step() * grabbing_spinner_dist_cache * 10); + grabbing_spinner_dist_cache = 0; + } } - - double v = get_value(); - - double diff_x = mm->get_relative().x; - diff_x = Math::pow(ABS(diff_x), 1.8) * SGN(diff_x); - diff_x *= 0.1; - - v += diff_x * get_step(); - - set_value(v); - } else if (updown_offset != -1) { bool new_hover = (mm->get_position().x > updown_offset); if (new_hover != hover_updown) { @@ -115,25 +116,10 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->is_action("ui_accept")) { - Rect2 gr = get_global_rect(); - value_input->set_text(get_text_value()); - value_input->set_position(gr.position); - value_input->set_size(gr.size); - value_input->call_deferred("show_modal"); - value_input->call_deferred("grab_focus"); - value_input->call_deferred("select_all"); + _focus_entered(); } } -void EditorSpinSlider::_value_input_closed() { - set_value(value_input->get_text().to_double()); -} - -void EditorSpinSlider::_value_input_entered(const String &p_text) { - set_value(p_text.to_double()); - value_input->hide(); -} - void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; @@ -225,7 +211,7 @@ void EditorSpinSlider::_notification(int p_what) { Rect2 grabber_rect = Rect2(ofs + gofs, svofs + 1, grabber_w, 2 * EDSCALE); draw_rect(grabber_rect, c); - bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner; + bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input->is_visible(); if (grabber->is_visible() != display_grabber) { if (display_grabber) { grabber->show(); @@ -263,6 +249,12 @@ void EditorSpinSlider::_notification(int p_what) { mouse_over_spin = false; update(); } + if (p_what == NOTIFICATION_FOCUS_ENTER) { + if (!Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) { + _focus_entered(); + } + value_input_just_closed = false; + } } Size2 EditorSpinSlider::get_minimum_size() const { @@ -294,6 +286,34 @@ String EditorSpinSlider::get_label() const { return label; } +//text_entered signal +void EditorSpinSlider::_value_input_entered(const String &p_text) { + value_input_just_closed = true; + value_input->hide(); +} + +//modal_closed signal +void EditorSpinSlider::_value_input_closed() { + set_value(value_input->get_text().to_double()); + value_input_just_closed = true; +} + +//focus_exited signal +void EditorSpinSlider::_value_focus_exited() { + set_value(value_input->get_text().to_double()); + // focus is not on the same element after the vlalue_input was exited + // -> focus is on next element + // -> TAB was pressed + // -> modal_close was not called + // -> need to close/hide manually + if (!value_input_just_closed) { //value_input_just_closed should do the same + value_input->hide(); + //tab was pressed + } else { + //enter, click, esc + } +} + void EditorSpinSlider::_grabber_mouse_entered() { mouse_over_grabber = true; update(); @@ -314,6 +334,18 @@ bool EditorSpinSlider::is_read_only() const { return read_only; } +void EditorSpinSlider::_focus_entered() { + Rect2 gr = get_global_rect(); + value_input->set_text(get_text_value()); + value_input->set_position(gr.position); + value_input->set_size(gr.size); + value_input->call_deferred("show_modal"); + value_input->call_deferred("grab_focus"); + value_input->call_deferred("select_all"); + value_input->set_focus_next(find_next_valid_focus()->get_path()); + value_input->set_focus_previous(find_prev_valid_focus()->get_path()); +} + void EditorSpinSlider::_bind_methods() { ClassDB::bind_method(D_METHOD("set_label", "label"), &EditorSpinSlider::set_label); ClassDB::bind_method(D_METHOD("get_label"), &EditorSpinSlider::get_label); @@ -327,6 +359,7 @@ void EditorSpinSlider::_bind_methods() { ClassDB::bind_method(D_METHOD("_grabber_gui_input"), &EditorSpinSlider::_grabber_gui_input); ClassDB::bind_method(D_METHOD("_value_input_closed"), &EditorSpinSlider::_value_input_closed); ClassDB::bind_method(D_METHOD("_value_input_entered"), &EditorSpinSlider::_value_input_entered); + ClassDB::bind_method(D_METHOD("_value_focus_exited"), &EditorSpinSlider::_value_focus_exited); ADD_PROPERTY(PropertyInfo(Variant::STRING, "label"), "set_label", "get_label"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "read_only"), "set_read_only", "is_read_only"); @@ -336,7 +369,7 @@ EditorSpinSlider::EditorSpinSlider() { grabbing_spinner_attempt = false; grabbing_spinner = false; - + grabbing_spinner_dist_cache = 0; set_focus_mode(FOCUS_ALL); updown_offset = -1; hover_updown = false; @@ -358,6 +391,8 @@ EditorSpinSlider::EditorSpinSlider() { value_input->hide(); value_input->connect("modal_closed", this, "_value_input_closed"); value_input->connect("text_entered", this, "_value_input_entered"); + value_input->connect("focus_exited", this, "_value_focus_exited"); + value_input_just_closed = false; hide_slider = false; read_only = false; } diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 37d8a5f128..5316c0264a 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -57,14 +57,16 @@ class EditorSpinSlider : public Range { bool grabbing_spinner; bool read_only; + float grabbing_spinner_dist_cache; Vector2 grabbing_spinner_mouse_pos; LineEdit *value_input; + bool value_input_just_closed; void _grabber_gui_input(const Ref<InputEvent> &p_event); void _value_input_closed(); void _value_input_entered(const String &); - + void _value_focus_exited(); bool hide_slider; protected: @@ -73,6 +75,7 @@ protected: static void _bind_methods(); void _grabber_mouse_entered(); void _grabber_mouse_exited(); + void _focus_entered(); public: String get_text_value() const; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9a0432ad58..eebf1b6ab8 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -930,6 +930,21 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> & } } +void FileSystemDock::_update_project_settings_after_move(const Map<String, String> &p_renames) const { + + // Find all project settings of type FILE and replace them if needed + const Map<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info(); + for (const Map<StringName, PropertyInfo>::Element *E = prop_info.front(); E; E = E->next()) { + if (E->get().hint == PROPERTY_HINT_FILE) { + String old_path = GLOBAL_GET(E->key()); + if (p_renames.has(old_path)) { + ProjectSettings::get_singleton()->set_setting(E->key(), p_renames[old_path]); + } + }; + } + ProjectSettings::get_singleton()->save(); +} + void FileSystemDock::_update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const { Vector<String> favorite_dirs = EditorSettings::get_singleton()->get_favorite_dirs(); @@ -1012,6 +1027,7 @@ void FileSystemDock::_rename_operation_confirm() { _try_move_item(to_rename, new_path, file_renames, folder_renames); _update_dependencies_after_move(file_renames); _update_resource_paths_after_move(file_renames); + _update_project_settings_after_move(file_renames); _update_favorite_dirs_list_after_move(folder_renames); //Rescan everything @@ -1054,7 +1070,40 @@ void FileSystemDock::_duplicate_operation_confirm() { _rescan(); } -void FileSystemDock::_move_operation_confirm(const String &p_to_path) { +void FileSystemDock::_move_with_overwrite() { + _move_operation_confirm(to_move_path, true); +} + +bool FileSystemDock::_check_existing() { + String &p_to_path = to_move_path; + for (int i = 0; i < to_move.size(); i++) { + String ol_pth = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; + String p_new_path = p_to_path.plus_file(ol_pth.get_file()); + FileOrFolder p_item = to_move[i]; + + String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/"); + String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/"); + + if (p_item.is_file && FileAccess::exists(new_path)) { + return false; + } else if (!p_item.is_file && DirAccess::exists(new_path)) { + return false; + } + } + return true; +} + +void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool overwrite) { + if (!overwrite) { + to_move_path = p_to_path; + bool can_move = _check_existing(); + if (!can_move) { + //ask to do something + overwrite_dialog->popup_centered_minsize(); + overwrite_dialog->grab_focus(); + return; + } + } Map<String, String> file_renames; Map<String, String> folder_renames; @@ -1071,6 +1120,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path) { if (is_moved) { _update_dependencies_after_move(file_renames); _update_resource_paths_after_move(file_renames); + _update_project_settings_after_move(file_renames); _update_favorite_dirs_list_after_move(folder_renames); print_line("call rescan!"); @@ -1813,6 +1863,7 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option); ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &FileSystemDock::_make_dir_confirm); ClassDB::bind_method(D_METHOD("_move_operation_confirm"), &FileSystemDock::_move_operation_confirm); + ClassDB::bind_method(D_METHOD("_move_with_overwrite"), &FileSystemDock::_move_with_overwrite); ClassDB::bind_method(D_METHOD("_rename_operation_confirm"), &FileSystemDock::_rename_operation_confirm); ClassDB::bind_method(D_METHOD("_duplicate_operation_confirm"), &FileSystemDock::_duplicate_operation_confirm); @@ -2004,6 +2055,12 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { rename_dialog->register_text_enter(rename_dialog_text); rename_dialog->connect("confirmed", this, "_rename_operation_confirm"); + overwrite_dialog = memnew(ConfirmationDialog); + overwrite_dialog->set_text(TTR("There is already file or folder with the same name in this location.")); + overwrite_dialog->get_ok()->set_text(TTR("Overwrite")); + add_child(overwrite_dialog); + overwrite_dialog->connect("confirmed", this, "_move_with_overwrite"); + duplicate_dialog = memnew(ConfirmationDialog); VBoxContainer *duplicate_dialog_vb = memnew(VBoxContainer); duplicate_dialog->add_child(duplicate_dialog_vb); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 53f77b64f9..e8ab803cca 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -129,6 +129,7 @@ private: LineEdit *duplicate_dialog_text; ConfirmationDialog *make_dir_dialog; LineEdit *make_dir_dialog_text; + ConfirmationDialog *overwrite_dialog; ScriptCreateDialog *make_script_dialog_text; class FileOrFolder { @@ -146,6 +147,7 @@ private: FileOrFolder to_rename; FileOrFolder to_duplicate; Vector<FileOrFolder> to_move; + String to_move_path; Vector<String> history; int history_pos; @@ -187,11 +189,14 @@ private: void _update_dependencies_after_move(const Map<String, String> &p_renames) const; void _update_resource_paths_after_move(const Map<String, String> &p_renames) const; void _update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const; + void _update_project_settings_after_move(const Map<String, String> &p_renames) const; void _make_dir_confirm(); void _rename_operation_confirm(); void _duplicate_operation_confirm(); - void _move_operation_confirm(const String &p_to_path); + void _move_with_overwrite(); + bool _check_existing(); + void _move_operation_confirm(const String &p_to_path, bool overwrite = false); void _file_option(int p_option); void _folder_option(int p_option); diff --git a/editor/icons/icon_script_create_dialog.svg b/editor/icons/icon_script_create_dialog.svg new file mode 100644 index 0000000000..27d6c47d49 --- /dev/null +++ b/editor/icons/icon_script_create_dialog.svg @@ -0,0 +1,10 @@ +<svg width="17.067" height="17.067" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1036.4)"> +<path transform="translate(0 1036.4)" d="m6 1v1c-0.55228 0-1 0.44772-1 1v10h-1v-2h-2v2c2.826e-4 0.35698 0.19084 0.68674 0.5 0.86523 0.15194 0.088045 0.32439 0.13452 0.5 0.13477v1h6v-5l3-2v-3h3v-2c0-1.1046-0.89543-2-2-2z" fill="#a5efac"/> +<path transform="translate(0 1036.4)" d="m6 1c-1.1046 0-2 0.89543-2 2v7h-3v3c0 1.1046 0.89543 2 2 2s2-0.89543 2-2v-10c0-0.55228 0.44772-1 1-1s1 0.44772 1 1v3h5v-1h-4v-2c0-1.1046-0.89543-2-2-2zm-4 10h2v2c0 0.55228-0.44772 1-1 1s-1-0.44772-1-1z" fill="#87e29f"/> +<circle cx="3" cy="1048.4" r="0" fill="#e0e0e0"/> +<ellipse cx="12" cy="1048.4" rx=".5" ry="3" fill="#87e29f"/> +<ellipse transform="rotate(60)" cx="913.91" cy="513.79" rx=".5" ry="3" fill="#87e29f"/> +<ellipse transform="rotate(120)" cx="901.91" cy="-534.57" rx=".5" ry="3" fill="#87e29f"/> +</g> +</svg> diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 91644492c3..a5ad34f377 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -130,7 +130,9 @@ void EditorSceneImporter::_bind_methods() { ///////////////////////////////// void EditorScenePostImport::_bind_methods() { - BIND_VMETHOD(MethodInfo("post_import", PropertyInfo(Variant::OBJECT, "scene"))); + BIND_VMETHOD(MethodInfo(Variant::OBJECT, "post_import", PropertyInfo(Variant::OBJECT, "scene"))); + ClassDB::bind_method(D_METHOD("get_source_folder"), &EditorScenePostImport::get_source_folder); + ClassDB::bind_method(D_METHOD("get_source_file"), &EditorScenePostImport::get_source_file); } Node *EditorScenePostImport::post_import(Node *p_scene) { @@ -141,6 +143,21 @@ Node *EditorScenePostImport::post_import(Node *p_scene) { return p_scene; } +String EditorScenePostImport::get_source_folder() const { + + return source_folder; +} + +String EditorScenePostImport::get_source_file() const { + + return source_file; +} + +void EditorScenePostImport::init(const String &p_source_folder, const String &p_source_file) { + source_folder = p_source_folder; + source_file = p_source_file; +} + EditorScenePostImport::EditorScenePostImport() { } @@ -1370,6 +1387,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p } if (post_import_script.is_valid()) { + post_import_script->init(base_path, p_source_file); scene = post_import_script->post_import(scene); if (!scene) { EditorNode::add_io_error(TTR("Error running post-import script:") + " " + post_import_script_path); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 9c3ec7a29b..2bde9432fc 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -75,11 +75,17 @@ class EditorScenePostImport : public Reference { GDCLASS(EditorScenePostImport, Reference); + String source_folder; + String source_file; + protected: static void _bind_methods(); public: + String get_source_folder() const; + String get_source_file() const; virtual Node *post_import(Node *p_scene); + virtual void init(const String &p_scene_folder, const String &p_scene_path); EditorScenePostImport(); }; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 7d4415ba9e..23eeef9f20 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1697,6 +1697,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay //tool_anim->get_popup()->add_separator(); //tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM); + hb->add_child(memnew(VSeparator)); + track_editor = memnew(AnimationTrackEditor); hb->add_child(track_editor->get_edit_menu()); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 48ee011fc1..1d20c63969 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4481,7 +4481,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_insert_button->set_flat(true); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY)); - key_insert_button->set_tooltip(TTR("Insert Keys")); + key_insert_button->set_tooltip(TTR("Insert keys.")); key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT)); animation_hb->add_child(key_insert_button); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 67f506fdda..ad12add53f 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -72,9 +72,9 @@ public: class ScriptEditorDebugger; -class ScriptEditorBase : public Control { +class ScriptEditorBase : public VBoxContainer { - GDCLASS(ScriptEditorBase, Control); + GDCLASS(ScriptEditorBase, VBoxContainer); protected: static void _bind_methods(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 345c7c06eb..ffc2203475 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1619,6 +1619,7 @@ ScriptTextEditor::ScriptTextEditor() { code_editor->set_code_complete_func(_code_complete_scripts, this); code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled"); code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol"); + code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); update_settings(); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index ed13e063bb..17deab25de 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -215,6 +215,9 @@ public: void replace_node(Node *p_node, Node *p_by_node); void open_script_dialog(Node *p_for_node); + + ScriptCreateDialog *get_script_create_dialog() { return script_create_dialog; } + SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data); }; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 57a003060e..24c4ba4cb7 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -582,6 +582,9 @@ void ScriptCreateDialog::_bind_methods() { ClassDB::bind_method("_path_changed", &ScriptCreateDialog::_path_changed); ClassDB::bind_method("_path_entered", &ScriptCreateDialog::_path_entered); ClassDB::bind_method("_template_changed", &ScriptCreateDialog::_template_changed); + + ClassDB::bind_method(D_METHOD("config", "inherits", "path"), &ScriptCreateDialog::config); + ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); } diff --git a/main/main.cpp b/main/main.cpp index e2b3bb8e6f..23acb60c89 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -715,6 +715,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph memdelete(sdr); } else { script_debugger = sdr; + sdr->set_allow_focus_steal_pid(allow_focus_steal_pid); } } else if (debug_mode == "local") { @@ -1179,10 +1180,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) { #endif - if (allow_focus_steal_pid) { - OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid); - } - MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); register_platform_apis(); diff --git a/methods.py b/methods.py index 227a17d312..33d503a41a 100644 --- a/methods.py +++ b/methods.py @@ -937,6 +937,11 @@ def android_add_res_dir(self, subpath): if (base_path not in self.android_res_dirs): self.android_res_dirs.append(base_path) +def android_add_asset_dir(self, subpath): + base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath + if (base_path not in self.android_asset_dirs): + self.android_asset_dirs.append(base_path) + def android_add_aidl_dir(self, subpath): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath if (base_path not in self.android_aidl_dirs): diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 5c834966c5..85c36647a1 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -34,7 +34,7 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) { - if (!codegen.function_node || codegen.function_node->_static) + if (codegen.function_node && codegen.function_node->_static) return false; if (codegen.stack_identifiers.has(p_name)) diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index cccf09c58e..ce91e7dff3 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -105,6 +105,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) { "prints", "printerr", "printraw", + "print_debug", "var2str", "str2var", "var2bytes", @@ -702,6 +703,23 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ r_ret = Variant(); } break; + case TEXT_PRINT_DEBUG: { + String str; + for (int i = 0; i < p_arg_count; i++) { + + str += p_args[i]->operator String(); + } + + ScriptLanguage *script = GDScriptLanguage::get_singleton(); + if (script->debug_get_stack_level_count() > 0) { + str += "\n\t"; + str += "At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)); // + " in function '" + script->debug_get_stack_level_function(0) + "'"; + } + + //str+="\n"; + print_line(str); + r_ret = Variant(); + } break; case VAR_TO_STR: { VALIDATE_ARG_COUNT(1); String vars; @@ -1733,6 +1751,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { return mi; } break; + case TEXT_PRINT_DEBUG: { + + MethodInfo mi("print_debug"); + mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; + return mi; + + } break; case VAR_TO_STR: { MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var")); mi.return_val.type = Variant::STRING; diff --git a/modules/gdscript/gdscript_functions.h b/modules/gdscript/gdscript_functions.h index 899a7ebd25..a29f06e839 100644 --- a/modules/gdscript/gdscript_functions.h +++ b/modules/gdscript/gdscript_functions.h @@ -96,6 +96,7 @@ public: TEXT_PRINT_SPACED, TEXT_PRINTERR, TEXT_PRINTRAW, + TEXT_PRINT_DEBUG, VAR_TO_STR, STR_TO_VAR, VAR_TO_BYTES, diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index caf502de9d..62a6b96bb5 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -745,10 +745,9 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) { for (Map<Ref<CSharpScript>, Map<ObjectID, List<Pair<StringName, Variant> > > >::Element *E = to_reload.front(); E; E = E->next()) { Ref<CSharpScript> scr = E->key(); - scr->signals_invalidated = true; scr->exports_invalidated = true; + scr->signals_invalidated = true; scr->reload(p_soft_reload); - scr->update_signals(); scr->update_exports(); //restore state if saved @@ -1579,37 +1578,33 @@ bool CSharpScript::_update_exports() { return false; } -bool CSharpScript::_update_signals() { - if (!valid) - return false; - - bool changed = false; - - if (signals_invalidated) { - signals_invalidated = false; +void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class) { - GDMonoClass *top = script_class; + // no need to load the script's signals more than once + if (!signals_invalidated) { + return; + } - _signals.clear(); - changed = true; // TODO Do a real check for change + // make sure this classes signals are empty when loading for the first time + _signals.clear(); - while (top && top != native) { - const Vector<GDMonoClass *> &delegates = top->get_all_delegates(); - for (int i = delegates.size() - 1; i >= 0; --i) { - Vector<Argument> parameters; + GDMonoClass *top = p_class; + while (top && top != p_native_class) { + const Vector<GDMonoClass *> &delegates = top->get_all_delegates(); + for (int i = delegates.size() - 1; i >= 0; --i) { + Vector<Argument> parameters; - GDMonoClass *delegate = delegates[i]; + GDMonoClass *delegate = delegates[i]; - if (_get_signal(top, delegate, parameters)) { - _signals[delegate->get_name()] = parameters; - } + if (_get_signal(top, delegate, parameters)) { + _signals[delegate->get_name()] = parameters; } - - top = top->get_parent_class(); } + + top = top->get_parent_class(); } - return changed; + signals_invalidated = false; } bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms) { @@ -1848,6 +1843,8 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class) { top = top->get_parent_class(); } + script->load_script_signals(script->script_class, script->native); + return script; } @@ -1973,7 +1970,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this)); placeholders.insert(si); _update_exports(); - _update_signals(); return si; #else return NULL; @@ -1992,8 +1988,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { ERR_FAIL_V(NULL); } - update_signals(); - if (native) { String native_name = native->get_name(); if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { @@ -2114,6 +2108,8 @@ Error CSharpScript::reload(bool p_keep_state) { top->fetch_methods_with_godot_api_checks(native); top = top->get_parent_class(); } + + load_script_signals(script_class, native); } return OK; @@ -2173,10 +2169,6 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const { } } -void CSharpScript::update_signals() { - _update_signals(); -} - Ref<Script> CSharpScript::get_base_script() const { // TODO search in metadata file once we have it, not important any way? @@ -2241,9 +2233,10 @@ CSharpScript::CSharpScript() : #ifdef TOOLS_ENABLED source_changed_cache = false; exports_invalidated = true; - signals_invalidated = true; #endif + signals_invalidated = true; + _resource_path_changed(); #ifdef DEBUG_ENABLED diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index cae2bbf40a..df597ba776 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -111,7 +111,7 @@ class CSharpScript : public Script { void _clear(); - bool _update_signals(); + void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class); bool _get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms); bool _update_exports(); @@ -149,7 +149,6 @@ public: virtual bool has_script_signal(const StringName &p_signal) const; virtual void get_script_signal_list(List<MethodInfo> *r_signals) const; - virtual void update_signals(); /* TODO */ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const; virtual void get_script_property_list(List<PropertyInfo> *p_list) const; diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs index 0d20a12563..a89dfe5f27 100644 --- a/modules/mono/glue/cs_files/Mathf.cs +++ b/modules/mono/glue/cs_files/Mathf.cs @@ -138,19 +138,9 @@ namespace Godot return (real_t)Math.Floor(s); } - public static real_t Fposmod(real_t x, real_t y) - { - if (x >= 0f) - { - return x % y; - } - - return y - -x % y; - } - public static real_t InverseLerp(real_t from, real_t to, real_t weight) { - return (Clamp(weight, 0f, 1f) - from) / (to - from); + return (weight - from) / (to - from); } public static bool IsInf(real_t s) @@ -165,7 +155,7 @@ namespace Godot public static real_t Lerp(real_t from, real_t to, real_t weight) { - return from + (to - from) * Clamp(weight, 0f, 1f); + return from + (to - from) * weight; } public static real_t Log(real_t s) @@ -210,6 +200,32 @@ namespace Godot return new Vector2(r * Cos(th), r * Sin(th)); } + /// <summary> + /// Performs a canonical Modulus operation, where the output is on the range [0, b). + /// </summary> + public static real_t PosMod(real_t a, real_t b) + { + real_t c = a % b; + if ((c < 0 && b > 0) || (c > 0 && b < 0)) + { + c += b; + } + return c; + } + + /// <summary> + /// Performs a canonical Modulus operation, where the output is on the range [0, b). + /// </summary> + public static int PosMod(int a, int b) + { + int c = a % b; + if ((c < 0 && b > 0) || (c > 0 && b < 0)) + { + c += b; + } + return c; + } + public static real_t Pow(real_t x, real_t y) { return (real_t)Math.Pow(x, y); diff --git a/modules/mono/glue/cs_files/VERSION.txt b/modules/mono/glue/cs_files/VERSION.txt index 00750edc07..b8626c4cff 100755 --- a/modules/mono/glue/cs_files/VERSION.txt +++ b/modules/mono/glue/cs_files/VERSION.txt @@ -1 +1 @@ -3 +4 diff --git a/platform/android/SCsub b/platform/android/SCsub index 8c08289932..a65dab9668 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -53,7 +53,7 @@ if len(env.android_flat_dirs) > 0: gradle_maven_flat_text = gradle_maven_flat_text[:-1] gradle_maven_flat_text += "\n\t}\n" - + gradle_maven_repos_text = "" gradle_maven_repos_text += gradle_maven_flat_text @@ -99,6 +99,9 @@ for x in env.android_jni_dirs: gradle_asset_dirs_text = "" +for x in env.android_asset_dirs: + gradle_asset_dirs_text += ",'" + x.replace("\\", "/") + "'" + gradle_default_config_text = "" minSdk = 18 diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 6e77369d65..b6dfc666b0 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -259,7 +259,6 @@ void AudioStreamPlayer2D::_notification(int p_what) { void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) { - ERR_FAIL_COND(!p_stream.is_valid()); AudioServer::get_singleton()->lock(); mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); @@ -271,14 +270,15 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) { setseek = -1; } - stream = p_stream; - stream_playback = p_stream->instance_playback(); + if (p_stream.is_valid()) { + stream = p_stream; + stream_playback = p_stream->instance_playback(); + } AudioServer::get_singleton()->unlock(); - if (stream_playback.is_null()) { + if (p_stream.is_valid() && stream_playback.is_null()) { stream.unref(); - ERR_FAIL_COND(stream_playback.is_null()); } } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index f1da375451..35c52a26c9 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -569,7 +569,6 @@ void AudioStreamPlayer3D::_notification(int p_what) { void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) { - ERR_FAIL_COND(!p_stream.is_valid()); AudioServer::get_singleton()->lock(); mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); @@ -581,14 +580,15 @@ void AudioStreamPlayer3D::set_stream(Ref<AudioStream> p_stream) { setseek = -1; } - stream = p_stream; - stream_playback = p_stream->instance_playback(); + if (p_stream.is_valid()) { + stream = p_stream; + stream_playback = p_stream->instance_playback(); + } AudioServer::get_singleton()->unlock(); - if (stream_playback.is_null()) { + if (p_stream.is_valid() && stream_playback.is_null()) { stream.unref(); - ERR_FAIL_COND(stream_playback.is_null()); } } diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index b5c232c33c..40ec04e479 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -176,7 +176,6 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) { if (p_stream.is_valid() && stream_playback.is_null()) { stream.unref(); - ERR_FAIL_COND(stream_playback.is_null()); } } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fb0cec5212..068af42260 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1295,9 +1295,6 @@ Size2 Control::get_parent_area_size() const { void Control::_size_changed() { - if (!is_inside_tree()) - return; - Rect2 parent_rect = get_parent_anchorable_rect(); float margin_pos[4]; @@ -1334,7 +1331,7 @@ void Control::_size_changed() { } // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() - if (Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { + if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { new_size_cache = new_size_cache.round(); new_pos_cache = new_pos_cache.round(); } @@ -1344,17 +1341,19 @@ void Control::_size_changed() { data.pos_cache = new_pos_cache; data.size_cache = new_size_cache; - if (size_changed) { - notification(NOTIFICATION_RESIZED); - } - if (pos_changed || size_changed) { - item_rect_changed(size_changed); - _change_notify_margins(); - _notify_transform(); - } + if (is_inside_tree()) { + if (size_changed) { + notification(NOTIFICATION_RESIZED); + } + if (pos_changed || size_changed) { + item_rect_changed(size_changed); + _change_notify_margins(); + _notify_transform(); + } - if (pos_changed && !size_changed) { - _update_canvas_item_transform(); //move because it won't be updated + if (pos_changed && !size_changed) { + _update_canvas_item_transform(); //move because it won't be updated + } } } @@ -1386,7 +1385,7 @@ void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bo } update(); - _change_notify(); + _change_notify("anchor"); } void Control::_set_anchor(Margin p_margin, float p_anchor) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 0cd5219f8f..b71a4dd133 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -711,7 +711,8 @@ void LineEdit::_notification(int p_what) { if (selected) VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color); - drawer.draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color); + int yofs = y_ofs + (caret_height - font->get_height()) / 2; + drawer.draw_char(ci, Point2(x_ofs, yofs + font_ascent), cchar, next, selected ? font_color_selected : font_color); if (char_ofs == cursor_pos && draw_caret) { if (ime_text.length() == 0) { diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 4f72b5c6ed..c30fa96327 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -407,7 +407,7 @@ void TabContainer::_child_renamed_callback() { void TabContainer::add_child_notify(Node *p_child) { - Control::add_child_notify(p_child); + Container::add_child_notify(p_child); Control *c = Object::cast_to<Control>(p_child); if (!c) @@ -515,7 +515,7 @@ Control *TabContainer::get_current_tab_control() const { void TabContainer::remove_child_notify(Node *p_child) { - Control::remove_child_notify(p_child); + Container::remove_child_notify(p_child); call_deferred("_update_current_tab"); diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index 1afe5f7541..8a3c9d2bb2 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -31,11 +31,11 @@ #ifndef TAB_CONTAINER_H #define TAB_CONTAINER_H -#include "scene/gui/control.h" +#include "scene/gui/container.h" #include "scene/gui/popup.h" -class TabContainer : public Control { +class TabContainer : public Container { - GDCLASS(TabContainer, Control); + GDCLASS(TabContainer, Container); public: enum TabAlign { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 327c236f8c..218b5060a1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -966,12 +966,13 @@ void TextEdit::_notification(int p_what) { // draw line numbers if (cache.line_number_w) { + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; String fc = String::num(line + 1); while (fc.length() < line_number_char_count) { fc = line_num_padding + fc; } - cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + ofs_x, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color); + cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + ofs_x, yofs + cache.font->get_ascent()), fc, cache.line_number_color); } } @@ -1094,12 +1095,13 @@ void TextEdit::_notification(int p_what) { } if (brace_matching_enabled) { + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; if ((brace_open_match_line == line && brace_open_match_column == last_wrap_column + j) || (cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index && (brace_open_matching || brace_open_mismatch))) { if (brace_open_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } if ((brace_close_match_line == line && brace_close_match_column == last_wrap_column + j) || @@ -1107,7 +1109,7 @@ void TextEdit::_notification(int p_what) { if (brace_close_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } } @@ -1167,9 +1169,10 @@ void TextEdit::_notification(int p_what) { } if (str[j] >= 32) { - int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; + int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); if (underlined) { - draw_rect(Rect2(char_ofs + char_margin + ofs_x, ofs_y + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; @@ -1534,8 +1537,11 @@ void TextEdit::backspace_at_cursor() { if (is_line_hidden(cursor.line)) set_line_as_hidden(prev_line, true); - if (is_line_set_as_breakpoint(cursor.line)) + if (is_line_set_as_breakpoint(cursor.line)) { + if (!text.is_breakpoint(prev_line)) + emit_signal("breakpoint_toggled", prev_line); set_line_as_breakpoint(prev_line, true); + } if (auto_brace_completion_enabled && cursor.column > 0 && @@ -3310,22 +3316,37 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i ERR_FAIL_INDEX(p_line, text.size()); ERR_FAIL_COND(p_char < 0); - /* STEP 1 add spaces if the char is greater than the end of the line */ + /* STEP 1 remove \r from source text and separate in substrings */ + + Vector<String> substrings = p_text.replace("\r", "").split("\n"); + + /* STEP 2 fire breakpoint_toggled signals */ + + // Is this just a new empty line? + bool shift_first_line = p_char == 0 && p_text.replace("\r", "") == "\n"; + + int i = p_line + !shift_first_line; + int lines = substrings.size() - 1; + for (; i < text.size(); i++) { + if (text.is_breakpoint(i)) { + if ((i - lines < p_line || !text.is_breakpoint(i - lines)) || (i - lines == p_line && !shift_first_line)) + emit_signal("breakpoint_toggled", i); + if (i + lines >= text.size() || !text.is_breakpoint(i + lines)) + emit_signal("breakpoint_toggled", i + lines); + } + } + + /* STEP 3 add spaces if the char is greater than the end of the line */ while (p_char > text[p_line].length()) { text.set(p_line, text[p_line] + String::chr(' ')); } - /* STEP 2 separate dest string in pre and post text */ + /* STEP 4 separate dest string in pre and post text */ String preinsert_text = text[p_line].substr(0, p_char); String postinsert_text = text[p_line].substr(p_char, text[p_line].size()); - /* STEP 3 remove \r from source text and separate in substrings */ - - //buh bye \r and split - Vector<String> substrings = p_text.replace("\r", "").split("\n"); - for (int i = 0; i < substrings.size(); i++) { //insert the substrings @@ -3343,9 +3364,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i } } - // if we are just making a new empty line, reset breakpoints and hidden status - if (p_char == 0 && p_text.replace("\r", "") == "\n") { - + if (shift_first_line) { text.set_breakpoint(p_line + 1, text.is_breakpoint(p_line)); text.set_hidden(p_line + 1, text.is_hidden(p_line)); text.set_breakpoint(p_line, false); @@ -3401,11 +3420,20 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li String pre_text = text[p_from_line].substr(0, p_from_column); String post_text = text[p_to_line].substr(p_to_column, text[p_to_line].length()); - for (int i = p_from_line; i < p_to_line; i++) { + int lines = p_to_line - p_from_line; - text.remove(p_from_line + 1); + for (int i = p_from_line + 1; i < text.size(); i++) { + if (text.is_breakpoint(i)) { + if (i + lines >= text.size() || !text.is_breakpoint(i + lines)) + emit_signal("breakpoint_toggled", i); + if (i > p_to_line && (i - lines < 0 || !text.is_breakpoint(i - lines))) + emit_signal("breakpoint_toggled", i - lines); + } } + for (int i = p_from_line; i < p_to_line; i++) { + text.remove(p_from_line + 1); + } text.set(p_from_line, pre_text + post_text); text.set_line_wrap_amount(p_from_line, -1); @@ -4878,6 +4906,24 @@ void TextEdit::get_breakpoints(List<int> *p_breakpoints) const { } } +Array TextEdit::get_breakpoints_array() const { + + Array arr; + for (int i = 0; i < text.size(); i++) { + if (text.is_breakpoint(i)) + arr.append(i); + } + return arr; +} + +void TextEdit::remove_breakpoints() { + for (int i = 0; i < text.size(); i++) { + if (text.is_breakpoint(i)) + /* Should "breakpoint_toggled" be fired when breakpoints are removed this way? */ + text.set_breakpoint(i, false); + } +} + void TextEdit::set_line_as_hidden(int p_line, bool p_hidden) { ERR_FAIL_INDEX(p_line, text.size()); @@ -5547,7 +5593,17 @@ void TextEdit::_confirm_completion() { cursor_set_column(cursor.column - completion_base.length(), false); insert_text_at_cursor(completion_current); - if (completion_current.ends_with("(") && auto_brace_completion_enabled) { + // When inserted into the middle of an existing string, don't add an unnecessary quote + String line = text[cursor.line]; + CharType next_char = line[cursor.column]; + CharType last_completion_char = completion_current[completion_current.length() - 1]; + + if ((last_completion_char == '"' || last_completion_char == '\'') && + last_completion_char == next_char) { + _base_remove_text(cursor.line, cursor.column, cursor.line, cursor.column + 1); + } + + if (last_completion_char == '(' && auto_brace_completion_enabled) { insert_text_at_cursor(")"); cursor.column--; } @@ -5871,12 +5927,12 @@ void TextEdit::set_line_length_guideline_column(int p_column) { update(); } -void TextEdit::set_draw_breakpoint_gutter(bool p_draw) { +void TextEdit::set_breakpoint_gutter_enabled(bool p_draw) { draw_breakpoint_gutter = p_draw; update(); } -bool TextEdit::is_drawing_breakpoint_gutter() const { +bool TextEdit::is_breakpoint_gutter_enabled() const { return draw_breakpoint_gutter; } @@ -6059,6 +6115,8 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers); ClassDB::bind_method(D_METHOD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled); + ClassDB::bind_method(D_METHOD("set_breakpoint_gutter_enabled", "enable"), &TextEdit::set_breakpoint_gutter_enabled); + ClassDB::bind_method(D_METHOD("is_breakpoint_gutter_enabled"), &TextEdit::is_breakpoint_gutter_enabled); ClassDB::bind_method(D_METHOD("set_hiding_enabled", "enable"), &TextEdit::set_hiding_enabled); ClassDB::bind_method(D_METHOD("is_hiding_enabled"), &TextEdit::is_hiding_enabled); @@ -6097,11 +6155,15 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ClassDB::bind_method(D_METHOD("get_breakpoints"), &TextEdit::get_breakpoints_array); + ClassDB::bind_method(D_METHOD("remove_breakpoints"), &TextEdit::remove_breakpoints); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "breakpoint_gutter"), "set_breakpoint_gutter_enabled", "is_breakpoint_gutter_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_selected_font_color"), "set_override_selected_font_color", "is_overriding_selected_font_color"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 5c82d1ac20..586f4c8e93 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -473,6 +473,8 @@ public: void set_line_as_breakpoint(int p_line, bool p_breakpoint); bool is_line_set_as_breakpoint(int p_line) const; void get_breakpoints(List<int> *p_breakpoints) const; + Array get_breakpoints_array() const; + void remove_breakpoints(); void set_line_as_hidden(int p_line, bool p_hidden); bool is_line_hidden(int p_line) const; @@ -632,8 +634,8 @@ public: void set_show_line_length_guideline(bool p_show); void set_line_length_guideline_column(int p_column); - void set_draw_breakpoint_gutter(bool p_draw); - bool is_drawing_breakpoint_gutter() const; + void set_breakpoint_gutter_enabled(bool p_draw); + bool is_breakpoint_gutter_enabled() const; void set_breakpoint_gutter_width(int p_gutter_width); int get_breakpoint_gutter_width() const; diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index ae21775c55..4750e05633 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -30,8 +30,6 @@ #include "http_request.h" -#include "version.h" - void HTTPRequest::_redirect_request(const String &p_new_url) { } @@ -106,28 +104,10 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h validate_ssl = p_ssl_validate_domain; - bool has_user_agent = false; - bool has_accept = false; headers = p_custom_headers; request_data = p_request_data; - for (int i = 0; i < headers.size(); i++) { - - if (headers[i].findn("user-agent:") == 0) - has_user_agent = true; - if (headers[i].findn("Accept:") == 0) - has_accept = true; - } - - if (!has_user_agent) { - headers.push_back("User-Agent: GodotEngine/" + String(VERSION_FULL_BUILD) + " (" + OS::get_singleton()->get_name() + ")"); - } - - if (!has_accept) { - headers.push_back("Accept: */*"); - } - requesting = true; if (use_threads) { diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 1c837c0a8f..01302d4214 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1404,6 +1404,8 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_LEFT || mb->get_button_index() == BUTTON_WHEEL_RIGHT)); + Ref<InputEventPanGesture> pn = p_input; + cant_stop_me_now = pn.is_valid() || cant_stop_me_now; bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != NULL; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 3185fb6768..e57a2b68c8 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -2363,7 +2363,6 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const { int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset, float p_end_offset) { - print_line("really insert key? "); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); Track *t = tracks[p_track]; ERR_FAIL_COND_V(t->type != TYPE_AUDIO, -1); |