Commit Graph

51 Commits

Author SHA1 Message Date
D8H d6c99b27af Allow to use parameters and properties in the variable action and condition (#7124) 2025-01-15 23:28:18 +01:00
D8H de73d617b0 Fix missing error in expressions for missing object variables with children (#7159) 2024-11-13 16:16:46 +01:00
D8H a2ea751007 Fix to forbid behavior properties from being used as values in expressions (#7095) 2024-10-21 19:58:32 +02:00
D8H 011abaf808 Allow drag and drop in the extension function parameter editor (#6847) 2024-08-20 10:29:52 +02:00
Florian Rival a51c223c9c Add experimental, work-in-progress visual editor for custom objects (aka "prefabs"/"templates") (#6699)
* Still to do: 
  * Properly handle effects (disable 3D effects) for layers
  * Handle hot reloading properly
  * Avoid duplicating the configuration of the custom object inside each object created from it. Instead, only store the modified values.
  * Add a "Extract as a custom object ("prefab")" when selecting instances in a scene.
  * Add a dialog to give choice between 2D or 3D object when creating one.
  * Make sure "behavior shared data" are properly handled (physics, pathfinding...)
  * Check if we need to give an expression to translate coordinates from the parent to the local custom object.
  * Ensure a deleted custom object does not break the editor

Co-authored-by: Davy Hélard <davy.helard@gmail.com>
2024-07-11 11:27:34 +02:00
D8H f62811974d Remove an error about object name collision in object variable fields (#6751) 2024-07-04 12:56:25 +02:00
D8H 75d79a7758 Display errors on variable parameters about name collisions with objects (#6732) 2024-07-01 16:42:43 +02:00
D8H dc87f138a6 Fix expression validation for variables with brackets (#6652) 2024-06-13 18:38:35 +02:00
D8H 75bfa5cb45 Unify variable instructions and handle local variables (#6459)
- Global or scene variables can be used with a unique action and condition.
- Object variables can be used with a unique action and condition.
- Variables need to be declared following the same logic as the new expression syntax.
- Local variable can be declared on events
- Extensions have their own variables
- Show a diagnostic report when a preview is launched and there are missing scene variables, object variables or behaviors.
  - This is especially useful if external events are shared between several scenes.
2024-05-20 23:14:07 +02:00
Florian Rival 7e8b44af2e Fix expressions involving a variable (or property) of type number/string wrongly rejected when an operator like + was used after them (#6467)
* For example, "Your score is " + NumberVariable + " points" was rejected, because the second operator type was not properly inferred.
* If something does not work in your game anymore, double check if your expressions in the events sheets are not underlined in red. Sometimes, adding `ToString(` or `ToNumber(` around it might be required.
2024-03-28 09:42:41 +01:00
Clément Pasteau c56fa03bf6 Fix crash when trying to access a child of a non existing structure child in an expression (#6144) 2024-01-04 16:20:49 +01:00
Florian Rival e2c40ff205 Improve structure variables completion (#5978)
* When a structure variable name is entered in an expression, completions will also be provided for children variables.
2023-11-30 13:47:19 +01:00
Florian Rival 4f900c9451 Enable auto-completion for structure and array variables when writing an expression (#5960) 2023-11-28 11:30:26 +01:00
Florian Rival 913e367f6f Allow to properly use variables/properties/parameters in brackets to access a structure variable (#5738)
* This means expressions like `MyStructure[SomeIndexVariable]` will work properly for a structure if `SomeIndexVariable` is a string variable. Gdevelop now properly uses the type of the variable/property/parameter (to avoid considering what's inside the brackets as a number if it's a string). Remember to declare your variables in the variables editor so that you can use them in expressions.
2023-10-09 18:21:49 +02:00
Florian Rival cdf21ebd4c Allow to use the new variable syntax for groups (#5730)
* You can write `MyObjectGroup.SomeVariable` in the expressions as long as all the objects of the groups have this variable declared in the objects variable editor.
2023-10-08 11:59:35 +02:00
Florian Rival 8944df1831 Add support for writing parameter names directly in expressions (#5676) 2023-09-22 22:41:13 +02:00
Florian Rival a0925c79c3 Add a new simplified way to use variables in expressions, and automate renaming of variables in events (#5580)
* You can now simply write the name of the scene or global variable in an expression to use it: `1 + MyVariable` (instead of `1 + Variable(MyVariable)`).
* Objects can also have their variables accessed like this: `MyObject.MyVariable` (instead of `MyObject.Variable(MyVariable)`.
* This also works for properties inside functions of behaviors or custom objects. For example, you can write `Speed` instead of `Object.Behavior::PropertySpeed()`.
* This syntax will also handle all types of variables without the need to write ToString. For example, you can now write "Score: " + CoinsEarned instead of "Score: " + ToString(Variable(CoinsEarned)).
* This syntax will only work (and autocompletions will be shown) if you add the variable in the variables editor of the scene, the project or in the variables of the object. It's a good practice to always declare your variables here and give them a default value - do it to benefit from this new simplified syntax, which will make your formulas and expressions much more readable.
* When you rename a variable in an editor, it will now rename the variables everywhere in the events of the project. This makes it much easier to change the name of a variable if you find a better one. Note that this works for "rootæ variables, but not variables inside structures or arrays.
2023-09-21 18:56:12 +02:00
Florian Rival 2e9a5ee287 Fix ExpressionParser2 tests (#5654)
Don't show in changelog
2023-09-13 12:54:09 +02:00
D8H 18e8020bf5 Simplify the list of actions/conditions by removing duplicated actions/conditions that are common between objects (#5494)
* Actions, conditions and expressions related to opacity, size (width/height), scale, animations and other common features are now visible only once when you search for them in actions/conditions (instead of being shown once for every type of object supporting them). This reduces the risk of confusion for new or existing users, notably when multiple versions of the same action were returned by the search and was making it difficult to choose the proper one.
* Internally, this works thanks to default, built-in behaviors that are supported by the objects.
2023-08-25 11:11:55 +02:00
Florian Rival 4a4bf6d761 Add support for unicode names (any character, including emojis) for object/group/behavior/extension/function names (#5564)
* In other words: this allows to use emojis, accented characters, CJK languages and any word from any language to name anything in GDevelop. This should be very useful for non english speaking users.
* This must be activated in the preferences of GDevelop. This will be activated by default once this is proven to work without bugs.
2023-08-14 21:46:10 +02:00
D8H 73e1ea5ff1 Fix missing errors when a variable name is used alone in an expression (#5203) 2023-04-05 12:01:43 +02:00
D8H e8687119c9 Fix errors not being displayed in expressions when an object or a behavior doesn't exist (#5146)
* GDevelop will now warn when an object (or group of objects) written in an expression is misspelled or does not exist in the scene.
2023-03-27 13:55:23 +02:00
D8H e7d213534e Revert: Report errors in expressions when an object or a behavior doesn't exist (#5118) (#5134)
Do not show in changelog
2023-03-20 15:08:40 +01:00
D8H 48ae688873 Report errors in expressions when an object or a behavior doesn't exist (#5118) 2023-03-17 15:24:24 +01:00
D8H 763aa0aa25 Show expression errors directly in the event sheet (#3823) 2022-06-03 23:02:51 +02:00
Florian Rival 71e3b65134 Add a new "Text input" object (#3508)
* This object displays a field where the player can type a text.
* The cursor can be moved and the text can be selected and entered like any other input field according to the platform. For example, you can use all the usual keyboard shortcuts or emoji pickers on desktop. On mobile, all the usual gestures are supported, emoji pickers, text selection, clipboard...
* You can choose between different input field types: text, text area, email, password, phone number... This allows the keyboards to be adapted on mobile devices. The password field will also hide what is entered by the user.
  * Because the object is way more convenient to use (and actually works on mobile devices) than the Text Entry object, it is recommended you use it almost always instead of the Text Entry object.
* This object has 2 limitations, because it's using the native capabilities of the platform to display a "native" input field: the Z order can't be changed (the object is *always* displayed on top of the game) and no effects can be displayed. Because it's handled by the operating system, it may also slightly differ on each platform.
  * It's recommended you avoid displaying the object outside of a menu or a static UI, as it may not always display exactly at a position synchronised with the rest of the rendering of the game, especially if used in a fast paced or moving scene.
2022-02-13 15:18:31 +01:00
Clément Pasteau cf5c8ae631 Improve Expression autocomplete for functions 2021-10-18 13:22:01 +02:00
Florian Rival 6526e8ad8a Allow to enter numbers when accessing to a variable child with brackets notation (e.g: MyVariable[2]) (#2380) 2021-02-22 14:29:06 +01:00
Florian Rival deddfdc4cf Fix ObjectVarToJSON expression not working
Fix #2097
2020-11-16 23:03:49 +00:00
Florian Rival faa02d4459 Add proper handling of closing parenthesis in ExpressionCompletionFinder 2020-03-11 17:41:52 +00:00
Florian Rival 22c6a57394 Improve completions from ExpressionCompletionFinder 2020-03-02 22:11:31 +00:00
Florian Rival 94ac7166ed Add more tests for ExpressionParser2 2020-03-01 19:00:18 +00:00
Florian Rival 88b20240ff Fix location of identifier (function names, etc...) with trailing whitespaces 2020-03-01 18:40:30 +00:00
Florian Rival af93149f6a Add more location information in ExpressionParser nodes
Also fix some whitespace sensitivity of the parser
2020-03-01 17:37:21 +00:00
Florian Rival 4e59573042 Speed up identifiers and other character parsing in ExpressionParser2 2020-02-23 19:41:53 +00:00
Florian Rival ca6f11b55a Support for describing completions to display for an expression (#1447) 2020-02-22 14:27:43 +00:00
Florian Rival d544319302 Add location in ExpressionParser2 and ExpressionNodeLocationFinder 2020-02-11 08:20:09 +00:00
Florian Rival 9c6c8564fa Fix handling of object parameters in expressions 2019-01-28 23:16:20 +00:00
Florian Rival 4b33373296 Fix ConvertToString and code generation for strings with backlash/escaped characters 2019-01-28 23:16:20 +00:00
Florian Rival 0d864ce6a7 Update error message and add test case 2019-01-28 23:16:20 +00:00
Florian Rival 93708cb2f3 Properly handle numbers with leading 0 (normalize them to remove the extra 0) 2019-01-28 23:16:19 +00:00
Florian Rival 3035bc9386 Improve error messages for empty expressions 2019-01-28 23:16:19 +00:00
Florian Rival 4c789967c3 Fix code generation of invalid variable expressions 2019-01-28 23:16:19 +00:00
Florian Rival df68978adc Add edge cases fixes and fuzzy tests for ExpressionParser2 2019-01-28 23:16:19 +00:00
Florian Rival 7a87fd9924 Add support for unary operator in ExpressionParser2 2019-01-28 23:16:19 +00:00
Florian Rival 8d1502cb20 Fix parsing of behaviors expressions 2019-01-28 23:16:19 +00:00
Florian Rival 4fd88072e9 Improve ExpressionParser2 and use it for GenericExpressionField and EventsRefactorer 2019-01-28 23:16:19 +00:00
Florian Rival f2e6f19c34 Add ExpressionParser2NodePrinter 2019-01-28 23:16:18 +00:00
Florian Rival 66029c62ed Add Variable code generation for ExpressionParser2 2019-01-28 23:16:18 +00:00
Florian Rival 43d78a74bd Enhance ExpressionParser2 and add ExpressionCodeGenerator 2019-01-28 23:16:18 +00:00