From f6909094ae02a244868bae3d8ca2d781b157a74c Mon Sep 17 00:00:00 2001 From: MistEO Date: Sat, 26 Feb 2022 20:48:53 +0800 Subject: [PATCH] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8Dadb=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=90=8E=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/config.json | 31 ++++++++++------------- src/MeoAssistant/Controller.cpp | 4 +-- src/MeoAssistant/GeneralConfiger.cpp | 3 +-- src/MeoAssistant/GeneralConfiger.h | 7 ----- src/MeoAssistant/StageDropsTaskPlugin.cpp | 16 +++++++----- 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/resource/config.json b/resource/config.json index d18010efe0..a9d4b1ae05 100644 --- a/resource/config.json +++ b/resource/config.json @@ -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" } } } diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index 0c9054f85b..4e5eeb68af 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -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 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; }; diff --git a/src/MeoAssistant/GeneralConfiger.cpp b/src/MeoAssistant/GeneralConfiger.cpp index 8b7996acab..2f328e24e4 100644 --- a/src/MeoAssistant/GeneralConfiger.cpp +++ b/src/MeoAssistant/GeneralConfiger.cpp @@ -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(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(); diff --git a/src/MeoAssistant/GeneralConfiger.h b/src/MeoAssistant/GeneralConfiger.h index f845b69b22..3c7b2aca4d 100644 --- a/src/MeoAssistant/GeneralConfiger.h +++ b/src/MeoAssistant/GeneralConfiger.h @@ -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; // 点击随机延时上限:每次点击操作会进行随机延时 diff --git a/src/MeoAssistant/StageDropsTaskPlugin.cpp b/src/MeoAssistant/StageDropsTaskPlugin.cpp index 24c553f7bd..83de49d00f 100644 --- a/src/MeoAssistant/StageDropsTaskPlugin.cpp +++ b/src/MeoAssistant/StageDropsTaskPlugin.cpp @@ -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);