From af8f0718ba03cd7e7bcaea1d09119f7f3fb32eb9 Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 21 Nov 2022 23:25:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0adb=E8=A7=A6=E6=8E=A7?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/3.1-集成文档.md | 74 ++++++++++++++++++- docs/en-us/3.1-INTEGRATION.md | 66 +++++++++++++++++ include/AsstCaller.h | 20 +++-- resource/config.json | 2 + src/MeoAssistant/Assistant.cpp | 20 ++++- src/MeoAssistant/Assistant.h | 2 + src/MeoAssistant/AsstCaller.cpp | 31 ++++++-- src/MeoAssistant/Controller.cpp | 17 +++-- src/MeoAssistant/Controller.h | 2 +- src/MeoAssistant/Resource/GeneralConfiger.cpp | 1 + src/MeoAssistant/Resource/GeneralConfiger.h | 15 ++-- src/MeoAssistant/Utils/AsstTypes.h | 6 ++ src/MeoAsstGui/Helper/AsstProxy.cs | 66 +++++++++++------ .../Resources/Localizations/en-us.xaml | 1 + .../Resources/Localizations/zh-cn.xaml | 1 + .../ConnectSettingsUserControl.xaml | 10 ++- .../ViewModels/SettingsViewModel.cs | 14 ++++ .../ViewModels/TaskQueueViewModel.cs | 1 + 18 files changed, 291 insertions(+), 58 deletions(-) diff --git a/docs/3.1-集成文档.md b/docs/3.1-集成文档.md index 567d441542..472bd4b0b6 100644 --- a/docs/3.1-集成文档.md +++ b/docs/3.1-集成文档.md @@ -7,7 +7,7 @@ #### 接口原型 ```c++ -TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* params); +AsstTaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* params); ``` #### 接口说明 @@ -16,7 +16,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p #### 返回值 -- `TaskId` +- `AsstTaskId` 若添加成功,返回该任务 ID, 可用于后续设置任务参数; 若添加失败,返回 0 @@ -233,7 +233,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p #### 接口原型 ```c++ -bool ASSTAPI AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params); +bool ASSTAPI AsstSetTaskParams(AsstHandle handle, AsstTaskId id, const char* params); ``` #### 接口说明 @@ -249,8 +249,74 @@ bool ASSTAPI AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params) - `AsstHandle handle` 实例句柄 -- `TaskId task` +- `AsstTaskId task` 任务 ID, `AsstAppendTask` 接口的返回值 - `const char* params` 任务参数,json string,与 `AsstAppendTask` 接口相同。 未标注“不支持运行中设置”的字段都支持实时修改;否则若当前任务正在运行,会忽略对应的字段 + +### `AsstSetProcessOption` + +#### 接口原型 + +```c++ +bool ASSTAPI AsstSetProcessOption(AsstProcessOptionKey key, const char* value); +``` + +#### 接口说明 + +设置进程级参数 + +#### 返回值 + +- `bool` + 返回是否设置成功 + +#### 参数说明 + +- `AsstProcessOptionKey key` + 键 +- `const char* value` + 值 + +##### 键值一览 + +暂无 + +### `AsstSetProcessOption` + +#### 接口原型 + +```c++ +bool ASSTAPI AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, const char* value); +``` + +#### 接口说明 + +设置实例级参数 + +#### 返回值 + +- `bool` + 返回是否设置成功 + +#### 参数说明 + +- `AsstHandle handle` + 实例句柄 +- `AsstInstanceOptionKey key` + 键 +- `const char* value` + 值 + +##### 键值一览 + +```jsonc + enum InstanceOptionKey + { + Invalid = 0, + MinitouchEnabled = 1, // 是否启用 minitouch + // 开了也不代表就一定能用,有可能设备不支持等 + // "1" 开,"0" 关 + }; +``` diff --git a/docs/en-us/3.1-INTEGRATION.md b/docs/en-us/3.1-INTEGRATION.md index 476f6c362a..b88640ad1c 100644 --- a/docs/en-us/3.1-INTEGRATION.md +++ b/docs/en-us/3.1-INTEGRATION.md @@ -242,3 +242,69 @@ Set task parameters - `const char* params` Task parameter in JSON, same as `AsstAppendTask` For those fields that do not mention "Editing in run-time is not supported" can be changed during run-time. Otherwise these changes will be ignored when the task is running. + +### `AsstSetProcessOption` + +#### Prototype + +```c++ +bool ASSTAPI AsstSetProcessOption(AsstProcessOptionKey key, const char* value); +``` + +#### Description + +Set process-level parameters + +#### Return Value + +- `bool` + Is the setup successful + +#### Parameter Description + +- `AsstProcessOptionKey key` + key +- `const char* value` + value + +##### List of Key and value + +None + +### `AsstSetProcessOption` + +#### Prototype + +```c++ +bool ASSTAPI AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, const char* value); +``` + +#### Description + +Set instance-level parameters + +#### Return Value + +- `bool` + Is the setup successful + +#### Parameter Description + +- `AsstHandle handle` + handle +- `AsstInstanceOptionKey key` + key +- `const char* value` + value + +##### List of Key and value + +```jsonc + enum InstanceOptionKey + { + Invalid = 0, + MinitouchEnabled = 1, // Is minitouch enabled + // If you can't use minitouch, it's useless to turn it on. + // "1" - on,"0" - off + }; +``` diff --git a/include/AsstCaller.h b/include/AsstCaller.h index 76900c7ad1..2b4ddcf71a 100644 --- a/include/AsstCaller.h +++ b/include/AsstCaller.h @@ -22,30 +22,36 @@ extern "C" #else typedef void* AsstHandle; #endif - typedef int TaskId; + typedef int AsstTaskId; + typedef int AsstProcessOptionKey; + typedef int AsstInstanceOptionKey; + typedef unsigned long long AsstSize; + typedef void(ASST_CALL* AsstApiCallback)(int msg, const char* detail_json, void* custom_arg); bool ASSTAPI AsstSetUserDir(const char* path); bool ASSTAPI AsstLoadResource(const char* path); + bool ASSTAPI AsstSetProcessOption(AsstProcessOptionKey key, const char* value); AsstHandle ASSTAPI AsstCreate(); AsstHandle ASSTAPI AsstCreateEx(AsstApiCallback callback, void* custom_arg); void ASSTAPI AsstDestroy(AsstHandle handle); + bool ASSTAPI AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, const char* value); bool ASSTAPI AsstConnect(AsstHandle handle, const char* adb_path, const char* address, const char* config); - TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* params); - bool ASSTAPI AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params); + AsstTaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* params); + bool ASSTAPI AsstSetTaskParams(AsstHandle handle, AsstTaskId id, const char* params); bool ASSTAPI AsstStart(AsstHandle handle); bool ASSTAPI AsstStop(AsstHandle handle); bool ASSTAPI AsstRunning(AsstHandle handle); bool ASSTAPI AsstClick(AsstHandle handle, int x, int y); - unsigned long long ASSTAPI AsstGetImage(AsstHandle handle, void* buff, unsigned long long buff_size); - unsigned long long ASSTAPI AsstGetUUID(AsstHandle handle, char* buff, unsigned long long buff_size); - unsigned long long ASSTAPI AsstGetTasksList(AsstHandle handle, TaskId* buff, unsigned long long buff_size); - unsigned long long ASSTAPI AsstGetNullSize(); + AsstSize ASSTAPI AsstGetImage(AsstHandle handle, void* buff, AsstSize buff_size); + AsstSize ASSTAPI AsstGetUUID(AsstHandle handle, char* buff, AsstSize buff_size); + AsstSize ASSTAPI AsstGetTasksList(AsstHandle handle, AsstTaskId* buff, AsstSize buff_size); + AsstSize ASSTAPI AsstGetNullSize(); ASSTAPI_PORT const char* ASST_CALL AsstGetVersion(); void ASSTAPI AsstLog(const char* level, const char* message); diff --git a/resource/config.json b/resource/config.json index 1a04dda4a6..8c8f5c774c 100644 --- a/resource/config.json +++ b/resource/config.json @@ -12,6 +12,8 @@ "adbExtraSwipeDist_Doc": "额外的滑动距离:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来", "adbExtraSwipeDuration": 500, "adbExtraSwipeDuration_Doc": "额外的滑动持续时间:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来。若小于0,则关闭额外滑动功能", + "adbSwipeDurationMultiplier": 10.0, + "adbSwipeDurationMultiplier_Doc": "adb 滑动延迟倍数", "minitouchExtraSwipeDist": 100, "minitouchExtraSwipeDuration": 200, "penguinReport": { diff --git a/src/MeoAssistant/Assistant.cpp b/src/MeoAssistant/Assistant.cpp index de06ccc42f..be02bd6c83 100644 --- a/src/MeoAssistant/Assistant.cpp +++ b/src/MeoAssistant/Assistant.cpp @@ -33,7 +33,6 @@ Assistant::Assistant(AsstApiCallback callback, void* callback_arg) : m_callback( m_status = std::make_shared(); m_ctrler = std::make_shared(task_callback, static_cast(this)); m_ctrler->set_exit_flag(&m_thread_idle); - m_ctrler->set_minitouch_enabled(true); m_working_thread = std::thread(&Assistant::working_proc, this); m_msg_thread = std::thread(&Assistant::msg_proc, this); @@ -56,6 +55,25 @@ Assistant::~Assistant() } } +bool asst::Assistant::set_instance_option(InstanceOptionKey key, const std::string& value) +{ + switch (key) { + case InstanceOptionKey::MinitouchEnabled: + if (value == "0") { + m_ctrler->set_minitouch_enabled(false); + return true; + } + else if (value == "1") { + m_ctrler->set_minitouch_enabled(true); + return true; + } + else { + return false; + } + } + return false; +} + bool asst::Assistant::connect(const std::string& adb_path, const std::string& address, const std::string& config) { LogTraceFunction; diff --git a/src/MeoAssistant/Assistant.h b/src/MeoAssistant/Assistant.h index 4d9e578e59..b0dc16621c 100644 --- a/src/MeoAssistant/Assistant.h +++ b/src/MeoAssistant/Assistant.h @@ -31,6 +31,8 @@ namespace asst Assistant(AsstApiCallback callback = nullptr, void* callback_arg = nullptr); ~Assistant(); + // 设置实例级参数 + bool set_instance_option(InstanceOptionKey key, const std::string& value); // 连接adb bool connect(const std::string& adb_path, const std::string& address, const std::string& config); diff --git a/src/MeoAssistant/AsstCaller.cpp b/src/MeoAssistant/AsstCaller.cpp index 3a439f2138..3d198e50be 100644 --- a/src/MeoAssistant/AsstCaller.cpp +++ b/src/MeoAssistant/AsstCaller.cpp @@ -13,7 +13,7 @@ #include "Utils/UserDir.hpp" #include "Utils/Version.h" -static constexpr unsigned long long NullSize = static_cast(-1); +static constexpr AsstSize NullSize = static_cast(-1); #if 0 #if _MSC_VER @@ -56,6 +56,14 @@ bool AsstLoadResource(const char* path) return inited; } +bool AsstSetProcessOption(AsstProcessOptionKey key, const char* value) +{ + // TODO: 把 config.option 里的全实现一遍 + std::ignore = key; + std::ignore = value; + return false; +} + AsstHandle AsstCreate() { if (!inited) { @@ -82,6 +90,15 @@ void AsstDestroy(AsstHandle handle) handle = nullptr; } +bool AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, const char* value) +{ + if (handle == nullptr) { + return false; + } + + return handle->set_instance_option(static_cast(key), value); +} + bool AsstConnect(AsstHandle handle, const char* adb_path, const char* address, const char* config) { if (!inited || handle == nullptr) { @@ -118,7 +135,7 @@ bool AsstRunning(AsstHandle handle) return handle->running(); } -TaskId AsstAppendTask(AsstHandle handle, const char* type, const char* params) +AsstTaskId AsstAppendTask(AsstHandle handle, const char* type, const char* params) { if (!inited || handle == nullptr) { return 0; @@ -127,7 +144,7 @@ TaskId AsstAppendTask(AsstHandle handle, const char* type, const char* params) return handle->append_task(type, params ? params : ""); } -bool AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params) +bool AsstSetTaskParams(AsstHandle handle, AsstTaskId id, const char* params) { if (!inited || handle == nullptr) { return false; @@ -144,7 +161,7 @@ bool AsstClick(AsstHandle handle, int x, int y) return handle->ctrler_click(x, y); } -unsigned long long AsstGetImage(AsstHandle handle, void* buff, unsigned long long buff_size) +AsstSize AsstGetImage(AsstHandle handle, void* buff, AsstSize buff_size) { if (!inited || handle == nullptr || buff == nullptr) { return NullSize; @@ -158,7 +175,7 @@ unsigned long long AsstGetImage(AsstHandle handle, void* buff, unsigned long lon return data_size; } -unsigned long long AsstGetUUID(AsstHandle handle, char* buff, unsigned long long buff_size) +AsstSize AsstGetUUID(AsstHandle handle, char* buff, AsstSize buff_size) { if (!inited || handle == nullptr || buff == nullptr) { return NullSize; @@ -172,7 +189,7 @@ unsigned long long AsstGetUUID(AsstHandle handle, char* buff, unsigned long long return data_size; } -unsigned long long AsstGetTasksList(AsstHandle handle, TaskId* buff, unsigned long long buff_size) +AsstSize AsstGetTasksList(AsstHandle handle, AsstTaskId* buff, AsstSize buff_size) { if (!inited || handle == nullptr || buff == nullptr) { return NullSize; @@ -186,7 +203,7 @@ unsigned long long AsstGetTasksList(AsstHandle handle, TaskId* buff, unsigned lo return data_size; } -unsigned long long AsstGetNullSize() +AsstSize AsstGetNullSize() { return NullSize; } diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index f11acb8569..d001b1001c 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -1202,14 +1202,15 @@ bool asst::Controller::swipe_without_scale(const Point& p1, const Point& p2, int return toucher.up(); } else { - std::string cur_cmd = - utils::string_replace_all(m_adb.swipe, { - { "[x1]", std::to_string(x1) }, - { "[y1]", std::to_string(y1) }, - { "[x2]", std::to_string(x2) }, - { "[y2]", std::to_string(y2) }, - { "[duration]", duration <= 0 ? "" : std::to_string(duration) }, - }); + std::string duration_str = + duration <= 0 ? "" : std::to_string(static_cast(duration * opt.adb_swipe_duration_multiplier)); + std::string cur_cmd = utils::string_replace_all(m_adb.swipe, { + { "[x1]", std::to_string(x1) }, + { "[y1]", std::to_string(y1) }, + { "[x2]", std::to_string(x2) }, + { "[y2]", std::to_string(y2) }, + { "[duration]", duration_str }, + }); bool ret = call_command(cur_cmd).has_value(); // 额外的滑动:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来 diff --git a/src/MeoAssistant/Controller.h b/src/MeoAssistant/Controller.h index e342f53d5a..9e563d05a6 100644 --- a/src/MeoAssistant/Controller.h +++ b/src/MeoAssistant/Controller.h @@ -165,7 +165,7 @@ namespace asst } screencap_method = ScreencapMethod::UnknownYet; } m_adb; - bool m_minitouch_enabled = false; // 开关 + bool m_minitouch_enabled = true; // 开关 bool m_minitouch_avaiable = false; // 状态 #ifdef _WIN32 diff --git a/src/MeoAssistant/Resource/GeneralConfiger.cpp b/src/MeoAssistant/Resource/GeneralConfiger.cpp index 68fa5a4843..5ee58a8580 100644 --- a/src/MeoAssistant/Resource/GeneralConfiger.cpp +++ b/src/MeoAssistant/Resource/GeneralConfiger.cpp @@ -15,6 +15,7 @@ bool asst::GeneralConfiger::parse(const json::value& json) // m_options.print_window = options_json.at("printWindow").as_boolean(); m_options.adb_extra_swipe_dist = options_json.get("adbExtraSwipeDist", 100); m_options.adb_extra_swipe_duration = options_json.get("adbExtraSwipeDuration", -1); + m_options.adb_swipe_duration_multiplier = options_json.get("adbSwipeDurationMultiplier", 10.0); m_options.minitouch_extra_swipe_dist = options_json.get("minitouchExtraSwipeDist", 100); m_options.minitouch_extra_swipe_duration = options_json.get("minitouchExtraSwipeDuration", -1); m_options.penguin_report.cmd_format = options_json.get("penguinReport", "cmdFormat", std::string()); diff --git a/src/MeoAssistant/Resource/GeneralConfiger.h b/src/MeoAssistant/Resource/GeneralConfiger.h index c82bb2f86b..66e54a92a9 100644 --- a/src/MeoAssistant/Resource/GeneralConfiger.h +++ b/src/MeoAssistant/Resource/GeneralConfiger.h @@ -32,13 +32,14 @@ namespace asst int control_delay_lower = 0; // 点击随机延时下限:每次点击操作会进行随机延时 int control_delay_upper = 0; // 点击随机延时上限:每次点击操作会进行随机延时 // bool print_window = false;// 截图功能:开启后每次结算界面会截图到screenshot目录下 - int adb_extra_swipe_dist = 0; // 额外的滑动距离: - // adb有bug,同样的参数,偶尔会划得非常远。 - // 额外做一个短程滑动,把之前的停下来。 - int adb_extra_swipe_duration = -1; // 额外的滑动持续时间: - // adb有bug,同样的参数,偶尔会划得非常远。 - // 额外做一个短程滑动,把之前的停下来。 - // 若小于0,则关闭额外滑动功能。 + int adb_extra_swipe_dist = 0; // 额外的滑动距离: + // adb有bug,同样的参数,偶尔会划得非常远。 + // 额外做一个短程滑动,把之前的停下来。 + int adb_extra_swipe_duration = -1; // 额外的滑动持续时间: + // adb有bug,同样的参数,偶尔会划得非常远。 + // 额外做一个短程滑动,把之前的停下来。 + // 若小于0,则关闭额外滑动功能。 + double adb_swipe_duration_multiplier = 0; // adb 滑动持续时间倍数 int minitouch_extra_swipe_dist = 0; int minitouch_extra_swipe_duration = -1; PenguinReportCfg penguin_report; // 企鹅物流汇报: diff --git a/src/MeoAssistant/Utils/AsstTypes.h b/src/MeoAssistant/Utils/AsstTypes.h index 5a2b9242a2..20b35e3d41 100644 --- a/src/MeoAssistant/Utils/AsstTypes.h +++ b/src/MeoAssistant/Utils/AsstTypes.h @@ -29,6 +29,12 @@ namespace asst static constexpr double TemplThresholdDefault = 0.8; + enum class InstanceOptionKey + { + Invalid = 0, + MinitouchEnabled = 1, + }; + struct Point { Point() = default; diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 1c64574194..0299ceaf60 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -14,7 +14,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; @@ -29,7 +28,9 @@ namespace MeoAsstGui #pragma warning disable SA1135 // Using directives should be qualified using AsstHandle = IntPtr; - using TaskId = Int32; + using AsstInstanceOptionKey = Int32; + + using AsstTaskId = Int32; #pragma warning restore SA1135 // Using directives should be qualified @@ -80,6 +81,17 @@ namespace MeoAsstGui [DllImport("MeoAssistant.dll")] private static extern void AsstDestroy(AsstHandle handle); + [DllImport("MeoAssistant.dll")] + private static extern unsafe bool AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, byte* value); + + private static unsafe bool AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, string value) + { + fixed (byte* ptr1 = EncodeNullTerminatedUTF8(value)) + { + return AsstSetInstanceOption(handle, key, ptr1); + } + } + [DllImport("MeoAssistant.dll")] private static extern unsafe bool AsstConnect(AsstHandle handle, byte* adb_path, byte* address, byte* config); @@ -94,9 +106,9 @@ namespace MeoAsstGui } [DllImport("MeoAssistant.dll")] - private static extern unsafe TaskId AsstAppendTask(AsstHandle handle, byte* type, byte* task_params); + private static extern unsafe AsstTaskId AsstAppendTask(AsstHandle handle, byte* type, byte* task_params); - private static unsafe TaskId AsstAppendTask(AsstHandle handle, string type, string task_params) + private static unsafe AsstTaskId AsstAppendTask(AsstHandle handle, string type, string task_params) { fixed (byte* ptr1 = EncodeNullTerminatedUTF8(type), ptr2 = EncodeNullTerminatedUTF8(task_params)) @@ -106,9 +118,9 @@ namespace MeoAsstGui } [DllImport("MeoAssistant.dll")] - private static extern unsafe bool AsstSetTaskParams(AsstHandle handle, TaskId id, byte* task_params); + private static extern unsafe bool AsstSetTaskParams(AsstHandle handle, AsstTaskId id, byte* task_params); - private static unsafe bool AsstSetTaskParams(AsstHandle handle, TaskId id, string task_params) + private static unsafe bool AsstSetTaskParams(AsstHandle handle, AsstTaskId id, string task_params) { fixed (byte* ptr1 = EncodeNullTerminatedUTF8(task_params)) { @@ -499,7 +511,7 @@ namespace MeoAsstGui var finished_tasks = details["finished_tasks"] as JArray; if (finished_tasks.Count == 1) { - var unique_finished_task = (TaskId)finished_tasks[0]; + var unique_finished_task = (AsstTaskId)finished_tasks[0]; if (unique_finished_task == (_latestTaskId.TryGetValue(TaskType.Copilot, out var copilotTaskId) ? copilotTaskId : 0) || unique_finished_task == (_latestTaskId.TryGetValue(TaskType.RecruitCalc, out var recruitCalcTaskId) ? recruitCalcTaskId : 0) || unique_finished_task == (_latestTaskId.TryGetValue(TaskType.CloseDown, out var closeDownTaskId) ? closeDownTaskId : 0) @@ -1021,6 +1033,11 @@ namespace MeoAsstGui } } + public bool AsstSetInstanceOption(InstanceOptionKey key, string value) + { + return AsstSetInstanceOption(_handle, (AsstInstanceOptionKey)key, value); + } + /// /// 连接模拟器。 /// @@ -1090,13 +1107,13 @@ namespace MeoAsstGui return ret; } - private TaskId AsstAppendTaskWithEncoding(string type, JObject task_params = null) + private AsstTaskId AsstAppendTaskWithEncoding(string type, JObject task_params = null) { task_params = task_params ?? new JObject(); return AsstAppendTask(_handle, type, JsonConvert.SerializeObject(task_params)); } - private bool AsstSetTaskParamsWithEncoding(TaskId id, JObject task_params = null) + private bool AsstSetTaskParamsWithEncoding(AsstTaskId id, JObject task_params = null) { if (id == 0) { @@ -1124,7 +1141,7 @@ namespace MeoAsstGui Depot, } - private readonly Dictionary _latestTaskId = new Dictionary(); + private readonly Dictionary _latestTaskId = new Dictionary(); private JObject SerializeFightTaskParams(string stage, int max_medicine, int max_stone, int max_times, string drops_item_id, int drops_item_quantity) { @@ -1162,7 +1179,7 @@ namespace MeoAsstGui public bool AsstAppendFight(string stage, int max_medicine, int max_stone, int max_times, string drops_item_id, int drops_item_quantity, bool is_main_fight = true) { var task_params = SerializeFightTaskParams(stage, max_medicine, max_stone, max_times, drops_item_id, drops_item_quantity); - TaskId id = AsstAppendTaskWithEncoding("Fight", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Fight", task_params); if (is_main_fight) { _latestTaskId[TaskType.Fight] = id; @@ -1210,7 +1227,7 @@ namespace MeoAsstGui /// 是否成功。 public bool AsstAppendAward() { - TaskId id = AsstAppendTaskWithEncoding("Award"); + AsstTaskId id = AsstAppendTaskWithEncoding("Award"); _latestTaskId[TaskType.Award] = id; return id != 0; } @@ -1226,7 +1243,7 @@ namespace MeoAsstGui var task_params = new JObject(); task_params["client_type"] = client_type; task_params["start_game_enabled"] = enable; - TaskId id = AsstAppendTaskWithEncoding("StartUp", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("StartUp", task_params); _latestTaskId[TaskType.StartUp] = id; return id != 0; } @@ -1238,7 +1255,7 @@ namespace MeoAsstGui public bool AsstStartCloseDown() { AsstStop(); - TaskId id = AsstAppendTaskWithEncoding("CloseDown"); + AsstTaskId id = AsstAppendTaskWithEncoding("CloseDown"); _latestTaskId[TaskType.CloseDown] = id; return id != 0 && AsstStart(); } @@ -1249,7 +1266,7 @@ namespace MeoAsstGui /// 是否成功。 public bool AsstAppendVisit() { - TaskId id = AsstAppendTaskWithEncoding("Visit"); + AsstTaskId id = AsstAppendTaskWithEncoding("Visit"); _latestTaskId[TaskType.Visit] = id; return id != 0; } @@ -1269,7 +1286,7 @@ namespace MeoAsstGui task_params["buy_first"] = new JArray { first_list }; task_params["blacklist"] = new JArray { blacklist }; task_params["force_shopping_if_credit_full"] = force_shopping_if_credit_full; - TaskId id = AsstAppendTaskWithEncoding("Mall", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Mall", task_params); _latestTaskId[TaskType.Mall] = id; return id != 0; } @@ -1308,7 +1325,7 @@ namespace MeoAsstGui task_params["penguin_id"] = settings.PenguinId; task_params["server"] = settings.ServerType; - TaskId id = AsstAppendTaskWithEncoding("Recruit", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Recruit", task_params); _latestTaskId[TaskType.Recruit] = id; return id != 0; } @@ -1363,7 +1380,7 @@ namespace MeoAsstGui order, uses_of_drones, dorm_threshold, dorm_filter_not_stationed_enabled, dorm_drom_trust_enabled, originium_shard_auto_replenishment, is_custom, filename, plan_index); - TaskId id = AsstAppendTaskWithEncoding("Infrast", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Infrast", task_params); _latestTaskId[TaskType.Infrast] = id; return id != 0; } @@ -1449,7 +1466,7 @@ namespace MeoAsstGui task_params["core_char"] = core_char; } - TaskId id = AsstAppendTaskWithEncoding("Roguelike", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Roguelike", task_params); _latestTaskId[TaskType.Roguelike] = id; return id != 0; } @@ -1478,7 +1495,7 @@ namespace MeoAsstGui task_params["yituliu_id"] = settings.PenguinId; // 一图流说随便传个uuid就行,让client自己生成,所以先直接嫖一下企鹅的( task_params["server"] = settings.ServerType; - TaskId id = AsstAppendTaskWithEncoding("Recruit", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Recruit", task_params); _latestTaskId[TaskType.RecruitCalc] = id; return id != 0 && AsstStart(); } @@ -1490,7 +1507,7 @@ namespace MeoAsstGui public bool AsstStartDepot() { var task_params = new JObject(); - TaskId id = AsstAppendTaskWithEncoding("Depot", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Depot", task_params); _latestTaskId[TaskType.Depot] = id; return id != 0 && AsstStart(); } @@ -1508,7 +1525,7 @@ namespace MeoAsstGui task_params["stage_name"] = stage_name; task_params["filename"] = filename; task_params["formation"] = formation; - TaskId id = AsstAppendTaskWithEncoding("Copilot", task_params); + AsstTaskId id = AsstAppendTaskWithEncoding("Copilot", task_params); _latestTaskId[TaskType.Copilot] = id; return id != 0 && AsstStart(); } @@ -1623,6 +1640,11 @@ namespace MeoAsstGui /// SubTaskStopped, } + + public enum InstanceOptionKey + { + MinitouchEnabled = 1, + } } #pragma warning restore SA1121 // Use built-in type alias diff --git a/src/MeoAsstGui/Resources/Localizations/en-us.xaml b/src/MeoAsstGui/Resources/Localizations/en-us.xaml index 8ff71bb28b..4bb577a8a8 100644 --- a/src/MeoAsstGui/Resources/Localizations/en-us.xaml +++ b/src/MeoAsstGui/Resources/Localizations/en-us.xaml @@ -172,6 +172,7 @@ Emulator exec path Select Forced Replace ADB File + Compatibility Touch Mode (without minitouch) Addiction Command arguments I.S. Theme diff --git a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml index a7e9601d06..8d90334f01 100644 --- a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml +++ b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml @@ -172,6 +172,7 @@ 模拟器路径 选择 强制替换 ADB + 兼容性的触控模式(不使用 minitouch) 附加命令 肉鸽主题 diff --git a/src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml index 0c8c9dbd91..b06173cd4b 100644 --- a/src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/ConnectSettingsUserControl.xaml @@ -123,12 +123,20 @@ HorizontalAlignment="Center" />