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:
@@ -40,7 +40,6 @@
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void AnimationTreePlayerEditor::edit(AnimationTreePlayer *p_anim_tree) {
|
||||
|
||||
anim_tree = p_anim_tree;
|
||||
|
||||
if (!anim_tree) {
|
||||
@@ -60,15 +59,12 @@ void AnimationTreePlayerEditor::edit(AnimationTreePlayer *p_anim_tree) {
|
||||
}
|
||||
|
||||
Size2 AnimationTreePlayerEditor::_get_maximum_size() {
|
||||
|
||||
Size2 max;
|
||||
|
||||
for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
|
||||
|
||||
Point2 pos = anim_tree->node_get_position(E->get());
|
||||
|
||||
if (click_type == CLICK_NODE && click_node == E->get()) {
|
||||
|
||||
pos += click_motion - click_pos;
|
||||
}
|
||||
pos += get_node_size(E->get());
|
||||
@@ -84,7 +80,6 @@ Size2 AnimationTreePlayerEditor::_get_maximum_size() {
|
||||
const char *AnimationTreePlayerEditor::_node_type_names[] = { "Output", "Animation", "OneShot", "Mix", "Blend2", "Blend3", "Blend4", "TimeScale", "TimeSeek", "Transition" };
|
||||
|
||||
Size2 AnimationTreePlayerEditor::get_node_size(const StringName &p_node) const {
|
||||
|
||||
AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
|
||||
|
||||
Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
|
||||
@@ -113,7 +108,6 @@ Size2 AnimationTreePlayerEditor::get_node_size(const StringName &p_node) const {
|
||||
case AnimationTreePlayer::NODE_BLEND4:
|
||||
case AnimationTreePlayer::NODE_TIMESCALE:
|
||||
case AnimationTreePlayer::NODE_TRANSITION: {
|
||||
|
||||
size.height += font->get_height();
|
||||
} break;
|
||||
case AnimationTreePlayer::NODE_MAX: {
|
||||
@@ -127,30 +121,24 @@ Size2 AnimationTreePlayerEditor::get_node_size(const StringName &p_node) const {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_changede(String) {
|
||||
|
||||
edit_dialog->hide();
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_changeds(String s) {
|
||||
|
||||
_edit_dialog_changed();
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_changedf(float) {
|
||||
|
||||
_edit_dialog_changed();
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_changed() {
|
||||
|
||||
if (updating_edit)
|
||||
return;
|
||||
|
||||
if (renaming_edit) {
|
||||
|
||||
if (anim_tree->node_rename(edited_node, edit_line[0]->get_text()) == OK) {
|
||||
for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
|
||||
|
||||
if (E->get() == edited_node)
|
||||
E->get() = edit_line[0]->get_text();
|
||||
}
|
||||
@@ -163,7 +151,6 @@ void AnimationTreePlayerEditor::_edit_dialog_changed() {
|
||||
AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
|
||||
|
||||
switch (type) {
|
||||
|
||||
case AnimationTreePlayer::NODE_TIMESCALE:
|
||||
anim_tree->timescale_node_set_scale(edited_node, edit_line[0]->get_text().to_double());
|
||||
break;
|
||||
@@ -207,35 +194,29 @@ void AnimationTreePlayerEditor::_edit_dialog_changed() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_animation_changed() {
|
||||
|
||||
Ref<Animation> anim = property_editor->get_variant().operator RefPtr();
|
||||
anim_tree->animation_node_set_animation(edited_node, anim);
|
||||
update();
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_dialog_edit_animation() {
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
get_tree()->get_root()->get_child(0)->call("_resource_selected", property_editor->get_variant().operator RefPtr());
|
||||
};
|
||||
};
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_oneshot_start() {
|
||||
|
||||
anim_tree->oneshot_node_start(edited_node);
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_play_toggled() {
|
||||
|
||||
anim_tree->set_active(play_button->is_pressed());
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_master_anim_menu_item(int p_item) {
|
||||
|
||||
if (p_item == 0)
|
||||
_edit_filters();
|
||||
else {
|
||||
|
||||
String str = master_anim_popup->get_item_text(p_item);
|
||||
anim_tree->animation_node_set_master_animation(edited_node, str);
|
||||
}
|
||||
@@ -243,14 +224,12 @@ void AnimationTreePlayerEditor::_master_anim_menu_item(int p_item) {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_popup_edit_dialog() {
|
||||
|
||||
updating_edit = true;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
edit_scroll[i]->hide();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
edit_line[i]->hide();
|
||||
edit_label[i]->hide();
|
||||
}
|
||||
@@ -267,7 +246,6 @@ void AnimationTreePlayerEditor::_popup_edit_dialog() {
|
||||
popup_pos += get_global_position();
|
||||
|
||||
if (renaming_edit) {
|
||||
|
||||
edit_label[0]->set_text(TTR("New name:"));
|
||||
edit_label[0]->set_position(Point2(5, 5));
|
||||
edit_label[0]->show();
|
||||
@@ -277,15 +255,12 @@ void AnimationTreePlayerEditor::_popup_edit_dialog() {
|
||||
edit_dialog->set_size(Size2(150, 50));
|
||||
|
||||
} else {
|
||||
|
||||
AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
|
||||
|
||||
switch (type) {
|
||||
|
||||
case AnimationTreePlayer::NODE_ANIMATION:
|
||||
|
||||
if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()))) {
|
||||
|
||||
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(anim_tree->get_node(anim_tree->get_master_player()));
|
||||
master_anim_popup->clear();
|
||||
master_anim_popup->add_item(TTR("Edit Filters"));
|
||||
@@ -435,7 +410,6 @@ void AnimationTreePlayerEditor::_popup_edit_dialog() {
|
||||
break;
|
||||
|
||||
case AnimationTreePlayer::NODE_TRANSITION: {
|
||||
|
||||
edit_label[0]->set_text(TTR("X-Fade Time (s):"));
|
||||
edit_label[0]->set_position(Point2(5, 5));
|
||||
edit_label[0]->show();
|
||||
@@ -471,7 +445,6 @@ void AnimationTreePlayerEditor::_popup_edit_dialog() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
|
||||
RID ci = get_canvas_item();
|
||||
AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
|
||||
|
||||
@@ -485,7 +458,6 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
Size2 size = get_node_size(p_node);
|
||||
Point2 pos = anim_tree->node_get_position(p_node);
|
||||
if (click_type == CLICK_NODE && click_node == p_node) {
|
||||
|
||||
pos += click_motion - click_pos;
|
||||
if (pos.x < 5)
|
||||
pos.x = 5;
|
||||
@@ -521,11 +493,9 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
|
||||
if (inputs) {
|
||||
for (int i = 0; i < inputs; i++) {
|
||||
|
||||
slot_icon->draw(ci, ofs + Point2(-slot_icon->get_width(), icon_h_ofs));
|
||||
String text;
|
||||
switch (type) {
|
||||
|
||||
case AnimationTreePlayer::NODE_TIMESCALE:
|
||||
case AnimationTreePlayer::NODE_TIMESEEK:
|
||||
text = "in";
|
||||
@@ -597,7 +567,6 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
bool editable = true;
|
||||
switch (type) {
|
||||
case AnimationTreePlayer::NODE_ANIMATION: {
|
||||
|
||||
Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
|
||||
String text;
|
||||
if (anim_tree->animation_node_get_master_animation(p_node) != "")
|
||||
@@ -617,7 +586,6 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
case AnimationTreePlayer::NODE_BLEND4:
|
||||
case AnimationTreePlayer::NODE_TIMESCALE:
|
||||
case AnimationTreePlayer::NODE_TRANSITION: {
|
||||
|
||||
font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, "edit...", font_color_title);
|
||||
} break;
|
||||
default:
|
||||
@@ -625,7 +593,6 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
}
|
||||
|
||||
if (editable) {
|
||||
|
||||
Ref<Texture> arrow = get_icon("GuiDropdown", "EditorIcons");
|
||||
Point2 arrow_ofs(w - arrow->get_width(), Math::floor((h - arrow->get_height()) / 2));
|
||||
arrow->draw(ci, ofs + arrow_ofs);
|
||||
@@ -633,14 +600,12 @@ void AnimationTreePlayerEditor::_draw_node(const StringName &p_node) {
|
||||
}
|
||||
|
||||
AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const {
|
||||
|
||||
Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
|
||||
Ref<Font> font = get_font("font", "PopupMenu");
|
||||
|
||||
float h = (font->get_height() + get_constant("vseparation", "PopupMenu"));
|
||||
|
||||
for (const List<StringName>::Element *E = order.back(); E; E = E->prev()) {
|
||||
|
||||
const StringName &node = E->get();
|
||||
|
||||
AnimationTreePlayer::NodeType type = anim_tree->node_get_type(node);
|
||||
@@ -668,9 +633,7 @@ AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(co
|
||||
int count = MAX(inputs, 1);
|
||||
|
||||
if (inputs == 0 || (pos.x > size.width / 2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
|
||||
|
||||
if (y < count * h) {
|
||||
|
||||
if (p_slot_index)
|
||||
*p_slot_index = 0;
|
||||
return CLICK_OUTPUT_SLOT;
|
||||
@@ -678,7 +641,6 @@ AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(co
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
if (y < h) {
|
||||
if (p_slot_index)
|
||||
*p_slot_index = i;
|
||||
@@ -695,7 +657,6 @@ AnimationTreePlayerEditor::ClickType AnimationTreePlayerEditor::_locate_click(co
|
||||
}
|
||||
|
||||
Point2 AnimationTreePlayerEditor::_get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot) {
|
||||
|
||||
Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
|
||||
Ref<Font> font = get_font("font", "PopupMenu");
|
||||
Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons");
|
||||
@@ -704,7 +665,6 @@ Point2 AnimationTreePlayerEditor::_get_slot_pos(const StringName &p_node_id, boo
|
||||
Point2 pos = anim_tree->node_get_position(p_node_id);
|
||||
|
||||
if (click_type == CLICK_NODE && click_node == p_node_id) {
|
||||
|
||||
pos += click_motion - click_pos;
|
||||
if (pos.x < 5)
|
||||
pos.x = 5;
|
||||
@@ -733,19 +693,15 @@ Point2 AnimationTreePlayerEditor::_get_slot_pos(const StringName &p_node_id, boo
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
|
||||
if (mb.is_valid()) {
|
||||
|
||||
if (mb->is_pressed()) {
|
||||
|
||||
if (mb->get_button_index() == 1) {
|
||||
click_pos = Point2(mb->get_position().x, mb->get_position().y);
|
||||
click_motion = click_pos;
|
||||
click_type = _locate_click(click_pos, &click_node, &click_slot);
|
||||
if (click_type != CLICK_NONE) {
|
||||
|
||||
order.erase(click_node);
|
||||
order.push_back(click_node);
|
||||
update();
|
||||
@@ -759,7 +715,6 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
click_pos = _get_slot_pos(click_node, false, click_slot);
|
||||
} break;
|
||||
case CLICK_PARAMETER: {
|
||||
|
||||
edited_node = click_node;
|
||||
renaming_edit = false;
|
||||
_popup_edit_dialog();
|
||||
@@ -771,7 +726,6 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
}
|
||||
}
|
||||
if (mb->get_button_index() == 2) {
|
||||
|
||||
if (click_type != CLICK_NONE) {
|
||||
click_type = CLICK_NONE;
|
||||
update();
|
||||
@@ -781,7 +735,6 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
Point2 rclick_pos = Point2(mb->get_position().x, mb->get_position().y);
|
||||
rclick_type = _locate_click(rclick_pos, &rclick_node, &rclick_slot);
|
||||
if (rclick_type == CLICK_INPUT_SLOT || rclick_type == CLICK_OUTPUT_SLOT) {
|
||||
|
||||
node_popup->clear();
|
||||
node_popup->set_size(Size2(1, 1));
|
||||
node_popup->add_item(TTR("Disconnect"), NODE_DISCONNECT);
|
||||
@@ -813,24 +766,19 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (mb->get_button_index() == 1 && click_type != CLICK_NONE) {
|
||||
|
||||
switch (click_type) {
|
||||
case CLICK_INPUT_SLOT:
|
||||
case CLICK_OUTPUT_SLOT: {
|
||||
|
||||
Point2 dst_click_pos = Point2(mb->get_position().x, mb->get_position().y);
|
||||
StringName id;
|
||||
int slot;
|
||||
ClickType dst_click_type = _locate_click(dst_click_pos, &id, &slot);
|
||||
|
||||
if (dst_click_type == CLICK_INPUT_SLOT && click_type == CLICK_OUTPUT_SLOT) {
|
||||
|
||||
anim_tree->connect_nodes(click_node, id, slot);
|
||||
}
|
||||
if (click_type == CLICK_INPUT_SLOT && dst_click_type == CLICK_OUTPUT_SLOT) {
|
||||
|
||||
anim_tree->connect_nodes(id, click_node, click_slot);
|
||||
}
|
||||
|
||||
@@ -857,14 +805,11 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
|
||||
if (mm.is_valid()) {
|
||||
|
||||
if (mm->get_button_mask() & 1 && click_type != CLICK_NONE) {
|
||||
|
||||
click_motion = Point2(mm->get_position().x, mm->get_position().y);
|
||||
update();
|
||||
}
|
||||
if (mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
|
||||
|
||||
h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
|
||||
v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);
|
||||
update();
|
||||
@@ -873,7 +818,6 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color) {
|
||||
|
||||
static const int steps = 20;
|
||||
|
||||
Rect2 r;
|
||||
@@ -884,7 +828,6 @@ void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vect
|
||||
|
||||
Vector2 prev;
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
|
||||
float d = i / float(steps);
|
||||
float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
|
||||
if (flip)
|
||||
@@ -892,7 +835,6 @@ void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vect
|
||||
Vector2 p = r.position + Vector2(d * r.size.width, c * r.size.height);
|
||||
|
||||
if (i > 0) {
|
||||
|
||||
draw_line(prev, p, p_color, 2);
|
||||
}
|
||||
|
||||
@@ -901,27 +843,21 @@ void AnimationTreePlayerEditor::_draw_cos_line(const Vector2 &p_from, const Vect
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
play_button->set_icon(get_icon("Play", "EditorIcons"));
|
||||
add_menu->set_icon(get_icon("Add", "EditorIcons"));
|
||||
} break;
|
||||
case NOTIFICATION_DRAW: {
|
||||
|
||||
_update_scrollbars();
|
||||
//VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1));
|
||||
get_stylebox("bg", "Tree")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
|
||||
|
||||
for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
|
||||
|
||||
_draw_node(E->get());
|
||||
}
|
||||
|
||||
if (click_type == CLICK_INPUT_SLOT || click_type == CLICK_OUTPUT_SLOT) {
|
||||
|
||||
_draw_cos_line(click_pos, click_motion, Color(0.5, 1, 0.5, 0.8));
|
||||
}
|
||||
|
||||
@@ -929,7 +865,6 @@ void AnimationTreePlayerEditor::_notification(int p_what) {
|
||||
anim_tree->get_connection_list(&connections);
|
||||
|
||||
for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
|
||||
|
||||
const AnimationTreePlayer::Connection &c = E->get();
|
||||
Point2 source = _get_slot_pos(c.src_node, false, 0);
|
||||
Point2 dest = _get_slot_pos(c.dst_node, true, c.dst_input);
|
||||
@@ -952,13 +887,10 @@ void AnimationTreePlayerEditor::_notification(int p_what) {
|
||||
const Point2 status_offset = Point2(5, 25) * EDSCALE + Point2(0, f->get_ascent());
|
||||
|
||||
switch (anim_tree->get_last_error()) {
|
||||
|
||||
case AnimationTreePlayer::CONNECT_OK: {
|
||||
|
||||
f->draw(get_canvas_item(), status_offset, TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
|
||||
} break;
|
||||
default: {
|
||||
|
||||
f->draw(get_canvas_item(), status_offset, TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
|
||||
} break;
|
||||
}
|
||||
@@ -968,7 +900,6 @@ void AnimationTreePlayerEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_update_scrollbars() {
|
||||
|
||||
Size2 size = get_size();
|
||||
Size2 hmin = h_scroll->get_combined_minimum_size();
|
||||
Size2 vmin = v_scroll->get_combined_minimum_size();
|
||||
@@ -982,11 +913,9 @@ void AnimationTreePlayerEditor::_update_scrollbars() {
|
||||
Size2 min = _get_maximum_size();
|
||||
|
||||
if (min.height < size.height - hmin.height) {
|
||||
|
||||
v_scroll->hide();
|
||||
offset.y = 0;
|
||||
} else {
|
||||
|
||||
v_scroll->show();
|
||||
v_scroll->set_max(min.height);
|
||||
v_scroll->set_page(size.height - hmin.height);
|
||||
@@ -994,11 +923,9 @@ void AnimationTreePlayerEditor::_update_scrollbars() {
|
||||
}
|
||||
|
||||
if (min.width < size.width - vmin.width) {
|
||||
|
||||
h_scroll->hide();
|
||||
offset.x = 0;
|
||||
} else {
|
||||
|
||||
h_scroll->show();
|
||||
h_scroll->set_max(min.width);
|
||||
h_scroll->set_page(size.width - vmin.width);
|
||||
@@ -1007,34 +934,26 @@ void AnimationTreePlayerEditor::_update_scrollbars() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_scroll_moved(float) {
|
||||
|
||||
offset.x = h_scroll->get_value();
|
||||
offset.y = v_scroll->get_value();
|
||||
update();
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_node_menu_item(int p_item) {
|
||||
|
||||
switch (p_item) {
|
||||
|
||||
case NODE_DISCONNECT: {
|
||||
|
||||
if (rclick_type == CLICK_INPUT_SLOT) {
|
||||
|
||||
anim_tree->disconnect_nodes(rclick_node, rclick_slot);
|
||||
update();
|
||||
}
|
||||
|
||||
if (rclick_type == CLICK_OUTPUT_SLOT) {
|
||||
|
||||
List<AnimationTreePlayer::Connection> connections;
|
||||
anim_tree->get_connection_list(&connections);
|
||||
|
||||
for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
|
||||
|
||||
const AnimationTreePlayer::Connection &c = E->get();
|
||||
if (c.dst_node == rclick_node) {
|
||||
|
||||
anim_tree->disconnect_nodes(c.dst_node, c.dst_input);
|
||||
}
|
||||
}
|
||||
@@ -1043,37 +962,31 @@ void AnimationTreePlayerEditor::_node_menu_item(int p_item) {
|
||||
|
||||
} break;
|
||||
case NODE_RENAME: {
|
||||
|
||||
renaming_edit = true;
|
||||
edited_node = rclick_node;
|
||||
_popup_edit_dialog();
|
||||
|
||||
} break;
|
||||
case NODE_ADD_INPUT: {
|
||||
|
||||
anim_tree->transition_node_set_input_count(rclick_node, anim_tree->transition_node_get_input_count(rclick_node) + 1);
|
||||
update();
|
||||
} break;
|
||||
case NODE_DELETE_INPUT: {
|
||||
|
||||
anim_tree->transition_node_delete_input(rclick_node, rclick_slot);
|
||||
update();
|
||||
} break;
|
||||
case NODE_SET_AUTOADVANCE: {
|
||||
|
||||
anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, true);
|
||||
update();
|
||||
|
||||
} break;
|
||||
case NODE_CLEAR_AUTOADVANCE: {
|
||||
|
||||
anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, false);
|
||||
update();
|
||||
|
||||
} break;
|
||||
|
||||
case NODE_ERASE: {
|
||||
|
||||
if (rclick_node == "out")
|
||||
break;
|
||||
order.erase(rclick_node);
|
||||
@@ -1084,7 +997,6 @@ void AnimationTreePlayerEditor::_node_menu_item(int p_item) {
|
||||
}
|
||||
|
||||
StringName AnimationTreePlayerEditor::_add_node(int p_item) {
|
||||
|
||||
static const char *bname[] = {
|
||||
"out",
|
||||
"anim",
|
||||
@@ -1102,7 +1014,6 @@ StringName AnimationTreePlayerEditor::_add_node(int p_item) {
|
||||
int idx = 1;
|
||||
|
||||
while (true) {
|
||||
|
||||
name = bname[p_item];
|
||||
if (idx > 1)
|
||||
name += " " + itos(idx);
|
||||
@@ -1125,14 +1036,11 @@ StringName AnimationTreePlayerEditor::_add_node(int p_item) {
|
||||
};
|
||||
|
||||
void AnimationTreePlayerEditor::_file_dialog_selected(String p_path) {
|
||||
|
||||
switch (file_op) {
|
||||
|
||||
case MENU_IMPORT_ANIMATIONS: {
|
||||
Vector<String> files = file_dialog->get_selected_files();
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
|
||||
StringName node = _add_node(AnimationTreePlayer::NODE_ANIMATION);
|
||||
|
||||
RES anim = ResourceLoader::load(files[i]);
|
||||
@@ -1147,33 +1055,26 @@ void AnimationTreePlayerEditor::_file_dialog_selected(String p_path) {
|
||||
};
|
||||
|
||||
void AnimationTreePlayerEditor::_add_menu_item(int p_item) {
|
||||
|
||||
if (p_item == MENU_GRAPH_CLEAR) {
|
||||
|
||||
//clear
|
||||
} else if (p_item == MENU_IMPORT_ANIMATIONS) {
|
||||
|
||||
file_op = MENU_IMPORT_ANIMATIONS;
|
||||
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
||||
file_dialog->popup_centered_ratio();
|
||||
|
||||
} else {
|
||||
|
||||
_add_node(p_item);
|
||||
}
|
||||
}
|
||||
|
||||
Size2 AnimationTreePlayerEditor::get_minimum_size() const {
|
||||
|
||||
return Size2(10, 200);
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_find_paths_for_filter(const StringName &p_node, Set<String> &paths) {
|
||||
|
||||
ERR_FAIL_COND(!anim_tree->node_exists(p_node));
|
||||
|
||||
for (int i = 0; i < anim_tree->node_get_input_count(p_node); i++) {
|
||||
|
||||
StringName port = anim_tree->node_get_input_source(p_node, i);
|
||||
if (port == StringName())
|
||||
continue;
|
||||
@@ -1181,10 +1082,8 @@ void AnimationTreePlayerEditor::_find_paths_for_filter(const StringName &p_node,
|
||||
}
|
||||
|
||||
if (anim_tree->node_get_type(p_node) == AnimationTreePlayer::NODE_ANIMATION) {
|
||||
|
||||
Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
|
||||
if (anim.is_valid()) {
|
||||
|
||||
for (int i = 0; i < anim->get_track_count(); i++) {
|
||||
paths.insert(anim->track_get_path(i));
|
||||
}
|
||||
@@ -1193,7 +1092,6 @@ void AnimationTreePlayerEditor::_find_paths_for_filter(const StringName &p_node,
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_filter_edited() {
|
||||
|
||||
TreeItem *ed = filter->get_edited();
|
||||
if (!ed)
|
||||
return;
|
||||
@@ -1208,7 +1106,6 @@ void AnimationTreePlayerEditor::_filter_edited() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_edit_filters() {
|
||||
|
||||
filter_dialog->popup_centered_ratio();
|
||||
filter->clear();
|
||||
|
||||
@@ -1222,7 +1119,6 @@ void AnimationTreePlayerEditor::_edit_filters() {
|
||||
Node *base = anim_tree->get_node(anim_tree->get_base_path());
|
||||
|
||||
for (Set<String>::Element *E = npb.front(); E; E = E->next()) {
|
||||
|
||||
TreeItem *parent = root;
|
||||
String descr = E->get();
|
||||
if (base) {
|
||||
@@ -1232,7 +1128,6 @@ void AnimationTreePlayerEditor::_edit_filters() {
|
||||
Node *n = base->get_node(np);
|
||||
Skeleton *s = Object::cast_to<Skeleton>(n);
|
||||
if (s) {
|
||||
|
||||
String skelbase = E->get().substr(0, E->get().find(":"));
|
||||
|
||||
int bidx = s->find_bone(np.get_subname(0));
|
||||
@@ -1241,14 +1136,12 @@ void AnimationTreePlayerEditor::_edit_filters() {
|
||||
int bparent = s->get_bone_parent(bidx);
|
||||
//
|
||||
if (bparent != -1) {
|
||||
|
||||
String bpn = skelbase + ":" + s->get_bone_name(bparent);
|
||||
if (pm.has(bpn)) {
|
||||
parent = pm[bpn];
|
||||
descr = np.get_subname(0);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (pm.has(skelbase)) {
|
||||
parent = pm[skelbase];
|
||||
}
|
||||
@@ -1275,7 +1168,6 @@ void AnimationTreePlayerEditor::_edit_filters() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_add_menu_item", &AnimationTreePlayerEditor::_add_menu_item);
|
||||
ClassDB::bind_method("_node_menu_item", &AnimationTreePlayerEditor::_node_menu_item);
|
||||
ClassDB::bind_method("_gui_input", &AnimationTreePlayerEditor::_gui_input);
|
||||
@@ -1296,7 +1188,6 @@ void AnimationTreePlayerEditor::_bind_methods() {
|
||||
}
|
||||
|
||||
AnimationTreePlayerEditor::AnimationTreePlayerEditor() {
|
||||
|
||||
set_focus_mode(FOCUS_ALL);
|
||||
|
||||
PopupMenu *p;
|
||||
@@ -1435,17 +1326,14 @@ AnimationTreePlayerEditor::AnimationTreePlayerEditor() {
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
anim_tree_editor->edit(Object::cast_to<AnimationTreePlayer>(p_object));
|
||||
}
|
||||
|
||||
bool AnimationTreePlayerEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("AnimationTreePlayer");
|
||||
}
|
||||
|
||||
void AnimationTreePlayerEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
//editor->hide_animation_player_editors();
|
||||
//editor->animation_panel_make_visible(true);
|
||||
@@ -1453,7 +1341,6 @@ void AnimationTreePlayerEditorPlugin::make_visible(bool p_visible) {
|
||||
editor->make_bottom_panel_item_visible(anim_tree_editor);
|
||||
anim_tree_editor->set_physics_process(true);
|
||||
} else {
|
||||
|
||||
if (anim_tree_editor->is_visible_in_tree())
|
||||
editor->hide_bottom_panel();
|
||||
button->hide();
|
||||
@@ -1462,7 +1349,6 @@ void AnimationTreePlayerEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
AnimationTreePlayerEditorPlugin::AnimationTreePlayerEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
anim_tree_editor = memnew(AnimationTreePlayerEditor);
|
||||
anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
|
||||
|
||||
Reference in New Issue
Block a user