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:
Rémi Verschelde 2020-05-14 13:23:58 +02:00
parent 710b34b702
commit 0be6d925dc
1552 changed files with 1 additions and 33876 deletions

View file

@ -43,17 +43,14 @@
#include "scene/main/window.h"
bool AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) {
Ref<AnimationNodeStateMachine> ansm = p_node;
return ansm.is_valid();
}
void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) {
state_machine = p_node;
if (state_machine.is_valid()) {
selected_transition_from = StringName();
selected_transition_to = StringName();
selected_node = StringName();
@ -63,7 +60,6 @@ void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) {
}
void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEvent> &p_event) {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
if (playback.is_null())
return;
@ -104,7 +100,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
String name = String(E->get()).replace_first("AnimationNode", "");
if (name == "Animation")
continue; // nope
@ -128,7 +123,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
// select node or push a field inside
if (mb.is_valid() && !mb->get_shift() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
selected_transition_from = StringName();
selected_transition_to = StringName();
selected_node = StringName();
@ -191,7 +185,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
int closest = -1;
float closest_d = 1e20;
for (int i = 0; i < transition_lines.size(); i++) {
Vector2 s[2] = {
transition_lines[i].from,
transition_lines[i].to
@ -222,9 +215,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//end moving node
if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
if (dragging_selected) {
Ref<AnimationNode> an = state_machine->get_node(selected_node);
updating = true;
undo_redo->create_action(TTR("Move Node"));
@ -245,7 +236,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//connect nodes
if (mb.is_valid() && ((tool_select->is_pressed() && mb->get_shift()) || tool_connect->is_pressed()) && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
if (node_rects[i].node.has_point(mb->get_position())) { //select node since nothing else was selected
connecting = true;
@ -259,14 +249,11 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//end connecting nodes
if (mb.is_valid() && connecting && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) {
if (connecting_to_node != StringName()) {
if (state_machine->has_transition(connecting_from, connecting_to_node)) {
EditorNode::get_singleton()->show_warning(TTR("Transition exists!"));
} else {
Ref<AnimationNodeStateMachineTransition> tr;
tr.instance();
tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()));
@ -296,14 +283,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//pan window
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) {
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
}
//move mouse while connecting
if (mm.is_valid() && connecting) {
connecting_to = mm->get_position();
connecting_to_node = StringName();
state_machine_draw->update();
@ -318,7 +303,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//move mouse while moving a node
if (mm.is_valid() && dragging_selected_attempt) {
dragging_selected = true;
drag_ofs = mm->get_position() - drag_from;
snap_x = StringName();
@ -358,14 +342,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
//put ibeam (text cursor) over names to make it clearer that they are editable
if (mm.is_valid()) {
state_machine_draw->grab_focus();
bool over_text_now = false;
String new_over_node = StringName();
int new_over_node_what = -1;
if (tool_select->is_pressed()) {
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
if (node_rects[i].name.has_point(mm->get_position())) {
@ -392,7 +374,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
if (over_text != over_text_now) {
if (over_text_now) {
state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM);
} else {
@ -405,7 +386,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
}
void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
file_loaded = ResourceLoader::load(p_file);
if (file_loaded.is_valid()) {
_add_menu_type(MENU_LOAD_FILE_CONFIRM);
@ -413,12 +393,10 @@ void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
}
void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
String base_name;
Ref<AnimationRootNode> node;
if (p_index == MENU_LOAD_FILE) {
open_file->clear_filters();
List<String> filters;
ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters);
@ -431,7 +409,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
node = file_loaded;
file_loaded.unref();
} else if (p_index == MENU_PASTE) {
node = EditorSettings::get_singleton()->get_resource_clipboard();
} else {
@ -452,7 +429,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
}
if (base_name == String()) {
base_name = node->get_class().replace_first("AnimationNode", "");
}
@ -476,7 +452,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
}
void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
Ref<AnimationNodeAnimation> anim;
anim.instance();
@ -503,7 +478,6 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
}
void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) {
Color linecolor = get_theme_color("font_color", "Label");
Color icon_color(1, 1, 1);
Color accent = get_theme_color("accent_color", "Editor");
@ -546,7 +520,6 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
}
void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) {
if (r_to == r_from)
return;
@ -558,7 +531,6 @@ void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Ve
}
void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) {
if (r_to == r_from)
return;
@ -570,7 +542,6 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Ve
}
void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode");
@ -611,7 +582,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//snap lines
if (dragging_selected) {
Vector2 from = (state_machine->get_node_position(selected_node) * EDSCALE) + drag_ofs - state_machine->get_graph_offset() * EDSCALE;
if (snap_x != StringName()) {
Vector2 to = (state_machine->get_node_position(snap_x) * EDSCALE) - state_machine->get_graph_offset() * EDSCALE;
@ -625,7 +595,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//pre pass nodes so we know the rectangles
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
Ref<AnimationNode> anode = state_machine->get_node(E->get());
String name = E->get();
bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr());
@ -691,7 +660,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//draw transition lines
for (int i = 0; i < state_machine->get_transition_count(); i++) {
TransitionLine tl;
tl.from_node = state_machine->get_transition_from(i);
Vector2 ofs_from = (dragging_selected && tl.from_node == selected_node) ? drag_ofs : Vector2();
@ -733,7 +701,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
if (travel_path.size()) {
if (current == tl.from_node && travel_path[0] == tl.to_node) {
travel = true;
} else {
@ -759,7 +726,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
//draw actual nodes
for (int i = 0; i < node_rects.size(); i++) {
String name = node_rects[i].node_name;
Ref<AnimationNode> anode = state_machine->get_node(name);
bool needs_editor = AnimationTreeEditor::get_singleton()->can_edit(anode);
@ -786,7 +752,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
if (state_machine->get_end_node() == name) {
int endofs = nr.node.size.x - font->get_string_size(TTR("End")).x;
state_machine_draw->draw_string(font, offset + Vector2(endofs, -font->get_height() - 3 * EDSCALE + font->get_ascent()), TTR("End"), font_color);
}
@ -844,7 +809,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
}
void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
if (!playback.is_valid() || !playback->is_playing())
@ -891,7 +855,6 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
}
void AnimationNodeStateMachineEditor::_update_graph() {
if (updating)
return;
@ -903,7 +866,6 @@ void AnimationNodeStateMachineEditor::_update_graph() {
}
void AnimationNodeStateMachineEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
@ -928,7 +890,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
if (p_what == NOTIFICATION_PROCESS) {
String error;
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
@ -1017,7 +978,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
{
if (last_travel_path.size() != tp.size()) {
same_travel_path = false;
} else {
@ -1032,7 +992,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
//update if travel state changed
if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) {
state_machine_draw->update();
last_travel_path = tp;
last_current_node = current_node;
@ -1043,7 +1002,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
{
if (current_node != StringName() && state_machine->has_node(current_node)) {
String next = current_node;
Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next);
Ref<AnimationNodeStateMachinePlayback> current_node_playback;
@ -1063,7 +1021,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
if (last_play_pos != play_pos) {
last_play_pos = play_pos;
state_machine_play_pos->update();
}
@ -1076,17 +1033,14 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
}
void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) {
AnimationTreeEditor::get_singleton()->enter_editor(p_name);
}
void AnimationNodeStateMachineEditor::_removed_from_graph() {
EditorNode::get_singleton()->edit_item(nullptr);
}
void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
const String &new_name = p_text;
ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1);
@ -1117,7 +1071,6 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
}
void AnimationNodeStateMachineEditor::_name_edited_focus_out() {
if (updating)
return;
@ -1125,7 +1078,6 @@ void AnimationNodeStateMachineEditor::_name_edited_focus_out() {
}
void AnimationNodeStateMachineEditor::_scroll_changed(double) {
if (updating)
return;
@ -1134,7 +1086,6 @@ void AnimationNodeStateMachineEditor::_scroll_changed(double) {
}
void AnimationNodeStateMachineEditor::_erase_selected() {
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
updating = true;
undo_redo->create_action(TTR("Node Removed"));
@ -1158,7 +1109,6 @@ void AnimationNodeStateMachineEditor::_erase_selected() {
}
if (selected_transition_to != StringName() && selected_transition_from != StringName() && state_machine->has_transition(selected_transition_from, selected_transition_to)) {
Ref<AnimationNodeStateMachineTransition> tr = state_machine->get_transition(state_machine->find_transition(selected_transition_from, selected_transition_to));
updating = true;
undo_redo->create_action(TTR("Transition Removed"));
@ -1176,9 +1126,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() {
}
void AnimationNodeStateMachineEditor::_autoplay_selected() {
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
StringName new_start_node;
if (state_machine->get_start_node() == selected_node) { //toggle it
new_start_node = StringName();
@ -1199,9 +1147,7 @@ void AnimationNodeStateMachineEditor::_autoplay_selected() {
}
void AnimationNodeStateMachineEditor::_end_selected() {
if (selected_node != StringName() && state_machine->has_node(selected_node)) {
StringName new_end_node;
if (state_machine->get_end_node() == selected_node) { //toggle it
new_end_node = StringName();
@ -1221,7 +1167,6 @@ void AnimationNodeStateMachineEditor::_end_selected() {
}
}
void AnimationNodeStateMachineEditor::_update_mode() {
if (tool_select->is_pressed()) {
tool_erase_hb->show();
tool_erase->set_disabled(selected_node == StringName() && selected_transition_from == StringName() && selected_transition_to == StringName());
@ -1233,7 +1178,6 @@ void AnimationNodeStateMachineEditor::_update_mode() {
}
void AnimationNodeStateMachineEditor::_bind_methods() {
ClassDB::bind_method("_update_graph", &AnimationNodeStateMachineEditor::_update_graph);
ClassDB::bind_method("_removed_from_graph", &AnimationNodeStateMachineEditor::_removed_from_graph);
@ -1244,7 +1188,6 @@ void AnimationNodeStateMachineEditor::_bind_methods() {
AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = nullptr;
AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
singleton = this;
updating = false;