diff options
56 files changed, 855 insertions, 296 deletions
diff --git a/core/io/unzip.c b/core/io/unzip.c index 78672677f9..7aa0a86d13 100644 --- a/core/io/unzip.c +++ b/core/io/unzip.c @@ -1031,10 +1031,19 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, if (lSeek!=0) { - if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; + if (lSeek<0) { + // WORKAROUND for backwards seeking + z_off_t pos = ZTELL64(s->z_filefunc, s->filestream); + if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } else { + if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } } while(acc < file_info.size_file_extra) diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index a3ee9395de..1f23e8f33d 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -35,6 +35,8 @@ FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX]={0,0}; +FileAccess::FileCloseFailNotify FileAccess::close_fail_notify=NULL; + bool FileAccess::backup_save=false; diff --git a/core/os/file_access.h b/core/os/file_access.h index 2c894c94eb..8d5823663e 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -47,6 +47,8 @@ public: ACCESS_MAX }; + typedef void (*FileCloseFailNotify)(const String&); + typedef FileAccess*(*CreateFunc)(); bool endian_swap; bool real_is_double; @@ -56,7 +58,7 @@ protected: virtual Error _open(const String& p_path, int p_mode_flags)=0; ///< open a file virtual uint64_t _get_modified_time(const String& p_file)=0; - + static FileCloseFailNotify close_fail_notify; private: static bool backup_save; @@ -69,8 +71,12 @@ private: return memnew( T ); } + + public: + static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify=p_cbk; } + virtual void _set_access_type(AccessType p_access); enum ModeFlags { diff --git a/core/script_language.cpp b/core/script_language.cpp index b3116a0297..68a694398a 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -32,7 +32,7 @@ ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES]; int ScriptServer::_language_count=0; bool ScriptServer::scripting_enabled=true; - +bool ScriptServer::reload_scripts_on_save=false; void Script::_notification( int p_what) { @@ -92,6 +92,16 @@ void ScriptServer::init_languages() { } } +void ScriptServer::set_reload_scripts_on_save(bool p_enable) { + + reload_scripts_on_save=p_enable; +} + +bool ScriptServer::is_reload_scripts_on_save_enabled() { + + return reload_scripts_on_save; +} + void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) { List<PropertyInfo> pinfo; diff --git a/core/script_language.h b/core/script_language.h index cbf6d8e116..478ebd88ed 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -47,6 +47,7 @@ class ScriptServer { static ScriptLanguage *_languages[MAX_LANGUAGES]; static int _language_count; static bool scripting_enabled; + static bool reload_scripts_on_save; public: static void set_scripting_enabled(bool p_enabled); @@ -55,6 +56,9 @@ public: static ScriptLanguage *get_language(int p_idx); static void register_language(ScriptLanguage *p_language); + static void set_reload_scripts_on_save(bool p_enable); + static bool is_reload_scripts_on_save_enabled(); + static void init_languages(); }; diff --git a/core/ustring.cpp b/core/ustring.cpp index a039ba11cd..309b9e08fa 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2752,6 +2752,50 @@ bool String::begins_with(const char* p_string) const { } +bool String::is_subsequence_of(const String& p_string) const { + + return _base_is_subsequence_of(p_string, false); +} + +bool String::is_subsequence_ofi(const String& p_string) const { + + return _base_is_subsequence_of(p_string, true); +} + +bool String::_base_is_subsequence_of(const String& p_string, bool case_insensitive) const { + + int len=length(); + if (len == 0) { + // Technically an empty string is subsequence of any string + return true; + } + + if (len > p_string.length()) { + return false; + } + + const CharType *src = &operator[](0); + const CharType *tgt = &p_string[0]; + + for (;*src && *tgt;tgt++) { + bool match = false; + if (case_insensitive) { + CharType srcc = _find_lower(*src); + CharType tgtc = _find_lower(*tgt); + match = srcc == tgtc; + } else { + match = *src == *tgt; + } + if (match) { + src++; + if(!*src) { + return true; + } + } + } + + return false; +} static bool _wildcard_match(const CharType* p_pattern, const CharType* p_string,bool p_case_sensitive) { switch (*p_pattern) { diff --git a/core/ustring.h b/core/ustring.h index e03f74f506..fddb77b040 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -66,6 +66,7 @@ class String : public Vector<CharType> { void copy_from(const char *p_cstr); void copy_from(const CharType* p_cstr, int p_clip_to=-1); void copy_from(const CharType& p_char); + bool _base_is_subsequence_of(const String& p_string, bool case_insensitive) const; public: @@ -122,6 +123,8 @@ public: bool begins_with(const String& p_string) const; bool begins_with(const char* p_string) const; bool ends_with(const String& p_string) const; + bool is_subsequence_of(const String& p_string) const; + bool is_subsequence_ofi(const String& p_string) const; String replace_first(String p_key,String p_with) const; String replace(String p_key,String p_with) const; String replacen(String p_key,String p_with) const; diff --git a/core/variant.cpp b/core/variant.cpp index 38f5e69cc0..472d6cf568 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -3029,9 +3029,9 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c int errorarg=ce.argument; err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+"."; } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) { - err_text="Expected "+itos(ce.argument)+" arguments."; + err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+"."; } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) { - err_text="Expected "+itos(ce.argument)+" arguments."; + err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+"."; } else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) { err_text="Method not found."; } else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) { diff --git a/core/variant_call.cpp b/core/variant_call.cpp index cc2d15b88c..94ab93d55c 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -247,6 +247,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(String,matchn); VCALL_LOCALMEM1R(String,begins_with); VCALL_LOCALMEM1R(String,ends_with); + VCALL_LOCALMEM1R(String,is_subsequence_of); + VCALL_LOCALMEM1R(String,is_subsequence_ofi); VCALL_LOCALMEM2R(String,replace); VCALL_LOCALMEM2R(String,replacen); VCALL_LOCALMEM2R(String,insert); @@ -1269,6 +1271,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(STRING,BOOL,String,matchn,STRING,"expr",varray()); ADDFUNC1(STRING,BOOL,String,begins_with,STRING,"text",varray()); ADDFUNC1(STRING,BOOL,String,ends_with,STRING,"text",varray()); + ADDFUNC1(STRING,BOOL,String,is_subsequence_of,STRING,"text",varray()); + ADDFUNC1(STRING,BOOL,String,is_subsequence_ofi,STRING,"text",varray()); ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray()); ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray()); diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index e2786b8099..875a144fef 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1789,6 +1789,14 @@ Error VariantParser::parse(Stream *p_stream, Variant& r_ret, String &r_err_str, ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// +static String rtosfix(double p_value) { + + + if (p_value==0.0) + return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist. + else + return rtoss(p_value); +} Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud,EncodeResourceFunc p_encode_res_func,void* p_encode_res_ud) { @@ -1807,7 +1815,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str } break; case Variant::REAL: { - String s = rtoss(p_variant.operator real_t()); + String s = rtosfix(p_variant.operator real_t()); if (s.find(".")==-1 && s.find("e")==-1) s+=".0"; p_store_string_func(p_store_string_ud, s ); @@ -1822,35 +1830,35 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str case Variant::VECTOR2: { Vector2 v = p_variant; - p_store_string_func(p_store_string_ud,"Vector2( "+rtoss(v.x) +", "+rtoss(v.y)+" )" ); + p_store_string_func(p_store_string_ud,"Vector2( "+rtosfix(v.x) +", "+rtosfix(v.y)+" )" ); } break; case Variant::RECT2: { Rect2 aabb = p_variant; - p_store_string_func(p_store_string_ud,"Rect2( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y)+" )" ); + p_store_string_func(p_store_string_ud,"Rect2( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y)+" )" ); } break; case Variant::VECTOR3: { Vector3 v = p_variant; - p_store_string_func(p_store_string_ud,"Vector3( "+rtoss(v.x) +", "+rtoss(v.y)+", "+rtoss(v.z)+" )"); + p_store_string_func(p_store_string_ud,"Vector3( "+rtosfix(v.x) +", "+rtosfix(v.y)+", "+rtosfix(v.z)+" )"); } break; case Variant::PLANE: { Plane p = p_variant; - p_store_string_func(p_store_string_ud,"Plane( "+rtoss(p.normal.x) +", "+rtoss(p.normal.y)+", "+rtoss(p.normal.z)+", "+rtoss(p.d)+" )" ); + p_store_string_func(p_store_string_ud,"Plane( "+rtosfix(p.normal.x) +", "+rtosfix(p.normal.y)+", "+rtosfix(p.normal.z)+", "+rtosfix(p.d)+" )" ); } break; case Variant::_AABB: { AABB aabb = p_variant; - p_store_string_func(p_store_string_ud,"AABB( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.pos.z) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) +", "+rtoss(aabb.size.z)+" )" ); + p_store_string_func(p_store_string_ud,"AABB( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.pos.z) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y) +", "+rtosfix(aabb.size.z)+" )" ); } break; case Variant::QUAT: { Quat quat = p_variant; - p_store_string_func(p_store_string_ud,"Quat( "+rtoss(quat.x)+", "+rtoss(quat.y)+", "+rtoss(quat.z)+", "+rtoss(quat.w)+" )"); + p_store_string_func(p_store_string_ud,"Quat( "+rtosfix(quat.x)+", "+rtosfix(quat.y)+", "+rtosfix(quat.z)+", "+rtosfix(quat.w)+" )"); } break; case Variant::MATRIX32: { @@ -1862,7 +1870,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i!=0 || j!=0) s+=", "; - s+=rtoss( m3.elements[i][j] ); + s+=rtosfix( m3.elements[i][j] ); } } @@ -1878,7 +1886,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i!=0 || j!=0) s+=", "; - s+=rtoss( m3.elements[i][j] ); + s+=rtosfix( m3.elements[i][j] ); } } @@ -1895,11 +1903,11 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i!=0 || j!=0) s+=", "; - s+=rtoss( m3.elements[i][j] ); + s+=rtosfix( m3.elements[i][j] ); } } - s=s+", "+rtoss(t.origin.x) +", "+rtoss(t.origin.y)+", "+rtoss(t.origin.z); + s=s+", "+rtosfix(t.origin.x) +", "+rtosfix(t.origin.y)+", "+rtosfix(t.origin.z); p_store_string_func(p_store_string_ud,s+" )"); } break; @@ -1908,7 +1916,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str case Variant::COLOR: { Color c = p_variant; - p_store_string_func(p_store_string_ud,"Color( "+rtoss(c.r) +", "+rtoss(c.g)+", "+rtoss(c.b)+", "+rtoss(c.a)+" )"); + p_store_string_func(p_store_string_ud,"Color( "+rtosfix(c.r) +", "+rtosfix(c.g)+", "+rtosfix(c.b)+", "+rtosfix(c.a)+" )"); } break; case Variant::IMAGE: { @@ -2143,7 +2151,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i>0) p_store_string_func(p_store_string_ud,", "); - p_store_string_func(p_store_string_ud,rtoss(ptr[i])); + p_store_string_func(p_store_string_ud,rtosfix(ptr[i])); } p_store_string_func(p_store_string_ud," )"); @@ -2184,7 +2192,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i>0) p_store_string_func(p_store_string_ud,", "); - p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y) ); + p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y) ); } p_store_string_func(p_store_string_ud," )"); @@ -2202,7 +2210,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i>0) p_store_string_func(p_store_string_ud,", "); - p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y)+", "+rtoss(ptr[i].z) ); + p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y)+", "+rtosfix(ptr[i].z) ); } p_store_string_func(p_store_string_ud," )"); @@ -2222,7 +2230,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str if (i>0) p_store_string_func(p_store_string_ud,", "); - p_store_string_func(p_store_string_ud,rtoss(ptr[i].r)+", "+rtoss(ptr[i].g)+", "+rtoss(ptr[i].b)+", "+rtoss(ptr[i].a) ); + p_store_string_func(p_store_string_ud,rtosfix(ptr[i].r)+", "+rtosfix(ptr[i].g)+", "+rtosfix(ptr[i].b)+", "+rtosfix(ptr[i].a) ); } p_store_string_func(p_store_string_ud," )"); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index b72f082afa..0d8f7eecdd 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8751,7 +8751,7 @@ Concave polygon 2D shape resource for physics. </brief_description> <description> - Concave polygon 2D shape resource for physics. It is made out of segments and is very optimal for complex polygonal concave collisions. It is really not advised to use for RigidBody nodes. A CollisionPolygon2D in convex decomposition mode (solids) or several convex objects are advised for that instead. Otherwise, a concave polygon 2D shape is better for static collisions. + Concave polygon 2D shape resource for physics. It is made out of segments and is very optimal for complex polygonal concave collisions. It is really not advised to use for [RigidBody2D] nodes. A CollisionPolygon2D in convex decomposition mode (solids) or several convex objects are advised for that instead. Otherwise, a concave polygon 2D shape is better for static collisions. The main difference between a [ConvexPolygonShape2D] and a [ConcavePolygonShape2D] is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex in order to speed up collision detection. </description> <methods> @@ -24970,12 +24970,14 @@ This method controls whether the position between two cached points is interpola <return type="float"> </return> <description> + Return the rate at which the body stops moving, if there are not any other forces moving it. </description> </method> <method name="get_total_angular_damp" qualifiers="const"> <return type="float"> </return> <description> + Return the rate at which the body stops rotating, if there are not any other forces moving it. </description> </method> <method name="get_inverse_mass" qualifiers="const"> @@ -25070,6 +25072,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="contact_idx" type="int"> </argument> <description> + Return the local normal (of this body) of the contact point. </description> </method> <method name="get_contact_local_shape" qualifiers="const"> @@ -25087,7 +25090,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="contact_idx" type="int"> </argument> <description> - Return the RID of the collider. + Return the [RID] of the collider. </description> </method> <method name="get_contact_collider_pos" qualifiers="const"> @@ -25132,6 +25135,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="contact_idx" type="int"> </argument> <description> + Return the metadata of the collided shape. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. </description> </method> <method name="get_contact_collider_velocity_at_pos" qualifiers="const"> @@ -25168,8 +25172,10 @@ This method controls whether the position between two cached points is interpola </class> <class name="Physics2DDirectBodyStateSW" inherits="Physics2DDirectBodyState" category="Core"> <brief_description> + Software implementation of [Physics2DDirectBodyState]. </brief_description> <description> + Software implementation of [Physics2DDirectBodyState]. This object exposes no new methods or properties and should not be used, as [Physics2DDirectBodyState] selects the best implementation available. </description> <methods> </methods> @@ -25198,6 +25204,13 @@ This method controls whether the position between two cached points is interpola <argument index="4" name="type_mask" type="int" default="15"> </argument> <description> + Check whether a point is inside any shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields: + shape: Shape index within the object the point is in. + metadata: Metadata of the shape the point is in. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + collider_id: Id of the object the point is in. + collider: Object the point is inside of. + rid: [RID] of the object the point is in. + Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). </description> </method> <method name="intersect_ray"> @@ -25214,15 +25227,16 @@ This method controls whether the position between two cached points is interpola <argument index="4" name="type_mask" type="int" default="15"> </argument> <description> - Intersect a ray in a given space, the returned object is a dictionary with the following fields: - position: place where ray is stopped. - normal: normal of the object at the point where the ray was stopped. - shape: shape index of the object against which the ray was stopped. - collider_: collider against which the ray was stopped. - collider_id: collider id of the object against which the ray was stopped. - collider: collider object against which the ray was stopped. + Intersect a ray in a given space. The returned object is a dictionary with the following fields: + position: Place where ray is stopped. + normal: Normal of the object at the point where the ray was stopped. + shape: Shape index within the object against which the ray was stopped. + metadata: Metadata of the shape against which the ray was stopped. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + collider_id: Id of the object against which the ray was stopped. + collider: Object against which the ray was stopped. rid: [RID] of the object against which the ray was stopped. If the ray did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. + Additionally, the method can take an array of objects or [RID]s that are to be excluded from collisions, a bitmask representing the physics layers to check in, and another bitmask for the types of objects to check (see TYPE_MASK_* constants). </description> </method> <method name="intersect_shape"> @@ -25233,7 +25247,13 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="max_results" type="int" default="32"> </argument> <description> - Intersect a given shape (RID or [Shape2D]) against the space, the intersected shapes are returned in a special result object. + Check the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields: + shape: Shape index within the object the shape intersected. + metadata: Metadata of the shape intersected by the shape given through the [Physics2DShapeQueryParameters]. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + collider_id: Id of the object the shape intersected. + collider: Object the shape intersected. + rid: [RID] of the object the shape intersected. + The number of intersections can be limited with the second paramater, to reduce the processing time. </description> </method> <method name="cast_motion"> @@ -25242,6 +25262,8 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> </argument> <description> + Check whether the shape can travel to a point. If it can, the method will return an array with two floats: The first is the distance the shape can move in that direction without colliding, and the second is the distance at which it will collide. + If the shape can not move, the array will be empty. </description> </method> <method name="collide_shape"> @@ -25252,6 +25274,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="max_results" type="int" default="32"> </argument> <description> + Check the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. </description> </method> <method name="get_rest_info"> @@ -25260,21 +25283,37 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> </argument> <description> + Check the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. If it collides with more than a shape, the nearest one is selected. The returned object is a dictionary containing the following fields: + pointo: Place where the shapes intersect. + normal: Normal of the object at the point where the shapes intersect. + shape: Shape index within the object against which the shape intersected. + metadata: Metadata of the shape against which the shape intersected. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + collider_id: Id of the object against which the shape intersected. + collider: Object against which the shape intersected. + rid: [RID] of the object against which the shape intersected. + linear_velocity: The movement vector of the object the shape intersected, if it was a body. If it was an area, it is (0,0). + If the shape did not intersect anything, then an empty dictionary (dir.empty()==true) is returned instead. </description> </method> </methods> <constants> <constant name="TYPE_MASK_STATIC_BODY" value="1"> + Check for collisions with static bodies. </constant> <constant name="TYPE_MASK_KINEMATIC_BODY" value="2"> + Check for collisions with kinematic bodies. </constant> <constant name="TYPE_MASK_RIGID_BODY" value="4"> + Check for collisions with rigid bodies. </constant> <constant name="TYPE_MASK_CHARACTER_BODY" value="8"> + Check for collisions with rigid bodies in character mode. </constant> <constant name="TYPE_MASK_AREA" value="16"> + Check for collisions with areas. </constant> <constant name="TYPE_MASK_COLLISION" value="15"> + Check for collisions with any kind of bodies (but not areas). </constant> </constants> </class> @@ -25283,7 +25322,7 @@ This method controls whether the position between two cached points is interpola Physics 2D Server. </brief_description> <description> - Physics 2D Server is the server responsible for all 2D physics. + Physics 2D Server is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree. </description> <methods> <method name="shape_create"> @@ -25292,6 +25331,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="type" type="int"> </argument> <description> + Create a shape of type SHAPE_*. Does not assign it to a body or an area. To do so, you must use [method area_set_shape] or [method body_set_shape]. </description> </method> <method name="shape_set_data"> @@ -25300,6 +25340,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="data" type="Variant"> </argument> <description> + Set the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type]. </description> </method> <method name="shape_get_type" qualifiers="const"> @@ -25308,18 +25349,23 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="shape" type="RID"> </argument> <description> + Return the type of shape (see SHAPE_* constants). </description> </method> <method name="shape_get_data" qualifiers="const"> + <return type="Variant"> + </return> <argument index="0" name="shape" type="RID"> </argument> <description> + Return the shape data. </description> </method> <method name="space_create"> <return type="RID"> </return> <description> + Create a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space]. </description> </method> <method name="space_set_active"> @@ -25328,6 +25374,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="active" type="bool"> </argument> <description> + Mark a space as active. It will not have an effect, unless it is assigned to an area or body. </description> </method> <method name="space_is_active" qualifiers="const"> @@ -25336,6 +25383,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="space" type="RID"> </argument> <description> + Return whether the space is active. </description> </method> <method name="space_set_param"> @@ -25346,6 +25394,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="float"> </argument> <description> + Set the value for a space parameter. A list of available parameters is on the SPACE_PARAM_* constants. </description> </method> <method name="space_get_param" qualifiers="const"> @@ -25356,6 +25405,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="param" type="int"> </argument> <description> + Return the value of a space parameter. </description> </method> <method name="space_get_direct_state"> @@ -25364,12 +25414,14 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="space" type="RID"> </argument> <description> + Return the state of a space, a [Physics2DDirectSpaceState]. This object can be used to make collision/intersection queries. </description> </method> <method name="area_create"> <return type="RID"> </return> <description> + Create an [Area2D]. </description> </method> <method name="area_set_space"> @@ -25378,6 +25430,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="space" type="RID"> </argument> <description> + Assign a space to the area. </description> </method> <method name="area_get_space" qualifiers="const"> @@ -25386,6 +25439,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="area" type="RID"> </argument> <description> + Return the space assigned to the area. </description> </method> <method name="area_set_space_override_mode"> @@ -25394,6 +25448,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mode" type="int"> </argument> <description> + Set the space override mode for the area. The modes are described in the constants AREA_SPACE_OVERRIDE_*. </description> </method> <method name="area_get_space_override_mode" qualifiers="const"> @@ -25402,6 +25457,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="area" type="RID"> </argument> <description> + Return the space override mode for the area. </description> </method> <method name="area_add_shape"> @@ -25412,6 +25468,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="transform" type="Matrix32" default="1,0, 0,1, 0,0"> </argument> <description> + Add a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="area_set_shape"> @@ -25422,6 +25479,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="shape" type="RID"> </argument> <description> + Substitute a given area shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="area_set_shape_transform"> @@ -25432,6 +25490,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="transform" type="Matrix32"> </argument> <description> + Set the transform matrix for an area shape. </description> </method> <method name="area_get_shape_count" qualifiers="const"> @@ -25440,6 +25499,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="area" type="RID"> </argument> <description> + Return the number of shapes assigned to an area. </description> </method> <method name="area_get_shape" qualifiers="const"> @@ -25450,6 +25510,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return the [RID] of the nth shape of an area. </description> </method> <method name="area_get_shape_transform" qualifiers="const"> @@ -25460,6 +25521,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return the transform matrix of a shape within an area. </description> </method> <method name="area_remove_shape"> @@ -25468,12 +25530,14 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Remove a shape from an area. It does not delete the shape, so it can be reassigned later. </description> </method> <method name="area_clear_shapes"> <argument index="0" name="area" type="RID"> </argument> <description> + Remove all shapes from an area. It does not delete the shapes, so they can be reassigned later. </description> </method> <method name="area_set_layer_mask"> @@ -25482,6 +25546,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mask" type="int"> </argument> <description> + Assign the area to one or many physics layers. </description> </method> <method name="area_set_collision_mask"> @@ -25490,6 +25555,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mask" type="int"> </argument> <description> + Set which physics layers the area will monitor. </description> </method> <method name="area_set_param"> @@ -25500,6 +25566,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="Variant"> </argument> <description> + Set the value for an area parameter. A list of available parameters is on the AREA_PARAM_* constants. </description> </method> <method name="area_set_transform"> @@ -25508,14 +25575,18 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="transform" type="Matrix32"> </argument> <description> + Set the transform matrix for an area. </description> </method> <method name="area_get_param" qualifiers="const"> + <return type="Variant"> + </return> <argument index="0" name="area" type="RID"> </argument> <argument index="1" name="param" type="int"> </argument> <description> + Return an area parameter value. </description> </method> <method name="area_get_transform" qualifiers="const"> @@ -25524,6 +25595,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="area" type="RID"> </argument> <description> + Return the transform matrix for an area. </description> </method> <method name="area_attach_object_instance_ID"> @@ -25532,6 +25604,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="id" type="int"> </argument> <description> + Assign the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="area_get_object_instance_ID" qualifiers="const"> @@ -25540,6 +25613,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="area" type="RID"> </argument> <description> + Get the instance ID of the object the area is assigned to. </description> </method> <method name="area_set_monitor_callback"> @@ -25550,6 +25624,12 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="method" type="String"> </argument> <description> + Set the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters: + 1: AREA_BODY_ADDED or AREA_BODY_REMOVED, depending on whether the object entered or exited the area. + 2: [RID] of the object that entered/exited the area. + 3: Instance ID of the object that entered/exited the area. + 4: The shape index of the object that entered/exited the area. + 5: The shape index of the area where the object entered/exited. </description> </method> <method name="body_create"> @@ -25560,6 +25640,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="init_sleeping" type="bool" default="false"> </argument> <description> + Create a physics body. The first parameter can be any value from constants BODY_MODE*, for the type of body created. Additionally, the body can be created in sleeping state to save processing time. </description> </method> <method name="body_set_space"> @@ -25568,6 +25649,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="space" type="RID"> </argument> <description> + Assign a space to the body (see [method create_space]). </description> </method> <method name="body_get_space" qualifiers="const"> @@ -25576,6 +25658,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the [RID] of the space assigned to a body. </description> </method> <method name="body_set_mode"> @@ -25584,6 +25667,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mode" type="int"> </argument> <description> + Set the body mode, from one of the constants BODY_MODE*. </description> </method> <method name="body_get_mode" qualifiers="const"> @@ -25592,6 +25676,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the body mode. </description> </method> <method name="body_add_shape"> @@ -25602,6 +25687,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="transform" type="Matrix32" default="1,0, 0,1, 0,0"> </argument> <description> + Add a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index. </description> </method> <method name="body_set_shape"> @@ -25612,6 +25698,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="shape" type="RID"> </argument> <description> + Substitute a given body shape by another. The old shape is selected by its index, the new one by its [RID]. </description> </method> <method name="body_set_shape_transform"> @@ -25622,6 +25709,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="transform" type="Matrix32"> </argument> <description> + Set the transform matrix for a body shape. </description> </method> <method name="body_set_shape_metadata"> @@ -25632,6 +25720,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="metadata" type="Variant"> </argument> <description> + Set metadata of a shape within a body. This metadata is different from [method Object.set_meta], and can be retrieved on shape queries. </description> </method> <method name="body_get_shape_count" qualifiers="const"> @@ -25640,6 +25729,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the number of shapes assigned to a body. </description> </method> <method name="body_get_shape" qualifiers="const"> @@ -25650,6 +25740,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return the [RID] of the nth shape of a body. </description> </method> <method name="body_get_shape_transform" qualifiers="const"> @@ -25660,14 +25751,18 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return the transform matrix of a body shape. </description> </method> <method name="body_get_shape_metadata" qualifiers="const"> + <return type="Variant"> + </return> <argument index="0" name="body" type="RID"> </argument> <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return the metadata of a shape of a body. </description> </method> <method name="body_remove_shape"> @@ -25676,12 +25771,14 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Remove a shape from a body. The shape is not deleted, so it can be reused afterwards. </description> </method> <method name="body_clear_shapes"> <argument index="0" name="body" type="RID"> </argument> <description> + Remove all shapes from a body. </description> </method> <method name="body_set_shape_as_trigger"> @@ -25692,6 +25789,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="enable" type="bool"> </argument> <description> + Mark a body's shape as a trigger. A trigger shape cannot affect other bodies, but detects other shapes entering and exiting it. </description> </method> <method name="body_is_shape_set_as_trigger" qualifiers="const"> @@ -25702,6 +25800,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="shape_idx" type="int"> </argument> <description> + Return whether a body's shape is marked as a trigger. </description> </method> <method name="body_attach_object_instance_ID"> @@ -25710,6 +25809,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="id" type="int"> </argument> <description> + Assign the area to a descendant of [Object], so it can exist in the node tree. </description> </method> <method name="body_get_object_instance_ID" qualifiers="const"> @@ -25718,6 +25818,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Get the instance ID of the object the area is assigned to. </description> </method> <method name="body_set_continuous_collision_detection_mode"> @@ -25726,6 +25827,8 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mode" type="int"> </argument> <description> + Set the continuous collision detection mode from any of the CCD_MODE_* constants. + Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. </description> </method> <method name="body_get_continuous_collision_detection_mode" qualifiers="const"> @@ -25734,6 +25837,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the continuous collision detection mode. </description> </method> <method name="body_set_layer_mask"> @@ -25742,6 +25846,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mask" type="int"> </argument> <description> + Set the physics layer or layers a body belongs to. </description> </method> <method name="body_get_layer_mask" qualifiers="const"> @@ -25750,6 +25855,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the physics layer or layers a body belongs to. </description> </method> <method name="body_set_collision_mask"> @@ -25758,6 +25864,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="mask" type="int"> </argument> <description> + Set the physics layer or layers a body can collide with. </description> </method> <method name="body_get_collision_mask" qualifiers="const"> @@ -25766,6 +25873,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the physics layer or layers a body can collide with. </description> </method> <method name="body_set_param"> @@ -25776,6 +25884,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="float"> </argument> <description> + Set a body parameter (see BODY_PARAM* constants). </description> </method> <method name="body_get_param" qualifiers="const"> @@ -25786,6 +25895,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="param" type="int"> </argument> <description> + Return the value of a body parameter. </description> </method> <method name="body_set_state"> @@ -25796,14 +25906,18 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="Variant"> </argument> <description> + Set a body state (see BODY_STATE* constants). </description> </method> <method name="body_get_state" qualifiers="const"> + <return type="Variant"> + </return> <argument index="0" name="body" type="RID"> </argument> <argument index="1" name="state" type="int"> </argument> <description> + Return a body state. </description> </method> <method name="body_apply_impulse"> @@ -25814,6 +25928,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="impulse" type="Vector2"> </argument> <description> + Add a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates. </description> </method> <method name="body_add_force"> @@ -25824,7 +25939,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="force" type="Vector2"> </argument> <description> - Add a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. + Add a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied. </description> </method> <method name="body_set_axis_velocity"> @@ -25833,6 +25948,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="axis_velocity" type="Vector2"> </argument> <description> + Set an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior. </description> </method> <method name="body_add_collision_exception"> @@ -25841,6 +25957,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="excepted_body" type="RID"> </argument> <description> + Add a body to the list of bodies exempt from collisions. </description> </method> <method name="body_remove_collision_exception"> @@ -25849,6 +25966,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="excepted_body" type="RID"> </argument> <description> + Remove a body from the list of bodies exempt from collisions. </description> </method> <method name="body_set_max_contacts_reported"> @@ -25857,6 +25975,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="amount" type="int"> </argument> <description> + Set the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. </description> </method> <method name="body_get_max_contacts_reported" qualifiers="const"> @@ -25865,6 +25984,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the maximum contacts that can be reported. See [method body_set_max_contacts_reported]. </description> </method> <method name="body_set_one_way_collision_direction"> @@ -25873,6 +25993,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="normal" type="Vector2"> </argument> <description> + Set a direction in which bodies can go through the given one. If this value is different from (0,0), any movement within 90 degrees of this vector is considered a valid movement. Set this direction to (0,0) to disable one-way collisions. </description> </method> <method name="body_get_one_way_collision_direction" qualifiers="const"> @@ -25881,6 +26002,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return the direction used for one-way collision detection. </description> </method> <method name="body_set_one_way_collision_max_depth"> @@ -25889,6 +26011,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="depth" type="float"> </argument> <description> + Set how far a body can go through the given one, if it allows one-way collisions (see [method body_set_one_way_collision_direction]). </description> </method> <method name="body_get_one_way_collision_max_depth" qualifiers="const"> @@ -25897,6 +26020,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return how far a body can go through the given one, when it allows one-way collisions. </description> </method> <method name="body_set_omit_force_integration"> @@ -25905,6 +26029,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="enable" type="bool"> </argument> <description> + Set whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_is_omitting_force_integration" qualifiers="const"> @@ -25913,6 +26038,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="body" type="RID"> </argument> <description> + Return whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). </description> </method> <method name="body_set_force_integration_callback"> @@ -25925,6 +26051,7 @@ This method controls whether the position between two cached points is interpola <argument index="3" name="userdata" type="Variant" default="NULL"> </argument> <description> + Set the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force integration]). </description> </method> <method name="body_test_motion"> @@ -25939,6 +26066,7 @@ This method controls whether the position between two cached points is interpola <argument index="3" name="result" type="Physics2DTestMotionResult" default="NULL"> </argument> <description> + Return whether a body can move in a given direction. Apart from the boolean return value, a [Physics2DTestMotionResult] can be passed to return additional information in. </description> </method> <method name="joint_set_param"> @@ -25949,6 +26077,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="float"> </argument> <description> + Set a joint parameter. Parameters are explained in the JOINT_PARAM* constants. </description> </method> <method name="joint_get_param" qualifiers="const"> @@ -25959,6 +26088,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="param" type="int"> </argument> <description> + Return the value of a joint parameter. </description> </method> <method name="pin_joint_create"> @@ -25971,6 +26101,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="body_b" type="RID" default="RID()"> </argument> <description> + Create a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself. </description> </method> <method name="groove_joint_create"> @@ -25987,6 +26118,7 @@ This method controls whether the position between two cached points is interpola <argument index="4" name="body_b" type="RID" default="RID()"> </argument> <description> + Create a groove joint between two bodies. If not specified, the bodyies are assumed to be the joint itself. </description> </method> <method name="damped_spring_joint_create"> @@ -26001,6 +26133,7 @@ This method controls whether the position between two cached points is interpola <argument index="3" name="body_b" type="RID" default="RID()"> </argument> <description> + Create a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself. </description> </method> <method name="damped_string_joint_set_param"> @@ -26011,6 +26144,7 @@ This method controls whether the position between two cached points is interpola <argument index="2" name="value" type="float"> </argument> <description> + Set a damped spring joint parameter. Parameters are explained in the DAMPED_STRING* constants. </description> </method> <method name="damped_string_joint_get_param" qualifiers="const"> @@ -26021,6 +26155,7 @@ This method controls whether the position between two cached points is interpola <argument index="1" name="param" type="int"> </argument> <description> + Return the value of a damped spring joint parameter. </description> </method> <method name="joint_get_type" qualifiers="const"> @@ -26029,18 +26164,21 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="joint" type="RID"> </argument> <description> + Return the type of a joint (see JOINT_* constants). </description> </method> <method name="free_rid"> <argument index="0" name="rid" type="RID"> </argument> <description> + Destroy any of the objects created by Physics2DServer. If the [RID] passed is not one of the objects that can be created by Physics2DServer, an error will be sent to the console. </description> </method> <method name="set_active"> <argument index="0" name="active" type="bool"> </argument> <description> + Activate or deactivate the 2D physics engine. </description> </method> <method name="get_process_info"> @@ -26049,41 +26187,79 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="process_info" type="int"> </argument> <description> + Return information about the current state of the 2D physics engine. The states are listed under the INFO_* constants. </description> </method> </methods> <constants> + <constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0"> + Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated. + </constant> + <constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1"> + Constant to set/get the maximum distance a shape can be from another before they are considered separated. + </constant> + <constant name="SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION" value="2"> + Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision. + </constant> + <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD" value="3"> + Constant to set/get the linear velocity threshold. Bodies slower than this will be marked as potentially inactive. + </constant> + <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD" value="4"> + Constant to set/get the angular velocity threshold. Bodies slower than this will be marked as potentially inactive. + </constant> + <constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="5"> + Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time. + </constant> + <constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="6"> + Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision. + </constant> <constant name="SHAPE_LINE" value="0"> + This is the constant for creating line shapes. A line shape is an infinite line with an origin point, and a normal. Thus, it can be used for front/behind checks. </constant> <constant name="SHAPE_SEGMENT" value="2"> + This is the constant for creating segment shapes. A segment shape is a line from a point A to a point B. It can be checked for intersections. </constant> <constant name="SHAPE_CIRCLE" value="3"> + This is the constant for creating circle shapes. A circle shape only has a radius. It can be used for intersections and inside/outside checks. </constant> <constant name="SHAPE_RECTANGLE" value="4"> + This is the constant for creating rectangle shapes. A rectangle shape is defined by a width and a height. It can be used for intersections and inside/outside checks. </constant> <constant name="SHAPE_CAPSULE" value="5"> + This is the constant for creating capsule shapes. A capsule shape is defined by a radius and a length. It can be used for intersections and inside/outside checks. </constant> <constant name="SHAPE_CONVEX_POLYGON" value="6"> + This is the constant for creating convex polygon shapes. A polygon is defined by a list of points. It can be used for intersections and inside/outside checks. Unlike the method [method CollisionPolygon2D.set_polygon], polygons modified with [method shape_set_data] do not verify that the points supplied form, in fact, a convex polygon. </constant> <constant name="SHAPE_CONCAVE_POLYGON" value="7"> + This is the constant for creating concave polygon shapes. A polygon is defined by a list of points. It can be used for intersections checks, but not for inside/outside checks. </constant> <constant name="SHAPE_CUSTOM" value="8"> + This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. </constant> <constant name="AREA_PARAM_GRAVITY" value="0"> + Constant to set/get gravity strength in an area. </constant> <constant name="AREA_PARAM_GRAVITY_VECTOR" value="1"> + Constant to set/get gravity vector/center in an area. </constant> <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="2"> + Constant to set/get whether the gravity vector of an area is a direction, or a center point. </constant> <constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="3"> + Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance. </constant> <constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="4"> + This constant was used to set/get the falloff factor for point gravity. It has been superseded by AREA_PARAM_GRAVITY_DISTANCE_SCALE. </constant> <constant name="AREA_PARAM_LINEAR_DAMP" value="5"> + Constant to set/get the linear dampening factor of an area. </constant> <constant name="AREA_PARAM_ANGULAR_DAMP" value="6"> + Constant to set/get the angular dampening factor of an area. </constant> <constant name="AREA_PARAM_PRIORITY" value="7"> + Constant to set/get the priority (order of processing) of an area. </constant> <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0"> This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them. @@ -26101,73 +26277,115 @@ This method controls whether the position between two cached points is interpola This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one. </constant> <constant name="BODY_MODE_STATIC" value="0"> + Constant for static bodies. </constant> <constant name="BODY_MODE_KINEMATIC" value="1"> + Constant for kinematic bodies. </constant> <constant name="BODY_MODE_RIGID" value="2"> + Constant for rigid bodies. </constant> <constant name="BODY_MODE_CHARACTER" value="3"> + Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics. </constant> <constant name="BODY_PARAM_BOUNCE" value="0"> + Constant to set/get a body's bounce factor. </constant> <constant name="BODY_PARAM_FRICTION" value="1"> + Constant to set/get a body's friction. </constant> <constant name="BODY_PARAM_MASS" value="2"> + Constant to set/get a body's mass. </constant> <constant name="BODY_PARAM_INERTIA" value="3"> + Constant to set/get a body's inertia. </constant> <constant name="BODY_PARAM_GRAVITY_SCALE" value="4"> + Constant to set/get a body's gravity multiplier. </constant> <constant name="BODY_PARAM_LINEAR_DAMP" value="5"> + Constant to set/get a body's linear dampening factor. </constant> <constant name="BODY_PARAM_ANGULAR_DAMP" value="6"> + Constant to set/get a body's angular dampening factor. </constant> <constant name="BODY_PARAM_MAX" value="7"> + This is the last ID for body parameters. Any attempt to set this property is ignored. Any attempt to get it returns 0. </constant> <constant name="BODY_STATE_TRANSFORM" value="0"> + Constant to set/get the current transform matrix of the body. </constant> <constant name="BODY_STATE_LINEAR_VELOCITY" value="1"> + Constant to set/get the current linear velocity of the body. </constant> <constant name="BODY_STATE_ANGULAR_VELOCITY" value="2"> + Constant to set/get the current angular velocity of the body. </constant> <constant name="BODY_STATE_SLEEPING" value="3"> + Constant to sleep/wake up a body, or to get whether it is sleeping. </constant> <constant name="BODY_STATE_CAN_SLEEP" value="4"> + Constant to set/get whether the body can sleep. </constant> <constant name="JOINT_PIN" value="0"> + Constant to create pin joints. </constant> <constant name="JOINT_GROOVE" value="1"> + Constant to create groove joints. </constant> <constant name="JOINT_DAMPED_SPRING" value="2"> + Constant to create damped spring joints. + </constant> + <constant name="JOINT_PARAM_BIAS" value="0"> + Constant to set/get the solver bias for a joint. + </constant> + <constant name="JOINT_PARAM_MAX_BIAS" value="1"> + Constant to set/get the maximum speed at which a joint can correct its bodies. + </constant> + <constant name="JOINT_PARAM_MAX_FORCE" value="2"> + Constant to set the maximum force a joint can exert on its bodies. </constant> <constant name="DAMPED_STRING_REST_LENGTH" value="0"> + Set the resting length of the spring joint. The joint will always try to go to back this length when pulled apart. </constant> <constant name="DAMPED_STRING_STIFFNESS" value="1"> + Set the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length. </constant> <constant name="DAMPED_STRING_DAMPING" value="2"> + Set the damping ratio of the spring joint. A value of 0 indicates an undamped spring, while 1 causes the system to reach equilibrium as fast as possible (critical damping). </constant> <constant name="CCD_MODE_DISABLED" value="0"> + Disables continuous collision detection. This is the fastest way to detect body collisions, but can miss small, fast-moving objects. </constant> <constant name="CCD_MODE_CAST_RAY" value="1"> + Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise. </constant> <constant name="CCD_MODE_CAST_SHAPE" value="2"> + Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise. </constant> <constant name="AREA_BODY_ADDED" value="0"> + The value of the first parameter and area callback function receives, when an object enters one of its shapes. </constant> <constant name="AREA_BODY_REMOVED" value="1"> + The value of the first parameter and area callback function receives, when an object exits one of its shapes. </constant> <constant name="INFO_ACTIVE_OBJECTS" value="0"> + Constant to get the number of objects that are not sleeping. </constant> <constant name="INFO_COLLISION_PAIRS" value="1"> + Constant to get the number of possible collisions. </constant> <constant name="INFO_ISLAND_COUNT" value="2"> + Constant to get the number of space regions where a collision could occur. </constant> </constants> </class> <class name="Physics2DServerSW" inherits="Physics2DServer" category="Core"> <brief_description> + Software implementation of [Physics2DServer]. </brief_description> <description> + Software implementation of [Physics2DServer]. This class exposes no new methods or properties and should not be used, as [Physics2DServer] automatically selects the best implementation available. </description> <methods> </methods> @@ -26176,98 +26394,115 @@ This method controls whether the position between two cached points is interpola </class> <class name="Physics2DShapeQueryParameters" inherits="Reference" category="Core"> <brief_description> + Parameters to be sent to a 2D shape physics query. </brief_description> <description> + This class contains the shape and other parameters for intersection/collision queries. </description> <methods> <method name="set_shape"> <argument index="0" name="shape" type="Shape2D"> </argument> <description> + Set the [Shape2D] that will be used for collision/intersection queries. </description> </method> <method name="set_shape_rid"> <argument index="0" name="shape" type="RID"> </argument> <description> + Set the [RID] of the shape to be used in queries. </description> </method> <method name="get_shape_rid" qualifiers="const"> <return type="RID"> </return> <description> + Return the [RID] of the shape queried. </description> </method> <method name="set_transform"> <argument index="0" name="transform" type="Matrix32"> </argument> <description> + Set the transormation matrix of the shape. This is necessary to set its position/rotation/scale. </description> </method> <method name="get_transform" qualifiers="const"> <return type="Matrix32"> </return> <description> + Return the transform matrix of the shape queried. </description> </method> <method name="set_motion"> <argument index="0" name="motion" type="Vector2"> </argument> <description> + Set the current movement speed of the shape. </description> </method> <method name="get_motion" qualifiers="const"> <return type="Vector2"> </return> <description> + Return the current movement speed of the shape. </description> </method> <method name="set_margin"> <argument index="0" name="margin" type="float"> </argument> <description> + Set the collision margin for the shape. A collision margin is an amount (in pixels) that the shape will grow when computing collisions, to account for numerical imprecision. </description> </method> <method name="get_margin" qualifiers="const"> <return type="float"> </return> <description> + Return the collision margin for the shape. </description> </method> <method name="set_layer_mask"> <argument index="0" name="layer_mask" type="int"> </argument> <description> + Set the physics layer(s) the shape belongs to. </description> </method> <method name="get_layer_mask" qualifiers="const"> <return type="int"> </return> <description> + Return the physics layer(s) the shape belongs to. </description> </method> <method name="set_object_type_mask"> <argument index="0" name="object_type_mask" type="int"> </argument> <description> + Set the type of object the shape belongs to (see Physics2DDirectSpaceState.TYPE_MASK_*). </description> </method> <method name="get_object_type_mask" qualifiers="const"> <return type="int"> </return> <description> + Return the type of object the shape belongs to. </description> </method> <method name="set_exclude"> <argument index="0" name="exclude" type="Array"> </argument> <description> + Set the list of objects, or object [RID]s, that will be excluded from collisions. </description> </method> <method name="get_exclude" qualifiers="const"> <return type="Array"> </return> <description> + Return the list of objects, or object [RID]s, that will be excluded from collisions. </description> </method> </methods> @@ -28388,155 +28623,162 @@ This method controls whether the position between two cached points is interpola 2D polygon representation </brief_description> <description> - A Polygon2D is defined by a set of n points connected together by line segments, meaning that the point 1 will be connected with point 2, point 2 with point 3 ..., point n-1 with point n and point n with point 1 in order to close the loop and define a plane. + A Polygon2D is defined by a set of n vertices connected together by line segments, meaning that the vertex 1 will be connected with vertex 2, vertex 2 with vertex 3 ..., vertex n-1 with vertex n and vertex n with vertex 1 in order to close the loop and define a polygon. </description> <methods> <method name="set_polygon"> <argument index="0" name="polygon" type="Vector2Array"> </argument> <description> - Defines the set of points that will represent the polygon. + Define the set of vertices that will represent the polygon. </description> </method> <method name="get_polygon" qualifiers="const"> <return type="Vector2Array"> </return> <description> - Returns the set of points that defines this polygon + Return the set of vertices that defines this polygon. </description> </method> <method name="set_uv"> <argument index="0" name="uv" type="Vector2Array"> </argument> <description> - Sets the uv value for every point of the polygon + Set the texture coordinates for every vertex of the polygon. There should be one uv vertex for every vertex in the polygon. If there are less, the undefined ones will be assumed to be (0,0). Extra uv vertices are ignored. </description> </method> <method name="get_uv" qualifiers="const"> <return type="Vector2Array"> </return> <description> - Returns the uv value associated with every point of the polygon + Return the texture coordinates associated with every vertex of the polygon. </description> </method> <method name="set_color"> <argument index="0" name="color" type="Color"> </argument> <description> - Sets the polygon fill color, if the polygon has a texture defined, the defined texture will be tinted to the polygon fill color. + Set the polygon fill color. If the polygon has a texture defined, the defined texture will be multiplied by the polygon fill color. This, also, is the default color for those vertices that are not defined by [method get_vertex_colors]. </description> </method> <method name="get_color" qualifiers="const"> <return type="Color"> </return> <description> - Returns the polygon fill color + Return the polygon fill color. </description> </method> <method name="set_vertex_colors"> <argument index="0" name="vertex_colors" type="ColorArray"> </argument> <description> + Set the color for each vertex of the polygon. There should be one color for every vertex in the polygon. If there are less, the undefined ones will be assumed to be [method get_color]. Extra color entries are ignored. + Colors are interpolated between vertices, resulting in smooth gradients when they differ. </description> </method> <method name="get_vertex_colors" qualifiers="const"> <return type="ColorArray"> </return> <description> + Return the list of vertex colors. </description> </method> <method name="set_texture"> <argument index="0" name="texture" type="Object"> </argument> <description> - Sets the polygon texture. + Set the polygon texture. </description> </method> <method name="get_texture" qualifiers="const"> <return type="Object"> </return> <description> - Returns the polygon texture + Return the polygon texture </description> </method> <method name="set_texture_offset"> <argument index="0" name="texture_offset" type="Vector2"> </argument> <description> - Sets the offset of the polygon texture. Initially the texture will appear anchored to the polygon position, the offset is used to move the texture location away from that point (notice that the texture origin is set to its top left corner, so when offset is 0,0 the top left corner of the texture is at the polygon position), for example setting the offset to 10, 10 will move the texture 10 units to the left and 10 units to the top. + Set the offset of the polygon texture. Initially the texture will appear anchored to the polygon position, the offset is used to move the texture location away from that point (notice that the texture origin is set to its top left corner, so when offset is 0,0 the top left corner of the texture is at the polygon position), for example setting the offset to 10, 10 will move the texture 10 units to the left and 10 units to the top. </description> </method> <method name="get_texture_offset" qualifiers="const"> <return type="Vector2"> </return> <description> - Returns the polygon texture offset. + Return the polygon texture offset. </description> </method> <method name="set_texture_rotation"> <argument index="0" name="texture_rotation" type="float"> </argument> <description> - Sets the amount of rotation of the polygon texture, [code]texture_rotation[/code] is specified in radians and clockwise rotation. + Set the amount of rotation of the polygon texture, [code]texture_rotation[/code] is specified in radians and clockwise rotation. </description> </method> <method name="get_texture_rotation" qualifiers="const"> <return type="float"> </return> <description> - Returns the rotation in radians of the texture polygon. + Return the rotation in radians of the texture polygon. </description> </method> <method name="set_texture_scale"> <argument index="0" name="texture_scale" type="Vector2"> </argument> <description> + Set the value that will multiply the uv coordinates ([method get_uv]) when applying the texture. Larger values make the texture smaller, and vice versa. </description> </method> <method name="get_texture_scale" qualifiers="const"> <return type="Vector2"> </return> <description> + Return the uv coordinate multiplier. </description> </method> <method name="set_invert"> <argument index="0" name="invert" type="bool"> </argument> <description> - Sets the polygon as the defined polygon bounding box minus the defined polygon (the defined polygon will appear as a hole on square that contains the defined polygon). + Set the polygon as the defined polygon bounding box minus the defined polygon (the defined polygon will appear as a hole on the square that contains the defined polygon). </description> </method> <method name="get_invert" qualifiers="const"> <return type="bool"> </return> <description> - Returns whether this polygon is inverted or not + Return whether this polygon is inverted or not. </description> </method> <method name="set_invert_border"> <argument index="0" name="invert_border" type="float"> </argument> <description> + Add extra padding around the bounding box, making it bigger. Too small a value can make the polygon triangulate strangely, due to numerical imprecision. </description> </method> <method name="get_invert_border" qualifiers="const"> <return type="float"> </return> <description> + Return the added padding around the bounding box. </description> </method> <method name="set_offset"> <argument index="0" name="offset" type="Vector2"> </argument> <description> - Sets the amount of distance from the polygon points from the polygon position, for example if the offset is set to 10,10 then all the polygon points will move 10 units to the right and 10 units to the bottom. + Set the an offset that will be added to the vertices' position. E.g. if the offset is set to (10,10) then all the polygon points will move 10 units to the right and 10 units to the bottom. </description> </method> <method name="get_offset" qualifiers="const"> <return type="Vector2"> </return> <description> - Returns the polygon points offset to the polygon position. + Return the offset for the polygon vertices. </description> </method> </methods> @@ -31415,6 +31657,7 @@ This method controls whether the position between two cached points is interpola Rigid body. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code. </constant> <constant name="MODE_CHARACTER" value="2"> + Character body. This behaves like a rigid body, but can not rotate. </constant> </constants> </class> @@ -31467,7 +31710,7 @@ This method controls whether the position between two cached points is interpola <return type="float"> </return> <description> - Return the body's moment of inertia. This is usually automatically computed from the mass and the shapes. Note that this doesn't seem to work in a [code]_ready[/code] function: it apparently has not been auto-computed yet. + Return the body's moment of inertia. This is usually automatically computed from the mass and the shapes. Note that this doesn't seem to work in a [code]_ready[/code] function: it apparently has not been auto-computed yet. </description> </method> <method name="set_inertia"> @@ -37028,6 +37271,24 @@ This method controls whether the position between two cached points is interpola If the string is a path to a file or directory, return true if the path is relative. </description> </method> + <method name="is_subsequence_of"> + <return type="bool"> + </return> + <argument index="0" name="text" type="String"> + </argument> + <description> + Checked whether this string is a subsequence of the given string. + </description> + </method> + <method name="is_subsequence_ofi"> + <return type="bool"> + </return> + <argument index="0" name="text" type="String"> + </argument> + <description> + Checked whether this string is a subsequence of the given string, without considering case. + </description> + </method> <method name="is_valid_float"> <return type="bool"> </return> diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 9f24633bd4..2838e7d913 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -124,6 +124,11 @@ void FileAccessUnix::close() { //unlink(save_path.utf8().get_data()); //print_line("renaming.."); int rename_error = rename((save_path+".tmp").utf8().get_data(),save_path.utf8().get_data()); + + if (rename_error && close_fail_notify) { + close_fail_notify(save_path); + } + save_path=""; ERR_FAIL_COND( rename_error != 0); } diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 66181a6f44..3f27068fb2 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -131,6 +131,10 @@ void FileAccessWindows::close() { //atomic replace for existing file rename_error = !ReplaceFileW(save_path.c_str(), (save_path+".tmp").c_str(), NULL, 2|4, NULL, NULL); } + if (rename_error && close_fail_notify) { + close_fail_notify(save_path); + } + save_path=""; ERR_FAIL_COND( rename_error ); } diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 3aff134327..ac96a2117c 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -730,7 +730,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ //find list [ or find dictionary { - print_line("found bug?"); + //print_line("found bug?"); _set_error("Error parsing expression, misplaced: "+String(tokenizer->get_token_name(tokenizer->get_token()))); return NULL; //nothing diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 359a9fe2d5..026fd04869 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1898,6 +1898,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path,const RES& p_resour } file->close(); memdelete(file); + + if (ScriptServer::is_reload_scripts_on_save_enabled()) { + GDScriptLanguage::get_singleton()->reload_tool_script(p_resource,false); + } + return OK; } diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 56eacfd20e..8dd68cf95a 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -79,8 +79,8 @@ const char* GDTokenizer::token_names[TK_MAX]={ "for", "do", "while", -"switch", -"case", +"switch (reserved)", +"case (reserved)", "break", "continue", "pass", @@ -874,6 +874,7 @@ void GDTokenizerText::_advance() { {TK_CF_WHILE,"while"}, {TK_CF_DO,"do"}, {TK_CF_SWITCH,"switch"}, + {TK_CF_CASE,"case"}, {TK_CF_BREAK,"break"}, {TK_CF_CONTINUE,"continue"}, {TK_CF_RETURN,"return"}, diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 503e723de2..5e30416641 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -1830,7 +1830,7 @@ GridMap::GridMap() { baked_light_instance=NULL; use_baked_light=false; - + navigation = NULL; } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 87afe3d5a4..f3beabceb8 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -741,7 +741,7 @@ void GridMapEditor::update_pallete() { } float min_size = EDITOR_DEF("grid_map/preview_size",64); - theme_pallete->set_min_icon_size(Size2(min_size, min_size)); + theme_pallete->set_fixed_icon_size(Size2(min_size, min_size)); theme_pallete->set_fixed_column_width(min_size*3/2); theme_pallete->set_max_text_lines(2); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 060819b90e..b35e3a8055 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -9,6 +9,7 @@ #include "os/file_access.h" #include "os/os.h" #include "platform/android/logo.h" +#include <string.h> static const char* android_perms[]={ @@ -231,6 +232,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { void _fix_manifest(Vector<uint8_t>& p_manifest, bool p_give_internet); void _fix_resources(Vector<uint8_t>& p_manifest); static Error save_apk_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); + static bool _should_compress_asset(const String& p_path); protected: @@ -1001,7 +1003,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String& NULL, 0, NULL, - Z_DEFLATED, + _should_compress_asset(p_path) ? Z_DEFLATED : 0, Z_DEFAULT_COMPRESSION); @@ -1012,13 +1014,63 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String& } +bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path) { + + /* + * By not compressing files with little or not benefit in doing so, + * a performance gain is expected at runtime. Moreover, if the APK is + * zip-aligned, assets stored as they are can be efficiently read by + * Android by memory-mapping them. + */ + + // -- Unconditional uncompress to mimic AAPT plus some other + + static const char* unconditional_compress_ext[] = { + // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp + // These formats are already compressed, or don't compress well: + ".jpg", ".jpeg", ".png", ".gif", + ".wav", ".mp2", ".mp3", ".ogg", ".aac", + ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", + ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", + ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", + ".amr", ".awb", ".wma", ".wmv", + // Godot-specific: + ".webp", // Same reasoning as .png + ".cfb", // Don't let small config files slow-down startup + // Trailer for easier processing + NULL + }; + + for (const char** ext=unconditional_compress_ext; *ext; ++ext) { + if (p_path.to_lower().ends_with(String(*ext))) { + return false; + } + } + + // -- Compressed resource? + + FileAccess *f=FileAccess::open(p_path,FileAccess::READ); + ERR_FAIL_COND_V(!f,true); + + uint8_t header[4]; + f->get_buffer(header,4); + if (header[0]=='R' && header[1]=='S' && header[2]=='C' && header[3]=='C') { + // Already compressed + return false; + } + + // --- TODO: Decide on texture resources according to their image compression setting + + return true; +} + Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_debug, int p_flags) { String src_apk; - EditorProgress ep("export","Exporting for Android",104); + EditorProgress ep("export","Exporting for Android",105); if (p_debug) src_apk=custom_debug_package; @@ -1058,7 +1110,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d zlib_filefunc_def io2=io; FileAccess *dst_f=NULL; io2.opaque=&dst_f; - zipFile apk=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); + String unaligned_path=EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpexport-unaligned.apk"; + zipFile unaligned_apk=zipOpen2(unaligned_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); while(ret==UNZ_OK) { @@ -1137,7 +1190,11 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d print_line("ADDING: "+file); if (!skip) { - zipOpenNewFileInZip(apk, + + // Respect decision on compression made by AAPT for the export template + const bool uncompressed = info.compression_method == 0; + + zipOpenNewFileInZip(unaligned_apk, file.utf8().get_data(), NULL, NULL, @@ -1145,11 +1202,11 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d NULL, 0, NULL, - Z_DEFLATED, + uncompressed ? 0 : Z_DEFLATED, Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(apk,data.ptr(),data.size()); - zipCloseFileInZip(apk); + zipWriteInFileInZip(unaligned_apk,data.ptr(),data.size()); + zipCloseFileInZip(unaligned_apk); } ret = unzGoToNextFile(pkg); @@ -1206,7 +1263,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d APKExportData ed; ed.ep=&ep; - ed.apk=apk; + ed.apk=unaligned_apk; err = export_project_files(save_apk_file,&ed,false); } @@ -1235,7 +1292,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d print_line(itos(i)+" param: "+cl[i]); } - zipOpenNewFileInZip(apk, + zipOpenNewFileInZip(unaligned_apk, "assets/_cl_", NULL, NULL, @@ -1243,15 +1300,15 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d NULL, 0, NULL, - Z_DEFLATED, + 0, // No compress (little size gain and potentially slower startup) Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(apk,clf.ptr(),clf.size()); - zipCloseFileInZip(apk); + zipWriteInFileInZip(unaligned_apk,clf.ptr(),clf.size()); + zipCloseFileInZip(unaligned_apk); } - zipClose(apk,NULL); + zipClose(unaligned_apk,NULL); unzClose(pkg); if (err) { @@ -1308,7 +1365,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d args.push_back(keystore); args.push_back("-storepass"); args.push_back(password); - args.push_back(p_path); + args.push_back(unaligned_path); args.push_back(user); int retval; int err = OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval); @@ -1321,16 +1378,102 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d args.clear(); args.push_back("-verify"); - args.push_back(p_path); + args.push_back(unaligned_path); args.push_back("-verbose"); err = OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval); if (retval) { - EditorNode::add_io_error("'jarsigner' verificaiton of APK failed. Make sure to use jarsigner from Java 6."); + EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use jarsigner from Java 6."); return ERR_CANT_CREATE; } } + + + + // Let's zip-align (must be done after signing) + + static const int ZIP_ALIGNMENT = 4; + + ep.step("Aligning APK..",105); + + unzFile tmp_unaligned = unzOpen2(unaligned_path.utf8().get_data(), &io); + if (!tmp_unaligned) { + + EditorNode::add_io_error("Could not find temp unaligned APK."); + return ERR_FILE_NOT_FOUND; + } + + ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN); + ret = unzGoToFirstFile(tmp_unaligned); + + io2=io; + dst_f=NULL; + io2.opaque=&dst_f; + zipFile final_apk=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); + + // Take files from the unaligned APK and write them out to the aligned one + // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed, + // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp + int bias = 0; + while(ret==UNZ_OK) { + + unz_file_info info; + memset(&info, 0, sizeof(info)); + + char fname[16384]; + char extra[16384]; + ret = unzGetCurrentFileInfo(tmp_unaligned,&info,fname,16384,extra,16384-ZIP_ALIGNMENT,NULL,0); + + String file=fname; + + Vector<uint8_t> data; + data.resize(info.compressed_size); + + // read + int method, level; + unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read + long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned); + unzReadCurrentFile(tmp_unaligned,data.ptr(),data.size()); + unzCloseCurrentFile(tmp_unaligned); + + // align + int padding = 0; + if (!info.compression_method) { + // Uncompressed file => Align + long new_offset = file_offset + bias; + padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT; + } + + memset(extra + info.size_file_extra, 0, padding); + + // write + zipOpenNewFileInZip2(final_apk, + file.utf8().get_data(), + NULL, + extra, + info.size_file_extra + padding, + NULL, + 0, + NULL, + method, + level, + 1); // raw write + zipWriteInFileInZip(final_apk,data.ptr(),data.size()); + zipCloseFileInZipRaw(final_apk,info.uncompressed_size,info.crc); + + bias += padding; + + ret = unzGoToNextFile(tmp_unaligned); + } + + zipClose(final_apk,NULL); + unzClose(tmp_unaligned); + + if (err) { + return err; + } + return OK; } diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index e35ba11e84..7d134a070e 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -990,7 +990,7 @@ float VehicleBody::get_steering() const{ return m_steeringValue; } -Vector3 VehicleBody::get_linear_velocity() +Vector3 VehicleBody::get_linear_velocity() const { return linear_velocity; } diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index b6ad88f15e..31c61ff99d 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -178,7 +178,7 @@ public: void set_steering(float p_steering); float get_steering() const; - Vector3 get_linear_velocity(); + Vector3 get_linear_velocity() const; VehicleBody(); }; diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp index b4a237c60f..bcd4354975 100644 --- a/scene/audio/sample_player.cpp +++ b/scene/audio/sample_player.cpp @@ -290,7 +290,7 @@ void SamplePlayer::stop_all() { #define _GET_VOICE\ uint32_t voice=p_voice&0xFFFF;\ - ERR_FAIL_COND(voice > (uint32_t)voices.size());\ + ERR_FAIL_COND(voice >= (uint32_t)voices.size());\ Voice &v=voices[voice];\ if (v.check!=uint32_t(p_voice>>16))\ return;\ @@ -381,7 +381,7 @@ void SamplePlayer::set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send #define _GET_VOICE_V(m_ret)\ uint32_t voice=p_voice&0xFFFF;\ - ERR_FAIL_COND_V(voice > (uint32_t)voices.size(),m_ret);\ + ERR_FAIL_COND_V(voice >= (uint32_t)voices.size(),m_ret);\ const Voice &v=voices[voice];\ if (v.check!=(p_voice>>16))\ return m_ret;\ diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index bd56369746..dfad7d1432 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -223,7 +223,7 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const { String sname=p_name; - if (!sname.begins_with("custom")) + if (!sname.begins_with("custom")) { if (sname.begins_with("margin/")) { String dname = sname.get_slicec('/', 1); if (dname == "left") { @@ -248,6 +248,7 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const { } else { return false; } + } if (sname.begins_with("custom_icons/")) { String name = sname.get_slicec('/',1); @@ -489,6 +490,10 @@ void Control::_notification(int p_notification) { } + if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { + data.theme_owner=data.parent->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } } break; case NOTIFICATION_EXIT_CANVAS: { @@ -520,26 +525,9 @@ void Control::_notification(int p_notification) { data.parent=NULL; data.parent_canvas_item=NULL; - - } break; - - - case NOTIFICATION_PARENTED: { - - Control * parent = get_parent()->cast_to<Control>(); - - //make children reference them theme - - if (parent && data.theme.is_null() && parent->data.theme_owner) { - _propagate_theme_changed(parent->data.theme_owner); - } - - } break; - case NOTIFICATION_UNPARENTED: { - - //make children unreference the theme - if (data.theme.is_null() && data.theme_owner) { - _propagate_theme_changed(NULL); + if (data.theme_owner && data.theme.is_null()) { + data.theme_owner=NULL; + //notification(NOTIFICATION_THEME_CHANGED); } } break; @@ -785,7 +773,7 @@ Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type while(theme_owner) { if (theme_owner->data.theme->has_icon(p_name, type ) ) - return data.theme_owner->data.theme->get_icon(p_name, type ); + return theme_owner->data.theme->get_icon(p_name, type ); Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; if (parent) @@ -815,7 +803,7 @@ Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_typ while(theme_owner) { if (theme_owner->data.theme->has_shader(p_name, type)) - return data.theme_owner->data.theme->get_shader(p_name, type ); + return theme_owner->data.theme->get_shader(p_name, type ); Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; if (parent) @@ -843,8 +831,9 @@ Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p while(theme_owner) { - if (theme_owner->data.theme->has_stylebox(p_name, type ) ) - return data.theme_owner->data.theme->get_stylebox(p_name, type ); + if (theme_owner->data.theme->has_stylebox(p_name, type ) ) { + return theme_owner->data.theme->get_stylebox(p_name, type ); + } Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; if (parent) @@ -872,7 +861,7 @@ Ref<Font> Control::get_font(const StringName& p_name,const StringName& p_type) c while(theme_owner) { if (theme_owner->data.theme->has_font(p_name, type ) ) - return data.theme_owner->data.theme->get_font(p_name, type ); + return theme_owner->data.theme->get_font(p_name, type ); if (theme_owner->data.theme->get_default_theme_font().is_valid()) return theme_owner->data.theme->get_default_theme_font(); Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; @@ -902,7 +891,7 @@ Color Control::get_color(const StringName& p_name,const StringName& p_type) cons while(theme_owner) { if (theme_owner->data.theme->has_color(p_name, type ) ) - return data.theme_owner->data.theme->get_color(p_name, type ); + return theme_owner->data.theme->get_color(p_name, type ); Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; if (parent) @@ -931,7 +920,7 @@ int Control::get_constant(const StringName& p_name,const StringName& p_type) con while(theme_owner) { if (theme_owner->data.theme->has_constant(p_name, type ) ) - return data.theme_owner->data.theme->get_constant(p_name, type ); + return theme_owner->data.theme->get_constant(p_name, type ); Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL; if (parent) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index fc4ab5f8ca..66e8fe10ff 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -384,27 +384,16 @@ ItemList::IconMode ItemList::get_icon_mode() const{ return icon_mode; } -void ItemList::set_min_icon_size(const Size2& p_size) { - min_icon_size=p_size; - update(); -} - -Size2 ItemList::get_min_icon_size() const { - - return min_icon_size; -} +void ItemList::set_fixed_icon_size(const Size2& p_size) { - -void ItemList::set_max_icon_size(const Size2& p_size) { - - max_icon_size=p_size; + fixed_icon_size=p_size; update(); } -Size2 ItemList::get_max_icon_size() const { +Size2 ItemList::get_fixed_icon_size() const { - return max_icon_size; + return fixed_icon_size; } Size2 ItemList::Item::get_icon_size() const { @@ -732,51 +721,21 @@ void ItemList::ensure_current_is_visible() { update(); } -static Size2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) { - - if (p_max_size.x<=0) - p_max_size.x=1e20; - if (p_max_size.y<=0) - p_max_size.y=1e20; - +static Rect2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) { - Size2 new_size; + Size2 size=p_max_size; + int tex_width = p_size.width * size.height / p_size.height; + int tex_height = size.height; - if (p_size.x > p_max_size.x) { - - new_size.width=p_max_size.x; - new_size.height=p_size.height * p_max_size.width / p_size.width; - - if (new_size.height > p_max_size.height) { - new_size=Size2(); //invalid - } + if (tex_width>size.width) { + tex_width=size.width; + tex_height=p_size.height * tex_width / p_size.width; } + int ofs_x=(size.width - tex_width)/2; + int ofs_y=(size.height - tex_height)/2; - if (p_size.y > p_max_size.y) { - - Size2 new_size2; - new_size2.height=p_max_size.y; - new_size2.width=p_size.width * p_max_size.height / p_size.height; - - if (new_size2.width < p_max_size.width) { - - if (new_size!=Size2()) { - - if (new_size2.x*new_size2.y > new_size.x*new_size.y) { - new_size=new_size2; - } - } else { - new_size=new_size2; - } - } - - } - - if (new_size==Size2()) - return p_size; - else - return new_size; + return Rect2(ofs_x,ofs_y,tex_width,tex_height); } @@ -845,7 +804,11 @@ void ItemList::_notification(int p_what) { Size2 minsize; if (items[i].icon.is_valid()) { - minsize=_adjust_to_max_size(items[i].get_icon_size(),max_icon_size) * icon_scale; + if (fixed_icon_size.x>0 && fixed_icon_size.y>0) { + minsize=fixed_icon_size* icon_scale; + } else { + minsize=items[i].get_icon_size() *icon_scale; + } if (items[i].text!="") { if (icon_mode==ICON_MODE_TOP) { @@ -1001,13 +964,18 @@ void ItemList::_notification(int p_what) { Vector2 text_ofs; if (items[i].icon.is_valid()) { - Size2 icon_size = _adjust_to_max_size(items[i].get_icon_size(),max_icon_size) * icon_scale; + Size2 icon_size; + //= _adjust_to_max_size(items[i].get_icon_size(),fixed_icon_size) * icon_scale; + + if (fixed_icon_size.x>0 && fixed_icon_size.y>0) { + icon_size=fixed_icon_size* icon_scale; + } else { + icon_size=items[i].get_icon_size() *icon_scale; - Vector2 icon_ofs; - if (min_icon_size!=Vector2()) { - icon_ofs = (min_icon_size - icon_size)/2; } + Vector2 icon_ofs; + Point2 pos = items[i].rect_cache.pos + icon_ofs + base_ofs; if (icon_mode==ICON_MODE_TOP) { @@ -1017,18 +985,26 @@ void ItemList::_notification(int p_what) { Math::floor((items[i].rect_cache.size.height - icon_size.height)/2), items[i].rect_cache.size.height - items[i].min_rect_cache.size.height ); - text_ofs.y = MAX(icon_size.height, min_icon_size.y) + icon_margin; + text_ofs.y = icon_size.height + icon_margin; text_ofs.y += items[i].rect_cache.size.height - items[i].min_rect_cache.size.height; } else { pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height)/2); - text_ofs.x = MAX(icon_size.width, min_icon_size.x) + icon_margin; + text_ofs.x = icon_size.width + icon_margin; + } + + Rect2 draw_rect=Rect2(pos,icon_size); + + if (fixed_icon_size.x>0 && fixed_icon_size.y>0) { + Rect2 adj = _adjust_to_max_size(items[i].get_icon_size() * icon_scale,icon_size); + draw_rect.pos+=adj.pos; + draw_rect.size=adj.size; } if (items[i].icon_region.has_no_area()) - draw_texture_rect(items[i].icon, Rect2(pos,icon_size) ); + draw_texture_rect(items[i].icon, draw_rect ); else - draw_texture_rect_region(items[i].icon, Rect2(pos, icon_size), items[i].icon_region); + draw_texture_rect_region(items[i].icon, draw_rect, items[i].icon_region); } @@ -1298,11 +1274,9 @@ void ItemList::_bind_methods(){ ObjectTypeDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode); ObjectTypeDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode); - ObjectTypeDB::bind_method(_MD("set_min_icon_size","size"),&ItemList::set_min_icon_size); - ObjectTypeDB::bind_method(_MD("get_min_icon_size"),&ItemList::get_min_icon_size); - ObjectTypeDB::bind_method(_MD("set_max_icon_size","size"),&ItemList::set_max_icon_size); - ObjectTypeDB::bind_method(_MD("get_max_icon_size"),&ItemList::get_max_icon_size); + ObjectTypeDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size); + ObjectTypeDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size); ObjectTypeDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale); ObjectTypeDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 087c585128..a4909205ef 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -62,8 +62,7 @@ private: int max_text_lines; int max_columns; - Size2 min_icon_size; - Size2 max_icon_size; + Size2 fixed_icon_size; Size2 max_item_size_cache; @@ -75,6 +74,8 @@ private: void _scroll_changed(double); void _input_event(const InputEvent& p_event); + + protected: void _notification(int p_what); @@ -144,11 +145,8 @@ public: void set_icon_mode(IconMode p_mode); IconMode get_icon_mode() const; - void set_min_icon_size(const Size2& p_size); - Size2 get_min_icon_size() const; - - void set_max_icon_size(const Size2& p_size); - Size2 get_max_icon_size() const; + void set_fixed_icon_size(const Size2& p_size); + Size2 get_fixed_icon_size() const; void set_allow_rmb_select(bool p_allow); bool get_allow_rmb_select() const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 2a4e82a8e7..ab556ede0c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -731,14 +731,21 @@ void LineEdit::set_cursor_pos(int p_pos) { int width_to_cursor=0; int wp=window_pos; - if (font != NULL) { - for (int i=window_pos;i<cursor_pos;i++) - width_to_cursor+=font->get_char_size( text[i] ).width; + if (font.is_valid()) { + + int accum_width=0; + + for(int i=cursor_pos;i>=window_pos;i--) { - while (width_to_cursor >= window_width && wp < text.length()) { + if (i>=text.length()) { + accum_width=font->get_char_size(' ').width; //anything should do + } else { + accum_width+=font->get_char_size(text[i],i+1<text.length()?text[i+1]:0).width; //anything should do + } + if (accum_width>=window_width) + break; - width_to_cursor -= font->get_char_size(text[wp]).width; - wp++; + wp=i; } } diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index d22f6a0229..6b36a60ea2 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -351,7 +351,7 @@ void SplitContainer::_input_event(const InputEvent& p_event) { } -Control::CursorShape SplitContainer::get_cursor_shape(const Point2& p_pos) { +Control::CursorShape SplitContainer::get_cursor_shape(const Point2& p_pos) const { if (collapsed) return Control::get_cursor_shape(p_pos); diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index f721d16310..d2dc42165e 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -75,7 +75,7 @@ public: void set_dragger_visibility(DraggerVisibility p_visibility); DraggerVisibility get_dragger_visibility() const; - virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()); + virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const; virtual Size2 get_minimum_size() const; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 3e374ef888..3d3ef46465 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2892,7 +2892,7 @@ int TextEdit::get_char_count() { return totalsize; // omit last \n } -Size2 TextEdit::get_minimum_size() { +Size2 TextEdit::get_minimum_size() const { return cache.style_normal->get_minimum_size(); } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 24a72afd48..22f024c491 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -278,7 +278,7 @@ class TextEdit : public Control { void _scroll_lines_down(); // void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask); - Size2 get_minimum_size(); + Size2 get_minimum_size() const; int get_row_height() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 2c39aea08c..08fe847a33 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1186,7 +1186,8 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Ref<Texture> updown = cache.updown; - String valtext = String::num( p_item->cells[i].val, Math::decimals( p_item->cells[i].step ) ); + //String valtext = String::num( p_item->cells[i].val, Math::decimals( p_item->cells[i].step ) ); + String valtext = rtos( p_item->cells[i].val ); font->draw( ci, text_pos, valtext, col, item_rect.size.x-updown->get_width()); if (!p_item->cells[i].editable) diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5df22ba8cc..5ac7946391 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -545,9 +545,19 @@ https://github.com/godotengine/godot/issues/3127 } #endif - if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { - //exists and did not change - continue; + if (exists) { + + //check if already exists and did not change + if (value.get_type()==Variant::REAL && original.get_type()==Variant::REAL) { + //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error + float a = value; + float b = original; + + if (Math::abs(a-b)<CMP_EPSILON) + continue; + } else if (bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { + continue; + } } if (!exists && isdefault) { diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index 4024e2f45c..d1fc614c90 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -31,7 +31,7 @@ #include "servers/visual_server.h" -RID RoomBounds::get_rid() { +RID RoomBounds::get_rid() const { return area; } diff --git a/scene/resources/room.h b/scene/resources/room.h index a9f159cd46..3ed41a3e61 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -50,7 +50,7 @@ protected: public: - virtual RID get_rid(); + virtual RID get_rid() const; void set_bounds( const BSP_Tree& p_bounds ); BSP_Tree get_bounds() const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 8d0aedbf93..2f4d37053e 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -240,7 +240,7 @@ Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) bool Theme::has_icon(const StringName& p_name,const StringName& p_type) const { - return (icon_map.has(p_type) && icon_map[p_type].has(p_name)); + return (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()); } @@ -337,12 +337,13 @@ Ref<StyleBox> Theme::get_stylebox(const StringName& p_name,const StringName& p_t return style_map[p_type][p_name]; } else { return default_style; + } } bool Theme::has_stylebox(const StringName& p_name,const StringName& p_type) const { - return (style_map.has(p_type) && style_map[p_type].has(p_name) ); + return (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()); } void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) { @@ -402,7 +403,7 @@ Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) con bool Theme::has_font(const StringName& p_name,const StringName& p_type) const { - return (font_map.has(p_type) && font_map[p_type].has(p_name)); + return (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid()); } void Theme::clear_font(const StringName& p_name,const StringName& p_type) { diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 411b99ebc8..e41461c11f 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -646,6 +646,14 @@ void Physics2DServer::_bind_methods() { // ObjectTypeDB::bind_method(_MD("sync"),&Physics2DServer::sync); //ObjectTypeDB::bind_method(_MD("flush_queries"),&Physics2DServer::flush_queries); + BIND_CONSTANT( SPACE_PARAM_CONTACT_RECYCLE_RADIUS ); + BIND_CONSTANT( SPACE_PARAM_CONTACT_MAX_SEPARATION ); + BIND_CONSTANT( SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION ); + BIND_CONSTANT( SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD ); + BIND_CONSTANT( SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD ); + BIND_CONSTANT( SPACE_PARAM_BODY_TIME_TO_SLEEP ); + BIND_CONSTANT( SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS ); + BIND_CONSTANT( SHAPE_LINE ); BIND_CONSTANT( SHAPE_SEGMENT ); BIND_CONSTANT( SHAPE_CIRCLE ); diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index f62209fafa..d023827a3c 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -521,6 +521,9 @@ FindReplaceBar::FindReplaceBar() { error_label = memnew(Label); search_options->add_child(error_label); + error_label->add_color_override("font_color", Color(1,1,0,1)); + error_label->add_color_override("font_color_shadow", Color(0,0,0,1)); + error_label->add_constant_override("shadow_as_outline", 1); search_options->add_spacer(); diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index e2b8f2884f..222e42f8a7 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -294,47 +294,33 @@ void ConnectDialog::_bind_methods() { ConnectDialog::ConnectDialog() { - int margin = get_constant("margin","Dialogs"); - int button_margin = get_constant("button_margin","Dialogs"); + VBoxContainer *vbc = memnew( VBoxContainer ); + add_child(vbc); + set_child_rect(vbc); + HBoxContainer *main_hb = memnew( HBoxContainer ); + vbc->add_child(main_hb); + main_hb->set_v_size_flags(SIZE_EXPAND_FILL); - Label * label = memnew( Label ); - label->set_pos( Point2( 8,11) ); - label->set_text(TTR("Connect To Node:")); - - - add_child(label); - label = memnew( Label ); - label->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); - label->set_pos( Point2( 0.5,11) ); - label->set_text(TTR("Binds (Extra Params):")); - add_child(label); + VBoxContainer *vbc_left = memnew( VBoxContainer ); + main_hb->add_child(vbc_left); + vbc_left->set_h_size_flags(SIZE_EXPAND_FILL); tree = memnew(SceneTreeEditor(false)); - tree->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO ); - tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - tree->set_begin( Point2( 15,32) ); - tree->set_end( Point2( 0.5,127 ) ); + vbc_left->add_margin_child(TTR("Conect To Node:"),tree,true); - add_child(tree); - bind_editor = memnew( PropertyEditor ); - bind_editor->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - bind_editor->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); - bind_editor->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - bind_editor->set_begin( Point2( 0.51,42) ); - bind_editor->set_end( Point2( 15,127 ) ); - bind_editor->get_top_label()->hide(); - add_child(bind_editor); + VBoxContainer *vbc_right = memnew( VBoxContainer ); + main_hb->add_child(vbc_right); + vbc_right->set_h_size_flags(SIZE_EXPAND_FILL); + + HBoxContainer *add_bind_hb = memnew( HBoxContainer ); type_list = memnew( OptionButton ); - type_list->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO ); - type_list->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); - type_list->set_begin( Point2( 0.51,32) ); - type_list->set_end( Point2( 0.75,33 ) ); - add_child(type_list); + type_list->set_h_size_flags(SIZE_EXPAND_FILL); + add_bind_hb->add_child(type_list); type_list->add_item("bool",Variant::BOOL); @@ -356,65 +342,36 @@ ConnectDialog::ConnectDialog() { type_list->select(0); Button *add_bind = memnew( Button ); - add_bind->set_anchor( MARGIN_RIGHT, ANCHOR_RATIO ); - add_bind->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); - add_bind->set_begin( Point2( 0.76,32) ); - add_bind->set_end( Point2( 0.84,33 ) ); + add_bind->set_text(TTR("Add")); - add_child(add_bind); + add_bind_hb->add_child(add_bind); add_bind->connect("pressed",this,"_add_bind"); Button *del_bind = memnew( Button ); - del_bind->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - del_bind->set_anchor( MARGIN_LEFT, ANCHOR_RATIO ); - del_bind->set_begin( Point2( 0.85,32) ); - del_bind->set_end( Point2( 15,33 ) ); del_bind->set_text(TTR("Remove")); - add_child(del_bind); + add_bind_hb->add_child(del_bind); del_bind->connect("pressed",this,"_remove_bind"); + vbc_right->add_margin_child(TTR("Add Extra Call Argument:"),add_bind_hb); - label = memnew( Label ); - label->set_anchor( MARGIN_TOP, ANCHOR_END ); - label->set_begin( Point2( 8,124) ); - label->set_end( Point2( 15,99) ); - label->set_text(TTR("Path To Node:")); + bind_editor = memnew( PropertyEditor ); + bind_editor->hide_top_label(); - add_child(label); + vbc_right->add_margin_child(TTR("Extra Call Arguments:"),bind_editor,true); - dst_path = memnew(LineEdit); - dst_path->set_anchor( MARGIN_TOP, ANCHOR_END ); - dst_path->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - dst_path->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - dst_path->set_begin( Point2( 15,105) ); - dst_path->set_end( Point2( 15,80 ) ); - add_child(dst_path); - label = memnew( Label ); - label->set_anchor( MARGIN_TOP, ANCHOR_END ); - label->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - label->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - label->set_begin( Point2( 8,78 ) ); - label->set_end( Point2( 15,52 ) ); - label->set_text(TTR("Method In Node:")); - add_child(label); + dst_path = memnew(LineEdit); + vbc->add_margin_child(TTR("Path to Node:"),dst_path); HBoxContainer *dstm_hb = memnew( HBoxContainer ); - dstm_hb->set_anchor( MARGIN_TOP, ANCHOR_END ); - dstm_hb->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - dstm_hb->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - dstm_hb->set_begin( Point2( 15,59) ); - dstm_hb->set_end( Point2( 15,39 ) ); - add_child(dstm_hb); + vbc->add_margin_child("Method In Node:",dstm_hb); dst_method = memnew(LineEdit); dst_method->set_h_size_flags(SIZE_EXPAND_FILL); dstm_hb->add_child(dst_method); - - /*dst_method_list = memnew( MenuButton ); dst_method_list->set_text("List.."); dst_method_list->set_anchor( MARGIN_RIGHT, ANCHOR_END ); @@ -567,6 +524,7 @@ void ConnectionsDock::_connect_pressed() { connect_dialog->edit(node); connect_dialog->popup_centered_ratio(); + connect_dialog->set_title(TTR("Connecting Signal:")+" "+signalname); connect_dialog->set_dst_method("_on_"+midname+"_"+signal); connect_dialog->set_dst_node(node->get_owner()?node->get_owner():node); diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index b6137ddac0..5275e1beeb 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -103,7 +103,7 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty item->set_selectable(0,false); } else { - if (!*to_select && (search_box->get_text()=="" || p_type.findn(search_box->get_text())!=-1)) { + if (!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) { *to_select=item; } @@ -172,7 +172,7 @@ void CreateDialog::_update_search() { bool found=false; String type=I->get(); while(type!="" && ObjectTypeDB::is_type(type,base_type) && type!=base_type) { - if (type.findn(search_box->get_text())!=-1) { + if (search_box->get_text().is_subsequence_ofi(type)) { found=true; break; @@ -194,7 +194,7 @@ void CreateDialog::_update_search() { const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for(int i=0;i<ct.size();i++) { - bool show = search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1; + bool show = search_box->get_text().is_subsequence_ofi(ct[i].name); if (!show) continue; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 185ec17459..e631aad7f6 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -443,7 +443,7 @@ void EditorFileDialog::update_file_list() { item_list->set_icon_mode(ItemList::ICON_MODE_TOP); item_list->set_fixed_column_width(thumbnail_size*3/2); item_list->set_max_text_lines(2); - item_list->set_min_icon_size(Size2(thumbnail_size,thumbnail_size)); + item_list->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size)); if (!has_icon("ResizedFolder","EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig","EditorIcons"); @@ -475,7 +475,7 @@ void EditorFileDialog::update_file_list() { item_list->set_max_columns(1); item_list->set_max_text_lines(1); item_list->set_fixed_column_width(0); - item_list->set_min_icon_size(Size2()); + item_list->set_fixed_icon_size(Size2()); if (preview->get_texture().is_valid()) preview_vb->show(); diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index ac9feacd46..0b60db5ee3 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -453,7 +453,7 @@ void EditorHelpIndex::_update_class_list() { String type = E->key(); while(type != "") { - if (type.findn(filter)!=-1) { + if (filter.is_subsequence_ofi(type)) { if (to_select.empty()) { to_select = type; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 26e40cf816..2e8bf0f311 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -217,7 +217,7 @@ void EditorNode::_notification(int p_what) { if (p_what==NOTIFICATION_EXIT_TREE) { editor_data.save_editor_external_data(); - + FileAccess::set_file_close_fail_notify_callback(NULL); log->deinit(); // do not get messages anymore } if (p_what==NOTIFICATION_PROCESS) { @@ -3089,6 +3089,7 @@ void EditorNode::set_addon_plugin_enabled(const String& p_addon,bool p_enabled) if (!p_enabled) { EditorPlugin *addon = plugin_addons[p_addon]; + editor_data.remove_editor_plugin( addon ); memdelete(addon); //bye plugin_addons.erase(p_addon); _update_addon_config(); @@ -5137,6 +5138,10 @@ void EditorNode::_dropped_files(const Vector<String>& p_files,int p_screen) { EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); } } +void EditorNode::_file_access_close_error_notify(const String& p_str) { + + add_io_error("Unable to write to file '"+p_str+"', file in use, locked or lacking permissions."); +} void EditorNode::_bind_methods() { @@ -5232,7 +5237,6 @@ EditorNode::EditorNode() { SceneState::set_disable_placeholders(true); editor_initialize_certificates(); //for asset sharing - InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); if (id) { @@ -6274,7 +6278,7 @@ EditorNode::EditorNode() { logo->set_texture(gui_base->get_icon("Logo","EditorIcons") ); warning = memnew( AcceptDialog ); - add_child(warning); + gui_base->add_child(warning); @@ -6574,6 +6578,7 @@ EditorNode::EditorNode() { _load_docks(); + FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify); } @@ -6581,6 +6586,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { + memdelete( EditorHelp::get_doc_data() ); memdelete(editor_selection); memdelete(editor_plugins_over); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 65a5687dce..7023c6c174 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -574,6 +574,7 @@ private: void _update_addon_config(); + static void _file_access_close_error_notify(const String& p_str); protected: void _notification(int p_what); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index bf01e02330..0d0008fcb8 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -86,6 +86,10 @@ bool EditorSettings::_set(const StringName& p_name, const Variant& p_value) { props[p_name].variant=p_value; else props[p_name]=VariantContainer(p_value,last_order++); + + if (save_changed_setting) { + props[p_name].save=true; + } } emit_signal("settings_changed"); @@ -126,6 +130,7 @@ struct _EVCSort { String name; Variant::Type type; int order; + bool save; bool operator<(const _EVCSort& p_vcs) const{ return order< p_vcs.order; } }; @@ -148,15 +153,24 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { vc.name=*k; vc.order=v->order; vc.type=v->variant.get_type(); + vc.save=v->save; + vclist.insert(vc); } for(Set<_EVCSort>::Element *E=vclist.front();E;E=E->next()) { - int pinfo = PROPERTY_USAGE_STORAGE; - if (!E->get().name.begins_with("_")) + int pinfo = 0; + if (E->get().save) { + pinfo|=PROPERTY_USAGE_STORAGE; + } + + if (!E->get().name.begins_with("_") && !E->get().name.begins_with("projects/")) { pinfo|=PROPERTY_USAGE_EDITOR; + } else { + pinfo|=PROPERTY_USAGE_STORAGE; //hiddens must always be saved + } PropertyInfo pi(E->get().type, E->get().name); pi.usage=pinfo; @@ -330,6 +344,7 @@ void EditorSettings::create() { goto fail; } + singleton->save_changed_setting=true; singleton->config_file_path=config_file_path; singleton->project_config_path=pcp; singleton->settings_path=config_path+"/"+config_dir; @@ -363,6 +378,7 @@ void EditorSettings::create() { }; singleton = Ref<EditorSettings>( memnew( EditorSettings ) ); + singleton->save_changed_setting=true; singleton->config_file_path=config_file_path; singleton->settings_path=config_path+"/"+config_dir; singleton->_load_defaults(extra_config); @@ -975,6 +991,7 @@ EditorSettings::EditorSettings() { //singleton=this; last_order=0; + save_changed_setting=true; EditorTranslationList *etl=_editor_translations; @@ -999,6 +1016,7 @@ EditorSettings::EditorSettings() { } _load_defaults(); + save_changed_setting=false; } diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index 60333b5811..d975a7ef86 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -64,7 +64,8 @@ private: int order; Variant variant; bool hide_from_editor; - VariantContainer(){ order=0; hide_from_editor=false; } + bool save; + VariantContainer(){ order=0; hide_from_editor=false; save=false;} VariantContainer(const Variant& p_variant, int p_order) { variant=p_variant; order=p_order; hide_from_editor=false; } }; @@ -85,6 +86,9 @@ private: Ref<Resource> clipboard; + bool save_changed_setting; + + void _load_defaults(Ref<ConfigFile> p_extra_config = NULL); void _load_default_text_editor_theme(); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 8d00f2cd8a..48505324d3 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -2147,12 +2147,17 @@ void ScriptEditor::save_all_scripts() { continue; Ref<Script> script = ste->get_edited_script(); + if (script.is_valid()) + ste->apply_code(); + if (script->get_path()!="" && script->get_path().find("local://")==-1 &&script->get_path().find("::")==-1) { //external script, save it - ste->apply_code(); + editor->save_resource(script); //ResourceSaver::save(script->get_path(),script); + } + } } @@ -2273,6 +2278,8 @@ void ScriptEditor::_editor_settings_changed() { ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); } + ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true)); + } void ScriptEditor::_autosave_scripts() { @@ -2614,8 +2621,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { edit_menu->get_popup()->add_item(TTR("Auto Indent"),EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I); edit_menu->get_popup()->connect("item_pressed", this,"_menu_option"); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_item(TTR("Reload Tool Script"),FILE_TOOL_RELOAD,KEY_MASK_CMD|KEY_R); - edit_menu->get_popup()->add_item(TTR("Reload Tool Script (Soft)"),FILE_TOOL_RELOAD_SOFT,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R); + edit_menu->get_popup()->add_item(TTR("Soft Reload Script"),FILE_TOOL_RELOAD_SOFT,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R); search_menu = memnew( MenuButton ); @@ -2919,6 +2925,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { script_editor->hide(); EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",true); + ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true)); EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true); EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); @@ -2930,6 +2937,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("external_editor/exec_flags",""); + } diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 4532e91e1f..4f59287994 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -825,7 +825,7 @@ SpriteFramesEditor::SpriteFramesEditor() { tree->set_icon_mode(ItemList::ICON_MODE_TOP); tree->set_fixed_column_width(thumbnail_size*3/2); tree->set_max_text_lines(2); - tree->set_max_icon_size(Size2(thumbnail_size,thumbnail_size)); + tree->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size)); //tree->set_min_icon_size(Size2(thumbnail_size,thumbnail_size)); tree->set_drag_forwarding(this); diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 37cb0398e7..2673948365 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -583,6 +583,7 @@ ThemeEditor::ThemeEditor() { add_child(panel); panel->set_area_as_parent_rect(0); panel->set_margin(MARGIN_TOP,25); + panel->set_theme(Theme::get_default()); main_vb= memnew( VBoxContainer ); panel->add_child(main_vb); diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 6d5f2a519c..5a40777665 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -208,9 +208,14 @@ void TileMapEditor::_update_palette() { palette->set_max_columns(0); palette->add_constant_override("hseparation", 6); + + float min_size = EDITOR_DEF("tile_map/preview_size",64); + palette->set_fixed_icon_size(Size2(min_size, min_size)); + palette->set_fixed_column_width(min_size*3/2); palette->set_icon_mode(ItemList::ICON_MODE_TOP); palette->set_max_text_lines(2); + String filter = search_box->get_text().strip_edges(); for (List<int>::Element *E=tiles.front();E;E=E->next()) { @@ -1434,6 +1439,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { + EDITOR_DEF("tile_map/preview_size",64); tile_map_editor = memnew( TileMapEditor(p_node) ); add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor); tile_map_editor->hide(); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 2f0ba2da99..763734f035 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -1963,6 +1963,13 @@ bool PropertyEditor::_is_property_different(const Variant& p_current, const Vari return false; } + if (p_current.get_type()==Variant::REAL && p_orig.get_type()==Variant::REAL) { + float a = p_current; + float b = p_orig; + + return Math::abs(a-b)>CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error + } + return bool(Variant::evaluate(Variant::OP_NOT_EQUAL,p_current,p_orig)); } @@ -2232,6 +2239,7 @@ void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) { if (_get_instanced_node_original_property(p_name,vorig) || usage) { Variant v = obj->get(p_name); + bool changed = _is_property_different(v,vorig,usage); //if ((found!=-1 && !is_disabled)!=changed) { @@ -2804,7 +2812,7 @@ void PropertyEditor::update_tree() { if (capitalize_paths) cat = cat.capitalize(); - if (cat.findn(filter)==-1 && name.findn(filter)==-1) + if (!filter.is_subsequence_ofi(cat) && !filter.is_subsequence_ofi(name)) continue; } diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index 72059c264f..fc2a2241ab 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -126,7 +126,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { path+="/"; if (path!="res://") { path=path.substr(6,path.length()); - if (path.findn(search_box->get_text())!=-1) { + if (search_box->get_text().is_subsequence_ofi(path)) { TreeItem *ti = search_options->create_item(root); ti->set_text(0,path); Ref<Texture> icon = get_icon("folder","FileDialog"); @@ -138,7 +138,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { String file = efsd->get_file_path(i); file=file.substr(6,file.length()); - if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text()=="" || file.findn(search_box->get_text())!=-1)) { + if (ObjectTypeDB::is_type(efsd->get_file_type(i),base_type) && (search_box->get_text().is_subsequence_ofi(file))) { TreeItem *ti = search_options->create_item(root); ti->set_text(0,file); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 9612305a0f..5124505b90 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -201,6 +201,7 @@ static String _get_name_num_separator() { return " "; } + void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=p_tool; @@ -519,6 +520,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorNode::get_singleton()->push_item(mne.ptr()); } break; + case TOOL_ERASE: { List<Node*> remove_list = editor_selection->get_selected_node_list(); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index f8ce121690..2de6fc5cf2 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -94,6 +94,29 @@ void SceneTreeEditor::_subscene_option(int p_idx) { case SCENE_MENU_CLEAR_INHERITANCE: { clear_inherit_confirm->popup_centered_minsize(); } break; + case SCENE_MENU_CLEAR_INSTANCING: { + + Node*root=EditorNode::get_singleton()->get_edited_scene(); + if (!root) + break; + + + ERR_FAIL_COND(node->get_filename()==String()); + + undo_redo->create_action("Discard Instancing"); + + undo_redo->add_do_method(node,"set_filename",""); + undo_redo->add_undo_method(node,"set_filename",node->get_filename()); + + _node_replace_owner(node,node,root); + + undo_redo->add_do_method(this,"update_tree"); + undo_redo->add_undo_method(this,"update_tree"); + + undo_redo->commit_action(); + + + } break; case SCENE_MENU_OPEN_INHERITED: { if (node && node->get_scene_inherited_state().is_valid()) { emit_signal("open",node->get_scene_inherited_state()->get_path()); @@ -108,11 +131,30 @@ void SceneTreeEditor::_subscene_option(int p_idx) { } break; + } } +void SceneTreeEditor::_node_replace_owner(Node* p_base,Node* p_node,Node* p_root) { + + if (p_base!=p_node) { + + if (p_node->get_owner()==p_base) { + + undo_redo->add_do_method(p_node,"set_owner",p_root); + undo_redo->add_undo_method(p_node,"set_owner",p_base); + } + } + + for(int i=0;i<p_node->get_child_count();i++) { + + _node_replace_owner(p_base,p_node->get_child(i),p_root); + } +} + + void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) { TreeItem *item=p_item->cast_to<TreeItem>(); @@ -386,7 +428,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { item->set_as_cursor(0); } - bool keep= ( filter==String() || String(p_node->get_name()).to_lower().find(filter.to_lower())!=-1 ); + bool keep= (filter.is_subsequence_ofi(String(p_node->get_name()))); for (int i=0;i<p_node->get_child_count();i++) { @@ -606,7 +648,7 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->connect("node_removed",this,"_node_removed"); get_tree()->connect("node_configuration_warning_changed",this,"_warning_changed"); - instance_menu->set_item_icon(3,get_icon("Load","EditorIcons")); + instance_menu->set_item_icon(5,get_icon("Load","EditorIcons")); tree->connect("item_collapsed",this,"_cell_collapsed"); inheritance_menu->set_item_icon(2,get_icon("Load","EditorIcons")); clear_inherit_confirm->connect("confirmed",this,"_subscene_option",varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM)); @@ -1109,6 +1151,8 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open instance_menu->add_check_item(TTR("Editable Children"),SCENE_MENU_EDITABLE_CHILDREN); instance_menu->add_check_item(TTR("Load As Placeholder"),SCENE_MENU_USE_PLACEHOLDER); instance_menu->add_separator(); + instance_menu->add_item(TTR("Discard Instancing"),SCENE_MENU_CLEAR_INSTANCING); + instance_menu->add_separator(); instance_menu->add_item(TTR("Open in Editor"),SCENE_MENU_OPEN); instance_menu->connect("item_pressed",this,"_subscene_option"); add_child(instance_menu); diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h index ae0afa32ec..e184891200 100644 --- a/tools/editor/scene_tree_editor.h +++ b/tools/editor/scene_tree_editor.h @@ -61,6 +61,7 @@ class SceneTreeEditor : public Control { SCENE_MENU_CLEAR_INHERITANCE, SCENE_MENU_OPEN_INHERITED, SCENE_MENU_CLEAR_INHERITANCE_CONFIRM, + SCENE_MENU_CLEAR_INSTANCING, }; Tree *tree; @@ -117,6 +118,7 @@ class SceneTreeEditor : public Control { void _node_visibility_changed(Node *p_node); void _subscene_option(int p_idx); + void _node_replace_owner(Node* p_base,Node* p_node,Node* p_root); void _selection_changed(); diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index 7953cf2739..44832c84eb 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -454,8 +454,7 @@ void ScenesDock::_update_files(bool p_keep_selection) { files->set_icon_mode(ItemList::ICON_MODE_TOP); files->set_fixed_column_width(thumbnail_size*3/2); files->set_max_text_lines(2); - files->set_min_icon_size(Size2(thumbnail_size,thumbnail_size)); - files->set_max_icon_size(Size2(thumbnail_size,thumbnail_size)); + files->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size)); if (!has_icon("ResizedFolder","EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig","EditorIcons"); @@ -485,7 +484,7 @@ void ScenesDock::_update_files(bool p_keep_selection) { files->set_max_columns(1); files->set_max_text_lines(1); files->set_fixed_column_width(0); - files->set_min_icon_size(Size2()); + files->set_fixed_icon_size(Size2()); } diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 37a90ba7be..6d8f54d88f 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -1731,15 +1731,17 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ docontinue->set_tooltip(TTR("Continue")); docontinue->connect("pressed",this,"debug_continue"); - hbc->add_child( memnew( VSeparator) ); + //hbc->add_child( memnew( VSeparator) ); back = memnew( Button ); hbc->add_child(back); back->set_tooltip(TTR("Inspect Previous Instance")); + back->hide(); forward = memnew( Button ); hbc->add_child(forward); forward->set_tooltip(TTR("Inspect Next Instance")); + forward->hide(); HSplitContainer *sc = memnew( HSplitContainer ); |