4ian / GDevelop

:video_game: Open-source, cross-platform game engine designed to be used by everyone.

Home Page:https://gdevelop.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve undeclared variables tip in the variable editor

AlexandreSi opened this issue · comments

Description

When editing Global/Scene/Object variables, there's a tip explaining that some variables are used in the event sheet but are not declared. While this is useful to detect misuses or clean a project's variables use, it doesn't work perfectly well because it doesn't take into account the refactoring: if you have a variable TotalGold that is used in the events sheet and decide to rename it Gold, the tip will appear telling you that the variable TotalGold is not declared.

Also, the tips appear in the instance variables but I'm not sure it's useful there. Or it should say that the variable XXX is not declared and that it should be changed at the object level, not the instance level.

Solution suggested

The tip should take into account that the refactoring will rename the variables in the events sheet and then should display nothing.

Technically speaking, I think that on each renaming operation, the changeset should be computed and use the oldToNewVariableNames data structure to know if some variables are truly undeclared or not.
The changeset is currently a struct in C++ and might need to be converted into a class in order to be used by Javascript.

I dislike how undeclared variables were removed from showing up in the event sheet. We shouldn't be required to declare them.