diff --git a/docs/en-us/protocol/integration.md b/docs/en-us/protocol/integration.md index f7bfa78aa9..31dd54ea41 100644 --- a/docs/en-us/protocol/integration.md +++ b/docs/en-us/protocol/integration.md @@ -56,6 +56,8 @@ Appends a task. // Corresponding task parameters { "enable": bool, // Whether to enable this task, optional, true by default + "client_type": string, // Client version, required, no execution if left blank + // Options: "Official" | "Bilibili" | "txwy" | "YoStarEN" | "YoStarJP" | "YoStarKR" } ``` diff --git a/docs/ja-jp/protocol/integration.md b/docs/ja-jp/protocol/integration.md index 226ac99bbe..2f412b9e38 100644 --- a/docs/ja-jp/protocol/integration.md +++ b/docs/ja-jp/protocol/integration.md @@ -64,6 +64,8 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p // 対応するタスクのパラメータ { "enable": bool, // このタスクを有効にするかどうか、オプション、デフォルトは true + "client_type": string, // クライアントのバージョンは必須です。空白を入力すると実行されません。 + // オプション:"Official" | "Bilibili" | "txwy" | "YoStarEN" | "YoStarJP" | "YoStarKR" } ``` diff --git a/docs/ko-kr/protocol/integration.md b/docs/ko-kr/protocol/integration.md index 5da1594b20..c012f187df 100644 --- a/docs/ko-kr/protocol/integration.md +++ b/docs/ko-kr/protocol/integration.md @@ -56,6 +56,8 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p // 해당 작업 매개변수 { "enable": bool, // 이 작업을 활성화할지 여부, 선택 사항, 기본값은 true + "client_type": string, // 클라이언트 버전 필수이며, 빈칸을 채워주시면 실행되지 않습니다. + // 옵션: "Official" | "Bilibili" | "txwy" | "YoStarEN" | "YoStarJP" | "YoStarKR" } ``` diff --git a/docs/zh-cn/protocol/integration.md b/docs/zh-cn/protocol/integration.md index c4c11791b9..ae0491b663 100644 --- a/docs/zh-cn/protocol/integration.md +++ b/docs/zh-cn/protocol/integration.md @@ -59,7 +59,9 @@ AsstTaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const cha ```json // 对应的任务参数 { - "enable": bool, // 是否启用本任务,可选,默认为 true + "enable": bool, // 是否启用本任务,可选,预设为 true + "client_type": string, // 客户端版本,必选,填空则不执行 + // 选项:"Official" | "Bilibili" | "txwy" | "YoStarEN" | "YoStarJP" | "YoStarKR" } ``` diff --git a/docs/zh-tw/protocol/integration.md b/docs/zh-tw/protocol/integration.md index 104c13affa..25c4d66d9c 100644 --- a/docs/zh-tw/protocol/integration.md +++ b/docs/zh-tw/protocol/integration.md @@ -59,6 +59,8 @@ AsstTaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const cha // 對應的任務參數 { "enable": bool, // 是否啟用本任務,可選,預設為 true + "client_type": string, // 用戶端版本,必選,填空則不執行 + // 選項:"Official" | "Bilibili" | "txwy" | "YoStarEN" | "YoStarJP" | "YoStarKR" } ``` diff --git a/resource/config.json b/resource/config.json index 762c11d51d..002c1c7d5a 100644 --- a/resource/config.json +++ b/resource/config.json @@ -54,13 +54,13 @@ "maxDebugFileNum": 1000 } }, - "intent": { - "Official": "com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "Bilibili": "com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext", - "YoStarEN": "com.YoStarEN.Arknights/com.u8.sdk.U8UnityContext", - "YoStarJP": "com.YoStarJP.Arknights/com.u8.sdk.U8UnityContext", - "YoStarKR": "com.YoStarKR.Arknights/com.u8.sdk.U8UnityContext", - "txwy": "tw.txwy.and.arknights/com.u8.sdk.U8UnityContext" + "packageName": { + "Official": "com.hypergryph.arknights", + "Bilibili": "com.hypergryph.arknights.bilibili", + "YoStarEN": "com.YoStarEN.Arknights", + "YoStarJP": "com.YoStarJP.Arknights", + "YoStarKR": "com.YoStarKR.Arknights", + "txwy": "tw.txwy.and.arknights" }, "connection": [ { @@ -69,26 +69,26 @@ "addressRegex": "(.+)\tdevice", "connect": "[Adb] connect [AdbSerial]", "uuid": "[Adb] -s [AdbSerial] shell settings get secure android_id", - "click": "[Adb] -s [AdbSerial] shell input tap [x] [y]", - "swipe": "[Adb] -s [AdbSerial] shell input swipe [x1] [y1] [x2] [y2] [duration]", - "pressEsc": "[Adb] -s [AdbSerial] shell input keyevent 111", + "version": "[Adb] -s [AdbSerial] shell getprop ro.build.version.release", "display": "[Adb] -s [AdbSerial] shell \"dumpsys window displays | grep -o -E cur=+[^\\ ]+ | grep -o -E [0-9]+\"", "displayFormat": "%d%d", - "screencapRawByNC": "[Adb] -s [AdbSerial] exec-out \"screencap | nc -w 3 [NcAddress] [NcPort]\"", "ncAddress": "[Adb] -s [AdbSerial] shell \" cat /proc/net/arp | grep : \"", - "screencapRawWithGzip": "[Adb] -s [AdbSerial] exec-out \"screencap | gzip -1\"", - "screencapEncode": "[Adb] -s [AdbSerial] exec-out screencap -p", - "release": "[Adb] kill-server", - "start": "[Adb] -s [AdbSerial] shell am start -n [Intent]", - "stop": "[Adb] -s [AdbSerial] shell \"PACKAGE_NAME=$(dumpsys activity activities 2>/dev/null | grep -i -o -E 'packageName=.+arknights' 2>/dev/null | grep -i -o -E '[^= ]*arknights[^ /]*' | head -n 1); if [ -n \\\"$PACKAGE_NAME\\\" ]; then echo \\\"Closing $PACKAGE_NAME\\\"; am force-stop $PACKAGE_NAME; else echo \\\"app not running or arknights package name not found\\\"; fi\"", "abilist": "[Adb] -s [AdbSerial] shell getprop ro.product.cpu.abilist", - "version": "[Adb] -s [AdbSerial] shell getprop ro.build.version.release", "orientation": "[Adb] -s [AdbSerial] shell \"dumpsys input | grep SurfaceOrientation | grep -m 1 -o -E [0-9]\"", "pushMinitouch": "[Adb] -s [AdbSerial] push \"[minitouchLocalPath]\" \"/data/local/tmp/[minitouchWorkingFile]\"", "chmodMinitouch": "[Adb] -s [AdbSerial] shell chmod 700 \"/data/local/tmp/[minitouchWorkingFile]\"", "callMinitouch": "[Adb] -s [AdbSerial] shell \"/data/local/tmp/[minitouchWorkingFile]\" -i", "callMaatouch": "[Adb] -s [AdbSerial] shell \"export CLASSPATH=/data/local/tmp/[minitouchWorkingFile]; app_process /data/local/tmp com.shxyke.MaaTouch.App\"", - "back_to_home": "[Adb] -s [AdbSerial] shell input keyevent HOME" + "screencapRawByNC": "[Adb] -s [AdbSerial] exec-out \"screencap | nc -w 3 [NcAddress] [NcPort]\"", + "screencapRawWithGzip": "[Adb] -s [AdbSerial] exec-out \"screencap | gzip -1\"", + "screencapEncode": "[Adb] -s [AdbSerial] exec-out screencap -p", + "click": "[Adb] -s [AdbSerial] shell input tap [x] [y]", + "swipe": "[Adb] -s [AdbSerial] shell input swipe [x1] [y1] [x2] [y2] [duration]", + "start": "[Adb] -s [AdbSerial] shell am start -n [PackageName]/com.u8.sdk.U8UnityContext", + "stop": "[Adb] -s [AdbSerial] shell am force-stop [PackageName]", + "back_to_home": "[Adb] -s [AdbSerial] shell input keyevent HOME", + "release": "[Adb] kill-server", + "pressEsc": "[Adb] -s [AdbSerial] shell input keyevent 111" }, { "configName": "CapWithShell", @@ -121,10 +121,10 @@ { "configName": "WSA", "baseConfig": "CapWithShell", - "displayId": "[Adb] -s [AdbSerial] shell \"dumpsys display | grep mUniqueId=virtual:com.microsoft.windows.systemapp:com.hypergryph.arknights\"", + "display": "[Adb] -s [AdbSerial] shell \"wm size -d [DisplayId] | grep -o -E [0-9]+\"", + "displayId": "[Adb] -s [AdbSerial] shell \"dumpsys display | grep mUniqueId=virtual:com.microsoft.windows.systemapp:[PackageName]\"", "click": "[Adb] -s [AdbSerial] shell input -d [DisplayId] tap [x] [y]", - "swipe": "[Adb] -s [AdbSerial] shell input -d [DisplayId] swipe [x1] [y1] [x2] [y2] [duration]", - "display": "[Adb] -s [AdbSerial] shell \"wm size -d [DisplayId] | grep -o -E [0-9]+\"" + "swipe": "[Adb] -s [AdbSerial] shell input -d [DisplayId] swipe [x1] [y1] [x2] [y2] [duration]" }, { "configName": "Compatible", @@ -140,18 +140,16 @@ "configName": "CompatMac", "baseConfig": "Compatible", "ncAddress": "[Adb] -s [AdbSerial] shell \"cat /proc/net/arp | grep : | sort\"", - "stop": "[Adb] -s [AdbSerial] shell 'PACKAGE_NAME=$(dumpsys activity activities 2>/dev/null | grep -E \"(packageName|Activities)=[^\\n]+rknights\" 2>/dev/null | grep -i -o -E \"[^= ]*rknights[^ /\\n]*\" | head -n 1); if [ -n \"$PACKAGE_NAME\" ]; then echo \"Closing $PACKAGE_NAME\"; am force-stop $PACKAGE_NAME; else echo \"app not running or arknights package name not found\"; fi'", "screencapRawWithGzip": "" }, { "configName": "CompatPOSIXShell", - "baseConfig": "General", - "stop": "[Adb] -s [AdbSerial] shell 'PACKAGE_NAME=$(dumpsys activity activities 2>/dev/null | grep -E \"(packageName|Activities)=[^\\n]+rknights\" 2>/dev/null | grep -i -o -E \"[^= ]*rknights[^ /\\n]*\" | head -n 1); if [ -n \"$PACKAGE_NAME\" ]; then echo \"Closing $PACKAGE_NAME\"; am force-stop $PACKAGE_NAME; else echo \"app not running or arknights package name not found\"; fi'" + "baseConfig": "General" }, { "configName": "Waydroid", "baseConfig": "CompatPOSIXShell", - "start": "[Adb] -s [AdbSerial] shell am start --windowingMode 4 -n [Intent]", + "start": "[Adb] -s [AdbSerial] shell am start --windowingMode 4 -n [PackageName]/com.u8.sdk.U8UnityContext", "screencapRawWithGzip": "[Adb] -s [AdbSerial] exec-out \"screencap 2>/dev/null | gzip -1\"", "screencapEncode": "[Adb] -s [AdbSerial] exec-out \"screencap -p 2>/dev/null\"" } diff --git a/src/MaaCore/Config/GeneralConfig.cpp b/src/MaaCore/Config/GeneralConfig.cpp index 51b0e57fdd..f0f1d0a408 100644 --- a/src/MaaCore/Config/GeneralConfig.cpp +++ b/src/MaaCore/Config/GeneralConfig.cpp @@ -74,8 +74,8 @@ bool asst::GeneralConfig::parse(const json::value& json) m_options.debug.max_debug_file_num = options_json.get("debug", "maxDebugFileNum", 1000); } - for (const auto& [client_type, intent_name] : json.at("intent").as_object()) { - m_intent_name[client_type] = intent_name.as_string(); + for (const auto& [client_type, package_name] : json.at("packageName").as_object()) { + m_package_name[client_type] = package_name.as_string(); } for (const auto& cfg_json : json.at("connection").as_array()) { diff --git a/src/MaaCore/Config/GeneralConfig.h b/src/MaaCore/Config/GeneralConfig.h index 9cd9f31393..054e95b29a 100644 --- a/src/MaaCore/Config/GeneralConfig.h +++ b/src/MaaCore/Config/GeneralConfig.h @@ -115,9 +115,9 @@ public: } } - std::optional get_intent_name(const std::string& client_type) const + std::optional get_package_name(const std::string& client_type) const { - if (auto iter = m_intent_name.find(client_type); iter != m_intent_name.cend()) { + if (auto iter = m_package_name.find(client_type); iter != m_package_name.cend()) { return iter->second; } return std::nullopt; @@ -131,7 +131,7 @@ protected: std::string m_version; Options m_options; std::unordered_map m_adb_cfg; - std::unordered_map m_intent_name; + std::unordered_map m_package_name; }; inline static auto& Config = GeneralConfig::get_instance(); diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index a015bfe09e..132a813e76 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -244,17 +244,27 @@ bool asst::AdbController::start_game(const std::string& client_type) if (client_type.empty()) { return false; } - auto intent_name = Config.get_intent_name(client_type); - if (!intent_name) { + auto package_name = Config.get_package_name(client_type); + if (!package_name) { return false; } - std::string cur_cmd = utils::string_replace_all(m_adb.start, "[Intent]", intent_name.value()); + std::string cur_cmd = + utils::string_replace_all(m_adb.start, "[PackageName]", package_name.value()); return call_command(cur_cmd).has_value(); } -bool asst::AdbController::stop_game() +bool asst::AdbController::stop_game(const std::string& client_type) { - return call_command(m_adb.stop).has_value(); + if (client_type.empty()) { + return false; + } + auto package_name = Config.get_package_name(client_type); + if (!package_name) { + return false; + } + std::string cur_cmd = + utils::string_replace_all(m_adb.stop, "[PackageName]", package_name.value()); + return call_command(cur_cmd).has_value(); } bool asst::AdbController::click(const Point& p) diff --git a/src/MaaCore/Controller/AdbController.h b/src/MaaCore/Controller/AdbController.h index 198862b776..bebbbf4150 100644 --- a/src/MaaCore/Controller/AdbController.h +++ b/src/MaaCore/Controller/AdbController.h @@ -44,7 +44,7 @@ public: virtual bool screencap(cv::Mat& image_payload, bool allow_reconnect = false) override; virtual bool start_game(const std::string& client_type) override; - virtual bool stop_game() override; + virtual bool stop_game(const std::string& client_type) override; virtual bool click(const Point& p) override; diff --git a/src/MaaCore/Controller/Controller.cpp b/src/MaaCore/Controller/Controller.cpp index 881367333e..d23a2e3fca 100644 --- a/src/MaaCore/Controller/Controller.cpp +++ b/src/MaaCore/Controller/Controller.cpp @@ -155,10 +155,10 @@ bool asst::Controller::start_game(const std::string& client_type) return m_controller->start_game(client_type); } -bool asst::Controller::stop_game() +bool asst::Controller::stop_game(const std::string& client_type) { CHECK_EXIST(m_controller, false); - return m_controller->stop_game(); + return m_controller->stop_game(client_type); } bool asst::Controller::click(const Point& p) diff --git a/src/MaaCore/Controller/Controller.h b/src/MaaCore/Controller/Controller.h index c6f6c3e9cb..e1204f7879 100644 --- a/src/MaaCore/Controller/Controller.h +++ b/src/MaaCore/Controller/Controller.h @@ -65,7 +65,7 @@ public: bool screencap(bool allow_reconnect = false); bool start_game(const std::string& client_type); - bool stop_game(); + bool stop_game(const std::string& client_type); bool click(const Point& p); bool click(const Rect& rect); diff --git a/src/MaaCore/Controller/ControllerAPI.h b/src/MaaCore/Controller/ControllerAPI.h index 989e8c3c2f..a7f70b96d3 100644 --- a/src/MaaCore/Controller/ControllerAPI.h +++ b/src/MaaCore/Controller/ControllerAPI.h @@ -41,7 +41,7 @@ public: virtual bool screencap(cv::Mat& image_payload, bool allow_reconnect = false) = 0; virtual bool start_game(const std::string& client_type) = 0; - virtual bool stop_game() = 0; + virtual bool stop_game(const std::string& client_type) = 0; virtual bool click(const Point& p) = 0; diff --git a/src/MaaCore/Controller/MaaThriftController.cpp b/src/MaaCore/Controller/MaaThriftController.cpp index 15d2d16300..c7ca1949cc 100644 --- a/src/MaaCore/Controller/MaaThriftController.cpp +++ b/src/MaaCore/Controller/MaaThriftController.cpp @@ -288,13 +288,13 @@ bool asst::MaaThriftController::start_game(const std::string& client_type) if (client_type.empty()) { return false; } - auto intent_name = Config.get_intent_name(client_type); - if (!intent_name) { + auto package_name = Config.get_package_name(client_type); + if (!package_name) { return false; } try { - return client_->start_game(*intent_name); + return client_->start_game(*package_name); } catch (const std::exception& e) { Log.error("Cannot start game:", e.what()); diff --git a/src/MaaCore/Controller/PlayToolsController.cpp b/src/MaaCore/Controller/PlayToolsController.cpp index 8b5b99e7c5..e9bc6b78de 100644 --- a/src/MaaCore/Controller/PlayToolsController.cpp +++ b/src/MaaCore/Controller/PlayToolsController.cpp @@ -102,7 +102,7 @@ bool asst::PlayToolsController::start_game(const std::string& client_type [[mayb return true; } -bool asst::PlayToolsController::stop_game() +bool asst::PlayToolsController::stop_game(const std::string& client_type [[maybe_unused]]) { try { constexpr char request[6] = { 0, 4, 'T', 'E', 'R', 'M' }; @@ -145,7 +145,7 @@ bool asst::PlayToolsController::swipe( } Log.trace("PlayTools swipe", p1, p2, duration, extra_swipe, slope_in, slope_out); - + toucher_down(p1); auto cubic_spline = [](double slope_0, double slope_1, double t) { diff --git a/src/MaaCore/Controller/PlayToolsController.h b/src/MaaCore/Controller/PlayToolsController.h index ce157d3153..38ecfecc19 100644 --- a/src/MaaCore/Controller/PlayToolsController.h +++ b/src/MaaCore/Controller/PlayToolsController.h @@ -38,7 +38,7 @@ public: virtual bool screencap(cv::Mat& image_payload, bool allow_reconnect = false) override; virtual bool start_game(const std::string& client_type) override; - virtual bool stop_game() override; + virtual bool stop_game(const std::string& client_type) override; virtual bool click(const Point& p) override; diff --git a/src/MaaCore/Task/Interface/CloseDownTask.cpp b/src/MaaCore/Task/Interface/CloseDownTask.cpp index b48db26470..0a9c06e221 100644 --- a/src/MaaCore/Task/Interface/CloseDownTask.cpp +++ b/src/MaaCore/Task/Interface/CloseDownTask.cpp @@ -2,11 +2,22 @@ #include +#include "Config/GeneralConfig.h" #include "Task/Miscellaneous/StopGameTaskPlugin.h" #include "Task/ProcessTask.h" asst::CloseDownTask::CloseDownTask(const AsstCallback& callback, Assistant* inst) : InterfaceTask(callback, inst, TaskType) + , m_stop_game_task_ptr(std::make_shared(m_callback, m_inst, TaskType)) { - m_subtasks.emplace_back(std::make_shared(m_callback, m_inst, TaskType)); + m_subtasks.emplace_back(m_stop_game_task_ptr); +} + +bool asst::CloseDownTask::set_params(const json::value& params) +{ + std::string client_type = params.get("client_type", std::string()); + + m_stop_game_task_ptr->set_client_type(client_type); + + return true; } diff --git a/src/MaaCore/Task/Interface/CloseDownTask.h b/src/MaaCore/Task/Interface/CloseDownTask.h index 656a6b4ba4..d68920ca50 100644 --- a/src/MaaCore/Task/Interface/CloseDownTask.h +++ b/src/MaaCore/Task/Interface/CloseDownTask.h @@ -3,12 +3,21 @@ namespace asst { - class CloseDownTask final : public InterfaceTask - { - public: - inline static constexpr std::string_view TaskType = "CloseDown"; +class StopGameTaskPlugin; +class ProcessTask; - CloseDownTask(const AsstCallback& callback, Assistant* inst); - virtual ~CloseDownTask() override = default; - }; +class CloseDownTask final : public InterfaceTask +{ +public: + inline static constexpr std::string_view TaskType = "CloseDown"; + + CloseDownTask(const AsstCallback& callback, Assistant* inst); + virtual ~CloseDownTask() override = default; + + bool set_params(const json::value& params) override; + +private: + std::shared_ptr m_stop_game_task_ptr = nullptr; + std::shared_ptr m_close_down_task_ptr = nullptr; +}; } diff --git a/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.cpp b/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.cpp index bd52ef5562..f9e736e70c 100644 --- a/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.cpp +++ b/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.cpp @@ -6,5 +6,14 @@ using namespace asst; bool StopGameTaskPlugin::_run() { - return ctrler()->stop_game(); + if (m_client_type.empty()) { + return false; + } + return ctrler()->stop_game(m_client_type); +} + +StopGameTaskPlugin& StopGameTaskPlugin::set_client_type(std::string client_type) noexcept +{ + m_client_type = std::move(client_type); + return *this; } diff --git a/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.h b/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.h index 77b26d937b..7f0725ba33 100644 --- a/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.h +++ b/src/MaaCore/Task/Miscellaneous/StopGameTaskPlugin.h @@ -5,20 +5,26 @@ namespace asst { - class StopGameTaskPlugin : public AbstractTaskPlugin +inline static const std::string ClientTypeKey = "client_type"; + +class StopGameTaskPlugin : public AbstractTaskPlugin +{ +public: + using AbstractTaskPlugin::AbstractTaskPlugin; + virtual ~StopGameTaskPlugin() noexcept override = default; + + virtual bool verify(AsstMsg msg, const json::value& details) const override { - public: - using AbstractTaskPlugin::AbstractTaskPlugin; - virtual ~StopGameTaskPlugin() noexcept override = default; + std::ignore = msg; + std::ignore = details; + return true; + } - virtual bool verify(AsstMsg msg, const json::value& details) const override - { - std::ignore = msg; - std::ignore = details; - return true; - } + StopGameTaskPlugin& set_client_type(std::string client_type) noexcept; - protected: - bool _run() override; - }; +protected: + bool _run() override; + + std::string m_client_type = ""; +}; } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 6c97f50cd5..64d695e6d2 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -976,6 +976,10 @@ namespace MaaWpfGui.Main Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("FailedToOpenClient"), UiLogColor.Error); break; + case "StopGameTask": + Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CloseArknightsFailed"), UiLogColor.Error); + break; + case "AutoRecruitTask": { var whyStr = details.TryGetValue("why", out var why) ? why.ToString() : LocalizationHelper.GetString("ErrorOccurred"); @@ -2042,14 +2046,18 @@ namespace MaaWpfGui.Main return id != 0; } - public bool AsstAppendCloseDown() + public bool AsstAppendCloseDown(string clientType) { + var taskParams = new JObject + { + ["client_type"] = clientType, + }; if (!AsstStop()) { _logger.Warning("Failed to stop Asst"); } - AsstTaskId id = AsstAppendTaskWithEncoding("CloseDown"); + AsstTaskId id = AsstAppendTaskWithEncoding("CloseDown", taskParams); _latestTaskId[TaskType.CloseDown] = id; return id != 0; } @@ -2057,10 +2065,11 @@ namespace MaaWpfGui.Main /// /// CloseDown 任务。 /// + /// 客户端版本。 /// 是否成功。 - public bool AsstStartCloseDown() + public bool AsstStartCloseDown(string clientType) { - return AsstAppendCloseDown() && AsstStart(); + return AsstAppendCloseDown(clientType) && AsstStart(); } public bool AsstBackToHome() diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 184adeceaf..d3f76cb68d 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1333,7 +1333,7 @@ namespace MaaWpfGui.ViewModels.UI } } - private string _clientType = ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, "Official"); + private string _clientType = ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty); /// /// Gets or sets the client type. @@ -3392,7 +3392,7 @@ namespace MaaWpfGui.ViewModels.UI /// public static string UiVersion { get; } = _uiVersion == "0.0.1" ? "DEBUG VERSION" : _uiVersion; - private static string _resourceVersion = GetResourceVersionByClientType(ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, "Official")); + private static string _resourceVersion = GetResourceVersionByClientType(ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty)); /// /// Gets or sets the resource version. diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index f6dc757848..c49f0a65ea 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -124,7 +124,8 @@ namespace MaaWpfGui.ViewModels.UI } else if (actions.ExitArknights) { - if (!Instances.AsstProxy.AsstStartCloseDown()) + var mode = Instances.SettingsViewModel.ClientType; + if (!Instances.AsstProxy.AsstStartCloseDown(mode)) { AddLog(LocalizationHelper.GetString("CloseArknightsFailed"), UiLogColor.Error); } @@ -441,7 +442,8 @@ namespace MaaWpfGui.ViewModels.UI await Stop(); } - if (!Instances.AsstProxy.AsstAppendCloseDown()) + var mode = Instances.SettingsViewModel.ClientType; + if (!Instances.AsstProxy.AsstAppendCloseDown(mode)) { AddLog(LocalizationHelper.GetString("CloseArknightsFailed"), UiLogColor.Error); }