diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/array.cpp | 3 | ||||
| -rw-r--r-- | core/math/disjoint_set.cpp | 2 | ||||
| -rw-r--r-- | core/os/main_loop.cpp | 2 | ||||
| -rw-r--r-- | core/script_language.cpp | 2 | ||||
| -rw-r--r-- | core/ustring.cpp | 16 | ||||
| -rw-r--r-- | core/ustring.h | 1 | ||||
| -rw-r--r-- | core/variant_call.cpp | 2 | 
7 files changed, 26 insertions, 2 deletions
diff --git a/core/array.cpp b/core/array.cpp index ac30df08bc..fd507f46c3 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -240,6 +240,9 @@ int Array::_clamp_index(int p_index) const {  Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound  	Array new_arr; +	if (empty()) // Don't try to slice empty arrays. +		return new_arr; +  	p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range  	p_end = Array::_fix_slice_index(p_end, size(), 0); diff --git a/core/math/disjoint_set.cpp b/core/math/disjoint_set.cpp index 838939e1ba..c9d47aa0ae 100644 --- a/core/math/disjoint_set.cpp +++ b/core/math/disjoint_set.cpp @@ -1,5 +1,5 @@  /*************************************************************************/ -/*  disjoint_set.h                                                       */ +/*  disjoint_set.cpp                                                     */  /*************************************************************************/  /*                       This file is part of:                           */  /*                           GODOT ENGINE                                */ diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index eca3b2a7f4..5587e827ba 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -63,6 +63,8 @@ void MainLoop::_bind_methods() {  	BIND_CONSTANT(NOTIFICATION_WM_ABOUT);  	BIND_CONSTANT(NOTIFICATION_CRASH);  	BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE); +	BIND_CONSTANT(NOTIFICATION_APP_RESUMED); +	BIND_CONSTANT(NOTIFICATION_APP_PAUSED);  };  void MainLoop::set_init_script(const Ref<Script> &p_init_script) { diff --git a/core/script_language.cpp b/core/script_language.cpp index ee8589d76a..7201773ea5 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -114,7 +114,7 @@ void Script::_bind_methods() {  	ClassDB::bind_method(D_METHOD("get_script_method_list"), &Script::_get_script_method_list);  	ClassDB::bind_method(D_METHOD("get_script_signal_list"), &Script::_get_script_signal_list);  	ClassDB::bind_method(D_METHOD("get_script_constant_map"), &Script::_get_script_constant_map); -	ClassDB::bind_method(D_METHOD("get_property_default_value"), &Script::_get_property_default_value); +	ClassDB::bind_method(D_METHOD("get_property_default_value", "property"), &Script::_get_property_default_value);  	ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); diff --git a/core/ustring.cpp b/core/ustring.cpp index dee554716f..07caa3a018 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3049,6 +3049,22 @@ String String::replacen(const String &p_key, const String &p_with) const {  	return new_string;  } +String String::repeat(int p_count) const { + +	ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number."); + +	String new_string; +	const CharType *src = this->c_str(); + +	new_string.resize(length() * p_count + 1); + +	for (int i = 0; i < p_count; i++) +		for (int j = 0; j < length(); j++) +			new_string[i * length() + j] = src[j]; + +	return new_string; +} +  String String::left(int p_pos) const {  	if (p_pos <= 0) diff --git a/core/ustring.h b/core/ustring.h index bbd0bcceb5..87a14bfad7 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -223,6 +223,7 @@ public:  	String replace(const String &p_key, const String &p_with) const;  	String replace(const char *p_key, const char *p_with) const;  	String replacen(const String &p_key, const String &p_with) const; +	String repeat(int p_count) const;  	String insert(int p_at_pos, const String &p_string) const;  	String pad_decimals(int p_digits) const;  	String pad_zeros(int p_digits) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index c288c50abf..53f64fcde6 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -256,6 +256,7 @@ struct _VariantCall {  	VCALL_LOCALMEM2R(String, format);  	VCALL_LOCALMEM2R(String, replace);  	VCALL_LOCALMEM2R(String, replacen); +	VCALL_LOCALMEM1R(String, repeat);  	VCALL_LOCALMEM2R(String, insert);  	VCALL_LOCALMEM0R(String, capitalize);  	VCALL_LOCALMEM3R(String, split); @@ -1530,6 +1531,7 @@ void register_variant_methods() {  	ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));  	ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray());  	ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray()); +	ADDFUNC1R(STRING, STRING, String, repeat, INT, "count", varray());  	ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray());  	ADDFUNC0R(STRING, STRING, String, capitalize, varray());  	ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));  |