@@ -105,7 +105,7 @@ sheetmgr = {
105
105
106
106
downloadAndLoad : function ( file , extraData , listener ) {
107
107
listener ( { status :1 } ) ;
108
- config . fetchRepoFile ( "shared_sheets/" + file , config . values . gitVersion , function ( body ) {
108
+ config . fetchRepoFile ( "shared_sheets/" + file , function ( body ) {
109
109
var sheet = files . join ( sheetmgr . rootDir , files . getNameWithoutExtension ( file ) + ( function ( length ) {
110
110
var string = "0123456789abcde" ;
111
111
var stringBuffer = new java . lang . StringBuffer ( ) ;
@@ -162,7 +162,7 @@ sheetmgr = {
162
162
}
163
163
} ,
164
164
__internal_fetchOnlineSharedSheets : function ( ) {
165
- config . fetchRepoFile ( "shared_sheets.json" , config . values . gitVersion , function ( body ) {
165
+ config . fetchRepoFile ( "shared_sheets.json" , function ( body ) {
166
166
sheetmgr . cachedOnlineSharedSheetInfoList = body . json ( ) . sheets ;
167
167
} ) ;
168
168
} ,
@@ -301,25 +301,30 @@ sheetplayer = {
301
301
// 播放完自动下一首
302
302
303
303
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 ) {
316
310
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 ( ) ;
320
324
}
321
325
} else {
322
326
sheetplayer . stop ( ) ;
327
+ gui . main . show ( 0 ) ;
323
328
}
324
329
}
325
330
} ) ;
@@ -384,7 +389,7 @@ config = {
384
389
_global_storage : null ,
385
390
386
391
values : {
387
- currentVersion : 22 ,
392
+ currentVersion : 23 ,
388
393
gitVersion : "" ,
389
394
390
395
key_coordinates15 : [ ] ,
@@ -402,6 +407,9 @@ config = {
402
407
autoPlay : false ,
403
408
lang : "zh_CN" ,
404
409
chordDelay : 0 ,
410
+ noPopupPlay : false ,
411
+ noPopupPlayWarning : true ,
412
+ intervalSecondsPlayInNoPopupMode : 5 ,
405
413
} ,
406
414
407
415
bitmaps : { } ,
@@ -493,6 +501,8 @@ config = {
493
501
page_setting_set_15key_coordinate : "设置15键盘键位坐标" ,
494
502
page_setting_key_coordinate_saved : "坐标设置已保存至存储!" ,
495
503
page_setting_random_and_continuate_play : "连续随机播放" ,
504
+ page_setting_no_popup_play : "弹奏不显示悬浮窗" ,
505
+ page_setting_no_popup_play_interval : "无悬浮窗弹奏开始间隔" ,
496
506
page_setting_show_broken_sheet : "显示加载失败的乐谱" ,
497
507
page_setting_show_storage_tip_on_android11 : "启动脚本时显示存储提示" ,
498
508
page_setting_set_theme : "设置主题色" ,
@@ -534,7 +544,18 @@ config = {
534
544
res_language_dialog_tip : "找不到你的语言?欢迎贡献翻译:<br><a href=>https://github.com/StageGuard/SkyAutoPlayerScript</a>" ,
535
545
res_language_failed_fetch_online_list : "无法获取在线语言列表" ,
536
546
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} 秒后开始弹奏。"
538
559
} ,
539
560
} ,
540
561
@@ -550,7 +571,7 @@ config = {
550
571
this . languages [ content . code ] = content . content ;
551
572
listener ( String . format ( this . languages [ content . code ] . res_use_language , content . name ) ) ;
552
573
threads . start ( function ( ) {
553
- config . fetchRepoFile ( "source/language_list.json" , config . values . gitVersion , function ( body ) {
574
+ config . fetchRepoFile ( "source/language_list.json" , function ( body ) {
554
575
var onlineList = JSON . parse ( body . string ( ) ) . list ;
555
576
for ( var i in onlineList ) {
556
577
if ( onlineList [ i ] . code == content . code ) {
@@ -609,6 +630,9 @@ config = {
609
630
this . values . autoPlay = this . _global_storage . get ( "auto_play" , this . values . autoPlay ) ;
610
631
this . values . lang = this . _global_storage . get ( "language" , this . values . lang )
611
632
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 )
612
636
try {
613
637
android . os . Build . VERSION_CODES . R
614
638
sheetmgr . rootDir = android . os . Environment . getExternalStorageDirectory ( ) + "/Documents/SkyAutoPlayer/sheets/" ;
@@ -630,7 +654,7 @@ config = {
630
654
var periodVersion = this . _global_storage . get ( "version" , this . values . currentVersion ) ;
631
655
var currentVersion = this . values . currentVersion ;
632
656
if ( periodVersion < currentVersion ) {
633
- config . fetchRepoFile ( "update_log.txt" , this . values . gitVersion , function ( body ) {
657
+ config . fetchRepoFile ( "update_log.txt" , function ( body ) {
634
658
gui . dialogs . showConfirmDialog ( {
635
659
title : config . languages [ config . values . lang ] . res_updated ,
636
660
text : String . format ( config . languages [ config . values . lang ] . res_updated_detail , currentVersion , periodVersion , body . string ( ) ) ,
@@ -658,7 +682,7 @@ config = {
658
682
try {
659
683
listener ( String . format ( config . languages [ config . values . lang ] . res_loading_detail , element ) ) ;
660
684
config . bitmaps [ files . getNameWithoutExtension ( absolutePath ) ] = android . graphics . Bitmap . createBitmap ( android . graphics . BitmapFactory . decodeFile ( absolutePath ) ) ;
661
- } catch ( e ) {
685
+ } catch ( e ) {
662
686
listener ( String . format ( config . languages [ config . values . lang ] . res_loading_error , element ) ) ;
663
687
downloadQueue . push ( element ) ;
664
688
}
@@ -680,7 +704,7 @@ config = {
680
704
var iterator = 0 ;
681
705
tmpQueue . map ( function ( element , i ) {
682
706
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 ) {
684
708
var absolutePath = files . join ( localRootDir , element ) ;
685
709
files . create ( absolutePath ) ;
686
710
files . writeBytes ( absolutePath , body . bytes ( ) ) ;
@@ -702,35 +726,30 @@ config = {
702
726
listener ( config . languages [ config . values . lang ] . res_download_successful ) ;
703
727
java . lang . Thread . sleep ( 1000 ) ; //为了方便看清
704
728
}
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 ) ) ) ;
707
731
}
708
732
709
733
} ,
710
734
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 ] ) ) ;
723
746
if ( resp . statusCode >= 200 && resp . statusCode < 300 ) {
724
747
successCbk ( resp . body ) ;
725
748
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" ; }
733
751
}
752
+ if ( failCbk != null ) failCbk ( errorCollector ) ;
734
753
} ,
735
754
736
755
updateBitmapTheme : function ( ) {
@@ -2087,7 +2106,31 @@ gui = {
2087
2106
s . play . setBackgroundDrawable ( gui . utils . ripple_drawable ( s . play . getMeasuredWidth ( ) , s . play . getMeasuredHeight ( ) , "rect" ) ) ;
2088
2107
s . play . setOnClickListener ( new android . view . View . OnClickListener ( {
2089
2108
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
+ }
2091
2134
}
2092
2135
} ) ) ;
2093
2136
s . play . setEnabled ( false ) ;
@@ -2221,6 +2264,13 @@ gui = {
2221
2264
} ) ;
2222
2265
2223
2266
} ) ; } ,
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
+ } ,
2224
2274
__internal_dismiss : function ( ) { gui . run ( function ( ) {
2225
2275
if ( gui . player_panel . isShowing ) {
2226
2276
gui . player_panel . isShowing = false ;
@@ -2337,7 +2387,7 @@ gui = {
2337
2387
var item = listAdapterController . get ( pos ) ;
2338
2388
if ( item . type == "item" ) {
2339
2389
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 ) {
2341
2391
var lf = android . os . Environment . getExternalStorageDirectory ( ) + "/Documents/SkyAutoPlayer/lang/" + item . code + ".json" ;
2342
2392
files . create ( lf )
2343
2393
files . writeBytes ( lf , body . bytes ( ) ) ;
@@ -2399,7 +2449,7 @@ gui = {
2399
2449
2400
2450
var onlineList = [ ] ;
2401
2451
threads . start ( function ( ) {
2402
- config . fetchRepoFile ( "source/language_list.json" , config . values . gitVersion , function ( body ) {
2452
+ config . fetchRepoFile ( "source/language_list.json" , function ( body ) {
2403
2453
onlineList = JSON . parse ( body . string ( ) ) . list ;
2404
2454
gui . run ( function ( ) {
2405
2455
var __listArray = listAdapterController . getArray ( ) ;
@@ -3505,6 +3555,21 @@ gui.dialogs.showProgressDialog(function(o) {
3505
3555
onClick : function ( checked ) {
3506
3556
config . values . autoPlay = config . save ( "auto_play" , checked ) ;
3507
3557
}
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
+ }
3508
3573
} , {
3509
3574
type : "seekbar" ,
3510
3575
name : config . languages [ config . values . lang ] . page_setting_chord_delay ,
@@ -3564,7 +3629,7 @@ gui.dialogs.showProgressDialog(function(o) {
3564
3629
name : config . languages [ config . values . lang ] . page_setting_show_license ,
3565
3630
onClick : function ( v ) {
3566
3631
threads . start ( function ( ) {
3567
- config . fetchRepoFile ( "LICENSE" , config . values . gitVersion , function ( body ) {
3632
+ config . fetchRepoFile ( "LICENSE" , function ( body ) {
3568
3633
gui . dialogs . showConfirmDialog ( {
3569
3634
title : "GNU GENERAL PUBLIC LICENSE" ,
3570
3635
text : body . string ( ) ,
@@ -3579,7 +3644,7 @@ gui.dialogs.showProgressDialog(function(o) {
3579
3644
name : config . languages [ config . values . lang ] . page_setting_show_changelog ,
3580
3645
onClick : function ( v ) {
3581
3646
threads . start ( function ( ) {
3582
- config . fetchRepoFile ( "update_log.txt" , config . values . gitVersion , function ( body ) {
3647
+ config . fetchRepoFile ( "update_log.txt" , function ( body ) {
3583
3648
gui . dialogs . showConfirmDialog ( {
3584
3649
title : config . languages [ config . values . lang ] . page_setting_changelog_title ,
3585
3650
text : body . string ( ) ,
@@ -3603,7 +3668,7 @@ gui.dialogs.showProgressDialog(function(o) {
3603
3668
try {
3604
3669
android . os . Build . VERSION_CODES . R
3605
3670
} catch ( e ) {
3606
- sList . list . splice ( 7 , 1 ) ;
3671
+ sList . list . splice ( 9 , 1 ) ;
3607
3672
}
3608
3673
return sList . list ;
3609
3674
} ( ) ) , function self ( element ) {
0 commit comments