Add shaderlib function to autocomplete with, check which files are included - implements #25

This commit is contained in:
ChaoticByte 2024-12-29 21:32:54 +01:00
parent 7f1415dada
commit 3abaf38400
No known key found for this signature in database

View file

@ -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)
#
# # # # # # # # # # # #