Fix edit.js server script status getting reset when changing properties

This commit is contained in:
Ryan Huffman 2017-01-20 15:34:22 -08:00
parent 888d7ab03d
commit ad70431c26
2 changed files with 22 additions and 21 deletions

View file

@ -1443,7 +1443,6 @@ var PropertiesTool = function (opts) {
};
function updateScriptStatus(info) {
print("Got status: ", info);
info.type = "server_script_status";
webView.emitScriptEvent(JSON.stringify(info));
};
@ -1457,26 +1456,28 @@ var PropertiesTool = function (opts) {
});
}
selectionManager.addEventListener(function () {
selectionManager.addEventListener(function (selectionUpdated) {
var data = {
type: 'update'
};
resetScriptStatus();
if (selectionUpdated) {
resetScriptStatus();
if (selectionManager.selections.length !== 1) {
if (statusMonitor !== null) {
statusMonitor.stop();
statusMonitor = null;
if (selectionManager.selections.length !== 1) {
if (statusMonitor !== null) {
statusMonitor.stop();
statusMonitor = null;
}
currentSelectedEntityID = null;
} else if (currentSelectedEntityID != selectionManager.selections[0]) {
if (statusMonitor !== null) {
statusMonitor.stop();
}
var entityID = selectionManager.selections[0];
currentSelectedEntityID = entityID;
statusMonitor = new ServerScriptStatusMonitor(entityID, updateScriptStatus);
}
currentSelectedEntityID = null;
} else if (currentSelectedEntityID != selectionManager.selections[0]) {
if (statusMonitor !== null) {
statusMonitor.stop();
}
var entityID = selectionManager.selections[0];
currentSelectedEntityID = entityID;
statusMonitor = new ServerScriptStatusMonitor(entityID, updateScriptStatus);
}
var selections = [];

View file

@ -113,7 +113,7 @@ SelectionManager = (function() {
that.selections.push(entityID);
}
that._update();
that._update(true);
};
that.addEntity = function(entityID, toggleSelection) {
@ -132,7 +132,7 @@ SelectionManager = (function() {
}
}
that._update();
that._update(true);
};
that.removeEntity = function(entityID) {
@ -140,15 +140,15 @@ SelectionManager = (function() {
if (idx >= 0) {
that.selections.splice(idx, 1);
}
that._update();
that._update(true);
};
that.clearSelections = function() {
that.selections = [];
that._update();
that._update(true);
};
that._update = function() {
that._update = function(selectionUpdated) {
if (that.selections.length == 0) {
that.localDimensions = null;
that.localPosition = null;
@ -205,7 +205,7 @@ SelectionManager = (function() {
for (var i = 0; i < listeners.length; i++) {
try {
listeners[i]();
listeners[i](selectionUpdated === true);
} catch (e) {
print("EntitySelectionTool got exception: " + JSON.stringify(e));
}