summaryrefslogtreecommitdiffstats
path: root/tools/editor/plugins/animation_player_editor_plugin.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-08-29 22:59:25 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-08-29 22:59:25 -0300
commit1bad27e1f8460424fa4476fe65209aa250d43115 (patch)
treebdd6d510cef95b5a159d4e7b7981bb3be3458711 /tools/editor/plugins/animation_player_editor_plugin.cpp
parentb4acd18f3245d0e8c928b1f275847473de8a2270 (diff)
downloadredot-engine-1bad27e1f8460424fa4476fe65209aa250d43115.tar.gz
-Properly keep animation editor and viewport state while switching scene tabs
Diffstat (limited to 'tools/editor/plugins/animation_player_editor_plugin.cpp')
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 05b12543d2..344e42c13b 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -549,6 +549,49 @@ void AnimationPlayerEditor::ensure_visibility() {
_animation_edit();
}
+Dictionary AnimationPlayerEditor::get_state() const {
+
+ Dictionary d;
+
+ d["visible"]=is_visible();
+ if (is_visible() && player) {
+ d["player"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
+ d["animation"]=player->get_current_animation();
+ d["editing"]=edit_anim->is_pressed();
+ }
+
+ return d;
+
+}
+void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
+
+ if (p_state.has("visible") && p_state["visible"]) {
+
+ Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
+ if (n && n->cast_to<AnimationPlayer>()) {
+ player=n->cast_to<AnimationPlayer>();
+ _update_player();
+ show();
+ set_process(true);
+ ensure_visibility();
+ EditorNode::get_singleton()->animation_panel_make_visible(true);
+
+ if (p_state.has("animation")) {
+ String anim = p_state["animation"];
+ _select_anim_by_name(anim);
+ if (p_state.has("editing") && p_state["editing"]) {
+
+ edit_anim->set_pressed(true);
+ _animation_edit();
+ }
+ }
+
+ }
+ }
+
+}
+
+
void AnimationPlayerEditor::_animation_resource_edit() {
if (animation->get_item_count()) {