mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
fix.修复adb连接重构后的一些问题
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"version": "0.9",
|
||||
"version": "1.0",
|
||||
"options": {
|
||||
"connectType": 0,
|
||||
"connectType_Doc": "连接类型:0-连接电脑上的模拟器;1-连接自定义端口,请手动修改'emulator.Custom'中的相关字段。默认0",
|
||||
"taskDelay": 500,
|
||||
"taskDelay_Doc": "识别的延迟:越快识别频率越快,但会增加CPU消耗。单位毫秒,默认500",
|
||||
"controlDelayRange": [
|
||||
@@ -21,8 +19,19 @@
|
||||
"cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i"
|
||||
}
|
||||
},
|
||||
"emulator_Doc": "下面的和模拟器窗口捕获逻辑有关,不需要修改",
|
||||
"emulator": {
|
||||
"connection": {
|
||||
"General": {
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init=",
|
||||
"displayFormat": " init=%dx%d",
|
||||
"screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"",
|
||||
"screencapEncode": "[Adb] -s [Address] exec-out screencap -p",
|
||||
"release": "[Adb] kill-server"
|
||||
},
|
||||
"BlueStacks": {
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
@@ -95,18 +104,6 @@
|
||||
"screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap -d [DisplayId] | gzip -1\"",
|
||||
"screencapEncode": "[Adb] -s [Address] shell screencap -d [DisplayId] -p",
|
||||
"release": "[Adb] kill-server"
|
||||
},
|
||||
"General": {
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init=",
|
||||
"displayFormat": " init=%dx%d",
|
||||
"screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"",
|
||||
"screencapEncode": "[Adb] -s [Address] exec-out screencap -p",
|
||||
"release": "[Adb] kill-server"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,13 +629,13 @@ bool asst::Controller::connect(const std::string & adb_path, const std::string &
|
||||
|
||||
auto cmd_replace = [&](const std::string& cfg_cmd) -> std::string {
|
||||
const std::unordered_map<std::string, std::string> replacements = {
|
||||
{"[Adb]", address},
|
||||
{"[Adb]", adb_path},
|
||||
{"[Address]", address},
|
||||
{"[DisplayId]", display_id}
|
||||
};
|
||||
std::string formatted = cfg_cmd;
|
||||
for (const auto& [key, value] : replacements) {
|
||||
utils::string_replace_all(formatted, key, value);
|
||||
formatted = utils::string_replace_all(formatted, key, value);
|
||||
}
|
||||
return formatted;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
|
||||
{
|
||||
const json::value& options_json = json.at("options");
|
||||
m_options.connect_type = static_cast<ConnectType>(options_json.at("connectType").as_integer());
|
||||
m_options.task_delay = options_json.at("taskDelay").as_integer();
|
||||
m_options.control_delay_lower = options_json.at("controlDelayRange")[0].as_integer();
|
||||
m_options.control_delay_upper = options_json.at("controlDelayRange")[1].as_integer();
|
||||
@@ -30,7 +29,7 @@ bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [name, cfg_json] : json.at("emulator").as_object()) {
|
||||
for (const auto& [name, cfg_json] : json.at("connection").as_object()) {
|
||||
AdbCfg adb;
|
||||
|
||||
adb.devices = cfg_json.at("devices").as_string();
|
||||
|
||||
@@ -11,12 +11,6 @@
|
||||
|
||||
namespace asst
|
||||
{
|
||||
enum class ConnectType
|
||||
{
|
||||
Emulator,
|
||||
Custom
|
||||
};
|
||||
|
||||
struct AipOcrCfg // 百度 OCR API 的配置
|
||||
{
|
||||
bool enable = false;
|
||||
@@ -35,7 +29,6 @@ namespace asst
|
||||
|
||||
struct Options
|
||||
{
|
||||
ConnectType connect_type = ConnectType::Emulator; // 连接类型
|
||||
int task_delay = 0; // 任务间延时:越快操作越快,但会增加CPU消耗
|
||||
int control_delay_lower = 0; // 点击随机延时下限:每次点击操作会进行随机延时
|
||||
int control_delay_upper = 0; // 点击随机延时上限:每次点击操作会进行随机延时
|
||||
|
||||
@@ -54,10 +54,14 @@ bool asst::StageDropsTaskPlugin::_run()
|
||||
}
|
||||
drop_info_callback();
|
||||
|
||||
auto upload_future = std::async(
|
||||
std::launch::async,
|
||||
std::bind(&StageDropsTaskPlugin::upload_to_penguin, this));
|
||||
m_upload_pending.emplace_back(std::move(upload_future));
|
||||
auto& opt = Resrc.cfg().get_options();
|
||||
|
||||
if (opt.penguin_report.enable) {
|
||||
auto upload_future = std::async(
|
||||
std::launch::async,
|
||||
std::bind(&StageDropsTaskPlugin::upload_to_penguin, this));
|
||||
m_upload_pending.emplace_back(std::move(upload_future));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -137,9 +141,7 @@ void asst::StageDropsTaskPlugin::upload_to_penguin()
|
||||
LogTraceFunction;
|
||||
|
||||
auto& opt = Resrc.cfg().get_options();
|
||||
if (!opt.penguin_report.enable) {
|
||||
return;
|
||||
}
|
||||
|
||||
json::value info = basic_info();
|
||||
info["subtask"] = "ReportToPenguinStats";
|
||||
callback(AsstMsg::SubTaskStart, info);
|
||||
|
||||
Reference in New Issue
Block a user