Commit 60132add authored by Florent Becker's avatar Florent Becker

Control the speed of stepping

parent ab7650f5
...@@ -302,9 +302,9 @@ ...@@ -302,9 +302,9 @@
<button id="fast-back-button" class="w3-bar-item w3-button"><span class="material-icons">fast_rewind</span></button> <button id="fast-back-button" class="w3-bar-item w3-button"><span class="material-icons">fast_rewind</span></button>
<button id="step-back-button" class="w3-bar-item w3-button"><span class="material-icons">skip_previous</span></button> <button id="step-back-button" class="w3-bar-item w3-button"><span class="material-icons">skip_previous</span></button>
<button id="stop-button" class="w3-bar-item w3-button"><span class="material-icons">stop</span></button> <button id="stop-button" class="w3-bar-item w3-button"><span class="material-icons">stop</span></button>
<span class="w3-bar-item">speed ×
<input style="width: 5em;" type="number" id="ff-speed-input" value="1"></input></span>
<button id="step-forward-button" class="w3-bar-item w3-button" style="margin-right: 0;"><span class="material-icons">skip_next</span></button> <button id="step-forward-button" class="w3-bar-item w3-button" style="margin-right: 0;"><span class="material-icons">skip_next</span></button>
<span class="w3-bar-item">speed ×
<input style="width: 10em;" type="number" id="ff-speed"></input></span>
<button id="fast-forward-button" class="w3-bar-item w3-button"><span class="material-icons">fast_forward</span></button> <button id="fast-forward-button" class="w3-bar-item w3-button"><span class="material-icons">fast_forward</span></button>
<div class="w3-bar-item bar-divider"></div> <div class="w3-bar-item bar-divider"></div>
......
...@@ -21,12 +21,13 @@ const ALL_TEXT_CUTOFF = 25; ...@@ -21,12 +21,13 @@ const ALL_TEXT_CUTOFF = 25;
const OUTLINE_CUTOFF = 5; const OUTLINE_CUTOFF = 5;
export class Simulator { export class Simulator {
constructor() { constructor() {
this.fastBackButton = document.getElementById('fast-back-button'); this.fastBackButton = document.getElementById('fast-back-button');
this.stepBackButton = document.getElementById('step-back-button'); this.stepBackButton = document.getElementById('step-back-button');
this.stopButton = document.getElementById('stop-button'); this.stopButton = document.getElementById('stop-button');
this.stepForwardButton = document.getElementById('step-forward-button'); this.stepForwardButton = document.getElementById('step-forward-button');
this.fastForwardButton = document.getElementById('fast-forward-button'); this.ffSpeedInput = document.getElementById('ff-speed-input');
this.fastForwardButton = document.getElementById('fast-forward-button');
this.selectModeButton = document.getElementById('select-mode-button'); this.selectModeButton = document.getElementById('select-mode-button');
this.placeModeButton = document.getElementById('place-mode-button'); this.placeModeButton = document.getElementById('place-mode-button');
this.zoomInButton = document.getElementById('zoom-in-button'); this.zoomInButton = document.getElementById('zoom-in-button');
...@@ -297,7 +298,9 @@ export class Simulator { ...@@ -297,7 +298,9 @@ export class Simulator {
} }
stepForward() { stepForward() {
this.tileWorker.postMessage({ msg: "step-forward" }); let speed = this.ffSpeedInput.value;
console.log(speed);
this.tileWorker.postMessage({ msg: "step-forward", repeat: speed });
} }
stepBackward() { stepBackward() {
......
...@@ -59,19 +59,22 @@ onmessage = function(e) { ...@@ -59,19 +59,22 @@ onmessage = function(e) {
precomputeSignatures(); precomputeSignatures();
} }
} else if (e.data.msg === "step-forward") { } else if (e.data.msg === "step-forward") {
const added_list = stepForward(); let n_tiles = e.data.repeat || 1;
if (added_list === null) { for (i = 0; i < n_tiles; i++) {
postMessage({ msg: "frontier-empty" }); const added_list = stepForward();
} else { if (added_list === null) {
for (let i=0; i<added_list.length; i++) { postMessage({ msg: "frontier-empty" });
postMessage({ } else {
msg: "tile-added", for (let i=0; i<added_list.length; i++) {
tid: added_list[i][0], postMessage({
x: added_list[i][1], msg: "tile-added",
y: added_list[i][2] tid: added_list[i][0],
}); x: added_list[i][1],
} y: added_list[i][2]
});
} }
}
}
} else if (e.data.msg === "step-backward") { } else if (e.data.msg === "step-backward") {
const removed = stepBackward(); const removed = stepBackward();
if (removed !== null) { if (removed !== null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment