diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-01-16 18:03:38 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-01-16 18:03:51 +0100 |
commit | 7dbb1c0571c0d1fb26c28552b09430807cc4d717 (patch) | |
tree | 5bd408f9a64475a5ddd2c34f3a4c8c65844a96ee /scene/animation | |
parent | 681575fa7123592897090c6cce44402c4e45baeb (diff) |
Improve .tscn VCS
Serialize dictionaries adding newlines between key-value pairs
Serialize group lists also with newlines in between
Serialize string properties escaping only " and \ (needed for a good diff experience with built-in scripts and shaders)
Bonus:
Make AnimationPlayer serialize its blend times always sorted so their order is predictable in the .tscn file.
This PR is back-compat; won't break the load of existing files.
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_player.cpp | 19 | ||||
-rw-r--r-- | scene/animation/animation_player.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 30af9b0094..6f3243e385 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -118,17 +118,20 @@ bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const { } else if (name=="blend_times") { - Array array; - - array.resize(blend_times.size()*3); - int idx=0; + Vector<BlendKey> keys; for(Map<BlendKey, float >::Element *E=blend_times.front();E;E=E->next()) { - array.set(idx*3+0,E->key().from); - array.set(idx*3+1,E->key().to); - array.set(idx*3+2,E->get()); - idx++; + keys.ordered_insert(E->key()); } + + Array array; + for(int i=0;i<keys.size();i++) { + + array.push_back(keys[i].from); + array.push_back(keys[i].to); + array.push_back(blend_times[keys[i]]); + } + r_ret=array; } else if (name=="autoplay") { r_ret=autoplay; diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index ac0265dbaa..4745a4add3 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -142,7 +142,7 @@ private: StringName from; StringName to; - bool operator<(const BlendKey& bk) const { return from==bk.from?to<bk.to:from<bk.from; } + bool operator<(const BlendKey& bk) const { return from==bk.from?String(to)<String(bk.to):String(from)<String(bk.from); } }; |