Fixed multiple particle tabs appearing

This commit is contained in:
ericrius1 2016-02-16 12:56:34 -08:00
parent 46907f446b
commit ad43e4ff6d
2 changed files with 12 additions and 4 deletions

View file

@ -1260,6 +1260,7 @@ function selectAllEtitiesInCurrentSelectionBox(keepIfTouching) {
function deleteSelectedEntities() { function deleteSelectedEntities() {
if (SelectionManager.hasSelection()) { if (SelectionManager.hasSelection()) {
selectedParticleEntity = 0;
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();
SelectionManager.saveProperties(); SelectionManager.saveProperties();
var savedProperties = []; var savedProperties = [];
@ -1888,17 +1889,19 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
var ids = data.entityIds; var ids = data.entityIds;
if(ids.length === 1) { if(ids.length === 1) {
if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) { if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) {
if (JSON.stringify(selectedParticleEntity) !== JSON.stringify(ids[0])) { if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) {
// We already had a particle entity selected, so destroy that one and create the new one // This particle entity is already selected, so return
particleExplorerTool.destroyWebView(); return;
} }
// Now we want to activate the partice explorer panel! // Destroy the old particles web view first
particleExplorerTool.destroyWebView();
particleExplorerTool.createWebView(); particleExplorerTool.createWebView();
var properties = Entities.getEntityProperties(ids[0]); var properties = Entities.getEntityProperties(ids[0]);
var particleData = { var particleData = {
messageType: "particle_settings", messageType: "particle_settings",
currentProperties: properties currentProperties: properties
}; };
selectedParticleEntity = ids[0];
particleExplorerTool.setActiveParticleEntity(ids[0]); particleExplorerTool.setActiveParticleEntity(ids[0]);
particleExplorerTool.webView.eventBridge.webEventReceived.connect(function(data) { particleExplorerTool.webView.eventBridge.webEventReceived.connect(function(data) {
@ -1908,6 +1911,7 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
} }
}); });
} else { } else {
selectedParticleEntity = 0;
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();
} }
} }

View file

@ -32,10 +32,14 @@ ParticleExplorerTool = function() {
that.destroyWebView = function() { that.destroyWebView = function() {
if (!that.webView) { if (!that.webView) {
print("EBL CAN'ZT CLOSE WEB VIEW- IT DOESNT EXISTS!")
return; return;
} }
print("EBL CLOSING WEB VIEW")
that.webView.close(); that.webView.close();
that.webView = null; that.webView = null;
that.activeParticleEntity = 0;
} }
that.webEventReceived = function(data) { that.webEventReceived = function(data) {