Skip to content

Commit ee925cc

Browse files
author
StageGuard
committed
new feature & version 23
1 parent fe4263f commit ee925cc

File tree

5 files changed

+138
-56
lines changed

5 files changed

+138
-56
lines changed

resources/language_pack/en_US.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "English (US)",
33
"code": "en_US",
4-
"version": 4,
4+
"version": 5,
55
"content": {
66
"launch_tip_in_content": "If you can't see a diamond popup dialog,<br>make sure that Auto.js is allowed to <u><b>display pop-up window</u></b><br><br><br>Version <b>4.1.1 Alpha2</b> is recommended.<br><b>4.1.1 Alpha2</b> Download: <a href=https://github.com/Ericwyn/Auto.js/releases/tag/V4.1.1.Alpha2>https://github.com/Ericwyn/Auto.js/releases/tag/V4.1.1.Alpha2</a>",
77
"launch_tip_force_exit": "FORCE EXIT",
@@ -106,6 +106,12 @@
106106
"res_language_download_failed": "Failed to download language pack: {0}",
107107
"res_language_dialog_tip": "Your language is not on the list?<br>Welcome to translate the script:<br><a href=>https://github.com/StageGuard/SkyAutoPlayerScript/blob/master/contribute-translation.md</a>",
108108
"res_language_failed_fetch_online_list": "Failed to fetch online language list",
109-
"res_language_update_needed": "Language pack need to be updated, please go to setting->language and click current language again to upgrade."
109+
"res_language_update_needed": "Language pack need to be updated, please go to setting->language and click current language again to upgrade.",
110+
111+
"page_setting_no_popup_play": "Close panel in playing",
112+
"page_setting_no_popup_play_interval": "Interval to play when close panel",
113+
"no_popup_play_warning_title": "WARNING",
114+
"no_popup_play_warning": "You have enabled \"Close panel in playing\" opinion!\nPlay without control panel is <b>extremely dangerous</b>.\n\nWhen popup notification or bubble chat appears, script may touch these popup window by mistake. At this time, script is still running(or playing) and is <b>uninterrupted</b>. You have no way to stop playing but wait.\n<b>Script touch in other pages may causes irreparable harm.</b>\n\nBesides, record play process is uesless and doesn't give you sense of satisfaction.\n\nI have already warned you that if there is any loss or dispute caused by using this function, it has nothing to do with the SkyAutoplayer script and the script author StageGuard.\nIf continue, please click the confirm button, or otherwise click the Cancel button.\n\nps. \"Random and continuate play\" will not work.",
115+
"no_popup_play_tip": "Script will start playing in {0} seconds."
110116
}
111117
}

resources/language_pack/zh_CN.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "简体中文",
33
"code": "zh_CN",
4-
"version": 4,
4+
"version": 5,
55
"content": {
66
"launch_tip_in_content": "当你发现什么事情都没有发生时<br>也许你应该看看是否授予了Auto.js<u><b>悬浮窗权限</u></b><br><br><br>建议使用 <b>4.1.1 Alpha2</b> 版本!<br><b>4.1.1 Alpha2</b> 版本下载: <a href=https://github.com/Ericwyn/Auto.js/releases/tag/V4.1.1.Alpha2>https://github.com/Ericwyn/Auto.js/releases/tag/V4.1.1.Alpha2</a>",
77
"launch_tip_force_exit": "强制退出",
@@ -106,6 +106,12 @@
106106
"res_language_download_failed": "语言下载失败:{0}",
107107
"res_language_dialog_tip": "找不到你的语言?欢迎贡献翻译:<br><a href=>https://github.com/StageGuard/SkyAutoPlayerScript/blob/master/contribute-translation.md</a>",
108108
"res_language_failed_fetch_online_list": "无法获取在线语言列表",
109-
"res_language_update_needed": "语言需要更新,请前往设置界面重新点击当前语言来更新"
109+
"res_language_update_needed": "语言需要更新,请前往设置界面重新点击当前语言来更新",
110+
111+
"page_setting_no_popup_play": "弹奏不显示悬浮窗",
112+
"page_setting_no_popup_play_interval": "无悬浮窗弹奏开始间隔",
113+
"no_popup_play_warning_title": "警告",
114+
"no_popup_play_warning": "您已经开启\"弹奏不显示悬浮窗\"选项!\n弹奏不受弹奏面板控制是<b>非常危险的</b>。\n\n当出现顶部悬浮通知(例如QQ消息)或气泡对话时,脚本可能会误触消息并开启其他软件,此时脚本依旧在运行中(弹奏中)且<b>无法被打断</b>。也就是说除了等待弹奏完成以外,没有任何办法终止弹奏。\n<b>脚本在其他界面的误触可能会对您造成不可挽回的损失!</b>\n\n另外,使用此功能且录屏不会使你获得任何成就感。\n\n我已经警告过你了,若因使用此功能造成了损失或纠纷,与 SkyAutoPlayer 脚本和脚本作者 StageGuard 无关,请悉知。\n若继续使用,请点击确认按钮,否则请点击取消按钮。\n\n注意:使用此功能时,\"连续随机播放\"功能将不会生效。",
115+
"no_popup_play_tip": "将在 {0} 秒后开始弹奏。"
110116
}
111117
}

source/SkyAutoplayer.js

+115-50
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ sheetmgr = {
105105

106106
downloadAndLoad: function(file, extraData, listener) {
107107
listener({status:1});
108-
config.fetchRepoFile("shared_sheets/" + file, config.values.gitVersion, function(body) {
108+
config.fetchRepoFile("shared_sheets/" + file, function(body) {
109109
var sheet = files.join(sheetmgr.rootDir, files.getNameWithoutExtension(file) + (function(length) {
110110
var string = "0123456789abcde";
111111
var stringBuffer = new java.lang.StringBuffer();
@@ -162,7 +162,7 @@ sheetmgr = {
162162
}
163163
},
164164
__internal_fetchOnlineSharedSheets: function() {
165-
config.fetchRepoFile("shared_sheets.json", config.values.gitVersion, function(body) {
165+
config.fetchRepoFile("shared_sheets.json", function(body) {
166166
sheetmgr.cachedOnlineSharedSheetInfoList = body.json().sheets;
167167
});
168168
},
@@ -301,25 +301,30 @@ sheetplayer = {
301301
// 播放完自动下一首
302302

303303
if(!(sheetplayer.currentNote < sheetplayer.noteCount)) {
304-
if(config.values.autoPlay && gui.player_panel.isShowing) {
305-
gui.player_panel.__internal_dismiss();
306-
sheetplayer.stop();
307-
// gui.main.show(0);
308-
if(sheetmgr.cachedLocalSheetList.length>0){
309-
setTimeout(function(){
310-
let sheet = sheetmgr.cachedLocalSheetList[random(0, sheetmgr.cachedLocalSheetList.length-1)]
311-
if(!sheet.keyCount){
312-
sheet.keyCount = 15 //默认键位
313-
}
314-
gui.player_panel.__internal_showPanel(sheet);
315-
// sheetplayer.stop();
304+
if(!config.values.noPopupPlay) {
305+
if(config.values.autoPlay && gui.player_panel.isShowing) {
306+
gui.player_panel.__internal_dismiss();
307+
sheetplayer.stop();
308+
// gui.main.show(0);
309+
if(sheetmgr.cachedLocalSheetList.length>0){
316310
setTimeout(function(){
317-
sheetplayer.play(gui.player_panel.refreshStatus);
318-
}, 1500)
319-
}, 500)
311+
let sheet = sheetmgr.cachedLocalSheetList[random(0, sheetmgr.cachedLocalSheetList.length-1)]
312+
if(!sheet.keyCount){
313+
sheet.keyCount = 15 //默认键位
314+
}
315+
gui.player_panel.__internal_showPanel(sheet);
316+
// sheetplayer.stop();
317+
setTimeout(function(){
318+
sheetplayer.play(gui.player_panel.refreshStatus);
319+
}, 1500)
320+
}, 500)
321+
}
322+
} else {
323+
sheetplayer.stop();
320324
}
321325
} else {
322326
sheetplayer.stop();
327+
gui.main.show(0);
323328
}
324329
}
325330
});
@@ -384,7 +389,7 @@ config = {
384389
_global_storage: null,
385390

386391
values: {
387-
currentVersion: 22,
392+
currentVersion: 23,
388393
gitVersion: "",
389394

390395
key_coordinates15: [],
@@ -402,6 +407,9 @@ config = {
402407
autoPlay: false,
403408
lang: "zh_CN",
404409
chordDelay: 0,
410+
noPopupPlay: false,
411+
noPopupPlayWarning: true,
412+
intervalSecondsPlayInNoPopupMode: 5,
405413
},
406414

407415
bitmaps: {},
@@ -493,6 +501,8 @@ config = {
493501
page_setting_set_15key_coordinate: "设置15键盘键位坐标",
494502
page_setting_key_coordinate_saved: "坐标设置已保存至存储!",
495503
page_setting_random_and_continuate_play: "连续随机播放",
504+
page_setting_no_popup_play: "弹奏不显示悬浮窗",
505+
page_setting_no_popup_play_interval: "无悬浮窗弹奏开始间隔",
496506
page_setting_show_broken_sheet: "显示加载失败的乐谱",
497507
page_setting_show_storage_tip_on_android11: "启动脚本时显示存储提示",
498508
page_setting_set_theme: "设置主题色",
@@ -534,7 +544,18 @@ config = {
534544
res_language_dialog_tip: "找不到你的语言?欢迎贡献翻译:<br><a href=>https://github.com/StageGuard/SkyAutoPlayerScript</a>",
535545
res_language_failed_fetch_online_list: "无法获取在线语言列表",
536546
res_language_dialog_title: "选择语言",
537-
res_language_update_needed: "语言需要更新,请前往设置界面重新点击当前语言来更新"
547+
res_language_update_needed: "语言需要更新,请前往设置界面重新点击当前语言来更新",
548+
549+
no_popup_play_warning_title: "警告",
550+
no_popup_play_warning: "您已经开启\"弹奏不显示悬浮窗\"选项!\n" +
551+
"弹奏不受弹奏面板控制是<b>非常危险的</b>。\n\n" +
552+
"当出现顶部悬浮通知(例如QQ消息)或气泡对话时,脚本可能会误触消息并开启其他软件,此时脚本依旧在运行中(弹奏中)且<b>无法被打断</b>。也就是说除了等待弹奏完成以外,没有任何办法终止弹奏。\n" +
553+
"<b>脚本在其他界面的误触可能会对您造成不可挽回的损失!</b>\n\n" +
554+
"另外,使用此功能且录屏不会使你获得任何成就感。\n\n" +
555+
"我已经警告过你了,若因使用此功能造成了损失或纠纷,与 SkyAutoPlayer 脚本和脚本作者 StageGuard 无关,请悉知。\n" +
556+
"若继续使用,请点击确认按钮,否则请点击取消按钮。\n\n" +
557+
"注意:使用此功能时,\"连续随机播放\"功能将不会生效。",
558+
no_popup_play_tip: "将在 {0} 秒后开始弹奏。"
538559
},
539560
},
540561

@@ -550,7 +571,7 @@ config = {
550571
this.languages[content.code] = content.content;
551572
listener(String.format(this.languages[content.code].res_use_language, content.name));
552573
threads.start(function() {
553-
config.fetchRepoFile("source/language_list.json", config.values.gitVersion, function(body) {
574+
config.fetchRepoFile("source/language_list.json", function(body) {
554575
var onlineList = JSON.parse(body.string()).list;
555576
for(var i in onlineList) {
556577
if(onlineList[i].code == content.code) {
@@ -609,6 +630,9 @@ config = {
609630
this.values.autoPlay = this._global_storage.get("auto_play", this.values.autoPlay);
610631
this.values.lang = this._global_storage.get("language", this.values.lang)
611632
this.values.chordDelay = this._global_storage.get("chordDelay", this.values.chordDelay)
633+
this.values.noPopupPlay = this._global_storage.get("no_popup_play", this.values.noPopupPlay)
634+
this.values.noPopupPlayWarning = this._global_storage.get("no_popup_play_warning", this.values.noPopupPlayWarning)
635+
this.values.intervalSecondsPlayInNoPopupMode = this._global_storage.get("interval_seconds_play", this.values.intervalSecondsPlayInNoPopupMode)
612636
try {
613637
android.os.Build.VERSION_CODES.R
614638
sheetmgr.rootDir = android.os.Environment.getExternalStorageDirectory() + "/Documents/SkyAutoPlayer/sheets/";
@@ -630,7 +654,7 @@ config = {
630654
var periodVersion = this._global_storage.get("version", this.values.currentVersion);
631655
var currentVersion = this.values.currentVersion;
632656
if(periodVersion < currentVersion) {
633-
config.fetchRepoFile("update_log.txt", this.values.gitVersion, function(body) {
657+
config.fetchRepoFile("update_log.txt", function(body) {
634658
gui.dialogs.showConfirmDialog({
635659
title: config.languages[config.values.lang].res_updated,
636660
text: String.format(config.languages[config.values.lang].res_updated_detail, currentVersion, periodVersion, body.string()),
@@ -658,7 +682,7 @@ config = {
658682
try {
659683
listener(String.format(config.languages[config.values.lang].res_loading_detail, element));
660684
config.bitmaps[files.getNameWithoutExtension(absolutePath)] = android.graphics.Bitmap.createBitmap(android.graphics.BitmapFactory.decodeFile(absolutePath));
661-
} catch(e) {
685+
} catch (e) {
662686
listener(String.format(config.languages[config.values.lang].res_loading_error, element));
663687
downloadQueue.push(element);
664688
}
@@ -680,7 +704,7 @@ config = {
680704
var iterator = 0;
681705
tmpQueue.map(function(element, i) {
682706
listener(String.format(config.languages[config.values.lang].res_downloading, element));
683-
config.fetchRepoFile("resources/" + element, config.values.gitVersion, function(body) {
707+
config.fetchRepoFile("resources/" + element, function(body) {
684708
var absolutePath = files.join(localRootDir, element);
685709
files.create(absolutePath);
686710
files.writeBytes(absolutePath, body.bytes());
@@ -702,35 +726,30 @@ config = {
702726
listener(config.languages[config.values.lang].res_download_successful);
703727
java.lang.Thread.sleep(1000); //为了方便看清
704728
}
705-
} catch(error) {
706-
listener(new Error(String.format(config.languages[config.values.lang].res_error_while_downloading, error)));
729+
} catch (e) {
730+
listener(new Error(String.format(config.languages[config.values.lang].res_error_while_downloading, e)));
707731
}
708732

709733
},
710734

711-
//jsdelivr cdn需要指定repo版本, gitee和github则不用
712-
//fetch顺序为 gitee raw content → jsdelivr cdn → github raw content
713-
fetchRepoFile: function(path, gitVersion, successCbk, failCbk) {
714-
//就用最蠢的if来判断吧
715-
try {
716-
var resp = http.get(encodeURI("https://cdn.jsdelivr.net/gh/StageGuard/SkyAutoPlayerScript" + (gitVersion == null ? "" : ("@" + gitVersion)) + "/" + path));
717-
if(resp.statusCode >= 200 && resp.statusCode < 300) {
718-
successCbk(resp.body);
719-
return;
720-
} else {
721-
var errorCollector = resp.statusCode + ": " + resp.statusMessage + "\n";
722-
resp = http.get(encodeURI("https://raw.githubusercontent.com/StageGuard/SkyAutoPlayerScript/master/" + path));
735+
fetchRepoFile: function(path, successCbk, failCbk) {
736+
var repos = [
737+
"https://cdn.jsdelivr.net/gh/StageGuard/SkyAutoPlayerScript@" + config.values.gitVersion + "/" + path,
738+
"https://dl.skyautoplayerscript.stageguard.top/" + path,
739+
"https://gitee.com/stageguard/SkyAutoPlayerScript/raw/master/" + path,
740+
"https://raw.githubusercontent.com/StageGuard/SkyAutoPlayerScript/master/" + path
741+
];
742+
var errorCollector = new String();
743+
for(var i in repos) {
744+
try {
745+
var resp = http.get(encodeURI(repos[i]));
723746
if(resp.statusCode >= 200 && resp.statusCode < 300) {
724747
successCbk(resp.body);
725748
return;
726-
} else {
727-
errorCollector += resp.statusCode + ": " + resp.statusMessage + "\n";
728-
if(failCbk != null) failCbk(errorCollector);
729-
}
730-
}
731-
} catch(e) {
732-
if(failCbk != null) failCbk(e);
749+
} else errorCollector += "Failed on " + repo[i] + ": " + resp.statusCode + ": " + resp.statusMessage + "\n";
750+
} catch (e) { errorCollector += "Failed on " + repo[i] + ": " + e + "\n"; }
733751
}
752+
if(failCbk != null) failCbk(errorCollector);
734753
},
735754

736755
updateBitmapTheme: function() {
@@ -2087,7 +2106,31 @@ gui = {
20872106
s.play.setBackgroundDrawable(gui.utils.ripple_drawable(s.play.getMeasuredWidth(), s.play.getMeasuredHeight(), "rect"));
20882107
s.play.setOnClickListener(new android.view.View.OnClickListener({
20892108
onClick: function() {
2090-
sheetplayer.play(gui.player_panel.refreshStatus);
2109+
if(config.values.noPopupPlay) {
2110+
if(!config.values.noPopupPlayWarning) {
2111+
gui.player_panel.noPopupPlayClick()
2112+
} else {
2113+
gui.dialogs.showConfirmDialog({
2114+
title: config.languages[config.values.lang].no_popup_play_warning_title,
2115+
text: android.text.Html.fromHtml(config.languages[config.values.lang].no_popup_play_warning.replace(new RegExp("\x0a", "gi"), "<br>")),
2116+
canExit: false,
2117+
buttons: [
2118+
config.languages[config.values.lang].button_confirm,
2119+
config.languages[config.values.lang].button_cancel
2120+
],
2121+
skip: function(checked) {
2122+
config.values.noPopupPlayWarning = config.save("no_popup_play_warning", !checked);
2123+
},
2124+
callback: function(id) {
2125+
if(id == 0) {
2126+
gui.player_panel.noPopupPlayClick()
2127+
}
2128+
}
2129+
});
2130+
}
2131+
} else {
2132+
sheetplayer.play(gui.player_panel.refreshStatus);
2133+
}
20912134
}
20922135
}));
20932136
s.play.setEnabled(false);
@@ -2221,6 +2264,13 @@ gui = {
22212264
});
22222265

22232266
});},
2267+
noPopupPlayClick: function() {
2268+
gui.player_panel.__internal_dismiss();
2269+
toast(String.format(config.languages[config.values.lang].no_popup_play_tip, config.values.intervalSecondsPlayInNoPopupMode));
2270+
(new android.os.Handler()).postDelayed(function() {
2271+
sheetplayer.play();
2272+
}, config.values.intervalSecondsPlayInNoPopupMode * 1000);
2273+
},
22242274
__internal_dismiss: function() { gui.run(function(){
22252275
if (gui.player_panel.isShowing) {
22262276
gui.player_panel.isShowing = false;
@@ -2337,7 +2387,7 @@ gui = {
23372387
var item = listAdapterController.get(pos);
23382388
if(item.type == "item") {
23392389
var fetchOnline = function() {
2340-
config.fetchRepoFile("resources/language_pack/" + item.code + ".json", config.values.gitVersion, function(body) {
2390+
config.fetchRepoFile("resources/language_pack/" + item.code + ".json", function(body) {
23412391
var lf = android.os.Environment.getExternalStorageDirectory() + "/Documents/SkyAutoPlayer/lang/" + item.code + ".json";
23422392
files.create(lf)
23432393
files.writeBytes(lf, body.bytes());
@@ -2399,7 +2449,7 @@ gui = {
23992449

24002450
var onlineList = [];
24012451
threads.start(function() {
2402-
config.fetchRepoFile("source/language_list.json", config.values.gitVersion, function(body) {
2452+
config.fetchRepoFile("source/language_list.json", function(body) {
24032453
onlineList = JSON.parse(body.string()).list;
24042454
gui.run(function() {
24052455
var __listArray = listAdapterController.getArray();
@@ -3505,6 +3555,21 @@ gui.dialogs.showProgressDialog(function(o) {
35053555
onClick: function(checked) {
35063556
config.values.autoPlay = config.save("auto_play", checked);
35073557
}
3558+
}, {
3559+
type: "checkbox",
3560+
name: config.languages[config.values.lang].page_setting_no_popup_play,
3561+
check: config.values.noPopupPlay,
3562+
onClick: function(checked) {
3563+
config.values.noPopupPlay = config.save("no_popup_play", checked);
3564+
}
3565+
}, {
3566+
type: "seekbar",
3567+
name: config.languages[config.values.lang].page_setting_no_popup_play_interval,
3568+
value: config.values.intervalSecondsPlayInNoPopupMode,
3569+
range: [3, 15],
3570+
onChangeUp: function(value) {
3571+
config.values.intervalSecondsPlayInNoPopupMode = config.save("interval_seconds_play", value);
3572+
}
35083573
}, {
35093574
type: "seekbar",
35103575
name: config.languages[config.values.lang].page_setting_chord_delay,
@@ -3564,7 +3629,7 @@ gui.dialogs.showProgressDialog(function(o) {
35643629
name: config.languages[config.values.lang].page_setting_show_license,
35653630
onClick: function(v) {
35663631
threads.start(function() {
3567-
config.fetchRepoFile("LICENSE", config.values.gitVersion, function(body) {
3632+
config.fetchRepoFile("LICENSE", function(body) {
35683633
gui.dialogs.showConfirmDialog({
35693634
title: "GNU GENERAL PUBLIC LICENSE",
35703635
text: body.string(),
@@ -3579,7 +3644,7 @@ gui.dialogs.showProgressDialog(function(o) {
35793644
name: config.languages[config.values.lang].page_setting_show_changelog,
35803645
onClick: function(v) {
35813646
threads.start(function() {
3582-
config.fetchRepoFile("update_log.txt", config.values.gitVersion, function(body) {
3647+
config.fetchRepoFile("update_log.txt", function(body) {
35833648
gui.dialogs.showConfirmDialog({
35843649
title: config.languages[config.values.lang].page_setting_changelog_title,
35853650
text: body.string(),
@@ -3603,7 +3668,7 @@ gui.dialogs.showProgressDialog(function(o) {
36033668
try {
36043669
android.os.Build.VERSION_CODES.R
36053670
} catch (e) {
3606-
sList.list.splice(7, 1);
3671+
sList.list.splice(9, 1);
36073672
}
36083673
return sList.list;
36093674
}()), function self(element) {

source/language_list.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"list": [{
33
"code": "zh_CN",
44
"name": "简体中文",
5-
"version": 4
5+
"version": 5
66
}, {
77
"code": "en_US",
88
"name": "English (US)",
9-
"version": 4
9+
"version": 5
1010
}]
1111
}

0 commit comments

Comments
 (0)