Implement automatic scene conversion#191
Conversation
Only used at the moment for transitioning from Node2D to MeshInstance2D but can be further expanded in the future if needed.
| var success := true | ||
|
|
||
| for i in converters.size(): | ||
| if converters[i].convert(): |
There was a problem hiding this comment.
Shouldn't we check if converter needs to convert the project once again? I assume not every converter needs to run on version upgrade.
There was a problem hiding this comment.
I specified in the IVersionConverter class that if no conversion is necessary, convert() should do nothing.
SmartShape2D/addons/rmsmartshape/version_transition.gd
Lines 15 to 16 in 8da922e
But for clarity and possible future changes, I can add another needs_conversion() check.
tests/unit/test_tscn_analyzer.gd
Outdated
| var analyzer := _get_test_analyzer() | ||
| assert_true(analyzer.contains_shapes()) | ||
|
|
||
| analyzer.load("res://tests/unit/res://tests/unit/test_convert_tscn_node_types.gd") |
tests/unit/test_tscn_analyzer.gd
Outdated
| assert_eq(analyzer._content_start_line, 11) | ||
|
|
||
| shape_ids.clear() | ||
| analyzer.load("res://tests/unit/res://tests/unit/test_convert_tscn_node_types.gd") |
- Fix broken paths - Fix a bug where `TscnAnalyzer.load()` does not reset `_shape_script_ids`. - Add another `needs_conversion()` check before running `convert()`. Technically not needed but makes it clearer.
|
Fixed.
Yes, this PR is only for the conversion process. Edit: Also just pushed another minor bug fix unrelated to this PR where point changed signal handlers are not disconnected. Might be related to the screenshot in Discord. |
I'm fine with it being here. Do you want to keep this open until MeshInstance PR? |
|
Nope, mesh instance PR takes a moment. |
This PR brings the foundation for running automatic version conversion on project startup.
Most importantly it implements scene conversion for the node type change to
MeshInstance2Ddiscussed in #172.Also shortly before finishing this, Godot 4.4 was released, so I included the update to 4.4 as well, i.e.
*.uidfiles and respective changes to the scenes.The plugin checks if version information about SS2D exists in the project settings. If none was found or if it is different, all registered converter try to detect if changes are required.
If yes, a message will propup asking the user to confirm. The "OK" button is intentionally disabled for 3s to prevent users from confirming without reading.
When confirmed, all converters run sequentally and the success or failure is reported.
After success or when no conversion is required, the current version number is written to a custom internal project settings key to prevent having to run this procedure at every start.
That means the project conversion check will only run at project startup after initial install and after every version change until it was successful.
At the moment, the version number check is really just a
!=comparison. I think it should suffice in most cases and if a more sophisticated check is required, it can be added later.In the 3-dot "Extra Options" menu there is also another entry to re-run the project conversion check manually. This might be useful for people copying scenes from older projects to newer projects.
To make testing easier, I have not yet included a commit with the
MeshInstance2Dconversion applied.I will do so after the PR was approved.