From 349af15e05307ed537e7753e316e30bebe52fef3 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Wed, 25 Nov 2020 03:59:57 -0700 Subject: [PATCH] Fix being stuck in rewind mode forever when using the button --- js/main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index ad51927..6a2af5b 100644 --- a/js/main.js +++ b/js/main.js @@ -368,8 +368,11 @@ class Player extends PrimaryView { }); this.rewind_button = this.root.querySelector('.controls .control-rewind'); this.rewind_button.addEventListener('click', ev => { - if (this.level.has_undo()) { - this.state = 'rewinding'; + if (this.state === 'rewinding') { + this.set_state('playing'); + } + else if (this.level.has_undo()) { + this.set_state('rewinding'); } }); // Demo playback @@ -928,8 +931,10 @@ class Player extends PrimaryView { } update_ui() { - this.pause_button.disabled = !(this.state === 'playing' || this.state === 'paused'); + this.pause_button.disabled = !(this.state === 'playing' || this.state === 'paused' || this.state === 'rewinding'); this.restart_button.disabled = (this.state === 'waiting'); + this.undo_button.disabled = ! this.level.has_undo(); + this.rewind_button.disabled = ! (this.level.has_undo() || this.state === 'rewinding'); // TODO can we do this only if they actually changed? this.chips_el.textContent = this.level.chips_remaining;