You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
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:
@@ -44,7 +44,6 @@
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
void AnimationPlayerEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if (player && player == p_node) {
|
||||
player = nullptr;
|
||||
|
||||
@@ -58,24 +57,20 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_PROCESS: {
|
||||
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
updating = true;
|
||||
|
||||
if (player->is_playing()) {
|
||||
|
||||
{
|
||||
String animname = player->get_assigned_animation();
|
||||
|
||||
if (player->has_animation(animname)) {
|
||||
Ref<Animation> anim = player->get_animation(animname);
|
||||
if (!anim.is_null()) {
|
||||
|
||||
frame->set_max(anim->get_length());
|
||||
}
|
||||
}
|
||||
@@ -96,7 +91,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
updating = false;
|
||||
} break;
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
tool_anim->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
|
||||
|
||||
onion_skinning->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu));
|
||||
@@ -108,11 +102,9 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
|
||||
} break;
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
|
||||
add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel"));
|
||||
} break;
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
|
||||
autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons"));
|
||||
|
||||
play->set_icon(get_theme_icon("PlayStart", "EditorIcons"));
|
||||
@@ -147,7 +139,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_autoplay_pressed() {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
if (animation->get_item_count() == 0) {
|
||||
@@ -176,15 +167,12 @@ void AnimationPlayerEditor::_autoplay_pressed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_play_pressed() {
|
||||
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
}
|
||||
|
||||
if (current != "") {
|
||||
|
||||
if (current == player->get_assigned_animation())
|
||||
player->stop(); //so it won't blend with itself
|
||||
player->play(current);
|
||||
@@ -195,19 +183,15 @@ void AnimationPlayerEditor::_play_pressed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_play_from_pressed() {
|
||||
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
}
|
||||
|
||||
if (current != "") {
|
||||
|
||||
float time = player->get_current_animation_position();
|
||||
|
||||
if (current == player->get_assigned_animation() && player->is_playing()) {
|
||||
|
||||
player->stop(); //so it won't blend with itself
|
||||
}
|
||||
|
||||
@@ -220,15 +204,12 @@ void AnimationPlayerEditor::_play_from_pressed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_play_bw_pressed() {
|
||||
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
}
|
||||
|
||||
if (current != "") {
|
||||
|
||||
if (current == player->get_assigned_animation())
|
||||
player->stop(); //so it won't blend with itself
|
||||
player->play(current, -1, -1, true);
|
||||
@@ -239,15 +220,12 @@ void AnimationPlayerEditor::_play_bw_pressed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_play_bw_from_pressed() {
|
||||
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
}
|
||||
|
||||
if (current != "") {
|
||||
|
||||
float time = player->get_current_animation_position();
|
||||
if (current == player->get_assigned_animation())
|
||||
player->stop(); //so it won't blend with itself
|
||||
@@ -260,7 +238,6 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
|
||||
stop->set_pressed(false);
|
||||
}
|
||||
void AnimationPlayerEditor::_stop_pressed() {
|
||||
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
@@ -271,24 +248,20 @@ void AnimationPlayerEditor::_stop_pressed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_selected(int p_which) {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
// when selecting an animation, the idea is that the only interesting behavior
|
||||
// ui-wise is that it should play/blend the next one if currently playing
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
}
|
||||
|
||||
if (current != "") {
|
||||
|
||||
player->set_assigned_animation(current);
|
||||
|
||||
Ref<Animation> anim = player->get_animation(current);
|
||||
{
|
||||
|
||||
track_editor->set_animation(anim);
|
||||
Node *root = player->get_node(player->get_root());
|
||||
if (root) {
|
||||
@@ -310,7 +283,6 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_new() {
|
||||
|
||||
renaming = false;
|
||||
name_title->set_text(TTR("New Animation Name:"));
|
||||
|
||||
@@ -334,7 +306,6 @@ void AnimationPlayerEditor::_animation_new() {
|
||||
name->grab_focus();
|
||||
}
|
||||
void AnimationPlayerEditor::_animation_rename() {
|
||||
|
||||
if (animation->get_item_count() == 0)
|
||||
return;
|
||||
int selected = animation->get_selected();
|
||||
@@ -355,7 +326,6 @@ void AnimationPlayerEditor::_animation_load() {
|
||||
|
||||
ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions);
|
||||
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
||||
|
||||
file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
|
||||
}
|
||||
|
||||
@@ -364,7 +334,6 @@ void AnimationPlayerEditor::_animation_load() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path) {
|
||||
|
||||
int flg = 0;
|
||||
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
|
||||
flg |= ResourceSaver::FLAG_COMPRESS;
|
||||
@@ -382,7 +351,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
|
||||
|
||||
if (p_resource->get_path().is_resource_file()) {
|
||||
_animation_save_in_path(p_resource, p_resource->get_path());
|
||||
} else {
|
||||
@@ -391,14 +359,12 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
|
||||
|
||||
file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||
|
||||
List<String> extensions;
|
||||
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
|
||||
file->clear_filters();
|
||||
for (int i = 0; i < extensions.size(); i++) {
|
||||
|
||||
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
|
||||
}
|
||||
|
||||
@@ -412,7 +378,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
String existing;
|
||||
if (extensions.size()) {
|
||||
if (p_resource->get_name() != "") {
|
||||
@@ -429,7 +394,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource)
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_remove() {
|
||||
|
||||
if (animation->get_item_count() == 0)
|
||||
return;
|
||||
|
||||
@@ -440,7 +404,6 @@ void AnimationPlayerEditor::_animation_remove() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_remove_confirmed() {
|
||||
|
||||
String current = animation->get_item_text(animation->get_selected());
|
||||
Ref<Animation> anim = player->get_animation(current);
|
||||
|
||||
@@ -463,12 +426,9 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) {
|
||||
|
||||
int idx = -1;
|
||||
for (int i = 0; i < animation->get_item_count(); i++) {
|
||||
|
||||
if (animation->get_item_text(i) == p_anim) {
|
||||
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
@@ -482,7 +442,6 @@ void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) {
|
||||
}
|
||||
|
||||
double AnimationPlayerEditor::_get_editor_step() const {
|
||||
|
||||
// Returns the effective snapping value depending on snapping modifiers, or 0 if snapping is disabled.
|
||||
if (track_editor->is_snap_enabled()) {
|
||||
const String current = player->get_assigned_animation();
|
||||
@@ -497,7 +456,6 @@ double AnimationPlayerEditor::_get_editor_step() const {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_name_edited() {
|
||||
|
||||
player->stop();
|
||||
|
||||
String new_name = name->get_text();
|
||||
@@ -534,7 +492,6 @@ void AnimationPlayerEditor::_animation_name_edited() {
|
||||
_select_anim_by_name(new_name);
|
||||
|
||||
} else {
|
||||
|
||||
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
|
||||
new_anim->set_name(new_name);
|
||||
|
||||
@@ -556,7 +513,6 @@ void AnimationPlayerEditor::_animation_name_edited() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
|
||||
|
||||
if (animation->get_item_count() == 0)
|
||||
return;
|
||||
|
||||
@@ -571,7 +527,6 @@ void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_blend() {
|
||||
|
||||
if (updating_blends)
|
||||
return;
|
||||
|
||||
@@ -599,7 +554,6 @@ void AnimationPlayerEditor::_animation_blend() {
|
||||
blend_editor.next->add_item("", i);
|
||||
|
||||
for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
|
||||
|
||||
String to = E->get();
|
||||
TreeItem *blend = blend_editor.tree->create_item(root);
|
||||
blend->set_editable(0, false);
|
||||
@@ -627,7 +581,6 @@ void AnimationPlayerEditor::_animation_blend() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_blend_edited() {
|
||||
|
||||
if (updating_blends)
|
||||
return;
|
||||
|
||||
@@ -655,7 +608,6 @@ void AnimationPlayerEditor::_blend_edited() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::ensure_visibility() {
|
||||
|
||||
if (player && pin->is_pressed())
|
||||
return; // another player is pinned, don't reset
|
||||
|
||||
@@ -663,7 +615,6 @@ void AnimationPlayerEditor::ensure_visibility() {
|
||||
}
|
||||
|
||||
Dictionary AnimationPlayerEditor::get_state() const {
|
||||
|
||||
Dictionary d;
|
||||
|
||||
d["visible"] = is_visible_in_tree();
|
||||
@@ -676,7 +627,6 @@ Dictionary AnimationPlayerEditor::get_state() const {
|
||||
return d;
|
||||
}
|
||||
void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
|
||||
|
||||
if (!p_state.has("visible") || !p_state["visible"]) {
|
||||
return;
|
||||
}
|
||||
@@ -685,7 +635,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
|
||||
}
|
||||
|
||||
if (p_state.has("player")) {
|
||||
|
||||
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
|
||||
if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
|
||||
player = Object::cast_to<AnimationPlayer>(n);
|
||||
@@ -710,7 +659,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_resource_edit() {
|
||||
|
||||
if (animation->get_item_count()) {
|
||||
String current = animation->get_item_text(animation->get_selected());
|
||||
Ref<Animation> anim = player->get_animation(current);
|
||||
@@ -719,7 +667,6 @@ void AnimationPlayerEditor::_animation_resource_edit() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_edit() {
|
||||
|
||||
if (animation->get_item_count()) {
|
||||
String current = animation->get_item_text(animation->get_selected());
|
||||
Ref<Animation> anim = player->get_animation(current);
|
||||
@@ -736,7 +683,6 @@ void AnimationPlayerEditor::_animation_edit() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_dialog_action(String p_file) {
|
||||
|
||||
switch (current_option) {
|
||||
case RESOURCE_LOAD: {
|
||||
ERR_FAIL_COND(!player);
|
||||
@@ -745,11 +691,9 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
|
||||
ERR_FAIL_COND_MSG(res.is_null(), "Cannot load Animation from file '" + p_file + "'.");
|
||||
ERR_FAIL_COND_MSG(!res->is_class("Animation"), "Loaded resource from file '" + p_file + "' is not Animation.");
|
||||
if (p_file.find_last("/") != -1) {
|
||||
|
||||
p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length());
|
||||
}
|
||||
if (p_file.find_last("\\") != -1) {
|
||||
|
||||
p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length());
|
||||
}
|
||||
|
||||
@@ -768,7 +712,6 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
|
||||
break;
|
||||
}
|
||||
case RESOURCE_SAVE: {
|
||||
|
||||
String current = animation->get_item_text(animation->get_selected());
|
||||
if (current != "") {
|
||||
Ref<Animation> anim = player->get_animation(current);
|
||||
@@ -784,24 +727,20 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_scale_changed(const String &p_scale) {
|
||||
|
||||
player->set_speed_scale(p_scale.to_double());
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_update_animation() {
|
||||
|
||||
// the purpose of _update_animation is to reflect the current state
|
||||
// of the animation player in the current editor..
|
||||
|
||||
updating = true;
|
||||
|
||||
if (player->is_playing()) {
|
||||
|
||||
play->set_pressed(true);
|
||||
stop->set_pressed(false);
|
||||
|
||||
} else {
|
||||
|
||||
play->set_pressed(false);
|
||||
stop->set_pressed(true);
|
||||
}
|
||||
@@ -810,7 +749,6 @@ void AnimationPlayerEditor::_update_animation() {
|
||||
String current = player->get_assigned_animation();
|
||||
|
||||
for (int i = 0; i < animation->get_item_count(); i++) {
|
||||
|
||||
if (animation->get_item_text(i) == current) {
|
||||
animation->select(i);
|
||||
break;
|
||||
@@ -821,7 +759,6 @@ void AnimationPlayerEditor::_update_animation() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_update_player() {
|
||||
|
||||
updating = true;
|
||||
List<StringName> animlist;
|
||||
if (player)
|
||||
@@ -860,7 +797,6 @@ void AnimationPlayerEditor::_update_player() {
|
||||
|
||||
int active_idx = -1;
|
||||
for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
|
||||
|
||||
if (player->get_autoplay() == E->get())
|
||||
animation->add_icon_item(autoplay_icon, E->get());
|
||||
else
|
||||
@@ -877,7 +813,6 @@ void AnimationPlayerEditor::_update_player() {
|
||||
_animation_selected(active_idx);
|
||||
|
||||
} else if (animation->get_item_count() > 0) {
|
||||
|
||||
animation->select(0);
|
||||
autoplay->set_pressed(animation->get_item_text(0) == player->get_autoplay());
|
||||
_animation_selected(0);
|
||||
@@ -899,7 +834,6 @@ void AnimationPlayerEditor::_update_player() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
|
||||
|
||||
if (player && pin->is_pressed())
|
||||
return; // Ignore, pinned.
|
||||
player = p_player;
|
||||
@@ -924,7 +858,6 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!onion.can_overlay)
|
||||
return;
|
||||
|
||||
@@ -973,7 +906,6 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_duplicate() {
|
||||
|
||||
if (!animation->get_item_count())
|
||||
return;
|
||||
|
||||
@@ -986,9 +918,7 @@ void AnimationPlayerEditor::_animation_duplicate() {
|
||||
List<PropertyInfo> plist;
|
||||
anim->get_property_list(&plist);
|
||||
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
|
||||
|
||||
if (E->get().usage & PROPERTY_USAGE_STORAGE) {
|
||||
|
||||
new_anim->set(E->get().name, anim->get(E->get().name));
|
||||
}
|
||||
}
|
||||
@@ -1009,9 +939,7 @@ void AnimationPlayerEditor::_animation_duplicate() {
|
||||
undo_redo->commit_action();
|
||||
|
||||
for (int i = 0; i < animation->get_item_count(); i++) {
|
||||
|
||||
if (animation->get_item_text(i) == new_name) {
|
||||
|
||||
animation->select(i);
|
||||
_animation_selected(i);
|
||||
return;
|
||||
@@ -1020,7 +948,6 @@ void AnimationPlayerEditor::_animation_duplicate() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
|
||||
|
||||
if (updating || !player || player->is_playing()) {
|
||||
return;
|
||||
};
|
||||
@@ -1056,9 +983,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
|
||||
};
|
||||
|
||||
void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
|
||||
|
||||
if (player == p_pl && is_visible_in_tree()) {
|
||||
|
||||
_update_player();
|
||||
if (blend_editor.dialog->is_visible())
|
||||
_animation_blend(); // Update.
|
||||
@@ -1066,18 +991,15 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_list_changed() {
|
||||
|
||||
if (is_visible_in_tree())
|
||||
_update_player();
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) {
|
||||
|
||||
frame->set_max(p_len);
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) {
|
||||
|
||||
timeline_position = p_pos;
|
||||
|
||||
if (!is_visible_in_tree())
|
||||
@@ -1101,7 +1023,6 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag)
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
|
||||
String current;
|
||||
if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
|
||||
current = animation->get_item_text(animation->get_selected());
|
||||
@@ -1113,47 +1034,37 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
}
|
||||
|
||||
switch (p_option) {
|
||||
|
||||
case TOOL_NEW_ANIM: {
|
||||
|
||||
_animation_new();
|
||||
} break;
|
||||
case TOOL_LOAD_ANIM: {
|
||||
|
||||
_animation_load();
|
||||
} break;
|
||||
case TOOL_SAVE_ANIM: {
|
||||
|
||||
if (anim.is_valid()) {
|
||||
_animation_save(anim);
|
||||
}
|
||||
} break;
|
||||
case TOOL_SAVE_AS_ANIM: {
|
||||
|
||||
if (anim.is_valid()) {
|
||||
_animation_save_as(anim);
|
||||
}
|
||||
} break;
|
||||
case TOOL_DUPLICATE_ANIM: {
|
||||
|
||||
_animation_duplicate();
|
||||
|
||||
[[fallthrough]]; // Allow immediate rename after animation is duplicated
|
||||
}
|
||||
case TOOL_RENAME_ANIM: {
|
||||
|
||||
_animation_rename();
|
||||
} break;
|
||||
case TOOL_EDIT_TRANSITIONS: {
|
||||
|
||||
_animation_blend();
|
||||
} break;
|
||||
case TOOL_REMOVE_ANIM: {
|
||||
|
||||
_animation_remove();
|
||||
} break;
|
||||
case TOOL_COPY_ANIM: {
|
||||
|
||||
if (!animation->get_item_count()) {
|
||||
error_dialog->set_text(TTR("No animation to copy!"));
|
||||
error_dialog->popup_centered();
|
||||
@@ -1165,7 +1076,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
EditorSettings::get_singleton()->set_resource_clipboard(anim2);
|
||||
} break;
|
||||
case TOOL_PASTE_ANIM: {
|
||||
|
||||
Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
|
||||
if (!anim2.is_valid()) {
|
||||
error_dialog->set_text(TTR("No animation resource on clipboard!"));
|
||||
@@ -1181,7 +1091,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
int idx = 1;
|
||||
String base = name;
|
||||
while (player->has_animation(name)) {
|
||||
|
||||
idx++;
|
||||
name = base + " " + itos(idx);
|
||||
}
|
||||
@@ -1196,7 +1105,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
_select_anim_by_name(name);
|
||||
} break;
|
||||
case TOOL_EDIT_RESOURCE: {
|
||||
|
||||
if (!animation->get_item_count()) {
|
||||
error_dialog->set_text(TTR("No animation to edit!"));
|
||||
error_dialog->popup_centered();
|
||||
@@ -1211,14 +1119,11 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
|
||||
|
||||
PopupMenu *menu = onion_skinning->get_popup();
|
||||
int idx = menu->get_item_index(p_option);
|
||||
|
||||
switch (p_option) {
|
||||
|
||||
case ONION_SKINNING_ENABLE: {
|
||||
|
||||
onion.enabled = !onion.enabled;
|
||||
|
||||
if (onion.enabled)
|
||||
@@ -1228,13 +1133,11 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
|
||||
|
||||
} break;
|
||||
case ONION_SKINNING_PAST: {
|
||||
|
||||
// Ensure at least one of past/future is checked.
|
||||
onion.past = onion.future ? !onion.past : true;
|
||||
menu->set_item_checked(idx, onion.past);
|
||||
} break;
|
||||
case ONION_SKINNING_FUTURE: {
|
||||
|
||||
// Ensure at least one of past/future is checked.
|
||||
onion.future = onion.past ? !onion.future : true;
|
||||
menu->set_item_checked(idx, onion.future);
|
||||
@@ -1242,7 +1145,6 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
|
||||
case ONION_SKINNING_1_STEP: // Fall-through.
|
||||
case ONION_SKINNING_2_STEPS:
|
||||
case ONION_SKINNING_3_STEPS: {
|
||||
|
||||
onion.steps = (p_option - ONION_SKINNING_1_STEP) + 1;
|
||||
int one_frame_idx = menu->get_item_index(ONION_SKINNING_1_STEP);
|
||||
for (int i = 0; i <= ONION_SKINNING_LAST_STEPS_OPTION - ONION_SKINNING_1_STEP; i++) {
|
||||
@@ -1250,17 +1152,14 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
|
||||
}
|
||||
} break;
|
||||
case ONION_SKINNING_DIFFERENCES_ONLY: {
|
||||
|
||||
onion.differences_only = !onion.differences_only;
|
||||
menu->set_item_checked(idx, onion.differences_only);
|
||||
} break;
|
||||
case ONION_SKINNING_FORCE_WHITE_MODULATE: {
|
||||
|
||||
onion.force_white_modulate = !onion.force_white_modulate;
|
||||
menu->set_item_checked(idx, onion.force_white_modulate);
|
||||
} break;
|
||||
case ONION_SKINNING_INCLUDE_GIZMOS: {
|
||||
|
||||
onion.include_gizmos = !onion.include_gizmos;
|
||||
menu->set_item_checked(idx, onion.include_gizmos);
|
||||
} break;
|
||||
@@ -1268,12 +1167,9 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
|
||||
Ref<InputEventKey> k = p_ev;
|
||||
if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) {
|
||||
|
||||
switch (k->get_keycode()) {
|
||||
|
||||
case KEY_A: {
|
||||
if (!k->get_shift())
|
||||
_play_bw_from_pressed();
|
||||
@@ -1294,14 +1190,12 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_editor_visibility_changed() {
|
||||
|
||||
if (is_visible() && animation->get_item_count() > 0) {
|
||||
_start_onion_skinning();
|
||||
}
|
||||
}
|
||||
|
||||
bool AnimationPlayerEditor::_are_onion_layers_valid() {
|
||||
|
||||
ERR_FAIL_COND_V(!onion.past && !onion.future, false);
|
||||
|
||||
Point2 capture_size = get_tree()->get_root()->get_size();
|
||||
@@ -1309,7 +1203,6 @@ bool AnimationPlayerEditor::_are_onion_layers_valid() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_allocate_onion_layers() {
|
||||
|
||||
_free_onion_layers();
|
||||
|
||||
int captures = onion.get_needed_capture_count();
|
||||
@@ -1338,7 +1231,6 @@ void AnimationPlayerEditor::_allocate_onion_layers() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_free_onion_layers() {
|
||||
|
||||
for (int i = 0; i < onion.captures.size(); i++) {
|
||||
if (onion.captures[i].is_valid()) {
|
||||
RS::get_singleton()->free(onion.captures[i]);
|
||||
@@ -1349,7 +1241,6 @@ void AnimationPlayerEditor::_free_onion_layers() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_prepare_onion_layers_1() {
|
||||
|
||||
// This would be called per viewport and we want to act once only.
|
||||
int64_t frame = get_tree()->get_frame();
|
||||
if (frame == onion.last_frame)
|
||||
@@ -1378,7 +1269,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
||||
|
||||
Ref<Animation> anim = player->get_animation(player->get_assigned_animation());
|
||||
if (!anim.is_valid())
|
||||
return;
|
||||
@@ -1455,7 +1345,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
||||
int cidx = 0;
|
||||
onion.capture.material->set_shader_param("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color")));
|
||||
for (int step_off = step_off_a; step_off <= step_off_b; step_off++) {
|
||||
|
||||
if (step_off == 0) {
|
||||
// Skip present step and switch to the color of future.
|
||||
if (!onion.force_white_modulate)
|
||||
@@ -1507,7 +1396,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_start_onion_skinning() {
|
||||
|
||||
// FIXME: Using "idle_frame" makes onion layers update one frame behind the current.
|
||||
if (!get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
|
||||
get_tree()->connect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
|
||||
@@ -1515,9 +1403,7 @@ void AnimationPlayerEditor::_start_onion_skinning() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_stop_onion_skinning() {
|
||||
|
||||
if (get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) {
|
||||
|
||||
get_tree()->disconnect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred));
|
||||
|
||||
_free_onion_layers();
|
||||
@@ -1529,12 +1415,10 @@ void AnimationPlayerEditor::_stop_onion_skinning() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_pin_pressed() {
|
||||
|
||||
EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->update_tree();
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new);
|
||||
ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename);
|
||||
ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load);
|
||||
@@ -1556,7 +1440,6 @@ void AnimationPlayerEditor::_bind_methods() {
|
||||
AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr;
|
||||
|
||||
AnimationPlayer *AnimationPlayerEditor::get_player() const {
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -1800,24 +1683,20 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
|
||||
}
|
||||
|
||||
AnimationPlayerEditor::~AnimationPlayerEditor() {
|
||||
|
||||
_free_onion_layers();
|
||||
RS::get_singleton()->free(onion.capture.canvas);
|
||||
RS::get_singleton()->free(onion.capture.canvas_item);
|
||||
}
|
||||
|
||||
void AnimationPlayerEditorPlugin::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
set_force_draw_over_forwarding_enabled();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationPlayerEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
anim_editor->set_undo_redo(&get_undo_redo());
|
||||
if (!p_object)
|
||||
return;
|
||||
@@ -1825,14 +1704,11 @@ void AnimationPlayerEditorPlugin::edit(Object *p_object) {
|
||||
}
|
||||
|
||||
bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("AnimationPlayer");
|
||||
}
|
||||
|
||||
void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
|
||||
editor->make_bottom_panel_item_visible(anim_editor);
|
||||
anim_editor->set_process(true);
|
||||
anim_editor->ensure_visibility();
|
||||
@@ -1840,7 +1716,6 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
anim_editor = memnew(AnimationPlayerEditor(editor, this));
|
||||
anim_editor->set_undo_redo(EditorNode::get_undo_redo());
|
||||
|
||||
Reference in New Issue
Block a user