changed inc/dec to use step correctly, still issues with type

This commit is contained in:
FizzleDorf 2023-04-10 13:56:25 -04:00
parent f938b3da37
commit 186c336eb7

View File

@ -18,37 +18,29 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
valueControl.afterQueued = () => { valueControl.afterQueued = () => {
var v = valueControl.value; var v = valueControl.value;
var w = targetWidget.type;
let min = targetWidget.options?.min; let min = targetWidget.options?.min;
let max = targetWidget.options?.max; let max = targetWidget.options?.max;
let range = Math.max(min, max); let range = Math.max(min, max);
//adjust values based on valueControl Behaviour //adjust values based on valueControl Behaviour
if (min != null && max != null) {
switch (v) { switch (v) {
case "fixed": case "fixed":
break; break;
case "increment": case "increment":
if (min != null && max != null) { targetWidget.value += targetWidget.options.step / 10;
if (max) {
targetWidget.value += targetWidget.options?.increment;
}
}
break; break;
case "decrement": case "decrement":
if (min != null && max != null) { targetWidget.value -= targetWidget.options.step / 10;
if (max) {
targetWidget.value -= targetWidget.options?.increment;
}
}
break; break;
case "randomize": case "randomize":
if (min != null && max != null) { var w = targetWidget.type;
switch (w) { switch (w) {
case "FLOAT": case FLOAT:
targetWidget.value = parseFloat((Math.floor(Math.random() * ((range * 100) + 1)) / 100).toFixed(2)); targetWidget.value = parseFloat((Math.floor(Math.random() * ((range * 100) + 1)) / 100).toFixed(2));
break; break;
case "INT": case INT:
if (targetWidget.name == "width" || targetWidget.name == "height") { if (targetWidget.name == "width" || targetWidget.name == "height") {
targetWidget.value = Math.floor(Math.random() * range) * 64 + min; targetWidget.value = Math.floor(Math.random() * range) * 64 + min;
} else { } else {
@ -58,11 +50,11 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
default: default:
break; break;
} }
}
break; break;
default: default:
break; break;
} }
}
/*check if values are over or under their respective /*check if values are over or under their respective
* ranges and set them to min or max.*/ * ranges and set them to min or max.*/
if (targetWidget.value < min) if (targetWidget.value < min)