-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Object text-based serialization more readable and VCS-friendly #9774
Comments
Old ui_accept Example
ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
} New ui_accept Example
ui_accept={
"deadzone": 0.5,
"events": [Object(
InputEventKey,
"resource_local_to_scene":false,
"resource_name":"",
"device":0,
"window_id":0,
"alt_pressed":false,
"shift_pressed":false,
"ctrl_pressed":false,
"meta_pressed":false,
"pressed":false,
"keycode":4194309,
"physical_keycode":0,
"key_label":0,
"unicode":0,
"location":0,
"echo":false,
"script":null
), Object(
InputEventKey,
"resource_local_to_scene":false,
"resource_name":"",
"device":0,
"window_id":0,
"alt_pressed":false,
"shift_pressed":false,
"ctrl_pressed":false,
"meta_pressed":false,
"pressed":false,
"keycode":4194310,
"physical_keycode":0,
"key_label":0,
"unicode":0,
"location":0,
"echo":false,
"script":null
), Object(
InputEventKey,
"resource_local_to_scene":false,
"resource_name":"",
"device":0,
"window_id":0,
"alt_pressed":false,
"shift_pressed":false,
"ctrl_pressed":false,
"meta_pressed":false,
"pressed":false,
"keycode":32,
"physical_keycode":0,
"key_label":0,
"unicode":32,
"location":0,
"echo":false,
"script":null
), Object(
InputEventJoypadButton,
"resource_local_to_scene":false,
"resource_name":"",
"device":-1,
"button_index":0,
"pressure":0.0,
"pressed":false,
"script":null
)]
} |
The extra |
I don't think this is a big deal for text-based resources, as they get converted to binary on export (by default). This includes |
Besides text-based resources being converted to binary on export by default, the main reasons for using text based resources during development instead of binary resources is having version control friendly files and human readable and editable files. IMHO the increased file size of having that extra |
I made this repo to show why newlines are important for VCS: https://github.com/robert-wallis/godot-object-lf-git There are two main branches: Here's the scenario:
When newlines are missing, this causes a merge conflict: robert-wallis/godot-object-lf-git#2 When newlines are added, the merge happens successfully: robert-wallis/godot-object-lf-git#4 Even github cannot solve this merge conflict easily robert-wallis/godot-object-lf-git#4 because that's just the way git diff works. ∎ 😋 |
If you're trying to decide how to resolve the above merge conflict, and you take either the top or bottom line, you accidently cause a bug regression.
Both commits need to be merged, not take one or the other. |
Describe the project you are working on
Upgrading the engine from 4.2 to 4.3 in my project.
Describe the problem or limitation you are having in your project
When you
git diff
after upgrading the engine, and an InputEventKey has a new property, it's very difficult to see what actually changed:Describe the feature / enhancement and how it helps to overcome the problem or limitation
This is because
Object
s are not written the same way thatDictionary
objects are.Dictionaries have newlines
\n
after each comma.core/variant/variant_parser.cpp
lines 2054-2066Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
By adding newline "
\n
" characters after commas ",
" in the variant writer. Now when you rungit diff
it shows exactly what property changed. In the case of 4.2 to 4.3 it was a new property"location":0
This was almost impossible to see when everything in
Object
was serialized in one line as shown above.If this enhancement will not be used often, can it be worked around with a few lines of script?
This simple PR has the changes godotengine/godot#92102
Is there a reason why this should be core and not an add-on in the asset library?
The
project.godot
file is serialized withObject
variants for key events.The text was updated successfully, but these errors were encountered: