Add shaderlib function to autocomplete with, check which files are included - implements #25
This commit is contained in:
parent
7f1415dada
commit
3abaf38400
1 changed files with 17 additions and 0 deletions
|
@ -121,6 +121,15 @@ const gdshader_builtins = [
|
|||
"POINT_COORD",
|
||||
"SPECULAR_SHININESS"
|
||||
]
|
||||
# shaderlib
|
||||
var shaderlib_regex = {
|
||||
"hsv": RegEx.create_from_string(r'\s*\#include\s+\"res\:\/\/shaderlib\/hsv\.gdshaderinc\"'),
|
||||
"transform": RegEx.create_from_string(r'\s*\#include\s+\"res\:\/\/shaderlib\/transform\.gdshaderinc\"')
|
||||
}
|
||||
const shaderlib_functions = {
|
||||
"hsv": ["rgb2hsv", "hsv2rgb", "hsv_offset", "hsv_multiply"],
|
||||
"transform": ["place_texture"]
|
||||
}
|
||||
#
|
||||
# configure Highlighter
|
||||
#
|
||||
|
@ -171,6 +180,14 @@ func _on_code_edit_code_completion_requested():
|
|||
for k in gdshader_builtin_functions + gdshader_sub_functions:
|
||||
code_editor.code_completion_prefixes.append(k)
|
||||
code_editor.add_code_completion_option(CodeEdit.KIND_FUNCTION, k, k+"(", Color.INDIAN_RED)
|
||||
# shaderlib #
|
||||
var shader_code = code_editor.text
|
||||
for key in shaderlib_functions:
|
||||
if shaderlib_regex[key].search(shader_code) != null:
|
||||
for k in shaderlib_functions[key]:
|
||||
code_editor.code_completion_prefixes.append(k)
|
||||
code_editor.add_code_completion_option(CodeEdit.KIND_FUNCTION, k, k+"(", Color.INDIAN_RED)
|
||||
# # # # # # #
|
||||
code_editor.update_code_completion_options(true)
|
||||
#
|
||||
# # # # # # # # # # # #
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue