From 5a064d3499681c6b1376007e550fb7cea8526010 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 14:13:15 +1200 Subject: [PATCH 1/4] Remove selection handles and list highlight when entity deletes --- scripts/system/edit.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index c99c8d401a..9b6b70b954 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -471,6 +471,10 @@ var toolBar = (function () { } } + function checkDeletedEntityAndUpdate(entityID) { + selectionManager.removeEntity(entityID); + } + function initialize() { Script.scriptEnding.connect(cleanup); Window.domainChanged.connect(function () { @@ -493,8 +497,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({ From f27e363b6879d6a3e064ee45e91fafcb770ad465 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 15:23:13 +1200 Subject: [PATCH 2/4] Remove entity from list when it deletes; handle multiple deletions --- scripts/system/edit.js | 17 ++++++++++++++++- scripts/system/libraries/entitySelectionTool.js | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 9b6b70b954..6bb815a597 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -471,8 +471,23 @@ var toolBar = (function () { } } + var entitiesToDelete = []; + var deletedEntityTimer = null; + var DELETE_ENTITY_TIMER_TIMEOUT = 100; + function checkDeletedEntityAndUpdate(entityID) { - selectionManager.removeEntity(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() { diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 2322210522..4996579799 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -149,6 +149,17 @@ SelectionManager = (function() { that._update(true); }; + that.removeEntities = function (entityIDs) { + for (var i = 0, length = entityIDs.length; i < length; i++) { + var idx = that.selections.indexOf(entityIDs[i]); + if (idx >= 0) { + that.selections.splice(idx, 1); + Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityIDs[i]); + } + } + that._update(true); + }; + that.clearSelections = function() { that.selections = []; that._update(true); From 4a96dc2fdc4b4c722d8f342d1c33876273b08fc5 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 3 May 2018 08:48:17 +1200 Subject: [PATCH 3/4] Refactor --- scripts/system/libraries/entitySelectionTool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4996579799..36cc98a80b 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -140,22 +140,22 @@ 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++) { - var idx = that.selections.indexOf(entityIDs[i]); - if (idx >= 0) { - that.selections.splice(idx, 1); - Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityIDs[i]); - } + removeEntityByID(entityIDs[i]); } that._update(true); }; From 5312c81a6fe7be0ca5b5c90bbab24d91e2d14963 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 3 May 2018 08:49:18 +1200 Subject: [PATCH 4/4] Match style of surrounding code --- scripts/system/libraries/entitySelectionTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 36cc98a80b..e84600a64a 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -153,7 +153,7 @@ SelectionManager = (function() { that._update(true); }; - that.removeEntities = function (entityIDs) { + that.removeEntities = function(entityIDs) { for (var i = 0, length = entityIDs.length; i < length; i++) { removeEntityByID(entityIDs[i]); }