Merge pull request #72233 from TokageItLab/audio-blending
Implement blending audio feature to AnimationTree
This commit is contained in:
commit
e5752fdfd3
22 changed files with 566 additions and 215 deletions
|
|
@ -1954,6 +1954,10 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")),
|
||||
get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons"))
|
||||
};
|
||||
Ref<Texture2D> blend_icon[2] = {
|
||||
get_theme_icon(SNAME("UseBlendEnable"), SNAME("EditorIcons")),
|
||||
get_theme_icon(SNAME("UseBlendDisable"), SNAME("EditorIcons")),
|
||||
};
|
||||
|
||||
int ofs = get_size().width - timeline->get_buttons_width();
|
||||
|
||||
|
|
@ -1982,6 +1986,11 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
if (!animation->track_is_compressed(track) && animation->track_get_type(track) == Animation::TYPE_VALUE) {
|
||||
draw_texture(update_icon, update_mode_rect.position);
|
||||
}
|
||||
if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
|
||||
Ref<Texture2D> use_blend_icon = blend_icon[animation->audio_track_is_use_blend(track) ? 0 : 1];
|
||||
Vector2 use_blend_icon_pos = update_mode_rect.position + (update_mode_rect.size - use_blend_icon->get_size()) / 2;
|
||||
draw_texture(use_blend_icon, use_blend_icon_pos);
|
||||
}
|
||||
// Make it easier to click.
|
||||
update_mode_rect.position.y = 0;
|
||||
update_mode_rect.size.y = get_size().height;
|
||||
|
|
@ -1990,13 +1999,12 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
update_mode_rect.size.x += hsep / 2;
|
||||
|
||||
if (!read_only) {
|
||||
if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
|
||||
if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_AUDIO) {
|
||||
draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
|
||||
update_mode_rect.size.x += down_icon->get_width();
|
||||
} else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
|
||||
Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons"));
|
||||
update_mode_rect.size.x += down_icon->get_width();
|
||||
|
||||
update_mode_rect = Rect2();
|
||||
} else {
|
||||
update_mode_rect = Rect2();
|
||||
|
|
@ -2439,7 +2447,11 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
|
|||
}
|
||||
|
||||
if (update_mode_rect.has_point(p_pos)) {
|
||||
return TTR("Update Mode (How this property is set)");
|
||||
if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
|
||||
return TTR("Use Blend");
|
||||
} else {
|
||||
return TTR("Update Mode (How this property is set)");
|
||||
}
|
||||
}
|
||||
|
||||
if (interp_mode_rect.has_point(p_pos)) {
|
||||
|
|
@ -2641,9 +2653,14 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
}
|
||||
menu->clear();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
|
||||
if (animation->track_get_type(track) == Animation::TYPE_AUDIO) {
|
||||
menu->add_icon_item(get_theme_icon(SNAME("UseBlendEnable"), SNAME("EditorIcons")), TTR("Use Blend"), MENU_USE_BLEND_ENABLED);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("UseBlendDisable"), SNAME("EditorIcons")), TTR("Don't Use Blend"), MENU_USE_BLEND_DISABLED);
|
||||
} else {
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
|
||||
}
|
||||
menu->reset_size();
|
||||
|
||||
Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height);
|
||||
|
|
@ -2662,7 +2679,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC);
|
||||
// Check is angle property.
|
||||
// Check whether it is angle property.
|
||||
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
|
||||
if (ape) {
|
||||
AnimationPlayer *ap = ape->get_player();
|
||||
|
|
@ -3055,6 +3072,16 @@ void AnimationTrackEdit::_menu_selected(int p_index) {
|
|||
emit_signal(SNAME("delete_request"));
|
||||
|
||||
} break;
|
||||
case MENU_USE_BLEND_ENABLED:
|
||||
case MENU_USE_BLEND_DISABLED: {
|
||||
bool use_blend = p_index == MENU_USE_BLEND_ENABLED;
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("Change Animation Use Blend"));
|
||||
undo_redo->add_do_method(animation.ptr(), "audio_track_set_use_blend", track, use_blend);
|
||||
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_use_blend", track, animation->audio_track_is_use_blend(track));
|
||||
undo_redo->commit_action();
|
||||
queue_redraw();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3488,6 +3515,9 @@ void AnimationTrackEditor::_animation_track_remove_request(int p_track, Ref<Anim
|
|||
if (p_from_animation->track_get_type(idx) == Animation::TYPE_VALUE) {
|
||||
undo_redo->add_undo_method(p_from_animation.ptr(), "value_track_set_update_mode", idx, p_from_animation->value_track_get_update_mode(idx));
|
||||
}
|
||||
if (animation->track_get_type(idx) == Animation::TYPE_AUDIO) {
|
||||
undo_redo->add_undo_method(animation.ptr(), "audio_track_set_use_blend", idx, animation->audio_track_is_use_blend(idx));
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
|
@ -5618,6 +5648,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
if (tc.track_type == Animation::TYPE_VALUE) {
|
||||
tc.update_mode = animation->value_track_get_update_mode(idx);
|
||||
}
|
||||
if (tc.track_type == Animation::TYPE_AUDIO) {
|
||||
tc.use_blend = animation->audio_track_is_use_blend(idx);
|
||||
}
|
||||
tc.loop_wrap = animation->track_get_interpolation_loop_wrap(idx);
|
||||
tc.enabled = animation->track_is_enabled(idx);
|
||||
for (int i = 0; i < animation->track_get_key_count(idx); i++) {
|
||||
|
|
@ -5662,6 +5695,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
|
|||
if (track_clipboard[i].track_type == Animation::TYPE_VALUE) {
|
||||
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", base_track, track_clipboard[i].update_mode);
|
||||
}
|
||||
if (track_clipboard[i].track_type == Animation::TYPE_AUDIO) {
|
||||
undo_redo->add_do_method(animation.ptr(), "audio_track_set_use_blend", base_track, track_clipboard[i].use_blend);
|
||||
}
|
||||
|
||||
for (int j = 0; j < track_clipboard[i].keys.size(); j++) {
|
||||
undo_redo->add_do_method(animation.ptr(), "track_insert_key", base_track, track_clipboard[i].keys[j].time, track_clipboard[i].keys[j].value, track_clipboard[i].keys[j].transition);
|
||||
|
|
|
|||
|
|
@ -220,7 +220,9 @@ class AnimationTrackEdit : public Control {
|
|||
MENU_KEY_INSERT,
|
||||
MENU_KEY_DUPLICATE,
|
||||
MENU_KEY_ADD_RESET,
|
||||
MENU_KEY_DELETE
|
||||
MENU_KEY_DELETE,
|
||||
MENU_USE_BLEND_ENABLED,
|
||||
MENU_USE_BLEND_DISABLED,
|
||||
};
|
||||
|
||||
AnimationTimelineEdit *timeline = nullptr;
|
||||
|
|
@ -566,6 +568,7 @@ class AnimationTrackEditor : public VBoxContainer {
|
|||
Animation::LoopMode loop_mode = Animation::LOOP_PINGPONG;
|
||||
bool loop_wrap = false;
|
||||
bool enabled = false;
|
||||
bool use_blend = false;
|
||||
|
||||
struct Key {
|
||||
float time = 0;
|
||||
|
|
|
|||
1
editor/icons/UseBlendDisable.svg
Normal file
1
editor/icons/UseBlendDisable.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg enable-background="new -595.5 420.5 16 16" height="16" viewBox="-595.5 420.5 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m-591 421.5h7v14h-7z" fill="#a3e595" opacity=".5"/><g fill="none" stroke="#a3e595" stroke-linecap="square" stroke-width="2"><path d="m-585 434.5v-12"/><path d="m-590 422.5v12"/><path d="m-581.5 422.5h-12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 361 B |
1
editor/icons/UseBlendEnable.svg
Normal file
1
editor/icons/UseBlendEnable.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg enable-background="new -595.5 420.5 16 16" height="16" viewBox="-595.5 420.5 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m-587.5 423.244c-3.995 2.354-7 6.775-7 11.256v1h14v-1c0-4.48-3.005-8.901-7-11.256z" fill="#95c6e8" opacity=".5"/><g fill="none" stroke="#95c6e8" stroke-linecap="square" stroke-width="2"><path d="m-581.5 422.5c-6 0-12 6-12 12"/><path d="m-581.5 434.5c0-6-6-12-12-12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 422 B |
Loading…
Add table
Add a link
Reference in a new issue