diff options
-rw-r--r-- | core/config/project_settings.cpp | 2 | ||||
-rw-r--r-- | core/core_bind.cpp | 6 | ||||
-rw-r--r-- | core/core_bind.h | 2 | ||||
-rw-r--r-- | core/io/json.cpp | 19 | ||||
-rw-r--r-- | core/io/json.h | 4 | ||||
-rw-r--r-- | core/string/ustring.cpp | 35 | ||||
-rw-r--r-- | core/string/ustring.h | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 2 | ||||
-rw-r--r-- | doc/classes/JSON.xml | 3 | ||||
-rw-r--r-- | doc/classes/String.xml | 2 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 2 | ||||
-rw-r--r-- | editor/editor_export.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 6 | ||||
-rw-r--r-- | editor/property_editor.cpp | 70 | ||||
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 2 | ||||
-rw-r--r-- | modules/mono/utils/path_utils.cpp | 2 | ||||
-rw-r--r-- | platform/android/plugin/godot_plugin_config.h | 2 | ||||
-rw-r--r-- | platform/iphone/plugin/godot_plugin_config.h | 4 | ||||
-rw-r--r-- | platform/linuxbsd/os_linuxbsd.cpp | 6 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 6 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 6 | ||||
-rw-r--r-- | tests/test_string.h | 2 |
24 files changed, 113 insertions, 80 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index a1782f4ef3..590c3ff50e 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -62,7 +62,7 @@ String ProjectSettings::localize_path(const String &p_path) const { } if (p_path.begins_with("res://") || p_path.begins_with("user://") || - (p_path.is_abs_path() && !p_path.begins_with(resource_path))) { + (p_path.is_absolute_path() && !p_path.begins_with(resource_path))) { return p_path.simplify_path(); } diff --git a/core/core_bind.cpp b/core/core_bind.cpp index fe0166d0e6..81d229ae92 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2420,12 +2420,12 @@ Variant JSONParseResult::get_result() const { } void _JSON::_bind_methods() { - ClassDB::bind_method(D_METHOD("print", "value", "indent", "sort_keys"), &_JSON::print, DEFVAL(String()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("print", "value", "indent", "sort_keys", "full_precision"), &_JSON::print, DEFVAL(String()), DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("parse", "json"), &_JSON::parse); } -String _JSON::print(const Variant &p_value, const String &p_indent, bool p_sort_keys) { - return JSON::print(p_value, p_indent, p_sort_keys); +String _JSON::print(const Variant &p_value, const String &p_indent, bool p_sort_keys, bool p_full_precision) { + return JSON::print(p_value, p_indent, p_sort_keys, p_full_precision); } Ref<JSONParseResult> _JSON::parse(const String &p_json) { diff --git a/core/core_bind.h b/core/core_bind.h index 2de77a60c8..e47d6dc0d5 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -706,7 +706,7 @@ protected: public: static _JSON *get_singleton() { return singleton; } - String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false); + String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false, bool p_full_precision = false); Ref<JSONParseResult> parse(const String &p_json); _JSON() { singleton = this; } diff --git a/core/io/json.cpp b/core/io/json.cpp index 394cf216e8..e3e9d6158b 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -55,7 +55,7 @@ static String _make_indent(const String &p_indent, int p_size) { return indent_text; } -String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys) { +String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, bool p_full_precision) { String colon = ":"; String end_statement = ""; @@ -71,8 +71,17 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ return p_var.operator bool() ? "true" : "false"; case Variant::INT: return itos(p_var); - case Variant::FLOAT: - return rtos(p_var); + case Variant::FLOAT: { + double num = p_var; + if (p_full_precision) { + // Store unreliable digits (17) instead of just reliable + // digits (14) so that the value can be decoded exactly. + return String::num(num, 17 - (int)floor(log10(num))); + } else { + // Store only reliable digits (14) by default. + return String::num(num, 14 - (int)floor(log10(num))); + } + } case Variant::PACKED_INT32_ARRAY: case Variant::PACKED_INT64_ARRAY: case Variant::PACKED_FLOAT32_ARRAY: @@ -121,8 +130,8 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ } } -String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys) { - return _print_var(p_var, p_indent, 0, p_sort_keys); +String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) { + return _print_var(p_var, p_indent, 0, p_sort_keys, p_full_precision); } Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) { diff --git a/core/io/json.h b/core/io/json.h index 537477666e..f2711d8c54 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -62,7 +62,7 @@ class JSON { static const char *tk_name[TK_MAX]; - static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys); + static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, bool p_full_precision = false); static Error _get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str); static Error _parse_value(Variant &value, Token &token, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); @@ -70,7 +70,7 @@ class JSON { static Error _parse_object(Dictionary &object, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); public: - static String print(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true); + static String print(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false); static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line); }; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 49cf171f2b..ec5ec3dd79 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -54,7 +54,7 @@ #define snprintf _snprintf_s #endif -#define MAX_DIGITS 6 +#define MAX_DECIMALS 32 #define UPPERCASE(m_c) (((m_c) >= 'a' && (m_c) <= 'z') ? ((m_c) - ('a' - 'A')) : (m_c)) #define LOWERCASE(m_c) (((m_c) >= 'A' && (m_c) <= 'Z') ? ((m_c) + ('a' - 'A')) : (m_c)) #define IS_DIGIT(m_d) ((m_d) >= '0' && (m_d) <= '9') @@ -1379,8 +1379,11 @@ String String::num(double p_num, int p_decimals) { } #ifndef NO_USE_STDLIB - if (p_decimals > 16) { - p_decimals = 16; + if (p_decimals < 0) { + p_decimals = 14 - (int)floor(log10(p_num)); + } + if (p_decimals > MAX_DECIMALS) { + p_decimals = MAX_DECIMALS; } char fmt[7]; @@ -1391,7 +1394,6 @@ String String::num(double p_num, int p_decimals) { fmt[1] = 'l'; fmt[2] = 'f'; fmt[3] = 0; - } else if (p_decimals < 10) { fmt[2] = '0' + p_decimals; fmt[3] = 'l'; @@ -1458,8 +1460,9 @@ String String::num(double p_num, int p_decimals) { double dec = p_num - (double)((int)p_num); int digit = 0; - if (p_decimals > MAX_DIGITS) - p_decimals = MAX_DIGITS; + if (p_decimals > MAX_DECIMALS) { + p_decimals = MAX_DECIMALS; + } int dec_int = 0; int dec_max = 0; @@ -1471,16 +1474,18 @@ String String::num(double p_num, int p_decimals) { digit++; if (p_decimals == -1) { - if (digit == MAX_DIGITS) //no point in going to infinite + if (digit == MAX_DECIMALS) { //no point in going to infinite break; + } if (dec - (double)((int)dec) < 1e-6) { break; } } - if (digit == p_decimals) + if (digit == p_decimals) { break; + } } dec *= 10; int last = (int)dec % 10; @@ -1616,7 +1621,15 @@ String String::num_real(double p_num) { double dec = p_num - (double)((int)p_num); int digit = 0; - int decimals = MAX_DIGITS; + +#if REAL_T_IS_DOUBLE + int decimals = 14 - (int)floor(log10(p_num)); +#else + int decimals = 6 - (int)floor(log10(p_num)); +#endif + if (decimals > MAX_DECIMALS) { + decimals = MAX_DECIMALS; + } int dec_int = 0; int dec_max = 0; @@ -3786,7 +3799,7 @@ String String::humanize_size(uint64_t p_size) { return String::num(p_size / divisor).pad_decimals(digits) + " " + prefixes[prefix_idx]; } -bool String::is_abs_path() const { +bool String::is_absolute_path() const { if (length() > 1) { return (operator[](0) == '/' || operator[](0) == '\\' || find(":/") != -1 || find(":\\") != -1); } else if ((length()) == 1) { @@ -4396,7 +4409,7 @@ bool String::is_resource_file() const { } bool String::is_rel_path() const { - return !is_abs_path(); + return !is_absolute_path(); } String String::get_base_dir() const { diff --git a/core/string/ustring.h b/core/string/ustring.h index a56845deff..f05865165d 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -397,7 +397,7 @@ public: _FORCE_INLINE_ bool is_empty() const { return length() == 0; } // path functions - bool is_abs_path() const; + bool is_absolute_path() const; bool is_rel_path() const; bool is_resource_file() const; String path_to(const String &p_path) const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index a1314a11f3..02a59f7685 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1365,7 +1365,7 @@ static void _register_variant_builtin_methods() { // FIXME: Static function, not sure how to bind //bind_method(String, humanize_size, sarray("size"), varray()); - bind_method(String, is_abs_path, sarray(), varray()); + bind_method(String, is_absolute_path, sarray(), varray()); bind_method(String, is_rel_path, sarray(), varray()); bind_method(String, get_base_dir, sarray(), varray()); bind_method(String, get_file, sarray(), varray()); diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index a9fb50c262..7baff7aa39 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -27,9 +27,12 @@ </argument> <argument index="2" name="sort_keys" type="bool" default="false"> </argument> + <argument index="3" name="full_precision" type="bool" default="false"> + </argument> <description> Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network. [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a Variant to JSON text will convert all numerical values to [float] types. + [b]Note:[/b] If [code]full_precision[/code] is true, when printing floats, the unreliable digits are printed in addition to the reliable digits to guarantee exact decoding. Use [code]indent[/code] parameter to pretty print the output. [b]Example output:[/b] [codeblock] diff --git a/doc/classes/String.xml b/doc/classes/String.xml index a81defa16c..d0c5f0ea86 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -275,7 +275,7 @@ Returns a copy of the string with the substring [code]what[/code] inserted at the given position. </description> </method> - <method name="is_abs_path" qualifiers="const"> + <method name="is_absolute_path" qualifiers="const"> <return type="bool"> </return> <description> diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 55f9e6de17..325bae5b56 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -208,7 +208,7 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) { bool DirAccessWindows::file_exists(String p_file) { GLOBAL_LOCK_FUNCTION - if (!p_file.is_abs_path()) { + if (!p_file.is_absolute_path()) { p_file = get_current_dir().plus_file(p_file); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index f5652ab7b5..7c5a06107d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -151,7 +151,7 @@ void EditorExportPreset::set_export_path(const String &p_path) { export_path = p_path; /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path, * this should be removed. */ - if (export_path.is_abs_path()) { + if (export_path.is_absolute_path()) { String res_path = OS::get_singleton()->get_resource_dir(); export_path = res_path.path_to_file(export_path); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b96103b07e..275af0f09e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -770,7 +770,7 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { if (!res->editor_can_reload_from_file()) { continue; } - if (!res->get_path().is_resource_file() && !res->get_path().is_abs_path()) { + if (!res->get_path().is_resource_file() && !res->get_path().is_absolute_path()) { continue; } if (!FileAccess::exists(res->get_path())) { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index c592e4b031..3aa17ee581 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -126,7 +126,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand String p = l.replace("map_Kd", "").replace("\\", "/").strip_edges(); String path; - if (p.is_abs_path()) { + if (p.is_absolute_path()) { path = p; } else { path = base_path.plus_file(p); @@ -146,7 +146,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand String p = l.replace("map_Ks", "").replace("\\", "/").strip_edges(); String path; - if (p.is_abs_path()) { + if (p.is_absolute_path()) { path = p; } else { path = base_path.plus_file(p); @@ -166,7 +166,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand String p = l.replace("map_Ns", "").replace("\\", "/").strip_edges(); String path; - if (p.is_abs_path()) { + if (p.is_absolute_path()) { path = p; } else { path = base_path.plus_file(p); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 7a4b0964fa..c44f8d9a4b 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1446,6 +1446,8 @@ void CustomPropertyEditor::_modified(String p_string) { return; } + Variant prev_v = v; + updating = true; switch (type) { case Variant::INT: { @@ -1459,14 +1461,18 @@ void CustomPropertyEditor::_modified(String p_string) { } else { v = expr->execute(Array(), nullptr, false); } - emit_signal("variant_changed"); + if (v != prev_v) { + emit_signal("variant_changed"); + } } break; case Variant::FLOAT: { if (hint != PROPERTY_HINT_EXP_EASING) { String text = TS->parse_number(value_editor[0]->get_text()); v = _parse_real_expression(text); - emit_signal("variant_changed"); + if (v != prev_v) { + emit_signal("variant_changed"); + } } } break; @@ -1479,7 +1485,9 @@ void CustomPropertyEditor::_modified(String p_string) { vec.x = _parse_real_expression(value_editor[0]->get_text()); vec.y = _parse_real_expression(value_editor[1]->get_text()); v = vec; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::RECT2: { @@ -1490,7 +1498,9 @@ void CustomPropertyEditor::_modified(String p_string) { r2.size.x = _parse_real_expression(value_editor[2]->get_text()); r2.size.y = _parse_real_expression(value_editor[3]->get_text()); v = r2; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; @@ -1500,7 +1510,9 @@ void CustomPropertyEditor::_modified(String p_string) { vec.y = _parse_real_expression(value_editor[1]->get_text()); vec.z = _parse_real_expression(value_editor[2]->get_text()); v = vec; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::PLANE: { @@ -1510,7 +1522,9 @@ void CustomPropertyEditor::_modified(String p_string) { pl.normal.z = _parse_real_expression(value_editor[2]->get_text()); pl.d = _parse_real_expression(value_editor[3]->get_text()); v = pl; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::QUATERNION: { @@ -1520,7 +1534,9 @@ void CustomPropertyEditor::_modified(String p_string) { q.z = _parse_real_expression(value_editor[2]->get_text()); q.w = _parse_real_expression(value_editor[3]->get_text()); v = q; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::AABB: { @@ -1534,7 +1550,9 @@ void CustomPropertyEditor::_modified(String p_string) { size.y = _parse_real_expression(value_editor[4]->get_text()); size.z = _parse_real_expression(value_editor[5]->get_text()); v = AABB(pos, size); - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::TRANSFORM2D: { @@ -1544,7 +1562,9 @@ void CustomPropertyEditor::_modified(String p_string) { } v = m; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::BASIS: { @@ -1554,7 +1574,9 @@ void CustomPropertyEditor::_modified(String p_string) { } v = m; - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::TRANSFORM3D: { @@ -1570,7 +1592,9 @@ void CustomPropertyEditor::_modified(String p_string) { origin.z = _parse_real_expression(value_editor[11]->get_text()); v = Transform3D(basis, origin); - _emit_changed_whole_or_field(); + if (v != prev_v) { + _emit_changed_whole_or_field(); + } } break; case Variant::COLOR: { @@ -1578,7 +1602,9 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::NODE_PATH: { v = NodePath(value_editor[0]->get_text()); - emit_signal("variant_changed"); + if (v != prev_v) { + emit_signal("variant_changed"); + } } break; case Variant::DICTIONARY: { } break; @@ -1654,25 +1680,7 @@ void CustomPropertyEditor::_focus_enter() { } void CustomPropertyEditor::_focus_exit() { - switch (type) { - case Variant::FLOAT: - case Variant::STRING: - case Variant::VECTOR2: - case Variant::RECT2: - case Variant::VECTOR3: - case Variant::PLANE: - case Variant::QUATERNION: - case Variant::AABB: - case Variant::TRANSFORM2D: - case Variant::BASIS: - case Variant::TRANSFORM3D: { - for (int i = 0; i < MAX_VALUE_EDITORS; ++i) { - value_editor[i]->select(0, 0); - } - } break; - default: { - } - } + _modified(String()); } void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 9e974b6fdc..58620f2b3e 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -240,10 +240,10 @@ </method> </methods> <constants> - <constant name="PI" value="3.141593"> + <constant name="PI" value="3.14159265358979"> Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code]. </constant> - <constant name="TAU" value="6.283185"> + <constant name="TAU" value="6.28318530717959"> The circle constant, the circumference of the unit circle in radians. </constant> <constant name="INF" value="inf"> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 77e6729b63..fdbe557956 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2064,7 +2064,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (err == OK) { const GDScriptParser::ClassNode *c = parser.get_tree(); if (r_icon_path) { - if (c->icon_path.is_empty() || c->icon_path.is_abs_path()) { + if (c->icon_path.is_empty() || c->icon_path.is_absolute_path()) { *r_icon_path = c->icon_path; } else if (c->icon_path.is_rel_path()) { *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path(); diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 3da2b06f7c..ec04d50704 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -80,7 +80,7 @@ String cwd() { } String abspath(const String &p_path) { - if (p_path.is_abs_path()) { + if (p_path.is_absolute_path()) { return p_path.simplify_path(); } else { return path::join(path::cwd(), p_path).simplify_path(); diff --git a/platform/android/plugin/godot_plugin_config.h b/platform/android/plugin/godot_plugin_config.h index c5c1c690a2..6b708548ae 100644 --- a/platform/android/plugin/godot_plugin_config.h +++ b/platform/android/plugin/godot_plugin_config.h @@ -102,7 +102,7 @@ struct PluginConfigAndroid { static inline String resolve_local_dependency_path(String plugin_config_dir, String dependency_path) { String absolute_path; if (!dependency_path.is_empty()) { - if (dependency_path.is_abs_path()) { + if (dependency_path.is_absolute_path()) { absolute_path = ProjectSettings::get_singleton()->globalize_path(dependency_path); } else { absolute_path = plugin_config_dir.plus_file(dependency_path); diff --git a/platform/iphone/plugin/godot_plugin_config.h b/platform/iphone/plugin/godot_plugin_config.h index e2546e733c..4d0c67bfff 100644 --- a/platform/iphone/plugin/godot_plugin_config.h +++ b/platform/iphone/plugin/godot_plugin_config.h @@ -104,7 +104,7 @@ static inline String resolve_local_dependency_path(String plugin_config_dir, Str return absolute_path; } - if (dependency_path.is_abs_path()) { + if (dependency_path.is_absolute_path()) { return dependency_path; } @@ -121,7 +121,7 @@ static inline String resolve_system_dependency_path(String dependency_path) { return absolute_path; } - if (dependency_path.is_abs_path()) { + if (dependency_path.is_absolute_path()) { return dependency_path; } diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index f112f4dde6..adae059552 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -166,7 +166,7 @@ bool OS_LinuxBSD::_check_internal_feature_support(const String &p_feature) { String OS_LinuxBSD::get_config_path() const { if (has_environment("XDG_CONFIG_HOME")) { - if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + if (get_environment("XDG_CONFIG_HOME").is_absolute_path()) { return get_environment("XDG_CONFIG_HOME"); } else { WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.config` or `.` per the XDG Base Directory specification."); @@ -181,7 +181,7 @@ String OS_LinuxBSD::get_config_path() const { String OS_LinuxBSD::get_data_path() const { if (has_environment("XDG_DATA_HOME")) { - if (get_environment("XDG_DATA_HOME").is_abs_path()) { + if (get_environment("XDG_DATA_HOME").is_absolute_path()) { return get_environment("XDG_DATA_HOME"); } else { WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.local/share` or `get_config_path()` per the XDG Base Directory specification."); @@ -196,7 +196,7 @@ String OS_LinuxBSD::get_data_path() const { String OS_LinuxBSD::get_cache_path() const { if (has_environment("XDG_CACHE_HOME")) { - if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { return get_environment("XDG_CACHE_HOME"); } else { WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.cache` or `get_config_path()` per the XDG Base Directory specification."); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 9e3f0350e9..b65d84d900 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -190,7 +190,7 @@ MainLoop *OS_OSX::get_main_loop() const { String OS_OSX::get_config_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CONFIG_HOME")) { - if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + if (get_environment("XDG_CONFIG_HOME").is_absolute_path()) { return get_environment("XDG_CONFIG_HOME"); } else { WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Application Support` or `.` per the XDG Base Directory specification."); @@ -205,7 +205,7 @@ String OS_OSX::get_config_path() const { String OS_OSX::get_data_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_DATA_HOME")) { - if (get_environment("XDG_DATA_HOME").is_abs_path()) { + if (get_environment("XDG_DATA_HOME").is_absolute_path()) { return get_environment("XDG_DATA_HOME"); } else { WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); @@ -217,7 +217,7 @@ String OS_OSX::get_data_path() const { String OS_OSX::get_cache_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CACHE_HOME")) { - if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { return get_environment("XDG_CACHE_HOME"); } else { WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Libary/Caches` or `get_config_path()` per the XDG Base Directory specification."); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index ccf13488ab..dcaa42cd1f 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -633,7 +633,7 @@ MainLoop *OS_Windows::get_main_loop() const { String OS_Windows::get_config_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. if (has_environment("XDG_CONFIG_HOME")) { - if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + if (get_environment("XDG_CONFIG_HOME").is_absolute_path()) { return get_environment("XDG_CONFIG_HOME"); } else { WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `%APPDATA%` or `.` per the XDG Base Directory specification."); @@ -648,7 +648,7 @@ String OS_Windows::get_config_path() const { String OS_Windows::get_data_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. if (has_environment("XDG_DATA_HOME")) { - if (get_environment("XDG_DATA_HOME").is_abs_path()) { + if (get_environment("XDG_DATA_HOME").is_absolute_path()) { return get_environment("XDG_DATA_HOME"); } else { WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); @@ -660,7 +660,7 @@ String OS_Windows::get_data_path() const { String OS_Windows::get_cache_path() const { // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. if (has_environment("XDG_CACHE_HOME")) { - if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { return get_environment("XDG_CACHE_HOME"); } else { WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `%TEMP%` or `get_config_path()` per the XDG Base Directory specification."); diff --git a/tests/test_string.h b/tests/test_string.h index 6e214574af..7f404a34e8 100644 --- a/tests/test_string.h +++ b/tests/test_string.h @@ -1130,7 +1130,7 @@ TEST_CASE("[String] Path functions") { CHECK(String(path[i]).get_basename() == base_name[i]); CHECK(String(path[i]).get_extension() == ext[i]); CHECK(String(path[i]).get_file() == file[i]); - CHECK(String(path[i]).is_abs_path() == abs[i]); + CHECK(String(path[i]).is_absolute_path() == abs[i]); CHECK(String(path[i]).is_rel_path() != abs[i]); CHECK(String(path[i]).simplify_path().get_base_dir().plus_file(file[i]) == String(path[i]).simplify_path()); } |