From 279eafd07c29b78cad0a47fc2cfbb7c41234df5d Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 13 Aug 2021 00:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E6=95=88=E9=9F=B3=E8=B0=83=E9=A2=84?= =?UTF-8?q?=E8=A7=88=20&=20=E5=8A=A8=E7=94=BB=E9=9F=B3=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_ui.js | 40 ++++++++++++++++++++++++++++------------ libs/enemys.js | 3 +-- libs/loader.js | 2 +- libs/maps.js | 2 +- main.js | 1 + runtime.d.ts | 1 - 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/_server/editor_ui.js b/_server/editor_ui.js index 090af052..08960107 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -844,7 +844,8 @@ editor_ui_wrapper = function (editor) { } // 试听音频 if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) { - html += ""; + html += "" + html += " 音调:"; html += `0:00 / 0:00
`; @@ -884,7 +885,7 @@ editor_ui_wrapper = function (editor) { } uievent._previewMaterialAudio = function (button) { - var span = button.nextElementSibling; + var span = button.nextElementSibling.nextElementSibling; var br = span.nextElementSibling; var audio = br.nextElementSibling; var progress = audio.nextElementSibling; @@ -903,6 +904,12 @@ editor_ui_wrapper = function (editor) { } } + uievent._previewMaterialAudio_onPitchChange = function (input) { + var audio = input.parentElement.nextElementSibling.nextElementSibling.nextElementSibling; + audio.preservesPitch = false; + audio.playbackRate = core.clamp((parseInt(input.value) || 100) / 100, 0.3, 3.0); + } + uievent._previewMaterialAudio_onTimeUpdate = function (audio) { var _format = function (time) { return parseInt(time/60) + ":" + core.setTwoDigits(parseInt(time) % 60); } if (audio.duration > 0) { @@ -960,13 +967,14 @@ editor_ui_wrapper = function (editor) { var _previewMaterialAnimate_buildSounds = function (span, content) { var sounds = content.se || {}; if (typeof sounds == 'string') sounds = {1: sounds}; + var pitch = content.pitch || {}; span.appendChild(document.createElement('br')); var dom = document.createElement('span'); dom.setAttribute('frames', content.frame); var html = ""; Object.keys(sounds).forEach(function (frame) { - html += "" + _previewMaterialAnimate_buildSoundRow(frame, sounds[frame], content.frame) + ""; + html += "" + _previewMaterialAnimate_buildSoundRow(frame, sounds[frame], content.frame, pitch[frame]) + ""; }); html += ''; html += ''; @@ -976,7 +984,7 @@ editor_ui_wrapper = function (editor) { _previewMaterialAnimate_awesomplete(span); } - var _previewMaterialAnimate_buildSoundRow = function (index, se, frames) { + var _previewMaterialAnimate_buildSoundRow = function (index, se, frames, pitch) { var audios = Object.keys(core.material.sounds).sort().join(","); var html = ""; html += "第 帧:"; - html += ''; + html += ''; html += ''; + html += " 音调:"; html += ''; html += '
'; return html; } var _previewMaterialAnimate_awesomplete = function (span) { - var inputs = span.getElementsByTagName("input"); + var inputs = span.getElementsByClassName("_audio"); for (var i = 0; i < inputs.length; ++i) { var input = inputs[i]; if (!input.hasAttribute('awesomplete')) { @@ -1039,6 +1048,8 @@ editor_ui_wrapper = function (editor) { if (!uievent.values.audio) uievent.values.audio = new Audio(); uievent.values.audio.src = './project/sounds/' + input.value; + uievent.values.audio.preservesPitch = false; + uievent.values.audio.playbackRate = core.clamp((parseInt(button.nextElementSibling.children[0].value) || 100) / 100, 0.3, 3.0); uievent.values.audio.play(); } @@ -1060,17 +1071,22 @@ editor_ui_wrapper = function (editor) { var filename = span.parentElement.getAttribute("key"); if (!filename || !uievent.values.animates[filename]) return; var se = {}; + var pitch = {}; - var inputs = span.getElementsByTagName("input"); - for (var i = 0; i < inputs.length; ++i) { - var input = inputs[i]; - var select = input.parentElement.previousElementSibling; - if (input.value && select.tagName == 'SELECT') { - se[select.value] = input.value; + var audios = span.getElementsByClassName("_audio"); + for (var i = 0; i < audios.length; ++i) { + var audio = audios[i]; + var select = audio.parentElement.previousElementSibling; + if (audio.value && select.tagName == 'SELECT') { + se[select.value] = audio.value; + var p = audio.parentElement.nextElementSibling.nextElementSibling.children[0]; + pitch[select.value] = core.clamp(parseInt(p.value) || 100, 30, 300); } } uievent.values.animates[filename].se = se; uievent.values.animates[filename+':raw'].se = se; + uievent.values.animates[filename].pitch = pitch; + uievent.values.animates[filename+':raw'].pitch = pitch; fs.writeFile(filename, JSON.stringify(uievent.values.animates[filename+':raw']), 'utf-8', function (e, d) { if (e) alert('无法修改音效文件!'+e); else { diff --git a/libs/enemys.js b/libs/enemys.js index 06a97b4f..23fff03f 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -243,8 +243,7 @@ enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId) { } if (core.flags.useLoop) { - var LOOP_MAX_VALUE = 1; - if (core.status.hero.atk <= LOOP_MAX_VALUE) { + if (core.status.hero.atk <= (main.criticalUseLoop || 1)) { return this._nextCriticals_useLoop(enemy, info, number, x, y, floorId); } else { diff --git a/libs/loader.js b/libs/loader.js index 8243378d..1395d34f 100644 --- a/libs/loader.js +++ b/libs/loader.js @@ -334,8 +334,8 @@ loader.prototype._loadAnimate = function (content) { var data = {}; data.ratio = content.ratio; data.se = content.se; + data.pitch = content.pitch; data.images = []; - data.images_rev = []; content.bitmaps.forEach(function (t2) { if (!t2) { data.images.push(null); diff --git a/libs/maps.js b/libs/maps.js index 363341c8..73c62105 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -3001,7 +3001,7 @@ maps.prototype._drawAnimateFrame = function (name, animate, centerX, centerY, in var ctx = core.getContextByName(name); if (!ctx) return; var frame = animate.frames[index % animate.frame]; - core.playSound((animate.se||{})[index % animate.frame + 1]); + core.playSound((animate.se||{})[index % animate.frame + 1], (animate.pitch||{})[index % animate.frame + 1]); var ratio = animate.ratio; frame.forEach(function (t) { var image = animate.images[t.index]; diff --git a/main.js b/main.js index d0a8422b..8bbbe161 100644 --- a/main.js +++ b/main.js @@ -15,6 +15,7 @@ function main() { this.isCompetition = false; // 是否是比赛模式 this.savePages = 1000; // 存档页数,每页可存5个;默认为1000页5000个存档 + this.criticalUseLoop = 1; // 循环临界的分界 //------------------------ 用户修改内容 END ------------------------// diff --git a/runtime.d.ts b/runtime.d.ts index 372574eb..dcd84326 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -35,7 +35,6 @@ type Animate = { frame: number frames: frameObj[][] images: HTMLImageElement[] - images_rev: HTMLImageElement[] ratio: number se: string }