From 0e1283c5376d63859e13eb685f1684a0d1f248d6 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Mon, 15 Oct 2018 02:18:01 +0300 Subject: [PATCH] Add autoplay toggle, fix notes not being skipped on autoplay --- public/src/css/debug.css | 5 ++++- public/src/js/debug.js | 34 +++++++++++++++++++++++++++++++--- public/src/js/game.js | 9 ++++----- public/src/views/debug.html | 1 + 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/public/src/css/debug.css b/public/src/css/debug.css index 907efe2..7c838f0 100644 --- a/public/src/css/debug.css +++ b/public/src/css/debug.css @@ -3,7 +3,6 @@ top: 0; left: 0; width: 260px; - height: 240px; background: #fff; border: 1px solid #333; color: #000; @@ -111,3 +110,7 @@ #debug .exit-btn{ margin-left: 3px; } + +#debug .autoplay-label{ + display: none; +} diff --git a/public/src/js/debug.js b/public/src/js/debug.js index 4bbda33..0c566ee 100644 --- a/public/src/js/debug.js +++ b/public/src/js/debug.js @@ -13,6 +13,8 @@ class Debug{ this.offsetDiv = this.debugDiv.getElementsByClassName("offset")[0] this.measureNumDiv = this.debugDiv.getElementsByClassName("measure-num")[0] this.restartCheckbox = this.debugDiv.getElementsByClassName("change-restart")[0] + this.autoplayLabel = this.debugDiv.getElementsByClassName("autoplay-label")[0] + this.autoplayCheckbox = this.debugDiv.getElementsByClassName("autoplay")[0] this.restartBtn = this.debugDiv.getElementsByClassName("restart-btn")[0] this.exitBtn = this.debugDiv.getElementsByClassName("exit-btn")[0] @@ -23,6 +25,7 @@ class Debug{ pageEvents.add(this.minimiseDiv, "click", this.minimise.bind(this)) pageEvents.add(this.restartBtn, "click", this.restartSong.bind(this)) pageEvents.add(this.exitBtn, "click", this.clean.bind(this)) + pageEvents.add(this.autoplayCheckbox, "change", this.toggleAutoplay.bind(this)) this.offsetSlider = new InputSlider(this.offsetDiv, -60, 60, 3) this.offsetSlider.onchange(this.offsetChange.bind(this)) @@ -85,6 +88,7 @@ class Debug{ updateStatus(){ if(debugObj.controller && !this.controller){ this.restartBtn.style.display = "block" + this.autoplayLabel.style.display = "block" this.controller = debugObj.controller var selectedSong = this.controller.selectedSong @@ -109,16 +113,16 @@ class Debug{ var circles = game.songData.circles for(var i in circles){ game.currentCircle = i - if(circles[i].ms < measureMS){ - game.currentCircle = i - }else{ + if(circles[i].endTime >= measureMS){ break } } } + this.autoplayCheckbox.checked = this.controller.autoPlayEnabled } if(this.controller && !debugObj.controller){ this.restartBtn.style.display = "" + this.autoplayLabel.style.display = "" this.controller = null } } @@ -149,14 +153,38 @@ class Debug{ this.controller.restartSong() } } + toggleAutoplay(){ + if(this.controller){ + this.controller.autoPlayEnabled = this.autoplayCheckbox.checked + if(!this.controller.autoPlayEnabled){ + var keyboard = debugObj.controller.keyboard + var kbd = keyboard.getBindings() + keyboard.setKey(kbd.don_l, false) + keyboard.setKey(kbd.don_r, false) + keyboard.setKey(kbd.ka_l, false) + keyboard.setKey(kbd.ka_r, false) + } + } + } clean(){ this.offsetSlider.clean() pageEvents.remove(window, ["mousedown", "mouseup", "mousemove", "blur"]) pageEvents.remove(this.title, "mousedown") + pageEvents.remove(this.minimiseDiv, "click") + pageEvents.remove(this.restartBtn, "click") + pageEvents.remove(this.exitBtn, "click") + pageEvents.remove(this.autoplayCheckbox, "change") delete this.titleDiv delete this.minimiseDiv + delete this.offsetDiv + delete this.measureNumDiv + delete this.restartCheckbox + delete this.autoplayLabel + delete this.autoplayCheckbox + delete this.restartBtn + delete this.exitBtn delete this.controller debugObj.state = "closed" diff --git a/public/src/js/game.js b/public/src/js/game.js index 14ee334..a194fda 100644 --- a/public/src/js/game.js +++ b/public/src/js/game.js @@ -71,7 +71,7 @@ class Game{ var endTime = circle.getEndTime() + (drumrollNotes ? 0 : this.rules.bad) if(ms >= circle.getMS()){ - if(drumrollNotes && !circle.rendaPlayed){ + if(drumrollNotes && !circle.rendaPlayed && ms < endTime){ circle.rendaPlayed = true if(this.rules.difficulty === "easy"){ assets.sounds["renda" + this.controller.snd].stop() @@ -84,10 +84,6 @@ class Game{ } circle.beatMSCopied = true } - if(!nextSet){ - nextSet = true - this.currentCircle = i - } } if(ms > endTime){ if(!this.controller.autoPlayEnabled){ @@ -113,6 +109,9 @@ class Game{ } } } + }else if(!this.controller.autoPlayEnabled && !nextSet){ + nextSet = true + this.currentCircle = i } } } diff --git a/public/src/views/debug.html b/public/src/views/debug.html index dcee191..eba64ac 100644 --- a/public/src/views/debug.html +++ b/public/src/views/debug.html @@ -10,6 +10,7 @@ x-+ +
Restart song
Exit debug