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>
<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 × <span class="w3-bar-item">speed ×
<input style="width: 10em;" type="number" id="ff-speed"></input></span> <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="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>
......
...@@ -26,6 +26,7 @@ export class Simulator { ...@@ -26,6 +26,7 @@ export class Simulator {
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.ffSpeedInput = document.getElementById('ff-speed-input');
this.fastForwardButton = document.getElementById('fast-forward-button'); 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');
...@@ -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,6 +59,8 @@ onmessage = function(e) { ...@@ -59,6 +59,8 @@ onmessage = function(e) {
precomputeSignatures(); precomputeSignatures();
} }
} else if (e.data.msg === "step-forward") { } else if (e.data.msg === "step-forward") {
let n_tiles = e.data.repeat || 1;
for (i = 0; i < n_tiles; i++) {
const added_list = stepForward(); const added_list = stepForward();
if (added_list === null) { if (added_list === null) {
postMessage({ msg: "frontier-empty" }); postMessage({ msg: "frontier-empty" });
...@@ -72,6 +74,7 @@ onmessage = function(e) { ...@@ -72,6 +74,7 @@ onmessage = function(e) {
}); });
} }
} }
}
} 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