grid resizing and auto reset

This commit is contained in:
MaxRobinsonTheGreat
2020-07-19 17:33:09 -06:00
parent ebb39df34a
commit a5a559e61b
7 changed files with 411 additions and 34 deletions

View File

@@ -6,6 +6,7 @@ class ControlPanel {
constructor(engine) {
this.engine = engine;
this.defineEngineSpeedControls();
this.defineGridSizeControls();
this.defineTabNavigation();
this.defineHyperparameterControls();
this.defineModeControls();
@@ -39,6 +40,29 @@ class ControlPanel {
}.bind(this));
}
defineGridSizeControls() {
$('#fill-window').change(function() {
if (this.checked)
$('.col-row-input').css('display' ,'none');
else
$('.col-row-input').css('display' ,'block');
});
$('#resize').click(function() {
var cell_size = $('#cell-size').val();
var fill_window = $('#fill-window').is(":checked");
if (fill_window) {
this.engine.env.resizeFillWindow(cell_size);
}
else {
var cols = $('#col-input').val();
var rows = $('#row-input').val();
this.engine.env.resizeGridColRow(cell_size, cols, rows);
}
}.bind(this));
}
defineTabNavigation() {
var self = this;
$('.tabnav-item').click(function() {
@@ -146,10 +170,13 @@ class ControlPanel {
}
});
var env = this.engine.env;
$('#reset-env').click( function() {
this.engine.env.reset();
}.bind(this));
$('#auto-reset').change(function() {
env.auto_reset = this.checked;
});
$('#kill-all').click( function() {
this.engine.env.clearOrganisms();
}.bind(this));