diff options
author | MarianoGNU <marianognu.easyrpg@gmail.com> | 2015-10-16 23:21:39 -0300 |
---|---|---|
committer | MarianoGNU <marianognu.easyrpg@gmail.com> | 2015-10-16 23:21:39 -0300 |
commit | a5ebb525000d8301f73377426a2c1924d70aaf86 (patch) | |
tree | 55eaf1e0e6553dbb34d236b07a051689ae8f2493 /core/path_db.cpp | |
parent | 553edf1f250f34ca0ef0703b13b4d601f609e491 (diff) | |
parent | 17a90ddc0824bb51b5ea707f5d4d11aed301f91d (diff) |
Merge branch 'master' of https://github.com/okamstudio/godot
# Solved Conflicts:
# tools/editor/property_editor.cpp
Diffstat (limited to 'core/path_db.cpp')
-rw-r--r-- | core/path_db.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/path_db.cpp b/core/path_db.cpp index d3dc3aceb8..c6ea25d966 100644 --- a/core/path_db.cpp +++ b/core/path_db.cpp @@ -286,6 +286,37 @@ NodePath::NodePath(const Vector<StringName>& p_path,const Vector<StringName>& p_ data->property=p_property; } + +void NodePath::simplify() { + + if (!data) + return; + for(int i=0;i<data->path.size();i++) { + if (data->path.size()==1) + break; + if (data->path[i].operator String()==".") { + data->path.remove(i); + i--; + } else if (data->path[i].operator String()==".." && i>0 && data->path[i-1].operator String()!="." && data->path[i-1].operator String()!="..") { + //remove both + data->path.remove(i-1); + data->path.remove(i-1); + i-=2; + if (data->path.size()==0) { + data->path.push_back("."); + break; + } + } + } +} + +NodePath NodePath::simplified() const { + + NodePath np=*this; + np.simplify(); + return np; +} + NodePath::NodePath(const String& p_path) { data=NULL; |