mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add bool constant and if true nodes
This commit is contained in:
parent
26bf7cf0b3
commit
dbdda4614a
3 changed files with 53 additions and 1 deletions
20
classes/deck/nodes/bool_constant.gd
Normal file
20
classes/deck/nodes/bool_constant.gd
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
extends DeckNode
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
name = "Bool Constant"
|
||||||
|
node_type = name.to_snake_case()
|
||||||
|
category = "general"
|
||||||
|
|
||||||
|
add_output_port(
|
||||||
|
DeckType.Types.BOOL,
|
||||||
|
"Value",
|
||||||
|
"checkbox"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _value_request(_from_port: int) -> Variant:
|
||||||
|
if ports[0].value_callback.get_object():
|
||||||
|
return ports[0].value_callback.call()
|
||||||
|
else:
|
||||||
|
return ports[0].value
|
33
classes/deck/nodes/if_true.gd
Normal file
33
classes/deck/nodes/if_true.gd
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
extends DeckNode
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
"Condition",
|
||||||
|
"checkbox"
|
||||||
|
)
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.ANY,
|
||||||
|
"Input"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_output_port(
|
||||||
|
DeckType.Types.ANY,
|
||||||
|
"Output"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
|
||||||
|
if to_input_port != 1:
|
||||||
|
return
|
||||||
|
|
||||||
|
if !request_value(0):
|
||||||
|
return
|
||||||
|
|
||||||
|
send(0, data, extra_data)
|
|
@ -178,7 +178,6 @@ func _on_category_collapse_toggled(collapsed: bool, category: String) -> void:
|
||||||
class Category extends VBoxContainer:
|
class Category extends VBoxContainer:
|
||||||
const COLLAPSE_ICON := preload("res://graph_node_renderer/textures/collapse-icon.svg")
|
const COLLAPSE_ICON := preload("res://graph_node_renderer/textures/collapse-icon.svg")
|
||||||
const COLLAPSE_ICON_COLLAPSED := preload("res://graph_node_renderer/textures/collapse-icon-collapsed.svg")
|
const COLLAPSE_ICON_COLLAPSED := preload("res://graph_node_renderer/textures/collapse-icon-collapsed.svg")
|
||||||
|
|
||||||
var collapse_button: Button
|
var collapse_button: Button
|
||||||
|
|
||||||
## Emitted when a child item has been pressed.
|
## Emitted when a child item has been pressed.
|
||||||
|
|
Loading…
Reference in a new issue