diff options
author | Anton Yabchinskiy <arn@bestmx.ru> | 2015-01-17 18:27:08 +0300 |
---|---|---|
committer | Anton Yabchinskiy <arn@bestmx.ru> | 2015-01-17 18:27:08 +0300 |
commit | fa38e9b838f32baedfca7a9250a76418b1872f5d (patch) | |
tree | c37f2d5817f5de216f1d864754063993883d6f90 /tools/editor/scene_tree_dock.cpp | |
parent | d6998995b54fd4fed83eef9db3bbb45fa60565db (diff) | |
parent | 91faf8e21810c8995e4f6e3b6ba47a6482ab877e (diff) |
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'tools/editor/scene_tree_dock.cpp')
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index f5d9e83bf8..cff3913579 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -100,6 +100,16 @@ Node* SceneTreeDock::instance(const String& p_file) { } +static String _get_name_num_separator() { + switch(EditorSettings::get_singleton()->get("scenetree_editor/duplicate_node_name_num_separator").operator int()) { + case 0: return ""; + case 1: return " "; + case 2: return "_"; + case 3: return "-"; + } + return " "; +} + void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=p_tool; @@ -318,17 +328,21 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } int num=nums.to_int(); - if (num<2) - num=2; + if (num<1) + num=1; else num++; - name=name.substr(0,name.length()-nums.length()).strip_edges(); - String attempt=name+" "+itos(num); + String nnsep = _get_name_num_separator(); + name = name.substr(0,name.length()-nums.length()).strip_edges(); + if ( name.substr(name.length()-nnsep.length(),nnsep.length()) == nnsep) { + name = name.substr(0,name.length()-nnsep.length()); + } + String attempt = (name + nnsep + itos(num)).strip_edges(); while(parent->has_node(attempt)) { num++; - attempt=name+" "+itos(num); + attempt = (name + nnsep + itos(num)).strip_edges(); } dup->set_name(attempt); |