Skip to content
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

Unify variable instructions and handle local variables #6459

Merged
merged 145 commits into from May 20, 2024
Merged

Conversation

D8H
Copy link
Collaborator

@D8H D8H commented Mar 14, 2024

Changes

  • Global or scene variables can be used with a unique action and condition.
    • Merged from 6 conditions and 7 actions to 1 condition and 1 action:
      • global or scene variable
      • string, number and boolean
  • Object variables can be used with a unique action and condition.
    • Merged from 3 conditions and 4 actions to 1 condition and 1 action:
      • object variable
      • string, number and boolean
  • Instructions for string, number and boolean are actually 3 instructions but the editor switch them according to the chosen variable type
  • 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:

Out of scope

  • Declare a scene/global/object variable from an expression field.
  • Drag and drop local variables from one event to another
  • Select and delete local variables directly from the event sheet
  • Edit local variables with floating fields directly from the event sheet
  • Scroll and focus on the variable name field when opening the variable editor
  • Warn about variables overlapping another one from a wider scope
  • Suffix identical labels with the path difference in instruction search results
  • Declare local variables on any kind of event?
  • Implicitly convert numbers to strings in expressions
  • Make "For each children" loop accept global variables
  • Replace scene variable parameters in other instructions

Demo

This command can help to migrate a project (which is not mandatory to do).

You will still have to:

  • Update/Reinstall the extensions because they cannot use them yet (or revert the changes with git, they are at the end of the file)
  • Declare the variables with the right type (or use a local variable)
  • Optionally remove Variable() and GlobalVariable()
  • Optionally replace variable toggle actions
sed -i 's/"VarScene"\|"VarGlobal"/"NumberVariable"/g ; s/"VarSceneTxt"\|"VarGlobalTxt"/"StringVariable"/g ; s/"SceneVariableAsBoolean"\|"GlobalVariableAsBoolean"/"BooleanVariable"/g ; s/"ModVarScene"\|"ModVarGlobal"/"SetNumberVariable"/g ; s/"ModVarSceneTxt"\|"ModVarGlobalTxt"/"SetStringVariable"/g ; s/"SetSceneVariableAsBoolean"\|"SetGlobalVariableAsBoolean"/"SetBooleanVariable"/g ; s/"SceneVariableChildCount"\|"GlobalVariableChildCount"/"VariableChildCount"/g ; s/"VariableChildExists"\|"GlobalVariableChildExists"/"VariableChildExists2"/g ; s/"VariableRemoveChild"\|"GlobalVariableRemoveChild"/"RemoveVariableChild"/g ; s/"VariableClearChildren"\|"GlobalVariableClearChildren"/"ClearVariableChildren"/g ; s/"SceneVariablePush"\|"GlobalVariablePush"/"PushVariable"/g ; s/"SceneVariablePushNumber"\|"GlobalVariablePushNumber"/"PushNumber"/g ; s/"SceneVariablePushString"\|"GlobalVariablePushString"/"PushString"/g ; s/"SceneVariablePushBool"\|"GlobalVariablePushBool"/"PushBoolean"/g ; s/"SceneVariableRemoveAt"\|"GlobalVariableRemoveAt"/"RemoveVariableAt"/g ; s/"VarObjet"/"NumberObjectVariable"/g ; s/"VarObjetTxt"/"StringObjectVariable"/g ; s/"ObjectVariableAsBoolean"/"BooleanObjectVariable"/g ; s/"ModVarObjet"/"SetNumberObjectVariable"/g ; s/"ModVarObjetTxt"/"SetStringObjectVariable"/g ; s/"SetObjectVariableAsBoolean"/"SetBooleanObjectVariable"/g ; s/"ObjectVariablePushNumber"/"PushNumberToObjectVariable"/g ; s/"ObjectVariablePushString"/"PushStringToObjectVariable"/g ; s/"ObjectVariablePushBool"/"PushBooleanToObjectVariable"/g' project.json

@D8H D8H force-pushed the unify-variable branch 2 times, most recently from ee0b072 to 8965c1a Compare March 15, 2024 20:07
@@ -1298,7 +1298,20 @@ gd::String EventsCodeGenerator::GenerateGetVariable(
const gd::String& objectName) {
gd::String output;
const gd::VariablesContainer* variables = NULL;
if (scope == LAYOUT_VARIABLE) {
if (scope == ANY_VARIABLE) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be interesting to see if we can pass here a VariablesContainersList at some point so the work of scoping is always done by a method of VariablesContainersList.

@D8H D8H force-pushed the unify-variable branch 3 times, most recently from 769c0fb to df3232c Compare March 29, 2024 18:56
@D8H D8H force-pushed the unify-variable branch 5 times, most recently from b466237 to 0a85259 Compare April 9, 2024 16:47
@D8H D8H mentioned this pull request Apr 18, 2024
@D8H D8H changed the title WIP: Unify variable instructions Unify variable instructions and handle local variables Apr 18, 2024
@D8H D8H marked this pull request as ready for review April 25, 2024 13:12
GDevelop.js/CMakeLists.txt Outdated Show resolved Hide resolved
@D8H D8H merged commit 75bfa5c into master May 20, 2024
5 of 6 checks passed
@D8H D8H deleted the unify-variable branch May 20, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants