From 8cf478567dd1d7b3d7b84a00955f2f8d3206f325 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 1 Mar 2023 23:06:01 +0100 Subject: [PATCH] Added buttons slots to MMGraphNodes. --- modules/material_maker/editor/mm_graph_node.cpp | 9 +++++++++ modules/material_maker/editor/mm_graph_node.h | 1 + 2 files changed, 10 insertions(+) diff --git a/modules/material_maker/editor/mm_graph_node.cpp b/modules/material_maker/editor/mm_graph_node.cpp index faecbaea7..ad41e061e 100644 --- a/modules/material_maker/editor/mm_graph_node.cpp +++ b/modules/material_maker/editor/mm_graph_node.cpp @@ -282,6 +282,14 @@ int MMGraphNode::add_slot_bool(const String &getter, const String &setter, const return slot_idx; } +int MMGraphNode::add_slot_button(const String &method, const String &slot_name) { + Button *button = memnew(Button); + button->set_text(slot_name); + int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, "", "", button); + button->connect("pressed", *_node, method); + return slot_idx; +} + int MMGraphNode::add_slot_label_universal(const Ref &property) { Label *l = memnew(Label); l->set_text(property->get_slot_name()); @@ -920,6 +928,7 @@ void MMGraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("add_slot_enum", "getter", "setter", "slot_name", "values"), &MMGraphNode::add_slot_enum); ClassDB::bind_method(D_METHOD("add_slot_int", "getter", "setter", "slot_name", "prange"), &MMGraphNode::add_slot_int, Vector2(-1000, 1000)); ClassDB::bind_method(D_METHOD("add_slot_bool", "getter", "setter", "slot_name"), &MMGraphNode::add_slot_bool); + ClassDB::bind_method(D_METHOD("add_slot_button", "method", "slot_name"), &MMGraphNode::add_slot_button); ClassDB::bind_method(D_METHOD("add_slot_label_universal", "property"), &MMGraphNode::add_slot_label_universal); ClassDB::bind_method(D_METHOD("add_slot_int_universal", "property"), &MMGraphNode::add_slot_int_universal); ClassDB::bind_method(D_METHOD("add_slot_float", "getter", "setter", "slot_name", "step", "prange"), &MMGraphNode::add_slot_float, 0.1, Vector2(-1000, 1000)); diff --git a/modules/material_maker/editor/mm_graph_node.h b/modules/material_maker/editor/mm_graph_node.h index 48111dcf4..f51ed1aab 100644 --- a/modules/material_maker/editor/mm_graph_node.h +++ b/modules/material_maker/editor/mm_graph_node.h @@ -60,6 +60,7 @@ public: int add_slot_enum(const String &getter, const String &setter, const String &slot_name, const Array &values); int add_slot_int(const String &getter, const String &setter, const String &slot_name, const Vector2 &prange = Vector2(-1000, 1000)); int add_slot_bool(const String &getter, const String &setter, const String &slot_name); + int add_slot_button(const String &method, const String &slot_name); int add_slot_label_universal(const Ref &property); int add_slot_int_universal(const Ref &property); int add_slot_float(const String &getter, const String &setter, const String &slot_name, const float step = 0.1, const Vector2 &prange = Vector2(-1000, 1000));