mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:17:02 +02:00
Merge pull request #603 from AleziaKurdis/575_DuplicateNaming
Incremental suffix to cloned entities's name (issue #575)
This commit is contained in:
commit
012b6b0c84
1 changed files with 43 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
// Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on 4/7/2017
|
// Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on 4/7/2017
|
||||||
// Modified by David Back on 1/9/2018
|
// Modified by David Back on 1/9/2018
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors
|
||||||
//
|
//
|
||||||
// This script implements a class useful for building tools for editing entities.
|
// This script implements a class useful for building tools for editing entities.
|
||||||
//
|
//
|
||||||
|
@ -31,6 +32,46 @@ function deepCopy(v) {
|
||||||
return JSON.parse(JSON.stringify(v));
|
return JSON.parse(JSON.stringify(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDuplicateAppendedName(name) {
|
||||||
|
var appendiceChar = "(0123456789)";
|
||||||
|
var currentChar = "";
|
||||||
|
var rippedName = name;
|
||||||
|
var existingSequence = 0;
|
||||||
|
var sequenceReader = "";
|
||||||
|
for (var i = name.length - 1; i >= 0; i--) {
|
||||||
|
currentChar = name.charAt(i);
|
||||||
|
if (i === (name.length - 1) && currentChar !== ")") {
|
||||||
|
rippedName = name;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (appendiceChar.indexOf(currentChar) === -1) {
|
||||||
|
rippedName = name;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (currentChar == "(" && i === name.length - 2) {
|
||||||
|
rippedName = name;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (currentChar == "(") {
|
||||||
|
rippedName = name.substr(0, i-1);
|
||||||
|
existingSequence = parseInt(sequenceReader);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
sequenceReader = currentChar + sequenceReader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (existingSequence === 0) {
|
||||||
|
rippedName = rippedName.trim() + " (2)";
|
||||||
|
} else {
|
||||||
|
existingSequence++;
|
||||||
|
rippedName = rippedName.trim() + " (" + existingSequence + ")";
|
||||||
|
}
|
||||||
|
return rippedName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
SelectionManager = (function() {
|
SelectionManager = (function() {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -289,6 +330,8 @@ SelectionManager = (function() {
|
||||||
properties.localRotation = properties.rotation;
|
properties.localRotation = properties.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
properties.name = getDuplicateAppendedName(properties.name);
|
||||||
|
|
||||||
properties.localVelocity = Vec3.ZERO;
|
properties.localVelocity = Vec3.ZERO;
|
||||||
properties.localAngularVelocity = Vec3.ZERO;
|
properties.localAngularVelocity = Vec3.ZERO;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue