Skip to content

Commit

Permalink
Merge pull request #54071 from KoBeWi/infinite_unlimited_connections
Browse files Browse the repository at this point in the history
Focus current node after connecting
  • Loading branch information
akien-mga committed Jul 7, 2023
2 parents 4438206 + d17c522 commit 6ed632b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/scene_tree_editor.h"
#include "editor/node_dock.h"
#include "editor/scene_tree_dock.h"
#include "plugins/script_editor_plugin.h"
#include "scene/gui/button.h"
Expand Down Expand Up @@ -1440,6 +1441,7 @@ ConnectionsDock::ConnectionsDock() {
connect_button->connect("pressed", callable_mp(this, &ConnectionsDock::_connect_pressed));

connect_dialog = memnew(ConnectDialog);
connect_dialog->connect("connected", callable_mp(NodeDock::get_singleton(), &NodeDock::restore_last_valid_node), CONNECT_DEFERRED);
add_child(connect_dialog);

disconnect_all_dialog = memnew(ConfirmationDialog);
Expand Down
7 changes: 7 additions & 0 deletions editor/node_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void NodeDock::update_lists() {
void NodeDock::set_node(Node *p_node) {
connections->set_node(p_node);
groups->set_current(p_node);
if (p_node) {
last_valid_node = p_node;
}

if (p_node) {
if (connections_button->is_pressed()) {
Expand All @@ -88,6 +91,10 @@ void NodeDock::set_node(Node *p_node) {
}
}

void NodeDock::restore_last_valid_node() {
set_node(last_valid_node);
}

NodeDock::NodeDock() {
singleton = this;

Expand Down
2 changes: 2 additions & 0 deletions editor/node_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class NodeDock : public VBoxContainer {
HBoxContainer *mode_hb = nullptr;

Label *select_a_node = nullptr;
Node *last_valid_node = nullptr;

private:
static NodeDock *singleton;
Expand All @@ -60,6 +61,7 @@ class NodeDock : public VBoxContainer {

public:
void set_node(Node *p_node);
void restore_last_valid_node();

void show_groups();
void show_connections();
Expand Down

0 comments on commit 6ed632b

Please sign in to comment.