-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Add custom nested Blockly categories support #4236
Add custom nested Blockly categories support #4236
Conversation
Is there a realistic case where one would want the category nested and not nested simultaneously for this parameter to be needed? |
It was mainly to cover all possible cases and because it was possible and easy 🤷 However, this also helps to make the system smaller and simpler as I avoid a loop iterating over all toolboxes to check if it's not a nested category (making performances slower and a bad code). |
I would ask you in this case to mark toolboxes that are children during runtime while loading them as this is neither bad code nor it will not impact performance(s) badly that much. You can do that ExternalBlockLoader at line 112 (lines at your branch) |
I was about to merge this PR but then realized it would be much better for the category to define its parent instead of nested categories. This way a plugin could eg. add sub-category to existing category, eg. special category of "Block data" blocks. All this needs is when assembling category, you would need to iterate through all categories and if any declares current one as parent, add XML of that category as "sub-category" |
Toolbox should only have one parent category. In the previous system, toolbox could only have one parent category so this should stay the same as it was ok and logical |
No, they could already have multiple parents. The system is the same as before, except you define the parents inside the nested category instead of defining the children inside the parent categories. The example I pushed simply didn't show this case. |
You are correct, there could be multiple parents before too. But I don't think this is a good idea as it would allow cluttered toolboxes and also in most (all sensible) cases one would want just one, where JSON will require array |
Ok, I'll change it. I made a list, so users wanting to put their categories in multiple parents would have been able to. |
I understand your reasoning for the decision of supporting multiple parents, as this offers more options. What I have concern with multiple parents for one category is whether that would bring any real benefits or just allow to "dig" same category under two parents, which is a bit unnatural for usual "tree" structures which the toolbox aims to be |
It's now changed to a single parent only |
This PR adds the possibility to make nested categories for Blockly editors. Nested categories work and are created exactly like regular categories. However, 2 new parameters have been added to allow this:
parent_category
: A String (ID) used inside a category to define what category will be its parent.is_expanded
: If true, the category will expand its children (not recursive)Example withBlock management
andSecondary #4
expanded.https://github.com/MCreator/MCreator/assets/38427877/c9d77745-a4ae-4015-a56f-97b99ca6b5e8An example of the features in use can be seen in this commit