From 012e8f828d974a8d269c5dd3a31c52382c67319e Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 21:01:02 +0800 Subject: [PATCH 01/26] update adb command --- resource/config.json | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/resource/config.json b/resource/config.json index 366d834b1d..f95362b4b3 100644 --- a/resource/config.json +++ b/resource/config.json @@ -30,7 +30,9 @@ "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" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "BlueStacks": { "devices": "[Adb] devices", @@ -43,7 +45,9 @@ "displayFormat": "cur=%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "MuMuEmulator": { "devices": "[Adb] devices", @@ -56,7 +60,9 @@ "displayFormat": "cur=%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "LDPlayer": { "devices": "[Adb] devices", @@ -69,7 +75,9 @@ "displayFormat": "cur=%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "Nox": { "devices": "[Adb] devices", @@ -82,7 +90,9 @@ "displayFormat": "cur=%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "XYAZ": { "devices": "[Adb] devices", @@ -95,7 +105,9 @@ "displayFormat": " init=%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "WSA": { "devices": "[Adb] devices", @@ -109,7 +121,9 @@ "displayFormat": "Physical size:%dx%d", "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap -d [DisplayId] | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -d [DisplayId] -p", - "release": "[Adb] kill-server" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "Compatible": { "devices": "[Adb] devices", @@ -122,7 +136,9 @@ "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" + "release": "[Adb] kill-server", + "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" } } } From d93321623a5c83e86a61cfff4d0eb59098f9b671 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 21:04:58 +0800 Subject: [PATCH 02/26] change name --- resource/config.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/resource/config.json b/resource/config.json index f95362b4b3..0f15d1bdb2 100644 --- a/resource/config.json +++ b/resource/config.json @@ -31,8 +31,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "BlueStacks": { "devices": "[Adb] devices", @@ -46,8 +46,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "MuMuEmulator": { "devices": "[Adb] devices", @@ -61,8 +61,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "LDPlayer": { "devices": "[Adb] devices", @@ -76,8 +76,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "Nox": { "devices": "[Adb] devices", @@ -91,8 +91,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "XYAZ": { "devices": "[Adb] devices", @@ -106,8 +106,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "WSA": { "devices": "[Adb] devices", @@ -122,8 +122,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap -d [DisplayId] | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -d [DisplayId] -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" }, "Compatible": { "devices": "[Adb] devices", @@ -137,8 +137,8 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "openOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "openBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" } } } From c840db0c4ece1da6b907e2d5247c868d831f1f5f Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 21:52:53 +0800 Subject: [PATCH 03/26] refract start command --- resource/config.json | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/resource/config.json b/resource/config.json index 0f15d1bdb2..03f138bdd2 100644 --- a/resource/config.json +++ b/resource/config.json @@ -31,8 +31,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "BlueStacks": { "devices": "[Adb] devices", @@ -46,8 +45,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "MuMuEmulator": { "devices": "[Adb] devices", @@ -61,8 +59,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "LDPlayer": { "devices": "[Adb] devices", @@ -76,8 +73,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "Nox": { "devices": "[Adb] devices", @@ -91,8 +87,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "XYAZ": { "devices": "[Adb] devices", @@ -106,8 +101,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "WSA": { "devices": "[Adb] devices", @@ -122,8 +116,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] shell \"screencap -d [DisplayId] | gzip -1\"", "screencapEncode": "[Adb] -s [Address] shell screencap -d [DisplayId] -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" }, "Compatible": { "devices": "[Adb] devices", @@ -137,8 +130,7 @@ "screencapRawWithGzip": "[Adb] -s [Address] exec-out \"screencap | gzip -1\"", "screencapEncode": "[Adb] -s [Address] exec-out screencap -p", "release": "[Adb] kill-server", - "startOfficial": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights/com.u8.sdk.U8UnityContext", - "startBilibili": "[Adb] -s [Address] shell am start -n com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + "start": "[Adb] -s [Address] shell am start -n [Intent]" } } } From 22f7d778060ec48e58e517e51924278b585088e0 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 23:15:03 +0800 Subject: [PATCH 04/26] underlying codes implement --- resource/config.json | 4 ++++ src/MeoAssistant/AsstTypes.h | 6 ++++++ src/MeoAssistant/Controller.cpp | 16 ++++++++++++++++ src/MeoAssistant/Controller.h | 6 +++++- src/MeoAssistant/GeneralConfiger.cpp | 6 ++++++ src/MeoAssistant/GeneralConfiger.h | 12 ++++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/resource/config.json b/resource/config.json index 03f138bdd2..bf793c7fe3 100644 --- a/resource/config.json +++ b/resource/config.json @@ -18,6 +18,10 @@ "cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i" } }, + "intent": { + "Official": "com.hypergryph.arknights/com.u8.sdk.U8UnityContext", + "Bilibili": "com.hypergryph.arknights.bilibili/com.u8.sdk.U8UnityContext" + }, "connection": { "General": { "devices": "[Adb] devices", diff --git a/src/MeoAssistant/AsstTypes.h b/src/MeoAssistant/AsstTypes.h index 1a8490a980..86f0d37f52 100644 --- a/src/MeoAssistant/AsstTypes.h +++ b/src/MeoAssistant/AsstTypes.h @@ -158,6 +158,12 @@ namespace asst double score = 0.0; Rect rect; }; + + enum class ServerType + { + Official, + Bilibili + }; } namespace std diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index 9ab6a6249f..31e990a0e4 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -522,6 +522,21 @@ cv::Mat asst::Controller::get_resized_image() const return resized_mat; } +int asst::Controller::start_game(const ServerType& server_type, bool block) +{ + if (auto intent_name = Resrc.cfg().get_intent_name(server_type)) + { + std::string cur_cmd = utils::string_replace_all(m_adb.start, "[Intent]", intent_name.value()); + int id = push_cmd(cur_cmd); + if (block) + { + wait(id); + } + return id; + } + return -1; +} + int asst::Controller::click(const Point& p, bool block) { int x = static_cast(p.x * m_control_scale); @@ -828,6 +843,7 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a m_adb.screencap_raw_with_gzip = cmd_replace(adb_cfg.screencap_raw_with_gzip); m_adb.screencap_encode = cmd_replace(adb_cfg.screencap_encode); m_adb.release = cmd_replace(adb_cfg.release); + m_adb.start = cmd_replace(adb_cfg.start); return true; } diff --git a/src/MeoAssistant/Controller.h b/src/MeoAssistant/Controller.h index 47e2d117bb..7fb9101f30 100644 --- a/src/MeoAssistant/Controller.h +++ b/src/MeoAssistant/Controller.h @@ -37,7 +37,9 @@ namespace asst cv::Mat get_image(bool raw = false); std::vector get_image_encode() const; - // 点击和滑动都是异步执行,返回该任务的id + // 开启/置顶游戏、点击和滑动都是异步执行,返回该任务的id + int start_game(const ServerType& server_type = asst::ServerType::Official, bool block = true); + int click(const Point& p, bool block = true); int click(const Rect& rect, bool block = true); int click_without_scale(const Point& p, bool block = true); @@ -108,6 +110,8 @@ namespace asst std::string screencap_encode; std::string release; + std::string start; + /* propertities */ enum class ScreencapEndOfLine { diff --git a/src/MeoAssistant/GeneralConfiger.cpp b/src/MeoAssistant/GeneralConfiger.cpp index 47c372bcb1..d9e65a78f4 100644 --- a/src/MeoAssistant/GeneralConfiger.cpp +++ b/src/MeoAssistant/GeneralConfiger.cpp @@ -28,6 +28,11 @@ bool asst::GeneralConfiger::parse(const json::value& json) m_options.aip_ocr.client_id = aip_ocr.get("clientId", std::string()); m_options.aip_ocr.client_secret = aip_ocr.get("clientSerect", std::string()); } + + const json::value& intent_json = json.at("intent"); + m_intent_name[asst::ServerType::Official] = intent_json.at("Official").as_string(); + m_intent_name[asst::ServerType::Bilibili] = intent_json.at("Bilibili").as_string(); + } for (const auto& [name, cfg_json] : json.at("connection").as_object()) { @@ -45,6 +50,7 @@ bool asst::GeneralConfiger::parse(const json::value& json) adb.screencap_raw_with_gzip = cfg_json.at("screencapRawWithGzip").as_string(); adb.screencap_encode = cfg_json.at("screencapEncode").as_string(); adb.release = cfg_json.at("release").as_string(); + adb.start = cfg_json.at("start").as_string(); //adb.pullscreen = cfg_json.at("pullscreen").as_string(); m_adb_cfg[name] = std::move(adb); diff --git a/src/MeoAssistant/GeneralConfiger.h b/src/MeoAssistant/GeneralConfiger.h index cb1ee76c99..6cd7121dd7 100644 --- a/src/MeoAssistant/GeneralConfiger.h +++ b/src/MeoAssistant/GeneralConfiger.h @@ -53,6 +53,7 @@ namespace asst std::string screencap_raw_with_gzip; std::string screencap_encode; std::string release; + std::string start; }; class GeneralConfiger : public AbstractConfiger @@ -83,6 +84,16 @@ namespace asst } } + [[nodiscard]] std::optional get_intent_name(const asst::ServerType& server_type) const + { + if (auto iter = m_intent_name.find(server_type); + iter != m_intent_name.cend()) + { + return iter->second; + } + return std::nullopt; + } + void set_options(Options opt) noexcept { m_options = std::move(opt); @@ -94,5 +105,6 @@ namespace asst std::string m_version; Options m_options; std::unordered_map m_adb_cfg; + std::unordered_map m_intent_name; }; } From 9ea6c865c4e3e4e6fc1996262f04e3350abf2733 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 23:43:06 +0800 Subject: [PATCH 05/26] before add files --- src/MeoAssistant/StartUpTask.cpp | 7 +++++++ src/MeoAssistant/StartUpTask.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/MeoAssistant/StartUpTask.cpp b/src/MeoAssistant/StartUpTask.cpp index 2dcea8e628..b1229003c0 100644 --- a/src/MeoAssistant/StartUpTask.cpp +++ b/src/MeoAssistant/StartUpTask.cpp @@ -11,3 +11,10 @@ asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg) .set_times_limit("Terminal", 0); m_subtasks.emplace_back(m_start_up_task_ptr); } + +bool asst::StartUpTask::set_params(const json::value& params) +{ + if (!params.contains("server_type")) { + return false; + } +} diff --git a/src/MeoAssistant/StartUpTask.h b/src/MeoAssistant/StartUpTask.h index c508d01701..7119161c71 100644 --- a/src/MeoAssistant/StartUpTask.h +++ b/src/MeoAssistant/StartUpTask.h @@ -11,6 +11,8 @@ namespace asst StartUpTask(AsstCallback callback, void* callback_arg); virtual ~StartUpTask() = default; + bool set_params(const json::value& params) override; + static constexpr const char* TaskType = "StartUp"; private: From fbba196133e5b997272f8c4b997742afc611a411 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sat, 4 Jun 2022 23:58:27 +0800 Subject: [PATCH 06/26] add files --- src/MeoAssistant/MeoAssistant.vcxproj | 4 +++- src/MeoAssistant/MeoAssistant.vcxproj.filters | 8 +++++++- src/MeoAssistant/StartGameTask.cpp | 1 + src/MeoAssistant/StartGameTask.h | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/MeoAssistant/StartGameTask.cpp create mode 100644 src/MeoAssistant/StartGameTask.h diff --git a/src/MeoAssistant/MeoAssistant.vcxproj b/src/MeoAssistant/MeoAssistant.vcxproj index 27bed142f1..4bef932522 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj +++ b/src/MeoAssistant/MeoAssistant.vcxproj @@ -86,6 +86,7 @@ + @@ -165,6 +166,7 @@ + @@ -334,4 +336,4 @@ - \ No newline at end of file + diff --git a/src/MeoAssistant/MeoAssistant.vcxproj.filters b/src/MeoAssistant/MeoAssistant.vcxproj.filters index 67898e17bf..e46ebc49dc 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj.filters +++ b/src/MeoAssistant/MeoAssistant.vcxproj.filters @@ -240,6 +240,9 @@ 头文件\Task\Sub + + 头文件\Task\Sub + 头文件\ImageAnalyzer\Final @@ -473,6 +476,9 @@ 源文件\Task\Sub + + 源文件\Task\Sub + 源文件\ImageAnalyzer\Final @@ -578,4 +584,4 @@ 资源文件 - \ No newline at end of file + diff --git a/src/MeoAssistant/StartGameTask.cpp b/src/MeoAssistant/StartGameTask.cpp new file mode 100644 index 0000000000..9295881f6f --- /dev/null +++ b/src/MeoAssistant/StartGameTask.cpp @@ -0,0 +1 @@ +#include "StartGameTask.h" diff --git a/src/MeoAssistant/StartGameTask.h b/src/MeoAssistant/StartGameTask.h new file mode 100644 index 0000000000..f7cc928661 --- /dev/null +++ b/src/MeoAssistant/StartGameTask.h @@ -0,0 +1,7 @@ +#pragma once + +class StartGameTask +{ +public: + +}; From a48f7c9a550f112e4f9041538ccd68eb0d68ae5d Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sun, 5 Jun 2022 00:46:21 +0800 Subject: [PATCH 07/26] core completed. --- resource/tasks.json | 1 + src/MeoAssistant/AsstTypes.h | 2 +- src/MeoAssistant/StartGameTask.cpp | 16 ++++++++++++++++ src/MeoAssistant/StartGameTask.h | 22 ++++++++++++++++++---- src/MeoAssistant/StartUpTask.cpp | 16 ++++++++++------ src/MeoAssistant/StartUpTask.h | 3 ++- 6 files changed, 48 insertions(+), 12 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 933a10e71a..f179ff183b 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -821,6 +821,7 @@ 255 ], "next": [ + "GameStart", "StartToWakeUp", "StartUpConnectingFlag", "StartLoginBServer", diff --git a/src/MeoAssistant/AsstTypes.h b/src/MeoAssistant/AsstTypes.h index 86f0d37f52..f8b5c452fa 100644 --- a/src/MeoAssistant/AsstTypes.h +++ b/src/MeoAssistant/AsstTypes.h @@ -161,7 +161,7 @@ namespace asst enum class ServerType { - Official, + Official = 0, Bilibili }; } diff --git a/src/MeoAssistant/StartGameTask.cpp b/src/MeoAssistant/StartGameTask.cpp index 9295881f6f..5b4dfca554 100644 --- a/src/MeoAssistant/StartGameTask.cpp +++ b/src/MeoAssistant/StartGameTask.cpp @@ -1 +1,17 @@ #include "StartGameTask.h" + +#include "Controller.h" + +using namespace asst; + +bool StartGameTask::_run() +{ + m_ctrler->start_game(m_server_type); + return true; +} + +StartGameTask& StartGameTask::set_param(ServerType server_type) noexcept +{ + m_server_type = server_type; + return *this; +} diff --git a/src/MeoAssistant/StartGameTask.h b/src/MeoAssistant/StartGameTask.h index f7cc928661..79751d9b63 100644 --- a/src/MeoAssistant/StartGameTask.h +++ b/src/MeoAssistant/StartGameTask.h @@ -1,7 +1,21 @@ #pragma once -class StartGameTask +#include "AbstractTask.h" +#include "AsstTypes.h" + +namespace asst { -public: - -}; + class StartGameTask : public AbstractTask + { + public: + using AbstractTask::AbstractTask; + ~StartGameTask() override = default; + + StartGameTask& set_param(ServerType server_type = ServerType::Official) noexcept; + + protected: + bool _run() override; + + ServerType m_server_type = ServerType::Official; + }; +} diff --git a/src/MeoAssistant/StartUpTask.cpp b/src/MeoAssistant/StartUpTask.cpp index b1229003c0..7580c2559c 100644 --- a/src/MeoAssistant/StartUpTask.cpp +++ b/src/MeoAssistant/StartUpTask.cpp @@ -4,17 +4,21 @@ asst::StartUpTask::StartUpTask(AsstCallback callback, void* callback_arg) : PackageTask(callback, callback_arg, TaskType), - m_start_up_task_ptr(std::make_shared(m_callback, m_callback_arg, TaskType)) + m_start_game_task_ptr(std::make_shared(m_callback, m_callback_arg, TaskType)), + m_start_up_task_ptr(std::make_shared(m_callback, m_callback_arg, TaskType)) { - m_start_up_task_ptr->set_tasks({ "StartUp" }) - .set_times_limit("ReturnToTerminal", 0) - .set_times_limit("Terminal", 0); + m_start_up_task_ptr->set_tasks({"StartUp"}) + .set_times_limit("ReturnToTerminal", 0) + .set_times_limit("Terminal", 0); + m_subtasks.emplace_back(m_start_game_task_ptr); m_subtasks.emplace_back(m_start_up_task_ptr); } bool asst::StartUpTask::set_params(const json::value& params) { - if (!params.contains("server_type")) { - return false; + if (params.contains("server_type")) + { + m_start_game_task_ptr->set_param(static_cast(params.get("server_type", 0))); } + return true; } diff --git a/src/MeoAssistant/StartUpTask.h b/src/MeoAssistant/StartUpTask.h index 7119161c71..69be38ce29 100644 --- a/src/MeoAssistant/StartUpTask.h +++ b/src/MeoAssistant/StartUpTask.h @@ -1,5 +1,6 @@ #pragma once #include "PackageTask.h" +#include "StartGameTask.h" namespace asst { @@ -15,7 +16,7 @@ namespace asst static constexpr const char* TaskType = "StartUp"; private: - + std::shared_ptr m_start_game_task_ptr = nullptr; std::shared_ptr m_start_up_task_ptr = nullptr; }; } From a39e4b999e1948a0b3df019682d5770910c79ad1 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sun, 5 Jun 2022 01:13:54 +0800 Subject: [PATCH 08/26] view completed. --- src/MeoAsstGui/MeoAsstGui.csproj | 4 +++ .../UserControl/StartSettingsUserControl.xaml | 25 ++++++++++++++++++ .../StartSettingsUserControl.xaml.cs | 26 +++++++++++++++++++ .../ViewModels/SettingsViewModel.cs | 22 ++++++++++++++++ src/MeoAsstGui/Views/SettingsView.xaml | 21 ++++++++------- 5 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml create mode 100644 src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml.cs diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj index af025fcad5..e8d2faff11 100644 --- a/src/MeoAsstGui/MeoAsstGui.csproj +++ b/src/MeoAsstGui/MeoAsstGui.csproj @@ -101,6 +101,9 @@ + + StartSettingsUserControl.xaml + TimerSettingsUserControl.xaml @@ -153,6 +156,7 @@ MSBuild:Compile Designer + MSBuild:Compile Designer diff --git a/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml new file mode 100644 index 0000000000..d93c89978b --- /dev/null +++ b/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml.cs new file mode 100644 index 0000000000..92fbcd2e9c --- /dev/null +++ b/src/MeoAsstGui/UserControl/StartSettingsUserControl.xaml.cs @@ -0,0 +1,26 @@ +// MeoAsstGui - A part of the MeoAssistantArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY + +using System.Windows.Controls; + +namespace MeoAsstGui +{ + /// + /// StartSettingsUserControl.xaml 的交互逻辑 + /// + public partial class StartSettingsUserControl : UserControl + { + public StartSettingsUserControl() + { + InitializeComponent(); + } + } +} diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index f05f115787..22f8fb240c 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -43,6 +43,7 @@ namespace MeoAsstGui _windowManager = windowManager; DisplayName = "设置"; + _listTitle.Add("唤醒设置"); _listTitle.Add("基建设置"); _listTitle.Add("肉鸽设置"); _listTitle.Add("自动公招"); @@ -132,6 +133,12 @@ namespace MeoAsstGui new CombData { Display = "刷源石锭投资,第一层商店后直接退出", Value = "1" }, new CombData { Display = "刷源石锭投资,投资过后退出", Value = "2" } }; + + ServerTypeList = new List + { + new CombData { Display = "官服", Value = "0" }, + new CombData { Display = "Bilibili服", Value = "1" } + }; } private bool _idle = true; @@ -145,12 +152,27 @@ namespace MeoAsstGui } } + /* 唤醒设置 */ + + private string _serverType = ViewStatusStorage.Get("Start.ServerType", "0"); + + public string ServerType + { + get { return _serverType; } + set + { + SetAndNotify(ref _serverType, value); + ViewStatusStorage.Set("Start.ServerType", value); + } + } + /* 基建设置 */ public Dictionary FacilityKey = new Dictionary(); public ObservableCollection InfrastItemViewModels { get; set; } public List UsesOfDronesList { get; set; } public List RoguelikeModeList { get; set; } + public List ServerTypeList { get; set; } public List ConnectConfigList { get; set; } private int _dormThreshold = Convert.ToInt32(ViewStatusStorage.Get("Infrast.DormThreshold", "30")); diff --git a/src/MeoAsstGui/Views/SettingsView.xaml b/src/MeoAsstGui/Views/SettingsView.xaml index 4b5ee02d1c..03f63b00b0 100644 --- a/src/MeoAsstGui/Views/SettingsView.xaml +++ b/src/MeoAsstGui/Views/SettingsView.xaml @@ -26,33 +26,36 @@ - + - + - + - + - + - + - + - + - + + + + From 64d3e3018147075bffb7714ba3c50cd006c581b1 Mon Sep 17 00:00:00 2001 From: lhhxxxxx Date: Sun, 5 Jun 2022 01:24:06 +0800 Subject: [PATCH 09/26] full completed. --- src/MeoAsstGui/Helper/AsstProxy.cs | 6 ++++-- src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index a313192e88..bf12949cf3 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -681,9 +681,11 @@ namespace MeoAsstGui return AsstAppendTaskWithEncoding("Award"); } - public bool AsstAppendStartUp() + public bool AsstAppendStartUp(int server_type) { - return AsstAppendTaskWithEncoding("StartUp"); + var task_params = new JObject(); + task_params["server_type"] = server_type; + return AsstAppendTaskWithEncoding("StartUp", task_params); } public bool AsstAppendVisit() diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 9e56fe558b..a4744ad421 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -250,7 +250,7 @@ namespace MeoAsstGui } else if (item.Name == "开始唤醒") { - ret &= asstProxy.AsstAppendStartUp(); + ret &= appendStart(); } else if (item.Name == "刷理智") { @@ -327,6 +327,14 @@ namespace MeoAsstGui ViewStatusStorage.Set("MainFunction.TimesLimited.Quantity", MaxTimes); } + private bool appendStart() + { + var settings = _container.Get(); + var asstProxy = _container.Get(); + int.TryParse(settings.ServerType, out var mode); + return asstProxy.AsstAppendStartUp(mode); + } + private bool appendFight() { int medicine = 0; From db886e777b3b24742d72b704b694690383eee68b Mon Sep 17 00:00:00 2001 From: sakuraxp Date: Sun, 5 Jun 2022 03:07:05 +0800 Subject: [PATCH 10/26] =?UTF-8?q?feat.=E4=BC=98=E5=8C=96=EF=BC=8C=E5=BD=93?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?Windows=E7=B3=BB=E7=BB=9F=E6=8E=A8=E9=80=81=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=9A=90=E8=97=8F=E7=9B=B8=E5=BA=94=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E9=A1=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserControl/ToastSettingsUserControl.xaml | 86 +++++++------------ .../ViewModels/SettingsViewModel.cs | 40 +++------ 2 files changed, 43 insertions(+), 83 deletions(-) diff --git a/src/MeoAsstGui/UserControl/ToastSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/ToastSettingsUserControl.xaml index 8efff9a2ff..8da08177c3 100644 --- a/src/MeoAsstGui/UserControl/ToastSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/ToastSettingsUserControl.xaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:s="https://github.com/canton7/Stylet" d:DesignHeight="300" xmlns:vm="clr-namespace:MeoAsstGui;assembly=MeoAsstGui" + xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" d:DataContext="{d:DesignInstance {x:Type vm:SettingsViewModel}}" d:DesignWidth="550" mc:Ignorable="d"> @@ -14,18 +15,28 @@ - - - - - - - + + - + + + + + + + @@ -36,74 +47,41 @@ - - - - - - - - - + IsChecked="{Binding ToastPositionTopLeft}"/> + IsChecked="{Binding ToastPositionCenterLeft}"/> - + IsChecked="{Binding ToastPositionBottomLeft}"/> + IsChecked="{Binding ToastPositionTopCenter}"/> - + IsChecked="{Binding ToastPositionBottomCenter}"/> + IsChecked="{Binding ToastPositionTopRight}"/> + IsChecked="{Binding ToastPositionCenterRight}"/> + IsChecked="{Binding ToastPositionBottomRight}"/> - - - + +