From c311591d4afcd33f97737c104af43fe67f542c86 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 12:48:44 +0800 Subject: [PATCH 01/15] test --- libs/actions.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 1a8597dd..9fef0934 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -822,6 +822,8 @@ actions.prototype._selectChoices = function (length, keycode, callback) { var topIndex = this.HSIZE - parseInt((length - 1) / 2) + (core.status.event.ui.offset || 0); if (keycode == 13 || keycode == 32 || keycode == 67) { callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]); + } + if (keycode == 39) callback.apply(this, [this.HSIZE + 2, topIndex + core.status.event.selection]); } if (keycode >= 49 && keycode <= 57) { var index = keycode - 49; @@ -1910,7 +1912,7 @@ actions.prototype._keyUpSL = function (keycode) { ////// 系统设置界面时的点击操作 ////// actions.prototype._clickSwitchs = function (x, y) { - if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; + if ((x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) && (x != 4 && y != 4) && (x != 8 && y != 4)) 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) { @@ -1922,18 +1924,22 @@ actions.prototype._clickSwitchs = function (x, y) { case 1: return this._clickSwitchs_sound(); case 2: - return this._clickSwitchs_moveSpeed(); + if (x == 4) return this._clickSwitchs_volume_down(); + else if (x == 8) return this._clickSwitchs_volume_up(); + return; case 3: - return this._clickSwitchs_displayEnemyDamage(); + return this._clickSwitchs_moveSpeed(); case 4: - return this._clickSwitchs_displayCritical(); + return this._clickSwitchs_displayEnemyDamage(); case 5: - return this._clickSwitchs_displayExtraDamage(); + return this._clickSwitchs_displayCritical(); case 6: - return this._clickSwitchs_localForage(); + return this._clickSwitchs_displayExtraDamage(); case 7: - return this._clickSwitchs_clickMove(); + return this._clickSwitchs_localForage(); case 8: + return this._clickSwitchs_clickMove(); + case 9: core.status.event.selection = 0; core.ui.drawSettings(); break; @@ -1952,6 +1958,20 @@ actions.prototype._clickSwitchs_sound = function () { core.ui.drawSwitchs(); } +actions.prototype._clickSwitchs_volume_down = function () { + //浮点运算精度 + core.musicStatus.volume = core.clamp(parseFloat(core.musicStatus.volume - 0.1).toFixed(1), 0, 1); + core.musicStatus.gainNode.gain.value = core.musicStatus.volume; + if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.volume; + core.ui.drawSwitchs(); +} +actions.prototype._clickSwitchs_volume_up = function () { + core.musicStatus.volume = core.clamp(parseFloat(core.musicStatus.volume + 0.1).toFixed(1), 0, 1); + core.musicStatus.gainNode.gain.value = core.musicStatus.volume; + if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.volume; + core.ui.drawSwitchs(); +} + actions.prototype._clickSwitchs_moveSpeed = function () { core.myprompt("请输入行走速度(每走一步的时间,单位毫秒,默认100)", core.values.moveSpeed, function (value) { value = parseInt(value) || core.values.moveSpeed; @@ -2103,7 +2123,7 @@ actions.prototype._clickSyncSave_readFile = function () { if (obj.version != core.firstData.version) return alert("游戏版本不一致!"); if (!obj.data) return alert("无效的存档!"); core.control._syncLoad_write(obj.data); - }, null, ".h5save"); + }); } actions.prototype._clickSyncSave_replay = function () { From 93e297d73f03a3dbd6e1c7c46a37a2742c14a2ef Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 13:00:53 +0800 Subject: [PATCH 02/15] Update actions.js --- libs/actions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/actions.js b/libs/actions.js index 9fef0934..301e3973 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -823,6 +823,10 @@ actions.prototype._selectChoices = function (length, keycode, callback) { if (keycode == 13 || keycode == 32 || keycode == 67) { callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]); } + //左右方向键音量 + if(core.status.event.id == "switchs" && core.status.event.selection == 2) + { + if (keycode == 37) callback.apply(this, [this.HSIZE - 2, topIndex + core.status.event.selection]); if (keycode == 39) callback.apply(this, [this.HSIZE + 2, topIndex + core.status.event.selection]); } if (keycode >= 49 && keycode <= 57) { From 641459bf787617bca463cedafcededaf16e8ceba Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 13:01:04 +0800 Subject: [PATCH 03/15] Update ui.js --- libs/ui.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ui.js b/libs/ui.js index a1b88121..dd00e7ff 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -459,7 +459,7 @@ ui.prototype.clearUI = function () { ////// 左上角绘制一段提示 ////// ui.prototype.drawTip = function (text, id, clear) { - this.clearTip(); + if (clear) this.clearTip(); var one = { text: text, textX: 21, @@ -1496,6 +1496,8 @@ ui.prototype.drawSwitchs = function() { var choices = [ "背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"), "背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), + //显示为 1~10 十挡 + " < " + "音量:"+parseInt(core.musicStatus.volume * 10) + " > ", "行走速度: "+parseInt(core.values.moveSpeed), "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"), From 300d84d3eead82885ad194f7c2c0eb26da493b04 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 16:37:11 +0800 Subject: [PATCH 04/15] Update actions.js --- libs/actions.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 301e3973..599e4d12 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1928,8 +1928,8 @@ actions.prototype._clickSwitchs = function (x, y) { case 1: return this._clickSwitchs_sound(); case 2: - if (x == 4) return this._clickSwitchs_volume_down(); - else if (x == 8) return this._clickSwitchs_volume_up(); + if (x == 4) return this._clickSwitchs_userVolume_down(); + else if (x == 8) return this._clickSwitchs_userVolume_up(); return; case 3: return this._clickSwitchs_moveSpeed(); @@ -1962,17 +1962,20 @@ actions.prototype._clickSwitchs_sound = function () { core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_volume_down = function () { +actions.prototype._clickSwitchs_userVolume_down = function () { //浮点运算精度 - core.musicStatus.volume = core.clamp(parseFloat(core.musicStatus.volume - 0.1).toFixed(1), 0, 1); - core.musicStatus.gainNode.gain.value = core.musicStatus.volume; - if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.volume; + core.musicStatus.userVolume = core.clamp(parseFloat(core.musicStatus.userVolume - 0.1).toFixed(1), 0, 1); + //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_volume_up = function () { - core.musicStatus.volume = core.clamp(parseFloat(core.musicStatus.volume + 0.1).toFixed(1), 0, 1); - core.musicStatus.gainNode.gain.value = core.musicStatus.volume; - if (core.musicStatus.playingBgm) core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.volume; +actions.prototype._clickSwitchs_userVolume_up = function () { + core.musicStatus.userVolume = core.clamp(parseFloat(core.musicStatus.userVolume + 0.1).toFixed(1), 0, 1); + 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(); } From 25ce9e9b757da17cdaf24d2bfaeced5deec94e87 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 16:37:36 +0800 Subject: [PATCH 05/15] Update control.js --- libs/control.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/control.js b/libs/control.js index 5f7b5e6b..06e80118 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2247,7 +2247,7 @@ control.prototype._playBgm_play = function (bgm, startTime) { // 缓存BGM core.loader.loadBgm(bgm); // 播放当前BGM - core.material.bgms[bgm].volume = core.musicStatus.volume; + core.material.bgms[bgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume; core.material.bgms[bgm].currentTime = startTime || 0; core.material.bgms[bgm].play(); core.musicStatus.playingBgm = bgm; @@ -2320,7 +2320,7 @@ control.prototype.playSound = function (sound) { core.musicStatus.playingSounds[id] = source; } else { - core.material.sounds[sound].volume = core.musicStatus.volume; + core.material.sounds[sound].volume = core.musicStatus.userVolume; core.material.sounds[sound].play(); } } From d877de208140520142f829847fd34175514fb106 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 16:37:48 +0800 Subject: [PATCH 06/15] Update core.js --- libs/core.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/core.js b/libs/core.js index 0268bb5a..d9c8f933 100644 --- a/libs/core.js +++ b/libs/core.js @@ -61,7 +61,8 @@ function core() { 'lastBgm': null, // 上次播放的bgm 'gainNode': null, 'playingSounds': {}, // 正在播放的SE - 'volume': 1.0, // 音量 + 'userVolume': 1.0, // 用户音量 + 'designVolume': 1.0, //设计音量 'cachedBgms': [], // 缓存BGM内容 'cachedBgmCount': 4, // 缓存的bgm数量 } @@ -302,6 +303,8 @@ core.prototype._init_platform = function () { } core.musicStatus.bgmStatus = core.getLocalStorage('bgmStatus', true); core.musicStatus.soundStatus = core.getLocalStorage('soundStatus', true); + //新增 userVolume 默认值1.0 + core.musicStatus.userVolume = core.getLocalStorage('userVolume', 1.0); ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"].forEach(function (t) { if (navigator.userAgent.indexOf(t) >= 0) { if (t == 'iPhone' || t == 'iPad' || t == 'iPod') core.platform.isIOS = true; From 4748fb65d83428cae333605c997acd3d233176df Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 16:38:04 +0800 Subject: [PATCH 07/15] Update events.js --- libs/events.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/events.js b/libs/events.js index c95f2390..1729d674 100644 --- a/libs/events.js +++ b/libs/events.js @@ -2329,16 +2329,16 @@ events.prototype.showGif = function (name, x, y) { ////// 淡入淡出音乐 ////// events.prototype.setVolume = function (value, time, callback) { var set = function (value) { - core.musicStatus.volume = value; + core.musicStatus.designVolume = value; if (core.musicStatus.playingBgm) - core.material.bgms[core.musicStatus.playingBgm].volume = value; + core.material.bgms[core.musicStatus.playingBgm].volume = core.musicStatus.userVolume * core.musicStatus.designVolume; } if (!time || time < 100) { set(value); if (callback) callback(); return; } - var currVolume = core.musicStatus.volume; + var currVolume = core.musicStatus.designVolume; time /= Math.max(core.status.replay.speed, 1); var per_time = 10, step = 0, steps = parseInt(time / per_time); if (steps <= 0) steps = 1; From 3ad99dd59325f22702652201db779dd169bbb8ac Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Fri, 29 Nov 2019 16:38:14 +0800 Subject: [PATCH 08/15] Update ui.js --- libs/ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index dd00e7ff..bc9f2834 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -459,7 +459,7 @@ ui.prototype.clearUI = function () { ////// 左上角绘制一段提示 ////// ui.prototype.drawTip = function (text, id, clear) { - if (clear) this.clearTip(); + this.clearTip(); var one = { text: text, textX: 21, @@ -1497,7 +1497,7 @@ ui.prototype.drawSwitchs = function() { "背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"), "背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), //显示为 1~10 十挡 - " < " + "音量:"+parseInt(core.musicStatus.volume * 10) + " > ", + " < " + "音量:"+parseInt(core.musicStatus.userVolume* 10) + " > ", "行走速度: "+parseInt(core.values.moveSpeed), "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"), From cfecb91bbe7c58e69336cab621dc9b3613b39cf4 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sat, 30 Nov 2019 11:35:17 +0800 Subject: [PATCH 09/15] Update ui.js --- libs/ui.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index bc9f2834..ad24f43c 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1496,9 +1496,10 @@ ui.prototype.drawSwitchs = function() { var choices = [ "背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"), "背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), - //显示为 1~10 十挡 - " < " + "音量:"+parseInt(core.musicStatus.userVolume* 10) + " > ", - "行走速度: "+parseInt(core.values.moveSpeed), + //显示为 0~10 十挡 + " < "+"音量:"+parseInt(parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1)) * 10)+" > ", + //显示为 1~15 十五挡 + " < "+"行走速度:" + parseInt((210 - core.values.moveSpeed) / 10) +" > ", "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"), "领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), From 5087d4a4e538b299966c4fb8ceed527360331245 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sat, 30 Nov 2019 11:36:16 +0800 Subject: [PATCH 10/15] Update actions.js --- libs/actions.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 599e4d12..179e6133 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -823,12 +823,13 @@ actions.prototype._selectChoices = function (length, keycode, callback) { if (keycode == 13 || keycode == 32 || keycode == 67) { callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]); } - //左右方向键音量 - if(core.status.event.id == "switchs" && core.status.event.selection == 2) + //左右方向键调整 音量 行走速度 + if(core.status.event.id == "switchs" && (core.status.event.selection == 2 || core.status.event.selection == 3)) { if (keycode == 37) callback.apply(this, [this.HSIZE - 2, topIndex + core.status.event.selection]); if (keycode == 39) callback.apply(this, [this.HSIZE + 2, topIndex + core.status.event.selection]); } + if (keycode >= 49 && keycode <= 57) { var index = keycode - 49; if (index < length) { @@ -1916,7 +1917,7 @@ 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)) return; + 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) { @@ -1928,11 +1929,13 @@ 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(); - return; + if (x == 4) { return this._clickSwitchs_userVolume_down(); } + else if (x == 8) { return this._clickSwitchs_userVolume_up(); } + return; case 3: - return this._clickSwitchs_moveSpeed(); + if (x == 4) { return this._clickSwitchs_moveSpeed_down(); } + else if (x == 8) { return this._clickSwitchs_moveSpeed_up(); } + return; case 4: return this._clickSwitchs_displayEnemyDamage(); case 5: @@ -1963,8 +1966,9 @@ actions.prototype._clickSwitchs_sound = function () { } actions.prototype._clickSwitchs_userVolume_down = function () { - //浮点运算精度 - core.musicStatus.userVolume = core.clamp(parseFloat(core.musicStatus.userVolume - 0.1).toFixed(1), 0, 1); + //浮点运算精度 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); //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; @@ -1972,21 +1976,25 @@ actions.prototype._clickSwitchs_userVolume_down = function () { core.ui.drawSwitchs(); } actions.prototype._clickSwitchs_userVolume_up = function () { - core.musicStatus.userVolume = core.clamp(parseFloat(core.musicStatus.userVolume + 0.1).toFixed(1), 0, 1); + 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); core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_moveSpeed = function () { - core.myprompt("请输入行走速度(每走一步的时间,单位毫秒,默认100)", core.values.moveSpeed, function (value) { - value = parseInt(value) || core.values.moveSpeed; - value = core.clamp(value, 10, 500); - core.values.moveSpeed = value; - core.setLocalStorage("moveSpeed", value); - 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 () { From 4b84c4347e39343acaa5bdd1537c762cc18ab55a Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sat, 30 Nov 2019 11:46:03 +0800 Subject: [PATCH 11/15] Update actions.js --- libs/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/actions.js b/libs/actions.js index 179e6133..e2278a7d 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -2138,7 +2138,7 @@ actions.prototype._clickSyncSave_readFile = function () { if (obj.version != core.firstData.version) return alert("游戏版本不一致!"); if (!obj.data) return alert("无效的存档!"); core.control._syncLoad_write(obj.data); - }); + }, null, ".h5save"); } actions.prototype._clickSyncSave_replay = function () { From 13710c04c8aba21f347ea2175f07db7d1e7d504b Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sun, 1 Dec 2019 08:22:41 +0800 Subject: [PATCH 12/15] 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; From 51aa80f9bfa8df9390aec719f7e68bf703003ca3 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sun, 1 Dec 2019 09:51:41 +0800 Subject: [PATCH 13/15] Update actions.js --- libs/actions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index bf8a6140..544dc945 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1933,8 +1933,8 @@ actions.prototype._clickSwitchs = function (x, y) { else if (x == this.HSIZE+2) { return this._clickSwitchs_userVolume(0.1); } return; case 3: - if (x == this.HSIZE-2) { return this._clickSwitchs_moveSpeed(10); } - else if (x == this.HSIZE+2) { return this._clickSwitchs_moveSpeed(-10); } + 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(); @@ -1977,7 +1977,7 @@ actions.prototype._clickSwitchs_userVolume = function (delta) { } actions.prototype._clickSwitchs_moveSpeed = function (delta) { - var value = core.clamp(parseInt(core.values.moveSpeed + delta), 60, 200); + var value = core.clamp(parseInt(core.values.moveSpeed + delta), 50, 200); core.values.moveSpeed = parseInt(value); core.setLocalStorage("moveSpeed", core.values.moveSpeed); core.ui.drawSwitchs(); From 75d4cd6bfd6e31a789dad9190aa717828799e191 Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sun, 1 Dec 2019 09:51:47 +0800 Subject: [PATCH 14/15] Update ui.js --- libs/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ui.js b/libs/ui.js index ad24f43c..34c588f8 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1499,7 +1499,7 @@ ui.prototype.drawSwitchs = function() { //显示为 0~10 十挡 " < "+"音量:"+parseInt(parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1)) * 10)+" > ", //显示为 1~15 十五挡 - " < "+"行走速度:" + parseInt((210 - core.values.moveSpeed) / 10) +" > ", + " < "+"步时:" + parseInt(core.values.moveSpeed) +" > ", "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"), "领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), From c4991cd20ac64b701ead0d2eaaf9950eeacc4aad Mon Sep 17 00:00:00 2001 From: InstantMeteor Date: Sun, 1 Dec 2019 09:54:24 +0800 Subject: [PATCH 15/15] Update ui.js --- libs/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ui.js b/libs/ui.js index 34c588f8..3a17f00d 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1498,7 +1498,7 @@ ui.prototype.drawSwitchs = function() { "背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), //显示为 0~10 十挡 " < "+"音量:"+parseInt(parseFloat(Math.sqrt(core.musicStatus.userVolume).toFixed(1)) * 10)+" > ", - //显示为 1~15 十五挡 + //数值越大耗时越长 " < "+"步时:" + parseInt(core.values.moveSpeed) +" > ", "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"),