Add read-only mode to AnimationEditor for foreign resources.
This commit is contained in:
parent
8d15814e6a
commit
7776b47489
6 changed files with 618 additions and 319 deletions
|
|
@ -47,6 +47,7 @@ class AnimationTrackKeyEdit : public Object {
|
|||
|
||||
public:
|
||||
bool setting = false;
|
||||
bool animation_read_only = false;
|
||||
|
||||
bool _hide_script_from_inspector() {
|
||||
return true;
|
||||
|
|
@ -56,12 +57,17 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _read_only() {
|
||||
return animation_read_only;
|
||||
}
|
||||
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj);
|
||||
ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed);
|
||||
ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector);
|
||||
ClassDB::bind_method("get_root_path", &AnimationTrackKeyEdit::get_root_path);
|
||||
ClassDB::bind_method("_dont_undo_redo", &AnimationTrackKeyEdit::_dont_undo_redo);
|
||||
ClassDB::bind_method("_read_only", &AnimationTrackKeyEdit::_read_only);
|
||||
}
|
||||
|
||||
void _fix_node_path(Variant &value) {
|
||||
|
|
@ -702,6 +708,7 @@ class AnimationMultiTrackKeyEdit : public Object {
|
|||
|
||||
public:
|
||||
bool setting = false;
|
||||
bool animation_read_only = false;
|
||||
|
||||
bool _hide_script_from_inspector() {
|
||||
return true;
|
||||
|
|
@ -711,12 +718,17 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _read_only() {
|
||||
return animation_read_only;
|
||||
}
|
||||
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method("_update_obj", &AnimationMultiTrackKeyEdit::_update_obj);
|
||||
ClassDB::bind_method("_key_ofs_changed", &AnimationMultiTrackKeyEdit::_key_ofs_changed);
|
||||
ClassDB::bind_method("_hide_script_from_inspector", &AnimationMultiTrackKeyEdit::_hide_script_from_inspector);
|
||||
ClassDB::bind_method("get_root_path", &AnimationMultiTrackKeyEdit::get_root_path);
|
||||
ClassDB::bind_method("_dont_undo_redo", &AnimationMultiTrackKeyEdit::_dont_undo_redo);
|
||||
ClassDB::bind_method("_read_only", &AnimationMultiTrackKeyEdit::_read_only);
|
||||
}
|
||||
|
||||
void _fix_node_path(Variant &value, NodePath &base) {
|
||||
|
|
@ -1415,22 +1427,32 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
|
|||
}
|
||||
|
||||
void AnimationTimelineEdit::_anim_loop_pressed() {
|
||||
undo_redo->create_action(TTR("Change Animation Loop"));
|
||||
switch (animation->get_loop_mode()) {
|
||||
case Animation::LOOP_NONE: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_LINEAR);
|
||||
} break;
|
||||
case Animation::LOOP_LINEAR: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_PINGPONG);
|
||||
} break;
|
||||
case Animation::LOOP_PINGPONG: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_NONE);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
if (!read_only) {
|
||||
undo_redo->create_action(TTR("Change Animation Loop"));
|
||||
switch (animation->get_loop_mode()) {
|
||||
case Animation::LOOP_NONE: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_LINEAR);
|
||||
} break;
|
||||
case Animation::LOOP_LINEAR: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_PINGPONG);
|
||||
} break;
|
||||
case Animation::LOOP_PINGPONG: {
|
||||
undo_redo->add_do_method(animation.ptr(), "set_loop_mode", Animation::LOOP_NONE);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
undo_redo->add_undo_method(animation.ptr(), "set_loop_mode", animation->get_loop_mode());
|
||||
undo_redo->commit_action();
|
||||
} else {
|
||||
String base_path = animation->get_path();
|
||||
if (FileAccess::exists(base_path + ".import")) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation instanced from imported scene."));
|
||||
} else {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can't change loop mode on animation embedded in another scene."));
|
||||
}
|
||||
update_values();
|
||||
}
|
||||
undo_redo->add_undo_method(animation.ptr(), "set_loop_mode", animation->get_loop_mode());
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
int AnimationTimelineEdit::get_buttons_width() const {
|
||||
|
|
@ -1655,11 +1677,17 @@ void AnimationTimelineEdit::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) {
|
||||
void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, bool p_read_only) {
|
||||
animation = p_animation;
|
||||
read_only = p_read_only;
|
||||
|
||||
if (animation.is_valid()) {
|
||||
len_hb->show();
|
||||
add_track->show();
|
||||
if (read_only) {
|
||||
add_track->hide();
|
||||
} else {
|
||||
add_track->show();
|
||||
}
|
||||
play_position->show();
|
||||
} else {
|
||||
len_hb->hide();
|
||||
|
|
@ -1981,6 +2009,8 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
Color linecolor = color;
|
||||
linecolor.a = 0.2;
|
||||
|
||||
Color dc = get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"));
|
||||
|
||||
// NAMES AND ICONS //
|
||||
|
||||
{
|
||||
|
|
@ -2130,14 +2160,18 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
ofs += update_icon->get_width() + hsep / 2;
|
||||
update_mode_rect.size.x += hsep / 2;
|
||||
|
||||
if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
|
||||
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();
|
||||
if (!read_only) {
|
||||
if (animation->track_get_type(track) == Animation::TYPE_VALUE) {
|
||||
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();
|
||||
update_mode_rect = Rect2();
|
||||
} else {
|
||||
update_mode_rect = Rect2();
|
||||
}
|
||||
} else {
|
||||
update_mode_rect = Rect2();
|
||||
}
|
||||
|
|
@ -2168,7 +2202,7 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
ofs += icon->get_width() + hsep / 2;
|
||||
interp_mode_rect.size.x += hsep / 2;
|
||||
|
||||
if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
|
||||
if (!read_only && !animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
|
||||
draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
|
||||
interp_mode_rect.size.x += down_icon->get_width();
|
||||
} else {
|
||||
|
|
@ -2201,7 +2235,7 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
ofs += icon->get_width() + hsep / 2;
|
||||
loop_wrap_rect.size.x += hsep / 2;
|
||||
|
||||
if (!animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
|
||||
if (!read_only && !animation->track_is_compressed(track) && (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_BLEND_SHAPE || animation->track_get_type(track) == Animation::TYPE_POSITION_3D || animation->track_get_type(track) == Animation::TYPE_SCALE_3D || animation->track_get_type(track) == Animation::TYPE_ROTATION_3D)) {
|
||||
draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2));
|
||||
loop_wrap_rect.size.x += down_icon->get_width();
|
||||
} else {
|
||||
|
|
@ -2222,7 +2256,11 @@ void AnimationTrackEdit::_notification(int p_what) {
|
|||
remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
|
||||
remove_rect.size = icon->get_size();
|
||||
|
||||
draw_texture(icon, remove_rect.position);
|
||||
if (read_only) {
|
||||
draw_texture(icon, remove_rect.position, dc);
|
||||
} else {
|
||||
draw_texture(icon, remove_rect.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2438,8 +2476,10 @@ Ref<Animation> AnimationTrackEdit::get_animation() const {
|
|||
return animation;
|
||||
}
|
||||
|
||||
void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) {
|
||||
void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only) {
|
||||
animation = p_animation;
|
||||
read_only = p_read_only;
|
||||
|
||||
track = p_track;
|
||||
update();
|
||||
|
||||
|
|
@ -2720,17 +2760,23 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
|
||||
if (p_event->is_pressed()) {
|
||||
if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) {
|
||||
emit_signal(SNAME("duplicate_request"));
|
||||
if (!read_only) {
|
||||
emit_signal(SNAME("duplicate_request"));
|
||||
}
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->matches_event(p_event)) {
|
||||
emit_signal(SNAME("duplicate_transpose_request"));
|
||||
if (!read_only) {
|
||||
emit_signal(SNAME("duplicate_transpose_request"));
|
||||
}
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) {
|
||||
emit_signal(SNAME("delete_request"));
|
||||
if (!read_only) {
|
||||
emit_signal(SNAME("delete_request"));
|
||||
}
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
|
|
@ -2739,79 +2785,81 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
|
||||
Point2 pos = mb->get_position();
|
||||
|
||||
if (check_rect.has_point(pos)) {
|
||||
undo_redo->create_action(TTR("Toggle Track Enabled"));
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track));
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track));
|
||||
undo_redo->commit_action();
|
||||
update();
|
||||
accept_event();
|
||||
}
|
||||
|
||||
// Don't overlap track keys if they start at 0.
|
||||
if (path_rect.has_point(pos + Size2(type_icon->get_width(), 0))) {
|
||||
clicking_on_name = true;
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (update_mode_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
if (!read_only) {
|
||||
if (check_rect.has_point(pos)) {
|
||||
undo_redo->create_action(TTR("Toggle Track Enabled"));
|
||||
undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track));
|
||||
undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track));
|
||||
undo_redo->commit_action();
|
||||
update();
|
||||
accept_event();
|
||||
}
|
||||
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("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER);
|
||||
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);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (interp_mode_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
// Don't overlap track keys if they start at 0.
|
||||
if (path_rect.has_point(pos + Size2(type_icon->get_width(), 0))) {
|
||||
clicking_on_name = true;
|
||||
accept_event();
|
||||
}
|
||||
menu->clear();
|
||||
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);
|
||||
menu->reset_size();
|
||||
|
||||
Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
if (update_mode_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
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("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
|
||||
menu->reset_size();
|
||||
|
||||
if (loop_wrap_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
menu->clear();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP);
|
||||
menu->reset_size();
|
||||
|
||||
Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
if (interp_mode_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
}
|
||||
menu->clear();
|
||||
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);
|
||||
menu->reset_size();
|
||||
|
||||
if (remove_rect.has_point(pos)) {
|
||||
emit_signal(SNAME("remove_request"), track);
|
||||
accept_event();
|
||||
return;
|
||||
Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (loop_wrap_rect.has_point(pos)) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
}
|
||||
menu->clear();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP);
|
||||
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP);
|
||||
menu->reset_size();
|
||||
|
||||
Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height);
|
||||
menu->set_position(popup_pos);
|
||||
menu->popup();
|
||||
accept_event();
|
||||
}
|
||||
|
||||
if (remove_rect.has_point(pos)) {
|
||||
emit_signal(SNAME("remove_request"), track);
|
||||
accept_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check keyframes.
|
||||
|
|
@ -2871,6 +2919,11 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
moving_selection_attempt = true;
|
||||
moving_selection_from_ofs = (mb->get_position().x - limit) / timeline->get_zoom_scale();
|
||||
}
|
||||
|
||||
if (read_only) {
|
||||
moving_selection_attempt = false;
|
||||
moving_selection_from_ofs = 0.0f;
|
||||
}
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
|
|
@ -2882,33 +2935,35 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (pos.x >= timeline->get_name_limit() && pos.x <= get_size().width - timeline->get_buttons_width()) {
|
||||
// Can do something with menu too! show insert key.
|
||||
float offset = (pos.x - timeline->get_name_limit()) / timeline->get_zoom_scale();
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
}
|
||||
|
||||
menu->clear();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT);
|
||||
if (editor->is_selection_active()) {
|
||||
menu->add_separator();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE);
|
||||
|
||||
AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player();
|
||||
if (!player->has_animation(SceneStringNames::get_singleton()->RESET) || animation != player->get_animation(SceneStringNames::get_singleton()->RESET)) {
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET);
|
||||
if (!read_only) {
|
||||
if (!menu) {
|
||||
menu = memnew(PopupMenu);
|
||||
add_child(menu);
|
||||
menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected));
|
||||
}
|
||||
|
||||
menu->add_separator();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE);
|
||||
menu->clear();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT);
|
||||
if (editor->is_selection_active()) {
|
||||
menu->add_separator();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE);
|
||||
|
||||
AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player();
|
||||
if (!player->has_animation(SceneStringNames::get_singleton()->RESET) || animation != player->get_animation(SceneStringNames::get_singleton()->RESET)) {
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Add RESET Value(s)"), MENU_KEY_ADD_RESET);
|
||||
}
|
||||
|
||||
menu->add_separator();
|
||||
menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE);
|
||||
}
|
||||
menu->reset_size();
|
||||
|
||||
menu->set_position(get_screen_position() + get_local_mouse_position());
|
||||
menu->popup();
|
||||
|
||||
insert_at_pos = offset + timeline->get_value();
|
||||
accept_event();
|
||||
}
|
||||
menu->reset_size();
|
||||
|
||||
menu->set_position(get_screen_position() + get_local_mouse_position());
|
||||
menu->popup();
|
||||
|
||||
insert_at_pos = offset + timeline->get_value();
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3353,7 +3408,7 @@ void AnimationTrackEditor::remove_track_edit_plugin(const Ref<AnimationTrackEdit
|
|||
track_edit_plugins.erase(p_plugin);
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
|
||||
void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_read_only) {
|
||||
if (animation != p_anim && _get_track_selected() >= 0) {
|
||||
track_edits[_get_track_selected()]->release_focus();
|
||||
}
|
||||
|
|
@ -3362,7 +3417,8 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
|
|||
_clear_selection();
|
||||
}
|
||||
animation = p_anim;
|
||||
timeline->set_animation(p_anim);
|
||||
read_only = p_read_only;
|
||||
timeline->set_animation(p_anim, read_only);
|
||||
|
||||
_cancel_bezier_edit();
|
||||
_update_tracks();
|
||||
|
|
@ -3371,7 +3427,7 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
|
|||
animation->connect("changed", callable_mp(this, &AnimationTrackEditor::_animation_changed));
|
||||
|
||||
hscroll->show();
|
||||
edit->set_disabled(false);
|
||||
edit->set_disabled(read_only);
|
||||
step->set_block_signals(true);
|
||||
|
||||
_update_step_spinbox();
|
||||
|
|
@ -3500,7 +3556,7 @@ void AnimationTrackEditor::set_state(const Dictionary &p_state) {
|
|||
}
|
||||
|
||||
void AnimationTrackEditor::cleanup() {
|
||||
set_animation(Ref<Animation>());
|
||||
set_animation(Ref<Animation>(), read_only);
|
||||
}
|
||||
|
||||
void AnimationTrackEditor::_name_limit_changed() {
|
||||
|
|
@ -4381,6 +4437,27 @@ void AnimationTrackEditor::_update_tracks() {
|
|||
return;
|
||||
}
|
||||
|
||||
bool read_only = false;
|
||||
if (!animation->get_path().is_resource_file()) {
|
||||
int srpos = animation->get_path().find("::");
|
||||
if (srpos != -1) {
|
||||
String base = animation->get_path().substr(0, srpos);
|
||||
if (ResourceLoader::get_resource_type(base) == "PackedScene") {
|
||||
if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) {
|
||||
read_only = true;
|
||||
}
|
||||
} else {
|
||||
if (FileAccess::exists(base + ".import")) {
|
||||
read_only = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (FileAccess::exists(animation->get_path() + ".import")) {
|
||||
read_only = true;
|
||||
}
|
||||
}
|
||||
|
||||
RBMap<String, VBoxContainer *> group_sort;
|
||||
|
||||
bool use_grouping = !view_group->is_pressed();
|
||||
|
|
@ -4509,7 +4586,7 @@ void AnimationTrackEditor::_update_tracks() {
|
|||
track_edit->set_undo_redo(undo_redo);
|
||||
track_edit->set_timeline(timeline);
|
||||
track_edit->set_root(root);
|
||||
track_edit->set_animation_and_track(animation, i);
|
||||
track_edit->set_animation_and_track(animation, i, read_only);
|
||||
track_edit->set_play_position(timeline->get_play_position());
|
||||
track_edit->set_editor(this);
|
||||
|
||||
|
|
@ -5181,6 +5258,7 @@ void AnimationTrackEditor::_update_key_edit() {
|
|||
if (selection.size() == 1) {
|
||||
key_edit = memnew(AnimationTrackKeyEdit);
|
||||
key_edit->animation = animation;
|
||||
key_edit->animation_read_only = read_only;
|
||||
key_edit->track = selection.front()->key().track;
|
||||
key_edit->use_fps = timeline->is_using_fps();
|
||||
|
||||
|
|
@ -5197,6 +5275,7 @@ void AnimationTrackEditor::_update_key_edit() {
|
|||
} else if (selection.size() > 1) {
|
||||
multi_key_edit = memnew(AnimationMultiTrackKeyEdit);
|
||||
multi_key_edit->animation = animation;
|
||||
multi_key_edit->animation_read_only = read_only;
|
||||
|
||||
RBMap<int, List<float>> key_ofs_map;
|
||||
RBMap<int, NodePath> base_map;
|
||||
|
|
@ -5476,7 +5555,7 @@ void AnimationTrackEditor::_cancel_bezier_edit() {
|
|||
void AnimationTrackEditor::_bezier_edit(int p_for_track) {
|
||||
_clear_selection(); // Bezier probably wants to use a separate selection mode.
|
||||
bezier_edit->set_root(root);
|
||||
bezier_edit->set_animation_and_track(animation, p_for_track);
|
||||
bezier_edit->set_animation_and_track(animation, p_for_track, read_only);
|
||||
scroll->hide();
|
||||
bezier_edit->show();
|
||||
// Search everything within the track and curve - edit it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue