mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat(PC): 支持 PC 端明日方舟 (#15407)
* feat(controller): 集成 MaaWin32ControlUnit 支持 Win32 窗口截图与控制 - 提取公共滑动插值逻辑到 SwipeHelper.hpp,重构 Minitouch/PlayTools 控制器 - 新增 Win32ControlUnitLoader 动态加载 MaaWin32ControlUnit.dll - 新增 Win32Controller 实现 ControllerAPI,适配 touch_down/move/up 接口 - 添加 AsstAsyncAttachWindow 公开 API 用于绑定 Win32 窗口 - 添加 Win32 截图/输入方式的类型定义和枚举常量 * feat(api): 增加同步版本的 AsstAttachWindow 接口 模仿 AsstConnect 实现同步绑定 Win32 窗口的接口,方便简单场景下直接调用。 该接口标记为 deprecated,建议使用异步版本 AsstAsyncAttachWindow。 * fix: can build MaaCore * feat: 完成整体适配 * feat(ci): 添加 MaaFramework Win32ControlUnit 下载步骤 使用 robinraju/release-downloader 从 MaaFramework 最新 release 下载 win-x64 版本并提取 MaaWin32ControlUnit 到构建产物中 * docs: 添加 Win32Controller 调试所需 MaaWin32ControlUnit 的说明 在开发文档的环境配置步骤中说明调试 Win32Controller 需要手动下载 MaaWin32ControlUnit.dll,并欢迎社区贡献自动下载脚本 * fix(i18n): 修改 UseAttachWindowWarning 措辞为"仅供尝鲜" * fix: 小细节修复 * ci: fix maafw filename * feat: PC 移至连接配置 * feat: 调整描述 * chore: 调整 PC 在连接配置中的顺序 * feat: 设置指引和开始唤醒界面 PC 选项绑定 --------- Co-authored-by: uye <99072975+ABA2396@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "Config/GeneralConfig.h"
|
||||
#include "MaaUtils/NoWarningCV.hpp"
|
||||
#include "SwipeHelper.hpp"
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
namespace socket_ops = boost::asio::detail::socket_ops;
|
||||
@@ -153,26 +154,15 @@ bool asst::PlayToolsController::swipe(
|
||||
|
||||
toucher_down(p1);
|
||||
|
||||
auto cubic_spline = [](double slope_0, double slope_1, double t) {
|
||||
const double a = slope_0;
|
||||
const double b = -(2 * slope_0 + slope_1 - 3);
|
||||
const double c = -(-slope_0 - slope_1 + 2);
|
||||
return a * t + b * std::pow(t, 2) + c * std::pow(t, 3);
|
||||
}; // TODO: move this to math.hpp
|
||||
auto bounds_check = [width, height](int x, int y) { return x >= 0 && x <= width && y >= 0 && y <= height; };
|
||||
|
||||
const auto progressive_move = [&](int _x1, int _y1, int _x2, int _y2, int _duration) {
|
||||
for (int cur_time = DefaultSwipeDelay; cur_time < _duration; cur_time += DefaultSwipeDelay) {
|
||||
double progress = cubic_spline(slope_in, slope_out, static_cast<double>(cur_time) / duration);
|
||||
int cur_x = static_cast<int>(std::lerp(_x1, _x2, progress));
|
||||
int cur_y = static_cast<int>(std::lerp(_y1, _y2, progress));
|
||||
if (cur_x < 0 || cur_x > width || cur_y < 0 || cur_y > height) {
|
||||
continue;
|
||||
}
|
||||
toucher_move({ cur_x, cur_y });
|
||||
}
|
||||
if (_x2 >= 0 && _x2 <= width && _y2 >= 0 && _y2 <= height) {
|
||||
toucher_move({ _x2, _y2 });
|
||||
}
|
||||
auto move_func = [this](int x, int y) {
|
||||
toucher_move({ x, y });
|
||||
return true;
|
||||
};
|
||||
|
||||
auto progressive_move = [&](int _x1, int _y1, int _x2, int _y2, int _duration) {
|
||||
interpolate_swipe(_x1, _y1, _x2, _y2, _duration, DefaultSwipeDelay, slope_in, slope_out, move_func, bounds_check);
|
||||
};
|
||||
|
||||
const auto& opt = Config.get_options();
|
||||
@@ -180,7 +170,7 @@ bool asst::PlayToolsController::swipe(
|
||||
progressive_move(x1, y1, x2, y2, duration ? duration : opt.minitouch_swipe_default_duration);
|
||||
|
||||
if (extra_swipe && opt.minitouch_extra_swipe_duration > 0) {
|
||||
toucher_wait(opt.minitouch_swipe_extra_end_delay); // 停留终点
|
||||
toucher_wait(opt.minitouch_swipe_extra_end_delay);
|
||||
progressive_move(x2, y2, x2, y2 - opt.minitouch_extra_swipe_dist, opt.minitouch_extra_swipe_duration);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user