Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@ -47,7 +47,6 @@ static Node *_find_first_script(Node *p_root, Node *p_node) {
|
||||
}
|
||||
|
||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||
|
||||
Node *ret = _find_first_script(p_root, p_node->get_child(i));
|
||||
if (ret) {
|
||||
return ret;
|
||||
@ -58,14 +57,12 @@ static Node *_find_first_script(Node *p_root, Node *p_node) {
|
||||
}
|
||||
|
||||
class ConnectDialogBinds : public Object {
|
||||
|
||||
GDCLASS(ConnectDialogBinds, Object);
|
||||
|
||||
public:
|
||||
Vector<Variant> params;
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value) {
|
||||
|
||||
String name = p_name;
|
||||
|
||||
if (name.begins_with("bind/")) {
|
||||
@ -79,7 +76,6 @@ public:
|
||||
}
|
||||
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const {
|
||||
|
||||
String name = p_name;
|
||||
|
||||
if (name.begins_with("bind/")) {
|
||||
@ -93,14 +89,12 @@ public:
|
||||
}
|
||||
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const {
|
||||
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
p_list->push_back(PropertyInfo(params[i].get_type(), "bind/" + itos(i + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
void notify_changed() {
|
||||
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
@ -112,7 +106,6 @@ public:
|
||||
* Signal automatically called by parent dialog.
|
||||
*/
|
||||
void ConnectDialog::ok_pressed() {
|
||||
|
||||
if (dst_method->get_text() == "") {
|
||||
error->set_text(TTR("Method in target node must be specified."));
|
||||
error->popup_centered();
|
||||
@ -149,7 +142,6 @@ void ConnectDialog::_text_entered(const String &p_text) {
|
||||
* Called each time a target node is selected within the target node tree.
|
||||
*/
|
||||
void ConnectDialog::_tree_node_selected() {
|
||||
|
||||
Node *current = tree->get_selected();
|
||||
|
||||
if (!current)
|
||||
@ -163,7 +155,6 @@ void ConnectDialog::_tree_node_selected() {
|
||||
* Adds a new parameter bind to connection.
|
||||
*/
|
||||
void ConnectDialog::_add_bind() {
|
||||
|
||||
if (cdbinds->params.size() >= VARIANT_ARG_MAX)
|
||||
return;
|
||||
Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected());
|
||||
@ -228,7 +219,6 @@ void ConnectDialog::_add_bind() {
|
||||
* Remove parameter bind from connection.
|
||||
*/
|
||||
void ConnectDialog::_remove_bind() {
|
||||
|
||||
String st = bind_editor->get_selected_path();
|
||||
if (st == "")
|
||||
return;
|
||||
@ -244,7 +234,6 @@ void ConnectDialog::_remove_bind() {
|
||||
* node is selected and valid in the selected mode.
|
||||
*/
|
||||
void ConnectDialog::_update_ok_enabled() {
|
||||
|
||||
Node *target = tree->get_selected();
|
||||
|
||||
if (target == nullptr) {
|
||||
@ -261,14 +250,12 @@ void ConnectDialog::_update_ok_enabled() {
|
||||
}
|
||||
|
||||
void ConnectDialog::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
bind_editor->edit(cdbinds);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectDialog::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed);
|
||||
ClassDB::bind_method("_update_ok_enabled", &ConnectDialog::_update_ok_enabled);
|
||||
|
||||
@ -276,27 +263,22 @@ void ConnectDialog::_bind_methods() {
|
||||
}
|
||||
|
||||
Node *ConnectDialog::get_source() const {
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
StringName ConnectDialog::get_signal_name() const {
|
||||
|
||||
return signal;
|
||||
}
|
||||
|
||||
NodePath ConnectDialog::get_dst_path() const {
|
||||
|
||||
return dst_path;
|
||||
}
|
||||
|
||||
void ConnectDialog::set_dst_node(Node *p_node) {
|
||||
|
||||
tree->set_selected(p_node);
|
||||
}
|
||||
|
||||
StringName ConnectDialog::get_dst_method_name() const {
|
||||
|
||||
String txt = dst_method->get_text();
|
||||
if (txt.find("(") != -1)
|
||||
txt = txt.left(txt.find("(")).strip_edges();
|
||||
@ -304,22 +286,18 @@ StringName ConnectDialog::get_dst_method_name() const {
|
||||
}
|
||||
|
||||
void ConnectDialog::set_dst_method(const StringName &p_method) {
|
||||
|
||||
dst_method->set_text(p_method);
|
||||
}
|
||||
|
||||
Vector<Variant> ConnectDialog::get_binds() const {
|
||||
|
||||
return cdbinds->params;
|
||||
}
|
||||
|
||||
bool ConnectDialog::get_deferred() const {
|
||||
|
||||
return deferred->is_pressed();
|
||||
}
|
||||
|
||||
bool ConnectDialog::get_oneshot() const {
|
||||
|
||||
return oneshot->is_pressed();
|
||||
}
|
||||
|
||||
@ -327,7 +305,6 @@ bool ConnectDialog::get_oneshot() const {
|
||||
* Returns true if ConnectDialog is being used to edit an existing connection.
|
||||
*/
|
||||
bool ConnectDialog::is_editing() const {
|
||||
|
||||
return bEditMode;
|
||||
}
|
||||
|
||||
@ -337,7 +314,6 @@ bool ConnectDialog::is_editing() const {
|
||||
* If editing an existing connection, previous data is retained.
|
||||
*/
|
||||
void ConnectDialog::init(ConnectionData c, bool bEdit) {
|
||||
|
||||
set_hide_on_ok(false);
|
||||
|
||||
source = static_cast<Node *>(c.source);
|
||||
@ -367,7 +343,6 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) {
|
||||
}
|
||||
|
||||
void ConnectDialog::popup_dialog(const String &p_for_signal) {
|
||||
|
||||
from_signal->set_text(p_for_signal);
|
||||
error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor"));
|
||||
if (!advanced->is_pressed())
|
||||
@ -377,7 +352,6 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) {
|
||||
}
|
||||
|
||||
void ConnectDialog::_advanced_pressed() {
|
||||
|
||||
if (advanced->is_pressed()) {
|
||||
set_min_size(Size2(900, 500) * EDSCALE);
|
||||
connect_to_label->set_text(TTR("Connect to Node:"));
|
||||
@ -401,7 +375,6 @@ void ConnectDialog::_advanced_pressed() {
|
||||
}
|
||||
|
||||
ConnectDialog::ConnectDialog() {
|
||||
|
||||
set_min_size(Size2(600, 500) * EDSCALE);
|
||||
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
@ -515,7 +488,6 @@ ConnectDialog::ConnectDialog() {
|
||||
}
|
||||
|
||||
ConnectDialog::~ConnectDialog() {
|
||||
|
||||
memdelete(cdbinds);
|
||||
}
|
||||
|
||||
@ -523,7 +495,6 @@ ConnectDialog::~ConnectDialog() {
|
||||
|
||||
// Originally copied and adapted from EditorProperty, try to keep style in sync.
|
||||
Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
|
||||
|
||||
EditorHelpBit *help_bit = memnew(EditorHelpBit);
|
||||
help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel"));
|
||||
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
|
||||
@ -536,7 +507,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
|
||||
}
|
||||
|
||||
struct _ConnectionsDockMethodInfoSort {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const {
|
||||
return a.name < b.name;
|
||||
}
|
||||
@ -547,7 +517,6 @@ struct _ConnectionsDockMethodInfoSort {
|
||||
* Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
|
||||
*/
|
||||
void ConnectionsDock::_make_or_edit_connection() {
|
||||
|
||||
TreeItem *it = tree->get_selected();
|
||||
ERR_FAIL_COND(!it);
|
||||
|
||||
@ -616,7 +585,6 @@ void ConnectionsDock::_make_or_edit_connection() {
|
||||
* Creates single connection w/ undo-redo functionality.
|
||||
*/
|
||||
void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) {
|
||||
|
||||
Node *source = static_cast<Node *>(cToMake.source);
|
||||
Node *target = static_cast<Node *>(cToMake.target);
|
||||
|
||||
@ -641,7 +609,6 @@ void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) {
|
||||
* Break single connection w/ undo-redo functionality.
|
||||
*/
|
||||
void ConnectionsDock::_disconnect(TreeItem &item) {
|
||||
|
||||
Connection cd = item.get_metadata(0);
|
||||
ConnectDialog::ConnectionData c = cd;
|
||||
|
||||
@ -664,7 +631,6 @@ void ConnectionsDock::_disconnect(TreeItem &item) {
|
||||
* Can undo-redo as a single action.
|
||||
*/
|
||||
void ConnectionsDock::_disconnect_all() {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
|
||||
if (!_is_item_signal(*item))
|
||||
@ -691,7 +657,6 @@ void ConnectionsDock::_disconnect_all() {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_tree_item_selected() {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
if (!item) { // Unlikely. Disable button just in case.
|
||||
connect_button->set_text(TTR("Connect..."));
|
||||
@ -720,7 +685,6 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click.
|
||||
}
|
||||
|
||||
bool ConnectionsDock::_is_item_signal(TreeItem &item) {
|
||||
|
||||
return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root());
|
||||
}
|
||||
|
||||
@ -728,7 +692,6 @@ bool ConnectionsDock::_is_item_signal(TreeItem &item) {
|
||||
* Open connection dialog with TreeItem data to CREATE a brand-new connection.
|
||||
*/
|
||||
void ConnectionsDock::_open_connection_dialog(TreeItem &item) {
|
||||
|
||||
String signal = item.get_metadata(0).operator Dictionary()["name"];
|
||||
const String &signalname = signal;
|
||||
String midname = selectedNode->get_name();
|
||||
@ -769,7 +732,6 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &item) {
|
||||
* Open connection dialog with Connection data to EDIT an existing connection.
|
||||
*/
|
||||
void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToEdit) {
|
||||
|
||||
Node *src = static_cast<Node *>(cToEdit.source);
|
||||
Node *dst = static_cast<Node *>(cToEdit.target);
|
||||
|
||||
@ -784,7 +746,6 @@ void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToE
|
||||
* Open slot method location in script editor.
|
||||
*/
|
||||
void ConnectionsDock::_go_to_script(TreeItem &item) {
|
||||
|
||||
if (_is_item_signal(item))
|
||||
return;
|
||||
|
||||
@ -806,7 +767,6 @@ void ConnectionsDock::_go_to_script(TreeItem &item) {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_handle_signal_menu_option(int option) {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
|
||||
if (!item)
|
||||
@ -825,7 +785,6 @@ void ConnectionsDock::_handle_signal_menu_option(int option) {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_handle_slot_menu_option(int option) {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
|
||||
if (!item)
|
||||
@ -847,7 +806,6 @@ void ConnectionsDock::_handle_slot_menu_option(int option) {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_rmb_pressed(Vector2 position) {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
|
||||
if (!item)
|
||||
@ -865,12 +823,10 @@ void ConnectionsDock::_rmb_pressed(Vector2 position) {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_close() {
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
void ConnectionsDock::_connect_pressed() {
|
||||
|
||||
TreeItem *item = tree->get_selected();
|
||||
if (!item) {
|
||||
connect_button->set_disabled(true);
|
||||
@ -886,25 +842,21 @@ void ConnectionsDock::_connect_pressed() {
|
||||
}
|
||||
|
||||
void ConnectionsDock::_notification(int p_what) {
|
||||
|
||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||
update_tree();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionsDock::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
|
||||
}
|
||||
|
||||
void ConnectionsDock::set_node(Node *p_node) {
|
||||
|
||||
selectedNode = p_node;
|
||||
update_tree();
|
||||
}
|
||||
|
||||
void ConnectionsDock::update_tree() {
|
||||
|
||||
tree->clear();
|
||||
|
||||
if (!selectedNode)
|
||||
@ -920,13 +872,11 @@ void ConnectionsDock::update_tree() {
|
||||
StringName base = selectedNode->get_class();
|
||||
|
||||
while (base) {
|
||||
|
||||
List<MethodInfo> node_signals2;
|
||||
Ref<Texture2D> icon;
|
||||
String name;
|
||||
|
||||
if (!did_script) {
|
||||
|
||||
Ref<Script> scr = selectedNode->get_script();
|
||||
if (scr.is_valid()) {
|
||||
scr->get_script_signal_list(&node_signals2);
|
||||
@ -940,7 +890,6 @@ void ConnectionsDock::update_tree() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
ClassDB::get_signal_list(base, &node_signals2, true);
|
||||
if (has_theme_icon(base, "EditorIcons")) {
|
||||
icon = get_theme_icon(base, "EditorIcons");
|
||||
@ -965,7 +914,6 @@ void ConnectionsDock::update_tree() {
|
||||
}
|
||||
|
||||
for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) {
|
||||
|
||||
MethodInfo &mi = E->get();
|
||||
|
||||
StringName signal_name = mi.name;
|
||||
@ -973,7 +921,6 @@ void ConnectionsDock::update_tree() {
|
||||
PackedStringArray argnames;
|
||||
if (mi.arguments.size()) {
|
||||
for (int i = 0; i < mi.arguments.size(); i++) {
|
||||
|
||||
PropertyInfo &pi = mi.arguments[i];
|
||||
|
||||
if (i > 0)
|
||||
@ -1040,7 +987,6 @@ void ConnectionsDock::update_tree() {
|
||||
selectedNode->get_signal_connection_list(signal_name, &connections);
|
||||
|
||||
for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
|
||||
|
||||
Connection cn = F->get();
|
||||
if (!(cn.flags & CONNECT_PERSIST))
|
||||
continue;
|
||||
@ -1056,10 +1002,8 @@ void ConnectionsDock::update_tree() {
|
||||
if (c.flags & CONNECT_ONESHOT)
|
||||
path += " (oneshot)";
|
||||
if (c.binds.size()) {
|
||||
|
||||
path += " binds(";
|
||||
for (int i = 0; i < c.binds.size(); i++) {
|
||||
|
||||
if (i > 0)
|
||||
path += ", ";
|
||||
path += c.binds[i].operator String();
|
||||
@ -1087,7 +1031,6 @@ void ConnectionsDock::update_tree() {
|
||||
}
|
||||
|
||||
ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
|
||||
|
||||
editor = p_editor;
|
||||
set_name(TTR("Signals"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user