mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
EXPERIMENTAL: add_port() now sets a default value for the port type
This commit is contained in:
parent
1d6365c4bd
commit
0a564722f2
2 changed files with 13 additions and 0 deletions
|
@ -109,6 +109,9 @@ func add_port(type: DeckType.Types,
|
|||
descriptor: String = "",
|
||||
usage: Port.UsageType = Port.UsageType.BOTH) -> Port:
|
||||
var port := Port.new(type, label, ports.size(), port_type, index_of_type, descriptor, usage)
|
||||
# WARNING: EXPERIMENTAL
|
||||
port.set_value_no_signal(DeckType.DEFAULT_VALUES[type])
|
||||
|
||||
ports.append(port)
|
||||
port_added.emit(ports.size() - 1)
|
||||
port.value_updated.connect(
|
||||
|
|
|
@ -12,6 +12,15 @@ enum Types{
|
|||
ANY,
|
||||
}
|
||||
|
||||
const DEFAULT_VALUES := {
|
||||
Types.BOOL: false,
|
||||
Types.NUMERIC: 0.0,
|
||||
Types.STRING: "",
|
||||
Types.ARRAY: [],
|
||||
Types.DICTIONARY: {},
|
||||
Types.ANY: null,
|
||||
}
|
||||
|
||||
const CONVERSION_MAP := {
|
||||
Types.BOOL: [Types.NUMERIC, Types.STRING, Types.ANY],
|
||||
Types.NUMERIC: [Types.BOOL, Types.STRING, Types.ANY],
|
||||
|
@ -56,6 +65,7 @@ static func convert_value(value: Variant, to: Types) -> Variant:
|
|||
static func type_str(type: Types) -> String:
|
||||
return str(Types.keys()[type])
|
||||
|
||||
|
||||
## Validates whether the given Dictionary is a "Vector", AKA that it has an X and a Y key.
|
||||
static func is_valid_vector(dict : Variant):
|
||||
|
||||
|
|
Loading…
Reference in a new issue