|
@@ -29,6 +29,7 @@
|
|
/*************************************************************************/
|
|
/*************************************************************************/
|
|
#include "visual_script_editor.h"
|
|
#include "visual_script_editor.h"
|
|
|
|
|
|
|
|
+#include "core/script_language.h"
|
|
#include "editor/editor_node.h"
|
|
#include "editor/editor_node.h"
|
|
#include "editor/editor_resource_preview.h"
|
|
#include "editor/editor_resource_preview.h"
|
|
#include "os/input.h"
|
|
#include "os/input.h"
|
|
@@ -3258,6 +3259,8 @@ void VisualScriptEditor::_bind_methods() {
|
|
ClassDB::bind_method("_member_rmb_selected", &VisualScriptEditor::_member_rmb_selected);
|
|
ClassDB::bind_method("_member_rmb_selected", &VisualScriptEditor::_member_rmb_selected);
|
|
|
|
|
|
ClassDB::bind_method("_member_option", &VisualScriptEditor::_member_option);
|
|
ClassDB::bind_method("_member_option", &VisualScriptEditor::_member_option);
|
|
|
|
+
|
|
|
|
+ ClassDB::bind_method("_update_available_nodes", &VisualScriptEditor::_update_available_nodes);
|
|
}
|
|
}
|
|
|
|
|
|
VisualScriptEditor::VisualScriptEditor() {
|
|
VisualScriptEditor::VisualScriptEditor() {
|
|
@@ -3442,6 +3445,8 @@ VisualScriptEditor::VisualScriptEditor() {
|
|
members->connect("item_rmb_selected", this, "_member_rmb_selected");
|
|
members->connect("item_rmb_selected", this, "_member_rmb_selected");
|
|
members->set_allow_rmb_select(true);
|
|
members->set_allow_rmb_select(true);
|
|
member_popup->connect("id_pressed", this, "_member_option");
|
|
member_popup->connect("id_pressed", this, "_member_option");
|
|
|
|
+
|
|
|
|
+ _VisualScriptEditor::get_singleton()->connect("custom_nodes_updated", this, "_update_available_nodes");
|
|
}
|
|
}
|
|
|
|
|
|
VisualScriptEditor::~VisualScriptEditor() {
|
|
VisualScriptEditor::~VisualScriptEditor() {
|
|
@@ -3485,4 +3490,42 @@ void VisualScriptEditor::register_editor() {
|
|
EditorNode::add_plugin_init_callback(register_editor_callback);
|
|
EditorNode::add_plugin_init_callback(register_editor_callback);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) {
|
|
|
|
+
|
|
|
|
+ Ref<VisualScriptCustomNode> node;
|
|
|
|
+ node.instance();
|
|
|
|
+ node->set_script(singleton->custom_nodes[p_name]);
|
|
|
|
+ return node;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+_VisualScriptEditor *_VisualScriptEditor::singleton = NULL;
|
|
|
|
+Map<String, RefPtr> _VisualScriptEditor::custom_nodes;
|
|
|
|
+
|
|
|
|
+_VisualScriptEditor::_VisualScriptEditor() {
|
|
|
|
+ singleton = this;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+_VisualScriptEditor::~_VisualScriptEditor() {
|
|
|
|
+ custom_nodes.clear();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script) {
|
|
|
|
+ String node_name = "custom/" + p_category + "/" + p_name;
|
|
|
|
+ custom_nodes.insert(node_name, p_script.get_ref_ptr());
|
|
|
|
+ VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom);
|
|
|
|
+ emit_signal("custom_nodes_updated");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void _VisualScriptEditor::remove_custom_node(const String &p_name, const String &p_category) {
|
|
|
|
+ String node_name = "custom/" + p_category + "/" + p_name;
|
|
|
|
+ custom_nodes.erase(node_name);
|
|
|
|
+ VisualScriptLanguage::singleton->remove_register_func(node_name);
|
|
|
|
+ emit_signal("custom_nodes_updated");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void _VisualScriptEditor::_bind_methods() {
|
|
|
|
+ ClassDB::bind_method(D_METHOD("add_custom_node", "name", "category", "script"), &_VisualScriptEditor::add_custom_node);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("remove_custom_node", "name", "category"), &_VisualScriptEditor::remove_custom_node);
|
|
|
|
+ ADD_SIGNAL(MethodInfo("custom_nodes_updated"));
|
|
|
|
+}
|
|
#endif
|
|
#endif
|