"use strict"; // Define the menu interface Gui.prototype = Object.create(dat.GUI.prototype); function Gui() { dat.GUI.call(this); var self = this; var cmd; cmd = this.add(Cubie.prototype, 'explosion', 0.50, 2.00); cmd.name("Explode"); cmd.onChange(function (value) { Cubie.prototype.explosion = value; for (var i = 0; i < cubies.size; i++) { cubies.get(i).updateExplosion(); } needsRender = true; }); cmd = this.add({ func: solvedCube }, 'func'); cmd.name("Solved Cube"); cmd = this.add({ func: scramble }, 'func'); cmd.name("Scramble"); cmd = this.add({ func: function(){ selectFile(false); } }, 'func'); cmd.name("Load File"); cmd = this.add({ func: function(){ // Default name // This is used if the browser is *not* configured to prompt for a name // (and location) to save a new file. var filename = "rubik.txt" var content = "Answer: 0\n" for (var i = 0; i < cubies.size; i++) { let cubie = cubies.get(i) content += `is(0,${i},${cubie.colors[0].value},${cubie.colors[1].value},${cubie.colors[2].value}) ` } saveToFile(filename,content); } }, 'func'); cmd.name("Save to File"); var pos_commands_folder = this.addFolder('Commands (Positive)'); var neg_commands_folder = this.addFolder('Commands (Negative)'); animations.forEach(function(value,key) { cmd = pos_commands_folder.add({ dummy: function(){} }, 'dummy'); cmd.name(key); cmd.onChange(function() { startAnimation(key,1.0); }) cmd = neg_commands_folder.add({ dummy: function(){} }, 'dummy'); cmd.name(key); cmd.onChange(function() { startAnimation(key,-1.0); }) }); // pos_commands_folder.open(); // neg_commands_folder.open(); }