Update version 15

This commit is contained in:
StageGuard
2020-10-01 00:09:10 +08:00
parent 2a16af252f
commit 65fdecb9be
3 changed files with 410 additions and 304 deletions

View File

@@ -77,6 +77,8 @@ files.removeDir("/storage/emulated/0/Documents/SkyAutoPlayer/");
"bpm" : 320, "bpm" : 320,
//暂时没用 //暂时没用
"suggested_instrument": 1, "suggested_instrument": 1,
//乐谱键位数(8键或15键)
"keyCount": 15,
//乐谱音高 //乐谱音高
"pitchLevel": 0 "pitchLevel": 0
} }

View File

@@ -90,7 +90,7 @@ sheetmgr = {
return resultList; return resultList;
}, },
downloadAndLoad: function(file, author, listener) { downloadAndLoad: function(file, extraData, listener) {
listener({status:1}); listener({status:1});
config.fetchRepoFile("shared_sheets/" + file, null, function(body) { config.fetchRepoFile("shared_sheets/" + file, null, function(body) {
var sheet = files.join(sheetmgr.rootDir, files.getNameWithoutExtension(file) + (function(length) { var sheet = files.join(sheetmgr.rootDir, files.getNameWithoutExtension(file) + (function(length) {
@@ -105,7 +105,8 @@ sheetmgr = {
files.write(sheet, parsed = (function() { files.write(sheet, parsed = (function() {
var data = eval(body.string())[0]; var data = eval(body.string())[0];
listener({status:2}); listener({status:2});
data.author = author; data.author = extraData.author;
data.keyCount = extraData.keyCount;
return "[" + JSON.stringify(data) + "]"; return "[" + JSON.stringify(data) + "]";
}()), sheetmgr.encoding); }()), sheetmgr.encoding);
parsed = eval(parsed)[0]; parsed = eval(parsed)[0];
@@ -221,6 +222,8 @@ sheetplayer = {
playing: false, playing: false,
nextInterval: 0, nextInterval: 0,
keyCount: 15,
speed: 1, speed: 1,
current_speed_index: 9, current_speed_index: 9,
speed_list: [ speed_list: [
@@ -261,11 +264,8 @@ sheetplayer = {
run: function() { run: function() {
var gestureMap = []; var gestureMap = [];
sheetplayer.notes[sheetplayer.currentNote].keys.map(function(e, i) { sheetplayer.notes[sheetplayer.currentNote].keys.map(function(e, i) {
gestureMap.push([ var keyCoordinates = sheetplayer.keyCount == 15 ? [config.values.key_coordinates15[e][0], config.values.key_coordinates15[e][1]] : [config.values.key_coordinates8[e][0], config.values.key_coordinates8[e][1]];
0, 25, gestureMap.push([0, 25, keyCoordinates, keyCoordinates]);
[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); gestureMap = sheetplayer.toSource(gestureMap);
eval("gestures(" + gestureMap.slice(1, gestureMap.length - 1) + ");"); eval("gestures(" + gestureMap.slice(1, gestureMap.length - 1) + ");");
@@ -319,6 +319,7 @@ sheetplayer = {
this.pitch = j.pitchLevel; this.pitch = j.pitchLevel;
this.bpm = j.bpm; this.bpm = j.bpm;
this.noteCount = this.notes.length; this.noteCount = this.notes.length;
this.keyCount = j.keyCount;
}, },
toSource: function(obj) { toSource: function(obj) {
@@ -344,16 +345,18 @@ config = {
_global_storage: null, _global_storage: null,
values: { values: {
key_coordinates: [], key_coordinates15: [],
key_coordinates8: [],
skipRunScriptTip: false, skipRunScriptTip: false,
skipOpenWindowTip: false, skipOpenWindowTip: false,
skipOpenPlayerPanelWindowTip: false, skipOpenPlayerPanelWindowTip: false,
skipOnlineUploadTip: false, skipOnlineUploadTip: false,
skipOnlineSharedSheetCTip: false, skipOnlineSharedSheetCTip: false,
skipImportLocalSheetTip: false, skipImportLocalSheetTip: false,
skipChangeKeyCountTip: false,
showFailedSheets: true, showFailedSheets: true,
tipOnAndroidR: true, tipOnAndroidR: true,
currentVersion: 14, currentVersion: 15,
gitVersion: "", gitVersion: "",
}, },
@@ -362,13 +365,15 @@ config = {
init: function() { init: function() {
this._global_storage = storages.create("StageGuard:SkyAutoPlayer:Config"); this._global_storage = storages.create("StageGuard:SkyAutoPlayer:Config");
this.values.key_coordinates = this._global_storage.get("key_coordinates", this.values.key_coordinates); this.values.key_coordinates15 = this._global_storage.get("key_coordinates15", this.values.key_coordinates15);
this.values.key_coordinates8 = this._global_storage.get("key_coordinates8", this.values.key_coordinates8);
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.skipOpenPlayerPanelWindowTip = this._global_storage.get("skip_open_player_panel_window_tip", this.values.skipOpenPlayerPanelWindowTip); this.values.skipOpenPlayerPanelWindowTip = this._global_storage.get("skip_open_player_panel_window_tip", this.values.skipOpenPlayerPanelWindowTip);
this.values.skipOnlineUploadTip = this._global_storage.get("skip_online_upload_tip", this.values.skipOnlineUploadTip); this.values.skipOnlineUploadTip = this._global_storage.get("skip_online_upload_tip", this.values.skipOnlineUploadTip);
this.values.skipOnlineSharedSheetCTip = this._global_storage.get("skip_shared_sheet_c_tip", this.values.skipOnlineSharedSheetCTip); this.values.skipOnlineSharedSheetCTip = this._global_storage.get("skip_shared_sheet_c_tip", this.values.skipOnlineSharedSheetCTip);
this.values.skipImportLocalSheetTip = this._global_storage.get("skip_import_local_sheet_tip", this.values.skipImportLocalSheetTip); this.values.skipImportLocalSheetTip = this._global_storage.get("skip_import_local_sheet_tip", this.values.skipImportLocalSheetTip);
this.values.skipChangeKeyCountTip = this._global_storage.get("skip_change_key_count_tip", this.values.skipChangeKeyCountTip);
this.values.showFailedSheets = this._global_storage.get("show_failed_sheets", this.values.showFailedSheets); this.values.showFailedSheets = this._global_storage.get("show_failed_sheets", this.values.showFailedSheets);
this.values.tipOnAndroidR = this._global_storage.get("tip_storage_on_android_r", this.values.tipOnAndroidR); this.values.tipOnAndroidR = this._global_storage.get("tip_storage_on_android_r", this.values.tipOnAndroidR);
@@ -1517,7 +1522,7 @@ gui = {
current_index: 0, current_index: 0,
__internal_showTargetDots: function s() { gui.run(function(){ __internal_showTargetDots: function s(keyTargetedCbk, finishCbk) { gui.run(function(){
if(!gui.key_coordinate_navigation.isShowing) { if(!gui.key_coordinate_navigation.isShowing) {
gui.key_coordinate_navigation._global_base = new android.widget.TextView(ctx); gui.key_coordinate_navigation._global_base = new android.widget.TextView(ctx);
gui.key_coordinate_navigation._global_base.setLayoutParams(new android.widget.LinearLayout.LayoutParams(-2, -2)); gui.key_coordinate_navigation._global_base.setLayoutParams(new android.widget.LinearLayout.LayoutParams(-2, -2));
@@ -1539,7 +1544,7 @@ gui = {
break; break;
case event.ACTION_UP: case event.ACTION_UP:
gui.key_coordinate_navigation._global_text.setText("键" + (gui.key_coordinate_navigation.current_index + 1) + "坐标已设置: [" + event.getRawX() + ", " + event.getRawY() + "]"); gui.key_coordinate_navigation._global_text.setText("键" + (gui.key_coordinate_navigation.current_index + 1) + "坐标已设置: [" + event.getRawX() + ", " + event.getRawY() + "]");
config.values.key_coordinates.push([event.getRawX(), event.getRawY()]) keyTargetedCbk([event.getRawX(), event.getRawY()]);
gui.utils.value_animation("Float", 1, 0, 200 , new android.view.animation.DecelerateInterpolator(), function(anim) { gui.utils.value_animation("Float", 1, 0, 200 , new android.view.animation.DecelerateInterpolator(), function(anim) {
gui.key_coordinate_navigation._global_base.setAlpha(anim.getAnimatedValue()); gui.key_coordinate_navigation._global_base.setAlpha(anim.getAnimatedValue());
gui.key_coordinate_navigation._global_text.setAlpha(1 - anim.getAnimatedValue()); gui.key_coordinate_navigation._global_text.setAlpha(1 - anim.getAnimatedValue());
@@ -1548,19 +1553,16 @@ gui = {
gui.key_coordinate_navigation.isShowing = false; gui.key_coordinate_navigation.isShowing = false;
} }
}); });
threads.start(function() { var handler = new android.os.Handler();
java.lang.Thread.currentThread().sleep(1000); handler.postDelayed(function() {
gui.run(function() { if(++gui.key_coordinate_navigation.current_index < gui.key_coordinate_navigation.total) {
if(++gui.key_coordinate_navigation.current_index < 15) { gui.key_coordinate_navigation.__internal_showTargetDots(keyTargetedCbk, finishCbk);
gui.key_coordinate_navigation.__internal_showTargetDots(gui.key_coordinate_navigation.current_index);
} else { } else {
config.save("key_coordinates"); finishCbk();
toast("坐标设置已保存至存储!\n");
gui.key_coordinate_navigation.__internal_dismissText(); gui.key_coordinate_navigation.__internal_dismissText();
gui.main.show(2); gui.main.show(2);
} }
}); }, 1000);
});
default: default:
return false; return false;
} }
@@ -1630,11 +1632,11 @@ gui = {
} }
})}, })},
show: function() { show: function(keyCount, keyTargetedCbk, finishCbk) {
config.values.key_coordinates.length = 0;
gui.key_coordinate_navigation.current_index = 0; gui.key_coordinate_navigation.current_index = 0;
gui.key_coordinate_navigation.total = keyCount ? keyCount : 15;
this.__internal_showTips(); this.__internal_showTips();
this.__internal_showTargetDots(); this.__internal_showTargetDots(keyTargetedCbk, finishCbk);
}, },
}, },
@@ -2090,18 +2092,47 @@ gui.dialogs.showProgressDialog(function(o) {
element.v_play.setBackgroundDrawable(gui.utils.ripple_drawable(element.v_play.getMeasuredWidth(), element.v_play.getMeasuredHeight(), "rect")); element.v_play.setBackgroundDrawable(gui.utils.ripple_drawable(element.v_play.getMeasuredWidth(), element.v_play.getMeasuredHeight(), "rect"));
element.v_play.setOnClickListener(new android.view.View.OnClickListener({ element.v_play.setOnClickListener(new android.view.View.OnClickListener({
onClick: function() { onClick: function() {
if(config.values.key_coordinates.length == 15 && gui.main.isShowing) { if(gui.main.isShowing) {
if(!element.keyCount) {
gui.dialogs.showConfirmDialog({
title: "设置键位数",
text: "这是一个本地乐谱,请设置这个乐谱的键位数",
canExit: true,
buttons: ["8 键位", "15 键位"],
callback: function(id) {
files.write(files.join(sheetmgr.rootDir, element.fileName), (function() {
var readable = files.open(files.join(sheetmgr.rootDir, element.fileName), "r", sheetmgr.encoding);
var parsed = eval(readable.read())[0];
readable.close();
parsed.keyCount = id == 0 ? (element.keyCount = 8) : (element.keyCount = 15)
return "[" + JSON.stringify(parsed) + "]";
}()), sheetmgr.encoding);
toast("已将 " + element.name + " 设置为 " + element.keyCount + " 键乐谱\n请再次点击弹奏按钮。\n长按乐谱以重新设置键位数。");
},
});
} else {
switch(element.keyCount) {
case 8: {
if(config.values.key_coordinates8.length != 8) {
toast("未设置8键键位坐标或坐标数据错误请前往设置页设置键位坐标");
return true;
}
};break;
case 15: {
if(config.values.key_coordinates15.length != 15) {
toast("未设置15键键位坐标或坐标数据错误请前往设置页设置键位坐标");
return true;
}
};break;
}
gui.main.__internal_dismiss(); gui.main.__internal_dismiss();
gui.player_panel.__internal_showPanel(element); gui.player_panel.__internal_showPanel(element);
} else { }
toast("未设置键位坐标或坐标数据错误,请前往设置页设置键位坐标");
} }
return true; return true;
} }
})); }));
element.v_relative.addView(element.v_play); element.v_relative.addView(element.v_play);
} }
element.v_delete = new android.widget.ImageView(ctx); element.v_delete = new android.widget.ImageView(ctx);
@@ -2144,7 +2175,8 @@ gui.dialogs.showProgressDialog(function(o) {
s.ns0_listView.setAdapter(s.ns0_listAdapterController.self); s.ns0_listView.setAdapter(s.ns0_listAdapterController.self);
s.ns0_listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener({ s.ns0_listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener({
onItemClick: function(parent, view, pos, id) { onItemClick: function(parent, view, pos, id) {
var item = s.ns0_listAdapterController.get(pos);if(item.type == -1) { var item = s.ns0_listAdapterController.get(pos);
if(item.type == -1) {
switch(item.index) { switch(item.index) {
case 0: { case 0: {
gui.dialogs.showConfirmDialog({ gui.dialogs.showConfirmDialog({
@@ -2171,6 +2203,24 @@ gui.dialogs.showProgressDialog(function(o) {
}); });
break; break;
} }
case 1: {
gui.dialogs.showConfirmDialog({
title: "修改乐谱键位数",
text: "版本15增加了对不同键位乐器(8键位和15键位)乐谱的支持,它们使用不同的坐标数据。\n" +
"当前已存储在本地的乐谱(外部导入的乐谱或在版本15之前从共享乐谱下载的乐谱)它们没有键位信息SkyAutoPlayerScript无法确认它是8键位乐谱还是15键位乐谱。\n" +
"共享乐谱信息已更新,现在下载的共享乐谱它已经包含了乐谱键位信息,不需要再设置。\n" +
"点击开始弹奏按钮时若无键位信息则会弹出对话框以选择乐谱键位SkyAutoPlayerScript会保存键位信息到乐谱。\n" +
"如果因为一些原因设置了错误的键位信息,可以长按乐谱来重新设置。\n\n" +
"p.s.: 需要重新设置15键键位坐标。",
canExit: true,
skip: function(checked) {
config.values.skipChangeKeyCountTip = config.save("skip_change_key_count_tip", checked);
if(checked) s.ns0_listAdapterController.removeByIndex(pos, true);
},
buttons: ["确认"]
});
break;
}
} }
return true; return true;
} }
@@ -2253,6 +2303,30 @@ gui.dialogs.showProgressDialog(function(o) {
}()), -2, -2, null, true); }()), -2, -2, null, true);
} }
})); }));
s.ns0_listView.setOnItemLongClickListener(new android.widget.AdapterView.OnItemLongClickListener({
onItemLongClick: function(parent, view, pos, id) {
var item = s.ns0_listAdapterController.get(pos);
if(!item.failed && item.type == 0) {
gui.dialogs.showConfirmDialog({
title: "设置键位数",
text: "这是一个本地乐谱,请设置这个乐谱的键位数",
canExit: true,
buttons: ["8 键位", "15 键位"],
callback: function(id) {
files.write(files.join(sheetmgr.rootDir, item.fileName), (function() {
var readable = files.open(files.join(sheetmgr.rootDir, item.fileName), "r", sheetmgr.encoding);
var parsed = eval(readable.read())[0];
readable.close();
parsed.keyCount = id == 0 ? (item.keyCount = 8) : (item.keyCount = 15)
return "[" + JSON.stringify(parsed) + "]";
}()), sheetmgr.encoding);
toast("已将 " + item.name + " 设置为 " + item.keyCount + " 键乐谱\n请再次点击弹奏按钮。\n长按乐谱以重新设置键位数。");
},
});
}
return true;
},
}));
s.ns0_rl.addView(s.ns0_listView); s.ns0_rl.addView(s.ns0_listView);
s.ns0_progress = new android.widget.ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal); s.ns0_progress = new android.widget.ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal);
@@ -2289,6 +2363,11 @@ gui.dialogs.showProgressDialog(function(o) {
title: "如何导入本地乐谱", title: "如何导入本地乐谱",
index: 0 index: 0
});//上传乐谱提示 });//上传乐谱提示
if(!config.values.skipChangeKeyCountTip) s.ns0_listAdapterController.add({
type: -1,
title: "修改乐谱键位数",
index: 1
});//修改乐谱键位提示
s.ns0_listAdapterController.notifyChange(); s.ns0_listAdapterController.notifyChange();
threads.start(function() { threads.start(function() {
sheetmgr.getLocalSheetList(isForce, function(successCount, failedCount) { sheetmgr.getLocalSheetList(isForce, function(successCount, failedCount) {
@@ -2297,10 +2376,11 @@ gui.dialogs.showProgressDialog(function(o) {
}); });
}).map(function(e, i) { }).map(function(e, i) {
gui.run(function(){ gui.run(function(){
if(!e.failed) { if(!e.failed || config.values.showFailedSheets) {
s.ns0_listAdapterController.add(e); s.ns0_listAdapterController.add((function(item) {
} else if(config.values.showFailedSheets){ item.type = 0;
s.ns0_listAdapterController.add(e); return item;
}(e)));
} }
}); });
}); });
@@ -2435,7 +2515,7 @@ gui.dialogs.showProgressDialog(function(o) {
element.download.setBackgroundDrawable(gui.utils.ripple_drawable(element.download.getMeasuredWidth(), element.download.getMeasuredHeight(), "rect")); element.download.setBackgroundDrawable(gui.utils.ripple_drawable(element.download.getMeasuredWidth(), element.download.getMeasuredHeight(), "rect"));
element.download.setOnClickListener(new android.view.View.OnClickListener({ element.download.setOnClickListener(new android.view.View.OnClickListener({
onClick: function() { threads.start(function() { onClick: function() { threads.start(function() {
if(!element.isShowingStatusBar) sheetmgr.downloadAndLoad(element.file, element.author, function(r) { if(!element.isShowingStatusBar) sheetmgr.downloadAndLoad(element.file, {author: element.author, keyCount: element.keyCount}, function(r) {
switch(r.status) { switch(r.status) {
case 1: { case 1: {
gui.run(function() { gui.run(function() {
@@ -2797,10 +2877,29 @@ gui.dialogs.showProgressDialog(function(o) {
name: "基本设置", name: "基本设置",
}, { }, {
type: "default", type: "default",
name: "设置键位坐标", name: "设置8键盘键位坐标",
onClick: function(v) { onClick: function(v) {
gui.main.__internal_dismiss(); gui.main.__internal_dismiss();
gui.key_coordinate_navigation.show(); config.values.key_coordinates8.length = 0;
gui.key_coordinate_navigation.show(8, function(value) {
config.values.key_coordinates8.push(value);
}, function() {
config.save("key_coordinates8");
toast("坐标设置已保存至存储!");
});
}
}, {
type: "default",
name: "设置15键盘键位坐标",
onClick: function(v) {
gui.main.__internal_dismiss();
config.values.key_coordinates15.length = 0;
gui.key_coordinate_navigation.show(15, function(value) {
config.values.key_coordinates15.push(value);
}, function() {
config.save("key_coordinates15");
toast("坐标设置已保存至存储!");
});
} }
}, { }, {
type: "checkbox", type: "checkbox",
@@ -2859,7 +2958,7 @@ gui.dialogs.showProgressDialog(function(o) {
try { try {
android.os.Build.VERSION_CODES.R android.os.Build.VERSION_CODES.R
} catch (e) { } catch (e) {
sList.list.splice(3, 1); sList.list.splice(4, 1);
} }
return sList.list; return sList.list;
}()), function self(element) { }()), function self(element) {

View File

@@ -1,5 +1,10 @@
版本: 15
更新时间: 2020.10.01 00:00
更新内容:
* 新增8键位乐谱支持
版本: 14 版本: 14
更新时间: 2020.09.03 20:51 更新时间: 2020.09.13 20:51
更新内容: 更新内容:
* 新增:共享乐谱支持搜索功能 * 新增:共享乐谱支持搜索功能
* 改善:窗口拓展功能 * 改善:窗口拓展功能