You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -43,17 +43,14 @@
|
||||
#include "scene/main/viewport.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 {
|
||||
@@ -411,7 +392,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);
|
||||
@@ -419,12 +399,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);
|
||||
@@ -437,7 +415,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 {
|
||||
@@ -458,7 +435,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
|
||||
}
|
||||
|
||||
if (base_name == String()) {
|
||||
|
||||
base_name = node->get_class().replace_first("AnimationNode", "");
|
||||
}
|
||||
|
||||
@@ -482,7 +458,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) {
|
||||
|
||||
Ref<AnimationNodeAnimation> anim;
|
||||
anim.instance();
|
||||
|
||||
@@ -509,7 +484,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_color("font_color", "Label");
|
||||
Color icon_color(1, 1, 1);
|
||||
Color accent = get_color("accent_color", "Editor");
|
||||
@@ -552,7 +526,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;
|
||||
|
||||
@@ -564,7 +537,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;
|
||||
|
||||
@@ -576,7 +548,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_stylebox("state_machine_frame", "GraphNode");
|
||||
@@ -617,7 +588,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;
|
||||
@@ -631,7 +601,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());
|
||||
@@ -697,7 +666,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();
|
||||
@@ -739,7 +707,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
|
||||
}
|
||||
|
||||
if (travel_path.size()) {
|
||||
|
||||
if (current == tl.from_node && travel_path[0] == tl.to_node) {
|
||||
travel = true;
|
||||
} else {
|
||||
@@ -765,7 +732,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);
|
||||
@@ -792,7 +758,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);
|
||||
}
|
||||
@@ -850,7 +815,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())
|
||||
@@ -897,7 +861,6 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachineEditor::_update_graph() {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
|
||||
@@ -909,7 +872,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_style_override("panel", get_stylebox("bg", "Tree"));
|
||||
error_label->add_color_override("font_color", get_color("error_color", "Editor"));
|
||||
@@ -942,7 +904,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");
|
||||
@@ -1031,7 +992,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
if (last_travel_path.size() != tp.size()) {
|
||||
same_travel_path = false;
|
||||
} else {
|
||||
@@ -1046,7 +1006,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;
|
||||
@@ -1057,7 +1016,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;
|
||||
@@ -1077,7 +1035,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
if (last_play_pos != play_pos) {
|
||||
|
||||
last_play_pos = play_pos;
|
||||
state_machine_play_pos->update();
|
||||
}
|
||||
@@ -1090,17 +1047,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(NULL);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -1131,7 +1085,6 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachineEditor::_name_edited_focus_out() {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
|
||||
@@ -1139,7 +1092,6 @@ void AnimationNodeStateMachineEditor::_name_edited_focus_out() {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachineEditor::_scroll_changed(double) {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
|
||||
@@ -1148,7 +1100,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"));
|
||||
@@ -1172,7 +1123,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"));
|
||||
@@ -1190,9 +1140,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();
|
||||
@@ -1213,9 +1161,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();
|
||||
@@ -1235,7 +1181,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());
|
||||
@@ -1247,7 +1192,6 @@ void AnimationNodeStateMachineEditor::_update_mode() {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachineEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_state_machine_gui_input", &AnimationNodeStateMachineEditor::_state_machine_gui_input);
|
||||
ClassDB::bind_method("_state_machine_draw", &AnimationNodeStateMachineEditor::_state_machine_draw);
|
||||
ClassDB::bind_method("_state_machine_pos_draw", &AnimationNodeStateMachineEditor::_state_machine_pos_draw);
|
||||
@@ -1274,7 +1218,6 @@ void AnimationNodeStateMachineEditor::_bind_methods() {
|
||||
AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = NULL;
|
||||
|
||||
AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
|
||||
|
||||
singleton = this;
|
||||
updating = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user