From c314203a70414dd765f57660cbecca2024e99323 Mon Sep 17 00:00:00 2001 From: Max Hilbrunner Date: Mon, 23 Aug 2021 18:15:50 +0200 Subject: Fix Visual Script editor --- doc/classes/@GlobalScope.xml | 4 +-- doc/classes/VisualScriptCustomNodes.xml | 39 ++++++++++++++++++++++ .../doc_classes/VisualScriptEditor.xml | 37 -------------------- modules/visual_script/register_types.cpp | 12 +++---- modules/visual_script/visual_script_editor.cpp | 26 +++++++-------- modules/visual_script/visual_script_editor.h | 18 +++++----- 6 files changed, 67 insertions(+), 69 deletions(-) create mode 100644 doc/classes/VisualScriptCustomNodes.xml delete mode 100644 modules/visual_script/doc_classes/VisualScriptEditor.xml diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 46b9bdd52d..3d920171c6 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1072,8 +1072,8 @@ The [TranslationServer] singleton. - - The [VisualScriptEditor] singleton. + + The [VisualScriptCustomNodes] singleton. The [XRServer] singleton. diff --git a/doc/classes/VisualScriptCustomNodes.xml b/doc/classes/VisualScriptCustomNodes.xml new file mode 100644 index 0000000000..3ef8022f5e --- /dev/null +++ b/doc/classes/VisualScriptCustomNodes.xml @@ -0,0 +1,39 @@ + + + + Manages custom nodes for the Visual Script editor. + + + This singleton can be used to manage (i.e., add or remove) custom nodes for the Visual Script editor. + + + + + + + + + + + Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter. + + + + + + + + Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed. + + + + + + + Emitted when a custom Visual Script node is added or removed. + + + + + + diff --git a/modules/visual_script/doc_classes/VisualScriptEditor.xml b/modules/visual_script/doc_classes/VisualScriptEditor.xml deleted file mode 100644 index 9ea889c77b..0000000000 --- a/modules/visual_script/doc_classes/VisualScriptEditor.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter. - - - - - - - - Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed. - - - - - - - Emitted when a custom Visual Script node is added or removed. - - - - - - diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index fce98eb8a0..7fb9707fce 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -43,7 +43,7 @@ VisualScriptLanguage *visual_script_language = nullptr; #ifdef TOOLS_ENABLED -static vs_bind::VisualScriptEditor *vs_editor_singleton = nullptr; +static VisualScriptCustomNodes *vs_custom_nodes_singleton = nullptr; #endif void register_visual_script_types() { @@ -114,10 +114,10 @@ void register_visual_script_types() { #ifdef TOOLS_ENABLED ClassDB::set_current_api(ClassDB::API_EDITOR); - GDREGISTER_CLASS(vs_bind::VisualScriptEditor); + GDREGISTER_CLASS(VisualScriptCustomNodes); ClassDB::set_current_api(ClassDB::API_CORE); - vs_editor_singleton = memnew(vs_bind::VisualScriptEditor); - Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptEditor", vs_bind::VisualScriptEditor::get_singleton())); + vs_custom_nodes_singleton = memnew(VisualScriptCustomNodes); + Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptEditor", VisualScriptCustomNodes::get_singleton())); VisualScriptEditor::register_editor(); #endif @@ -130,8 +130,8 @@ void unregister_visual_script_types() { #ifdef TOOLS_ENABLED VisualScriptEditor::free_clipboard(); - if (vs_editor_singleton) { - memdelete(vs_editor_singleton); + if (vs_custom_nodes_singleton) { + memdelete(vs_custom_nodes_singleton); } #endif if (visual_script_language) { diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index ded716cf18..eee9e8f32b 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -4522,46 +4522,44 @@ void VisualScriptEditor::register_editor() { void VisualScriptEditor::validate() { } -namespace vs_bind { +// VisualScriptCustomNodes -Ref VisualScriptEditor::create_node_custom(const String &p_name) { +Ref VisualScriptCustomNodes::create_node_custom(const String &p_name) { Ref node; node.instantiate(); node->set_script(singleton->custom_nodes[p_name]); return node; } -VisualScriptEditor *VisualScriptEditor::singleton = nullptr; -Map VisualScriptEditor::custom_nodes; +VisualScriptCustomNodes *VisualScriptCustomNodes::singleton = nullptr; +Map VisualScriptCustomNodes::custom_nodes; -VisualScriptEditor::VisualScriptEditor() { +VisualScriptCustomNodes::VisualScriptCustomNodes() { singleton = this; } -VisualScriptEditor::~VisualScriptEditor() { +VisualScriptCustomNodes::~VisualScriptCustomNodes() { custom_nodes.clear(); } -void VisualScriptEditor::add_custom_node(const String &p_name, const String &p_category, const Ref