Merge pull request #109322 from 4d49/graph-node-slot-meta
Add metadata for slots in `GraphNode`
This commit is contained in:
@ -835,6 +835,19 @@ Ref<Texture2D> GraphNode::get_slot_custom_icon_left(int p_slot_index) const {
|
||||
return slot_table[p_slot_index].custom_port_icon_left;
|
||||
}
|
||||
|
||||
void GraphNode::set_slot_metadata_left(int p_slot_index, const Variant &p_value) {
|
||||
ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set left metadata for the slot with index '%d' because it hasn't been enabled.", p_slot_index));
|
||||
slot_table[p_slot_index].metadata_left = p_value;
|
||||
}
|
||||
|
||||
Variant GraphNode::get_slot_metadata_left(int p_slot_index) const {
|
||||
const Slot *slot = slot_table.getptr(p_slot_index);
|
||||
if (slot == nullptr) {
|
||||
return Variant();
|
||||
}
|
||||
return slot->metadata_left;
|
||||
}
|
||||
|
||||
bool GraphNode::is_slot_enabled_right(int p_slot_index) const {
|
||||
if (!slot_table.has(p_slot_index)) {
|
||||
return false;
|
||||
@ -923,6 +936,19 @@ Ref<Texture2D> GraphNode::get_slot_custom_icon_right(int p_slot_index) const {
|
||||
return slot_table[p_slot_index].custom_port_icon_right;
|
||||
}
|
||||
|
||||
void GraphNode::set_slot_metadata_right(int p_slot_index, const Variant &p_value) {
|
||||
ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set right metadata for the slot with index '%d' because it hasn't been enabled.", p_slot_index));
|
||||
slot_table[p_slot_index].metadata_right = p_value;
|
||||
}
|
||||
|
||||
Variant GraphNode::get_slot_metadata_right(int p_slot_index) const {
|
||||
const Slot *slot = slot_table.getptr(p_slot_index);
|
||||
if (slot == nullptr) {
|
||||
return Variant();
|
||||
}
|
||||
return slot->metadata_right;
|
||||
}
|
||||
|
||||
bool GraphNode::is_slot_draw_stylebox(int p_slot_index) const {
|
||||
if (!slot_table.has(p_slot_index)) {
|
||||
return false;
|
||||
@ -1229,6 +1255,9 @@ void GraphNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_slot_custom_icon_left", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_left);
|
||||
ClassDB::bind_method(D_METHOD("get_slot_custom_icon_left", "slot_index"), &GraphNode::get_slot_custom_icon_left);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_slot_metadata_left", "slot_index", "value"), &GraphNode::set_slot_metadata_left);
|
||||
ClassDB::bind_method(D_METHOD("get_slot_metadata_left", "slot_index"), &GraphNode::get_slot_metadata_left);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_slot_enabled_right", "slot_index"), &GraphNode::is_slot_enabled_right);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_enabled_right", "slot_index", "enable"), &GraphNode::set_slot_enabled_right);
|
||||
|
||||
@ -1241,6 +1270,9 @@ void GraphNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_slot_custom_icon_right", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_right);
|
||||
ClassDB::bind_method(D_METHOD("get_slot_custom_icon_right", "slot_index"), &GraphNode::get_slot_custom_icon_right);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_slot_metadata_right", "slot_index", "value"), &GraphNode::set_slot_metadata_right);
|
||||
ClassDB::bind_method(D_METHOD("get_slot_metadata_right", "slot_index"), &GraphNode::get_slot_metadata_right);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_slot_draw_stylebox", "slot_index"), &GraphNode::is_slot_draw_stylebox);
|
||||
ClassDB::bind_method(D_METHOD("set_slot_draw_stylebox", "slot_index", "enable"), &GraphNode::set_slot_draw_stylebox);
|
||||
|
||||
|
||||
@ -44,11 +44,13 @@ class GraphNode : public GraphElement {
|
||||
int type_left = 0;
|
||||
Color color_left = Color(1, 1, 1, 1);
|
||||
Ref<Texture2D> custom_port_icon_left;
|
||||
Variant metadata_left;
|
||||
|
||||
bool enable_right = false;
|
||||
int type_right = 0;
|
||||
Color color_right = Color(1, 1, 1, 1);
|
||||
Ref<Texture2D> custom_port_icon_right;
|
||||
Variant metadata_right;
|
||||
|
||||
bool draw_stylebox = true;
|
||||
};
|
||||
@ -150,6 +152,9 @@ public:
|
||||
void set_slot_custom_icon_left(int p_slot_index, const Ref<Texture2D> &p_custom_icon);
|
||||
Ref<Texture2D> get_slot_custom_icon_left(int p_slot_index) const;
|
||||
|
||||
void set_slot_metadata_left(int p_slot_index, const Variant &p_value);
|
||||
Variant get_slot_metadata_left(int p_slot_index) const;
|
||||
|
||||
bool is_slot_enabled_right(int p_slot_index) const;
|
||||
void set_slot_enabled_right(int p_slot_index, bool p_enable);
|
||||
|
||||
@ -162,6 +167,9 @@ public:
|
||||
void set_slot_custom_icon_right(int p_slot_index, const Ref<Texture2D> &p_custom_icon);
|
||||
Ref<Texture2D> get_slot_custom_icon_right(int p_slot_index) const;
|
||||
|
||||
void set_slot_metadata_right(int p_slot_index, const Variant &p_value);
|
||||
Variant get_slot_metadata_right(int p_slot_index) const;
|
||||
|
||||
bool is_slot_draw_stylebox(int p_slot_index) const;
|
||||
void set_slot_draw_stylebox(int p_slot_index, bool p_enable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user