mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
saving and loading port values
This commit is contained in:
parent
3c5dfdd6fd
commit
2f92233ca0
4 changed files with 19 additions and 0 deletions
|
@ -123,6 +123,10 @@ static func from_json(json: String) -> Deck:
|
||||||
var connection_data = nodes_data[node_id].incoming_connections[connection_id]
|
var connection_data = nodes_data[node_id].incoming_connections[connection_id]
|
||||||
node.incoming_connections[int(connection_id)] = connection_data
|
node.incoming_connections[int(connection_id)] = connection_data
|
||||||
|
|
||||||
|
for i in nodes_data[node_id].port_values.size():
|
||||||
|
var port_value = nodes_data[node_id].port_values[i]
|
||||||
|
node.ports[i].value = port_value
|
||||||
|
|
||||||
for key in nodes_data[node_id].meta:
|
for key in nodes_data[node_id].meta:
|
||||||
node.set_meta(key, nodes_data[node_id].meta[key])
|
node.set_meta(key, nodes_data[node_id].meta[key])
|
||||||
|
|
||||||
|
|
|
@ -176,11 +176,17 @@ func to_dict(with_meta: bool = true) -> Dictionary:
|
||||||
"incoming_connections": incoming_connections,
|
"incoming_connections": incoming_connections,
|
||||||
"props": {},
|
"props": {},
|
||||||
"node_type": node_type,
|
"node_type": node_type,
|
||||||
|
"port_values": []
|
||||||
}
|
}
|
||||||
|
|
||||||
for prop in props_to_serialize:
|
for prop in props_to_serialize:
|
||||||
d.props[prop] = get(prop)
|
d.props[prop] = get(prop)
|
||||||
|
|
||||||
|
ports.map(
|
||||||
|
func(port: Port) -> void:
|
||||||
|
d.port_values.append(port.value)
|
||||||
|
)
|
||||||
|
|
||||||
if with_meta:
|
if with_meta:
|
||||||
d["meta"] = {}
|
d["meta"] = {}
|
||||||
for meta in get_meta_list():
|
for meta in get_meta_list():
|
||||||
|
|
|
@ -9,6 +9,8 @@ var port_type: DeckNode.PortType
|
||||||
var index_of_type: int
|
var index_of_type: int
|
||||||
var index: int
|
var index: int
|
||||||
|
|
||||||
|
var value: Variant: set = set_value
|
||||||
|
|
||||||
|
|
||||||
func _init(
|
func _init(
|
||||||
p_type: Deck.Types,
|
p_type: Deck.Types,
|
||||||
|
@ -27,3 +29,7 @@ func _init(
|
||||||
port_type = p_port_type
|
port_type = p_port_type
|
||||||
index_of_type = p_index_of_type
|
index_of_type = p_index_of_type
|
||||||
index = p_index
|
index = p_index
|
||||||
|
|
||||||
|
|
||||||
|
func set_value(v: Variant) -> void:
|
||||||
|
value = v
|
||||||
|
|
|
@ -27,8 +27,11 @@ func _ready() -> void:
|
||||||
"field":
|
"field":
|
||||||
var line_edit := LineEdit.new()
|
var line_edit := LineEdit.new()
|
||||||
add_child(line_edit)
|
add_child(line_edit)
|
||||||
|
if port.value:
|
||||||
|
line_edit.text = str(port.value)
|
||||||
line_edit.placeholder_text = port.label
|
line_edit.placeholder_text = port.label
|
||||||
port.value_callback = line_edit.get_text
|
port.value_callback = line_edit.get_text
|
||||||
|
line_edit.text_changed.connect(port.set_value)
|
||||||
_:
|
_:
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
add_child(label)
|
add_child(label)
|
||||||
|
|
Loading…
Reference in a new issue