Autocompletion using expression parameter sub-types (layer, color...) #2678
Replies: 3 comments 5 replies
-
I think it could be done by modifying ExpressionCompletionFinder to:
GDevelop/Core/GDCore/IDE/Events/ExpressionCompletionFinder.h Lines 178 to 197 in 822146e |
Beta Was this translation helpful? Give feedback.
-
It could be maybe still useful to make the "subtype" survives the parsing. Could maybe be used for something else. |
Beta Was this translation helpful? Give feedback.
-
I did an implementation here: #2702 |
Beta Was this translation helpful? Give feedback.
-
Use case
Expressions like MouseX(:Layer, :number) have a general string autocompletion for its layer parameter. It could be interesting to refine autocompletion using the subtype "Layer" instead of the type "string".
https://trello.com/c/hdJPfWtC/200-add-dropdown-with-list-of-points-for-parameters-asking-for-a-sprite-point-name-in-events
Code limitations
The GUI calls gd.ExpressionCompletionFinder.getCompletionDescriptionsFor() which only gives string or number as type for parameters no matter the subtype.
GDevelop/newIDE/app/src/EventsSheet/ParameterFields/GenericExpressionField/index.js
Lines 340 to 343 in 98303f7
Looking at the Core code, the parser loses the information on the subtype when it builds the tree:
GDevelop/Core/GDCore/Events/Parsers/ExpressionParser2.h
Lines 579 to 586 in 98303f7
The subtype to type mapping is in IsExpression()
GDevelop/Core/GDCore/Extensions/Metadata/ParameterMetadata.h
Lines 174 to 196 in 98303f7
Solution
How should the subtype make its way to the GUI?
I guess that adding it to ExpressionNode may not be ideal as it would only be useful for instances that are the parameter child of a FunctionCallNode.
But when a user is writing a parameter, getCompletionDescriptionsFor will give the description of the ExpressionNode that represents the parameter.
Beta Was this translation helpful? Give feedback.
All reactions