aboutsummaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2022-08-13 11:33:30 +0100
committerFederico Igne <git@federicoigne.com>2022-08-13 11:33:30 +0100
commit2fd9cc46ff2428bb2fa891f47002e9d3e7585583 (patch)
tree81b8b0122a00e9cd06d5f55091a3b087e430ddb0 /gui.js
downloadrubik-2fd9cc46ff2428bb2fa891f47002e9d3e7585583.tar.gz
rubik-2fd9cc46ff2428bb2fa891f47002e9d3e7585583.zip
init: import project
Diffstat (limited to 'gui.js')
-rwxr-xr-xgui.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/gui.js b/gui.js
new file mode 100755
index 0000000..7f28fd0
--- /dev/null
+++ b/gui.js
@@ -0,0 +1,76 @@
1
2"use strict";
3
4// Define the menu interface
5Gui.prototype = Object.create(dat.GUI.prototype);
6
7function Gui()
8{
9 dat.GUI.call(this);
10
11 var self = this;
12
13 var cmd;
14 cmd = this.add(Cubie.prototype, 'explosion', 0.50, 2.00);
15 cmd.name("Explode");
16 cmd.onChange(function (value)
17 {
18 Cubie.prototype.explosion = value;
19 for (var i = 0; i < cubies.size; i++)
20 {
21 cubies.get(i).updateExplosion();
22 }
23 needsRender = true;
24 });
25
26 cmd = this.add({ func: solvedCube }, 'func');
27 cmd.name("Solved Cube");
28
29 cmd = this.add({ func: scramble }, 'func');
30 cmd.name("Scramble");
31
32 cmd = this.add({ func: function(){ selectFile(false); } }, 'func');
33 cmd.name("Load File");
34
35 cmd = this.add({ func: function(){
36 // Default name
37 // This is used if the browser is *not* configured to prompt for a name
38 // (and location) to save a new file.
39 var filename = "rubik.txt"
40 var content = "Answer: 0\n"
41 for (var i = 0; i < cubies.size; i++)
42 {
43 let cubie = cubies.get(i)
44 content += `is(0,${i},${cubie.colors[0].value},${cubie.colors[1].value},${cubie.colors[2].value}) `
45 }
46
47 saveToFile(filename,content);
48 } }, 'func');
49 cmd.name("Save to File");
50
51 var pos_commands_folder = this.addFolder('Commands (Positive)');
52 var neg_commands_folder = this.addFolder('Commands (Negative)');
53 animations.forEach(function(value,key)
54 {
55 cmd = pos_commands_folder.add({ dummy: function(){} }, 'dummy');
56 cmd.name(key);
57 cmd.onChange(function()
58 {
59 startAnimation(key,1.0);
60 })
61
62 cmd = neg_commands_folder.add({ dummy: function(){} }, 'dummy');
63 cmd.name(key);
64 cmd.onChange(function()
65 {
66 startAnimation(key,-1.0);
67 })
68 });
69 // pos_commands_folder.open();
70 // neg_commands_folder.open();
71}
72
73
74
75
76