diff --git a/repo/js/AutoFishingTeyvat/main.js b/repo/js/AutoFishingTeyvat/main.js index 44c380856..2ae6c34de 100644 --- a/repo/js/AutoFishingTeyvat/main.js +++ b/repo/js/AutoFishingTeyvat/main.js @@ -671,8 +671,8 @@ if (is_time_kill) { let now = new Date(); - time_target.setHours(parseInt(kill_hour), 10); - time_target.setMinutes(parseInt(kill_minute), 10); + time_target.setHours(parseInt(kill_hour, 10)); + time_target.setMinutes(parseInt(kill_minute, 10)); time_target.setSeconds(0); time_target.setMilliseconds(0); if (time_target < now) { // 不是当天终止,天数+1 diff --git a/repo/js/AutoFishingTeyvat/manifest.json b/repo/js/AutoFishingTeyvat/manifest.json index 53d477b03..21799166b 100644 --- a/repo/js/AutoFishingTeyvat/manifest.json +++ b/repo/js/AutoFishingTeyvat/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "提瓦特自动钓鱼(全流程+自选)", - "version": "2.2.6", + "version": "2.2.7", "bgi_version": "0.47.0", "description": "支持自动追踪并垂钓bgi支持的全提瓦特垂钓点", "authors": [ diff --git a/repo/js/AutoYuanQin/README.md b/repo/js/AutoYuanQin/README.md index 1d030d479..e94cb9792 100644 --- a/repo/js/AutoYuanQin/README.md +++ b/repo/js/AutoYuanQin/README.md @@ -13,10 +13,10 @@ 3.发送邮件到hijiwos@hotmail.com并说明,你的谱子将会在一段时间内更新到仓库 ## MIDI翻谱器使用方法 -**MIDI翻谱器: AutoYuanQin\assets\tutorial_file\MIDI翻谱器.html(请确保 五线谱注解.png与制谱器位于同一目录下)** -**声明:本制谱器生成的曲谱文件为标准格式(区别于五线谱制谱器,生成的是MIDI版本的JSON标准格式)** +**MIDI翻谱器路径: AutoYuanQin\assets\tutorial_file\MIDI翻谱器.html** +**声明:本翻谱器生成的曲谱文件为标准格式(区别于五线谱制谱器,生成的是MIDI版本的JSON标准格式)** -使用浏览器打开```MIDI翻谱器.html```即可,注意**千万不要手动修改生成的JSON文件中的author** +使用浏览器打开```MIDI翻谱器.html```即可,注意**千万不要手动修改翻谱器生成的JSON文件中的author** ## 曲谱制作器使用方法 **制谱器路径: AutoYuanQin\assets\tutorial_file\五线谱制谱器.html(请确保 五线谱注解.png与制谱器位于同一目录下)** diff --git a/repo/js/AutoYuanQin/assets/score_file/1.小星星.json b/repo/js/AutoYuanQin/assets/score_file/0001.小星星.json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/1.小星星.json rename to repo/js/AutoYuanQin/assets/score_file/0001.小星星.json diff --git a/repo/js/AutoYuanQin/assets/score_file/2.小星星变奏曲.json b/repo/js/AutoYuanQin/assets/score_file/0002.小星星变奏曲.json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/2.小星星变奏曲.json rename to repo/js/AutoYuanQin/assets/score_file/0002.小星星变奏曲.json diff --git a/repo/js/AutoYuanQin/assets/score_file/3.Unknown Mother Goose [アンノウン・マザーグース].json b/repo/js/AutoYuanQin/assets/score_file/0003.Unknown Mother Goose [アンノウン・マザーグース].json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/3.Unknown Mother Goose [アンノウン・マザーグース].json rename to repo/js/AutoYuanQin/assets/score_file/0003.Unknown Mother Goose [アンノウン・マザーグース].json diff --git a/repo/js/AutoYuanQin/assets/score_file/4.铃芽之旅[Suzume].json b/repo/js/AutoYuanQin/assets/score_file/0004.铃芽之旅[Suzume].json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/4.铃芽之旅[Suzume].json rename to repo/js/AutoYuanQin/assets/score_file/0004.铃芽之旅[Suzume].json diff --git a/repo/js/AutoYuanQin/assets/score_file/5.Flower Dance.json b/repo/js/AutoYuanQin/assets/score_file/0005.Flower Dance.json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/5.Flower Dance.json rename to repo/js/AutoYuanQin/assets/score_file/0005.Flower Dance.json diff --git a/repo/js/AutoYuanQin/assets/score_file/6.起风了.json b/repo/js/AutoYuanQin/assets/score_file/0006.起风了.json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/6.起风了.json rename to repo/js/AutoYuanQin/assets/score_file/0006.起风了.json diff --git a/repo/js/AutoYuanQin/assets/score_file/7.千本樱 (Eric Chen).json b/repo/js/AutoYuanQin/assets/score_file/0007.千本樱 (Eric Chen).json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/7.千本樱 (Eric Chen).json rename to repo/js/AutoYuanQin/assets/score_file/0007.千本樱 (Eric Chen).json diff --git a/repo/js/AutoYuanQin/assets/score_file/8.春よ、来い(春天,来吧).json b/repo/js/AutoYuanQin/assets/score_file/0008.春よ、来い(春天,来吧).json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/8.春よ、来い(春天,来吧).json rename to repo/js/AutoYuanQin/assets/score_file/0008.春よ、来い(春天,来吧).json diff --git a/repo/js/AutoYuanQin/assets/score_file/9.One Last Kiss.json b/repo/js/AutoYuanQin/assets/score_file/0009.One Last Kiss.json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/9.One Last Kiss.json rename to repo/js/AutoYuanQin/assets/score_file/0009.One Last Kiss.json diff --git a/repo/js/AutoYuanQin/assets/score_file/10.卡农(MIDI转谱).json b/repo/js/AutoYuanQin/assets/score_file/0010.卡农(MIDI转谱).json similarity index 100% rename from repo/js/AutoYuanQin/assets/score_file/10.卡农(MIDI转谱).json rename to repo/js/AutoYuanQin/assets/score_file/0010.卡农(MIDI转谱).json diff --git a/repo/js/AutoYuanQin/main.js b/repo/js/AutoYuanQin/main.js index 6c23bc852..8923f90a8 100644 --- a/repo/js/AutoYuanQin/main.js +++ b/repo/js/AutoYuanQin/main.js @@ -1,19 +1,20 @@ (async function () { // 待解决问题: 连音总时值如果为3个四分音符无法表示 - // 乐曲名(带序号) - const music_list = [ - "1.小星星", - "2.小星星变奏曲", - "3.Unknown Mother Goose [アンノウン・マザーグース]", - "4.铃芽之旅[Suzume]", - "5.Flower Dance", - "6.起风了", - "7.千本樱 (Eric Chen)", - "8.春よ、来い(春天,来吧)", - "9.One Last Kiss", - "10.卡农(MIDI转谱)" - ] + // // 乐曲名(带序号) + // const music_list = [ + // "0001.小星星", + // "0002.小星星变奏曲", + // "0003.Unknown Mother Goose [アンノウン・マザーグース]", + // "0004.铃芽之旅[Suzume]", + // "0005.Flower Dance", + // "0006.起风了", + // "0007.千本樱 (Eric Chen)", + // "0008.春よ、来い(春天,来吧)", + // "0009.One Last Kiss", + // "0010.卡农(MIDI转谱)" + // ] const base_path = "assets/score_file/" + const regex_name = /(?<=score_file\\)[\s\S]*?(?=.json)/ /** * @@ -108,8 +109,10 @@ * - music {string}|{Array.string} 乐曲名(type为"single"时为 {string}, type为"queue"时为 {Array.}) * */ - function get_settings() { + function get_settings(music_list) { try{ + // 读取开始时间 + let music_start = typeof(settings.music_start) === 'undefined' ? "" : settings.music_start; // 读取选择的单曲 let music_single = typeof(settings.music_selector) === 'undefined' ? 0 : settings.music_selector; // 读取循环次数 @@ -137,6 +140,7 @@ if (music_single !== 0) { return { "type": "single", + "start": music_start, "repeat": music_repeat, "repeat_interval": repeat_interval, "music": local_music_dic[music_single.split(".")[0]] @@ -158,9 +162,9 @@ } } - return { "type": "queue", + "start": music_start, "repeat": music_repeat, "repeat_interval": repeat_interval, "repeat_mode": repeat_mode, @@ -198,39 +202,14 @@ log.info(`文件读取成功: ${music_path}`); } - let music_msg_dic = {}; - - // 正则表达式,用于匹配如下内容 - let regex_name = /(?<="name": ")[\s\S]*?(?=")/ - let regex_author = /(?<="author": ")[\s\S]*?(?=")/ - let regex_description = /(?<="description": ")[\s\S]*?(?=")/ - let regex_bpm = /(?<="bpm": ")[\s\S]*?(?=")/ - let regex_time_signature = /(?<="time_signature": ")[\s\S]*?(?=")/ - let regex_composer = /(?<="composer": ")[\s\S]*?(?=")/ - let regex_arranger = /(?<="arranger": ")[\s\S]*?(?=")/ - let regex_notes = /(?<="notes": ")[\s\S]*?(?=")/ - - let regex_blank = /[\\n]/g + let music_msg_dic = JSON.parse(file_text); + let regex_blank = /[\n]/g try { - // 歌曲名 - music_msg_dic["name"] = file_text.match(regex_name)[0]; - // 录谱人 - music_msg_dic["author"] = file_text.match(regex_author)[0]; - // 描述 - music_msg_dic["description"] = file_text.match(regex_description)[0]; - // 歌曲BPM - music_msg_dic["bpm"] = file_text.match(regex_bpm)[0]; - // 拍号 - music_msg_dic["time_signature"] = file_text.match(regex_time_signature)[0]; - // 曲师 - music_msg_dic["composer"] = file_text.match(regex_composer)[0]; - // 谱师 - music_msg_dic["arranger"] = file_text.match(regex_arranger)[0]; // 曲谱内容(删除换行符) if (music_msg_dic["author"] !== "MidiTrans") { - music_msg_dic["notes"] = file_text.match(regex_notes)[0].replace(regex_blank, ''); + music_msg_dic["notes"] = music_msg_dic["notes"].replace(regex_blank, ''); } else { - music_msg_dic["notes"] = JSON.parse(file_text)["notes"]; + music_msg_dic["notes"] = JSON.parse(music_msg_dic["notes"])["notes"]; } } catch(error) { log.info(`曲谱解析错误:${error}\n请检查曲谱文件格式是否正确`); @@ -445,10 +424,76 @@ } async function main() { - const settings_msg = get_settings(); - if (settings_msg == null) { - return null + // 首先检测本地曲谱文件与主程序中是否一致(本地已有的曲谱为最高优先级) + // 1.读取本地所有JSON曲谱文件 + let music_list = []; + const all_scores = Array.from(file.readPathSync("assets/score_file")).filter(p => !file.isFolder(p) && p.endsWith(".json")); + for (let i = 0; i < all_scores.length; i++) { + music_list.push(all_scores[i].match(regex_name)[0]); } + // 2.读取JS脚本配置中的曲谱列表 + let setting_list = []; + let ori_set_list = JSON.parse(file.readTextSync("settings.json"))[1]["options"]; + for (let i = 0; i < ori_set_list.length; i++) { + setting_list.push(ori_set_list[i]); + } + // 3.核对 + if (!(setting_list.sort().join() == music_list.sort().join())) { // 曲谱配置不相同 + // 以本地曲谱为准 + let temp_json = JSON.parse(file.readTextSync("settings.json")); + temp_json[0]["options"] = music_list; + file.writeTextSync("settings.json", JSON.stringify(temp_json, null, 2)); // 覆写settings + log.warn("检测到曲谱文件不一致,已自动修改settings(以本地曲谱文件为基准)..."); + log.warn("JS脚本配置已更新,请重新运行脚本!"); + return null; + } + const settings_msg = get_settings(music_list); + // 检测开始时间 + // if (settings_msg["start"] !== "") { + // let target_time = new Date(); + // for (let i = 0; i < settings_msg["start"].length; i++) { + // if (i == 0) { + // time_target.setHours(parseInt(settings_msg["start"][i], 10)); + // time_target.setMinutes(0); + // time_target.setSeconds(0); + // time_target.setMilliseconds(0); + // } else if (i == 1) { + // time_target.setMinutes(parseInt(settings_msg["start"][i], 10)); + // time_target.setSeconds(0); + // time_target.setMilliseconds(0); + // } else if (i == 2) { + // time_target.setSeconds(parseInt(settings_msg["start"][i], 10)); + // time_target.setMilliseconds(0); + // } else if (i == 3) { + // time_target.setMilliseconds(parseInt(settings_msg["start"][i], 10)); + // } + // } + // } + let time_target = new Date(); + if (settings_msg.start !== "") { + const setters = ["setHours", "setMinutes", "setSeconds", "setMilliseconds"]; + let start_time_list = settings_msg.start.split(":"); + start_time_list.forEach((val, i) => { + time_target[setters[i]](parseInt(val, 10)); + // 清零更小的单位 + for (let j = i + 1; j < setters.length; j++) { + time_target[setters[j]](0); + } + }); + + // 如果剩余时间大于 1 秒,先等待到目标时间前 1 秒 + let diff = time_target - new Date(); + if (diff > 1000) await sleep(diff - 1000); + // 最后 1 秒内用短间隔检查 + while (new Date() < time_target) { + continue; + } + } + + // if (settings_msg == null) { + // return null + // } + // try { if (settings_msg["type"] === "single") { // 单曲 // 读取乐谱 diff --git a/repo/js/AutoYuanQin/manifest.json b/repo/js/AutoYuanQin/manifest.json index 0f0af883f..f9856eabf 100644 --- a/repo/js/AutoYuanQin/manifest.json +++ b/repo/js/AutoYuanQin/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "原琴·五线谱版", - "version": "3.0", + "version": "3.0.1", "bgi_version": "0.43.1", "description": "功能描述:功能及其强大的原琴脚本\n核心功能------------------------------>\n1.轻松实现根据五线谱翻版琴谱,支持单音、和弦\n2.曲谱支持录入BPM、拍号\n3.特殊音符支持休止符、浮点音符、(三/六)连音、(三/六)连音标记线、装饰音·倚音\n4.含有制谱器,方便制作曲谱\n注意事项------------------------------>\n1.使用前请装备原琴\n2.音域只有3个八度,受原琴音域限制,本脚本的上限取决于翻谱的大佬(卑微\n3.实际上装饰音·倚音的时长视为基础时值单位(比如拍号2/4的基础时值单位就是4分音符)的1/16\n4.制铺说明:曲谱JSON文件的notes必须保证为一行且不能包括空白符(换行符除外);小节之间用|隔开,|不是必要的,作用是方便曲谱维护\n---------------------------------------->\n作者:提瓦特钓鱼玳师\n脚本反馈邮箱:hijiwos@hotmail.com", "authors": [ diff --git a/repo/js/AutoYuanQin/settings.json b/repo/js/AutoYuanQin/settings.json index e364e3b8a..9f09b9efe 100644 --- a/repo/js/AutoYuanQin/settings.json +++ b/repo/js/AutoYuanQin/settings.json @@ -1,48 +1,53 @@ -[ - { - "name": "music_selector", - "type": "select", - "label": "选择乐曲(队列执行启用后该选项失效)", - "options": [ - "1.小星星-[0:36]", - "2.小星星变奏曲-[7:57]", - "3.Unknown Mother Goose [アンノウン・マザーグース]-[4:08]", - "4.铃芽之旅[Suzume]-[3:52]", - "5.Flower Dance-[5:20]", - "6.起风了-[3:22]", - "7.千本樱 (Eric Chen)-[4:03]", - "8.春よ、来い(春天,来吧)-[4:02]", - "9.One Last Kiss-[4:12]", - "10.卡农(MIDI转谱).json" - ] - }, - { - "name": "music_repeat", - "type": "input-text", - "label": "循环执行次数(不填默认不循环)" - }, - { - "name": "repeat_interval", - "type": "input-text", - "label": "循环间隔时间(单位:s, 循环执行启用时生效,不填默认0s)" - }, - { - "name": "repeat_mode", - "type": "select", - "label": "循环模式(不填默认为单曲循环)", - "options": [ - "单曲循环", - "队列循环" - ] - }, - { - "name": "music_queue", - "type": "input-text", - "label": "队列执行(填写数字[乐曲前的序号],空格隔开,不填默认不启用)" - }, - { - "name": "music_interval", - "type": "input-text", - "label": "队列内间隔时间(单位:s, 队列执行启用时生效)" - } -] +[ + { + "name": "music_start", + "type": "input-text", + "label": "开始时间(留空则不启用,示例 00:00:00 )" + }, + { + "name": "music_selector", + "type": "select", + "label": "选择乐曲(队列执行启用后该选项失效)", + "options": [ + "0001.小星星", + "0002.小星星变奏曲", + "0003.Unknown Mother Goose [アンノウン・マザーグース]", + "0004.铃芽之旅[Suzume]", + "0005.Flower Dance", + "0006.起风了", + "0007.千本樱 (Eric Chen)", + "0008.春よ、来い(春天,来吧)", + "0009.One Last Kiss", + "0010.卡农(MIDI转谱)" + ] + }, + { + "name": "music_repeat", + "type": "input-text", + "label": "循环执行次数(不填默认不循环)" + }, + { + "name": "repeat_interval", + "type": "input-text", + "label": "循环间隔时间(单位:s, 循环执行启用时生效,不填默认0s)" + }, + { + "name": "repeat_mode", + "type": "select", + "label": "循环模式(不填默认为单曲循环)", + "options": [ + "单曲循环", + "队列循环" + ] + }, + { + "name": "music_queue", + "type": "input-text", + "label": "队列执行(填写数字[乐曲前的序号],空格隔开,不填默认不启用)" + }, + { + "name": "music_interval", + "type": "input-text", + "label": "队列内间隔时间(单位:s, 队列执行启用时生效)" + } +] \ No newline at end of file