diff options
91 files changed, 1631 insertions, 455 deletions
diff --git a/.travis.yml b/.travis.yml index c5f9cf48b7..3c7ee5c102 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,7 @@ addons: - libglu1-mesa-dev - libssl-dev - libxinerama-dev - - libudev-dev + - libxrandr-dev # For cross-compiling to Windows. - binutils-mingw-w64-i686 diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 63764383ff..2594be63ac 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -489,6 +489,7 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORE_IF_NONONE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NO_INSTANCE_STATE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_RESTART_IF_CHANGED ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_SCRIPT_VARIABLE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT_INTL ), 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/object.h b/core/object.h index 9359f4d4b2..a27e8c7dd8 100644 --- a/core/object.h +++ b/core/object.h @@ -86,6 +86,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false PROPERTY_USAGE_NO_INSTANCE_STATE=2048, PROPERTY_USAGE_RESTART_IF_CHANGED=4096, + PROPERTY_USAGE_SCRIPT_VARIABLE=8192, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, 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/os/input.cpp b/core/os/input.cpp index a766ef87fc..005a248aac 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -59,6 +59,10 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis); ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name); ObjectTypeDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid); + ObjectTypeDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength); + ObjectTypeDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration); + ObjectTypeDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration); + ObjectTypeDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration); ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); ObjectTypeDB::bind_method(_MD("get_magnetometer"),&Input::get_magnetometer); //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want diff --git a/core/os/input.h b/core/os/input.h index 46edb30aa1..6364d597b0 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -67,6 +67,11 @@ public: virtual void remove_joy_mapping(String p_guid)=0; virtual bool is_joy_known(int p_device)=0; virtual String get_joy_guid(int p_device) const=0; + virtual Vector2 get_joy_vibration_strength(int p_device)=0; + virtual float get_joy_vibration_duration(int p_device)=0; + virtual uint64_t get_joy_vibration_timestamp(int p_device)=0; + virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration)=0; + virtual void stop_joy_vibration(int p_device)=0; virtual Point2 get_mouse_pos() const=0; virtual Point2 get_mouse_speed() const=0; 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..71e972bac6 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> @@ -15788,6 +15788,23 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Returns a SDL2 compatible device guid on platforms that use gamepad remapping. Returns "Default Gamepad" otherwise. </description> </method> + <method name="get_joy_vibration_strength"> + <return type="Vector2"> + </return> + <argument index="0" name="device" type="int"> + </argument> + <description> + Returns the strength of the joystick vibration: x is the strength of the weak motor, and y is the strength of the strong motor. + </description> + </method> + <method name="get_joy_vibration_duration"> + <return type="float"> + </return> + <argument index="0" name="device" type="int"> + </argument> + <description> + Returns the duration of the current vibration effect in seconds. + </description> <method name="get_accelerometer"> <return type="Vector3"> </return> @@ -15830,6 +15847,26 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Return the mouse mode. See the constants for more information. </description> </method> + <method name="start_joy_vibration"> + <argument index="0" name="device" type="int"> + </argument> + <argument index="1" name="weak_magnitude" type="float"> + </argument> + <argument index="2" name="strong_magnitude" type="float"> + </argument> + <argument index="3" name="duration" type="float"> + </argument> + <description> + Starts to vibrate the joystick. Joysticks usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will play the vibration indefinitely). + </description> + </method> + <method name="stop_joy_vibration"> + <argument index="0" name="device" type="int"> + </argument> + <description> + Stops the vibration of the joystick. + </description> + </method> <method name="warp_mouse_pos"> <argument index="0" name="to" type="Vector2"> </argument> @@ -24970,12 +25007,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 +25109,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 +25127,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 +25172,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 +25209,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 +25241,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 +25264,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 +25284,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 +25299,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 +25311,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 +25320,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 +25359,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 +25368,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 +25377,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 +25386,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 +25411,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 +25420,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 +25431,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 +25442,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 +25451,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 +25467,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 +25476,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 +25485,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 +25494,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 +25505,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 +25516,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 +25527,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 +25536,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 +25547,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 +25558,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 +25567,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 +25583,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 +25592,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 +25603,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 +25612,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 +25632,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 +25641,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 +25650,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 +25661,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 +25677,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 +25686,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 +25695,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 +25704,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 +25713,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 +25724,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 +25735,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 +25746,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 +25757,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 +25766,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 +25777,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 +25788,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 +25808,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 +25826,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 +25837,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 +25846,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 +25855,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 +25864,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 +25874,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 +25883,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 +25892,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 +25901,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 +25910,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 +25921,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 +25932,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 +25943,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 +25965,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 +25976,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 +25985,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 +25994,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 +26003,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 +26012,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 +26021,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 +26030,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 +26039,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 +26048,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 +26057,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 +26066,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 +26075,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 +26088,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 +26103,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 +26114,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 +26125,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 +26138,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 +26155,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 +26170,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 +26181,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 +26192,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 +26201,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 +26224,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 +26314,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 +26431,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 +28660,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 +31694,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 +31747,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 +37308,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/main/input_default.cpp b/main/input_default.cpp index 5b4ae7f2cb..a6f14ae1f5 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -137,6 +137,30 @@ String InputDefault::get_joy_name(int p_idx) { return joy_names[p_idx].name; }; +Vector2 InputDefault::get_joy_vibration_strength(int p_device) { + if (joy_vibration.has(p_device)) { + return Vector2(joy_vibration[p_device].weak_magnitude, joy_vibration[p_device].strong_magnitude); + } else { + return Vector2(0, 0); + } +} + +uint64_t InputDefault::get_joy_vibration_timestamp(int p_device) { + if (joy_vibration.has(p_device)) { + return joy_vibration[p_device].timestamp; + } else { + return 0; + } +} + +float InputDefault::get_joy_vibration_duration(int p_device) { + if (joy_vibration.has(p_device)) { + return joy_vibration[p_device].duration; + } else { + return 0.f; + } +} + static String _hex_str(uint8_t p_byte) { static const char* dict = "0123456789abcdef"; @@ -294,6 +318,29 @@ void InputDefault::set_joy_axis(int p_device,int p_axis,float p_value) { _joy_axis[c]=p_value; } +void InputDefault::start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration) { + _THREAD_SAFE_METHOD_ + if (p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) { + return; + } + VibrationInfo vibration; + vibration.weak_magnitude = p_weak_magnitude; + vibration.strong_magnitude = p_strong_magnitude; + vibration.duration = p_duration; + vibration.timestamp = OS::get_singleton()->get_unix_time(); + joy_vibration[p_device] = vibration; +} + +void InputDefault::stop_joy_vibration(int p_device) { + _THREAD_SAFE_METHOD_ + VibrationInfo vibration; + vibration.weak_magnitude = 0; + vibration.strong_magnitude = 0; + vibration.duration = 0; + vibration.timestamp = OS::get_singleton()->get_unix_time(); + joy_vibration[p_device] = vibration; +} + void InputDefault::set_accelerometer(const Vector3& p_accel) { _THREAD_SAFE_METHOD_ @@ -416,26 +463,35 @@ static const char *s_ControllerMappings [] = #ifdef WINDOWS_ENABLED "00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", + "0d0f4900000000000000504944564944,Hatsune Miku Sho Controller,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", + "10080100000000000000504944564944,PS1 USB,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "10080300000000000000504944564944,PS2 USB,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a4,righty:a2,lefttrigger:b4,righttrigger:b5,", "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,", + "2509e803000000000000504944564944,Mayflash Wii Classic Controller,a:b1,b:b0,x:b3,y:b2,back:b8,guide:b10,start:b9,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:b11,dpdown:b13,dpleft:b12,dpright:b14,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "28040140000000000000504944564944,GamePad Pro USB,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,", "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "36280100000000000000504944564944,OUYA Controller,a:b0,b:b3,y:b2,x:b1,start:b14,guide:b15,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b8,dpleft:b10,dpdown:b9,dpright:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b12,righttrigger:b13,", + "49190204000000000000504944564944,Ipega PG-9023,a:b0,b:b1,x:b3,y:b4,back:b10,start:b11,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b8,righttrigger:b9", "4b12014d000000000000504944564944,NYKO AIRFLO,a:b0,b:b1,x:b2,y:b3,back:b8,guide:b10,start:b9,leftstick:a0,rightstick:a2,leftshoulder:a3,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:h0.6,lefty:h0.12,rightx:h0.9,righty:h0.4,lefttrigger:b6,righttrigger:b7,", "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "4f0400b3000000000000504944564944,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "4f0415b3000000000000504944564944,Thrustmaster Dual Analog 3.2,x:b1,a:b0,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", + "4f0423b3000000000000504944564944,Dual Trigger 3-in-1,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7", "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "6d0418c2000000000000504944564944,Logitech RumblePad 2 USB,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "6f0e1e01000000000000504944564944,Rock Candy Gamepad for PS3,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", + "79000018000000000000504944564944,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", + "79000600000000000000504944564944,G-Shark GS-GP702,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7", + "79004318000000000000504944564944,Mayflash GameCube Controller Adapter,a:b1,b:b2,x:b0,y:b3,back:b0,start:b9,guide:b0,leftshoulder:b4,rightshoulder:b7,leftstick:b0,rightstick:b0,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "79000600000000000000504944564944,Generic Speedlink,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,", "83056020000000000000504944564944,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,", "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,", "8f0e0300000000000000504944564944,Trust GXT 28,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "8f0e0d31000000000000504944564944,Multilaser JS071 USB,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "8f0e1200000000000000504944564944,Acme,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", + "9000318000000000000504944564944,Mayflash Wiimote PC Adapter,a:b2,b:h0.4,x:b0,y:b1,back:b4,start:b5,guide:b11,leftshoulder:b6,rightshoulder:b3,leftx:a0,lefty:a1,", "a3060cff000000000000504944564944,Saitek P2500,a:b2,b:b3,y:b1,x:b0,start:b4,guide:b10,back:b5,leftstick:b8,rightstick:b9,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "c911f055000000000000504944564944,GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "d6206dca000000000000504944564944,PowerA Pro Ex,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", @@ -475,11 +531,14 @@ static const char *s_ControllerMappings [] = "03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,y:b0,x:b3,start:b8,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,", "03000000260900008888000000010000,GameCube {WiseGroup USB box},a:b0,b:b2,y:b3,x:b1,start:b7,leftshoulder:,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,rightstick:,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", "03000000280400000140000000010000,Gravis GamePad Pro USB ,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftx:a0,lefty:a1,", + "03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,y:b3,x:b0,start:b9,guide:,back:,leftstick:,rightstick:,leftshoulder:,dpleft:b15,dpdown:b14,dpright:b13,leftx:a0,lefty:a1,rightx:a5,righty:a2,lefttrigger:a3,righttrigger:a4,rightshoulder:b7,dpup:b12,", + "03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c050000c405000011010000,Sony DualShock 4,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,", "030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,x:b0,y:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,", "030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,x:b0,y:b3,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", + "030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,x:b1,y:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,y:b3,x:b1,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a5,", "030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", @@ -490,6 +549,7 @@ static const char *s_ControllerMappings [] = "030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "030000005e040000d102000001010000,Microsoft X-Box One pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", + "030000005e040000dd02000003020000,Microsoft X-Box One pad v2,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,x:b3,y:b0,back:b9,start:b8,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,dpup:b12,dpleft:b15,dpdown:b14,dpright:b13,", "030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,y:b4,x:b3,start:b8,guide:b5,back:b2,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b9,righttrigger:b10,", "030000006d04000016c2000010010000,Logitech Logitech Dual Action,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", @@ -499,11 +559,14 @@ static const char *s_ControllerMappings [] = "030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", + "030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,x:b0,a:b2,b:b3,y:b1,back:b10,guide:b12,start:b11,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "030000006f0e00001304000000010000,Generic X-Box pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000006f0e00001e01000011010000,Rock Candy Gamepad for PS3,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "030000006f0e00001f01000000010000,Generic X-Box pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000006f0e00002801000011010000,PDP Rock Candy Wireless Controller for PS3,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b11,rightshoulder:b5,rightx:a2,start:b9,righty:a3,dpleft:h0.8,lefttrigger:b6,x:b0,dpup:h0.1,back:b8,leftstick:b10,leftshoulder:b4,y:b3,a:b1,dpright:h0.2,righttrigger:b7,b:b2,", "030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", + "030000006f0e00003901000020060000,Afterglow Wired Controller for Xbox One,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", + "030000006f0e00004601000001010000,Rock Candy Wired Controller for Xbox One,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,guide:b8,leftstick:b9,rightstick:b10,lefttrigger:a2,righttrigger:a5,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "03000000790000001100000010010000,RetroLink Saturn Classic Controller,x:b3,a:b0,b:b1,y:b4,back:b5,guide:b2,start:b8,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "03000000830500006020000010010000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,x:b3,y:b2,back:b6,start:b7,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,", @@ -511,6 +574,8 @@ static const char *s_ControllerMappings [] = "030000008916000001fd000024010000,Razer Onza Classic Edition,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:b11,dpdown:b14,dpright:b12,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000008f0e00000300000010010000,GreenAsia Inc. USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", "030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", + "03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,y:b3,x:b0,start:b12,guide:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,", + "03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,", "03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", diff --git a/main/input_default.h b/main/input_default.h index 8f6a430436..01b813f3ca 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -3,6 +3,7 @@ #include "os/input.h" + class InputDefault : public Input { OBJ_TYPE( InputDefault, Input ); @@ -19,6 +20,16 @@ class InputDefault : public Input { MainLoop *main_loop; bool emulate_touch; + + struct VibrationInfo { + float weak_magnitude; + float strong_magnitude; + float duration; // Duration in seconds + uint64_t timestamp; + }; + + Map<int, VibrationInfo> joy_vibration; + struct SpeedTrack { uint64_t last_tick; @@ -129,6 +140,9 @@ public: virtual float get_joy_axis(int p_device,int p_axis); String get_joy_name(int p_idx); + virtual Vector2 get_joy_vibration_strength(int p_device); + virtual float get_joy_vibration_duration(int p_device); + virtual uint64_t get_joy_vibration_timestamp(int p_device); void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = ""); void parse_joystick_mapping(String p_mapping, bool p_update_existing); @@ -147,6 +161,9 @@ public: void set_magnetometer(const Vector3& p_magnetometer); void set_joy_axis(int p_device,int p_axis,float p_value); + virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration); + virtual void stop_joy_vibration(int p_device); + void set_main_loop(MainLoop *main_loop); void set_mouse_pos(const Point2& p_posf); diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index d51f1a4ddc..7481eac620 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -1611,6 +1611,9 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa p_script->member_default_values[name]=p_class->variables[i].default_value; } #endif + } else { + + p_script->member_info[name]=PropertyInfo(Variant::NIL,name,PROPERTY_HINT_NONE,"",PROPERTY_USAGE_SCRIPT_VARIABLE); } //int new_idx = p_script->member_indices.size(); diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 04522aadc2..9d438998cb 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -727,7 +727,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a String methodstr = GDFunctions::get_func_name(func); - err_text=_get_call_error(err,"built-in function '"+methodstr+"'",(const Variant**)argptrs); + if (dst->get_type()==Variant::STRING) { + //call provided error string + err_text="Error calling built-in function '"+methodstr+"': "+String(*dst); + } else { + err_text=_get_call_error(err,"built-in function '"+methodstr+"'",(const Variant**)argptrs); + } break; } ip+=argc+1; diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 5ea5908c5f..077255064d 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -120,11 +120,13 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va if (p_arg_count<m_count) {\ r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;\ r_error.argument=m_count;\ + r_ret=Variant();\ return;\ }\ if (p_arg_count>m_count) {\ r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;\ r_error.argument=m_count;\ + r_ret=Variant();\ return;\ } @@ -133,6 +135,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;\ r_error.argument=m_arg;\ r_error.expected=Variant::REAL;\ + r_ret=Variant();\ return;\ } @@ -244,6 +247,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::REAL; + r_ret=Variant(); } } break; case MATH_SIGN: { @@ -261,6 +265,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::REAL; + r_ret=Variant(); } } break; case MATH_POW: { @@ -442,6 +447,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; + r_ret=Variant(); return; } @@ -479,7 +485,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; - r_ret=Variant(); + r_ret=Variant(); return; } @@ -508,8 +514,11 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va int type=*p_args[1]; if (type<0 || type>=Variant::VARIANT_MAX) { - ERR_PRINT("Invalid type argument to convert()"); - r_ret=Variant::NIL; + r_ret=RTR("Invalid type argument to convert(), use TYPE_* constants."); + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::INT; + return; } else { @@ -638,7 +647,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::STRING; - r_ret=Variant(); + r_ret="Parse error at line "+itos(line)+": "+errs; + return; } } break; @@ -652,7 +662,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::NIL; - r_ret=Variant(); + r_ret="Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."; return; } @@ -680,11 +690,10 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va ByteArray::Read r=varr.read(); Error err = decode_variant(ret,r.ptr(),varr.size(),NULL); if (err!=OK) { - ERR_PRINT("Not enough bytes for decoding.."); + r_ret=RTR("Not enough bytes for decoding bytes, or invalid format."); r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::RAW_ARRAY; - r_ret=Variant(); return; } @@ -701,6 +710,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument=1; + r_ret=Variant(); } break; case 1: { @@ -759,9 +769,9 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va int incr=*p_args[2]; if (incr==0) { - ERR_EXPLAIN("step argument is zero!"); + r_ret=RTR("step argument is zero!"); r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; - ERR_FAIL(); + return; } Array arr(true); @@ -812,6 +822,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.argument=3; + r_ret=Variant(); + } break; } @@ -847,8 +859,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::DICTIONARY; - ERR_PRINT("Not a script with an instance"); - + r_ret=RTR("Not a script with an instance"); + return; } else { GDInstance *ins = static_cast<GDInstance*>(obj->get_script_instance()); @@ -858,7 +870,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::DICTIONARY; - ERR_PRINT("Not based on a script"); + r_ret=RTR("Not based on a script"); return; } @@ -879,8 +891,10 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::DICTIONARY; - print_line("PATH: "+p->path); - ERR_PRINT("Not based on a resource file"); + r_ret=Variant(); + + + r_ret=RTR("Not based on a resource file"); return; } @@ -926,6 +940,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::DICTIONARY; + r_ret=Variant(); + return; } @@ -936,6 +952,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; + r_ret=RTR("Invalid instance dictionary format (missing @path)"); + return; } @@ -945,6 +963,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; + r_ret=RTR("Invalid instance dictionary format (can't load script at @path)"); return; } @@ -955,6 +974,8 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; + r_ret=Variant(); + r_ret=RTR("Invalid instance dictionary format (invalid script at @path)"); return; } @@ -971,20 +992,22 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_error.expected=Variant::OBJECT; + r_ret=Variant(); + r_ret=RTR("Invalid instance dictionary (invalid subclasses)"); return; } } r_ret = gdscr->_new(NULL,0,r_error); - GDInstance *ins = static_cast<GDInstance*>(static_cast<Object*>(r_ret)->get_script_instance()); - Ref<GDScript> gd_ref = ins->get_script(); + GDInstance *ins = static_cast<GDInstance*>(static_cast<Object*>(r_ret)->get_script_instance()); + Ref<GDScript> gd_ref = ins->get_script(); - for(Map<StringName,GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) { - if(d.has(E->key())) { - ins->members[E->get().index] = d[E->key()]; - } - } + for(Map<StringName,GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) { + if(d.has(E->key())) { + ins->members[E->get().index] = d[E->key()]; + } + } } break; case HASH: { @@ -998,11 +1021,15 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va if (p_arg_count<3) { r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument=3; + r_ret=Variant(); + return; } if (p_arg_count>4) { r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.argument=4; + r_ret=Variant(); + return; } @@ -1036,6 +1063,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va if (p_args[0]->get_type()!=Variant::INT && p_args[0]->get_type()!=Variant::REAL) { r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; + r_error.expected=Variant::INT; r_ret=Variant(); break; } diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 9e90027a70..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 @@ -2408,6 +2408,7 @@ void GDParser::_parse_class(ClassNode *p_class) { return; } current_export.type=type; + current_export.usage|=PROPERTY_USAGE_SCRIPT_VARIABLE; tokenizer->advance(); if (tokenizer->get_token()==GDTokenizer::TK_COMMA) { // hint expected next! @@ -2782,6 +2783,8 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.type=Variant::OBJECT; current_export.hint=PROPERTY_HINT_RESOURCE_TYPE; + current_export.usage|=PROPERTY_USAGE_SCRIPT_VARIABLE; + current_export.hint_string=identifier; tokenizer->advance(); @@ -2901,6 +2904,7 @@ void GDParser::_parse_class(ClassNode *p_class) { return; } member._export.type=cn->value.get_type(); + member._export.usage|=PROPERTY_USAGE_SCRIPT_VARIABLE; } } #ifdef TOOLS_ENABLED 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/platform/x11/detect.py b/platform/x11/detect.py index 0362756f7c..5f272536ba 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -45,6 +45,11 @@ def can_build(): print("xinerama not found.. x11 disabled.") return False + x11_error=os.system("pkg-config xrandr --modversion > /dev/null ") + if (x11_error): + print("xrandr not found.. x11 disabled.") + return False + return True # X11 enabled @@ -134,6 +139,7 @@ def configure(env): env.ParseConfig('pkg-config x11 --cflags --libs') env.ParseConfig('pkg-config xinerama --cflags --libs') env.ParseConfig('pkg-config xcursor --cflags --libs') + env.ParseConfig('pkg-config xrandr --cflags --libs') if (env["openssl"]=="yes"): env.ParseConfig('pkg-config openssl --cflags --libs') @@ -176,7 +182,7 @@ def configure(env): print("PulseAudio development libraries not found, disabling driver") env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'GLU', 'pthread', 'z']) + env.Append(LIBS=['GL', 'GLU', 'pthread', 'z', 'dl']) #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) #host compiler is default.. diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index 2793cc5734..5ce0219df7 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -316,13 +316,21 @@ void joystick_linux::setup_joystick_properties(int p_id) { } } } -} + joy->force_feedback = false; + joy->ff_effect_timestamp = 0; + unsigned long ffbit[NBITS(FF_CNT)]; + if (ioctl(joy->fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) != -1) { + if (test_bit(FF_RUMBLE, ffbit)) { + joy->force_feedback = true; + } + } +} void joystick_linux::open_joystick(const char *p_path) { int joy_num = get_free_joy_slot(); - int fd = open(p_path, O_RDONLY | O_NONBLOCK); + int fd = open(p_path, O_RDWR | O_NONBLOCK); if (fd != -1 && joy_num != -1) { unsigned long evbit[NBITS(EV_MAX)] = { 0 }; @@ -392,6 +400,55 @@ void joystick_linux::open_joystick(const char *p_path) { } } +void joystick_linux::joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) +{ + Joystick& joy = joysticks[p_id]; + if (!joy.force_feedback || joy.fd == -1 || p_weak_magnitude < 0.f || p_weak_magnitude > 1.f || p_strong_magnitude < 0.f || p_strong_magnitude > 1.f) { + return; + } + if (joy.ff_effect_id != -1) { + joystick_vibration_stop(p_id, p_timestamp); + } + + struct ff_effect effect; + effect.type = FF_RUMBLE; + effect.id = -1; + effect.u.rumble.weak_magnitude = floor(p_weak_magnitude * (float)0xffff); + effect.u.rumble.strong_magnitude = floor(p_strong_magnitude * (float)0xffff); + effect.replay.length = floor(p_duration * 1000); + effect.replay.delay = 0; + + if (ioctl(joy.fd, EVIOCSFF, &effect) < 0) { + return; + } + + struct input_event play; + play.type = EV_FF; + play.code = effect.id; + play.value = 1; + write(joy.fd, (const void*)&play, sizeof(play)); + + joy.ff_effect_id = effect.id; + joy.ff_effect_timestamp = p_timestamp; +} + +void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp) +{ + Joystick& joy = joysticks[p_id]; + if (!joy.force_feedback || joy.fd == -1 || joy.ff_effect_id == -1) { + return; + } + + struct input_event stop; + stop.type = EV_FF; + stop.code = joy.ff_effect_id; + stop.value = 0; + write(joy.fd, (const void*)&stop, sizeof(stop)); + + joy.ff_effect_id = -1; + joy.ff_effect_timestamp = p_timestamp; +} + InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const { int min = p_abs->minimum; @@ -485,6 +542,19 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { if (len == 0 || (len < 0 && errno != EAGAIN)) { close_joystick(i); }; + + if (joy->force_feedback) { + uint64_t timestamp = input->get_joy_vibration_timestamp(i); + if (timestamp > joy->ff_effect_timestamp) { + Vector2 strength = input->get_joy_vibration_strength(i); + float duration = input->get_joy_vibration_duration(i); + if (strength.x == 0 && strength.y == 0) { + joystick_vibration_stop(i, timestamp); + } else { + joystick_vibration_start(i, strength.x, strength.y, duration, timestamp); + } + } + } } joy_mutex->unlock(); return p_event_id; diff --git a/platform/x11/joystick_linux.h b/platform/x11/joystick_linux.h index 4f0533721b..7ea2664ebb 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joystick_linux.h @@ -61,6 +61,10 @@ private: String devpath; input_absinfo *abs_info[MAX_ABS]; + bool force_feedback; + int ff_effect_id; + uint64_t ff_effect_timestamp; + Joystick(); ~Joystick(); void reset(); @@ -88,6 +92,9 @@ private: void run_joystick_thread(); void open_joystick(const char* path); + void joystick_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); + void joystick_vibration_stop(int p_id, uint64_t p_timestamp); + InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const; }; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index b089436a17..1ca779ef7c 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -57,6 +57,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> +#include <dlfcn.h> //stupid linux.h #ifdef KEY_TAB @@ -117,6 +118,37 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi char * modifiers = XSetLocaleModifiers ("@im=none"); ERR_FAIL_COND( modifiers == NULL ); + const char* err; + xrr_get_monitors = NULL; + xrr_free_monitors = NULL; + int xrandr_major = 0; + int xrandr_minor = 0; + int event_base, error_base; + xrandr_ext_ok = XRRQueryExtension(x11_display,&event_base, &error_base); + xrandr_handle = dlopen("libXrandr.so", RTLD_LAZY); + err = dlerror(); + if (!xrandr_handle) { + fprintf(stderr, "could not load libXrandr.so, Error: %s\n", err); + } + else { + XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor); + if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) { + xrr_get_monitors = (xrr_get_monitors_t) dlsym(xrandr_handle, "XRRGetMonitors"); + if (!xrr_get_monitors) { + err = dlerror(); + fprintf(stderr, "could not find symbol XRRGetMonitors\nError: %s\n", err); + } + else { + xrr_free_monitors = (xrr_free_monitors_t) dlsym(xrandr_handle, "XRRFreeMonitors"); + if (!xrr_free_monitors) { + err = dlerror(); + fprintf(stderr, "could not find XRRFreeMonitors\nError: %s\n", err); + xrr_get_monitors = NULL; + } + } + } + } + xim = XOpenIM (x11_display, NULL, NULL, NULL); @@ -480,6 +512,9 @@ void OS_X11::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); + if (xrandr_handle) + dlclose(xrandr_handle); + XUnmapWindow( x11_display, x11_window ); XDestroyWindow( x11_display, x11_window ); @@ -722,6 +757,46 @@ Size2 OS_X11::get_screen_size(int p_screen) const { return size; } +int OS_X11::get_screen_dpi(int p_screen) const { + + //invalid screen? + ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0); + + //Get physical monitor Dimensions through XRandR and calculate dpi + Size2 sc = get_screen_size(p_screen); + if (xrandr_ext_ok) { + int count = 0; + if (xrr_get_monitors) { + xrr_monitor_info *monitors = xrr_get_monitors(x11_display, x11_window, true, &count); + if (p_screen < count) { + double xdpi = sc.width / (double) monitors[p_screen].mwidth * 25.4; + double ydpi = sc.height / (double) monitors[p_screen].mheight * 25.4; + xrr_free_monitors(monitors); + return (xdpi + ydpi) / 2; + } + xrr_free_monitors(monitors); + } + else if (p_screen == 0) { + XRRScreenSize *sizes = XRRSizes(x11_display, 0, &count); + if (sizes) { + double xdpi = sc.width / (double) sizes[0].mwidth * 25.4; + double ydpi = sc.height / (double) sizes[0].mheight * 25.4; + return (xdpi + ydpi) / 2; + } + } + } + + int width_mm = DisplayWidthMM(x11_display, p_screen); + int height_mm = DisplayHeightMM(x11_display, p_screen); + double xdpi = (width_mm ? sc.width / (double) width_mm * 25.4 : 0); + double ydpi = (height_mm ? sc.height / (double) height_mm * 25.4 : 0); + if (xdpi || xdpi) + return (xdpi + ydpi)/(xdpi && ydpi ? 2 : 1); + + //could not get dpi + return 96; +} + Point2 OS_X11::get_window_position() const { int x,y; Window child; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 311f26d4d3..71bbe726dd 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -52,6 +52,7 @@ #include <X11/keysym.h> #include <X11/Xlib.h> #include <X11/Xcursor/Xcursor.h> +#include <X11/extensions/Xrandr.h> // Hints for X11 fullscreen typedef struct { @@ -62,6 +63,20 @@ typedef struct { unsigned long status; } Hints; +typedef struct _xrr_monitor_info { + Atom name; + Bool primary; + Bool automatic; + int noutput; + int x; + int y; + int width; + int height; + int mwidth; + int mheight; + RROutput *outputs; +} xrr_monitor_info; + #undef CursorShape /** @author Juan Linietsky <reduzio@gmail.com> @@ -162,6 +177,12 @@ class OS_X11 : public OS_Unix { //void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); + typedef xrr_monitor_info* (*xrr_get_monitors_t)(Display *dpy, Window window, Bool get_active, int *nmonitors); + typedef void (*xrr_free_monitors_t)(xrr_monitor_info* monitors); + xrr_get_monitors_t xrr_get_monitors; + xrr_free_monitors_t xrr_free_monitors; + void *xrandr_handle; + Bool xrandr_ext_ok; protected: @@ -219,6 +240,7 @@ public: virtual void set_current_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; + virtual int get_screen_dpi(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 17e5503a2d..8864459dfb 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1042,7 +1042,9 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate); ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect); + ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect); //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); + ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item); ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible); @@ -1195,6 +1197,23 @@ int CanvasItem::get_canvas_layer() const { return 0; } + +Rect2 CanvasItem::get_item_and_children_rect() const { + + Rect2 rect = get_item_rect(); + + + for(int i=0;i<get_child_count();i++) { + CanvasItem *c=get_child(i)->cast_to<CanvasItem>(); + if (c) { + Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect()); + rect = rect.merge(sir); + } + } + + return rect; +} + CanvasItem::CanvasItem() : xform_change(this) { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 05a2e725e9..d915f742ec 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -240,6 +240,8 @@ public: virtual Matrix32 get_global_transform() const; virtual Matrix32 get_global_transform_with_canvas() const; + Rect2 get_item_and_children_rect() const; + CanvasItem *get_toplevel() const; _FORCE_INLINE_ RID get_canvas_item() const { return canvas_item; } diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 6a9c655141..920e56130c 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -712,6 +712,15 @@ void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) { Transform lookat; lookat.origin=get_global_transform().origin; + if (lookat.origin==p_target) { + ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed"); + ERR_FAIL(); + } + + if (p_up_normal.cross(p_target-lookat.origin)==Vector3()) { + ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed"); + ERR_FAIL(); + } lookat=lookat.looking_at(p_target,p_up_normal); set_global_transform(lookat); } 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/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 211c5961b0..0f7ed1cb29 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -669,7 +669,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode } tsn->seek_pos=-1; - return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek); + return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek, p_filter, p_reverse_weight); } break; case NODE_TRANSITION: { 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..666ac88055 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); @@ -436,11 +437,17 @@ void Control::_notification(int p_notification) { if (is_set_as_toplevel()) { data.SI=get_viewport()->_gui_add_subwindow_control(this); + + if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { + data.theme_owner=data.parent->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } + } else { Node *parent=this; //meh - Node *parent_control=NULL; + Control *parent_control=NULL; bool subwindow=false; while(parent) { @@ -456,8 +463,9 @@ void Control::_notification(int p_notification) { break; } - if (parent->cast_to<Control>()) { - parent_control=parent->cast_to<Control>(); + parent_control=parent->cast_to<Control>(); + + if (parent_control) { break; } else if (ci) { @@ -469,6 +477,10 @@ void Control::_notification(int p_notification) { if (parent_control) { //do nothing, has a parent control + if (data.theme.is_null() && parent_control->data.theme_owner) { + data.theme_owner=parent_control->data.theme_owner; + notification(NOTIFICATION_THEME_CHANGED); + } } else if (subwindow) { //is a subwindow (process input before other controls for that canvas) data.SI=get_viewport()->_gui_add_subwindow_control(this); @@ -489,6 +501,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 +536,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 +784,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 +814,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 +842,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 +872,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 +902,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 +931,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) @@ -1840,18 +1840,29 @@ void Control::_modal_stack_remove() { } -void Control::_propagate_theme_changed(Control *p_owner) { +void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) { - for(int i=0;i<get_child_count();i++) { + Control *c = p_at->cast_to<Control>(); + + if (c && c!=p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated + return; + + for(int i=0;i<p_at->get_child_count();i++) { + + CanvasItem *child = p_at->get_child(i)->cast_to<CanvasItem>(); + if (child) { + _propagate_theme_changed(child,p_owner); + } - Control *child = get_child(i)->cast_to<Control>(); - if (child && child->data.theme.is_null()) //has no theme, propagate - child->_propagate_theme_changed(p_owner); } - data.theme_owner=p_owner; - _notification(NOTIFICATION_THEME_CHANGED); - update(); + + if (c) { + + c->data.theme_owner=p_owner; + c->_notification(NOTIFICATION_THEME_CHANGED); + c->update(); + } } void Control::set_theme(const Ref<Theme>& p_theme) { @@ -1860,15 +1871,15 @@ void Control::set_theme(const Ref<Theme>& p_theme) { data.theme=p_theme; if (!p_theme.is_null()) { - _propagate_theme_changed(this); + _propagate_theme_changed(this,this); } else { Control *parent = get_parent()?get_parent()->cast_to<Control>():NULL; if (parent && parent->data.theme_owner) { - _propagate_theme_changed(parent->data.theme_owner); + _propagate_theme_changed(this,parent->data.theme_owner); } else { - _propagate_theme_changed(NULL); + _propagate_theme_changed(this,NULL); } } diff --git a/scene/gui/control.h b/scene/gui/control.h index 59704ae29b..69ee41f180 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -169,7 +169,7 @@ private: float _get_range(int p_idx) const; float _s2a(float p_val, AnchorType p_anchor,float p_range) const; float _a2s(float p_val, AnchorType p_anchor,float p_range) const; - void _propagate_theme_changed(Control *p_owner); + void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner); void _change_notify_margins(); void _update_minimum_size(); 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/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 98bc0b9434..786ce27a0c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -278,6 +278,11 @@ if (m_height > line_height) {\ if (c[end]=='\t') { cw=tab_size*font->get_char_size(' ').width; } + + if (end>0 && w+cw+begin > p_width ) { + break; //don't allow lines longer than assigned width + } + w+=cw; if (c[end]==' ') { @@ -340,10 +345,12 @@ if (m_height > line_height) {\ int cw=font->get_char_size(c[i],c[i+1]).x; + if (c[i]=='\t') { cw=tab_size*font->get_char_size(' ').width; } + if (p_click_pos.x-cw/2>p_ofs.x+align_ofs+pofs) { rchar=int((&c[i])-cf); @@ -374,6 +381,8 @@ if (m_height > line_height) {\ int cw=0; bool visible = visible_characters<0 || p_char_count<visible_characters; + if (c[i]=='\t') + visible=false; if (selected) { 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..49d7527786 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(); } @@ -3825,12 +3825,16 @@ void TextEdit::undo() { _do_text_op(op, true); current_op.version=op.prev_version; if(undo_stack_pos->get().chain_backward) { - do { + while(true) { + ERR_BREAK(!undo_stack_pos->prev()); undo_stack_pos = undo_stack_pos->prev(); op = undo_stack_pos->get(); _do_text_op(op, true); current_op.version = op.prev_version; - } while(!undo_stack_pos->get().chain_forward); + if (undo_stack_pos->get().chain_forward) { + break; + } + } } cursor_set_line(undo_stack_pos->get().from_line); @@ -3849,12 +3853,16 @@ void TextEdit::redo() { _do_text_op(op, false); current_op.version = op.version; if(undo_stack_pos->get().chain_forward) { - do { + + while(true) { + ERR_BREAK(!undo_stack_pos->next()); undo_stack_pos=undo_stack_pos->next(); op = undo_stack_pos->get(); _do_text_op(op, false); current_op.version = op.version; - } while(!undo_stack_pos->get().chain_backward); + if (undo_stack_pos->get().chain_backward) + break; + } } cursor_set_line(undo_stack_pos->get().to_line); cursor_set_column(undo_stack_pos->get().to_column); 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/texture_frame.cpp b/scene/gui/texture_frame.cpp index 2fe8735fda..143f0e83b8 100644 --- a/scene/gui/texture_frame.cpp +++ b/scene/gui/texture_frame.cpp @@ -60,6 +60,29 @@ void TextureFrame::_notification(int p_what) { Vector2 ofs = (get_size() - texture->get_size())/2; draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false,modulate); } break; + case STRETCH_KEEP_ASPECT_CENTERED: + case STRETCH_KEEP_ASPECT: { + + Size2 size=get_size(); + int tex_width = texture->get_width() * size.height / texture ->get_height(); + int tex_height = size.height; + + if (tex_width>size.width) { + tex_width=size.width; + tex_height=texture->get_height() * tex_width / texture->get_width(); + } + + int ofs_x = 0; + int ofs_y = 0; + + if (stretch_mode==STRETCH_KEEP_ASPECT_CENTERED) { + ofs_x+=(size.width - tex_width)/2; + ofs_y+=(size.height - tex_height)/2; + } + + draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height)); + } break; + } @@ -104,13 +127,16 @@ void TextureFrame::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); - ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") ); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") ); BIND_CONSTANT( STRETCH_SCALE_ON_EXPAND ); BIND_CONSTANT( STRETCH_SCALE ); BIND_CONSTANT( STRETCH_TILE ); BIND_CONSTANT( STRETCH_KEEP ); BIND_CONSTANT( STRETCH_KEEP_CENTERED ); + BIND_CONSTANT( STRETCH_KEEP_ASPECT ); + BIND_CONSTANT( STRETCH_KEEP_ASPECT_CENTERED ); + } diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_frame.h index a4acf588ea..0b47202532 100644 --- a/scene/gui/texture_frame.h +++ b/scene/gui/texture_frame.h @@ -43,6 +43,9 @@ public: STRETCH_TILE, STRETCH_KEEP, STRETCH_KEEP_CENTERED, + STRETCH_KEEP_ASPECT, + STRETCH_KEEP_ASPECT_CENTERED, + }; private: bool expand; 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/main/node.cpp b/scene/main/node.cpp index f8af83e23b..50b0fe224e 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -283,7 +283,11 @@ void Node::move_child(Node *p_child,int p_pos) { ERR_FAIL_INDEX( p_pos, data.children.size()+1 ); ERR_EXPLAIN("child is not a child of this node."); ERR_FAIL_COND(p_child->data.parent!=this); - ERR_FAIL_COND(data.blocked>0); + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, move_child() failed. Consider using call_deferred(\"move_child\") instead (or \"popup\" if this is from a popup)."); + ERR_FAIL_COND(data.blocked>0); + } + data.children.remove( p_child->data.pos ); data.children.insert( p_pos, p_child ); @@ -739,6 +743,12 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) { } ERR_EXPLAIN("Can't add child, already has a parent"); ERR_FAIL_COND( p_child->data.parent ); + + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead."); + ERR_FAIL_COND(data.blocked>0); + } + ERR_EXPLAIN("Can't add child while a notification is happening"); ERR_FAIL_COND( data.blocked > 0 ); @@ -800,7 +810,10 @@ void Node::_propagate_validate_owner() { void Node::remove_child(Node *p_child) { ERR_FAIL_NULL(p_child); - ERR_FAIL_COND( data.blocked > 0 ); + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\",child) instead."); + ERR_FAIL_COND(data.blocked>0); + } int idx=-1; for (int i=0;i<data.children.size();i++) { @@ -1770,6 +1783,8 @@ void Node::replace_by(Node* p_node,bool p_keep_data) { } } + _replace_connections_target(p_node); + if (data.owner) { for(int i=0;i<get_child_count();i++) find_owned_by(data.owner,get_child(i),&owned_by_owner); @@ -1808,6 +1823,20 @@ void Node::replace_by(Node* p_node,bool p_keep_data) { } +void Node::_replace_connections_target(Node* p_new_target) { + + List<Connection> cl; + get_signals_connected_to_this(&cl); + + for(List<Connection>::Element *E=cl.front();E;E=E->next()) { + + Connection &c=E->get(); + + c.source->disconnect(c.signal,this,c.method); + c.source->connect(c.signal,p_new_target,c.method,c.binds,c.flags); + } +} + Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) { diff --git a/scene/main/node.h b/scene/main/node.h index d099f6e773..a3b8d8de81 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -121,7 +121,7 @@ private: Node *_get_node(const NodePath& p_path) const; Node *_get_child_by_name(const StringName& p_name) const; - + void _replace_connections_target(Node* p_new_target); void _validate_child_name(Node *p_name, bool p_force_human_readable=false); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index aef53ea230..79502c74ce 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -500,7 +500,7 @@ void Viewport::_notification(int p_what) { - if (physics_object_picking) { + if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) { Vector2 last_pos(1e20,1e20); CollisionObject *last_object; diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 78a5571bf0..1edae01754 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -573,7 +573,11 @@ DynamicFontAtSize::~DynamicFontAtSize(){ void DynamicFont::set_font_data(const Ref<DynamicFontData>& p_data) { data=p_data; - data_at_size=data->_get_dynamic_font_at_size(size); + if (data.is_valid()) + data_at_size=data->_get_dynamic_font_at_size(size); + else + data_at_size=Ref<DynamicFontAtSize>(); + emit_changed(); } 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/servers/visual_server.cpp b/servers/visual_server.cpp index 570a5a6ee4..fafc09f554 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -560,7 +560,7 @@ void VisualServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("draw"),&VisualServer::draw); ObjectTypeDB::bind_method(_MD("sync"),&VisualServer::sync); - ObjectTypeDB::bind_method(_MD("free"),&VisualServer::free); + ObjectTypeDB::bind_method(_MD("free_rid"),&VisualServer::free); ObjectTypeDB::bind_method(_MD("set_default_clear_color"),&VisualServer::set_default_clear_color); diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp index 928acdbcbb..c571310ded 100644 --- a/tools/editor/asset_library_editor_plugin.cpp +++ b/tools/editor/asset_library_editor_plugin.cpp @@ -541,8 +541,12 @@ void EditorAssetLibrary::_notification(int p_what) { error_hb->add_child(tf); error_label->raise(); + } - _repository_changed(0); + if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if(!is_hidden()) { + _repository_changed(0); // Update when shown for the first time + } } if (p_what==NOTIFICATION_PROCESS) { diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index f62209fafa..be5d9c47ff 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -247,8 +247,18 @@ void FindReplaceBar::_get_search_from(int& r_line, int& r_col) { r_col=text_edit->cursor_get_column(); if (text_edit->is_selection_active() && !replace_all_mode) { - r_line=text_edit->get_selection_from_line(); - r_col=text_edit->get_selection_to_column(); + + int selection_line=text_edit->get_selection_from_line(); + + if (text_edit->get_selection_text()==get_search_text() && r_line==selection_line) { + + int selection_from_col=text_edit->get_selection_from_column(); + + if (r_col>=selection_from_col && r_col<=text_edit->get_selection_to_column()) { + r_col=selection_line; + r_col=selection_from_col; + } + } } if (r_line==result_line && r_col>=result_col && r_col<=result_col+get_search_text().length()) { @@ -521,6 +531,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..8847654ad7 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -35,6 +35,7 @@ #include "print_string.h" #include "editor_settings.h" #include "editor_node.h" +#include "plugins/script_editor_plugin.h" class ConnectDialogBinds : public Object { @@ -294,47 +295,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 +343,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 +525,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); @@ -808,11 +767,58 @@ void ConnectionsDock::_something_selected() { } +void ConnectionsDock::_something_activated() { + + TreeItem *item = tree->get_selected(); + + if (!item) + return; + + if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) { + // a signal - connect + String signal=item->get_metadata(0).operator Dictionary()["name"]; + String midname=node->get_name(); + for(int i=0;i<midname.length();i++) { + CharType c = midname[i]; + if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') { + //all good + } else if (c==' ') { + c='_'; + } else { + midname.remove(i); + i--; + continue; + } + + midname[i]=c; + } + + connect_dialog->edit(node); + connect_dialog->popup_centered_ratio(); + connect_dialog->set_dst_method("_on_"+midname+"_"+signal); + connect_dialog->set_dst_node(node->get_owner()?node->get_owner():node); + } else { + // a slot - go to target method + Connection c=item->get_metadata(0); + ERR_FAIL_COND(c.source!=node); //shouldn't happen but...bugcheck + + if (!c.target) + return; + + Ref<Script> script = c.target->get_script(); + + if (script.is_valid() && ScriptEditor::get_singleton()->script_go_to_method(script,c.method)) { + editor->call("_editor_select",EditorNode::EDITOR_SCRIPT); + } + } +} + void ConnectionsDock::_bind_methods() { ObjectTypeDB::bind_method("_connect",&ConnectionsDock::_connect); ObjectTypeDB::bind_method("_something_selected",&ConnectionsDock::_something_selected); + ObjectTypeDB::bind_method("_something_activated",&ConnectionsDock::_something_activated); ObjectTypeDB::bind_method("_close",&ConnectionsDock::_close); ObjectTypeDB::bind_method("_connect_pressed",&ConnectionsDock::_connect_pressed); ObjectTypeDB::bind_method("update_tree",&ConnectionsDock::update_tree); @@ -865,6 +871,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { remove_confirm->connect("confirmed", this,"_remove_confirm"); connect_dialog->connect("connected", this,"_connect"); tree->connect("item_selected", this,"_something_selected"); + tree->connect("item_activated", this,"_something_activated"); add_constant_override("separation",3*EDSCALE); } diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h index 96ebaf85b0..73f52abc9e 100644 --- a/tools/editor/connections_dialog.h +++ b/tools/editor/connections_dialog.h @@ -111,6 +111,7 @@ class ConnectionsDock : public VBoxContainer { void _close(); void _connect(); void _something_selected(); + void _something_activated(); UndoRedo *undo_redo; protected: 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..4ab5dddef6 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() { @@ -2496,6 +2503,51 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) { } } +bool ScriptEditor::script_go_to_method(Ref<Script> p_script, const String& p_method) { + + Vector<String> functions; + bool found=false; + + for (int i=0;i<tab_container->get_child_count();i++) { + ScriptTextEditor *current = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); + + if (current && current->get_edited_script()==p_script) { + functions=current->get_functions(); + found=true; + break; + } + } + + if (!found) { + String errortxt; + int line=-1,col; + String text=p_script->get_source_code(); + List<String> fnc; + + if (p_script->get_language()->validate(text,line,col,errortxt,p_script->get_path(),&fnc)) { + + for (List<String>::Element *E=fnc.front();E;E=E->next()) + functions.push_back(E->get()); + } + } + + String method_search = p_method + ":"; + + for (int i=0;i<functions.size();i++) { + String function=functions[i]; + + if (function.begins_with(method_search)) { + + edit(p_script); + int line=function.get_slice(":",1).to_int(); + _goto_script_line2(line-1); + return true; + } + } + + return false; +} + void ScriptEditor::set_live_auto_reload_running_scripts(bool p_enabled) { auto_reload_running_scripts=p_enabled; @@ -2614,8 +2666,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 +2970,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 +2982,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/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 5a9dce759e..3d723adfe9 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -325,6 +325,8 @@ public: void set_scene_root_script( Ref<Script> p_script ); + bool script_go_to_method(Ref<Script> p_script, const String& p_method); + virtual void edited_scene_changed(); ScriptEditorDebugger *get_debugger() { return debugger; } diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index e261b48f67..fdb654571a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -996,26 +996,26 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { case TRANSFORM_VIEW: { _edit.plane=TRANSFORM_X_AXIS; - set_message(TTR("View Plane Transform."),2); + set_message(TTR("X-Axis Transform."),2); name=""; _update_name(); } break; case TRANSFORM_X_AXIS: { _edit.plane=TRANSFORM_Y_AXIS; - set_message(TTR("X-Axis Transform."),2); + set_message(TTR("Y-Axis Transform."),2); } break; case TRANSFORM_Y_AXIS: { _edit.plane=TRANSFORM_Z_AXIS; - set_message(TTR("Y-Axis Transform."),2); + set_message(TTR("Z-Axis Transform."),2); } break; case TRANSFORM_Z_AXIS: { _edit.plane=TRANSFORM_VIEW; - set_message(TTR("Z-Axis Transform."),2); + set_message(TTR("View Plane Transform."),2); } break; } 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/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index b69b0d7a9b..57db19b736 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -43,6 +43,8 @@ void TextureRegionEditor::_region_draw() base_tex = node_patch9->get_texture(); else if(node_type == "StyleBoxTexture" && obj_styleBox) base_tex = obj_styleBox->get_texture(); + else if(node_type == "AtlasTexture" && atlas_tex) + base_tex = atlas_tex->get_atlas(); if (base_tex.is_null()) return; @@ -164,6 +166,8 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input) drag=true; if(node_type == "Sprite" && node_sprite ) rect_prev=node_sprite->get_region_rect(); + else if(node_type == "AtlasTexture" && atlas_tex) + rect_prev=atlas_tex->get_region(); else if(node_type == "Patch9Frame" && node_patch9) rect_prev=node_patch9->get_region_rect(); else if(node_type == "StyleBoxTexture" && obj_styleBox) @@ -191,10 +195,18 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input) undo_redo->add_do_method(node_sprite ,"set_region_rect",node_sprite->get_region_rect()); undo_redo->add_undo_method(node_sprite,"set_region_rect",rect_prev); } + else if(node_type == "AtlasTexture" && atlas_tex ){ + undo_redo->add_do_method(atlas_tex ,"set_region",atlas_tex->get_region()); + undo_redo->add_undo_method(atlas_tex,"set_region",rect_prev); + } else if(node_type == "Patch9Frame" && node_patch9){ undo_redo->add_do_method(node_patch9 ,"set_region_rect",node_patch9->get_region_rect()); undo_redo->add_undo_method(node_patch9,"set_region_rect",rect_prev); } + else if(node_type == "StyleBoxTexture" && obj_styleBox){ + undo_redo->add_do_method(obj_styleBox ,"set_region_rect",obj_styleBox->get_region_rect()); + undo_redo->add_undo_method(obj_styleBox,"set_region_rect",rect_prev); + } undo_redo->add_do_method(edit_draw,"update"); undo_redo->add_undo_method(edit_draw,"update"); undo_redo->commit_action(); @@ -355,6 +367,8 @@ void TextureRegionEditor::apply_rect(const Rect2& rect){ node_patch9->set_region_rect(rect); else if(obj_styleBox) obj_styleBox->set_region_rect(rect); + else if(atlas_tex) + atlas_tex->set_region(rect); } else if(this->editing_region == REGION_PATCH_MARGIN) { if(node_patch9) { @@ -387,10 +401,11 @@ void TextureRegionEditor::_notification(int p_what) void TextureRegionEditor::_node_removed(Object *p_obj) { - if(p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox) { - node_patch9 = NULL; - node_sprite = NULL; + if(p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox || p_obj == atlas_tex) { + node_patch9 = NULL; + node_sprite = NULL; obj_styleBox = NULL; + atlas_tex = NULL; hide(); } } @@ -421,30 +436,42 @@ void TextureRegionEditor::edit(Object *p_obj) node_sprite = p_obj->cast_to<Sprite>(); node_patch9 = NULL; obj_styleBox = NULL; + atlas_tex = NULL; + } + else if(node_type == "AtlasTexture") { + atlas_tex = p_obj->cast_to<AtlasTexture>(); + node_sprite = NULL; + node_patch9 = NULL; + obj_styleBox = NULL; } else if(node_type == "Patch9Frame") { node_patch9 = p_obj->cast_to<Patch9Frame>(); node_sprite = NULL; obj_styleBox = NULL; + atlas_tex = NULL; margin_button->show(); } else if(node_type == "StyleBoxTexture") { obj_styleBox = p_obj->cast_to<StyleBoxTexture>(); node_sprite = NULL; node_patch9 = NULL; + atlas_tex = NULL; margin_button->show(); } p_obj->connect("exit_tree",this,"_node_removed",varray(p_obj),CONNECT_ONESHOT); } else { if(node_sprite) node_sprite->disconnect("exit_tree",this,"_node_removed"); + else if(atlas_tex) + atlas_tex->disconnect("exit_tree",this,"_node_removed"); else if(node_patch9) node_patch9->disconnect("exit_tree",this,"_node_removed"); else if(obj_styleBox) obj_styleBox->disconnect("exit_tree",this,"_node_removed"); - node_sprite = NULL; - node_patch9 = NULL; + node_sprite = NULL; + node_patch9 = NULL; obj_styleBox = NULL; + atlas_tex = NULL; } } @@ -469,6 +496,8 @@ void TextureRegionEditor::_edit_node(int region) texture = node_patch9->get_texture(); else if(node_type == "StyleBoxTexture" && obj_styleBox) texture = obj_styleBox->get_texture(); + else if(node_type == "AtlasTexture" && atlas_tex) + texture = atlas_tex->get_atlas(); if (texture.is_null()) { error->set_text(TTR("No texture in this node.\nSet a texture to be able to edit region.")); @@ -482,6 +511,8 @@ void TextureRegionEditor::_edit_node(int region) tex_region = node_patch9->get_region_rect(); else if(node_type == "StyleBoxTexture" && obj_styleBox) tex_region = obj_styleBox->get_region_rect(); + else if(node_type == "AtlasTexture" && atlas_tex) + tex_region = atlas_tex->get_region(); rect = tex_region; if(region == REGION_PATCH_MARGIN) { @@ -521,6 +552,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor) { node_sprite = NULL; node_patch9 = NULL; + atlas_tex = NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); @@ -661,7 +693,7 @@ void TextureRegionEditorPlugin::edit(Object *p_node) bool TextureRegionEditorPlugin::handles(Object *p_obj) const { - return p_obj->is_type("Sprite") || p_obj->is_type("Patch9Frame") || p_obj->is_type("StyleBoxTexture"); + return p_obj->is_type("Sprite") || p_obj->is_type("Patch9Frame") || p_obj->is_type("StyleBoxTexture") || p_obj->is_type("AtlasTexture"); } void TextureRegionEditorPlugin::make_visible(bool p_visible) diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h index 951b11e1e6..1e4888b06d 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.h +++ b/tools/editor/plugins/texture_region_editor_plugin.h @@ -38,6 +38,7 @@ #include "scene/2d/sprite.h" #include "scene/gui/patch_9_frame.h" #include "scene/resources/style_box.h" +#include "scene/resources/texture.h" class TextureRegionEditor : public HBoxContainer { @@ -82,6 +83,7 @@ class TextureRegionEditor : public HBoxContainer { Patch9Frame *node_patch9; Sprite *node_sprite; StyleBoxTexture *obj_styleBox; + AtlasTexture *atlas_tex; int editing_region; Rect2 rect; 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 ); diff --git a/tools/translations/ru.po b/tools/translations/ru.po index aa98be2767..138aa2c858 100644 --- a/tools/translations/ru.po +++ b/tools/translations/ru.po @@ -26,7 +26,7 @@ msgid "" "order for AnimatedSprite to display frames." msgstr "" "Чтобы AnimatedSprite отображал кадры, пожалуйста установите или создайте " -"ресурс SpriteFrames в параметре 'Frames'" +"ресурс SpriteFrames в параметре 'Frames'." #: scene/2d/canvas_modulate.cpp msgid "" @@ -218,13 +218,12 @@ msgstr "" "ресурс SampleLibrary в параметре 'samples'." #: scene/3d/sprite_3d.cpp -#, fuzzy msgid "" "A SpriteFrames resource must be created or set in the 'Frames' property in " "order for AnimatedSprite3D to display frames." msgstr "" -"Чтобы AnimatedSprite отображал кадры, пожалуйста установите или создайте " -"ресурс SpriteFrames в параметре 'Frames'" +"Чтобы AnimatedSprite3D отображал кадры, пожалуйста установите или создайте " +"ресурс SpriteFrames в параметре 'Frames'." #: scene/gui/dialogs.cpp tools/editor/io_plugins/editor_scene_import_plugin.cpp msgid "Cancel" @@ -262,24 +261,20 @@ msgid "Open" msgstr "Открыть" #: scene/gui/file_dialog.cpp -#, fuzzy msgid "Open a File" -msgstr "Открыть сэмпл(ы)" +msgstr "Открыть файл" #: scene/gui/file_dialog.cpp -#, fuzzy msgid "Open File(s)" -msgstr "Открыть сэмпл(ы)" +msgstr "Открыть файл(ы)" #: scene/gui/file_dialog.cpp -#, fuzzy msgid "Open a Directory" -msgstr "Выбрать каталог" +msgstr "Открыть каталог" #: scene/gui/file_dialog.cpp -#, fuzzy msgid "Open a File or Directory" -msgstr "Выбрать каталог" +msgstr "Открыть каталог или файл" #: scene/gui/file_dialog.cpp tools/editor/editor_file_dialog.cpp #: tools/editor/editor_node.cpp @@ -343,7 +338,7 @@ msgstr "Alt+" #: scene/gui/input_action.cpp msgid "Ctrl+" -msgstr "" +msgstr "Ctrl+" #: scene/gui/input_action.cpp tools/editor/project_settings.cpp #: tools/editor/settings_config_dialog.cpp @@ -715,7 +710,7 @@ msgstr "Включить индивидуальное редактировани #: tools/editor/animation_editor.cpp msgid "Anim. Optimizer" -msgstr "Оптимизатор анимации." +msgstr "Оптимизатор анимации" #: tools/editor/animation_editor.cpp msgid "Max. Linear Error:" @@ -810,22 +805,20 @@ msgid "Site:" msgstr "Сайт:" #: tools/editor/asset_library_editor_plugin.cpp -#, fuzzy msgid "Support.." -msgstr "Экспортировать.." +msgstr "Поддержка.." #: tools/editor/asset_library_editor_plugin.cpp msgid "Official" -msgstr "" +msgstr "Официально" #: tools/editor/asset_library_editor_plugin.cpp msgid "Community" -msgstr "" +msgstr "Сообщество" #: tools/editor/asset_library_editor_plugin.cpp -#, fuzzy msgid "Testing" -msgstr "Настройки" +msgstr "Тестируемые" #: tools/editor/asset_library_editor_plugin.cpp msgid "Assets ZIP File" @@ -1018,9 +1011,8 @@ msgid "Disconnect" msgstr "Отсоединить" #: tools/editor/connections_dialog.cpp tools/editor/node_dock.cpp -#, fuzzy msgid "Signals" -msgstr "Сигналы:" +msgstr "Сигналы" #: tools/editor/create_dialog.cpp msgid "Create New" @@ -1245,7 +1237,7 @@ msgstr "Описание методов:" #: tools/editor/editor_help.cpp msgid "Search Text" -msgstr "Искать текст:" +msgstr "Искать текст" #: tools/editor/editor_import_export.cpp msgid "Added:" @@ -1280,9 +1272,8 @@ msgid "Setting Up.." msgstr "Настройка.." #: tools/editor/editor_log.cpp -#, fuzzy msgid " Output:" -msgstr "Вывод" +msgstr " Вывод:" #: tools/editor/editor_node.cpp tools/editor/editor_reimport_dialog.cpp msgid "Re-Importing" @@ -1396,9 +1387,8 @@ msgid "Copy Params" msgstr "Копировать параметры" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Paste Params" -msgstr "Вставить кадр" +msgstr "Вставить параметры" #: tools/editor/editor_node.cpp #: tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -1418,9 +1408,8 @@ msgid "Make Sub-Resources Unique" msgstr "Сделать вложенные ресурсы уникальными" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Open in Help" -msgstr "Открыть сцену" +msgstr "Открыть в справке" #: tools/editor/editor_node.cpp msgid "There is no defined scene to run." @@ -1431,6 +1420,9 @@ msgid "" "No main scene has ever been defined.\n" "Select one from \"Project Settings\" under the 'application' category." msgstr "" +"Не назначена главная сцена.\n" +"Укажите её в параметре \"main_scene\" расположенном\n" +"в \"Настройки проекта - Основное - application\"." #: tools/editor/editor_node.cpp msgid "Current scene was never saved, please save it prior to running." @@ -1550,9 +1542,8 @@ msgid "Save Layout" msgstr "Сохранить макет" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Load Layout" -msgstr "Сохранить макет" +msgstr "Загрузить макет" #: tools/editor/editor_node.cpp tools/editor/project_export.cpp msgid "Default" @@ -1616,9 +1607,8 @@ msgid "Open Recent" msgstr "Открыть последнее" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Quick Filter Files.." -msgstr "Быстрый поиск файлов.." +msgstr "Быстро отсортировать файлы.." #: tools/editor/editor_node.cpp msgid "Convert To.." @@ -1690,9 +1680,8 @@ msgid "Export" msgstr "Экспорт" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Play the project." -msgstr "Запустить проект (F5)." +msgstr "Запустить проект." #: tools/editor/editor_node.cpp #: tools/editor/plugins/sample_library_editor_plugin.cpp @@ -1704,14 +1693,12 @@ msgid "Pause the scene" msgstr "Приостановить сцену" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Pause Scene" msgstr "Приостановить сцену" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Stop the scene." -msgstr "Остановить проект (F8)." +msgstr "Остановить сцену." #: tools/editor/editor_node.cpp #: tools/editor/plugins/sample_library_editor_plugin.cpp @@ -1719,14 +1706,12 @@ msgid "Stop" msgstr "Остановить" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Play the edited scene." -msgstr "Запустить текущую сцену (F6)." +msgstr "Запустить текущую сцену." #: tools/editor/editor_node.cpp -#, fuzzy msgid "Play Scene" -msgstr "Сохранить сцену" +msgstr "Запустить сцену" #: tools/editor/editor_node.cpp msgid "Play custom scene" @@ -1737,19 +1722,20 @@ msgid "Debug options" msgstr "Параметры отладки" #: tools/editor/editor_node.cpp -#, fuzzy msgid "Deploy with Remote Debug" -msgstr "Развернуть удалённую отладку" +msgstr "Развернуть с удалённой отладкой" #: tools/editor/editor_node.cpp msgid "" "When exporting or deploying, the resulting executable will attempt to connect " "to the IP of this computer in order to be debugged." msgstr "" +"При экспорте или развёртывании, полученный исполняемый файл будет пытаться " +"подключиться к IP этого компьютера с целью отладки." #: tools/editor/editor_node.cpp msgid "Small Deploy with Network FS" -msgstr "" +msgstr "Небольшое развёртывание через сеть" #: tools/editor/editor_node.cpp msgid "" @@ -1760,6 +1746,11 @@ msgid "" "On Android, deploy will use the USB cable for faster performance. This option " "speeds up testing for games with a large footprint." msgstr "" +"Когда эта опция включена, экспорт или развёртывание будет создавать " +"минимальный исполняемый файл.\n" +"Файловая система проекта будет предоставляться редактором через сеть.\n" +"На Android развёртывание будет быстрее при подключении через USB.\n" +"Эта опция ускоряет тестирование больших проектов." #: tools/editor/editor_node.cpp msgid "Visible Collision Shapes" @@ -1770,6 +1761,8 @@ msgid "" "Collision shapes and raycast nodes (for 2D and 3D) will be visible on the " "running game if this option is turned on." msgstr "" +"Когда эта опция включена, области соприкосновений и ноды Raycast(в 2D и 3D) " +"будут видимыми в запущенной игре." #: tools/editor/editor_node.cpp msgid "Visible Navigation" @@ -1780,10 +1773,12 @@ msgid "" "Navigation meshes and polygons will be visible on the running game if this " "option is turned on." msgstr "" +"Когда эта опция включена, навигационные полисетки и полигоны будут видимыми " +"в запущенной игре." #: tools/editor/editor_node.cpp msgid "Sync Scene Changes" -msgstr "" +msgstr "Синхронизация изменений на сцене" #: tools/editor/editor_node.cpp msgid "" @@ -1792,11 +1787,14 @@ msgid "" "When used remotely on a device, this is more efficient with network " "filesystem." msgstr "" +"Когда эта опция включена, все изменения, внесённые на сцену, в редакторе " +"будут перенесены в запущенную игру.\n" +"При удалённом использовании на устройстве, это работает более эффективно с " +"сетевой файловой системой." #: tools/editor/editor_node.cpp -#, fuzzy msgid "Sync Script Changes" -msgstr "Обновлять при изменениях" +msgstr "Синхронизация изменений в скриптах" #: tools/editor/editor_node.cpp msgid "" @@ -1805,6 +1803,10 @@ msgid "" "When used remotely on a device, this is more efficient with network " "filesystem." msgstr "" +"Когда эта опция включена, любой сохранённый скрипт будет перезагружен в " +"запущенную игру.\n" +"При удалённом использовании на устройстве, это работает более эффективно с " +"сетевой файловой системой." #: tools/editor/editor_node.cpp tools/editor/plugins/spatial_editor_plugin.cpp msgid "Settings" @@ -2068,9 +2070,8 @@ msgid "Imported Resources" msgstr "Импортированные ресурсы" #: tools/editor/io_plugins/editor_bitmask_import_plugin.cpp -#, fuzzy msgid "No bit masks to import!" -msgstr "Нет элементов для импорта!" +msgstr "Нет битовой маски для импорта!" #: tools/editor/io_plugins/editor_bitmask_import_plugin.cpp #: tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -2100,9 +2101,8 @@ msgid "Save path is empty!" msgstr "Путь сохранения пуст!" #: tools/editor/io_plugins/editor_bitmask_import_plugin.cpp -#, fuzzy msgid "Import BitMasks" -msgstr "Импорт текстур" +msgstr "Импорт битовой маски" #: tools/editor/io_plugins/editor_bitmask_import_plugin.cpp #: tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -2129,7 +2129,7 @@ msgstr "Принять" #: tools/editor/io_plugins/editor_bitmask_import_plugin.cpp msgid "Bit Mask" -msgstr "" +msgstr "Битовая маска" #: tools/editor/io_plugins/editor_font_import_plugin.cpp msgid "No source font file!" @@ -2164,7 +2164,7 @@ msgid "The quick brown fox jumps over the lazy dog." msgstr "" "Съешь ещё этих мягких французских булок да выпей чаю. \n" "The quick brown fox jumps over the lazy dog.\n" -"0123456789`!@#$%^&*()_+-=\\/" +"0123456789`!@#$%^&*()_+-=\\/." #: tools/editor/io_plugins/editor_font_import_plugin.cpp msgid "Test:" @@ -2646,18 +2646,18 @@ msgid "MultiNode Set" msgstr "Мульти нодовый набор" #: tools/editor/node_dock.cpp -#, fuzzy msgid "Node" -msgstr "Mix Node" +msgstr "Нод" #: tools/editor/node_dock.cpp -#, fuzzy msgid "Groups" -msgstr "Группы:" +msgstr "Группы" #: tools/editor/node_dock.cpp msgid "Select a Node to edit Signals and Groups." msgstr "" +"Выберите нод для редактирования\n" +"сигналов и групп." #: tools/editor/plugins/animation_player_editor_plugin.cpp msgid "Toggle Autoplay" @@ -2774,7 +2774,7 @@ msgstr "Загрузить анимацию с диска." #: tools/editor/plugins/animation_player_editor_plugin.cpp msgid "Save the current animation" -msgstr "Сохранить текущую анимацию." +msgstr "Сохранить текущую анимацию" #: tools/editor/plugins/animation_player_editor_plugin.cpp msgid "Display list of animations in player." @@ -2925,39 +2925,39 @@ msgstr "Дерево анимации не действительно." #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Animation Node" -msgstr "Animation Node" +msgstr "Animation нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "OneShot Node" -msgstr "OneShot Node" +msgstr "OneShot нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Mix Node" -msgstr "Mix Node" +msgstr "Mix нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Blend2 Node" -msgstr "Blend2 Node" +msgstr "Blend2 нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Blend3 Node" -msgstr "Blend3 Node" +msgstr "Blend3 нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Blend4 Node" -msgstr "Blend4 Node" +msgstr "Blend4 нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "TimeScale Node" -msgstr "TimeScale Node" +msgstr "TimeScale нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "TimeSeek Node" -msgstr "TimeSeek Node" +msgstr "TimeSeek нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Transition Node" -msgstr "Transition Node" +msgstr "Transition нод" #: tools/editor/plugins/animation_tree_editor_plugin.cpp msgid "Import Animations.." @@ -3971,14 +3971,12 @@ msgid "Auto Indent" msgstr "Автоотступ" #: tools/editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Reload Tool Script" -msgstr "Перезагрузить скрипты" +msgstr "Перезагрузить инструм. скрипт" #: tools/editor/plugins/script_editor_plugin.cpp -#, fuzzy msgid "Reload Tool Script (Soft)" -msgstr "Перезагрузить скрипты" +msgstr "Перезагрузить инструм. скрипт (мягко)" #: tools/editor/plugins/script_editor_plugin.cpp #: tools/editor/plugins/shader_editor_plugin.cpp @@ -4635,20 +4633,20 @@ msgid "StyleBox Preview:" msgstr "StyleBox предпросмотр:" #: tools/editor/plugins/texture_region_editor_plugin.cpp -#, fuzzy msgid "Texture Region Editor" -msgstr "Редактор Области Спрайта" +msgstr "Редактор области текстуры" #: tools/editor/plugins/texture_region_editor_plugin.cpp -#, fuzzy msgid "Scale Region Editor" -msgstr "Редактор Области Спрайта" +msgstr "Редактор масштабируемой области текстуры" #: tools/editor/plugins/texture_region_editor_plugin.cpp msgid "" "No texture in this node.\n" "Set a texture to be able to edit region." msgstr "" +"В этом ноде нет текстуры.\n" +"Выберите текстуру, чтобы редактировать область." #: tools/editor/plugins/theme_editor_plugin.cpp msgid "Can't save theme to file:" @@ -5171,14 +5169,12 @@ msgid "Remove project from the list? (Folder contents will not be modified)" msgstr "Удалить проект из списка? (Содержимое папки не будет изменено)" #: tools/editor/project_manager.cpp -#, fuzzy msgid "Project Manager" -msgstr "Название проекта:" +msgstr "Менеджер проектов" #: tools/editor/project_manager.cpp -#, fuzzy msgid "Project List" -msgstr "Выйти в список проектов" +msgstr "Список проектов" #: tools/editor/project_manager.cpp msgid "Run" @@ -5198,7 +5194,7 @@ msgstr "Выход" #: tools/editor/project_settings.cpp msgid "Key " -msgstr "Кнопка" +msgstr "Кнопка " #: tools/editor/project_settings.cpp msgid "Joy Button" @@ -5334,14 +5330,12 @@ msgstr "" "константы." #: tools/editor/project_settings.cpp -#, fuzzy msgid "Autoload '%s' already exists!" -msgstr "Действие '%s' уже существует!" +msgstr "Автозагрузка '%s' уже существует!" #: tools/editor/project_settings.cpp -#, fuzzy msgid "Rename Autoload" -msgstr "Удалена автозагрузка" +msgstr "Переименовать автозагрузку" #: tools/editor/project_settings.cpp msgid "Toggle AutoLoad Globals" @@ -5691,9 +5685,7 @@ msgstr "Не могу работать с нодами из внешней сц #: tools/editor/scene_tree_dock.cpp msgid "Can't operate on nodes the current scene inherits from!" -msgstr "" -"Не могу работать с нодами текущей сцены, наследуемой откуда-то!\n" -"Очистите наследование, чтобы продолжить работу с ними." +msgstr "Невозможно работать с нодами текущей сцены, наследуемой откуда-то!" #: tools/editor/scene_tree_dock.cpp msgid "Remove Node(s)" @@ -5861,7 +5853,7 @@ msgstr "Файлы не выбраны!" #: tools/editor/scenes_dock.cpp msgid "Instance" -msgstr "Экземпляр" +msgstr "Добавить экземпляр" #: tools/editor/scenes_dock.cpp msgid "Edit Dependencies.." @@ -5872,9 +5864,8 @@ msgid "View Owners.." msgstr "Просмотреть владельцев.." #: tools/editor/scenes_dock.cpp -#, fuzzy msgid "Copy Path" -msgstr "Копировать параметры" +msgstr "Копировать путь" #: tools/editor/scenes_dock.cpp msgid "Rename or Move.." @@ -6050,7 +6041,7 @@ msgstr "Дерево сцены в реальном времени:" #: tools/editor/script_editor_debugger.cpp msgid "Remote Object Properties: " -msgstr "Параметры объекта:" +msgstr "Параметры объекта: " #: tools/editor/script_editor_debugger.cpp msgid "Profiler" @@ -6114,7 +6105,7 @@ msgstr "Установить из дерева нодов" #: tools/editor/settings_config_dialog.cpp msgid "Shortcuts" -msgstr "" +msgstr "Горячие клавиши" #: tools/editor/spatial_editor_gizmos.cpp msgid "Change Light Radius" |