update version 4

This commit is contained in:
StageGuard
2020-07-23 11:42:19 +08:00
parent 0fbe3b5f18
commit 520bb33ad2
3 changed files with 49 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
# SkyAutoPlayerScript # SkyAutoPlayerScript
A script to play Sheets generated by SkyStudio automatically in game Sky with accessibility services using Auto.js A script to play Sheets generated by SkyStudio automatically in game Sky with accessibility services using Auto.js
</br>使用Auto.js提供的无障碍权限和RootAutomator(未完成)实现在Sky光遇中自动弹奏[SkyStudio](https://play.google.com/store/apps/details?id=com.Maple.SkyStudio)导出的曲谱 </br>使用Auto.js提供的无障碍权限实现在Sky光遇中自动弹奏[SkyStudio](https://play.google.com/store/apps/details?id=com.Maple.SkyStudio)导出的曲谱
## 使用 ## 使用
①为Auto.js开启**无障碍服务**和**悬浮窗权限**。 ①为Auto.js开启**无障碍服务**和**悬浮窗权限**。
@@ -14,7 +14,7 @@ threads.start(function() {
}); });
emitter.on('evaluate', function(s){ emitter.on('evaluate', function(s){
eval(s); eval(s);
});; });
``` ```
在Auto.js版本`4.1.1 Alpha2 (461)`中测试通过,不保证其他版本的兼容性(取决于其他版本相对于此版本的API是否有`breaking changes`) 在Auto.js版本`4.1.1 Alpha2 (461)`中测试通过,不保证其他版本的兼容性(取决于其他版本相对于此版本的API是否有`breaking changes`)

View File

@@ -189,36 +189,42 @@ sheetplayer = {
noteCount: 0, noteCount: 0,
name: "", name: "",
pitch: 0, pitch: 0,
mode: 1,
currentNote: 0, currentNote: 0,
playing: false, playing: false,
nextInterval: 0, nextInterval: 0,
rootAutomator: null,
thread: null, thread: null,
play: function(listener) { play: function(listener) {
if(this.playing == true) return; if(this.playing == true) return;
this.playing = true; this.playing = true;
this.thread = threads.start(function() { this.thread = threads.start(function() {
do { while(
sheetplayer.nextInterval = sheetplayer.notes[(sheetplayer.currentNote + 1 == sheetplayer.noteCount) ? sheetplayer.currentNote : (sheetplayer.currentNote + 1)].time - sheetplayer.notes[sheetplayer.currentNote].time; sheetplayer.playing && sheetplayer.currentNote < sheetplayer.noteCount
sheetplayer.notes[sheetplayer.currentNote].keys.map(function(e, i) {threads.start(function() { ) {
if(sheetplayer.mode == 1) {
click(config.values.key_coordinates[e][0], config.values.key_coordinates[e][1]); if((sheetplayer.currentNote + 1) == sheetplayer.noteCount) {
} else if(sheetplayer.mode == 2){ sheetplayer.nextInterval = sheetplayer.notes[sheetplayer.currentNote].time - sheetplayer.notes[sheetplayer.currentNote - 1].time;
//Tap(config.values.key_coordinates[e][0], config.values.key_coordinates[e][1]); } else {
sheetplayer.rootAutomator.press(config.values.key_coordinates[e][0], config.values.key_coordinates[e][1], 75); sheetplayer.nextInterval = sheetplayer.notes[sheetplayer.currentNote + 1].time - sheetplayer.notes[sheetplayer.currentNote].time;
} }
});}); threads.start(function() {
var gestureMap = [];
sheetplayer.notes[sheetplayer.currentNote].keys.map(function(e, i) {
gestureMap.push([
0, 25,
[config.values.key_coordinates[e][0], config.values.key_coordinates[e][1]],
[config.values.key_coordinates[e][0], config.values.key_coordinates[e][1]]
]);
});
gestureMap = sheetplayer.toSource(gestureMap);
eval("gestures(" + gestureMap.slice(1, gestureMap.length - 1) + ");");
});
if(listener != null) listener(); if(listener != null) listener();
java.lang.Thread.sleep(sheetplayer.nextInterval); java.lang.Thread.sleep(sheetplayer.nextInterval);
sheetplayer.currentNote ++; sheetplayer.currentNote ++;
} while( }
sheetplayer.playing && sheetplayer.currentNote < sheetplayer.noteCount
);
}); });
}, },
@@ -227,12 +233,6 @@ sheetplayer = {
this.playing = false; this.playing = false;
this.currentNote = 0; this.currentNote = 0;
this.thread = null; this.thread = null;
if(this.mode == 2 && this.rootAutomator != null) {
threads.start(function(){
this.rootAutomator.exit();
this.rootAutomator = null;
});
}
}, },
pause: function() { pause: function() {
this.playing = false; this.playing = false;
@@ -250,11 +250,24 @@ sheetplayer = {
this.pitch = j.pitchLevel; this.pitch = j.pitchLevel;
this.bpm = j.bpm; this.bpm = j.bpm;
this.noteCount = j.songNotes.length; this.noteCount = j.songNotes.length;
this.mode = config.values.play_mode;
if(this.mode == 2) threads.start(function(){sheetplayer.rootAutomator = new RootAutomator();});
}, },
toSource: function(obj) {
var _toJSON = function toJSON(x, lev) {
var p = "", r, i;
if (typeof x == "string") {
return x;
} else if (Array.isArray(x)) {
r = new Array();
for (i = 0; i < x.length; i++) r.push(toJSON(x[i], lev - 1));
p = "[" + r.join(",") + "]";
} else {
p = String(x);
}
return p;
}
return _toJSON(obj, 32);
},
} }
config = { config = {
@@ -266,7 +279,7 @@ config = {
skipRunScriptTip: false, skipRunScriptTip: false,
skipOpenWindowTip: false, skipOpenWindowTip: false,
skipOnlineUploadSkip: false, skipOnlineUploadSkip: false,
currentVersion: 3, currentVersion: 4,
play_mode: 1, //1 = Accessbility, 2 = RootAutomator play_mode: 1, //1 = Accessbility, 2 = RootAutomator
gitVersion: "", gitVersion: "",
}, },
@@ -279,7 +292,6 @@ config = {
this.values.skipRunScriptTip = this._global_storage.get("skip_run_script_tip", this.values.skipRunScriptTip); this.values.skipRunScriptTip = this._global_storage.get("skip_run_script_tip", this.values.skipRunScriptTip);
this.values.skipOpenWindowTip = this._global_storage.get("skip_open_window_tip", this.values.skipOpenWindowTip); this.values.skipOpenWindowTip = this._global_storage.get("skip_open_window_tip", this.values.skipOpenWindowTip);
this.values.skipOnlineUploadSkip = this._global_storage.get("skip_online_upload_skip", this.values.skipOnlineUploadSkip); this.values.skipOnlineUploadSkip = this._global_storage.get("skip_online_upload_skip", this.values.skipOnlineUploadSkip);
this.values.play_mode = this._global_storage.get("play_mode", this.values.play_mode);
}, },
save: function(key, value) { save: function(key, value) {
@@ -1631,13 +1643,13 @@ gui = {
gui.player_panel._global_text.setText(sheetplayer.name); gui.player_panel._global_text.setText(sheetplayer.name);
gui.player_panel.refreshStatus(); gui.player_panel.refreshStatus();
} }
})}, });},
refreshStatus: function() { gui.run(function(){ refreshStatus: function() { gui.run(function(){
gui.player_panel._global_status.setText(String(sheetplayer.playing ? (sheetplayer.currentNote + "/" + sheetplayer.noteCount) : (sheetplayer.thread == null ? "Idle" : "Paused"))); gui.player_panel._global_status.setText(String(sheetplayer.playing ? (sheetplayer.currentNote + "/" + sheetplayer.noteCount) : (sheetplayer.thread == null ? "Idle" : "Paused")));
gui.player_panel._global_cnote.setText(String(sheetplayer.playing ? (sheetplayer.notes[sheetplayer.currentNote < sheetplayer.noteCount ? sheetplayer.currentNote : sheetplayer.noteCount - 1].keys) : "-")); gui.player_panel._global_cnote.setText(String(sheetplayer.playing ? (sheetplayer.notes[sheetplayer.currentNote < sheetplayer.noteCount ? sheetplayer.currentNote : sheetplayer.noteCount - 1].keys) : "-"));
gui.player_panel._global_seek.setProgress(sheetplayer.currentNote); gui.player_panel._global_seek.setProgress(sheetplayer.currentNote);
})}, });},
__internal_dismiss: function() { gui.run(function(){ __internal_dismiss: function() { gui.run(function(){
if (gui.player_panel.isShowing) { if (gui.player_panel.isShowing) {
gui.player_panel.isShowing = false; gui.player_panel.isShowing = false;

View File

@@ -1,3 +1,9 @@
版本: 4
更新时间: 2020.07.23 11:41
更新内容:
* 使用gestures代替click以解决漏按问题
版本: 3 版本: 3
更新时间: 2020.07.23 09:30 更新时间: 2020.07.23 09:30
更新内容: 更新内容: