Merge pull request #4350 from huffman/multi-select

Multi select properties for edit entities
This commit is contained in:
Brad Hefta-Gaub 2015-02-27 10:54:42 -08:00
commit addc729654
3 changed files with 62 additions and 14 deletions

View file

@ -934,24 +934,37 @@ PropertiesTool = function(opts) {
data = {
type: 'update',
};
if (selectionManager.hasSelection()) {
data.id = selectionManager.selections[0].id;
data.properties = Entities.getEntityProperties(selectionManager.selections[0]);
data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation);
var selections = [];
for (var i = 0; i < selectionManager.selections.length; i++) {
var entity = {};
entity.id = selectionManager.selections[i].id;
entity.properties = Entities.getEntityProperties(selectionManager.selections[i]);
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
selections.push(entity);
}
data.selections = selections;
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
});
webView.eventBridge.webEventReceived.connect(function(data) {
print(data);
data = JSON.parse(data);
if (data.type == "update") {
selectionManager.saveProperties();
if (data.properties.rotation !== undefined) {
var rotation = data.properties.rotation;
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
if (selectionManager.selections.length > 1) {
properties = {
locked: data.properties.locked,
visible: data.properties.visible,
};
for (var i = 0; i < selectionManager.selections.length; i++) {
Entities.editEntity(selectionManager.selections[i], properties);
}
} else {
if (data.properties.rotation !== undefined) {
var rotation = data.properties.rotation;
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
}
Entities.editEntity(selectionManager.selections[0], data.properties);
}
Entities.editEntity(selectionManager.selections[0], data.properties);
pushCommandForSelections();
selectionManager._update();
} else if (data.type == "action") {

View file

@ -161,12 +161,37 @@
EventBridge.scriptEventReceived.connect(function(data) {
data = JSON.parse(data);
if (data.type == "update") {
if (data.properties === undefined) {
disableChildren(document.getElementById("properties"), 'input');
} else {
var properties = data.properties;
if (data.selections.length == 0) {
elType.innerHTML = "<i>No Selection</i>";
elID.innerHTML = "";
disableChildren(document.getElementById("properties-list"), 'input');
} else if (data.selections.length > 1) {
var selections = data.selections;
elID.innerHTML = data.id;
var ids = [];
var types = {};
for (var i = 0; i < selections.length; i++) {
ids.push(selections[i].id);
var type = selections[i].properties.type;
if (types[type] === undefined) {
types[type] = 0;
}
types[type]++;
}
elID.innerHTML = ids.join("<br>");
var typeStrs = [];
for (type in types) {
typeStrs.push(type + " (" + types[type] + ")");
}
elType.innerHTML = typeStrs.join(", ");
disableChildren(document.getElementById("properties-list"), 'input');
} else {
var properties = data.selections[0].properties;
elID.innerHTML = properties.id;
elType.innerHTML = properties.type;

View file

@ -189,6 +189,11 @@ input, textarea {
font-size: 7.5pt;
}
input:disabled, textarea:disabled {
background-color: rgb(102, 102, 102);
color: rgb(160, 160, 160);
}
#properties-list input[type=button] {
cursor: pointer;
background-color: rgb(51, 102, 102);
@ -199,6 +204,11 @@ input, textarea {
color: rgb(204, 204, 204);
}
#properties-list input[type=button]:disabled {
background-color: rgb(41, 82, 82);
color: rgb(160, 160, 160);
}
#properties-list .property {
padding: 6pt 6pt;
border-top: 0.75pt solid rgb(63, 63, 63);