#ifdef TOOLS_ENABLED
#include "proc_nodes_editor_plugin.h"
#include <godot_cpp/classes/editor_interface.hpp>
namespace godot {
void ProcNodesEditorPlugin::_bind_methods() {
}
ProcNodesEditorPlugin::ProcNodesEditorPlugin() {
graph_editor = memnew(ProcGraphEdit);
graph_editor->set_custom_minimum_size(Vector2(0, 300));
graph_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
graph_editor->set_visible(false);
}
ProcNodesEditorPlugin::~ProcNodesEditorPlugin() {
if (graph_editor && !graph_editor->is_inside_tree()) {
memdelete(graph_editor);
graph_editor = nullptr;
}
}
bool ProcNodesEditorPlugin::_handles(Object *p_object) const {
return Object::cast_to<ProcGeometryNode>(p_object) != nullptr;
}
void ProcNodesEditorPlugin::_edit(Object *p_object) {
ProcGeometryNode *node = Object::cast_to<ProcGeometryNode>(p_object);
edited_node = node;
// Don't rebuild yet — _make_visible() ensures the panel is in the tree first
}
void ProcNodesEditorPlugin::_make_visible(bool p_visible) {
if (!graph_editor) {
return;
}
if (p_visible) {
if (!graph_editor->is_inside_tree()) {
add_control_to_bottom_panel(graph_editor, "Proc Nodes");
}
make_bottom_panel_item_visible(graph_editor);
// Now the panel is in the tree — safe to rebuild
graph_editor->set_edited_node(edited_node);
} else {
graph_editor->set_edited_node(nullptr);
if (graph_editor->is_inside_tree()) {
remove_control_from_bottom_panel(graph_editor);
}
edited_node = nullptr;
}
}
} // namespace godot
#endif // TOOLS_ENABLED