You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -46,7 +46,6 @@
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
void AnimationPlayerEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if (player && player == p_node) {
|
||||
player = NULL;
|
||||
|
||||
@@ -60,24 +59,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());
|
||||
}
|
||||
}
|
||||
@@ -98,7 +93,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
updating = false;
|
||||
} break;
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
||||
tool_anim->get_popup()->connect("id_pressed", this, "_animation_tool_menu");
|
||||
|
||||
onion_skinning->get_popup()->connect("id_pressed", this, "_onion_skinning_menu");
|
||||
@@ -110,11 +104,9 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
|
||||
} break;
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
|
||||
add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel"));
|
||||
} break;
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
|
||||
autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
|
||||
|
||||
play->set_icon(get_icon("PlayStart", "EditorIcons"));
|
||||
@@ -149,7 +141,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_autoplay_pressed() {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
if (animation->get_item_count() == 0) {
|
||||
@@ -178,15 +169,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);
|
||||
@@ -197,19 +185,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
|
||||
}
|
||||
|
||||
@@ -222,15 +206,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);
|
||||
@@ -241,15 +222,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
|
||||
@@ -262,7 +240,6 @@ void AnimationPlayerEditor::_play_bw_from_pressed() {
|
||||
stop->set_pressed(false);
|
||||
}
|
||||
void AnimationPlayerEditor::_stop_pressed() {
|
||||
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
@@ -273,24 +250,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) {
|
||||
@@ -312,7 +285,6 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_new() {
|
||||
|
||||
renaming = false;
|
||||
name_title->set_text(TTR("New Animation Name:"));
|
||||
|
||||
@@ -336,7 +308,6 @@ void AnimationPlayerEditor::_animation_new() {
|
||||
name->grab_focus();
|
||||
}
|
||||
void AnimationPlayerEditor::_animation_rename() {
|
||||
|
||||
if (animation->get_item_count() == 0)
|
||||
return;
|
||||
int selected = animation->get_selected();
|
||||
@@ -357,7 +328,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());
|
||||
}
|
||||
|
||||
@@ -366,7 +336,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;
|
||||
@@ -385,7 +354,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 {
|
||||
@@ -394,14 +362,12 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
|
||||
|
||||
file->set_mode(EditorFileDialog::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());
|
||||
}
|
||||
|
||||
@@ -430,7 +396,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource)
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_remove() {
|
||||
|
||||
if (animation->get_item_count() == 0)
|
||||
return;
|
||||
|
||||
@@ -439,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);
|
||||
|
||||
@@ -462,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;
|
||||
}
|
||||
@@ -481,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();
|
||||
@@ -496,7 +456,6 @@ double AnimationPlayerEditor::_get_editor_step() const {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_name_edited() {
|
||||
|
||||
player->stop();
|
||||
|
||||
String new_name = name->get_text();
|
||||
@@ -533,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);
|
||||
|
||||
@@ -555,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;
|
||||
|
||||
@@ -570,7 +527,6 @@ void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_blend() {
|
||||
|
||||
if (updating_blends)
|
||||
return;
|
||||
|
||||
@@ -598,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);
|
||||
@@ -626,7 +581,6 @@ void AnimationPlayerEditor::_animation_blend() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_blend_edited() {
|
||||
|
||||
if (updating_blends)
|
||||
return;
|
||||
|
||||
@@ -654,7 +608,6 @@ void AnimationPlayerEditor::_blend_edited() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::ensure_visibility() {
|
||||
|
||||
if (player && pin->is_pressed())
|
||||
return; // another player is pinned, don't reset
|
||||
|
||||
@@ -662,7 +615,6 @@ void AnimationPlayerEditor::ensure_visibility() {
|
||||
}
|
||||
|
||||
Dictionary AnimationPlayerEditor::get_state() const {
|
||||
|
||||
Dictionary d;
|
||||
|
||||
d["visible"] = is_visible_in_tree();
|
||||
@@ -675,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;
|
||||
}
|
||||
@@ -684,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);
|
||||
@@ -709,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);
|
||||
@@ -718,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);
|
||||
@@ -735,7 +683,6 @@ void AnimationPlayerEditor::_animation_edit() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_dialog_action(String p_file) {
|
||||
|
||||
switch (current_option) {
|
||||
case RESOURCE_LOAD: {
|
||||
ERR_FAIL_COND(!player);
|
||||
@@ -744,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());
|
||||
}
|
||||
|
||||
@@ -767,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);
|
||||
@@ -783,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);
|
||||
}
|
||||
@@ -809,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;
|
||||
@@ -820,7 +759,6 @@ void AnimationPlayerEditor::_update_animation() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_update_player() {
|
||||
|
||||
updating = true;
|
||||
List<StringName> animlist;
|
||||
if (player)
|
||||
@@ -859,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
|
||||
@@ -876,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);
|
||||
@@ -898,7 +834,6 @@ void AnimationPlayerEditor::_update_player() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
|
||||
|
||||
if (player && pin->is_pressed())
|
||||
return; // Ignore, pinned.
|
||||
player = p_player;
|
||||
@@ -923,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;
|
||||
|
||||
@@ -972,7 +906,6 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_animation_duplicate() {
|
||||
|
||||
if (!animation->get_item_count())
|
||||
return;
|
||||
|
||||
@@ -985,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));
|
||||
}
|
||||
}
|
||||
@@ -1008,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;
|
||||
@@ -1019,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;
|
||||
};
|
||||
@@ -1055,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_in_tree())
|
||||
_animation_blend(); // Update.
|
||||
@@ -1065,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())
|
||||
@@ -1100,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());
|
||||
@@ -1112,45 +1034,35 @@ 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();
|
||||
} break;
|
||||
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_minsize();
|
||||
@@ -1162,7 +1074,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!"));
|
||||
@@ -1178,7 +1089,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);
|
||||
}
|
||||
@@ -1193,7 +1103,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_minsize();
|
||||
@@ -1208,14 +1117,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)
|
||||
@@ -1225,13 +1131,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);
|
||||
@@ -1239,7 +1143,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++) {
|
||||
@@ -1247,17 +1150,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;
|
||||
@@ -1269,9 +1169,7 @@ 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_scancode()) {
|
||||
|
||||
case KEY_A: {
|
||||
if (!k->get_shift())
|
||||
_play_bw_from_pressed();
|
||||
@@ -1292,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();
|
||||
@@ -1307,7 +1203,6 @@ bool AnimationPlayerEditor::_are_onion_layers_valid() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_allocate_onion_layers() {
|
||||
|
||||
_free_onion_layers();
|
||||
|
||||
int captures = onion.get_needed_capture_count();
|
||||
@@ -1337,7 +1232,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()) {
|
||||
VS::get_singleton()->free(onion.captures[i]);
|
||||
@@ -1348,7 +1242,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)
|
||||
@@ -1373,7 +1266,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
||||
|
||||
Ref<Animation> anim = player->get_animation(player->get_assigned_animation());
|
||||
if (!anim.is_valid())
|
||||
return;
|
||||
@@ -1450,7 +1342,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)
|
||||
@@ -1502,7 +1393,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", this, "call_deferred")) {
|
||||
get_tree()->connect("idle_frame", this, "call_deferred", varray("_prepare_onion_layers_1"));
|
||||
@@ -1510,9 +1400,7 @@ void AnimationPlayerEditor::_start_onion_skinning() {
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::_stop_onion_skinning() {
|
||||
|
||||
if (get_tree()->is_connected("idle_frame", this, "call_deferred")) {
|
||||
|
||||
get_tree()->disconnect("idle_frame", this, "call_deferred");
|
||||
|
||||
_free_onion_layers();
|
||||
@@ -1524,12 +1412,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("_node_removed"), &AnimationPlayerEditor::_node_removed);
|
||||
ClassDB::bind_method(D_METHOD("_play_pressed"), &AnimationPlayerEditor::_play_pressed);
|
||||
ClassDB::bind_method(D_METHOD("_play_from_pressed"), &AnimationPlayerEditor::_play_from_pressed);
|
||||
@@ -1573,7 +1459,6 @@ void AnimationPlayerEditor::_bind_methods() {
|
||||
AnimationPlayerEditor *AnimationPlayerEditor::singleton = NULL;
|
||||
|
||||
AnimationPlayer *AnimationPlayerEditor::get_player() const {
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -1821,24 +1706,20 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
|
||||
}
|
||||
|
||||
AnimationPlayerEditor::~AnimationPlayerEditor() {
|
||||
|
||||
_free_onion_layers();
|
||||
VS::get_singleton()->free(onion.capture.canvas);
|
||||
VS::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;
|
||||
@@ -1846,14 +1727,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();
|
||||
@@ -1861,7 +1739,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