Make MeshLibrary use PropertyListHelper#116736
Make MeshLibrary use PropertyListHelper#116736YeldhamDev wants to merge 1 commit intogodotengine:masterfrom
MeshLibrary use PropertyListHelper#116736Conversation
|
Uh... #115281 |
|
Well, shit... But hey, due to mine being more recent, there are no file conflicts at least... 🫠 EDIT: Testing your version, I actually can't add nor remove elements, and the dropdown options for that are still present. |
28a9c26 to
497a6e4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
497a6e4 to
a695d14
Compare
|
Alright, good news: it can now handle the gaps between indexes. It's in a state where it could be merged, but the ideal solution would be that when a library with gaps is detected, it would be shrunk, and any |
KoBeWi
left a comment
There was a problem hiding this comment.
When deleting an element, all elements after it will be shifted, causing the GridMaps to become scrambled. I suppose this is the reason why MeshLibrary is using a sparse array. Your PR ignores that completely, my PR tries to keep this characteristic, albeit with limited results.
tbh the MeshLibrary as it is now reminds me of the old TileSet. Each tile is a separate entity in a very loose list. The main problem is that there is no proper editor for MeshLibrary at all and editing the properties in the inspector is a workaround, and not a very friendly one. The MeshLibrary properties should not be in the inspector at all, but right now there is no better way to edit them.
That said, if we ever want to add a dedicated editor, adding PropertyListHelper does not conflict with it (see #92472), so this PR should be fine (if we accept GridMap scrambling xd). It's also more functional than my one.
| uint32_t navigation_layers = 1; | ||
| }; | ||
|
|
||
| RBMap<int, Item> item_map; |
There was a problem hiding this comment.
This should be probably changed to LocalVector, since the structure can no longer have holes.
| if (!item_map.has(idx)) { | ||
| set_item_count(idx + 1); | ||
| } |
There was a problem hiding this comment.
This is technically unsafe. If the missing index is a hole, the further items will get erased if they were already assigned. Unlikely to happen with normal usage though.
There was a problem hiding this comment.
I've been testing this PR with this project: https://github.com/Nodragem/top-down-action-adventure-starter-kit
It has a library with separate gaps across it, and it didn't result in any data loss while manipulating it.
There was a problem hiding this comment.
Yeah, they'd need to be loaded out of order, which can only happen if you manually reorder them or due to some bug.
2d06a87 to
25b0207
Compare
|
I introduced a little hack to avoid polluting the
You bring a good point. Maybe the way to go would simply be creating a proper editor for |
25b0207 to
c4b3207
Compare
c4b3207 to
b40e9ae
Compare
This PR ports from the old way
MeshLibraryuses to show (common properties in the inspector) and manipulate (options inside a dropdown in the toolbar) its data, to instead usingPropertyListHelper(already used in stuff likePopupMenu,TileMap, etc). Allowing to easily create, delete, and move items.