Add validate method to individual checks

Fix switching elements to per face UV in validator
This commit is contained in:
JannisX11 2023-06-08 20:19:47 +02:00
parent 40ee8232f5
commit 83a1685f74

View File

@ -96,6 +96,7 @@ class ValidatorCheck {
this.run = options.run; this.run = options.run;
this.errors = []; this.errors = [];
this.warnings = []; this.warnings = [];
this._timeout = null;
Validator.checks.push(this); Validator.checks.push(this);
Validator.updateCashedTriggers(); Validator.updateCashedTriggers();
@ -116,6 +117,26 @@ class ValidatorCheck {
console.error(error); console.error(error);
} }
} }
validate() {
if (this._timeout) {
clearTimeout(this._timeout);
this._timeout = null;
}
this._timeout = setTimeout(() => {
this._timeout = null;
this.update();
Validator.warnings.empty();
Validator.errors.empty();
Validator.checks.forEach(check => {
Validator.warnings.push(...check.warnings);
Validator.errors.push(...check.errors);
})
}, 40)
}
warn(...warnings) { warn(...warnings) {
this.warnings.push(...warnings); this.warnings.push(...warnings);
} }
@ -186,15 +207,10 @@ new ValidatorCheck('box_uv', {
click() { click() {
Validator.dialog.hide(); Validator.dialog.hide();
save = Undo.initEdit({uv_mode: true}) Undo.initEdit({elements: [cube], uv_only: true});
Project.box_uv = false; cube.setUVMode(false);
Canvas.updateAllUVs() Undo.finishEdit('Change UV mode')
updateSelection() updateSelection();
Undo.finishEdit('Change project UV settings')
BARS.updateConditions()
if (Project.EditSession) {
Project.EditSession.sendAll('change_project_meta', JSON.stringify({box_uv: false}));
}
} }
}) })
} }