mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
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:
parent
43cd05c79d
commit
7ef913c13b
38 changed files with 27 additions and 56 deletions
|
@ -31,9 +31,6 @@ var node_type: String
|
||||||
var description: String
|
var description: String
|
||||||
## A list of aliases for this node, used by search.
|
## A list of aliases for this node, used by search.
|
||||||
var aliases: Array[String]
|
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].
|
## Controls whether this node should appear in [SearchProvider].
|
||||||
var appears_in_search: bool = true
|
var appears_in_search: bool = true
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,21 @@ func _init() -> void:
|
||||||
#if load_node_index():
|
#if load_node_index():
|
||||||
#return
|
#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()
|
dir.list_dir_begin()
|
||||||
var current_file := dir.get_next()
|
var current_file := dir.get_next()
|
||||||
while current_file != "":
|
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"):
|
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 node: DeckNode = load(script_path).new() as DeckNode
|
||||||
var aliases: String = node.aliases.reduce(
|
var aliases: String = node.aliases.reduce(
|
||||||
func(accum, el) -> void:
|
func(accum, el) -> void:
|
||||||
|
@ -46,13 +54,12 @@ func _init() -> void:
|
||||||
node.node_type,
|
node.node_type,
|
||||||
node.description,
|
node.description,
|
||||||
aliases,
|
aliases,
|
||||||
node.category,
|
path.get_slice("/", path.get_slice_count("/") - 1),
|
||||||
node.appears_in_search,
|
node.appears_in_search,
|
||||||
)
|
)
|
||||||
nodes[node.node_type] = descriptor
|
nodes[node.node_type] = descriptor
|
||||||
current_file = dir.get_next()
|
current_file = dir.get_next()
|
||||||
|
|
||||||
save_node_index()
|
|
||||||
|
|
||||||
## Helper Function that instances a [DeckNode] based off of it's [member DeckNode.node_type]
|
## Helper Function that instances a [DeckNode] based off of it's [member DeckNode.node_type]
|
||||||
func instance_node(type: String) -> DeckNode:
|
func instance_node(type: String) -> DeckNode:
|
||||||
|
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Get Array Index"
|
name = "Get Array Index"
|
||||||
node_type = "array_get_index"
|
node_type = "array_get_index"
|
||||||
description = "Returns an element from an array. 0-indexed."
|
description = "Returns an element from an array. 0-indexed."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.ARRAY,
|
DeckType.Types.ARRAY,
|
|
@ -7,7 +7,6 @@ extends DeckNode
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
name = "Bool Constant"
|
name = "Bool Constant"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
category = "general"
|
|
||||||
description = "A checkbox."
|
description = "A checkbox."
|
||||||
|
|
||||||
add_output_port(
|
add_output_port(
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Button"
|
name = "Button"
|
||||||
node_type = "button"
|
node_type = "button"
|
||||||
description = "A button to trigger certain nodes that have a trigger input."
|
description = "A button to trigger certain nodes that have a trigger input."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_output_port(
|
add_output_port(
|
||||||
DeckType.Types.BOOL,
|
DeckType.Types.BOOL,
|
|
@ -9,7 +9,6 @@ func _init():
|
||||||
name = "Delay"
|
name = "Delay"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = "A node that passes through its' input after the set time."
|
description = "A node that passes through its' input after the set time."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_output_port(DeckType.Types.ANY, "Value")
|
add_output_port(DeckType.Types.ANY, "Value")
|
||||||
|
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Get Dictionary Key"
|
name = "Get Dictionary Key"
|
||||||
node_type = "dictionary_get_key"
|
node_type = "dictionary_get_key"
|
||||||
description = "Returns the value of a key from a dictionary input, if it exists, or null otherwise."
|
description = "Returns the value of a key from a dictionary input, if it exists, or null otherwise."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -9,7 +9,6 @@ func _init():
|
||||||
name = "Expression"
|
name = "Expression"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = "A node returning the result of a mathematical expression."
|
description = "A node returning the result of a mathematical expression."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Get Deck Var"
|
name = "Get Deck Var"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = "Retrieve a deck variable."
|
description = "Retrieve a deck variable."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_output_port(
|
add_output_port(
|
||||||
DeckType.Types.ANY,
|
DeckType.Types.ANY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Pass If True"
|
name = "Pass If True"
|
||||||
node_type = "if_true"
|
node_type = "if_true"
|
||||||
description = "Pass input if and only if the condition input is true."
|
description = "Pass input if and only if the condition input is true."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.BOOL,
|
DeckType.Types.BOOL,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Compare Values"
|
name = "Compare Values"
|
||||||
node_type = "is_equal"
|
node_type = "is_equal"
|
||||||
description = "Returns true if the values are equal, false otherwise."
|
description = "Returns true if the values are equal, false otherwise."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.ANY,
|
DeckType.Types.ANY,
|
|
@ -12,7 +12,6 @@ func _init() -> void:
|
||||||
description = "Print a value to the console."
|
description = "Print a value to the console."
|
||||||
|
|
||||||
props_to_serialize = [&"times_activated"]
|
props_to_serialize = [&"times_activated"]
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.ANY,
|
DeckType.Types.ANY,
|
|
@ -10,7 +10,6 @@ func _init() -> void:
|
||||||
name = "Process Loop"
|
name = "Process Loop"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = "Sends a trigger output every frame, and returns the delta value (time since last frame in seconds)."
|
description = "Sends a trigger output every frame, and returns the delta value (time since last frame in seconds)."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.BOOL,
|
DeckType.Types.BOOL,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Set Deck Var"
|
name = "Set Deck Var"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = "Set a deck variable on trigger."
|
description = "Set a deck variable on trigger."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.STRING,
|
DeckType.Types.STRING,
|
|
@ -7,7 +7,6 @@ extends DeckNode
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
node_type = "string_constant"
|
node_type = "string_constant"
|
||||||
name = "String Constant"
|
name = "String Constant"
|
||||||
category = "general"
|
|
||||||
description = "A String field."
|
description = "A String field."
|
||||||
|
|
||||||
add_output_port(
|
add_output_port(
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Split String"
|
name = "Split String"
|
||||||
node_type = "string_split"
|
node_type = "string_split"
|
||||||
description = "Splits a string by a delimiter."
|
description = "Splits a string by a delimiter."
|
||||||
category = "general"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.STRING,
|
DeckType.Types.STRING,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Add Vectors"
|
name = "Add Vectors"
|
||||||
node_type = "vector_add"
|
node_type = "vector_add"
|
||||||
description = "Adds two 2D vectors."
|
description = "Adds two 2D vectors."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Compose Vector"
|
name = "Compose Vector"
|
||||||
node_type = "vector_compose"
|
node_type = "vector_compose"
|
||||||
description = "Returns a vector from two numeric inputs."
|
description = "Returns a vector from two numeric inputs."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.NUMERIC,
|
DeckType.Types.NUMERIC,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Decompose Vector"
|
name = "Decompose Vector"
|
||||||
node_type = "vector_decompose"
|
node_type = "vector_decompose"
|
||||||
description = "Returns the X and Y components of a vector."
|
description = "Returns the X and Y components of a vector."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Vector Dot Product"
|
name = "Vector Dot Product"
|
||||||
node_type = "vector_dot"
|
node_type = "vector_dot"
|
||||||
description = "Returns the dot product of two vectors."
|
description = "Returns the dot product of two vectors."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Multiply Vector by Scalar"
|
name = "Multiply Vector by Scalar"
|
||||||
node_type = "vector_multiply"
|
node_type = "vector_multiply"
|
||||||
description = "Multiplies a vector by a numeric value."
|
description = "Multiplies a vector by a numeric value."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Normalize Vector"
|
name = "Normalize Vector"
|
||||||
node_type = "vector_normalize"
|
node_type = "vector_normalize"
|
||||||
description = "Normalizes a vector so its' length (magnitude) is exactly 1."
|
description = "Normalizes a vector so its' length (magnitude) is exactly 1."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Subtract Vectors"
|
name = "Subtract Vectors"
|
||||||
node_type = "vector_subtract"
|
node_type = "vector_subtract"
|
||||||
description = "Subtracts each component of the given vectors."
|
description = "Subtracts each component of the given vectors."
|
||||||
category = "math"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Decompose OBS Transform"
|
name = "Decompose OBS Transform"
|
||||||
node_type = "obs_decompose_transform"
|
node_type = "obs_decompose_transform"
|
||||||
description = "Splits an OBS transform from one object into multiple outputs."
|
description = "Splits an OBS transform from one object into multiple outputs."
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -10,7 +10,6 @@ func _init() -> void:
|
||||||
name = "Scene Selector"
|
name = "Scene Selector"
|
||||||
node_type = "obs_scene_list"
|
node_type = "obs_scene_list"
|
||||||
description = ""
|
description = ""
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -14,7 +14,6 @@ func _init() -> void:
|
||||||
name = "Get Source ID"
|
name = "Get Source ID"
|
||||||
node_type = "obs_search_source"
|
node_type = "obs_search_source"
|
||||||
description = "Searches for an OBS source in a scene and returns its output."
|
description = "Searches for an OBS source in a scene and returns its output."
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.STRING,
|
DeckType.Types.STRING,
|
|
@ -19,7 +19,6 @@ func _init() -> void:
|
||||||
name = "Set Source Transform"
|
name = "Set Source Transform"
|
||||||
node_type = "obs_set_source_transform"
|
node_type = "obs_set_source_transform"
|
||||||
description = "Sets an OBS source's transform, which includes position and rotation, among other things."
|
description = "Sets an OBS source's transform, which includes position and rotation, among other things."
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -9,7 +9,6 @@ func _init() -> void:
|
||||||
name = "Set Scene"
|
name = "Set Scene"
|
||||||
node_type = "obs_set_scene"
|
node_type = "obs_set_scene"
|
||||||
description = "Sets the current scene in OBS."
|
description = "Sets the current scene in OBS."
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Vector to OBS Position"
|
name = "Vector to OBS Position"
|
||||||
node_type = "obs_vector_to_position"
|
node_type = "obs_vector_to_position"
|
||||||
description = "Transforms a Vector into a position vector accepted by OBS transform inputs."
|
description = "Transforms a Vector into a position vector accepted by OBS transform inputs."
|
||||||
category = "obs"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.DICTIONARY,
|
DeckType.Types.DICTIONARY,
|
|
@ -10,7 +10,6 @@ func _init() -> void:
|
||||||
name = "OBS WS Generic Request"
|
name = "OBS WS Generic Request"
|
||||||
node_type = "obs_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."
|
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 = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -7,7 +7,6 @@ extends DeckNode
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
node_type = "test_interleaved"
|
node_type = "test_interleaved"
|
||||||
name = "Test Interleaved"
|
name = "Test Interleaved"
|
||||||
category = "test"
|
|
||||||
|
|
||||||
for i in 4:
|
for i in 4:
|
||||||
add_output_port(
|
add_output_port(
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = "Types Test"
|
name = "Types Test"
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = ""
|
description = ""
|
||||||
category = "test"
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
|
@ -13,7 +13,6 @@ func _init():
|
||||||
name = "Twitch Chat Received"
|
name = "Twitch Chat Received"
|
||||||
node_type = "twitch_chat_received"
|
node_type = "twitch_chat_received"
|
||||||
description = "Receives Twitch chat events from a Twitch connection."
|
description = "Receives Twitch chat events from a Twitch connection."
|
||||||
category = "twitch"
|
|
||||||
|
|
||||||
add_output_port(DeckType.Types.STRING, "Username")
|
add_output_port(DeckType.Types.STRING, "Username")
|
||||||
add_output_port(DeckType.Types.STRING, "Message")
|
add_output_port(DeckType.Types.STRING, "Message")
|
|
@ -8,7 +8,6 @@ func _init():
|
||||||
name = "Twitch Send Chat"
|
name = "Twitch Send Chat"
|
||||||
node_type = "twitch_send_chat"
|
node_type = "twitch_send_chat"
|
||||||
description = "Sends a message to a Twitch chat."
|
description = "Sends a message to a Twitch chat."
|
||||||
category = "twitch"
|
|
||||||
|
|
||||||
add_input_port(
|
add_input_port(
|
||||||
DeckType.Types.STRING,
|
DeckType.Types.STRING,
|
|
@ -8,7 +8,6 @@ func _init() -> void:
|
||||||
name = ""
|
name = ""
|
||||||
node_type = name.to_snake_case()
|
node_type = name.to_snake_case()
|
||||||
description = ""
|
description = ""
|
||||||
category = ""
|
|
||||||
|
|
||||||
props_to_serialize = []
|
props_to_serialize = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue