diff options
50 files changed, 501 insertions, 442 deletions
diff --git a/.gitignore b/.gitignore index cbb0b5b133..f8296ef51e 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,10 @@ gmon.out .cproject .settings/ +# Geany/geany-plugins files +*.geany +.geanyprj + # Misc .DS_Store logs/ diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 2921626f3a..c7b08b8242 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2466,7 +2466,13 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const Array ret; for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { +#ifdef DEBUG_METHODS_ENABLED ret.push_back(E->get().operator Dictionary()); +#else + Dictionary dict; + dict["name"] = E->get().name; + ret.push_back(dict); +#endif } return ret; diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index bbc2125c5a..e3dc8eb53a 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -355,6 +355,13 @@ void ScriptDebuggerRemote::_get_output() { locking = false; } + if (n_messages_dropped > 0) { + Message msg; + msg.message = "Too many messages! " + String::num_int64(n_messages_dropped) + " messages were dropped."; + messages.push_back(msg); + n_messages_dropped = 0; + } + while (messages.size()) { locking = true; packet_peer_stream->put_var("message:" + messages.front()->get().message); @@ -366,6 +373,20 @@ void ScriptDebuggerRemote::_get_output() { locking = false; } + if (n_errors_dropped > 0) { + OutputError oe; + oe.error = "TOO_MANY_ERRORS"; + oe.error_descr = "Too many errors! " + String::num_int64(n_errors_dropped) + " errors were dropped."; + oe.warning = false; + uint64_t time = OS::get_singleton()->get_ticks_msec(); + oe.hr = time / 3600000; + oe.min = (time / 60000) % 60; + oe.sec = (time / 1000) % 60; + oe.msec = time % 1000; + errors.push_back(oe); + n_errors_dropped = 0; + } + while (errors.size()) { locking = true; packet_peer_stream->put_var("error"); @@ -453,7 +474,11 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) { - sdr->errors.push_back(oe); + if (sdr->errors.size() >= sdr->max_errors_per_frame) { + sdr->n_errors_dropped++; + } else { + sdr->errors.push_back(oe); + } } sdr->mutex->unlock(); @@ -891,10 +916,14 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->lock(); if (!locking && tcp_client->is_connected_to_host()) { - Message msg; - msg.message = p_message; - msg.data = p_args; - messages.push_back(msg); + if (messages.size() >= max_messages_per_frame) { + n_messages_dropped++; + } else { + Message msg; + msg.message = p_message; + msg.data = p_args; + messages.push_back(msg); + } } mutex->unlock(); } @@ -1011,7 +1040,11 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() : requested_quit(false), mutex(Mutex::create()), max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), + max_messages_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_messages_per_frame")), + max_errors_per_frame(GLOBAL_GET("network/limits/debugger_stdout/max_errors_per_frame")), char_count(0), + n_messages_dropped(0), + n_errors_dropped(0), last_msec(0), msec_count(0), locking(false), diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 00ed22dc29..924d5de2c4 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -87,7 +87,11 @@ class ScriptDebuggerRemote : public ScriptDebugger { List<String> output_strings; List<Message> messages; + int max_messages_per_frame; + int n_messages_dropped; List<OutputError> errors; + int max_errors_per_frame; + int n_errors_dropped; int max_cps; int char_count; diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index a8eb527b09..b3f9dd818d 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -108,6 +108,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) { void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -127,6 +128,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -149,6 +151,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT } void UndoRedo::add_do_property(Object *p_object, const String &p_property, const Variant &p_value) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -163,6 +166,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const } void UndoRedo::add_undo_property(Object *p_object, const String &p_property, const Variant &p_value) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -182,6 +186,7 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con } void UndoRedo::add_do_reference(Object *p_object) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -194,6 +199,7 @@ void UndoRedo::add_do_reference(Object *p_object) { } void UndoRedo::add_undo_reference(Object *p_object) { + ERR_FAIL_COND(p_object == NULL); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -240,13 +246,6 @@ void UndoRedo::commit_action() { redo(); // perform action - if (max_steps > 0 && actions.size() > max_steps) { - //clear early steps - - while (actions.size() > max_steps) - _pop_history_tail(); - } - if (callback && actions.size() > 0) { callback(callback_ud, actions[actions.size() - 1].name); } @@ -341,16 +340,6 @@ String UndoRedo::get_current_action_name() const { return actions[current_action].name; } -void UndoRedo::set_max_steps(int p_max_steps) { - - max_steps = p_max_steps; -} - -int UndoRedo::get_max_steps() const { - - return max_steps; -} - uint64_t UndoRedo::get_version() const { return version; @@ -379,7 +368,6 @@ UndoRedo::UndoRedo() { version = 1; action_level = 0; current_action = -1; - max_steps = -1; merge_mode = MERGE_DISABLE; callback = NULL; callback_ud = NULL; @@ -504,8 +492,6 @@ void UndoRedo::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_history"), &UndoRedo::clear_history); ClassDB::bind_method(D_METHOD("get_current_action_name"), &UndoRedo::get_current_action_name); ClassDB::bind_method(D_METHOD("get_version"), &UndoRedo::get_version); - ClassDB::bind_method(D_METHOD("set_max_steps", "max_steps"), &UndoRedo::set_max_steps); - ClassDB::bind_method(D_METHOD("get_max_steps"), &UndoRedo::get_max_steps); ClassDB::bind_method(D_METHOD("redo"), &UndoRedo::redo); ClassDB::bind_method(D_METHOD("undo"), &UndoRedo::undo); diff --git a/core/undo_redo.h b/core/undo_redo.h index 5d7ab782d6..a373296b73 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -79,7 +79,6 @@ private: Vector<Action> actions; int current_action; int action_level; - int max_steps; MergeMode merge_mode; uint64_t version; @@ -115,9 +114,6 @@ public: String get_current_action_name() const; void clear_history(); - void set_max_steps(int p_max_steps); - int get_max_steps() const; - uint64_t get_version() const; void set_commit_notify_callback(CommitNotifyCallback p_callback, void *p_ud); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 662371b107..e46fac77ee 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -339,7 +339,7 @@ bool Variant::booleanize() const { CASE_TYPE(m_prefix, m_op_name, m_name) { \ if (p_b.type == NIL) \ _RETURN(true) \ - DEFAULT_OP_ARRAY_OP_BODY(m_prefix, m_op_name, m_name, m_type, !=, ==, true, true, false) \ + DEFAULT_OP_ARRAY_OP_BODY(m_prefix, m_op_name, m_name, m_type, !=, !=, false, true, true) \ } #define DEFAULT_OP_ARRAY_LT(m_prefix, m_op_name, m_name, m_type) \ @@ -539,12 +539,12 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, if (arr_b->size() != l) _RETURN(true); for (int i = 0; i < l; i++) { - if (((*arr_a)[i] == (*arr_b)[i])) { - _RETURN(false); + if (((*arr_a)[i] != (*arr_b)[i])) { + _RETURN(true); } } - _RETURN(true); + _RETURN(false); } DEFAULT_OP_NUM_NULL(math, OP_NOT_EQUAL, INT, !=, _int); diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml index cd05c83347..c98a80ca8c 100644 --- a/doc/classes/@GDScript.xml +++ b/doc/classes/@GDScript.xml @@ -41,10 +41,12 @@ <argument index="1" name="alpha" type="float"> </argument> <description> - Returns color [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. Note: [code]name[/code] is defined in color_names.inc. + Returns a color according to the standardised [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. [codeblock] - red = ColorN('red') + red = ColorN("red", 1) [/codeblock] + Supported color names: + "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "webgray", "green", "webgreen", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "webmaroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "webpurple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen". </description> </method> <method name="abs"> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 6fa7ed0a86..ef555537a1 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -5,6 +5,7 @@ </brief_description> <description> A color is represented as red, green and blue (r,g,b) components. Additionally, "a" represents the alpha component, often used for transparency. Values are in floating point and usually range from 0 to 1. Some methods (such as set_modulate(color)) may accept values > 1. + You can also create a color from standardised color names with [method @GDScript.ColorN]. </description> <tutorials> </tutorials> @@ -63,7 +64,7 @@ <argument index="0" name="from" type="String"> </argument> <description> - Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. + Constructs a color from an HTML hexadecimal color string in ARGB or RGB format. See also [method @GDScript.ColorN]. The following string formats are supported: [code]"#ff00ff00"[/code] - ARGB format with '#' [code]"ff00ff00"[/code] - ARGB format diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml index d1dc236d40..92d648537c 100644 --- a/doc/classes/KinematicBody.xml +++ b/doc/classes/KinematicBody.xml @@ -82,7 +82,7 @@ <description> Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [code]KinematicBody[/code] or [RigidBody], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes. [code]linear_velocity[/code] is a value in pixels per second. Unlike in for example [method move_and_collide], you should [i]not[/i] multiply it with [code]delta[/code] — this is done by the method. - [code]floor_normal[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector2(0, 0)[/code], everything is considered a wall. This is useful for topdown games. + [code]floor_normal[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector3(0, 0, 0)[/code], everything is considered a wall. This is useful for topdown games. If the body is standing on a slope and the horizontal speed (relative to the floor's speed) goes below [code]slope_stop_min_velocity[/code], the body will stop completely. This prevents the body from sliding down slopes when you include gravity in [code]linear_velocity[/code]. When set to lower values, the body will not be able to stand still on steep slopes. If the body collides, it will change direction a maximum of [code]max_bounces[/code] times before it stops. [code]floor_max_angle[/code] is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees. diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index f0d69b9b7f..3cd88dafe3 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -108,12 +108,6 @@ Get the name of the current action. </description> </method> - <method name="get_max_steps" qualifiers="const"> - <return type="int"> - </return> - <description> - </description> - </method> <method name="get_version" qualifiers="const"> <return type="int"> </return> @@ -128,14 +122,6 @@ <description> </description> </method> - <method name="set_max_steps"> - <return type="void"> - </return> - <argument index="0" name="max_steps" type="int"> - </argument> - <description> - </description> - </method> <method name="undo"> <return type="void"> </return> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 976cdbbd90..5c1281b628 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -92,7 +92,7 @@ <argument index="3" name="t" type="float"> </argument> <description> - Cubicly interpolates between this Vector and "b", using "pre_a" and "post_b" as handles, and returning the result at position "t". + Cubicly interpolates between this Vector and "b", using "pre_a" and "post_b" as handles, and returning the result at position "t". "t" should be a float of 0.0-1.0, a percentage of how far along the interpolation is. </description> </method> <method name="distance_squared_to"> @@ -158,7 +158,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the result of the linear interpolation between this vector and "b", by amount "t". + Returns the result of the linear interpolation between this vector and "b", by amount "t". "t" should be a float of 0.0-1.0, a percentage of how far along the interpolation is. </description> </method> <method name="normalized"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index acb41297a7..dff3d04b0c 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -77,7 +77,7 @@ <argument index="3" name="t" type="float"> </argument> <description> - Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount (t). + Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is. </description> </method> <method name="distance_squared_to"> @@ -150,7 +150,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Linearly interpolates the vector to a given one (b), by the given amount (t). + Linearly interpolates the vector to a given one (b), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is. </description> </method> <method name="max_axis"> diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 0f30e3afdb..5f45f06c79 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -53,6 +53,7 @@ #if defined(__FreeBSD__) || defined(__OpenBSD__) #include <sys/param.h> +#include <sys/sysctl.h> #endif #include "project_settings.h" #include <assert.h> @@ -298,17 +299,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo args.push_back((char *)cs[i].get_data()); // shitty C cast args.push_back(0); -#ifdef __FreeBSD__ - if (p_path.find("/") != -1) { - // exec name contains path so use it - execv(p_path.utf8().get_data(), &args[0]); - } else { - // use program name and search through PATH to find it - execvp(getprogname(), &args[0]); - } -#else execvp(p_path.utf8().get_data(), &args[0]); -#endif // still alive? something failed.. fprintf(stderr, "**ERROR** OS_Unix::execute - Could not create child process while executing: %s\n", p_path.utf8().get_data()); abort(); @@ -462,12 +453,23 @@ String OS_Unix::get_executable_path() const { return OS::get_executable_path(); } return b; -#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#elif defined(__OpenBSD__) char resolved_path[MAXPATHLEN]; realpath(OS::get_executable_path().utf8().get_data(), resolved_path); return String(resolved_path); +#elif defined(__FreeBSD__) + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + char buf[MAXPATHLEN]; + size_t len = sizeof(buf); + if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) { + WARN_PRINT("Couldn't get executable path from sysctl"); + return OS::get_executable_path(); + } + String b; + b.parse_utf8(buf); + return b; #elif defined(__APPLE__) char temp_path[1]; uint32_t buff_size = 1; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index feb5bf2a8f..3e079cb3ca 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1034,7 +1034,7 @@ void CodeTextEditor::_reset_zoom() { Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default if (font.is_valid()) { - EditorSettings::get_singleton()->set("interface/editor/source_font_size", 14); + EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14); font->set_size(14); } } @@ -1098,7 +1098,7 @@ bool CodeTextEditor::_add_font_size(int p_delta) { if (font.is_valid()) { int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); if (new_size != font->get_size()) { - EditorSettings::get_singleton()->set("interface/editor/source_font_size", new_size / EDSCALE); + EditorSettings::get_singleton()->set("interface/editor/code_font_size", new_size / EDSCALE); font->set_size(new_size); } @@ -1140,20 +1140,7 @@ void CodeTextEditor::set_error(const String &p_error) { void CodeTextEditor::_update_font() { - // FONTS - String editor_font = EDITOR_DEF("text_editor/theme/font", ""); - bool font_overridden = false; - if (editor_font != "") { - Ref<Font> fnt = ResourceLoader::load(editor_font); - if (fnt.is_valid()) { - text_editor->add_font_override("font", fnt); - font_overridden = true; - } - } - if (!font_overridden) { - - text_editor->add_font_override("font", get_font("source", "EditorFonts")); - } + text_editor->add_font_override("font", get_font("source", "EditorFonts")); } void CodeTextEditor::_on_settings_change() { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9e8521e0fe..374688f2db 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -38,7 +38,7 @@ #include "project_settings.h" #include "scene/resources/packed_scene.h" -void EditorHistory::_cleanup_history() { +void EditorHistory::cleanup_history() { for (int i = 0; i < history.size(); i++) { @@ -48,8 +48,14 @@ void EditorHistory::_cleanup_history() { if (!history[i].path[j].ref.is_null()) continue; - if (ObjectDB::get_instance(history[i].path[j].object)) - continue; //has isntance, try next + Object *obj = ObjectDB::get_instance(history[i].path[j].object); + if (obj) { + Node *n = Object::cast_to<Node>(obj); + if (n && n->is_inside_tree()) + continue; + if (!n) // Possibly still alive + continue; + } if (j <= history[i].level) { //before or equal level, complete fail @@ -152,7 +158,7 @@ bool EditorHistory::is_at_end() const { bool EditorHistory::next() { - _cleanup_history(); + cleanup_history(); if ((current + 1) < history.size()) current++; @@ -164,7 +170,7 @@ bool EditorHistory::next() { bool EditorHistory::previous() { - _cleanup_history(); + cleanup_history(); if (current > 0) current--; diff --git a/editor/editor_data.h b/editor/editor_data.h index eacde04134..844145853d 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -70,11 +70,11 @@ class EditorHistory { Variant value; }; - void _cleanup_history(); - void _add_object(ObjectID p_object, const String &p_property, int p_level_change); public: + void cleanup_history(); + bool is_at_beginning() const; bool is_at_end() const; diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index c970ae355b..a58257962a 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -85,10 +85,24 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); +#define MAKE_SOURCE_FONT(m_name, m_size) \ + Ref<DynamicFont> m_name; \ + m_name.instance(); \ + m_name->set_size(m_size); \ + if (CustomFontSource.is_valid()) { \ + m_name->set_font_data(CustomFontSource); \ + m_name->add_fallback(dfmono); \ + } else { \ + m_name->set_font_data(dfmono); \ + } \ + m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ + m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ + MAKE_FALLBACKS(m_name); + void editor_register_fonts(Ref<Theme> p_theme) { /* Custom font */ - String custom_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); + String custom_font = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<DynamicFontData> CustomFont; if (custom_font.length() > 0) { CustomFont.instance(); @@ -96,6 +110,15 @@ void editor_register_fonts(Ref<Theme> p_theme) { CustomFont->set_force_autohinter(true); //just looks better..i think? } + /* Custom source code font */ + + String custom_font_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); + Ref<DynamicFontData> CustomFontSource; + if (custom_font_source.length() > 0) { + CustomFontSource.instance(); + CustomFontSource->set_font_path(custom_font_source); + } + /* Droid Sans */ Ref<DynamicFontData> DefaultFont; @@ -135,7 +158,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE; + int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/main_font_size")) * EDSCALE; MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); @@ -153,41 +176,15 @@ void editor_register_fonts(Ref<Theme> p_theme) { MAKE_DEFAULT_FONT(df_rulers, 8 * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); - Ref<DynamicFont> df_code; - df_code.instance(); - df_code->set_size(int(EditorSettings::get_singleton()->get("interface/editor/source_font_size")) * EDSCALE); - df_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_code); - + MAKE_SOURCE_FONT(df_code, int(EditorSettings::get_singleton()->get("interface/editor/code_font_size")) * EDSCALE); p_theme->set_font("source", "EditorFonts", df_code); - Ref<DynamicFont> df_doc_code; - df_doc_code.instance(); - df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); - df_doc_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_doc_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_doc_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_doc_code); - + MAKE_SOURCE_FONT(df_doc_code, int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); p_theme->set_font("doc_source", "EditorFonts", df_doc_code); - Ref<DynamicFont> df_output_code; - df_output_code.instance(); - df_output_code->set_size(int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); - df_output_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_output_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_output_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_output_code); - + MAKE_SOURCE_FONT(df_output_code, int(EDITOR_DEF("run/output/font_size", 13)) * EDSCALE); p_theme->set_font("output_source", "EditorFonts", df_output_code); - Ref<DynamicFont> df_text_editor_status_code; - df_text_editor_status_code.instance(); - df_text_editor_status_code->set_size(14 * EDSCALE); - df_text_editor_status_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); - df_text_editor_status_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); - df_text_editor_status_code->set_font_data(dfmono); - MAKE_FALLBACKS(df_text_editor_status_code); - + MAKE_SOURCE_FONT(df_text_editor_status_code, 14 * EDSCALE); p_theme->set_font("status_source", "EditorFonts", df_text_editor_status_code); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 70047bc60c..2b62faf218 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -393,42 +393,6 @@ void EditorNode::_fs_changed() { E->get()->invalidate(); } - if (export_defer.preset != "") { - Ref<EditorExportPreset> preset; - for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { - preset = EditorExport::get_singleton()->get_export_preset(i); - if (preset->get_name() == export_defer.preset) { - break; - } - preset.unref(); - } - if (preset.is_null()) { - String err = "Unknown export preset: " + export_defer.preset; - ERR_PRINT(err.utf8().get_data()); - } else { - Ref<EditorExportPlatform> platform = preset->get_platform(); - if (platform.is_null()) { - String err = "Preset \"" + export_defer.preset + "\" doesn't have a platform."; - ERR_PRINT(err.utf8().get_data()); - } else { - // ensures export_project does not loop infinitely, because notifications may - // come during the export - export_defer.preset = ""; - if (!preset->is_runnable() && (export_defer.path.ends_with(".pck") || export_defer.path.ends_with(".zip"))) { - if (export_defer.path.ends_with(".zip")) { - platform->save_zip(preset, export_defer.path); - } else if (export_defer.path.ends_with(".pck")) { - platform->save_pack(preset, export_defer.path); - } - } else { - platform->export_project(preset, export_defer.debug, export_defer.path, /*p_flags*/ 0); - } - } - } - - get_tree()->quit(); - } - { //reload changed resources List<Ref<Resource> > changed; @@ -465,6 +429,42 @@ void EditorNode::_fs_changed() { } _mark_unsaved_scenes(); + + if (export_defer.preset != "" && !EditorFileSystem::get_singleton()->is_scanning()) { + Ref<EditorExportPreset> preset; + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { + preset = EditorExport::get_singleton()->get_export_preset(i); + if (preset->get_name() == export_defer.preset) { + break; + } + preset.unref(); + } + if (preset.is_null()) { + String err = "Unknown export preset: " + export_defer.preset; + ERR_PRINT(err.utf8().get_data()); + } else { + Ref<EditorExportPlatform> platform = preset->get_platform(); + if (platform.is_null()) { + String err = "Preset \"" + export_defer.preset + "\" doesn't have a platform."; + ERR_PRINT(err.utf8().get_data()); + } else { + // ensures export_project does not loop infinitely, because notifications may + // come during the export + export_defer.preset = ""; + if (!preset->is_runnable() && (export_defer.path.ends_with(".pck") || export_defer.path.ends_with(".zip"))) { + if (export_defer.path.ends_with(".zip")) { + platform->save_zip(preset, export_defer.path); + } else if (export_defer.path.ends_with(".pck")) { + platform->save_pack(preset, export_defer.path); + } + } else { + platform->export_project(preset, export_defer.debug, export_defer.path, /*p_flags*/ 0); + } + } + } + + get_tree()->quit(); + } } void EditorNode::_resources_reimported(const Vector<String> &p_resources) { @@ -1398,7 +1398,7 @@ void EditorNode::_property_editor_forward() { } void EditorNode::_property_editor_back() { - if (editor_history.previous()) + if (editor_history.previous() || editor_history.get_path_size() == 1) _edit_current(); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index be03e24eee..7081bb925f 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -54,7 +54,18 @@ Ref<EditorSettings> EditorSettings::singleton = NULL; // Properties -bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool p_emit_signal) { +bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { + + _THREAD_SAFE_METHOD_ + + bool changed = _set_only(p_name, p_value); + if (changed) { + emit_signal("settings_changed"); + } + return true; +} + +bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) { _THREAD_SAFE_METHOD_ @@ -73,7 +84,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool add_shortcut(name, sc); } - return true; + return false; } bool changed = false; @@ -102,10 +113,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool } } - if (changed && p_emit_signal) { - emit_signal("settings_changed"); - } - return true; + return changed; } bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { @@ -273,12 +281,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/hidpi_mode", 0); hints["interface/editor/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/editor/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/scene_tabs/show_script_button", false); - _initial_set("interface/editor/font_size", 14); - hints["interface/editor/font_size"] = PropertyInfo(Variant::INT, "interface/editor/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/source_font_size", 14); - hints["interface/editor/source_font_size"] = PropertyInfo(Variant::INT, "interface/editor/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("interface/editor/custom_font", ""); - hints["interface/editor/custom_font"] = PropertyInfo(Variant::STRING, "interface/editor/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/main_font_size", 14); + hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/code_font_size", 14); + hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/main_font", ""); + hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("interface/editor/code_font", ""); + hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/dim_editor_on_dialog_popup", true); _initial_set("interface/editor/dim_amount", 0.6f); hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); @@ -367,9 +377,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1"); _initial_set("text_editor/cursor/right_click_moves_caret", true); - _initial_set("text_editor/theme/font", ""); - hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res"); _initial_set("text_editor/completion/auto_brace_complete", false); + _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true); + _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); _initial_set("text_editor/files/restore_scripts_on_load", true); _initial_set("text_editor/completion/complete_file_paths", true); _initial_set("text_editor/files/maximum_recent_files", 20); @@ -982,7 +992,7 @@ void EditorSettings::raise_order(const String &p_setting) { props[p_setting].order = ++last_order; } -void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) { +void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current) { _THREAD_SAFE_METHOD_ @@ -990,6 +1000,9 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian return; props[p_setting].initial = p_value; props[p_setting].has_default_value = true; + if (update_current) { + set(p_setting, p_value); + } } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { @@ -1174,8 +1187,10 @@ void EditorSettings::list_text_editor_themes() { void EditorSettings::load_text_editor_theme() { if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") { - _load_default_text_editor_theme(); // sorry for "Settings changed" console spam - return; + if (get("text_editor/theme/color_theme") == "Default") { + _load_default_text_editor_theme(); + } + return; // sorry for "Settings changed" console spam } String theme_path = get_text_editor_themes_dir().plus_file((String)get("text_editor/theme/color_theme") + ".tet"); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 0a20212ccd..914316ee61 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -111,7 +111,8 @@ private: bool save_changed_setting; bool optimize_save; //do not save stuff that came from config but was not set from engine - bool _set(const StringName &p_name, const Variant &p_value, bool p_emit_signal = true); + bool _set(const StringName &p_name, const Variant &p_value); + bool _set_only(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _initial_set(const StringName &p_name, const Variant &p_value); void _get_property_list(List<PropertyInfo> *p_list) const; @@ -144,9 +145,12 @@ public: bool has_setting(const String &p_setting) const; void erase(const String &p_setting); void raise_order(const String &p_setting); - void set_initial_value(const StringName &p_setting, const Variant &p_value); + void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false); void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) { - _set(p_setting, p_value, p_emit_signal); + if (p_emit_signal) + _set(p_setting, p_value); + else + _set_only(p_setting, p_value); } bool property_can_revert(const String &p_setting); Variant property_get_revert(const String &p_setting); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ea114472a8..9fda9d2ff6 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1063,67 +1063,67 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { EditorSettings *setting = EditorSettings::get_singleton(); String text_editor_color_theme = setting->get("text_editor/theme/color_theme"); if (text_editor_color_theme == "Adaptive") { - setting->set_manually("text_editor/highlighting/symbol_color", symbol_color); - setting->set_manually("text_editor/highlighting/keyword_color", keyword_color); - setting->set_manually("text_editor/highlighting/base_type_color", basetype_color); - setting->set_manually("text_editor/highlighting/engine_type_color", type_color); - setting->set_manually("text_editor/highlighting/comment_color", comment_color); - setting->set_manually("text_editor/highlighting/string_color", string_color); - setting->set_manually("text_editor/highlighting/background_color", background_color); - setting->set_manually("text_editor/highlighting/completion_background_color", completion_background_color); - setting->set_manually("text_editor/highlighting/completion_selected_color", completion_selected_color); - setting->set_manually("text_editor/highlighting/completion_existing_color", completion_existing_color); - setting->set_manually("text_editor/highlighting/completion_scroll_color", completion_scroll_color); - setting->set_manually("text_editor/highlighting/completion_font_color", completion_font_color); - setting->set_manually("text_editor/highlighting/text_color", text_color); - setting->set_manually("text_editor/highlighting/line_number_color", line_number_color); - setting->set_manually("text_editor/highlighting/caret_color", caret_color); - setting->set_manually("text_editor/highlighting/caret_background_color", caret_background_color); - setting->set_manually("text_editor/highlighting/text_selected_color", text_selected_color); - setting->set_manually("text_editor/highlighting/selection_color", selection_color); - setting->set_manually("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color); - setting->set_manually("text_editor/highlighting/current_line_color", current_line_color); - setting->set_manually("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color); - setting->set_manually("text_editor/highlighting/word_highlighted_color", word_highlighted_color); - setting->set_manually("text_editor/highlighting/number_color", number_color); - setting->set_manually("text_editor/highlighting/function_color", function_color); - setting->set_manually("text_editor/highlighting/member_variable_color", member_variable_color); - setting->set_manually("text_editor/highlighting/mark_color", mark_color); - setting->set_manually("text_editor/highlighting/breakpoint_color", breakpoint_color); - setting->set_manually("text_editor/highlighting/code_folding_color", code_folding_color); - setting->set_manually("text_editor/highlighting/search_result_color", search_result_color); - setting->set_manually("text_editor/highlighting/search_result_border_color", search_result_border_color); + setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true); + setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true); + setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true); + setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); + setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true); + setting->set_initial_value("text_editor/highlighting/string_color", string_color, true); + setting->set_initial_value("text_editor/highlighting/background_color", background_color, true); + setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true); + setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true); + setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true); + setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true); + setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true); + setting->set_initial_value("text_editor/highlighting/text_color", text_color, true); + setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true); + setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true); + setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true); + setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true); + setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true); + setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true); + setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true); + setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true); + setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true); + setting->set_initial_value("text_editor/highlighting/number_color", number_color, true); + setting->set_initial_value("text_editor/highlighting/function_color", function_color, true); + setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true); + setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true); + setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true); + setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true); + setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true); + setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true); } else if (text_editor_color_theme == "Default") { - setting->set_manually("text_editor/highlighting/symbol_color", Color::html("badfff")); - setting->set_manually("text_editor/highlighting/keyword_color", Color::html("ffffb3")); - setting->set_manually("text_editor/highlighting/base_type_color", Color::html("a4ffd4")); - setting->set_manually("text_editor/highlighting/engine_type_color", Color::html("83d3ff")); - setting->set_manually("text_editor/highlighting/comment_color", Color::html("676767")); - setting->set_manually("text_editor/highlighting/string_color", Color::html("ef6ebe")); - setting->set_manually("text_editor/highlighting/background_color", Color::html("3b000000")); - setting->set_manually("text_editor/highlighting/completion_background_color", Color::html("2C2A32")); - setting->set_manually("text_editor/highlighting/completion_selected_color", Color::html("434244")); - setting->set_manually("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")); - setting->set_manually("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")); - setting->set_manually("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/text_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/line_number_color", Color::html("66aaaaaa")); - setting->set_manually("text_editor/highlighting/caret_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/caret_background_color", Color::html("000000")); - setting->set_manually("text_editor/highlighting/text_selected_color", Color::html("000000")); - setting->set_manually("text_editor/highlighting/selection_color", Color::html("6ca9c2")); - setting->set_manually("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)); - setting->set_manually("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)); - setting->set_manually("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1)); - setting->set_manually("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)); - setting->set_manually("text_editor/highlighting/number_color", Color::html("EB9532")); - setting->set_manually("text_editor/highlighting/function_color", Color::html("66a2ce")); - setting->set_manually("text_editor/highlighting/member_variable_color", Color::html("e64e59")); - setting->set_manually("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); - setting->set_manually("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); - setting->set_manually("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); - setting->set_manually("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); - setting->set_manually("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); + setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true); + setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true); + setting->set_initial_value("text_editor/highlighting/base_type_color", Color::html("a4ffd4"), true); + setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true); + setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true); + setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true); + setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true); + setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true); + setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true); + setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true); + setting->set_initial_value("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"), true); + setting->set_initial_value("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/text_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/caret_color", Color::html("aaaaaa"), true); + setting->set_initial_value("text_editor/highlighting/caret_background_color", Color::html("000000"), true); + setting->set_initial_value("text_editor/highlighting/text_selected_color", Color::html("000000"), true); + setting->set_initial_value("text_editor/highlighting/selection_color", Color::html("6ca9c2"), true); + setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), true); + setting->set_initial_value("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), true); + setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true); + setting->set_initial_value("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true); + setting->set_initial_value("text_editor/highlighting/number_color", Color::html("EB9532"), true); + setting->set_initial_value("text_editor/highlighting/function_color", Color::html("66a2ce"), true); + setting->set_initial_value("text_editor/highlighting/member_variable_color", Color::html("e64e59"), true); + setting->set_initial_value("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true); + setting->set_initial_value("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2), true); + setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true); + setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true); + setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true); } return theme; diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 3d2959c598..a5d3959952 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -77,7 +77,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String & bit = c.a > threshold; } - bitmap->set_bit(Vector2(i, j), bit); + bitmap->set_bit(Vector2(j, i), bit); } } diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 12aa0bb33c..03155b3a48 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -268,9 +268,15 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s for (int i = 0; i < 10; i++) file->get_32(); // i wish to know why should i do this... no doc! - loop = file->get_32() ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD; - loop_begin = file->get_32(); - loop_end = file->get_32(); + // only read 0x00 (loop forward) and 0x01 (loop ping-pong) and skip anything else because + // it's not supported (loop backward), reserved for future uses or sampler specific + // from https://sites.google.com/site/musicgapi/technical-documents/wav-file-format#smpl (loop type values table) + int loop_type = file->get_32(); + if (loop_type == 0x00 || loop_type == 0x01) { + loop = loop_type ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD; + loop_begin = file->get_32(); + loop_end = file->get_32(); + } } file->seek(file_pos + chunksize); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index a186782128..2a46aba207 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -340,7 +340,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const // Grid Point2 offset = grid_offset; if (snap_relative) { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) { offset = Object::cast_to<Node2D>(selection[0])->get_global_position(); } else { @@ -382,7 +382,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { drag = DRAG_PIVOT; } else if (set_pivot_shortcut.is_valid() && set_pivot_shortcut->is_shortcut(p_ev) && drag == DRAG_NONE && can_move_pivot) { if (!Input::get_singleton()->is_mouse_button_pressed(0)) { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); Vector2 mouse_pos = viewport->get_local_mouse_position(); if (selection.size() && viewport->get_rect().has_point(mouse_pos)) { //just in case, make it work if over viewport @@ -751,7 +751,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE undo_redo->create_action(TTR("Move Action"), UndoRedo::MERGE_ENDS); - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -811,7 +811,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() { Rect2 r2; r2.position = tl; - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -835,7 +835,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() { int CanvasItemEditor::get_item_count() { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); int ic = 0; for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1002,7 +1002,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_anchor_handle_drag_type(const void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1527,7 +1527,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { bone_ik_list.clear(); } else { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); @@ -1608,7 +1608,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { } else { undo_redo->create_action(TTR("Edit CanvasItem")); - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1905,7 +1905,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { return; } - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); @@ -2921,7 +2921,7 @@ void CanvasItemEditor::_draw_viewport() { // hide/show buttons depending on the selection bool all_locked = true; bool all_group = true; - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.empty()) { all_locked = false; all_group = false; @@ -2976,7 +2976,7 @@ void CanvasItemEditor::_notification(int p_what) { EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); bool all_control = true; bool has_control = false; @@ -3277,7 +3277,7 @@ void CanvasItemEditor::_update_scroll(float) { } void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors and Margins")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3321,7 +3321,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p } void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3464,7 +3464,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { case LOCK_SELECTED: { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3482,7 +3482,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case UNLOCK_SELECTED: { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3502,7 +3502,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case GROUP_SELECTED: { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3520,7 +3520,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case UNGROUP_SELECTED: { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -3878,7 +3878,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_SET_IK_CHAIN: { - List<Node *> &selection = editor_selection->get_selected_node_list(); + List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bc986cee9c..51954a24d6 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -514,7 +514,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { if (p_save) { apply_scripts(); } - current->clear_edit_menu(); notify_script_close(current->get_edited_script()); } else { EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_child(selected)); @@ -540,6 +539,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { } int idx = tab_container->get_current_tab(); + if (current) { + current->clear_edit_menu(); + } memdelete(tselected); if (idx >= tab_container->get_child_count()) idx = tab_container->get_child_count() - 1; diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 15e8347bbd..08679b781a 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -618,8 +618,10 @@ void AutotileEditor::_on_edit_mode_changed(int p_edit_mode) { tool_containers[TOOLBAR_BITMASK]->hide(); tool_containers[TOOLBAR_SHAPE]->show(); tools[TOOL_SELECT]->set_tooltip(TTR("Select current edited sub-tile.")); - current_shape = PoolVector2Array(); spin_priority->hide(); + + current_shape = PoolVector2Array(); + select_coord(edited_shape_coord); } break; default: { tool_containers[TOOLBAR_DUMMY]->show(); @@ -931,50 +933,18 @@ void AutotileEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { edited_shape_coord = coord; edited_occlusion_shape = tile_set->autotile_get_light_occluder(get_current_tile(), edited_shape_coord); edited_navigation_shape = tile_set->autotile_get_navigation_polygon(get_current_tile(), edited_shape_coord); - shape_anchor = edited_shape_coord; - shape_anchor.x *= (size.x + spacing); - shape_anchor.y *= (size.y + spacing); - if (edit_mode == EDITMODE_OCCLUSION) { - current_shape.resize(0); - if (edited_occlusion_shape.is_valid()) { - for (int i = 0; i < edited_occlusion_shape->get_polygon().size(); i++) { - current_shape.push_back(edited_occlusion_shape->get_polygon()[i] + shape_anchor); - } - } - } else if (edit_mode == EDITMODE_NAVIGATION) { - current_shape.resize(0); - if (edited_navigation_shape.is_valid()) { - if (edited_navigation_shape->get_polygon_count() > 0) { - PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices(); - for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) { - current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + shape_anchor); - } - } - } - } - } else { - if (edit_mode == EDITMODE_COLLISION) { - Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(get_current_tile()); - for (int i = 0; i < sd.size(); i++) { - if (sd[i].autotile_coord == coord) { - Ref<ConvexPolygonShape2D> shape = sd[i].shape; - if (shape.is_valid()) { - - Rect2 bounding_rect; - PoolVector2Array polygon; - bounding_rect.position = shape->get_points()[0]; - for (int j = 0; j < shape->get_points().size(); j++) { - polygon.push_back(shape->get_points()[j] + shape_anchor); - bounding_rect.expand_to(shape->get_points()[j] + shape_anchor); - } - if (bounding_rect.has_point(mb->get_position())) { - current_shape = polygon; - edited_collision_shape = shape; - } - } - } + Vector<TileSet::ShapeData> sd = tile_set->tile_get_shapes(get_current_tile()); + bool found_collision_shape = false; + for (int i = 0; i < sd.size(); i++) { + if (sd[i].autotile_coord == coord) { + edited_collision_shape = sd[i].shape; + found_collision_shape = true; + break; } } + if (!found_collision_shape) + edited_collision_shape = Ref<ConvexPolygonShape2D>(NULL); + select_coord(edited_shape_coord); } workspace->update(); } else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { @@ -1341,7 +1311,7 @@ void AutotileEditor::draw_polygon_shapes() { } Vector<Vector2> polygon; Vector<Color> colors; - if (shape == edited_collision_shape) { + if (shape == edited_collision_shape && current_shape.size() > 2) { for (int j = 0; j < current_shape.size(); j++) { polygon.push_back(current_shape[j]); colors.push_back(c_bg); @@ -1391,7 +1361,7 @@ void AutotileEditor::draw_polygon_shapes() { } Vector<Vector2> polygon; Vector<Color> colors; - if (shape == edited_occlusion_shape) { + if (shape == edited_occlusion_shape && current_shape.size() > 2) { for (int j = 0; j < current_shape.size(); j++) { polygon.push_back(current_shape[j]); colors.push_back(c_bg); @@ -1439,7 +1409,7 @@ void AutotileEditor::draw_polygon_shapes() { } Vector<Vector2> polygon; Vector<Color> colors; - if (shape == edited_navigation_shape) { + if (shape == edited_navigation_shape && current_shape.size() > 2) { for (int j = 0; j < current_shape.size(); j++) { polygon.push_back(current_shape[j]); colors.push_back(c_bg); @@ -1549,6 +1519,39 @@ void AutotileEditor::close_shape(const Vector2 &shape_anchor) { } } +void AutotileEditor::select_coord(const Vector2 &coord) { + int spacing = tile_set->autotile_get_spacing(get_current_tile()); + Vector2 size = tile_set->autotile_get_size(get_current_tile()); + Vector2 shape_anchor = coord; + shape_anchor.x *= (size.x + spacing); + shape_anchor.y *= (size.y + spacing); + if (edit_mode == EDITMODE_COLLISION) { + current_shape.resize(0); + if (edited_collision_shape.is_valid()) { + for (int j = 0; j < edited_collision_shape->get_points().size(); j++) { + current_shape.push_back(edited_collision_shape->get_points()[j] + shape_anchor); + } + } + } else if (edit_mode == EDITMODE_OCCLUSION) { + current_shape.resize(0); + if (edited_occlusion_shape.is_valid()) { + for (int i = 0; i < edited_occlusion_shape->get_polygon().size(); i++) { + current_shape.push_back(edited_occlusion_shape->get_polygon()[i] + shape_anchor); + } + } + } else if (edit_mode == EDITMODE_NAVIGATION) { + current_shape.resize(0); + if (edited_navigation_shape.is_valid()) { + if (edited_navigation_shape->get_polygon_count() > 0) { + PoolVector<Vector2> vertices = edited_navigation_shape->get_vertices(); + for (int i = 0; i < edited_navigation_shape->get_polygon(0).size(); i++) { + current_shape.push_back(vertices[edited_navigation_shape->get_polygon(0)[i]] + shape_anchor); + } + } + } + } +} + Vector2 AutotileEditor::snap_point(const Vector2 &point) { Vector2 p = point; Vector2 coord = edited_shape_coord; diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index de989a11e8..9bd3e23181 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -144,6 +144,7 @@ private: void draw_grid_snap(); void draw_polygon_shapes(); void close_shape(const Vector2 &shape_anchor); + void select_coord(const Vector2 &coord); Vector2 snap_point(const Vector2 &point); void edit(Object *p_node); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1f732992d5..d8d44a635a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1285,6 +1285,11 @@ void SceneTreeDock::_delete_confirm() { editor->get_viewport_control()->update(); editor->push_item(NULL); + + // Fixes the EditorHistory from still offering deleted notes + EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + editor_history->cleanup_history(); + EditorNode::get_singleton()->call("_prepare_history"); } void SceneTreeDock::_selection_changed() { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index fa0deb7606..cbf2687d73 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1053,6 +1053,8 @@ void ScriptEditorDebugger::_notification(int p_what) { break; }; + const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; + while (ppeer->get_available_packet_count() > 0) { if (pending_in_queue) { @@ -1117,6 +1119,9 @@ void ScriptEditorDebugger::_notification(int p_what) { break; } } + + if (OS::get_singleton()->get_ticks_msec() > until) + break; } } break; @@ -1166,6 +1171,7 @@ void ScriptEditorDebugger::start() { } set_process(true); + breaked = false; } void ScriptEditorDebugger::pause() { @@ -1177,6 +1183,7 @@ void ScriptEditorDebugger::unpause() { void ScriptEditorDebugger::stop() { set_process(false); + breaked = false; server->stop(); diff --git a/main/main.cpp b/main/main.cpp index b51ea3211c..48537dc3a7 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -665,6 +665,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60); GLOBAL_DEF("network/limits/debugger_stdout/max_chars_per_second", 2048); + GLOBAL_DEF("network/limits/debugger_stdout/max_messages_per_frame", 10); + GLOBAL_DEF("network/limits/debugger_stdout/max_errors_per_frame", 10); if (debug_mode == "remote") { diff --git a/methods.py b/methods.py index f9da6c8dd5..fbdac8a966 100644 --- a/methods.py +++ b/methods.py @@ -1274,6 +1274,8 @@ def detect_modules(): for x in files: if (not os.path.isdir(x)): continue + if (not os.path.exists(x + "/config.py")): + continue x = x.replace("modules/", "") # rest of world x = x.replace("modules\\", "") # win32 module_list.append(x) diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 9bcbc4c4ea..3fe7e36d45 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -343,15 +343,20 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a ERR_FAIL_COND_V(!is_valid(), String()); - String output; - output.resize(p_subject.length()); + // safety_zone is the number of chars we allocate in addition to the number of chars expected in order to + // guard against the PCRE API writing one additional \0 at the end. PCRE's API docs are unclear on whether + // PCRE understands outlength in pcre2_substitute() as counting an implicit additional terminating char or + // not. always allocating one char more than telling PCRE has us on the safe side. + const int safety_zone = 1; + + PCRE2_SIZE olength = p_subject.length() + 1; // space for output string and one terminating \0 character + Vector<CharType> output; + output.resize(olength + safety_zone); uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH; if (p_all) flags |= PCRE2_SUBSTITUTE_GLOBAL; - PCRE2_SIZE olength = output.length(); - PCRE2_SIZE length = p_subject.length(); if (p_end >= 0 && (uint32_t)p_end < length) length = p_end; @@ -363,15 +368,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx); PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str(); PCRE2_SPTR16 r = (PCRE2_SPTR16)p_replacement.c_str(); - PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.c_str(); + PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.ptrw(); pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx); int res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength); if (res == PCRE2_ERROR_NOMEMORY) { - output.resize(olength); - o = (PCRE2_UCHAR16 *)output.c_str(); + output.resize(olength + safety_zone); + o = (PCRE2_UCHAR16 *)output.ptrw(); res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength); } @@ -388,15 +393,15 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx); PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str(); PCRE2_SPTR32 r = (PCRE2_SPTR32)p_replacement.c_str(); - PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.c_str(); + PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.ptrw(); pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx); int res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength); if (res == PCRE2_ERROR_NOMEMORY) { - output.resize(olength); - o = (PCRE2_UCHAR32 *)output.c_str(); + output.resize(olength + safety_zone); + o = (PCRE2_UCHAR32 *)output.ptrw(); res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength); } @@ -407,7 +412,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a return String(); } - return output; + return String(output.ptr(), olength); } bool RegEx::is_valid() const { diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 37f25cc839..b5b0afb9e0 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC //@Override public boolean dispatchTouchEvent (MotionEvent event) { public boolean gotTouchEvent(final MotionEvent event) { - super.onTouchEvent(event); final int evcount = event.getPointerCount(); if (evcount == 0) return true; @@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC arr[i * 3 + 1] = (int)event.getX(i); arr[i * 3 + 2] = (int)event.getY(i); } + final int pointer_idx = event.getPointerId(event.getActionIndex()); //System.out.printf("gaction: %d\n",event.getAction()); final int action = event.getAction() & MotionEvent.ACTION_MASK; @@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC */ } break; case MotionEvent.ACTION_POINTER_UP: { - final int indexPointUp = event.getActionIndex(); - final int pointer_idx = event.getPointerId(indexPointUp); GodotLib.touch(4, pointer_idx, evcount, arr); //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; case MotionEvent.ACTION_POINTER_DOWN: { - int pointer_idx = event.getActionIndex(); GodotLib.touch(3, pointer_idx, evcount, arr); //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index ca4895a2be..0222758c2b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { @Override public boolean onTouchEvent(MotionEvent event) { - + super.onTouchEvent(event); return activity.gotTouchEvent(event); }; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 93272a1000..23811f963a 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -444,25 +444,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> } touch.clear(); } - } break; - case 3: { // add tuchi - - ERR_FAIL_INDEX(p_pointer, p_points.size()); + case 3: { // add touch - TouchPos tp = p_points[p_pointer]; - touch.push_back(tp); + for (int i = 0; i < p_points.size(); i++) { + if (p_points[i].id == p_pointer) { + TouchPos tp = p_points[i]; + touch.push_back(tp); - Ref<InputEventScreenTouch> ev; - ev.instance(); + Ref<InputEventScreenTouch> ev; + ev.instance(); - ev->set_index(tp.id); - ev->set_pressed(true); - ev->set_position(tp.pos); - input->parse_input_event(ev); + ev->set_index(tp.id); + ev->set_pressed(true); + ev->set_position(tp.pos); + input->parse_input_event(ev); + break; + } + } } break; - case 4: { + case 4: { // remove touch for (int i = 0; i < touch.size(); i++) { if (touch[i].id == p_pointer) { @@ -474,10 +476,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev->set_position(touch[i].pos); input->parse_input_event(ev); touch.remove(i); - i--; + + break; } } - } break; } } diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 99d44f3b5e..e3119814f4 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -407,7 +407,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name); if (err) { memdelete(da); - String err_str = String("Failed to export loading screen: ") + loading_screen_file; + String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file; ERR_PRINT(err_str.utf8().get_data()); return err; } diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 8472c3ccab..8c7a904bca 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -49,8 +49,14 @@ def configure(env): ## Build type if (env["target"] == "release"): - env.Append(CCFLAGS=['-O3']) - env.Append(LINKFLAGS=['-O3']) + # Use -Os to prioritize optimizing for reduced file size. This is + # particularly valuable for the web platform because it directly + # decreases download time. + # -Os reduces file size by around 5 MiB over -O3. -Oz only saves about + # 100 KiB over -Os, which does not justify the negative impact on + # run-time performance. + env.Append(CCFLAGS=['-Os']) + env.Append(LINKFLAGS=['-Os']) elif (env["target"] == "release_debug"): env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index dc4bdc7efb..bca1851f40 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -138,13 +138,17 @@ } var actualCanvas = this.rtenv.canvas; - var context = false; + var testContext = false; + var testCanvas; try { - context = actualCanvas.getContext('webgl2') || actualCanvas.getContext('experimental-webgl2'); + testCanvas = document.createElement('canvas'); + testContext = testCanvas.getContext('webgl2') || testCanvas.getContext('experimental-webgl2'); } catch (e) {} - if (!context) { + if (!testContext) { throw new Error("WebGL 2 not available"); } + testCanvas = null; + testContext = null; // canvas can grab focus on click if (actualCanvas.tabIndex < 0) { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 23ca1e3fb9..c4efa1f0ff 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -359,6 +359,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } if (err == OK) { + print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks"); + err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks"); + } + + if (err == OK) { print_line("Creating " + tmp_app_path_name + "/Contents/Resources"); err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources"); } @@ -502,10 +507,23 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (use_dmg()) { String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck"; - err = save_pack(p_preset, pack_path); + Vector<SharedObject> shared_objects; + Error err = save_pack(p_preset, pack_path, &shared_objects); // see if we can code sign our new package String identity = p_preset->get("codesign/identity"); + + if (err == OK) { + DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + for (int i = 0; i < shared_objects.size(); i++) { + da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); + if (err == OK && identity != "") { + err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file()); + } + } + memdelete(da); + } + if (err == OK && identity != "") { ep.step("Code signing bundle", 2); @@ -582,7 +600,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p ERR_CONTINUE(file.empty()); zipOpenNewFileInZip(dst_pkg_zip, - (pkg_name + ".app/Contents/MacOS/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(), + (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(), NULL, NULL, 0, diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 9423b6e1d6..3648d41604 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -139,6 +139,8 @@ public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false); + virtual void set_cursor_shape(CursorShape p_shape); virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 19f33c814f..939f75859c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -39,6 +39,8 @@ #include "servers/visual/visual_server_raster.h" #include "version_generated.gen.h" +#include <mach-o/dyld.h> + #include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> #include <IOKit/IOCFPlugIn.h> @@ -49,6 +51,7 @@ #include <os/log.h> #endif +#include <dlfcn.h> #include <fcntl.h> #include <libproc.h> #include <stdio.h> @@ -1262,6 +1265,28 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) { [window release]; } +Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { + + String path = p_path; + + if (!FileAccess::exists(path)) { + //this code exists so gdnative can load .dylib files from within the executable path + path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); + } + + if (!FileAccess::exists(path)) { + //this code exists so gdnative can load .dylib files from a standard macOS location + path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file()); + } + + p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); + if (!p_library_handle) { + ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror()); + ERR_FAIL_V(ERR_CANT_OPEN); + } + return OK; +} + void OS_OSX::set_cursor_shape(CursorShape p_shape) { if (cursor_shape == p_shape) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 0a6d80d49c..006347d30a 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -143,7 +143,7 @@ Transform2D Camera2D::get_camera_transform() { if (smoothing_enabled && !Engine::get_singleton()->is_editor_hint()) { - float c = smoothing * get_physics_process_delta_time(); + float c = smoothing * get_process_delta_time(); smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos; ret_camera_pos = smoothed_camera_pos; //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; @@ -217,14 +217,14 @@ void Camera2D::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_PHYSICS_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { _update_scroll(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - if (!is_physics_processing()) + if (!is_processing_internal()) _update_scroll(); } break; @@ -246,7 +246,7 @@ void Camera2D::_notification(int p_what) { add_to_group(canvas_group_name); if (Engine::get_singleton()->is_editor_hint()) { - set_physics_process(false); + set_process_internal(false); } _update_scroll(); @@ -503,9 +503,9 @@ void Camera2D::set_follow_smoothing(float p_speed) { smoothing = p_speed; if (smoothing > 0 && !(is_inside_tree() && Engine::get_singleton()->is_editor_hint())) - set_physics_process(true); + set_process_internal(true); else - set_physics_process(false); + set_process_internal(false); } float Camera2D::get_follow_smoothing() const { diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 332eb3c740..c7556c0c5f 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -115,7 +115,7 @@ public: MODE_KINEMATIC, }; -private: +protected: bool can_sleep; PhysicsDirectBodyState *state; Mode mode; @@ -178,9 +178,8 @@ private: void _body_exit_tree(ObjectID p_id); void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape); - void _direct_state_changed(Object *p_state); + virtual void _direct_state_changed(Object *p_state); -protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index bc968b0a5f..aeee51c4b2 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -375,7 +375,7 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) { Basis steeringMat(up, steering); - Basis rotatingMat(right, -wheel.m_rotation); + Basis rotatingMat(right, wheel.m_rotation); /* if (p_idx==1) @@ -816,26 +816,24 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) { void VehicleBody::_direct_state_changed(Object *p_state) { - PhysicsDirectBodyState *s = Object::cast_to<PhysicsDirectBodyState>(p_state); + RigidBody::_direct_state_changed(p_state); - set_ignore_transform_notification(true); - set_global_transform(s->get_transform()); - set_ignore_transform_notification(false); + state = Object::cast_to<PhysicsDirectBodyState>(p_state); - float step = s->get_step(); + float step = state->get_step(); for (int i = 0; i < wheels.size(); i++) { - _update_wheel(i, s); + _update_wheel(i, state); } for (int i = 0; i < wheels.size(); i++) { - _ray_cast(i, s); - wheels[i]->set_transform(s->get_transform().inverse() * wheels[i]->m_worldTransform); + _ray_cast(i, state); + wheels[i]->set_transform(state->get_transform().inverse() * wheels[i]->m_worldTransform); } - _update_suspension(s); + _update_suspension(state); for (int i = 0; i < wheels.size(); i++) { @@ -848,21 +846,21 @@ void VehicleBody::_direct_state_changed(Object *p_state) { suspensionForce = wheel.m_maxSuspensionForce; } Vector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step; - Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - s->get_transform().origin; + Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - state->get_transform().origin; - s->apply_impulse(relpos, impulse); + state->apply_impulse(relpos, impulse); //getRigidBody()->applyImpulse(impulse, relpos); } - _update_friction(s); + _update_friction(state); for (int i = 0; i < wheels.size(); i++) { VehicleWheel &wheel = *wheels[i]; - Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - s->get_transform().origin; - Vector3 vel = s->get_linear_velocity() + (s->get_angular_velocity()).cross(relpos); // * mPos); + Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - state->get_transform().origin; + Vector3 vel = state->get_linear_velocity() + (state->get_angular_velocity()).cross(relpos); // * mPos); if (wheel.m_raycastInfo.m_isInContact) { - const Transform &chassisWorldTransform = s->get_transform(); + const Transform &chassisWorldTransform = state->get_transform(); Vector3 fwd( chassisWorldTransform.basis[0][Vector3::AXIS_Z], @@ -883,29 +881,8 @@ void VehicleBody::_direct_state_changed(Object *p_state) { wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact } - linear_velocity = s->get_linear_velocity(); -} - -void VehicleBody::set_mass(real_t p_mass) { - - mass = p_mass; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass); -} - -real_t VehicleBody::get_mass() const { - return mass; -} - -void VehicleBody::set_friction(real_t p_friction) { - - friction = p_friction; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction); -} - -real_t VehicleBody::get_friction() const { - - return friction; + state = NULL; } void VehicleBody::set_engine_force(float p_engine_force) { @@ -936,18 +913,8 @@ float VehicleBody::get_steering() const { return m_steeringValue; } -Vector3 VehicleBody::get_linear_velocity() const { - return linear_velocity; -} - void VehicleBody::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mass", "mass"), &VehicleBody::set_mass); - ClassDB::bind_method(D_METHOD("get_mass"), &VehicleBody::get_mass); - - ClassDB::bind_method(D_METHOD("set_friction", "friction"), &VehicleBody::set_friction); - ClassDB::bind_method(D_METHOD("get_friction"), &VehicleBody::get_friction); - ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force); ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody::get_engine_force); @@ -957,21 +924,14 @@ void VehicleBody::_bind_methods() { ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody::set_steering); ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody::get_steering); - ClassDB::bind_method(D_METHOD("get_linear_velocity"), &VehicleBody::get_linear_velocity); - - ClassDB::bind_method(D_METHOD("_direct_state_changed"), &VehicleBody::_direct_state_changed); - ADD_GROUP("Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::REAL, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01"), "set_engine_force", "get_engine_force"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering"); - ADD_GROUP("Mass", ""); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_RANGE, "0.01,65536,0.01"), "set_mass", "get_mass"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0.01,1,0.01"), "set_friction", "get_friction"); } VehicleBody::VehicleBody() : - PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { + RigidBody() { m_pitchControl = 0; m_currentVehicleSpeedKmHour = real_t(0.); @@ -982,10 +942,11 @@ VehicleBody::VehicleBody() : friction = 1; + state = NULL; ccd = false; exclude.insert(get_rid()); - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + //PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); set_mass(40); } diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index 1c7dacf5ac..7810a42e8a 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -139,20 +139,13 @@ public: VehicleWheel(); }; -class VehicleBody : public PhysicsBody { +class VehicleBody : public RigidBody { - GDCLASS(VehicleBody, PhysicsBody); - - real_t mass; - real_t friction; + GDCLASS(VehicleBody, RigidBody); float engine_force; float brake; - Vector3 linear_velocity; - Vector3 angular_velocity; - bool ccd; - real_t m_pitchControl; real_t m_steeringValue; real_t m_currentVehicleSpeedKmHour; @@ -192,12 +185,6 @@ class VehicleBody : public PhysicsBody { void _direct_state_changed(Object *p_state); public: - void set_mass(real_t p_mass); - real_t get_mass() const; - - void set_friction(real_t p_friction); - real_t get_friction() const; - void set_engine_force(float p_engine_force); float get_engine_force() const; @@ -207,8 +194,6 @@ public: void set_steering(float p_steering); float get_steering() const; - Vector3 get_linear_velocity() const; - VehicleBody(); }; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index d7987d4a19..cf01ce8643 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -305,11 +305,15 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { case BUTTON_WHEEL_DOWN: { - _scroll(-b->get_factor(), b->get_position()); + if (get_global_position().y + get_size().y > get_viewport_rect().size.y) { + _scroll(-b->get_factor(), b->get_position()); + } } break; case BUTTON_WHEEL_UP: { - _scroll(b->get_factor(), b->get_position()); + if (get_global_position().y < 0) { + _scroll(b->get_factor(), b->get_position()); + } } break; case BUTTON_LEFT: { @@ -380,7 +384,9 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventPanGesture> pan_gesture = p_event; if (pan_gesture.is_valid()) { - _scroll(-pan_gesture->get_delta().y, pan_gesture->get_position()); + if (get_global_position().y + get_size().y > get_viewport_rect().size.y || get_global_position().y < 0) { + _scroll(-pan_gesture->get_delta().y, pan_gesture->get_position()); + } } } diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 953ebe84f6..b0739a2f37 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -38,11 +38,6 @@ int VideoPlayer::sp_get_channel_count() const { return playback->get_channels(); } -void VideoPlayer::sp_set_mix_rate(int p_rate) { - - server_mix_rate = p_rate; -} - bool VideoPlayer::mix(AudioFrame *p_buffer, int p_frames) { // Check the amount resampler can really handle. @@ -241,7 +236,7 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) { AudioServer::get_singleton()->lock(); if (channels > 0) - resampler.setup(channels, playback->get_mix_rate(), server_mix_rate, buffering_ms, 0); + resampler.setup(channels, playback->get_mix_rate(), AudioServer::get_singleton()->get_mix_rate(), buffering_ms, 0); else resampler.clear(); AudioServer::get_singleton()->unlock(); @@ -494,7 +489,6 @@ VideoPlayer::VideoPlayer() { bus_index = 0; buffering_ms = 500; - server_mix_rate = 44100; // internal_stream.player=this; // stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index 7010c71ad9..5c379b5620 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -50,7 +50,6 @@ class VideoPlayer : public Control { Ref<VideoStream> stream; int sp_get_channel_count() const; - void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate bool mix(AudioFrame *p_buffer, int p_frames); RID stream_rid; @@ -69,7 +68,6 @@ class VideoPlayer : public Control { bool expand; bool loops; int buffering_ms; - int server_mix_rate; int audio_track; int bus_index; diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 00fc601779..575c222cc1 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -651,8 +651,8 @@ DynamicFontAtSize::~DynamicFontAtSize() { if (valid) { FT_Done_FreeType(library); - font->size_cache.erase(id); } + font->size_cache.erase(id); } ///////////////////////// |