Added missing dynamic

This commit is contained in:
Menithal 2017-02-26 19:17:46 +02:00
parent 69949cd6b5
commit 1d8be2aeaa
3 changed files with 16 additions and 5 deletions

View file

@ -2409,6 +2409,7 @@ function MyController(hand) {
var cloneableProps = Entities.getEntityProperties(grabbedProperties.id);
var lifetime = grabInfo.cloneLifetime ? grabInfo.cloneLifetime : 300;
var limit = grabInfo.cloneLimit ? grabInfo.cloneLimit : 10;
var dynamic = grabInfo.cloneDynamic ? grabInfo.cloneDynamic : false;
var cUserData = Object.assign({}, userData);
var cProperties = Object.assign({}, cloneableProps);
@ -2422,8 +2423,12 @@ function MyController(hand) {
delete cUserData.grabbableKey.cloneLifetime;
delete cUserData.grabbableKey.cloneable;
delete cUserData.grabbableKey.cloneDynamic;
delete cUserData.grabbableKey.cloneLimit;
delete cProperties.id
cProperties.dynamic = dynamic;
cProperties.locked = false;
cUserData.grabbableKey.triggerable = true;
cUserData.grabbableKey.grabbable = true;
cProperties.lifetime = lifetime;

View file

@ -312,6 +312,10 @@
<div class="cloneable-group property gen">
<div><label>Clone Lifetime</label><input type="number" data-user-data-type="cloneLifetime" id="property-cloneable-lifetime"></div>
<div><label>Clone Limit</label><input type="number" data-user-data-type="cloneLimit" id="property-cloneable-limit"></div>
<div class="property checkbox">
<input type="checkbox" id="property-cloneable-dynamic">
<label for="property-cloneable-dynamic">Clone Dynamic</label>
</div>
</div>
</div>
</div>

View file

@ -603,7 +603,7 @@ function loaded() {
var elGrabbable = document.getElementById("property-grabbable");
var elCloneable = document.getElementById("property-cloneable");
var elCloneableDynamic = document.getElementById("property-cloneable-dynamic");
var elCloneableGroup = document.getElementById("group-cloneable-group");
var elCloneableLifetime = document.getElementById("property-cloneable-lifetime");
var elCloneableLimit = document.getElementById("property-cloneable-limit");
@ -893,15 +893,14 @@ function loaded() {
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
elCloneableLimit.value = elCloneable.checked ? 10: 0;
elCloneableLifetime.value = elCloneable.checked ? 300: 0;
elCloneableDynamic.checked = parsedUserData["grabbableKey"].cloneDynamic ? parsedUserData["grabbableKey"].cloneDynamic : properties.dynamic;
elDynamic.checked = elCloneable.checked ? false: properties.dynamic;
} else {
elCloneable.checked = false;
elCloneableDynamic.checked = false;
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
elCloneableLimit.value = 0;
elCloneableLifetime.value = 0;
}
if ("cloneLifetime" in parsedUserData["grabbableKey"]) {
elCloneableLifetime.value = parsedUserData["grabbableKey"].cloneLifetime;
@ -1203,11 +1202,14 @@ function loaded() {
elGrabbable.addEventListener('change', function() {
userDataChanger("grabbableKey", "grabbable", elGrabbable, elUserData, properties.dynamic);
});
elCloneableDynamic.addEventListener('change', function (event){
userDataChanger("grabbableKey", "cloneDynamic", event.target, elUserData, -1);
});
elCloneable.addEventListener('change', function (event) {
var checked = event.target.checked;
if (checked) {
multiUserDataChanger("grabbableKey",
{cloneLifetime: elCloneableLifetime, cloneLimit: elCloneableLimit, cloneable: event.target},
{cloneLifetime: elCloneableLifetime, cloneLimit: elCloneableLimit, cloneDynamic: elCloneableDynamic, cloneable: event.target},
elUserData,
{cloneLifetime: 300, cloneLimit: 10, cloneable: false});
elCloneableGroup.style.display = "block";