Split node scripts into subfolders and use subfolder names as category names (#48)

fixes #41

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/48
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-01-20 05:02:57 +00:00 committed by yagich
parent 43cd05c79d
commit 7ef913c13b
38 changed files with 27 additions and 56 deletions

View file

@ -31,9 +31,6 @@ var node_type: String
var description: String
## A list of aliases for this node, used by search.
var aliases: Array[String]
## The category of this node. Must be snake_case. This is additional data which
## a renderer can optionally show to the user.
var category: String
## Controls whether this node should appear in [SearchProvider].
var appears_in_search: bool = true

View file

@ -28,13 +28,21 @@ func _init() -> void:
#if load_node_index():
#return
var dir := DirAccess.open(BASE_NODE_PATH)
create_descriptors(BASE_NODE_PATH)
save_node_index()
func create_descriptors(path: String) -> void:
var dir := DirAccess.open(path)
dir.list_dir_begin()
var current_file := dir.get_next()
while current_file != "":
#print(current_file)
if dir.current_is_dir():
create_descriptors(path.path_join(current_file))
else:
if current_file.ends_with(".gd"):
var script_path := BASE_NODE_PATH.path_join(current_file)
var script_path := path.path_join(current_file)
var node: DeckNode = load(script_path).new() as DeckNode
var aliases: String = node.aliases.reduce(
func(accum, el) -> void:
@ -46,13 +54,12 @@ func _init() -> void:
node.node_type,
node.description,
aliases,
node.category,
path.get_slice("/", path.get_slice_count("/") - 1),
node.appears_in_search,
)
nodes[node.node_type] = descriptor
current_file = dir.get_next()
save_node_index()
## Helper Function that instances a [DeckNode] based off of it's [member DeckNode.node_type]
func instance_node(type: String) -> DeckNode:

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Get Array Index"
node_type = "array_get_index"
description = "Returns an element from an array. 0-indexed."
category = "general"
add_input_port(
DeckType.Types.ARRAY,

View file

@ -7,7 +7,6 @@ extends DeckNode
func _init() -> void:
name = "Bool Constant"
node_type = name.to_snake_case()
category = "general"
description = "A checkbox."
add_output_port(

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Button"
node_type = "button"
description = "A button to trigger certain nodes that have a trigger input."
category = "general"
add_output_port(
DeckType.Types.BOOL,

View file

@ -9,7 +9,6 @@ func _init():
name = "Delay"
node_type = name.to_snake_case()
description = "A node that passes through its' input after the set time."
category = "general"
add_output_port(DeckType.Types.ANY, "Value")

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Get Dictionary Key"
node_type = "dictionary_get_key"
description = "Returns the value of a key from a dictionary input, if it exists, or null otherwise."
category = "general"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -9,7 +9,6 @@ func _init():
name = "Expression"
node_type = name.to_snake_case()
description = "A node returning the result of a mathematical expression."
category = "general"
props_to_serialize = []

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Get Deck Var"
node_type = name.to_snake_case()
description = "Retrieve a deck variable."
category = "general"
add_output_port(
DeckType.Types.ANY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Pass If True"
node_type = "if_true"
description = "Pass input if and only if the condition input is true."
category = "general"
add_input_port(
DeckType.Types.BOOL,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Compare Values"
node_type = "is_equal"
description = "Returns true if the values are equal, false otherwise."
category = "general"
add_input_port(
DeckType.Types.ANY,

View file

@ -12,7 +12,6 @@ func _init() -> void:
description = "Print a value to the console."
props_to_serialize = [&"times_activated"]
category = "general"
add_input_port(
DeckType.Types.ANY,

View file

@ -10,7 +10,6 @@ func _init() -> void:
name = "Process Loop"
node_type = name.to_snake_case()
description = "Sends a trigger output every frame, and returns the delta value (time since last frame in seconds)."
category = "general"
add_input_port(
DeckType.Types.BOOL,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Set Deck Var"
node_type = name.to_snake_case()
description = "Set a deck variable on trigger."
category = "general"
add_input_port(
DeckType.Types.STRING,

View file

@ -7,7 +7,6 @@ extends DeckNode
func _init() -> void:
node_type = "string_constant"
name = "String Constant"
category = "general"
description = "A String field."
add_output_port(

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Split String"
node_type = "string_split"
description = "Splits a string by a delimiter."
category = "general"
add_input_port(
DeckType.Types.STRING,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Add Vectors"
node_type = "vector_add"
description = "Adds two 2D vectors."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Compose Vector"
node_type = "vector_compose"
description = "Returns a vector from two numeric inputs."
category = "math"
add_input_port(
DeckType.Types.NUMERIC,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Decompose Vector"
node_type = "vector_decompose"
description = "Returns the X and Y components of a vector."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Vector Dot Product"
node_type = "vector_dot"
description = "Returns the dot product of two vectors."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Multiply Vector by Scalar"
node_type = "vector_multiply"
description = "Multiplies a vector by a numeric value."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Normalize Vector"
node_type = "vector_normalize"
description = "Normalizes a vector so its' length (magnitude) is exactly 1."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Subtract Vectors"
node_type = "vector_subtract"
description = "Subtracts each component of the given vectors."
category = "math"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Decompose OBS Transform"
node_type = "obs_decompose_transform"
description = "Splits an OBS transform from one object into multiple outputs."
category = "obs"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -10,7 +10,6 @@ func _init() -> void:
name = "Scene Selector"
node_type = "obs_scene_list"
description = ""
category = "obs"
props_to_serialize = []

View file

@ -14,7 +14,6 @@ func _init() -> void:
name = "Get Source ID"
node_type = "obs_search_source"
description = "Searches for an OBS source in a scene and returns its output."
category = "obs"
add_input_port(
DeckType.Types.STRING,

View file

@ -19,7 +19,6 @@ func _init() -> void:
name = "Set Source Transform"
node_type = "obs_set_source_transform"
description = "Sets an OBS source's transform, which includes position and rotation, among other things."
category = "obs"
props_to_serialize = []

View file

@ -9,7 +9,6 @@ func _init() -> void:
name = "Set Scene"
node_type = "obs_set_scene"
description = "Sets the current scene in OBS."
category = "obs"
props_to_serialize = []

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Vector to OBS Position"
node_type = "obs_vector_to_position"
description = "Transforms a Vector into a position vector accepted by OBS transform inputs."
category = "obs"
add_input_port(
DeckType.Types.DICTIONARY,

View file

@ -10,7 +10,6 @@ func _init() -> void:
name = "OBS WS Generic Request"
node_type = "obs_generic_request"
description = "Makes an OBS request and sends its result through. Use if if you really know what you're doing."
category = "obs"
props_to_serialize = []

View file

@ -7,7 +7,6 @@ extends DeckNode
func _init() -> void:
node_type = "test_interleaved"
name = "Test Interleaved"
category = "test"
for i in 4:
add_output_port(

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = "Types Test"
node_type = name.to_snake_case()
description = ""
category = "test"
props_to_serialize = []

View file

@ -13,7 +13,6 @@ func _init():
name = "Twitch Chat Received"
node_type = "twitch_chat_received"
description = "Receives Twitch chat events from a Twitch connection."
category = "twitch"
add_output_port(DeckType.Types.STRING, "Username")
add_output_port(DeckType.Types.STRING, "Message")

View file

@ -8,7 +8,6 @@ func _init():
name = "Twitch Send Chat"
node_type = "twitch_send_chat"
description = "Sends a message to a Twitch chat."
category = "twitch"
add_input_port(
DeckType.Types.STRING,

View file

@ -8,7 +8,6 @@ func _init() -> void:
name = ""
node_type = name.to_snake_case()
description = ""
category = ""
props_to_serialize = []