Error Checking and Detecting Unused Variables Functionality #1040
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added an error checking button and a checking for unused variables button to both the flowchart window and the flowchart editor. This serves as a "sanity check" that finds the issues in the current flowchart, colouring commands/blocks red, and/or prints out the issues found in the log so users may correct these problems faster.
What is the current behavior?
Currently, if there is a missing targetBlock in a Call command, a missing returnValue in an IF command, it's difficult to find the problem.
What is the new behavior?
2.a If "remove unused variables" is enabled, it removes all unused variables from the list as well.
Important Notes
Most commands already have "Error: [...]" in their summary when a targetBlock or parameters are null. Additionally:
(There are potentially other areas where the summary could be updated in this manner, for example menuDialog being null in Menu commands, MenuTimer having 0 time, VO clip missing from a Say command (probably needs a bool to enable this check, I presume some people dont plan to have VO) and so on.)
Adjusted the CommandListAdaptor, so that it colours the commands red when they contain an error, and their text white for readability, so users can find issues easier.
Added an override void "ErrorCheck" to the Command.cs, triggered by pressing the "Check For Errors" button in the flowchart editor or window. It prints out warnings in the log if it detects an IF or ELSEIF command having a null returnValue.
The IF and ELSEIF commands now can return their returnValue keys via GetReturnValueName() to the Flowchart.cs upon pressing the "Check for Unused Variables" button in the flowchart editor or window, which compares the full list of variables against the list of returned, used variables.
Possibly something that could extend to covering Invoke Method and Invoke Event commands. Just not sure how to implement that.
Screenshots