Separate visual shader code out of shader editor plugin and dialog #112100
+527
−204
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.
Last cleanup PR before actually moving visual shaders to a module: #64596
This PR moves the language-specific code out of
ShaderCreateDialog. Its API ofconfighas been changed to work with Strings for the type, instead of a hard-coded index. A small number of remaining hacks, such as things only working for text shaders, are indicated as comments - but not that these caveats were already present in the existing code, unmarked.The language-specific code now lives in classes that derive
EditorShaderLanguagePlugin. TheTextShaderLanguagePluginclass provides editor integration for text shaders, and theVisualShaderLanguagePluginclass provides editor integration for visual shaders.The base
EditorShaderLanguagePluginitself has static functions for registering shader languages in the editor (not to be confused with the non-editor code). Registered languages are consumed byShaderCreateDialogandShaderEditorPlugin, for populating the create dialog, and editing existing shaders, respectively.The primary motivation behind this abstraction is to allow moving visual shaders to a module. However, this also allows for users to register new shader types in the editor. The API for doing this is not exposed, so it is not available for GDScript or GDExtension, but it can be used with modules. We should not lock ourselves in to any particular API for registering shader types unless we have a good use case first, therefore I intentionally kept this unexposed.
The exposed functionality from the user's perspective should be the same, except that the dialog's list of types now has the order "Shader, ShaderInclude, VisualShader" instead of "Shader, VisualShader, ShaderInclude", which makes sense because it groups the text-based ones together. This PR doesn't try to expand functionality, for example, shader templates are text-shader-only the same as it is in master.