From 13710c04c8aba21f347ea2175f07db7d1e7d504b Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sun, 1 Dec 2019 08:22:41 +0800 Subject: [PATCH] Update actions.js --- libs/actions.js | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index e2278a7d..bf8a6140 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1917,11 +1917,11 @@ actions.prototype._keyUpSL = function (keycode) { ////// 系统设置界面时的点击操作 ////// actions.prototype._clickSwitchs = function (x, y) { - if ((x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) && (x != 4 && y != 4) && (x != 8 && y != 4) && (x != 4 && y != 5) && (x != 8 && y != 5)) return; var choices = core.status.event.ui.choices; var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); - if (y >= topIndex && y < topIndex + choices.length) { - var selection = y - topIndex; + var selection = y - topIndex; + if ((x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) && (x != this.HSIZE-2 && selection != 2) && (x != this.HSIZE+2 && selection != 2) && (x != this.HSIZE-2 && selection != 3) && (x != this.HSIZE+2 && selection != 3)) return; + if (selection >= 0 && selection < choices.length) { core.status.event.selection = selection; switch (selection) { case 0: @@ -1929,12 +1929,12 @@ actions.prototype._clickSwitchs = function (x, y) { case 1: return this._clickSwitchs_sound(); case 2: - if (x == 4) { return this._clickSwitchs_userVolume_down(); } - else if (x == 8) { return this._clickSwitchs_userVolume_up(); } + if (x == this.HSIZE-2) { return this._clickSwitchs_userVolume(-0.1); } + else if (x == this.HSIZE+2) { return this._clickSwitchs_userVolume(0.1); } return; case 3: - if (x == 4) { return this._clickSwitchs_moveSpeed_down(); } - else if (x == 8) { return this._clickSwitchs_moveSpeed_up(); } + if (x == this.HSIZE-2) { return this._clickSwitchs_moveSpeed(10); } + else if (x == this.HSIZE+2) { return this._clickSwitchs_moveSpeed(-10); } return; case 4: return this._clickSwitchs_displayEnemyDamage(); @@ -1965,37 +1965,24 @@ actions.prototype._clickSwitchs_sound = function () { core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_userVolume_down = function () { +actions.prototype._clickSwitchs_userVolume = function (delta) { //浮点运算精度 JS弱类型 - var value = Math.pow(core.clamp(parseFloat(Math.sqrt(Number(core.musicStatus.userVolume)).toFixed(1)) - 0.1, 0, 1), 2).toFixed(2); - core.musicStatus.userVolume = parseFloat(value); + var value= parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1)); + core.musicStatus.userVolume = parseFloat(Math.pow(core.clamp(parseFloat(value + delta), 0, 1), 2).toFixed(2)); //audioContext 音效 不受designVolume 影响 if(core.musicStatus.gainNode != null) core.musicStatus.gainNode.gain.value = core.musicStatus.userVolume; if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume; core.setLocalStorage('userVolume', core.musicStatus.userVolume); core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_userVolume_up = function () { - var value = Math.pow(core.clamp(parseFloat(Math.sqrt(Number(core.musicStatus.userVolume)).toFixed(1)) + 0.1, 0, 1), 2).toFixed(2); - core.musicStatus.userVolume = parseFloat(value); - if(core.musicStatus.gainNode != null) core.musicStatus.gainNode.gain.value = core.musicStatus.userVolume; - if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume; - core.setLocalStorage('userVolume', core.musicStatus.userVolume); + +actions.prototype._clickSwitchs_moveSpeed = function (delta) { + var value = core.clamp(parseInt(core.values.moveSpeed + delta), 60, 200); + core.values.moveSpeed = parseInt(value); + core.setLocalStorage("moveSpeed", core.values.moveSpeed); core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_moveSpeed_down = function () { - var value = core.clamp(parseInt(core.values.moveSpeed + 10), 60, 200); - core.values.moveSpeed = parseInt(value); - core.setLocalStorage("moveSpeed", core.values.moveSpeed); - core.ui.drawSwitchs(); -} -actions.prototype._clickSwitchs_moveSpeed_up = function () { - var value = core.clamp(parseInt(core.values.moveSpeed - 10), 60, 200); - core.values.moveSpeed = parseInt(value); - core.setLocalStorage("moveSpeed", core.values.moveSpeed); - core.ui.drawSwitchs(); -} actions.prototype._clickSwitchs_displayEnemyDamage = function () { core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage;