mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #13075 from ctrlaltdavid/21862
Clear entity selection handles and update list when entities are deleted
This commit is contained in:
commit
e4b6686e1c
2 changed files with 34 additions and 2 deletions
|
@ -471,6 +471,25 @@ var toolBar = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
var entitiesToDelete = [];
|
||||
var deletedEntityTimer = null;
|
||||
var DELETE_ENTITY_TIMER_TIMEOUT = 100;
|
||||
|
||||
function checkDeletedEntityAndUpdate(entityID) {
|
||||
// Allow for multiple entity deletes before updating the entity list.
|
||||
entitiesToDelete.push(entityID);
|
||||
if (deletedEntityTimer !== null) {
|
||||
Script.clearTimeout(deletedEntityTimer);
|
||||
}
|
||||
deletedEntityTimer = Script.setTimeout(function () {
|
||||
selectionManager.removeEntities(entitiesToDelete);
|
||||
entityListTool.clearEntityList();
|
||||
entityListTool.sendUpdate();
|
||||
entitiesToDelete = [];
|
||||
deletedEntityTimer = null;
|
||||
}, DELETE_ENTITY_TIMER_TIMEOUT);
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Window.domainChanged.connect(function () {
|
||||
|
@ -493,8 +512,10 @@ var toolBar = (function () {
|
|||
Entities.canRezTmpChanged.connect(checkEditPermissionsAndUpdate);
|
||||
Entities.canRezCertifiedChanged.connect(checkEditPermissionsAndUpdate);
|
||||
Entities.canRezTmpCertifiedChanged.connect(checkEditPermissionsAndUpdate);
|
||||
|
||||
var hasRezPermissions = (Entities.canRez() || Entities.canRezTmp() || Entities.canRezCertified() || Entities.canRezTmpCertified());
|
||||
|
||||
Entities.deletingEntity.connect(checkDeletedEntityAndUpdate);
|
||||
|
||||
var createButtonIconRsrc = (hasRezPermissions ? CREATE_ENABLED_ICON : CREATE_DISABLED_ICON);
|
||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
activeButton = tablet.addButton({
|
||||
|
|
|
@ -140,12 +140,23 @@ SelectionManager = (function() {
|
|||
that._update(true);
|
||||
};
|
||||
|
||||
that.removeEntity = function(entityID) {
|
||||
function removeEntityByID(entityID) {
|
||||
var idx = that.selections.indexOf(entityID);
|
||||
if (idx >= 0) {
|
||||
that.selections.splice(idx, 1);
|
||||
Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityID);
|
||||
}
|
||||
}
|
||||
|
||||
that.removeEntity = function (entityID) {
|
||||
removeEntityByID(entityID);
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
that.removeEntities = function(entityIDs) {
|
||||
for (var i = 0, length = entityIDs.length; i < length; i++) {
|
||||
removeEntityByID(entityIDs[i]);
|
||||
}
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue