diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-07-25 00:15:20 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-08-31 15:31:49 +0200 |
commit | 291d3aaabefa86b4e102fa7385bcf7aacd240d72 (patch) | |
tree | ff6a8f88a935e3a0faf89ff06e5a77a6bd562e57 | |
parent | de5f13e9356c1c075ced91893a67164f062b36bc (diff) |
Improve null and object printing to avoid confusion with arrays
- Use different syntax for object printing to avoid confusion with arrays.
- Print null as `<null>` to avoid confusion with a string `"null"`.
- Display `<empty>` in editor resource pickers to avoid confusion
with array-based properties.
-rw-r--r-- | core/object/object.cpp | 2 | ||||
-rw-r--r-- | core/variant/variant.cpp | 8 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 4 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/property_inline.out | 2 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/function_many_parameters.out | 2 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/str_preserves_case.out | 2 | ||||
-rw-r--r-- | modules/mono/glue/runtime_interop.cpp | 2 |
8 files changed, 13 insertions, 13 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp index 4f7f55c8b6..33208be539 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -811,7 +811,7 @@ String Object::to_string() { _extension->to_string(_extension_instance, &ret); return ret; } - return "[" + get_class() + ":" + itos(get_instance_id()) + "]"; + return "<" + get_class() + "#" + itos(get_instance_id()) + ">"; } void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance) { diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index a5bc6c229d..b280fc9fe3 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1787,7 +1787,7 @@ String stringify_vector(const T &vec, int recursion_count) { String Variant::stringify(int recursion_count) const { switch (type) { case NIL: - return "null"; + return "<null>"; case BOOL: return _data._bool ? "true" : "false"; case INT: @@ -1904,12 +1904,12 @@ String Variant::stringify(int recursion_count) const { case OBJECT: { if (_get_obj().obj) { if (!_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) { - return "[Freed Object]"; + return "<Freed Object>"; } return _get_obj().obj->to_string(); } else { - return "[Object:null]"; + return "<Object#null>"; } } break; @@ -1926,7 +1926,7 @@ String Variant::stringify(int recursion_count) const { return "RID(" + itos(s.get_id()) + ")"; } break; default: { - return "[" + get_type_name(type) + "]"; + return "<" + get_type_name(type) + ">"; } } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b7910a152e..d81e3d98e7 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -52,7 +52,7 @@ void EditorPropertyNil::update_property() { EditorPropertyNil::EditorPropertyNil() { Label *label = memnew(Label); - label->set_text("[null]"); + label->set_text("<null>"); add_child(label); } @@ -1382,7 +1382,7 @@ void EditorPropertyObjectID::update_property() { edit->set_disabled(false); edit->set_icon(EditorNode::get_singleton()->get_class_icon(type)); } else { - edit->set_text(TTR("[Empty]")); + edit->set_text(TTR("<empty>")); edit->set_disabled(true); edit->set_icon(Ref<Texture2D>()); } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 22e7b01418..f717188b3b 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -61,7 +61,7 @@ void EditorResourcePicker::_update_resource() { if (edited_resource == Ref<Resource>()) { assign_button->set_icon(Ref<Texture2D>()); - assign_button->set_text(TTR("[empty]")); + assign_button->set_text(TTR("<empty>")); assign_button->set_tooltip_text(""); } else { assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object")); @@ -1113,7 +1113,7 @@ void EditorAudioStreamPicker::_update_resource() { void EditorAudioStreamPicker::_preview_draw() { Ref<AudioStream> audio_stream = get_edited_resource(); if (!audio_stream.is_valid()) { - get_assign_button()->set_text(TTR("[empty]")); + get_assign_button()->set_text(TTR("<empty>")); return; } diff --git a/modules/gdscript/tests/scripts/analyzer/features/property_inline.out b/modules/gdscript/tests/scripts/analyzer/features/property_inline.out index 5482592e90..63e59398ae 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/property_inline.out +++ b/modules/gdscript/tests/scripts/analyzer/features/property_inline.out @@ -1,5 +1,5 @@ GDTEST_OK -null +<null> 0 1 2 diff --git a/modules/gdscript/tests/scripts/parser/features/function_many_parameters.out b/modules/gdscript/tests/scripts/parser/features/function_many_parameters.out index 3a979227d4..80df7a3d4c 100644 --- a/modules/gdscript/tests/scripts/parser/features/function_many_parameters.out +++ b/modules/gdscript/tests/scripts/parser/features/function_many_parameters.out @@ -1,2 +1,2 @@ GDTEST_OK -123456789101112131415161718192212223242526272829303132333435363738394041424344454647falsetruenull +123456789101112131415161718192212223242526272829303132333435363738394041424344454647falsetrue<null> diff --git a/modules/gdscript/tests/scripts/parser/features/str_preserves_case.out b/modules/gdscript/tests/scripts/parser/features/str_preserves_case.out index abba38e87c..867f45f0ac 100644 --- a/modules/gdscript/tests/scripts/parser/features/str_preserves_case.out +++ b/modules/gdscript/tests/scripts/parser/features/str_preserves_case.out @@ -1,4 +1,4 @@ GDTEST_OK -null +<null> true false diff --git a/modules/mono/glue/runtime_interop.cpp b/modules/mono/glue/runtime_interop.cpp index 529bda4c38..49a8109ab4 100644 --- a/modules/mono/glue/runtime_interop.cpp +++ b/modules/mono/glue/runtime_interop.cpp @@ -1319,7 +1319,7 @@ void godotsharp_object_to_string(Object *p_ptr, godot_string *r_str) { #endif // Can't call 'Object::to_string()' here, as that can end up calling 'ToString' again resulting in an endless circular loop. memnew_placement(r_str, - String("[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]")); + String("<" + p_ptr->get_class() + "#" + itos(p_ptr->get_instance_id()) + ">")); } #ifdef __cplusplus |