summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Sobrinho <franklin_gs@hotmail.com>2015-11-23 17:38:15 -0300
committerFranklin Sobrinho <franklin_gs@hotmail.com>2015-11-23 17:38:15 -0300
commite6047912fe7b40803f0e4833c07369790e87886b (patch)
treefc43553aa124e9db1a1b038e27147477541ef903
parent19a8f9b74d9ef7a4e2e9f5b1d1333995e2384943 (diff)
Add ability to set oneshot connection from Editor
-rw-r--r--tools/editor/connections_dialog.cpp19
-rw-r--r--tools/editor/connections_dialog.h2
2 files changed, 17 insertions, 4 deletions
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index b0bacdae61..d4937d7114 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -163,6 +163,7 @@ void ConnectDialog::edit(Node *p_node) {
dst_path->set_text("");
dst_method->set_text("");
deferred->set_pressed(false);
+ oneshot->set_pressed(false);
cdbinds->params.clear();
cdbinds->notify_changed();
}
@@ -196,6 +197,11 @@ bool ConnectDialog::get_deferred() const {
return deferred->is_pressed();
}
+bool ConnectDialog::get_oneshot() const {
+
+ return oneshot->is_pressed();
+}
+
StringName ConnectDialog::get_dst_method() const {
String txt=dst_method->get_text();
@@ -423,12 +429,13 @@ ConnectDialog::ConnectDialog() {
dstm_hb->add_child(make_callback);
deferred = memnew( CheckButton );
- deferred->set_toggle_mode(true);
- deferred->set_pressed(true);
deferred->set_text("Deferred");
dstm_hb->add_child(deferred);
-
+ oneshot = memnew( CheckButton );
+ oneshot->set_text("Oneshot");
+ dstm_hb->add_child(oneshot);
+
/*
realtime = memnew( CheckButton );
realtime->set_anchor( MARGIN_TOP, ANCHOR_END );
@@ -496,11 +503,13 @@ void ConnectionsDialog::_connect() {
StringName dst_method=connect_dialog->get_dst_method();
bool defer=connect_dialog->get_deferred();
+ bool oshot=connect_dialog->get_oneshot();
Vector<Variant> binds = connect_dialog->get_binds();
StringArray args = it->get_metadata(0).operator Dictionary()["args"];
+ int flags = CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0) | (oshot?CONNECT_ONESHOT:0);
undo_redo->create_action("Connect '"+signal+"' to '"+String(dst_method)+"'");
- undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0));
+ undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,flags);
undo_redo->add_undo_method(node,"disconnect",signal,target,dst_method);
undo_redo->add_do_method(this,"update_tree");
undo_redo->add_undo_method(this,"update_tree");
@@ -731,6 +740,8 @@ void ConnectionsDialog::update_tree() {
String path = String(node->get_path_to(target))+" :: "+c.method+"()";
if (c.flags&CONNECT_DEFERRED)
path+=" (deferred)";
+ if (c.flags&CONNECT_ONESHOT)
+ path+=" (oneshot)";
if (c.binds.size()) {
path+=" binds( ";
diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h
index 68b13bf07a..4a1c3f189c 100644
--- a/tools/editor/connections_dialog.h
+++ b/tools/editor/connections_dialog.h
@@ -58,6 +58,7 @@ class ConnectDialog : public ConfirmationDialog {
//MenuButton *dst_method_list;
OptionButton *type_list;
CheckButton *deferred;
+ CheckButton *oneshot;
CheckButton *make_callback;
PropertyEditor *bind_editor;
Node *node;
@@ -80,6 +81,7 @@ public:
NodePath get_dst_path() const;
StringName get_dst_method() const;
bool get_deferred() const;
+ bool get_oneshot() const;
Vector<Variant> get_binds() const;
void set_dst_method(const StringName& p_method);
void set_dst_node(Node* p_node);