CR changes from PR 15325

This commit is contained in:
unknown 2019-04-08 14:07:25 -07:00
parent b8b9035f9d
commit 1537d4351d
2 changed files with 15 additions and 14 deletions

View file

@ -2537,6 +2537,7 @@ var PropertiesTool = function (opts) {
} }
emitScriptEvent({ emitScriptEvent({
type: 'materialTargetReply', type: 'materialTargetReply',
entityID: data.entityID,
materialTargetData: parentModelData, materialTargetData: parentModelData,
}); });
} }

View file

@ -2480,7 +2480,7 @@ function resetDynamicMultiselectProperty(elDivOptions) {
let elDivOption = elInputs[0].parentNode; let elDivOption = elInputs[0].parentNode;
elDivOption.parentNode.removeChild(elDivOption); elDivOption.parentNode.removeChild(elDivOption);
} }
elDivOptions.firstChild.style.display = "block"; // show "No Options" text elDivOptions.firstChild.style.display = null; // show "No Options" text
elDivOptions.parentNode.lastChild.style.display = "none"; // hide Select/Clear all buttons elDivOptions.parentNode.lastChild.style.display = "none"; // hide Select/Clear all buttons
} }
@ -3184,7 +3184,7 @@ function setMaterialTargetData(materialTargetData) {
} }
elDivOptions.firstChild.style.display = "none"; // hide "No Options" text elDivOptions.firstChild.style.display = "none"; // hide "No Options" text
elDivOptions.parentNode.lastChild.style.display = "block"; // show Select/Clear all buttons elDivOptions.parentNode.lastChild.style.display = null; // show Select/Clear all buttons
let numMeshes = materialTargetData.numMeshes; let numMeshes = materialTargetData.numMeshes;
for (let i = 0; i < numMeshes; ++i) { for (let i = 0; i < numMeshes; ++i) {
@ -3260,37 +3260,35 @@ function sendMaterialTargetProperty() {
let elDivOptions = getPropertyInputElement("parentMaterialName"); let elDivOptions = getPropertyInputElement("parentMaterialName");
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput"); let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
let materialTargetList = ""; let materialTargetList = [];
for (let i = 0; i < elInputs.length; ++i) { for (let i = 0; i < elInputs.length; ++i) {
let elInput = elInputs[i]; let elInput = elInputs[i];
if (elInput.checked) { if (elInput.checked) {
let targetID = elInput.getAttribute("targetID"); let targetID = elInput.getAttribute("targetID");
if (elInput.getAttribute("isMaterialName") === "true") { if (elInput.getAttribute("isMaterialName") === "true") {
materialTargetList += "mat::" + targetID + ","; materialTargetList.push("mat::" + targetID);
} else { } else {
materialTargetList += targetID + ","; materialTargetList.push(targetID);
} }
} }
} }
if (materialTargetList !== "") { let propertyValue = materialTargetList.join(",");
materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1); if (propertyValue.length > 1) {
if (materialTargetList.length > 1) { propertyValue = "[" + propertyValue + "]";
materialTargetList = "[" + materialTargetList + "]";
}
} }
updateProperty("parentMaterialName", materialTargetList, false); updateProperty("parentMaterialName", propertyValue, false);
} }
function materialTargetPropertyUpdate(propertyValue) { function materialTargetPropertyUpdate(propertyValue) {
let elDivOptions = getPropertyInputElement("parentMaterialName"); let elDivOptions = getPropertyInputElement("parentMaterialName");
let elInputs = elDivOptions.getElementsByClassName("materialTargetInput"); let elInputs = elDivOptions.getElementsByClassName("materialTargetInput");
if (propertyValue.charAt(0) === '[') { if (propertyValue.startsWith('[')) {
propertyValue = propertyValue.substring(1, propertyValue.length); propertyValue = propertyValue.substring(1, propertyValue.length);
} }
if (propertyValue.charAt(propertyValue.length - 1) === ']') { if (propertyValue.endsWith(']')) {
propertyValue = propertyValue.substring(0, propertyValue.length - 1); propertyValue = propertyValue.substring(0, propertyValue.length - 1);
} }
@ -3854,7 +3852,9 @@ function loaded() {
} }
} }
} else if (data.type === 'materialTargetReply') { } else if (data.type === 'materialTargetReply') {
setMaterialTargetData(data.materialTargetData); if (data.entityID === selectedEntityProperties.id) {
setMaterialTargetData(data.materialTargetData);
}
} }
}); });