mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
* text=auto
|
||||
*.cs text eol=crlf
|
||||
*.xaml text eol=crlf
|
||||
|
||||
*.cpp text eol=lf
|
||||
*.hpp text eol=lf
|
||||
*.h text eol=lf
|
||||
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
*.yaml text eol=lf
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(MeoAssistantArknights)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(MaaAssistantArknights)
|
||||
|
||||
option(BUILD_JNI "build jni" OFF)
|
||||
option(BUILD_TEST "build a demo" OFF)
|
||||
@@ -16,8 +16,8 @@ if (WIN32)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
endif()
|
||||
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/W4>")
|
||||
add_compile_options("$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall;-Wextra;-Wpedantic>")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/W4;/WX>")
|
||||
add_compile_options("$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall;-Wextra;-Wpedantic;-Werror>")
|
||||
|
||||
add_definitions(-DASST_DLL_EXPORTS)
|
||||
|
||||
|
||||
24
appveyor.yml
24
appveyor.yml
@@ -1,24 +0,0 @@
|
||||
version: 0.9.{build}
|
||||
image: Visual Studio 2022
|
||||
configuration:
|
||||
- RelWithDebInfo
|
||||
- Release
|
||||
platform: x64
|
||||
clone_depth: 1
|
||||
before_build:
|
||||
- ps: nuget restore
|
||||
build:
|
||||
project: MeoAssistantArknights.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
notifications:
|
||||
- provider: Email
|
||||
to:
|
||||
- mistereo@hotmail.com
|
||||
subject: 'Build {{status}}: {{projectName}} {{buildVersion}}'
|
||||
message: 'Commit #{{commitId}} by {{commitAuthor}} on {{commitDate}}: {{commitMessage}}'
|
||||
on_build_success: true
|
||||
on_build_failure: true
|
||||
on_build_status_changed: false
|
||||
on_failure:
|
||||
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
600
docs/readme.md
600
docs/readme.md
@@ -1,600 +0,0 @@
|
||||
# MAA使用说明
|
||||
|
||||
## 详细介绍
|
||||
|
||||
### 刷理智
|
||||
|
||||
- 若选项中没有你需要的关卡,请手动进入游戏 **蓝色开始按钮** 界面,并选择 `当前关卡`。
|
||||
- 主界面上的 `吃理智`、`吃石头`、`指定次数` 三个选项为短路开关,即三个选项中的任一条件达到,均会视为任务完成,停止刷理智。
|
||||
- 举例1:设置 `吃理智药` : `999`、`吃石头` : `10`、`指定次数` : `1`。则在刷完 **一次** 后,由于满足了 `指定次数`:`1` 的条件,视为任务完成,停止刷理智。
|
||||
- 举例2:不勾选 `吃理智药`、不勾选 `吃石头`,设置 `指定次数` : `100`。则在当前可用理智全部刷完后(可能只刷了几次),由于满足了 `不吃理智药`、`不吃石头` 的条件,视为任务完成,停止刷理智。
|
||||
- 刷完自动上传 [企鹅物流数据统计](https://penguin-stats.cn/)
|
||||
- 可自定义企鹅物流 ID
|
||||
- 识别并显示材料掉落
|
||||
- 掉线后会重连,继续刷上次的图
|
||||
- 凌晨 4 点刷新后也会重连,继续刷上次的图
|
||||
- 支持剿灭模式
|
||||
- 支持打完升级了的情况
|
||||
- 支持代理失败的情况,会自动放弃本次行动
|
||||
|
||||
### 基建换班
|
||||
|
||||
#### 换班策略
|
||||
|
||||
自动计算并选择 **单设施内的最优解**,支持所有通用类技能和特殊技能组合;支持识别经验书、赤金、原石碎片、芯片,分别使用不同的干员组合!
|
||||
|
||||
#### 宿舍入驻心情阈值
|
||||
|
||||
识别心情进度条的百分比;心情小于该阈值的干员,不会再去上班,直接进驻宿舍。
|
||||
|
||||
#### 特殊说明
|
||||
|
||||
- 基建换班目前均为单设施最优解,但非跨设施的全局最优解。例如:`巫恋+龙舌兰`、`红云+稀音` 等这类单设施内的组合,都是可以正常识别并使用的;`迷迭香`、`红松骑士团` 这类多个设施间联动的体系,暂不支持使用。
|
||||
- 若 `无人机用途` 选择 `贸易站-龙门币` ,则将额外识别是否有 `巫恋组`,并优先为其使用。
|
||||
- 会客室仅缺一个线索时,会选择对应流派的干员;否则会选择通用干员。
|
||||
- 会客室仅当自有线索满时,才会送出线索,并且只送三个。有需要的同学可自行修改 `resource/tasks.json` 中 `SelectClue` - `maxTimes` 字段,自定义送出个数。
|
||||
- 控制中枢策略太过复杂,目前只考虑 `阿米娅`、`诗怀雅`、`凯尔希`、`彩虹小队` 及其他心情 +0.05 的干员,后续逐步优化。
|
||||
- 部分异格干员会在基建内产生冲突,请留意辅助界面上是否有提示 “干员冲突”,若有请手动再查看下基建换班情况(可能会有某个设施没人)
|
||||
|
||||
### 信用商店随缘买
|
||||
|
||||
从左到右依次买,但不会买 `碳` 和 `家具零件` 。有需要的同学可自行修改 `resource/tasks.json` 中 `CreditShop-NotToBuy` - `text` 字段,自定义不买的物品。后续版本会尝试开放界面选项
|
||||
|
||||
### 公开招募识别
|
||||
|
||||
- 自动公招和公招识别是两个独立的功能!
|
||||
- 自动公招支持使用 `加急许可`,全自动连续公招!请进入设置中选择~
|
||||
- 出 5、6 星都会有弹窗提示
|
||||
|
||||
### 自动肉鸽功能
|
||||
|
||||
- 设置中的三个选项
|
||||
- 尽可能往后打:用于刷蜡烛
|
||||
- 刷源石锭投资,第一层商店后直接退出:刷源石锭最高效的模式,建议手动选择 `古堡观光` (简单)模式
|
||||
- 刷源石锭投资,投资后退出:兼顾刷蜡烛和刷源石锭投资的模式
|
||||
- 肉鸽使用干员是可以自定义的,默认的干员是作者根据自己的练度随手写的,如果经常作战失败,建议按你自己的练度修改一下,请参考 [肉鸽自定义选人方法](https://github.com/MistEO/MeoAssistantArknights/issues/167)。后期将优化这里的选人逻辑
|
||||
- 支持掉线重连、支持凌晨 4 点更新后继续回去刷
|
||||
- 如果软件出现 bug 卡住了,会自动放弃当次探索并重试。但如果经常在某个地方卡住然后放弃、严重影响效率的,欢迎提个 issue 反馈一下~
|
||||
|
||||
|
||||
### 其他乱七八糟的说明
|
||||
|
||||
- 主界面上要执行的任务,是可以拖动改变顺序的。同样设置中基建换班的顺序,也是可以拖动改变的。
|
||||
- 新的活动关卡刚上线的时候可能无法正常识别,一般一两天内软件会自动 OTA 更新资源,更新后即可正常识别。
|
||||
- 活动关卡掉落识别到的 `未知材料`,一般就是活动商店的票据。
|
||||
- `resource/config.json` 中有一些自定义选项,可以尝试根据自己的需要进行修改。
|
||||
- 所有点击操作,都是点击按钮内随机位置,并模拟泊松分布(按钮偏中间位置点的概率大,越往旁边点到的概率越小)。
|
||||
- 底层算法纯 C++ 开发,并设计了多重的缓存技术,最大限度降低 CPU 和内存占用。
|
||||
- 软件支持自动更新✿✿ヽ(°▽°)ノ✿ 推荐非杠精的同学使用测试版,一般来说更新快且 bug 少(什么 MIUI (╯‵□′)╯︵┻━┻
|
||||
- 如果新版本自动下载失败,可手动下载后,直接把压缩包放到同目录下,会自动更新的。
|
||||
|
||||
### 我是国际服玩家,可以使用么?
|
||||
|
||||
可以!但是目前只支持少部分功能,请参考 [这个链接](../resource/international/)
|
||||
|
||||
### I'm an international server player, could I use it?
|
||||
|
||||
Yes, but there are few supported features, please refer to [this link](../resource/international/)
|
||||
## 模拟器支持
|
||||
|
||||
### 蓝叠模拟器
|
||||
|
||||
完美支持。需要在模拟器 `设置` - `引擎设置` 中打开 `允许ADB连接`
|
||||
|
||||
### 蓝叠模拟器国际版(推荐使用)
|
||||
|
||||
完美支持。需要在模拟器 `设定` - `进阶` 中打开 `Android调试桥`
|
||||
|
||||
### 蓝叠模拟器 Hyper-V 版本
|
||||
|
||||
支持
|
||||
|
||||
1. 在模拟器 `设定` - `进阶` 中打开 `Android调试桥`
|
||||
2. 下载 [adb](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) ,将 `platform-tools` 文件夹解压到 `MeoAsstGui.exe` 的同级目录
|
||||
3. 在软件 `设置` - `连接设置` 中填写蓝叠安装目录下 `bluestacks.conf` 文件的完整路径
|
||||
|
||||
### 夜神模拟器
|
||||
|
||||
完美支持
|
||||
|
||||
### 夜神模拟器 安卓 9
|
||||
|
||||
完美支持
|
||||
|
||||
### MuMu 模拟器
|
||||
|
||||
支持。但是可能会
|
||||
|
||||
- 一直连接出错:暂时不知道是什么原因,可尝试使用自定义连接
|
||||
- 卡在主界面无法识别,过一会提示任务出错:和 MuMu 的渲染方式有关,推荐换模拟器(
|
||||
|
||||
### MuMu 手游助手(星云引擎)
|
||||
|
||||
不支持。没开放 adb 端口
|
||||
|
||||
### MuMu 模拟器 安卓 9
|
||||
|
||||
不支持。adb 截图出来是黑的,不知道怎么整
|
||||
|
||||
### 雷电模拟器
|
||||
|
||||
勉强支持。雷电总有莫名其妙的问题,可以试试看,不保证能用(
|
||||
|
||||
### 逍遥模拟器
|
||||
|
||||
支持。但可能有莫名其妙的识别错误问题
|
||||
|
||||
### 腾讯手游助手
|
||||
|
||||
不支持。没开放 adb 端口
|
||||
|
||||
### Win11 WSA
|
||||
|
||||
不支持。WSA 目前没有实现 AOSP screencap 需要的接口,无法进行截图。等微软支持后会尝试适配
|
||||
|
||||
### AVD
|
||||
|
||||
支持。
|
||||
|
||||
### 自定义连接
|
||||
|
||||
1. 下载 [adb](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) ,将 `platform-tools` 文件夹解压到 `MeoAsstGui.exe` 的同级目录
|
||||
2. 进入软件 `设置` - `连接设置`,填写自定义 adb 地址(需要填写 IP + 端口,例如 `127.0.0.1:5555` )
|
||||
|
||||
**注意 :** 若是使用手机,在非 `16:9` 分辨率下,部分功能不稳定(但也凑合能用),尤其是基建,几乎是不可用状态,正在进一步适配中。推荐使用 `16:9` 分辨率,经过的测试验证最多,也最稳定。
|
||||
## 常见问题
|
||||
|
||||
### 软件一打开就闪退
|
||||
|
||||
- 可能性 1: 运行库问题。
|
||||
请尝试安装 [Visual C++ Redistributable](https://docs.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist?view=msvc-160#visual-studio-2015-2017-2019-and-2022)、[.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/net48) 后重新运行本软件。
|
||||
- 可能性 2: CPU 指令集不支持。
|
||||
项目使用 `PaddleOCR` 对游戏部分界面进行识别。`PaddleOCR` 用到了较新发布的 CPU 才支持的 `AVX` 指令集,而一些较老的 CPU 可能并不支持该指令集。
|
||||
您可以尝试下载 [NoAVX](../3rdparty/ppocr_noavx.zip) 版本的 `PaddleOCR`, 解压后替换本软件中同名的文件。这是对于使用不支持 `AVX` 指令集的 CPU 的用户的性能降低的替代方案,如非必要,请不要使用。
|
||||
(具体可以下载 [CPU-Z](https://www.cpuid.com/softwares/cpu-z.html),查看“指令集”中有无 `AVX` 这一项来判断)
|
||||
- 若上述均没有效果,请提 issue。
|
||||
|
||||
### 软件可以正常启动,但一点击开始运行就闪退
|
||||
|
||||
设置中的`bluestacks.conf`, 是给 [蓝叠模拟器 Hyper-V 版本](https://github.com/MistEO/MeoAssistantArknights/blob/master/docs/%E6%A8%A1%E6%8B%9F%E5%99%A8%E6%94%AF%E6%8C%81.md#%E8%93%9D%E5%8F%A0%E6%A8%A1%E6%8B%9F%E5%99%A8-hyper-v-%E7%89%88%E6%9C%AC) 使用的,若非该版本,请不要填写该项。如果确定不是这个问题,请再提 issue ~
|
||||
|
||||
### 连接错误/捕获模拟器窗口错误
|
||||
|
||||
提示 : 请根据 [使用说明](../README.md#使用说明) 确定您的模拟器及打开方式正确
|
||||
|
||||
- 方法 1: 使用 [自定义连接](#自定义连接) 的方式连接模拟器
|
||||
- 方法 2: 换模拟器,推荐 [蓝叠国际版](https://www.bluestacks.com/download.html) Nougat 64 bit
|
||||
- 方法 3: _根本解决方法_ 编辑 `resource/config.json`, 修改(最好是新增)模拟器窗口句柄名,并修改对应的 adb 设置。若您修改后可以提 PR 给我,我会感激不尽的_(:з」∠)_
|
||||
|
||||
### 识别错误/任务开始后一直不动、没有反应
|
||||
|
||||
提示 : 依次进行,若问题解决,则无需往下
|
||||
|
||||
1. 请根据 [模拟器支持情况](模拟器支持.md) 确定您的模拟器是受支持的
|
||||
2. 修改模拟器分辨率设置,`320 dpi`
|
||||
3. 修改模拟器分辨率设置,横屏 `1280 * 720` 分辨率
|
||||
4. 换模拟器,推荐 [蓝叠国际版](https://www.bluestacks.com/download.html) Nougat 64 bit ( 请注意蓝叠需要在模拟器设置里开启 adb )
|
||||
5. 若仍有问题,请提 issue
|
||||
|
||||
### 自定义连接
|
||||
|
||||
- 下载 [adb](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) ,将 `platform-tools` 文件夹解压到 `MeoAsstGui.exe` 的同级目录
|
||||
- 进入软件 `设置` - `连接设置`,填写自定义 adb 地址(需要填写 IP + 端口,例如 `127.0.0.1:5555` )
|
||||
|
||||
### 环境变量中已有 adb, 可以不再下载一份么?
|
||||
|
||||
可以!请手动修改 `resource\config.json` - `Custom` - `adb` - `path` 为 `adb.exe`, 或其他 adb 的路径
|
||||
## 回调消息协议
|
||||
|
||||
### 回调函数原型
|
||||
|
||||
```c++
|
||||
typedef void(ASST_CALL* AsstCallback)(int msg, const char* details, void* custom_arg);
|
||||
```
|
||||
|
||||
### 参数总览
|
||||
|
||||
- `int msg`
|
||||
消息类型
|
||||
|
||||
```c++
|
||||
enum class AsstMsg
|
||||
{
|
||||
/* Global Info */
|
||||
InternalError = 0, // 内部错误
|
||||
InitFailed, // 初始化失败
|
||||
ConnectionError, // 连接相关错误
|
||||
AllTasksCompleted, // 全部任务完成
|
||||
/* TaskChain Info */
|
||||
TaskChainError = 10000, // 任务链执行/识别错误
|
||||
TaskChainStart, // 任务链开始
|
||||
TaskChainCompleted, // 任务链完成
|
||||
TaskChainExtraInfo, // 任务链额外信息
|
||||
/* SubTask Info */
|
||||
SubTaskError = 20000, // 原子任务执行/识别错误
|
||||
SubTaskStart, // 原子任务开始
|
||||
SubTaskCompleted, // 原子任务完成
|
||||
SubTaskExtraInfo // 原子任务额外信息
|
||||
};
|
||||
```
|
||||
|
||||
- `const char* details`
|
||||
消息详情,json 字符串,详见 [字段解释](#字段解释)
|
||||
- `void* custom_arg`
|
||||
调用方自定义参数,会原样传出 `AsstCreateEx` 接口中的 `custom_arg` 参数,C 系语言可利用该参数传出 `this` 指针
|
||||
|
||||
### 字段解释
|
||||
|
||||
#### InternalError
|
||||
|
||||
Todo
|
||||
|
||||
#### InitFailed
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"what": string, // 错误类型
|
||||
"details": object, // 错误详情
|
||||
}
|
||||
```
|
||||
|
||||
#### ConnectionError
|
||||
|
||||
Todo
|
||||
|
||||
#### AllTasksCompleted
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"taskchain": string, // 最后的任务链
|
||||
"pre_taskchain": string // 上一个任务链
|
||||
}
|
||||
```
|
||||
|
||||
##### 常见 `taskchain` 字段
|
||||
|
||||
- `StartUp`
|
||||
开始唤醒
|
||||
- `Fight`
|
||||
刷理智
|
||||
- `Mall`
|
||||
信用点及购物
|
||||
- `Recruit`
|
||||
自动公招
|
||||
- `RecruitCalc`
|
||||
公招识别
|
||||
- `Infrast`
|
||||
基建换班
|
||||
- `Roguelike`
|
||||
无限刷肉鸽
|
||||
- `Debug`
|
||||
调试
|
||||
|
||||
#### TaskChain 相关消息
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"taskchain": string, // 当前的任务链
|
||||
"pre_taskchain": string // 上一个任务链
|
||||
}
|
||||
```
|
||||
|
||||
#### TaskChainExtraInfo
|
||||
|
||||
Todo
|
||||
|
||||
#### SubTask 相关消息
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"subtask": string, // 子任务名
|
||||
"class": string, // 子任务符号名
|
||||
"taskchain": string, // 当前任务链
|
||||
"details": object, // 详情
|
||||
}
|
||||
```
|
||||
|
||||
##### 常见 `subtask` 字段
|
||||
|
||||
- `ProcessTask`
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"task": "StartButton2", // 任务名
|
||||
"action": 512,
|
||||
"exec_times": 1, // 已执行次数
|
||||
"max_times": 999, // 最大执行次数
|
||||
"algorithm": 0
|
||||
}
|
||||
```
|
||||
|
||||
- Todo 其他
|
||||
|
||||
###### 常见 `task` 字段
|
||||
|
||||
- `StartButton2`
|
||||
开始战斗
|
||||
- `MedicineConfirm`
|
||||
使用理智药
|
||||
- `StoneConfirm`
|
||||
碎石
|
||||
- `RecruitRefreshConfirm`
|
||||
公招刷新标签
|
||||
- `RecruitConfirm`
|
||||
公招确认招募
|
||||
- `RecruitNowConfirm`
|
||||
公招使用加急许可
|
||||
- `ReportToPenguinStats`
|
||||
汇报到企鹅数据统计
|
||||
- `InfrastDormDoubleConfirmButton`
|
||||
基建宿舍的二次确认按钮,仅当干员冲突时才会有,请提示用户
|
||||
- `Roguelike1Start`
|
||||
肉鸽开始探索
|
||||
- `Roguelike1StageTraderInvestConfirm`
|
||||
肉鸽投资了源石锭
|
||||
- `Roguelike1StageTraderInvestSystemFull`
|
||||
肉鸽投资达到了游戏上限
|
||||
- `Roguelike1ExitThenAbandon`
|
||||
肉鸽放弃了本次探索
|
||||
- `Roguelike1MissionCompletedFlag`
|
||||
肉鸽战斗完成
|
||||
- `Roguelike1MissionFailedFlag`
|
||||
肉鸽战斗失败
|
||||
- `Roguelike1StageSafeHouseEnter`
|
||||
肉鸽关卡:诡异行商
|
||||
- `Roguelike1StageSafeHouseEnter`
|
||||
肉鸽关卡:安全的角落
|
||||
- `Roguelike1StageEncounterEnter`
|
||||
肉鸽关卡:不期而遇/古堡馈赠
|
||||
- `Roguelike1StageCambatDpsEnter`
|
||||
肉鸽关卡:普通作战
|
||||
- `Roguelike1StageEmergencyDps`
|
||||
肉鸽关卡:紧急作战
|
||||
- `Roguelike1StageDreadfulFoe`
|
||||
肉鸽关卡:险路恶敌
|
||||
- Todo 其他
|
||||
|
||||
#### SubTaskExtraInfo
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"taskchain": string, // 当前任务链
|
||||
"class": string, // 子任务类型
|
||||
"what": string, // 信息类型
|
||||
"details": object, // 信息详情
|
||||
}
|
||||
```
|
||||
|
||||
##### 常见 `what` 及 `details` 字段
|
||||
|
||||
- `StageDrops`
|
||||
关卡材料掉落信息
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"exceptions": [],
|
||||
"resultLabel": true,
|
||||
"drops": [ // 本次识别到的掉落材料
|
||||
{
|
||||
"dropType": "NORMAL_DROP",
|
||||
"itemId": "3301",
|
||||
"quantity": 2,
|
||||
"itemName": "技巧概要·卷1"
|
||||
},
|
||||
{
|
||||
"dropType": "NORMAL_DROP",
|
||||
"itemId": "3302",
|
||||
"quantity": 1,
|
||||
"itemName": "技巧概要·卷2"
|
||||
},
|
||||
{
|
||||
"dropType": "NORMAL_DROP",
|
||||
"itemId": "3303",
|
||||
"quantity": 2,
|
||||
"itemName": "技巧概要·卷3"
|
||||
}
|
||||
],
|
||||
"dropTypes": [
|
||||
{
|
||||
"dropTypes": "LMB"
|
||||
},
|
||||
{
|
||||
"dropTypes": "NORMAL_DROP"
|
||||
}
|
||||
],
|
||||
"stage": { // 关卡信息
|
||||
"stageCode": "CA-5",
|
||||
"stageId": "wk_fly_5"
|
||||
},
|
||||
"stars": 3, // 行动结束星级
|
||||
"fingerprint": "e464bafaa3f92877bbc4fb20209e4169ae49d587499c8d2e72026b96356c591f6a17477a5b345518a00b23be78252e0825070585d33f2109390807672c252a0b",
|
||||
"md5": "b40ea51ec7802afa2e86951bffbbc21f",
|
||||
"cost": 6.0624,
|
||||
"stats": [ // 本次执行期间总的材料掉落
|
||||
{
|
||||
"itemId": "3301",
|
||||
"itemName": "技巧概要·卷1",
|
||||
"quantity": 4
|
||||
},
|
||||
{
|
||||
"itemId": "3302",
|
||||
"itemName": "技巧概要·卷2",
|
||||
"quantity": 3
|
||||
},
|
||||
{
|
||||
"itemId": "3303",
|
||||
"itemName": "技巧概要·卷3",
|
||||
"quantity": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- `RecruitTagsDetected`
|
||||
公招识别到了 Tags
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"tags": [
|
||||
"费用回复",
|
||||
"防护",
|
||||
"先锋干员",
|
||||
"辅助干员",
|
||||
"近战位"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- `RecruitSpecialTag`
|
||||
公招识别到了特殊 Tag
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"tag": "高级资深干员"
|
||||
}
|
||||
```
|
||||
|
||||
- `RecruitResult`
|
||||
公招识别结果
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"level": 4, // 总的星级
|
||||
"result": [
|
||||
{
|
||||
"tags": [
|
||||
"削弱"
|
||||
],
|
||||
"level": 4, // 这组 tags 的星级
|
||||
"opers": [
|
||||
{
|
||||
"name": "初雪",
|
||||
"level": 5 // 干员星级
|
||||
},
|
||||
{
|
||||
"name": "陨星",
|
||||
"level": 5
|
||||
},
|
||||
{
|
||||
"name": "槐琥",
|
||||
"level": 5
|
||||
},
|
||||
{
|
||||
"name": "夜烟",
|
||||
"level": 4
|
||||
},
|
||||
{
|
||||
"name": "流星",
|
||||
"level": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tags": [
|
||||
"减速",
|
||||
"术师干员"
|
||||
],
|
||||
"level": 4,
|
||||
"opers": [
|
||||
{
|
||||
"name": "夜魔",
|
||||
"level": 5
|
||||
},
|
||||
{
|
||||
"name": "格雷伊",
|
||||
"level": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tags": [
|
||||
"削弱",
|
||||
"术师干员"
|
||||
],
|
||||
"level": 4,
|
||||
"opers": [
|
||||
{
|
||||
"name": "夜烟",
|
||||
"level": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- `RecruitTagsSelected`
|
||||
公招选择了 Tags
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"tags": [
|
||||
"减速",
|
||||
"术师干员"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- `EnterFacility`
|
||||
基建进入了设施
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"facility": "Mfg", // 设施名
|
||||
"index": 0 // 设施序号
|
||||
}
|
||||
```
|
||||
|
||||
- `NotEnoughStaff`
|
||||
基建可用干员不足
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"facility": "Mfg", // 设施名
|
||||
"index": 0 // 设施序号
|
||||
}
|
||||
```
|
||||
|
||||
- `ProductOfFacility`
|
||||
基建产物
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"product": "Money", // 产物名
|
||||
"facility": "Mfg", // 设施名
|
||||
"index": 0 // 设施序号
|
||||
}
|
||||
```
|
||||
|
||||
- `StageInfo`
|
||||
自动作战关卡信息
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"name": string // 关卡名
|
||||
}
|
||||
```
|
||||
|
||||
- `StageInfoError`
|
||||
自动作战关卡识别错误
|
||||
|
||||
- `PenguinId`
|
||||
企鹅物流 ID
|
||||
|
||||
```jsonc
|
||||
// 对应的 details 字段举例
|
||||
{
|
||||
"id": string
|
||||
}
|
||||
```
|
||||
|
||||
@@ -105,5 +105,5 @@
|
||||
|
||||
## 举例
|
||||
|
||||
[Sample](../resource/battle/test.json)
|
||||
[GA-EX8 突袭作业](../resource/battle/GA-EX8-raid.json)
|
||||
[Sample](../resource/copilot/test.json)
|
||||
[GA-EX8 突袭作业](../resource/copilot/GA-EX8-raid.json)
|
||||
|
||||
@@ -53,7 +53,9 @@
|
||||
|
||||
### Win11 WSA
|
||||
|
||||
勉强支持。但 WSA 的截图经常莫名其妙截出来一个白屏,导致识别异常,不推荐使用
|
||||
勉强支持。
|
||||
- 需要下载 [adb](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) ,将 `platform-tools` 文件夹解压到 `MeoAsstGui.exe` 的同级目录
|
||||
- 但 WSA 的截图经常莫名其妙截出来一个白屏,导致识别异常,不推荐使用
|
||||
|
||||
### AVD
|
||||
|
||||
|
||||
11
docs/集成文档.md
11
docs/集成文档.md
@@ -97,17 +97,20 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p
|
||||
不支持设置参数
|
||||
|
||||
- `Mall`
|
||||
领取信用及商店购物
|
||||
领取信用及商店购物。
|
||||
会先有序的按 `buy_first` 购买一遍,再从左到右并避开 `blacklist` 购买第二遍
|
||||
|
||||
```jsonc
|
||||
// 对应的任务参数
|
||||
{
|
||||
"shopping": bool, // 是否购物,可选,默认 false。不支持运行中设置
|
||||
"shopping_list": [ // 购物列表,当 shopping 为 true 时必选。不支持运行中设置
|
||||
"buy_first": [ // 优先购买列表,可选。不支持运行中设置
|
||||
string, // 商品名,如 "招聘许可"、"龙门币" 等
|
||||
],
|
||||
"blacklist": [ // 黑名单列表,可选。不支持运行中设置
|
||||
string, // 商品名,如 "加急许可"、"家具零件" 等
|
||||
...
|
||||
],
|
||||
"is_black_list": bool // 购物列表是否是黑名单模式,可选,默认 false。不支持运行中设置
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -71,10 +71,6 @@
|
||||
"subProfession": "pioneer",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"预备干员": {
|
||||
"Doc": "事实上没有叫这个名字的干员,但为了避免肉鸽中,requires设置了但找不到的问题,增设这个干员。",
|
||||
"level": 3
|
||||
},
|
||||
"翎羽": {
|
||||
"level": 3,
|
||||
"profession": "PIONEER",
|
||||
@@ -297,6 +293,12 @@
|
||||
"subProfession": "fearless",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"断罪者": {
|
||||
"level": 4,
|
||||
"profession": "WARRIOR",
|
||||
"subProfession": "fearless",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"霜叶": {
|
||||
"level": 4,
|
||||
"profession": "WARRIOR",
|
||||
@@ -381,6 +383,12 @@
|
||||
"subProfession": "healer",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"褐果": {
|
||||
"level": 4,
|
||||
"profession": "MEDIC",
|
||||
"subProfession": "wandermedic",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"角峰": {
|
||||
"level": 4,
|
||||
"profession": "TANK",
|
||||
@@ -747,6 +755,12 @@
|
||||
"subProfession": "funnel",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"洛洛": {
|
||||
"level": 5,
|
||||
"profession": "CASTER",
|
||||
"subProfession": "funnel",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"梅尔": {
|
||||
"level": 5,
|
||||
"profession": "SUPPORT",
|
||||
@@ -969,12 +983,24 @@
|
||||
"subProfession": "slower",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"掠风": {
|
||||
"level": 5,
|
||||
"profession": "SUPPORT",
|
||||
"subProfession": "craftsman",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"空": {
|
||||
"level": 5,
|
||||
"profession": "SUPPORT",
|
||||
"subProfession": "bard",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"海蒂": {
|
||||
"level": 5,
|
||||
"profession": "SUPPORT",
|
||||
"subProfession": "bard",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"月禾": {
|
||||
"level": 5,
|
||||
"profession": "SUPPORT",
|
||||
@@ -1251,6 +1277,12 @@
|
||||
"subProfession": "stalker",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"归溟幽灵鲨": {
|
||||
"level": 6,
|
||||
"profession": "SPECIAL",
|
||||
"subProfession": "dollkeeper",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"闪灵": {
|
||||
"level": 6,
|
||||
"profession": "MEDIC",
|
||||
@@ -1269,6 +1301,12 @@
|
||||
"subProfession": "physician",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"流明": {
|
||||
"level": 6,
|
||||
"profession": "MEDIC",
|
||||
"subProfession": "healer",
|
||||
"position": "RANGED"
|
||||
},
|
||||
"星熊": {
|
||||
"level": 6,
|
||||
"profession": "TANK",
|
||||
@@ -1305,6 +1343,12 @@
|
||||
"subProfession": "duelist",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"号角": {
|
||||
"level": 6,
|
||||
"profession": "TANK",
|
||||
"subProfession": "fortress",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"山": {
|
||||
"level": 6,
|
||||
"profession": "WARRIOR",
|
||||
@@ -1329,6 +1373,12 @@
|
||||
"subProfession": "sword",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"艾丽妮": {
|
||||
"level": 6,
|
||||
"profession": "WARRIOR",
|
||||
"subProfession": "sword",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"煌": {
|
||||
"level": 6,
|
||||
"profession": "WARRIOR",
|
||||
@@ -1407,10 +1457,8 @@
|
||||
"subProfession": "fearless",
|
||||
"position": "MELEE"
|
||||
},
|
||||
"断罪者": {
|
||||
"level": 4,
|
||||
"profession": "WARRIOR",
|
||||
"subProfession": "fearless",
|
||||
"position": "MELEE"
|
||||
"预备干员": {
|
||||
"Doc": "事实上没有叫这个名字的干员,但为了避免肉鸽中,requires设置了但找不到的问题,增设这个干员。",
|
||||
"level": 3
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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=",
|
||||
@@ -37,7 +37,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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= | awk ' { print $3 } '",
|
||||
@@ -50,7 +50,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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= | awk ' { print $3 } '",
|
||||
@@ -63,7 +63,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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= | awk ' { print $3 } '",
|
||||
@@ -76,7 +76,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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= | awk ' { print $3 } '",
|
||||
@@ -89,7 +89,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"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=",
|
||||
@@ -103,7 +103,7 @@
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"displayId": "[Adb] -s [Address] shell dumpsys display | grep mUniqueId=virtual:com.microsoft.windows.systemapp:com.hypergryph.arknights",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"click": "[Adb] -s [Address] shell input -d [DisplayId] tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input -d [DisplayId] swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell \"wm size -d [DisplayId]\"",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"action": "SwipeToTheRight",
|
||||
"next": [
|
||||
"StageSN-8",
|
||||
"SNChapter2ToSN-8",
|
||||
"SwipeRightToStageSN-8"
|
||||
]
|
||||
},
|
||||
@@ -103,6 +104,7 @@
|
||||
"action": "SwipeToTheLeft",
|
||||
"next": [
|
||||
"StageSN-9",
|
||||
"SNChapter3ToSN-9",
|
||||
"SwipeLeftToStageSN-9"
|
||||
]
|
||||
},
|
||||
@@ -162,6 +164,7 @@
|
||||
"action": "SwipeToTheLeft",
|
||||
"next": [
|
||||
"StageSN-10",
|
||||
"SNChapter3ToSN-10",
|
||||
"SwipeLeftToStageSN-10"
|
||||
]
|
||||
},
|
||||
@@ -2530,12 +2533,14 @@
|
||||
110
|
||||
]
|
||||
},
|
||||
"CreditShop-NotToBuy": {
|
||||
"CreditShop-ProductName": {
|
||||
"algorithm": "OcrDetect",
|
||||
"Doc": "这里的text,是子串搜索,即商品名中只要含有任一text,就不买",
|
||||
"text": [
|
||||
"碳",
|
||||
"家具"
|
||||
"text": [],
|
||||
"ocrReplace": [
|
||||
[
|
||||
"龙门.+",
|
||||
"龙门币"
|
||||
]
|
||||
],
|
||||
"roi": [
|
||||
0,
|
||||
|
||||
@@ -9,18 +9,17 @@ bool asst::AbstractConfiger::load(const std::string& filename)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
#ifdef WIN32
|
||||
std::string cvt_filename = utils::utf8_to_gbk(filename);
|
||||
#ifdef _WIN32
|
||||
Log.info("Load:", utils::gbk_2_utf8(filename));
|
||||
#else
|
||||
std::string cvt_filename = filename;
|
||||
Log.info("Load:", filename);
|
||||
#endif
|
||||
Log.info("Load:", cvt_filename);
|
||||
|
||||
if (!std::filesystem::exists(cvt_filename)) {
|
||||
if (!std::filesystem::exists(filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string content = utils::load_file_without_bom(cvt_filename);
|
||||
std::string content = utils::load_file_without_bom(filename);
|
||||
|
||||
auto&& ret = json::parser::parse(content);
|
||||
if (!ret) {
|
||||
|
||||
@@ -44,28 +44,30 @@ void asst::AbstractImageAnalyzer::set_roi(const Rect& roi) noexcept
|
||||
|
||||
asst::Rect asst::AbstractImageAnalyzer::empty_rect_to_full(const Rect& rect, const cv::Mat image) noexcept
|
||||
{
|
||||
if (image.empty()) {
|
||||
return rect;
|
||||
}
|
||||
if (rect.empty()) {
|
||||
return Rect(0, 0, image.cols, image.rows);
|
||||
}
|
||||
else {
|
||||
Rect res = rect;
|
||||
if (image.cols < res.x) {
|
||||
Log.error("roi is out of range", image.cols, image.rows, res.to_string());
|
||||
res.x = image.cols - res.width;
|
||||
}
|
||||
if (image.rows < res.y) {
|
||||
Log.error("roi is out of range", image.cols, image.rows, res.to_string());
|
||||
res.y = image.rows - res.height;
|
||||
}
|
||||
|
||||
if (image.cols < res.x + res.width) {
|
||||
Log.error("roi is out of range", res.to_string());
|
||||
res.width = image.cols - res.x;
|
||||
}
|
||||
if (image.rows < res.y + res.height) {
|
||||
Log.error("roi is out of range", res.to_string());
|
||||
res.height = image.rows - res.y;
|
||||
}
|
||||
return res;
|
||||
Rect res = rect;
|
||||
if (image.cols < res.x) {
|
||||
Log.error("roi is out of range", image.cols, image.rows, res.to_string());
|
||||
res.x = image.cols - res.width;
|
||||
}
|
||||
if (image.rows < res.y) {
|
||||
Log.error("roi is out of range", image.cols, image.rows, res.to_string());
|
||||
res.y = image.rows - res.height;
|
||||
}
|
||||
|
||||
if (image.cols < res.x + res.width) {
|
||||
Log.error("roi is out of range", res.to_string());
|
||||
res.width = image.cols - res.x;
|
||||
}
|
||||
if (image.rows < res.y + res.height) {
|
||||
Log.error("roi is out of range", res.to_string());
|
||||
res.height = image.rows - res.y;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,12 @@ AbstractTask& asst::AbstractTask::set_enable(bool enable) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
AbstractTask& asst::AbstractTask::set_ignore_error(bool ignore) noexcept
|
||||
{
|
||||
m_ignore_error = ignore;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AbstractTask& asst::AbstractTask::set_task_id(int task_id) noexcept
|
||||
{
|
||||
m_task_id = task_id;
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace asst
|
||||
virtual AbstractTask& set_ctrler(std::shared_ptr<Controller> ctrler) noexcept;
|
||||
virtual AbstractTask& set_status(std::shared_ptr<RuntimeStatus> status) noexcept;
|
||||
virtual AbstractTask& set_enable(bool enable) noexcept;
|
||||
virtual AbstractTask& set_ignore_error(bool ignore) noexcept;
|
||||
virtual AbstractTask& set_task_id(int task_id) noexcept;
|
||||
|
||||
template<typename PluginType>
|
||||
@@ -51,6 +52,7 @@ namespace asst
|
||||
void clear_plugin() noexcept;
|
||||
|
||||
bool get_enable() const noexcept { return m_enable; }
|
||||
bool get_ignore_error() const noexcept { return m_ignore_error; }
|
||||
const std::string& get_task_chain() const noexcept { return m_task_chain; }
|
||||
int get_task_id() const noexcept { return m_task_id; }
|
||||
virtual json::value basic_info() const;
|
||||
@@ -68,6 +70,7 @@ namespace asst
|
||||
bool save_image(const cv::Mat image, const std::string& dir);
|
||||
|
||||
bool m_enable = true;
|
||||
bool m_ignore_error = true;
|
||||
AsstCallback m_callback;
|
||||
void* m_callback_arg = nullptr;
|
||||
bool* m_exit_flag = nullptr;
|
||||
|
||||
@@ -237,7 +237,11 @@ void Assistant::working_proc()
|
||||
|
||||
bool ret = task_ptr->run();
|
||||
|
||||
m_tasks_list.pop_front();
|
||||
lock.lock();
|
||||
if (!m_tasks_list.empty()) {
|
||||
m_tasks_list.pop_front();
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
auto run_msg = AsstMsg::TaskChainCompleted;
|
||||
if (!ret) {
|
||||
|
||||
@@ -39,8 +39,13 @@ static bool inited = false;
|
||||
|
||||
bool AsstLoadResource(const char* path)
|
||||
{
|
||||
bool log_inited = asst::Logger::set_dirname(std::string(path) + "/");
|
||||
bool resrc_inited = asst::Resrc.load(std::string(path) + "/resource/");
|
||||
#ifdef _WIN32
|
||||
std::string working_path = asst::utils::utf8_to_gbk(path);
|
||||
#else
|
||||
std::string working_path = std::string(path);
|
||||
#endif
|
||||
bool log_inited = asst::Logger::set_dirname(working_path + "/");
|
||||
bool resrc_inited = asst::Resrc.load(working_path + "/resource/");
|
||||
if (!resrc_inited) {
|
||||
std::cerr << asst::Resrc.get_last_error() << std::endl;
|
||||
}
|
||||
@@ -80,7 +85,11 @@ bool AsstConnect(AsstHandle handle, const char* adb_path, const char* address, c
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
return handle->connect(asst::utils::utf8_to_gbk(adb_path), address, config ? config : std::string());
|
||||
#else
|
||||
return handle->connect(adb_path, address, config ? config : std::string());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AsstStart(AsstHandle handle)
|
||||
@@ -108,15 +117,15 @@ TaskId AsstAppendTask(AsstHandle handle, const char* type, const char* params)
|
||||
}
|
||||
|
||||
return handle->append_task(type, params);
|
||||
}
|
||||
|
||||
bool AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params)
|
||||
}
|
||||
|
||||
bool AsstSetTaskParams(AsstHandle handle, TaskId id, const char* params)
|
||||
{
|
||||
if (!inited || handle == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return handle->set_task_params(id, params);
|
||||
return handle->set_task_params(id, params);
|
||||
}
|
||||
|
||||
unsigned long long AsstGetImage(AsstHandle handle, void* buff, unsigned long long buff_size)
|
||||
|
||||
@@ -307,5 +307,5 @@ namespace asst
|
||||
// }
|
||||
// return str;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ bool asst::AutoRecruitTask::recruit_now()
|
||||
bool asst::AutoRecruitTask::confirm()
|
||||
{
|
||||
ProcessTask confirm_task(*this, { "RecruitConfirm" });
|
||||
return confirm_task.run();
|
||||
return confirm_task.set_retry_times(5).run();
|
||||
}
|
||||
|
||||
bool asst::AutoRecruitTask::refresh()
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4068)
|
||||
#include <zlib/decompress.hpp>
|
||||
#pragma warning( pop )
|
||||
|
||||
#include "AsstTypes.h"
|
||||
#include "Logger.hpp"
|
||||
@@ -508,7 +512,7 @@ cv::Mat asst::Controller::get_resized_image() const
|
||||
return cv::Mat(dsize, CV_8UC3);
|
||||
}
|
||||
cv::Mat resized_mat;
|
||||
cv::resize(m_cache_image, resized_mat, dsize);
|
||||
cv::resize(m_cache_image, resized_mat, dsize, 0.0, 0.0, cv::INTER_AREA);
|
||||
return resized_mat;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,37 +6,37 @@
|
||||
#include "BattleFormationTask.h"
|
||||
|
||||
asst::CopilotTask::CopilotTask(AsstCallback callback, void* callback_arg)
|
||||
: PackageTask(callback, callback_arg, TaskType),
|
||||
m_battle_task_ptr(std::make_shared<BattleProcessTask>(callback, callback_arg, TaskType)),
|
||||
m_formation_task_ptr(std::make_shared<BattleFormationTask>(callback, callback_arg, TaskType))
|
||||
: PackageTask(callback, callback_arg, TaskType),
|
||||
m_formation_task_ptr(std::make_shared<BattleFormationTask>(callback, callback_arg, TaskType)),
|
||||
m_battle_task_ptr(std::make_shared<BattleProcessTask>(callback, callback_arg, TaskType))
|
||||
{
|
||||
m_subtasks.emplace_back(m_formation_task_ptr);
|
||||
m_subtasks.emplace_back(m_formation_task_ptr)->set_ignore_error(false);
|
||||
|
||||
auto start_task_ptr = std::make_shared<ProcessTask>(callback, callback_arg, TaskType);
|
||||
start_task_ptr->set_tasks({ "BattleStartNormal", "BattleStartRaid", "BattleStartExercise" });
|
||||
m_subtasks.emplace_back(start_task_ptr);
|
||||
auto start_task_ptr = std::make_shared<ProcessTask>(callback, callback_arg, TaskType);
|
||||
start_task_ptr->set_tasks({ "BattleStartNormal", "BattleStartRaid", "BattleStartExercise" });
|
||||
m_subtasks.emplace_back(start_task_ptr)->set_ignore_error(false);
|
||||
|
||||
m_subtasks.emplace_back(m_battle_task_ptr);
|
||||
m_subtasks.emplace_back(m_battle_task_ptr);
|
||||
}
|
||||
|
||||
bool asst::CopilotTask::set_params(const json::value& params)
|
||||
{
|
||||
if (m_runned) {
|
||||
return false;
|
||||
}
|
||||
if (m_runned) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!params.contains("stage_name") || !params.at("stage_name").is_string()) {
|
||||
return false;
|
||||
}
|
||||
std::string stage_name = params.at("stage_name").as_string();
|
||||
if (!params.contains("stage_name") || !params.at("stage_name").is_string()) {
|
||||
return false;
|
||||
}
|
||||
std::string stage_name = params.at("stage_name").as_string();
|
||||
|
||||
m_battle_task_ptr->set_stage_name(stage_name);
|
||||
m_formation_task_ptr->set_stage_name(stage_name);
|
||||
m_battle_task_ptr->set_stage_name(stage_name);
|
||||
m_formation_task_ptr->set_stage_name(stage_name);
|
||||
|
||||
bool with_formation = params.get("formation", false);
|
||||
m_formation_task_ptr->set_enable(with_formation);
|
||||
bool with_formation = params.get("formation", false);
|
||||
m_formation_task_ptr->set_enable(with_formation);
|
||||
|
||||
std::string filename = params.get("filename", std::string());
|
||||
// 文件名为空时,不加载资源,直接返回 true
|
||||
return filename.empty() || Resrc.copilot().load(filename);
|
||||
}
|
||||
std::string filename = params.get("filename", std::string());
|
||||
// 文件名为空时,不加载资源,直接返回 true
|
||||
return filename.empty() || Resrc.copilot().load(filename);
|
||||
}
|
||||
|
||||
@@ -59,16 +59,17 @@ bool asst::CreditShopImageAnalyzer::commoditys_analyze()
|
||||
|
||||
bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze()
|
||||
{
|
||||
const auto not_to_buy_task_ptr = std::dynamic_pointer_cast<OcrTaskInfo>(
|
||||
Task.get("CreditShop-NotToBuy"));
|
||||
const auto product_name_task_ptr = std::dynamic_pointer_cast<OcrTaskInfo>(
|
||||
Task.get("CreditShop-ProductName"));
|
||||
|
||||
for (const Rect& commodity : m_commoditys) {
|
||||
// 商品名的区域
|
||||
Rect name_roi = not_to_buy_task_ptr->roi;
|
||||
Rect name_roi = product_name_task_ptr->roi;
|
||||
name_roi.x += commodity.x;
|
||||
name_roi.y += commodity.y;
|
||||
|
||||
OcrImageAnalyzer ocr_analyzer(m_image, name_roi);
|
||||
ocr_analyzer.set_replace(product_name_task_ptr->replace_map);
|
||||
ocr_analyzer.set_required(m_shopping_list);
|
||||
if (ocr_analyzer.analyze()) {
|
||||
// 黑名单模式,有识别结果说明这个商品不买,直接跳过
|
||||
@@ -84,8 +85,17 @@ bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze()
|
||||
#ifdef ASST_DEBUG
|
||||
cv::rectangle(m_image_draw, utils::make_rect<cv::Rect>(commodity), cv::Scalar(0, 0, 255), 2);
|
||||
#endif
|
||||
m_need_to_buy.emplace_back(commodity);
|
||||
m_need_to_buy.emplace_back(commodity, ocr_analyzer.get_result().empty() ? std::string() : ocr_analyzer.get_result().front().text);
|
||||
}
|
||||
|
||||
if (m_is_white_list) {
|
||||
std::sort(m_need_to_buy.begin(), m_need_to_buy.end(), [&](
|
||||
const auto& lhs, const auto& rhs) -> bool {
|
||||
return std::find(m_shopping_list.cbegin(), m_shopping_list.cend(), lhs.second)
|
||||
< std::find(m_shopping_list.cbegin(), m_shopping_list.cend(), rhs.second);
|
||||
});
|
||||
}
|
||||
|
||||
return !m_need_to_buy.empty();
|
||||
}
|
||||
|
||||
@@ -95,7 +105,7 @@ bool asst::CreditShopImageAnalyzer::sold_out_analyze()
|
||||
MatchImageAnalyzer sold_out_analyzer(m_image);
|
||||
sold_out_analyzer.set_task_info("CreditShop-SoldOut");
|
||||
|
||||
for (const Rect& commodity : m_need_to_buy) {
|
||||
for (const auto& [commodity, _] : m_need_to_buy) {
|
||||
sold_out_analyzer.set_roi(commodity);
|
||||
if (sold_out_analyzer.analyze()) {
|
||||
#ifdef ASST_DEBUG
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace asst
|
||||
bool sold_out_analyze();
|
||||
|
||||
std::vector<Rect> m_commoditys;
|
||||
std::vector<Rect> m_need_to_buy;
|
||||
std::vector<std::pair<Rect, std::string>> m_need_to_buy;
|
||||
std::vector<Rect> m_result;
|
||||
|
||||
std::vector<std::string> m_shopping_list;
|
||||
|
||||
@@ -16,14 +16,18 @@ asst::FightTask::FightTask(AsstCallback callback, void* callback_arg)
|
||||
.set_times_limit("StartButton2", 0)
|
||||
.set_times_limit("MedicineConfirm", 0)
|
||||
.set_times_limit("StoneConfirm", 0)
|
||||
.set_enable(false);
|
||||
.set_times_limit("StageSNReturnFlag", 0)
|
||||
.set_enable(false)
|
||||
.set_ignore_error(false);
|
||||
|
||||
// 进入对应的关卡
|
||||
m_stage_task_ptr->set_times_limit("StartButton1", 0)
|
||||
.set_times_limit("StartButton2", 0)
|
||||
.set_times_limit("MedicineConfirm", 0)
|
||||
.set_times_limit("StoneConfirm", 0)
|
||||
.set_enable(false);
|
||||
.set_times_limit("StageSNReturnFlag", 0)
|
||||
.set_enable(false)
|
||||
.set_ignore_error(false);
|
||||
|
||||
// 开始战斗任务
|
||||
m_fight_task_ptr->set_tasks({ "FightBegin" })
|
||||
|
||||
@@ -5,50 +5,50 @@
|
||||
|
||||
bool asst::GeneralConfiger::parse(const json::value& json)
|
||||
{
|
||||
LogTraceFunction;
|
||||
LogTraceFunction;
|
||||
|
||||
m_version = json.at("version").as_string();
|
||||
m_version = json.at("version").as_string();
|
||||
|
||||
{
|
||||
const json::value& options_json = json.at("options");
|
||||
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();
|
||||
//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);
|
||||
{
|
||||
const json::value& options_json = json.at("options");
|
||||
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();
|
||||
//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);
|
||||
|
||||
auto& penguin_report = options_json.at("penguinReport");
|
||||
m_options.penguin_report.cmd_format = penguin_report.get("cmdFormat", std::string());
|
||||
auto& penguin_report = options_json.at("penguinReport");
|
||||
m_options.penguin_report.cmd_format = penguin_report.get("cmdFormat", std::string());
|
||||
|
||||
if (options_json.contains("aipOcr")) {
|
||||
auto& aip_ocr = options_json.at("aipOcr");
|
||||
m_options.aip_ocr.enable = aip_ocr.get("enable", false);
|
||||
m_options.aip_ocr.accurate = aip_ocr.get("accurate", false);
|
||||
m_options.aip_ocr.client_id = aip_ocr.get("clientId", std::string());
|
||||
m_options.aip_ocr.client_secret = aip_ocr.get("clientSerect", std::string());
|
||||
}
|
||||
}
|
||||
if (options_json.contains("aipOcr")) {
|
||||
auto& aip_ocr = options_json.at("aipOcr");
|
||||
m_options.aip_ocr.enable = aip_ocr.get("enable", false);
|
||||
m_options.aip_ocr.accurate = aip_ocr.get("accurate", false);
|
||||
m_options.aip_ocr.client_id = aip_ocr.get("clientId", std::string());
|
||||
m_options.aip_ocr.client_secret = aip_ocr.get("clientSerect", std::string());
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [name, cfg_json] : json.at("connection").as_object()) {
|
||||
AdbCfg adb;
|
||||
for (const auto& [name, cfg_json] : json.at("connection").as_object()) {
|
||||
AdbCfg adb;
|
||||
|
||||
adb.devices = cfg_json.at("devices").as_string();
|
||||
adb.address_regex = cfg_json.at("addressRegex").as_string();
|
||||
adb.connect = cfg_json.at("connect").as_string();
|
||||
adb.display_id = cfg_json.get("displayId", std::string());
|
||||
adb.uuid = cfg_json.at("uuid").as_string();
|
||||
adb.click = cfg_json.at("click").as_string();
|
||||
adb.swipe = cfg_json.at("swipe").as_string();
|
||||
adb.display = cfg_json.at("display").as_string();
|
||||
adb.display_format = cfg_json.at("displayFormat").as_string();
|
||||
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.pullscreen = cfg_json.at("pullscreen").as_string();
|
||||
adb.devices = cfg_json.at("devices").as_string();
|
||||
adb.address_regex = cfg_json.at("addressRegex").as_string();
|
||||
adb.connect = cfg_json.at("connect").as_string();
|
||||
adb.display_id = cfg_json.get("displayId", std::string());
|
||||
adb.uuid = cfg_json.at("uuid").as_string();
|
||||
adb.click = cfg_json.at("click").as_string();
|
||||
adb.swipe = cfg_json.at("swipe").as_string();
|
||||
adb.display = cfg_json.at("display").as_string();
|
||||
adb.display_format = cfg_json.at("displayFormat").as_string();
|
||||
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.pullscreen = cfg_json.at("pullscreen").as_string();
|
||||
|
||||
m_adb_cfg[name] = std::move(adb);
|
||||
}
|
||||
m_adb_cfg[name] = std::move(adb);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -556,10 +556,7 @@ bool asst::InfrastProductionTask::opers_choose()
|
||||
[&](const infrast::BattleRealTimeOper& lhs) -> bool {
|
||||
int dist = HashImageAnalyzer::hamming(lhs.face_hash, find_iter->face_hash);
|
||||
Log.debug("opers_choose | face hash dist", dist);
|
||||
if (dist < face_hash_thres) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return dist < face_hash_thres;
|
||||
}
|
||||
);
|
||||
if (avlb_iter != m_all_available_opers.cend()) {
|
||||
@@ -574,13 +571,12 @@ bool asst::InfrastProductionTask::opers_choose()
|
||||
opt_iter = m_optimal_combs.erase(opt_iter);
|
||||
}
|
||||
if (m_optimal_combs.empty()) {
|
||||
if (count >= cur_max_num_of_opers) {
|
||||
break;
|
||||
}
|
||||
else { // 这种情况可能是萌新,可用干员人数不足以填满当前设施
|
||||
Log.trace(__FUNCTION__, "| count", count, "cur_max_num_of_opers", cur_max_num_of_opers);
|
||||
if (count < cur_max_num_of_opers) {
|
||||
// 这种情况可能是萌新,可用干员人数不足以填满当前设施
|
||||
callback(AsstMsg::SubTaskExtraInfo, basic_info_with_what("NotEnoughStaff"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 因为识别完了还要点击,所以这里不能异步滑动
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <mutex>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
#include "AsstUtils.hpp"
|
||||
#include "Version.h"
|
||||
@@ -109,7 +110,11 @@ namespace asst
|
||||
trace("MeoAssistant Process Start");
|
||||
trace("Version", asst::Version);
|
||||
trace("Build DataTime", __DATE__, __TIME__);
|
||||
#ifdef _WIN32 // 输出到日志的时候统一编码utf8
|
||||
trace("Working Path", asst::utils::gbk_2_utf8(m_dirname));
|
||||
#else
|
||||
trace("Working Path", m_dirname);
|
||||
#endif
|
||||
trace("-----------------------------");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@
|
||||
asst::MallTask::MallTask(AsstCallback callback, void* callback_arg)
|
||||
: PackageTask(callback, callback_arg, TaskType),
|
||||
m_mall_task_ptr(std::make_shared<ProcessTask>(callback, callback_arg, TaskType)),
|
||||
m_shopping_first_task_ptr(std::make_shared<CreditShoppingTask>(callback, callback_arg, TaskType)),
|
||||
m_shopping_task_ptr(std::make_shared<CreditShoppingTask>(callback, callback_arg, TaskType))
|
||||
{
|
||||
m_mall_task_ptr->set_tasks({ "MallBegin" });
|
||||
m_shopping_task_ptr->set_enable(false);
|
||||
m_shopping_first_task_ptr->set_enable(false).set_retry_times(1);
|
||||
m_shopping_task_ptr->set_enable(false).set_retry_times(1);
|
||||
|
||||
m_subtasks.emplace_back(m_mall_task_ptr);
|
||||
m_subtasks.emplace_back(m_shopping_first_task_ptr);
|
||||
m_subtasks.emplace_back(m_shopping_task_ptr);
|
||||
}
|
||||
|
||||
@@ -20,24 +23,35 @@ bool asst::MallTask::set_params(const json::value& params)
|
||||
bool shopping = params.get("shopping", true);
|
||||
|
||||
if (shopping) {
|
||||
if (params.contains("shopping_list") && params.at("shopping_list").is_array()) {
|
||||
std::vector<std::string> shopping_list;
|
||||
for (auto& name : params.at("shopping_list").as_array()) {
|
||||
shopping_list.emplace_back(name.as_string());
|
||||
if (params.contains("buy_first") && params.at("buy_first").is_array()) {
|
||||
std::vector<std::string> buy_first;
|
||||
for (auto& name : params.at("buy_first").as_array()) {
|
||||
buy_first.emplace_back(name.as_string());
|
||||
}
|
||||
if (params.get("is_black_list", false) == true) {
|
||||
m_shopping_task_ptr->set_black_list(std::move(shopping_list));
|
||||
if (!buy_first.empty()) {
|
||||
m_shopping_first_task_ptr->set_white_list(std::move(buy_first));
|
||||
m_shopping_first_task_ptr->set_enable(true);
|
||||
}
|
||||
else {
|
||||
m_shopping_task_ptr->set_white_list(std::move(shopping_list));
|
||||
m_shopping_first_task_ptr->set_enable(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
m_shopping_first_task_ptr->set_enable(false);
|
||||
}
|
||||
|
||||
if (params.contains("blacklist") && params.at("blacklist").is_array()) {
|
||||
std::vector<std::string> shopping_list;
|
||||
for (auto& name : params.at("blacklist").as_array()) {
|
||||
shopping_list.emplace_back(name.as_string());
|
||||
}
|
||||
m_shopping_task_ptr->set_black_list(std::move(shopping_list));
|
||||
}
|
||||
|
||||
m_shopping_task_ptr->set_enable(true);
|
||||
}
|
||||
else {
|
||||
m_shopping_first_task_ptr->set_enable(false);
|
||||
m_shopping_task_ptr->set_enable(false);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace asst
|
||||
static constexpr const char* TaskType = "Mall";
|
||||
private:
|
||||
std::shared_ptr<ProcessTask> m_mall_task_ptr = nullptr;
|
||||
std::shared_ptr<CreditShoppingTask> m_shopping_first_task_ptr = nullptr;
|
||||
std::shared_ptr<CreditShoppingTask> m_shopping_task_ptr = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -248,7 +248,8 @@
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<AdditionalOptions>/utf-8 /MP %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>/utf-8 /MP $(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -297,6 +298,7 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<AdditionalOptions>/utf-8 /MP %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -327,6 +329,7 @@
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<AdditionalOptions>/utf-8 /MP %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@@ -370,4 +373,4 @@
|
||||
<UserProperties _1_1_4_1_1_4resource_4config_1json__JsonSchema="" _1_1_4_1_1_4resource_4tasks_1json__JsonSchema="../docs/maa_tasks_schema.json" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -28,7 +28,7 @@ bool asst::PackageTask::run()
|
||||
.set_status(m_status)
|
||||
.set_task_id(m_task_id);
|
||||
|
||||
if (!task_ptr->run()) {
|
||||
if (!task_ptr->run() && !task_ptr->get_ignore_error()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ bool asst::PenguinPack::load(const std::string& dir)
|
||||
bool ret = load_json(dir + "/json/stages.json", dir + "/json/hash_index.json");
|
||||
|
||||
for (const auto& file : std::filesystem::directory_iterator(dir + "/items")) {
|
||||
ret &= load_templ(file.path().stem().u8string(), file.path().u8string());
|
||||
ret &= load_templ(file.path().stem().string(), file.path().string());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ asst::RecruitTask::RecruitTask(AsstCallback callback, void* callback_arg)
|
||||
m_recruit_only_calc_task_ptr->set_enable(false);
|
||||
|
||||
m_subtasks.emplace_back(m_recruit_begin_task_ptr);
|
||||
m_subtasks.emplace_back(m_auto_recruit_task_ptr);
|
||||
m_subtasks.emplace_back(m_auto_recruit_task_ptr)->set_retry_times(1);
|
||||
m_subtasks.emplace_back(m_recruit_only_calc_task_ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ bool asst::Resource::load(const std::string& dir)
|
||||
if (entry.path().extension() != ".json") {
|
||||
continue;
|
||||
}
|
||||
if (!m_copilot_cfg_unique_ins.load(entry.path().u8string())) {
|
||||
m_last_error = entry.path().u8string() + " Load failed";
|
||||
if (!m_copilot_cfg_unique_ins.load(entry.path().string())) {
|
||||
m_last_error = entry.path().string() + " Load failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -93,8 +93,8 @@ bool asst::Resource::load(const std::string& dir)
|
||||
if (entry.path().extension() != ".json") {
|
||||
continue;
|
||||
}
|
||||
if (!m_roguelike_cfg_unique_ins.load(entry.path().u8string())) {
|
||||
m_last_error = entry.path().u8string() + " Load failed";
|
||||
if (!m_roguelike_cfg_unique_ins.load(entry.path().string())) {
|
||||
m_last_error = entry.path().string() + " Load failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ bool asst::StageDropsTaskPlugin::recognize_drops()
|
||||
auto last_time = last_time_opt ? last_time_opt.value() : 0;
|
||||
m_status->set_data("LastRecognizeDrops", last_time + RecognizationTimeOffset);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
asst::TilePack::~TilePack() = default;
|
||||
|
||||
bool asst::TilePack::load(const std::string & dir)
|
||||
bool asst::TilePack::load(const std::string& dir)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
@@ -28,7 +28,7 @@ bool asst::TilePack::load(const std::string & dir)
|
||||
}
|
||||
|
||||
std::unordered_map<asst::Point, asst::TilePack::TileInfo> asst::TilePack::calc(
|
||||
const std::string & stage_code, bool side) const
|
||||
const std::string& stage_code, bool side) const
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
|
||||
@@ -2,5 +2,10 @@
|
||||
|
||||
namespace asst
|
||||
{
|
||||
constexpr static const char* Version = "DEBUG VERSION";
|
||||
constexpr static const char* Version =
|
||||
#ifdef MAA_VERSION
|
||||
MAA_VERSION;
|
||||
#else
|
||||
"DEBUG VERSION";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public static class Constants
|
||||
public const string MaaWpfProjectFilePath = $"{MaaWpfProjectDirectory}/MeoAsstGui.csproj";
|
||||
|
||||
public const string MaaBuildOutputDirectory = $"{MaaProjectRootDirectory}/x64";
|
||||
|
||||
|
||||
public const string MaaCoreBuildIntermediatOutputDirectory = $"{MaaCoreProjectDirectory}/x64";
|
||||
|
||||
public static readonly string[] MaaCoreExtraFiles = new [] { "MeoAssistant.pdb", "MeoAssistant.lib", "MeoAssistant.exp" };
|
||||
public static readonly string[] MaaCoreExtraFiles = new[] { "MeoAssistant.pdb", "MeoAssistant.lib", "MeoAssistant.exp" };
|
||||
|
||||
public static readonly string[] MaaWpfExtraFiles = new[] { "MeoAsstGui.pdb", "MeoAsstGui.exe.config" };
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Cake.Common.Diagnostics;
|
||||
using Cake.Common.IO;
|
||||
|
||||
namespace MeoAssistantBuilder.Helper;
|
||||
|
||||
public static class CleanDirectoryHelper
|
||||
{
|
||||
public static void CleanArtifacts(this MaaBuildContext context)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MeoAssistantBuilder;
|
||||
public class MaaBuildContext : FrostingContext
|
||||
{
|
||||
public string MsBuildExecutable { get; set; }
|
||||
|
||||
|
||||
public MaaBuildContext(ICakeContext context) : base(context)
|
||||
{
|
||||
MsBuildExecutable = context.Argument<string>("tool", "");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Cake.Common.Build;
|
||||
using Cake.Common.Diagnostics;
|
||||
using Cake.Frosting;
|
||||
using MeoAssistantBuilder.Helper;
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class ReleaseBundleTask : FrostingTask<MaaBuildContext>
|
||||
{
|
||||
version += $"-{ghActions.Environment.Workflow.RunId}";
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
var tag = ghActions.Environment.Workflow.Ref.Replace("refs/tags/", "");
|
||||
if (tag != version)
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class ReleaseCoreTask : FrostingTask<MaaBuildContext>
|
||||
{
|
||||
version += $"-{ghActions.Environment.Workflow.RunId}";
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
var tag = ghActions.Environment.Workflow.Ref.Replace("refs/tags/", "");
|
||||
if (tag != version)
|
||||
@@ -78,7 +78,7 @@ public sealed class ReleaseCoreTask : FrostingTask<MaaBuildContext>
|
||||
context.Information("--------------------------------------------------");
|
||||
|
||||
var thirdPartyDlls = Directory.GetFiles(Path.Combine(Constants.MaaProjectThirdPartyDirectory, "bin"));
|
||||
foreach(var f in thirdPartyDlls)
|
||||
foreach (var f in thirdPartyDlls)
|
||||
{
|
||||
var fileName = new FileInfo(f).Name;
|
||||
File.Copy(f, Path.Combine(buildOutput, fileName));
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Cake.Common.Build;
|
||||
using Cake.Common.Diagnostics;
|
||||
using Cake.Frosting;
|
||||
using MeoAssistantBuilder.Helper;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Cake.Common.Build;
|
||||
using Cake.Common.Diagnostics;
|
||||
using Cake.Frosting;
|
||||
using MeoAssistantBuilder.Helper;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -224,7 +224,6 @@ namespace MeoAsstGui
|
||||
|
||||
private static void BindRectangleVerticalOffsetList(ScrollViewer scrollViewer)
|
||||
{
|
||||
|
||||
if (scrollViewer.GetValue(RectangleVerticalOffsetListBindingProperty) != null)
|
||||
return;
|
||||
|
||||
@@ -257,6 +256,5 @@ namespace MeoAsstGui
|
||||
}
|
||||
|
||||
#endregion RectangleVerticalOffsetList attached property
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace MeoAsstGui
|
||||
// 最大显示宽度
|
||||
NotificationConstants.MaxWidth = 460d;
|
||||
|
||||
#endregion
|
||||
#endregion 初始化 Notification.Wpf 默认静态配置
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -130,7 +130,7 @@ namespace MeoAsstGui
|
||||
None
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 通知提示音列表枚举
|
||||
|
||||
/// <summary>
|
||||
/// 播放通知提示音
|
||||
@@ -180,19 +180,23 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 通知提示音
|
||||
|
||||
#region 通知按钮设置
|
||||
|
||||
#region 通知按钮变量
|
||||
|
||||
// 左边按钮
|
||||
protected string _buttonLeftText = null;
|
||||
|
||||
protected Action _buttonLeftAction = null;
|
||||
|
||||
// 右边按钮
|
||||
protected string _buttonRightText = null;
|
||||
|
||||
protected Action _buttonRightAction = null;
|
||||
#endregion
|
||||
|
||||
#endregion 通知按钮变量
|
||||
|
||||
/// <summary>
|
||||
/// 给通知添加一个在左边的按钮,比如确定按钮,多次设置只会按最后一次设置生效
|
||||
@@ -220,7 +224,7 @@ namespace MeoAsstGui
|
||||
return this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 通知按钮设置
|
||||
|
||||
#region 通知显示
|
||||
|
||||
@@ -279,7 +283,7 @@ namespace MeoAsstGui
|
||||
return content;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 通知基本字体样式和内容模板
|
||||
|
||||
#region 显示通知方法
|
||||
|
||||
@@ -373,9 +377,9 @@ namespace MeoAsstGui
|
||||
notificationContent: content);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 显示通知方法
|
||||
|
||||
#endregion
|
||||
#endregion 通知显示
|
||||
|
||||
#region 任务栏闪烁
|
||||
|
||||
@@ -457,7 +461,7 @@ namespace MeoAsstGui
|
||||
return FlashWindowEx(ref fInfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion 任务栏闪烁
|
||||
|
||||
/// <summary>
|
||||
/// 通知使用完后释放已使用的数据
|
||||
@@ -472,6 +476,5 @@ namespace MeoAsstGui
|
||||
_buttonLeftText = _buttonRightText = null;
|
||||
_buttonLeftAction = _buttonRightAction = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,87 +1,84 @@
|
||||
// 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;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
// 界面设置存储(读写json文件)
|
||||
public class ViewStatusStorage
|
||||
{
|
||||
private static readonly string _configFilename = System.Environment.CurrentDirectory + "\\gui.json";
|
||||
private static JObject _viewStatus = new JObject();
|
||||
|
||||
public static string Get(string key, string defalut_value)
|
||||
{
|
||||
if (_viewStatus.ContainsKey(key))
|
||||
{
|
||||
return _viewStatus[key].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return defalut_value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(string key, string value)
|
||||
{
|
||||
_viewStatus[key] = value;
|
||||
Save();
|
||||
}
|
||||
|
||||
public static bool Load()
|
||||
{
|
||||
if (File.Exists(_configFilename))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(_configFilename))
|
||||
{
|
||||
string jsonStr = sr.ReadToEnd();
|
||||
|
||||
// 文件存在但为空,会读出来一个null,感觉c#这库有bug,如果是null 就赋值一个空JObject
|
||||
_viewStatus = (JObject)JsonConvert.DeserializeObject(jsonStr) ?? new JObject();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_viewStatus = new JObject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewStatus = new JObject();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(_configFilename))
|
||||
{
|
||||
sw.Write(_viewStatus.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
// 界面设置存储(读写json文件)
|
||||
public class ViewStatusStorage
|
||||
{
|
||||
private static readonly string _configFilename = System.Environment.CurrentDirectory + "\\gui.json";
|
||||
private static JObject _viewStatus = new JObject();
|
||||
|
||||
public static string Get(string key, string defalut_value)
|
||||
{
|
||||
if (_viewStatus.ContainsKey(key))
|
||||
{
|
||||
return _viewStatus[key].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return defalut_value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(string key, string value)
|
||||
{
|
||||
_viewStatus[key] = value;
|
||||
Save();
|
||||
}
|
||||
|
||||
public static bool Load()
|
||||
{
|
||||
if (File.Exists(_configFilename))
|
||||
{
|
||||
try
|
||||
{
|
||||
string jsonStr = File.ReadAllText(_configFilename);
|
||||
|
||||
// 文件存在但为空,会读出来一个null,感觉c#这库有bug,如果是null 就赋值一个空JObject
|
||||
_viewStatus = (JObject)JsonConvert.DeserializeObject(jsonStr) ?? new JObject();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_viewStatus = new JObject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewStatus = new JObject();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(_configFilename))
|
||||
{
|
||||
sw.Write(_viewStatus.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Center">
|
||||
<CheckBox IsChecked="{Binding UseStone}" IsHitTestVisible="{Binding Idle}" Content="吃石头 " Margin="10" />
|
||||
<CheckBox IsChecked="{Binding UseStone}" IsHitTestVisible="{Binding Idle}" Content="吃石头 " Margin="10" />
|
||||
<TextBox Text="{Binding StoneNumber}" IsReadOnly="{c:Binding Path=!Idle}" TextWrapping="Wrap" Margin="10"
|
||||
Width="50" InputMethod.IsInputMethodEnabled="False" />
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="颗" />
|
||||
|
||||
@@ -8,9 +8,23 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="550">
|
||||
<Grid>
|
||||
<!--IsEnabled="{Binding CreditShoppingCheckBoxIsEnable}"-->
|
||||
<CheckBox IsChecked="{Binding CreditShopping}" Block.TextAlignment="Center"
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox Grid.Row="0" IsChecked="{Binding CreditShopping}" Block.TextAlignment="Center" Margin="10"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Content="信用商店随缘买 (不买碳和家具)" />
|
||||
Content=" 信用购物 " />
|
||||
<StackPanel Grid.Row="1" IsEnabled="{Binding CreditShopping}" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center"
|
||||
Text="优先购买
子串即可,空格分隔" Margin="10" />
|
||||
<TextBox Text="{Binding CreditFirstList}" Margin="10" Width="250" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" IsEnabled="{Binding CreditShopping}" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center"
|
||||
Text="黑名单
子串即可,空格分隔" Margin="10" />
|
||||
<TextBox Text="{Binding CreditBlackList}" Margin="10" Width="250" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -86,7 +86,6 @@
|
||||
VerticalAlignment="Bottom" Content="↘ 右下"
|
||||
IsChecked="{Binding ToastPositionBottomRight}" />
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Button
|
||||
@@ -95,4 +94,4 @@
|
||||
Command="{s:Action ToastPositionTest}"
|
||||
Content="测试通知" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -17,9 +17,10 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3">
|
||||
<CheckBox IsChecked="{Binding AutoDownloadUpdatePackage}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="自动下载更新包 " />
|
||||
<CheckBox IsChecked="{Binding UpdateBeta}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="检查测试版本更新 " />
|
||||
<CheckBox IsChecked="{Binding UseAria2}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="使用aria2进行下载" />
|
||||
<CheckBox IsChecked="{Binding UpdateCheck}" IsEnabled="False" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="检查更新" />
|
||||
<CheckBox IsChecked="{Binding AutoDownloadUpdatePackage}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="自动下载更新包" />
|
||||
<CheckBox IsChecked="{Binding UpdateBeta}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="检查测试版本更新" />
|
||||
<CheckBox IsChecked="{Binding UseAria2}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="使用 aria2 进行下载" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3">
|
||||
<Grid>
|
||||
|
||||
@@ -1,158 +1,158 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public class RecruitViewModel : Screen
|
||||
{
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly IContainer _container;
|
||||
|
||||
public RecruitViewModel(IContainer container, IWindowManager windowManager)
|
||||
{
|
||||
_container = container;
|
||||
_windowManager = windowManager;
|
||||
DisplayName = "公招识别";
|
||||
}
|
||||
|
||||
private string _recruitInfo = "小提示:和主界面的自动公招是两个独立的功能,请手动打开游戏公招Tags界面后使用~";
|
||||
|
||||
public string RecruitInfo
|
||||
{
|
||||
get { return _recruitInfo; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _recruitInfo, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _recruitResult;
|
||||
|
||||
public string RecruitResult
|
||||
{
|
||||
get { return _recruitResult; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _recruitResult, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel3 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel3", bool.FalseString));
|
||||
|
||||
public bool ChooseLevel3
|
||||
{
|
||||
get { return _chooseLevel3; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel3, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel3", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel4 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel4", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel4
|
||||
{
|
||||
get { return _chooseLevel4; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel4, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel4", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel5 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel5", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel5
|
||||
{
|
||||
get { return _chooseLevel5; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel5, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel5", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel6 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel6", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel6
|
||||
{
|
||||
get { return _chooseLevel6; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel6, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel6", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _autoSetTime = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.AutoSetTime", bool.TrueString));
|
||||
|
||||
public bool AutoSetTime
|
||||
{
|
||||
get { return _autoSetTime; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _autoSetTime, value);
|
||||
ViewStatusStorage.Set("Recruit.AutoSetTime", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _catched = false;
|
||||
|
||||
public async void StartCalc()
|
||||
{
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
if (!_catched)
|
||||
{
|
||||
RecruitInfo = "正在连接模拟器……";
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstConnect();
|
||||
});
|
||||
_catched = await task;
|
||||
}
|
||||
if (!_catched)
|
||||
{
|
||||
RecruitInfo = "连接模拟器失败,请参考使用说明处理";
|
||||
return;
|
||||
}
|
||||
RecruitInfo = "正在识别……";
|
||||
RecruitResult = "";
|
||||
|
||||
var levelList = new List<int>();
|
||||
|
||||
if (ChooseLevel3)
|
||||
{
|
||||
levelList.Add(3);
|
||||
}
|
||||
if (ChooseLevel4)
|
||||
{
|
||||
levelList.Add(4);
|
||||
}
|
||||
if (ChooseLevel5)
|
||||
{
|
||||
levelList.Add(5);
|
||||
}
|
||||
if (ChooseLevel6)
|
||||
{
|
||||
levelList.Add(6);
|
||||
}
|
||||
|
||||
asstProxy.AsstStartRecruitCalc(levelList.ToArray(), levelList.Count, AutoSetTime);
|
||||
asstProxy.AsstStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public class RecruitViewModel : Screen
|
||||
{
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly IContainer _container;
|
||||
|
||||
public RecruitViewModel(IContainer container, IWindowManager windowManager)
|
||||
{
|
||||
_container = container;
|
||||
_windowManager = windowManager;
|
||||
DisplayName = "公招识别";
|
||||
}
|
||||
|
||||
private string _recruitInfo = "小提示:和主界面的自动公招是两个独立的功能,请手动打开游戏公招Tags界面后使用~";
|
||||
|
||||
public string RecruitInfo
|
||||
{
|
||||
get { return _recruitInfo; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _recruitInfo, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _recruitResult;
|
||||
|
||||
public string RecruitResult
|
||||
{
|
||||
get { return _recruitResult; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _recruitResult, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel3 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel3", bool.FalseString));
|
||||
|
||||
public bool ChooseLevel3
|
||||
{
|
||||
get { return _chooseLevel3; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel3, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel3", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel4 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel4", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel4
|
||||
{
|
||||
get { return _chooseLevel4; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel4, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel4", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel5 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel5", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel5
|
||||
{
|
||||
get { return _chooseLevel5; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel5, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel5", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _chooseLevel6 = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.ChooseLevel6", bool.TrueString));
|
||||
|
||||
public bool ChooseLevel6
|
||||
{
|
||||
get { return _chooseLevel6; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _chooseLevel6, value);
|
||||
ViewStatusStorage.Set("Recruit.ChooseLevel6", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _autoSetTime = System.Convert.ToBoolean(ViewStatusStorage.Get("Recruit.AutoSetTime", bool.TrueString));
|
||||
|
||||
public bool AutoSetTime
|
||||
{
|
||||
get { return _autoSetTime; }
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _autoSetTime, value);
|
||||
ViewStatusStorage.Set("Recruit.AutoSetTime", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _catched = false;
|
||||
|
||||
public async void StartCalc()
|
||||
{
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
if (!_catched)
|
||||
{
|
||||
RecruitInfo = "正在连接模拟器……";
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
return asstProxy.AsstConnect();
|
||||
});
|
||||
_catched = await task;
|
||||
}
|
||||
if (!_catched)
|
||||
{
|
||||
RecruitInfo = "连接模拟器失败,请参考使用说明处理";
|
||||
return;
|
||||
}
|
||||
RecruitInfo = "正在识别……";
|
||||
RecruitResult = "";
|
||||
|
||||
var levelList = new List<int>();
|
||||
|
||||
if (ChooseLevel3)
|
||||
{
|
||||
levelList.Add(3);
|
||||
}
|
||||
if (ChooseLevel4)
|
||||
{
|
||||
levelList.Add(4);
|
||||
}
|
||||
if (ChooseLevel5)
|
||||
{
|
||||
levelList.Add(5);
|
||||
}
|
||||
if (ChooseLevel6)
|
||||
{
|
||||
levelList.Add(6);
|
||||
}
|
||||
|
||||
asstProxy.AsstStartRecruitCalc(levelList.ToArray(), levelList.Count, AutoSetTime);
|
||||
asstProxy.AsstStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +1,90 @@
|
||||
// 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.Threading.Tasks;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public class RootViewModel : Conductor<Screen>.Collection.OneActive
|
||||
{
|
||||
private readonly IContainer _container;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public RootViewModel(IContainer container, IWindowManager windowManager)
|
||||
{
|
||||
_container = container;
|
||||
_windowManager = windowManager;
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
CheckAndUpdateNow();
|
||||
InitProxy();
|
||||
InitViewModels();
|
||||
ShowUpdateOrDownload();
|
||||
}
|
||||
|
||||
private async void InitProxy()
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
var p = _container.Get<AsstProxy>();
|
||||
p.Init();
|
||||
});
|
||||
|
||||
await task;
|
||||
}
|
||||
|
||||
private void InitViewModels()
|
||||
{
|
||||
var tvm = _container.Get<TaskQueueViewModel>();
|
||||
var rvm = _container.Get<RecruitViewModel>();
|
||||
//var ivm = _container.Get<InfrastViewModel>();
|
||||
var svm = _container.Get<SettingsViewModel>();
|
||||
|
||||
Items.Add(tvm);
|
||||
Items.Add(rvm);
|
||||
//Items.Add(ivm);
|
||||
Items.Add(svm);
|
||||
ActiveItem = tvm;
|
||||
}
|
||||
|
||||
private bool CheckAndUpdateNow()
|
||||
{
|
||||
var vuvm = _container.Get<VersionUpdateViewModel>();
|
||||
return vuvm.CheckAndUpdateNow();
|
||||
}
|
||||
|
||||
private async void ShowUpdateOrDownload()
|
||||
{
|
||||
var vuvm = _container.Get<VersionUpdateViewModel>();
|
||||
|
||||
if (vuvm.IsFirstBootAfterUpdate)
|
||||
{
|
||||
_windowManager.ShowWindow(vuvm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
if (!vuvm.CheckAndDownloadUpdate())
|
||||
{
|
||||
vuvm.ResourceOTA();
|
||||
}
|
||||
});
|
||||
|
||||
await task;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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.Threading.Tasks;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
|
||||
namespace MeoAsstGui
|
||||
{
|
||||
public class RootViewModel : Conductor<Screen>.Collection.OneActive
|
||||
{
|
||||
private readonly IContainer _container;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public RootViewModel(IContainer container, IWindowManager windowManager)
|
||||
{
|
||||
_container = container;
|
||||
_windowManager = windowManager;
|
||||
}
|
||||
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
CheckAndUpdateNow();
|
||||
InitProxy();
|
||||
InitViewModels();
|
||||
ShowUpdateOrDownload();
|
||||
}
|
||||
|
||||
private async void InitProxy()
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
var p = _container.Get<AsstProxy>();
|
||||
p.Init();
|
||||
});
|
||||
|
||||
await task;
|
||||
}
|
||||
|
||||
private void InitViewModels()
|
||||
{
|
||||
var tvm = _container.Get<TaskQueueViewModel>();
|
||||
var rvm = _container.Get<RecruitViewModel>();
|
||||
//var ivm = _container.Get<InfrastViewModel>();
|
||||
var svm = _container.Get<SettingsViewModel>();
|
||||
|
||||
Items.Add(tvm);
|
||||
Items.Add(rvm);
|
||||
//Items.Add(ivm);
|
||||
Items.Add(svm);
|
||||
ActiveItem = tvm;
|
||||
}
|
||||
|
||||
private bool CheckAndUpdateNow()
|
||||
{
|
||||
var vuvm = _container.Get<VersionUpdateViewModel>();
|
||||
return vuvm.CheckAndUpdateNow();
|
||||
}
|
||||
|
||||
private async void ShowUpdateOrDownload()
|
||||
{
|
||||
var vuvm = _container.Get<VersionUpdateViewModel>();
|
||||
|
||||
if (vuvm.IsFirstBootAfterUpdate)
|
||||
{
|
||||
_windowManager.ShowWindow(vuvm);
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
if (!vuvm.CheckAndDownloadUpdate())
|
||||
{
|
||||
vuvm.ResourceOTA();
|
||||
}
|
||||
});
|
||||
|
||||
await task;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,20 +70,20 @@ namespace MeoAsstGui
|
||||
new CombData { Display = "当前关卡", Value = string.Empty },
|
||||
new CombData { Display = "上次作战", Value = "LastBattle" },
|
||||
new CombData { Display = "剿灭作战", Value = "Annihilation" },
|
||||
new CombData { Display = "龙门币-6/5", Value = "CE-6" },
|
||||
new CombData { Display = "龙门币-6/5", Value = "CE-6" },
|
||||
new CombData { Display = "经验-6/5", Value = "LS-6" },
|
||||
new CombData { Display = "红票-5", Value = "AP-5" },
|
||||
new CombData { Display = "技能-5", Value = "CA-5" },
|
||||
new CombData { Display = "1-7", Value = "1-7" },
|
||||
|
||||
// “愚人号” 活动关卡
|
||||
new CombData { Display = "SN-8", Value = "SN-8" },
|
||||
new CombData { Display = "SN-9", Value = "SN-9" },
|
||||
new CombData { Display = "SN-10", Value = "SN-10" },
|
||||
|
||||
new CombData { Display = "1-7", Value = "1-7" },
|
||||
|
||||
// “愚人号” 活动关卡
|
||||
new CombData { Display = "SN-8", Value = "SN-8" },
|
||||
new CombData { Display = "SN-9", Value = "SN-9" },
|
||||
new CombData { Display = "SN-10", Value = "SN-10" },
|
||||
|
||||
//// “风雪过境” 活动关卡
|
||||
//new CombData { Display = "BI-7", Value = "BI-7" },
|
||||
//new CombData { Display = "BI-8", Value = "BI-8" }
|
||||
//new CombData { Display = "BI-7", Value = "BI-7" },
|
||||
//new CombData { Display = "BI-8", Value = "BI-8" }
|
||||
};
|
||||
|
||||
var now = DateTime.Now;
|
||||
@@ -210,7 +210,6 @@ namespace MeoAsstGui
|
||||
Idle = true;
|
||||
return;
|
||||
}
|
||||
setPenguinId();
|
||||
|
||||
if (Idle) // 一般是点了“停止”按钮了
|
||||
{
|
||||
@@ -296,7 +295,9 @@ namespace MeoAsstGui
|
||||
{
|
||||
var settings = _container.Get<SettingsViewModel>();
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
return asstProxy.AsstAppendMall(settings.CreditShopping);
|
||||
var buy_first = settings.CreditFirstList.Split(' ');
|
||||
var black_list = settings.CreditBlackList.Split(' ');
|
||||
return asstProxy.AsstAppendMall(settings.CreditShopping, buy_first, black_list);
|
||||
}
|
||||
|
||||
private bool appendRecruit()
|
||||
@@ -346,13 +347,6 @@ namespace MeoAsstGui
|
||||
return asstProxy.AsstAppendRoguelike(mode);
|
||||
}
|
||||
|
||||
private void setPenguinId()
|
||||
{
|
||||
var settings = _container.Get<SettingsViewModel>();
|
||||
var asstProxy = _container.Get<AsstProxy>();
|
||||
asstProxy.AsstSetPenguinId(settings.PenguinId);
|
||||
}
|
||||
|
||||
public void CheckAndShutdown()
|
||||
{
|
||||
if (Shutdown)
|
||||
@@ -476,4 +470,4 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
Title="MeoAssistantArknights" Height="595" Width="800">
|
||||
Title="MaaAssistantArknights" Height="595" Width="800">
|
||||
<DockPanel>
|
||||
<TabControl Style="{StaticResource StyletConductorTabControl}" Margin="0,10,0,0" />
|
||||
</DockPanel>
|
||||
|
||||
@@ -52,8 +52,8 @@ if __name__ == "__main__":
|
||||
asst.append_task('Visit')
|
||||
asst.append_task('Mall', {
|
||||
'shopping': True,
|
||||
'shopping_list': ['家具', '碳'],
|
||||
'is_black_list': True
|
||||
'buy_first': ['招聘许可', '龙门币'],
|
||||
'blacklist': ['家具', '碳'],
|
||||
})
|
||||
asst.append_task('Award')
|
||||
# asst.append_task('Copilot', {
|
||||
|
||||
@@ -48,8 +48,8 @@ def job():
|
||||
asst.append_task('Visit')
|
||||
asst.append_task('Mall', {
|
||||
'shopping': True,
|
||||
'shopping_list': ['家具', '碳'],
|
||||
'is_black_list': True
|
||||
'buy_first': ['招聘许可', '龙门币'],
|
||||
'blacklist': ['家具', '碳'],
|
||||
})
|
||||
asst.append_task('Award')
|
||||
|
||||
|
||||
33
src/dart/.gitignore
vendored
Normal file
33
src/dart/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
*.so
|
||||
build/
|
||||
native/build/
|
||||
libraries/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.packages
|
||||
build/
|
||||
10
src/dart/.metadata
Normal file
10
src/dart/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5464c5bac742001448fe4fc0597be939379f88ea
|
||||
channel: stable
|
||||
|
||||
project_type: plugin
|
||||
3
src/dart/CHANGELOG.md
Normal file
3
src/dart/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
1
src/dart/LICENSE
Normal file
1
src/dart/LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
TODO: Add your license here.
|
||||
15
src/dart/README.md
Normal file
15
src/dart/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# maa_core
|
||||
|
||||
A new flutter plugin project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Flutter
|
||||
[plug-in package](https://flutter.dev/developing-packages/),
|
||||
a specialized package that includes platform-specific implementation code for
|
||||
Android and/or iOS.
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
|
||||
4
src/dart/analysis_options.yaml
Normal file
4
src/dart/analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
47
src/dart/example/.gitignore
vendored
Normal file
47
src/dart/example/.gitignore
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
resource/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Web related
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
10
src/dart/example/.metadata
Normal file
10
src/dart/example/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 5464c5bac742001448fe4fc0597be939379f88ea
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
16
src/dart/example/README.md
Normal file
16
src/dart/example/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# example
|
||||
|
||||
A new Flutter project.
|
||||
|
||||
## Getting Started
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
|
||||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
|
||||
|
||||
For help getting started with Flutter, view our
|
||||
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
29
src/dart/example/analysis_options.yaml
Normal file
29
src/dart/example/analysis_options.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This file configures the analyzer, which statically analyzes Dart code to
|
||||
# check for errors, warnings, and lints.
|
||||
#
|
||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||
# invoked from the command line by running `flutter analyze`.
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
# The lint rules applied to this project can be customized in the
|
||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||
# included above or to enable additional rules. A list of all available lints
|
||||
# and their documentation is published at
|
||||
# https://dart-lang.github.io/linter/lints/index.html.
|
||||
#
|
||||
# Instead of disabling a lint rule for the entire project in the
|
||||
# section below, it can also be suppressed for a single line of code
|
||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||
# producing the lint.
|
||||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
98
src/dart/example/lib/main.dart
Normal file
98
src/dart/example/lib/main.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import "package:maa_core/maa_core.dart";
|
||||
import 'package:maa_core/typedefs.dart';
|
||||
import "package:path/path.dart" as p;
|
||||
|
||||
void main() {
|
||||
print(Directory.current.path);
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// is not restarted.
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({Key? key, required this.title}) : super(key: key);
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
late MaaCore _asst;
|
||||
List<String> _logs = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
setState(() {
|
||||
_asst = MaaCore(p.current, callback);
|
||||
_asst.connect('adb', 'emulator-5554');
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void callback(String message) {
|
||||
setState(() {
|
||||
_logs.add(message);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: _logs.map((e) => Text(e)).toList(),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
1
src/dart/example/linux/.gitignore
vendored
Normal file
1
src/dart/example/linux/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
flutter/ephemeral
|
||||
116
src/dart/example/linux/CMakeLists.txt
Normal file
116
src/dart/example/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,116 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
set(BINARY_NAME "example")
|
||||
set(APPLICATION_ID "com.example.example")
|
||||
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||
|
||||
# Root filesystem for cross-building.
|
||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
||||
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endif()
|
||||
|
||||
# Configure build options.
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||
endfunction()
|
||||
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
|
||||
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
|
||||
|
||||
# Application build
|
||||
add_executable(${BINARY_NAME}
|
||||
"main.cc"
|
||||
"my_application.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
# Only the install-generated bundle's copy of the executable will launch
|
||||
# correctly, since the resources must in the right relative locations. To avoid
|
||||
# people trying to run the unbundled copy, put it in a subdirectory instead of
|
||||
# the default top-level location.
|
||||
set_target_properties(${BINARY_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
|
||||
)
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# By default, "installing" just makes a relocatable bundle in the build
|
||||
# directory.
|
||||
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
# Start with a clean build bundle directory every time.
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
|
||||
" COMPONENT Runtime)
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
if(PLUGIN_BUNDLED_LIBRARIES)
|
||||
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
87
src/dart/example/linux/flutter/CMakeLists.txt
Normal file
87
src/dart/example/linux/flutter/CMakeLists.txt
Normal file
@@ -0,0 +1,87 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
|
||||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||||
# which isn't available in 3.10.
|
||||
function(list_prepend LIST_NAME PREFIX)
|
||||
set(NEW_LIST "")
|
||||
foreach(element ${${LIST_NAME}})
|
||||
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||||
endforeach(element)
|
||||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# === Flutter Library ===
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"fl_basic_message_channel.h"
|
||||
"fl_binary_codec.h"
|
||||
"fl_binary_messenger.h"
|
||||
"fl_dart_project.h"
|
||||
"fl_engine.h"
|
||||
"fl_json_message_codec.h"
|
||||
"fl_json_method_codec.h"
|
||||
"fl_message_codec.h"
|
||||
"fl_method_call.h"
|
||||
"fl_method_channel.h"
|
||||
"fl_method_codec.h"
|
||||
"fl_method_response.h"
|
||||
"fl_plugin_registrar.h"
|
||||
"fl_plugin_registry.h"
|
||||
"fl_standard_message_codec.h"
|
||||
"fl_standard_method_codec.h"
|
||||
"fl_string_codec.h"
|
||||
"fl_value.h"
|
||||
"fl_view.h"
|
||||
"flutter_linux.h"
|
||||
)
|
||||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||||
target_link_libraries(flutter INTERFACE
|
||||
PkgConfig::GTK
|
||||
PkgConfig::GLIB
|
||||
PkgConfig::GIO
|
||||
)
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <maa_core/maa_core_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) maa_core_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "MaaCorePlugin");
|
||||
maa_core_plugin_register_with_registrar(maa_core_registrar);
|
||||
}
|
||||
15
src/dart/example/linux/flutter/generated_plugin_registrant.h
Normal file
15
src/dart/example/linux/flutter/generated_plugin_registrant.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
||||
16
src/dart/example/linux/flutter/generated_plugins.cmake
Normal file
16
src/dart/example/linux/flutter/generated_plugins.cmake
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
maa_core
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
6
src/dart/example/linux/main.cc
Normal file
6
src/dart/example/linux/main.cc
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "my_application.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
g_autoptr(MyApplication) app = my_application_new();
|
||||
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||
}
|
||||
104
src/dart/example/linux/my_application.cc
Normal file
104
src/dart/example/linux/my_application.cc
Normal file
@@ -0,0 +1,104 @@
|
||||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
struct _MyApplication {
|
||||
GtkApplication parent_instance;
|
||||
char** dart_entrypoint_arguments;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
GtkWindow* window =
|
||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
if (GDK_IS_X11_SCREEN(screen)) {
|
||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||
use_header_bar = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "example");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "example");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
// Implements GApplication::local_command_line.
|
||||
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
// Strip out the first argument as it is the binary name.
|
||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!g_application_register(application, nullptr, &error)) {
|
||||
g_warning("Failed to register: %s", error->message);
|
||||
*exit_status = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_application_activate(application);
|
||||
*exit_status = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GObject::dispose.
|
||||
static void my_application_dispose(GObject* object) {
|
||||
MyApplication* self = MY_APPLICATION(object);
|
||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void my_application_class_init(MyApplicationClass* klass) {
|
||||
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
||||
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
|
||||
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
||||
}
|
||||
|
||||
static void my_application_init(MyApplication* self) {}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
"application-id", APPLICATION_ID,
|
||||
"flags", G_APPLICATION_NON_UNIQUE,
|
||||
nullptr));
|
||||
}
|
||||
18
src/dart/example/linux/my_application.h
Normal file
18
src/dart/example/linux/my_application.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FLUTTER_MY_APPLICATION_H_
|
||||
#define FLUTTER_MY_APPLICATION_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
|
||||
GtkApplication)
|
||||
|
||||
/**
|
||||
* my_application_new:
|
||||
*
|
||||
* Creates a new Flutter-based application.
|
||||
*
|
||||
* Returns: a new #MyApplication.
|
||||
*/
|
||||
MyApplication* my_application_new();
|
||||
|
||||
#endif // FLUTTER_MY_APPLICATION_H_
|
||||
189
src/dart/example/pubspec.lock
Normal file
189
src/dart/example/pubspec.lock
Normal file
@@ -0,0 +1,189 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
ffi:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
maa_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.8"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
sdks:
|
||||
dart: ">=2.16.2 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
93
src/dart/example/pubspec.yaml
Normal file
93
src/dart/example/pubspec.yaml
Normal file
@@ -0,0 +1,93 @@
|
||||
name: example
|
||||
description: A new Flutter project.
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
# followed by an optional build number separated by a +.
|
||||
# Both the version and the builder number may be overridden in flutter
|
||||
# build by specifying --build-name and --build-number, respectively.
|
||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.2 <3.0.0"
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
||||
# dependencies can be manually updated by changing the version numbers below to
|
||||
# the latest version available on pub.dev. To see which dependencies have newer
|
||||
# versions available, run `flutter pub outdated`.
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
maa_core:
|
||||
path: ../
|
||||
ffi:
|
||||
path:
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# The "flutter_lints" package below contains a set of recommended lints to
|
||||
# encourage good coding practices. The lint set provided by the package is
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# For details regarding adding assets from package dependencies, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
|
||||
# To add custom fonts to your application, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
30
src/dart/example/test/widget_test.dart
Normal file
30
src/dart/example/test/widget_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility that Flutter provides. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:example/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
174
src/dart/lib/maa_core.dart
Normal file
174
src/dart/lib/maa_core.dart
Normal file
@@ -0,0 +1,174 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:convert';
|
||||
import 'dart:isolate';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:maa_core/typedefs.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
class MaaCore implements MaaCoreInterface {
|
||||
late Assistant _asst;
|
||||
late AsstLoadResourceFunc _asstLoadResource;
|
||||
late AsstCreateFunc _asstCreate;
|
||||
late AsstCreateExFunc _asstCreateEx;
|
||||
late AsstConnectFunc _asstConnect;
|
||||
late AsstDestroyFunc _asstDestroy;
|
||||
late AsstAppendTaskFunc _asstAppendTask;
|
||||
late AsstSetTaskParamsFunc _asstSetTaskParams;
|
||||
late AsstStartFunc _asstStart;
|
||||
late AsstStopFunc _asstStop;
|
||||
late AsstCtrlerClickFunc _asstCtrlerClick;
|
||||
late AsstGetVersionFunc _asstGetVersion;
|
||||
late AsstLogFunc _asstLog;
|
||||
static bool _resourceLoaded = false;
|
||||
late ReceivePort? _receivePort;
|
||||
static bool _apiInited = false;
|
||||
ReceivePort? get receivePort => _receivePort;
|
||||
late StreamSubscription _portSubscription;
|
||||
late List<Pointer> _allocated;
|
||||
|
||||
static Future<String> get platformVersion async {
|
||||
return Future<String>(() => '0.0.1');
|
||||
}
|
||||
|
||||
void _loadResource(String path) {
|
||||
final strPtr = toManagedString(path);
|
||||
final result = _asstLoadResource(strPtr);
|
||||
_resourceLoaded = _resourceLoaded || result;
|
||||
}
|
||||
|
||||
MaaCore(String libDir, [Function(String)? callback]) {
|
||||
_loadCppLib(libDir);
|
||||
if (!_apiInited) {
|
||||
final callbackLib = DynamicLibrary.open(p.join(libDir, 'libCallback.so'));
|
||||
final InitDartApiFunc initNativeApi =
|
||||
callbackLib.lookup<InitDartApiNative>('init_dart_api').asFunction();
|
||||
initNativeApi(NativeApi.initializeApiDLData);
|
||||
_apiInited = true;
|
||||
}
|
||||
|
||||
_allocated = [];
|
||||
if (!_resourceLoaded) {
|
||||
_loadResource(libDir);
|
||||
}
|
||||
_receivePort = ReceivePort();
|
||||
final nativePort = _receivePort!.sendPort.nativePort;
|
||||
final portPtr = malloc.allocate<Int64>(sizeOf<Int64>());
|
||||
_asst = _asstCreateEx(nativeCallback, portPtr.cast<Void>());
|
||||
_allocated.add(portPtr);
|
||||
portPtr.value = nativePort;
|
||||
if (callback != null) {
|
||||
_portSubscription = _receivePort!.listen(_wrapCallback(callback));
|
||||
}
|
||||
}
|
||||
|
||||
void Function(dynamic) _wrapCallback(void Function(String) cb) {
|
||||
return (dynamic data) {
|
||||
// c will manage the memory for the string
|
||||
String msg = data;
|
||||
cb(msg);
|
||||
};
|
||||
}
|
||||
|
||||
Pointer<AsstCallbackNative> get nativeCallback {
|
||||
return DynamicLibrary.open('./libCallback.so')
|
||||
.lookup<AsstCallbackNative>('callback');
|
||||
}
|
||||
|
||||
void _loadCppLib(String libDir) {
|
||||
final lib = DynamicLibrary.open(p.join(libDir, 'libMeoAssistant.so'));
|
||||
_asstLoadResource =
|
||||
lib.lookup<AsstLoadResourceNative>('AsstLoadResource').asFunction();
|
||||
_asstCreate = lib.lookup<AsstCreateNative>('AsstCreate').asFunction();
|
||||
_asstCreateEx = lib.lookup<AsstCreateExNative>('AsstCreateEx').asFunction();
|
||||
_asstConnect = lib.lookup<AsstConnectNative>('AsstConnect').asFunction();
|
||||
_asstDestroy = lib.lookup<AsstDestroyNative>('AsstDestroy').asFunction();
|
||||
_asstAppendTask =
|
||||
lib.lookup<AsstAppendTaskNative>('AsstAppendTask').asFunction();
|
||||
_asstSetTaskParams =
|
||||
lib.lookup<AsstSetTaskParamsNative>('AsstSetTaskParams').asFunction();
|
||||
_asstStart = lib.lookup<AsstStartNative>('AsstStart').asFunction();
|
||||
_asstStop = lib.lookup<AsstStopNative>('AsstStop').asFunction();
|
||||
_asstCtrlerClick =
|
||||
lib.lookup<AsstCtrlerClickNative>('AsstCtrlerClick').asFunction();
|
||||
_asstGetVersion =
|
||||
lib.lookup<AsstGetVersionNative>('AsstGetVersion').asFunction();
|
||||
_asstLog = lib.lookup<AsstLogNative>('AsstLog').asFunction();
|
||||
}
|
||||
|
||||
@override
|
||||
bool connect(adbPath, address, [config = '']) {
|
||||
return _asstConnect(
|
||||
_asst,
|
||||
toManagedString(adbPath),
|
||||
toManagedString(address),
|
||||
toManagedString(config),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void destroy() {
|
||||
if (_receivePort != null) {
|
||||
_portSubscription.cancel();
|
||||
_receivePort!.close();
|
||||
}
|
||||
while (_allocated.isNotEmpty) {
|
||||
final ptr = _allocated.removeLast();
|
||||
malloc.free(ptr);
|
||||
}
|
||||
_asstDestroy(_asst);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskId appendTask(String type, [Map<String, dynamic>? params]) {
|
||||
final json = jsonEncode(params ?? {});
|
||||
final taskId = _asstAppendTask(
|
||||
_asst,
|
||||
toManagedString(type),
|
||||
toManagedString(json),
|
||||
);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@override
|
||||
bool setTaskParams(TaskId taskId, [Map<String, dynamic>? params]) {
|
||||
final json = jsonEncode(params);
|
||||
final result = _asstSetTaskParams(
|
||||
_asst,
|
||||
taskId,
|
||||
toManagedString(json),
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
bool start() {
|
||||
return _asstStart(_asst);
|
||||
}
|
||||
|
||||
@override
|
||||
bool stop() {
|
||||
return _asstStop(_asst);
|
||||
}
|
||||
|
||||
@override
|
||||
bool ctrlerClick({required int x, required int y, required block}) {
|
||||
return _asstCtrlerClick(_asst, x, y, block);
|
||||
}
|
||||
|
||||
@override
|
||||
String getVersion() {
|
||||
return _asstGetVersion().toDartString();
|
||||
}
|
||||
|
||||
@override
|
||||
void log(String logLevel, String msg) {
|
||||
_asstLog(toManagedString(logLevel), toManagedString(msg));
|
||||
}
|
||||
|
||||
Pointer<Utf8> toManagedString(String str) {
|
||||
final ptr = str.toNativeUtf8();
|
||||
_allocated.add(ptr);
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
85
src/dart/lib/typedefs.dart
Normal file
85
src/dart/lib/typedefs.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import "dart:ffi";
|
||||
|
||||
import "package:ffi/ffi.dart";
|
||||
|
||||
typedef Assistant = Pointer<Void>;
|
||||
typedef AsstCallbackFunc = void Function(int, Pointer<Utf8>, Pointer<Void>);
|
||||
typedef AsstCallbackNative = NativeFunction<Void Function(Int32, Pointer<Utf8>, Pointer<Void>)>;
|
||||
// AsstCreateEx
|
||||
typedef AsstCreateDartFunc = Assistant Function(Pointer<Int64>);
|
||||
typedef AsstCreateDartNative
|
||||
= NativeFunction<Assistant Function(Pointer<Int64>)>;
|
||||
typedef AsstCreateExFunc = Assistant Function(Pointer<AsstCallbackNative>, Pointer<Void>);
|
||||
typedef AsstCreateExNative = NativeFunction<AsstCreateExFunc>;
|
||||
|
||||
// AsstCreate
|
||||
typedef AsstCreateFunc = Assistant Function();
|
||||
typedef AsstCreateNative = NativeFunction<AsstCreateFunc>;
|
||||
|
||||
// AsstDestroy
|
||||
typedef AsstDestroyFunc = void Function(Assistant);
|
||||
typedef AsstDestroyNative = NativeFunction<Void Function(Assistant)>;
|
||||
|
||||
// AsstConnect
|
||||
typedef AsstConnectFunc = bool Function(
|
||||
Assistant, StringPtr, StringPtr, StringPtr);
|
||||
typedef AsstConnectNative
|
||||
= NativeFunction<Bool Function(Assistant, StringPtr, StringPtr, StringPtr)>;
|
||||
|
||||
// AsstAppendTask
|
||||
typedef AsstAppendTaskFunc = TaskId Function(Assistant, StringPtr, StringPtr);
|
||||
typedef AsstAppendTaskNative
|
||||
= NativeFunction<TaskIdNative Function(Assistant, StringPtr, StringPtr)>;
|
||||
|
||||
// AsstSetTaskParams
|
||||
typedef AsstSetTaskParamsFunc = bool Function(Assistant, TaskId, StringPtr);
|
||||
typedef AsstSetTaskParamsNative
|
||||
= NativeFunction<Bool Function(Assistant, TaskIdNative, StringPtr)>;
|
||||
|
||||
// AsstStart
|
||||
typedef AsstStartFunc = bool Function(Assistant);
|
||||
typedef AsstStartNative = NativeFunction<Bool Function(Assistant)>;
|
||||
|
||||
// AsstStop
|
||||
typedef AsstStopFunc = bool Function(Assistant);
|
||||
typedef AsstStopNative = NativeFunction<Bool Function(Assistant)>;
|
||||
|
||||
// AsstCtrlerClick
|
||||
typedef AsstCtrlerClickFunc = bool Function(Assistant, int, int, bool);
|
||||
typedef AsstCtrlerClickNative
|
||||
= NativeFunction<Bool Function(Assistant, Int32, Int32, Bool)>;
|
||||
|
||||
// AsstGetVersion
|
||||
typedef AsstGetVersionFunc = StringPtr Function();
|
||||
typedef AsstGetVersionNative = NativeFunction<AsstGetVersionFunc>;
|
||||
|
||||
// AsstLog
|
||||
typedef AsstLogFunc = void Function(StringPtr, StringPtr);
|
||||
typedef AsstLogNative = NativeFunction<Void Function(StringPtr, StringPtr)>;
|
||||
|
||||
// AsstLoadResource
|
||||
typedef AsstLoadResourceFunc = bool Function(StringPtr);
|
||||
typedef AsstLoadResourceNative = NativeFunction<Bool Function(StringPtr)>;
|
||||
|
||||
typedef TaskId = int;
|
||||
typedef TaskIdNative = Int32;
|
||||
typedef StringPtr = Pointer<Utf8>;
|
||||
|
||||
typedef InitDartApiFunc = void Function(Pointer<Void>);
|
||||
typedef InitDartApiNative = NativeFunction<Void Function(Pointer<Void>)>;
|
||||
|
||||
|
||||
typedef CleanUpDartVMFunc = void Function();
|
||||
typedef CleanUpDartVMNative = NativeFunction<Void Function()>;
|
||||
|
||||
abstract class MaaCoreInterface {
|
||||
void destroy();
|
||||
bool connect(String adbPath, String address,[String config = '']);
|
||||
TaskId appendTask(String type, [Map<String, dynamic>? params]);
|
||||
bool setTaskParams(TaskId taskId, [Map<String, dynamic>? params]);
|
||||
bool start();
|
||||
bool stop();
|
||||
bool ctrlerClick({required int x, required int y, required block});
|
||||
void log(String logLevel, String msg);
|
||||
String getVersion();
|
||||
}
|
||||
31
src/dart/linux/CMakeLists.txt
Normal file
31
src/dart/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
set(PROJECT_NAME "maa_core")
|
||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||
|
||||
# This value is used when generating builds using this plugin, so it must
|
||||
# not be changed
|
||||
set(PLUGIN_NAME "maa_core_plugin")
|
||||
|
||||
|
||||
|
||||
add_library(${PLUGIN_NAME} SHARED
|
||||
"maa_core_plugin.cc"
|
||||
)
|
||||
|
||||
apply_standard_settings(${PLUGIN_NAME})
|
||||
set_target_properties(${PLUGIN_NAME} PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden)
|
||||
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
||||
|
||||
target_include_directories(${PLUGIN_NAME} INTERFACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
# List of absolute paths to libraries that should be bundled with the plugin
|
||||
set(maa_core_bundled_libraries
|
||||
""
|
||||
PARENT_SCOPE
|
||||
)
|
||||
26
src/dart/linux/include/maa_core/maa_core_plugin.h
Normal file
26
src/dart/linux/include/maa_core/maa_core_plugin.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef FLUTTER_PLUGIN_MAA_CORE_PLUGIN_H_
|
||||
#define FLUTTER_PLUGIN_MAA_CORE_PLUGIN_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifdef FLUTTER_PLUGIN_IMPL
|
||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define FLUTTER_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
typedef struct _MaaCorePlugin MaaCorePlugin;
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
} MaaCorePluginClass;
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT GType maa_core_plugin_get_type();
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void maa_core_plugin_register_with_registrar(
|
||||
FlPluginRegistrar* registrar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // FLUTTER_PLUGIN_MAA_CORE_PLUGIN_H_
|
||||
70
src/dart/linux/maa_core_plugin.cc
Normal file
70
src/dart/linux/maa_core_plugin.cc
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "include/maa_core/maa_core_plugin.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#define MAA_CORE_PLUGIN(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), maa_core_plugin_get_type(), \
|
||||
MaaCorePlugin))
|
||||
|
||||
struct _MaaCorePlugin {
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MaaCorePlugin, maa_core_plugin, g_object_get_type())
|
||||
|
||||
// Called when a method call is received from Flutter.
|
||||
static void maa_core_plugin_handle_method_call(
|
||||
MaaCorePlugin* self,
|
||||
FlMethodCall* method_call) {
|
||||
g_autoptr(FlMethodResponse) response = nullptr;
|
||||
|
||||
const gchar* method = fl_method_call_get_name(method_call);
|
||||
|
||||
if (strcmp(method, "getPlatformVersion") == 0) {
|
||||
struct utsname uname_data = {};
|
||||
uname(&uname_data);
|
||||
g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version);
|
||||
g_autoptr(FlValue) result = fl_value_new_string(version);
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
|
||||
} else {
|
||||
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
|
||||
}
|
||||
|
||||
fl_method_call_respond(method_call, response, nullptr);
|
||||
}
|
||||
|
||||
static void maa_core_plugin_dispose(GObject* object) {
|
||||
G_OBJECT_CLASS(maa_core_plugin_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void maa_core_plugin_class_init(MaaCorePluginClass* klass) {
|
||||
G_OBJECT_CLASS(klass)->dispose = maa_core_plugin_dispose;
|
||||
}
|
||||
|
||||
static void maa_core_plugin_init(MaaCorePlugin* self) {}
|
||||
|
||||
static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call,
|
||||
gpointer user_data) {
|
||||
MaaCorePlugin* plugin = MAA_CORE_PLUGIN(user_data);
|
||||
maa_core_plugin_handle_method_call(plugin, method_call);
|
||||
}
|
||||
|
||||
void maa_core_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
|
||||
MaaCorePlugin* plugin = MAA_CORE_PLUGIN(
|
||||
g_object_new(maa_core_plugin_get_type(), nullptr));
|
||||
|
||||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
|
||||
g_autoptr(FlMethodChannel) channel =
|
||||
fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
|
||||
"maa_core",
|
||||
FL_METHOD_CODEC(codec));
|
||||
fl_method_channel_set_method_call_handler(channel, method_call_cb,
|
||||
g_object_ref(plugin),
|
||||
g_object_unref);
|
||||
|
||||
g_object_unref(plugin);
|
||||
}
|
||||
9
src/dart/native/CMakeLists.txt
Normal file
9
src/dart/native/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(callback)
|
||||
|
||||
add_library(Callback SHARED callback.c dart_api_dl.c)
|
||||
|
||||
target_include_directories(Callback PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/internal"
|
||||
)
|
||||
32
src/dart/native/callback.c
Normal file
32
src/dart/native/callback.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "dart_api_dl.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
void callback(int, const char *, void *);
|
||||
void init_dart_api(void *);
|
||||
void init_dart_api(void *api_data) {
|
||||
Dart_InitializeApiDL(api_data);
|
||||
}
|
||||
|
||||
void callback(int retval, const char *json_str, void *custom_arg) {
|
||||
Dart_Port port = *(Dart_Port *)custom_arg;
|
||||
|
||||
|
||||
int n_digits = 1;
|
||||
int k = retval;
|
||||
while (k > 10) {
|
||||
n_digits++;
|
||||
k /= 10;
|
||||
}
|
||||
Dart_CObject obj;
|
||||
int required_len = n_digits + strlen(json_str) + 1;
|
||||
char retstr[required_len];
|
||||
retstr[required_len-1] = 0;
|
||||
sprintf(retstr, "{\"retval\": %d, \"payload\": %s }", retval, json_str);
|
||||
obj.type = Dart_CObject_kString;
|
||||
obj.value.as_string = retstr;
|
||||
printf("C: Sending Pointer %ld to dart through port %ld\n", (int64_t)json_str, port);
|
||||
char res = Dart_PostCObject_DL(port, &obj);
|
||||
if (res == 0) {
|
||||
printf("C: Failed to send message to Dart\n");
|
||||
}
|
||||
}
|
||||
59
src/dart/native/dart_api_dl.c
Normal file
59
src/dart/native/dart_api_dl.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
* for details. All rights reserved. Use of this source code is governed by a
|
||||
* BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "dart_api_dl.h" /* NOLINT */
|
||||
#include "dart_version.h" /* NOLINT */
|
||||
#include "internal/dart_api_dl_impl.h" /* NOLINT */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define DART_API_DL_DEFINITIONS(name, R, A) name##_Type name##_DL = NULL;
|
||||
|
||||
DART_API_ALL_DL_SYMBOLS(DART_API_DL_DEFINITIONS)
|
||||
|
||||
#undef DART_API_DL_DEFINITIONS
|
||||
|
||||
typedef void* DartApiEntry_function;
|
||||
|
||||
DartApiEntry_function FindFunctionPointer(const DartApiEntry* entries,
|
||||
const char* name) {
|
||||
while (entries->name != NULL) {
|
||||
if (strcmp(entries->name, name) == 0) return entries->function;
|
||||
entries++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intptr_t Dart_InitializeApiDL(void* data) {
|
||||
DartApi* dart_api_data = (DartApi*)data;
|
||||
|
||||
if (dart_api_data->major != DART_API_DL_MAJOR_VERSION) {
|
||||
// If the DartVM we're running on does not have the same version as this
|
||||
// file was compiled against, refuse to initialize. The symbols are not
|
||||
// compatible.
|
||||
return -1;
|
||||
}
|
||||
// Minor versions are allowed to be different.
|
||||
// If the DartVM has a higher minor version, it will provide more symbols
|
||||
// than we initialize here.
|
||||
// If the DartVM has a lower minor version, it will not provide all symbols.
|
||||
// In that case, we leave the missing symbols un-initialized. Those symbols
|
||||
// should not be used by the Dart and native code. The client is responsible
|
||||
// for checking the minor version number himself based on which symbols it
|
||||
// is using.
|
||||
// (If we would error out on this case, recompiling native code against a
|
||||
// newer SDK would break all uses on older SDKs, which is too strict.)
|
||||
|
||||
const DartApiEntry* dart_api_function_pointers = dart_api_data->functions;
|
||||
|
||||
#define DART_API_DL_INIT(name, R, A) \
|
||||
name##_DL = \
|
||||
(name##_Type)(FindFunctionPointer(dart_api_function_pointers, #name));
|
||||
DART_API_ALL_DL_SYMBOLS(DART_API_DL_INIT)
|
||||
#undef DART_API_DL_INIT
|
||||
|
||||
return 0;
|
||||
}
|
||||
4016
src/dart/native/include/dart_api.h
Normal file
4016
src/dart/native/include/dart_api.h
Normal file
File diff suppressed because it is too large
Load Diff
150
src/dart/native/include/dart_api_dl.h
Normal file
150
src/dart/native/include/dart_api_dl.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
* for details. All rights reserved. Use of this source code is governed by a
|
||||
* BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef RUNTIME_INCLUDE_DART_API_DL_H_
|
||||
#define RUNTIME_INCLUDE_DART_API_DL_H_
|
||||
|
||||
#include "dart_api.h" /* NOLINT */
|
||||
#include "dart_native_api.h" /* NOLINT */
|
||||
|
||||
/** \mainpage Dynamically Linked Dart API
|
||||
*
|
||||
* This exposes a subset of symbols from dart_api.h and dart_native_api.h
|
||||
* available in every Dart embedder through dynamic linking.
|
||||
*
|
||||
* All symbols are postfixed with _DL to indicate that they are dynamically
|
||||
* linked and to prevent conflicts with the original symbol.
|
||||
*
|
||||
* Link `dart_api_dl.c` file into your library and invoke
|
||||
* `Dart_InitializeApiDL` with `NativeApi.initializeApiDLData`.
|
||||
*/
|
||||
|
||||
DART_EXPORT intptr_t Dart_InitializeApiDL(void* data);
|
||||
|
||||
// ============================================================================
|
||||
// IMPORTANT! Never update these signatures without properly updating
|
||||
// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
|
||||
//
|
||||
// Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types
|
||||
// to trigger compile-time errors if the sybols in those files are updated
|
||||
// without updating these.
|
||||
//
|
||||
// Function return and argument types, and typedefs are carbon copied. Structs
|
||||
// are typechecked nominally in C/C++, so they are not copied, instead a
|
||||
// comment is added to their definition.
|
||||
typedef int64_t Dart_Port_DL;
|
||||
|
||||
typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
|
||||
Dart_CObject* message);
|
||||
|
||||
// dart_native_api.h symbols can be called on any thread.
|
||||
#define DART_NATIVE_API_DL_SYMBOLS(F) \
|
||||
/***** dart_native_api.h *****/ \
|
||||
/* Dart_Port */ \
|
||||
F(Dart_PostCObject, bool, (Dart_Port_DL port_id, Dart_CObject * message)) \
|
||||
F(Dart_PostInteger, bool, (Dart_Port_DL port_id, int64_t message)) \
|
||||
F(Dart_NewNativePort, Dart_Port_DL, \
|
||||
(const char* name, Dart_NativeMessageHandler_DL handler, \
|
||||
bool handle_concurrently)) \
|
||||
F(Dart_CloseNativePort, bool, (Dart_Port_DL native_port_id))
|
||||
|
||||
// dart_api.h symbols can only be called on Dart threads.
|
||||
#define DART_API_DL_SYMBOLS(F) \
|
||||
/***** dart_api.h *****/ \
|
||||
/* Errors */ \
|
||||
F(Dart_IsError, bool, (Dart_Handle handle)) \
|
||||
F(Dart_IsApiError, bool, (Dart_Handle handle)) \
|
||||
F(Dart_IsUnhandledExceptionError, bool, (Dart_Handle handle)) \
|
||||
F(Dart_IsCompilationError, bool, (Dart_Handle handle)) \
|
||||
F(Dart_IsFatalError, bool, (Dart_Handle handle)) \
|
||||
F(Dart_GetError, const char*, (Dart_Handle handle)) \
|
||||
F(Dart_ErrorHasException, bool, (Dart_Handle handle)) \
|
||||
F(Dart_ErrorGetException, Dart_Handle, (Dart_Handle handle)) \
|
||||
F(Dart_ErrorGetStackTrace, Dart_Handle, (Dart_Handle handle)) \
|
||||
F(Dart_NewApiError, Dart_Handle, (const char* error)) \
|
||||
F(Dart_NewCompilationError, Dart_Handle, (const char* error)) \
|
||||
F(Dart_NewUnhandledExceptionError, Dart_Handle, (Dart_Handle exception)) \
|
||||
F(Dart_PropagateError, void, (Dart_Handle handle)) \
|
||||
/* Dart_Handle, Dart_PersistentHandle, Dart_WeakPersistentHandle */ \
|
||||
F(Dart_HandleFromPersistent, Dart_Handle, (Dart_PersistentHandle object)) \
|
||||
F(Dart_HandleFromWeakPersistent, Dart_Handle, \
|
||||
(Dart_WeakPersistentHandle object)) \
|
||||
F(Dart_NewPersistentHandle, Dart_PersistentHandle, (Dart_Handle object)) \
|
||||
F(Dart_SetPersistentHandle, void, \
|
||||
(Dart_PersistentHandle obj1, Dart_Handle obj2)) \
|
||||
F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \
|
||||
F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \
|
||||
(Dart_Handle object, void* peer, intptr_t external_allocation_size, \
|
||||
Dart_HandleFinalizer callback)) \
|
||||
F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \
|
||||
F(Dart_UpdateExternalSize, void, \
|
||||
(Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \
|
||||
F(Dart_NewFinalizableHandle, Dart_FinalizableHandle, \
|
||||
(Dart_Handle object, void* peer, intptr_t external_allocation_size, \
|
||||
Dart_HandleFinalizer callback)) \
|
||||
F(Dart_DeleteFinalizableHandle, void, \
|
||||
(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)) \
|
||||
F(Dart_UpdateFinalizableExternalSize, void, \
|
||||
(Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \
|
||||
intptr_t external_allocation_size)) \
|
||||
/* Dart_Port */ \
|
||||
F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \
|
||||
F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \
|
||||
F(Dart_SendPortGetId, Dart_Handle, \
|
||||
(Dart_Handle port, Dart_Port_DL * port_id)) \
|
||||
/* Scopes */ \
|
||||
F(Dart_EnterScope, void, (void)) \
|
||||
F(Dart_ExitScope, void, (void))
|
||||
|
||||
#define DART_API_ALL_DL_SYMBOLS(F) \
|
||||
DART_NATIVE_API_DL_SYMBOLS(F) \
|
||||
DART_API_DL_SYMBOLS(F)
|
||||
// IMPORTANT! Never update these signatures without properly updating
|
||||
// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
|
||||
//
|
||||
// End of verbatim copy.
|
||||
// ============================================================================
|
||||
|
||||
// Copy of definition of DART_EXPORT without 'used' attribute.
|
||||
//
|
||||
// The 'used' attribute cannot be used with DART_API_ALL_DL_SYMBOLS because
|
||||
// they are not function declarations, but variable declarations with a
|
||||
// function pointer type.
|
||||
//
|
||||
// The function pointer variables are initialized with the addresses of the
|
||||
// functions in the VM. If we were to use function declarations instead, we
|
||||
// would need to forward the call to the VM adding indirection.
|
||||
#if defined(__CYGWIN__)
|
||||
#error Tool chain and platform not supported.
|
||||
#elif defined(_WIN32)
|
||||
#if defined(DART_SHARED_LIB)
|
||||
#define DART_EXPORT_DL DART_EXTERN_C __declspec(dllexport)
|
||||
#else
|
||||
#define DART_EXPORT_DL DART_EXTERN_C
|
||||
#endif
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#if defined(DART_SHARED_LIB)
|
||||
#define DART_EXPORT_DL DART_EXTERN_C __attribute__((visibility("default")))
|
||||
#else
|
||||
#define DART_EXPORT_DL DART_EXTERN_C
|
||||
#endif
|
||||
#else
|
||||
#error Tool chain not supported.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DART_API_DL_DECLARATIONS(name, R, A) \
|
||||
typedef R(*name##_Type) A; \
|
||||
DART_EXPORT_DL name##_Type name##_DL;
|
||||
|
||||
DART_API_ALL_DL_SYMBOLS(DART_API_DL_DECLARATIONS)
|
||||
|
||||
#undef DART_API_DL_DECLARATIONS
|
||||
|
||||
#undef DART_EXPORT_DL
|
||||
|
||||
#endif /* RUNTIME_INCLUDE_DART_API_DL_H_ */ /* NOLINT */
|
||||
197
src/dart/native/include/dart_native_api.h
Normal file
197
src/dart/native/include/dart_native_api.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
* for details. All rights reserved. Use of this source code is governed by a
|
||||
* BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef RUNTIME_INCLUDE_DART_NATIVE_API_H_
|
||||
#define RUNTIME_INCLUDE_DART_NATIVE_API_H_
|
||||
|
||||
#include "dart_api.h" /* NOLINT */
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* Message sending/receiving from native code
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Dart_CObject is used for representing Dart objects as native C
|
||||
* data outside the Dart heap. These objects are totally detached from
|
||||
* the Dart heap. Only a subset of the Dart objects have a
|
||||
* representation as a Dart_CObject.
|
||||
*
|
||||
* The string encoding in the 'value.as_string' is UTF-8.
|
||||
*
|
||||
* All the different types from dart:typed_data are exposed as type
|
||||
* kTypedData. The specific type from dart:typed_data is in the type
|
||||
* field of the as_typed_data structure. The length in the
|
||||
* as_typed_data structure is always in bytes.
|
||||
*
|
||||
* The data for kTypedData is copied on message send and ownership remains with
|
||||
* the caller. The ownership of data for kExternalTyped is passed to the VM on
|
||||
* message send and returned when the VM invokes the
|
||||
* Dart_HandleFinalizer callback; a non-NULL callback must be provided.
|
||||
*/
|
||||
typedef enum {
|
||||
Dart_CObject_kNull = 0,
|
||||
Dart_CObject_kBool,
|
||||
Dart_CObject_kInt32,
|
||||
Dart_CObject_kInt64,
|
||||
Dart_CObject_kDouble,
|
||||
Dart_CObject_kString,
|
||||
Dart_CObject_kArray,
|
||||
Dart_CObject_kTypedData,
|
||||
Dart_CObject_kExternalTypedData,
|
||||
Dart_CObject_kSendPort,
|
||||
Dart_CObject_kCapability,
|
||||
Dart_CObject_kNativePointer,
|
||||
Dart_CObject_kUnsupported,
|
||||
Dart_CObject_kNumberOfTypes
|
||||
} Dart_CObject_Type;
|
||||
|
||||
typedef struct _Dart_CObject {
|
||||
Dart_CObject_Type type;
|
||||
union {
|
||||
bool as_bool;
|
||||
int32_t as_int32;
|
||||
int64_t as_int64;
|
||||
double as_double;
|
||||
char* as_string;
|
||||
struct {
|
||||
Dart_Port id;
|
||||
Dart_Port origin_id;
|
||||
} as_send_port;
|
||||
struct {
|
||||
int64_t id;
|
||||
} as_capability;
|
||||
struct {
|
||||
intptr_t length;
|
||||
struct _Dart_CObject** values;
|
||||
} as_array;
|
||||
struct {
|
||||
Dart_TypedData_Type type;
|
||||
intptr_t length; /* in elements, not bytes */
|
||||
uint8_t* values;
|
||||
} as_typed_data;
|
||||
struct {
|
||||
Dart_TypedData_Type type;
|
||||
intptr_t length; /* in elements, not bytes */
|
||||
uint8_t* data;
|
||||
void* peer;
|
||||
Dart_HandleFinalizer callback;
|
||||
} as_external_typed_data;
|
||||
struct {
|
||||
intptr_t ptr;
|
||||
intptr_t size;
|
||||
Dart_HandleFinalizer callback;
|
||||
} as_native_pointer;
|
||||
} value;
|
||||
} Dart_CObject;
|
||||
// This struct is versioned by DART_API_DL_MAJOR_VERSION, bump the version when
|
||||
// changing this struct.
|
||||
|
||||
/**
|
||||
* Posts a message on some port. The message will contain the Dart_CObject
|
||||
* object graph rooted in 'message'.
|
||||
*
|
||||
* While the message is being sent the state of the graph of Dart_CObject
|
||||
* structures rooted in 'message' should not be accessed, as the message
|
||||
* generation will make temporary modifications to the data. When the message
|
||||
* has been sent the graph will be fully restored.
|
||||
*
|
||||
* If true is returned, the message was enqueued, and finalizers for external
|
||||
* typed data will eventually run, even if the receiving isolate shuts down
|
||||
* before processing the message. If false is returned, the message was not
|
||||
* enqueued and ownership of external typed data in the message remains with the
|
||||
* caller.
|
||||
*
|
||||
* This function may be called on any thread when the VM is running (that is,
|
||||
* after Dart_Initialize has returned and before Dart_Cleanup has been called).
|
||||
*
|
||||
* \param port_id The destination port.
|
||||
* \param message The message to send.
|
||||
*
|
||||
* \return True if the message was posted.
|
||||
*/
|
||||
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
|
||||
|
||||
/**
|
||||
* Posts a message on some port. The message will contain the integer 'message'.
|
||||
*
|
||||
* \param port_id The destination port.
|
||||
* \param message The message to send.
|
||||
*
|
||||
* \return True if the message was posted.
|
||||
*/
|
||||
DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, int64_t message);
|
||||
|
||||
/**
|
||||
* A native message handler.
|
||||
*
|
||||
* This handler is associated with a native port by calling
|
||||
* Dart_NewNativePort.
|
||||
*
|
||||
* The message received is decoded into the message structure. The
|
||||
* lifetime of the message data is controlled by the caller. All the
|
||||
* data references from the message are allocated by the caller and
|
||||
* will be reclaimed when returning to it.
|
||||
*/
|
||||
typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
|
||||
Dart_CObject* message);
|
||||
|
||||
/**
|
||||
* Creates a new native port. When messages are received on this
|
||||
* native port, then they will be dispatched to the provided native
|
||||
* message handler.
|
||||
*
|
||||
* \param name The name of this port in debugging messages.
|
||||
* \param handler The C handler to run when messages arrive on the port.
|
||||
* \param handle_concurrently Is it okay to process requests on this
|
||||
* native port concurrently?
|
||||
*
|
||||
* \return If successful, returns the port id for the native port. In
|
||||
* case of error, returns ILLEGAL_PORT.
|
||||
*/
|
||||
DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
|
||||
Dart_NativeMessageHandler handler,
|
||||
bool handle_concurrently);
|
||||
/* TODO(turnidge): Currently handle_concurrently is ignored. */
|
||||
|
||||
/**
|
||||
* Closes the native port with the given id.
|
||||
*
|
||||
* The port must have been allocated by a call to Dart_NewNativePort.
|
||||
*
|
||||
* \param native_port_id The id of the native port to close.
|
||||
*
|
||||
* \return Returns true if the port was closed successfully.
|
||||
*/
|
||||
DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
|
||||
|
||||
/*
|
||||
* ==================
|
||||
* Verification Tools
|
||||
* ==================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Forces all loaded classes and functions to be compiled eagerly in
|
||||
* the current isolate..
|
||||
*
|
||||
* TODO(turnidge): Document.
|
||||
*/
|
||||
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll(void);
|
||||
|
||||
/**
|
||||
* Finalizes all classes.
|
||||
*/
|
||||
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeAllClasses(void);
|
||||
|
||||
/* This function is intentionally undocumented.
|
||||
*
|
||||
* It should not be used outside internal tests.
|
||||
*/
|
||||
DART_EXPORT void* Dart_ExecuteInternalCommand(const char* command, void* arg);
|
||||
|
||||
#endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */
|
||||
538
src/dart/native/include/dart_tools_api.h
Normal file
538
src/dart/native/include/dart_tools_api.h
Normal file
@@ -0,0 +1,538 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef RUNTIME_INCLUDE_DART_TOOLS_API_H_
|
||||
#define RUNTIME_INCLUDE_DART_TOOLS_API_H_
|
||||
|
||||
#include "dart_api.h" /* NOLINT */
|
||||
|
||||
/** \mainpage Dart Tools Embedding API Reference
|
||||
*
|
||||
* This reference describes the Dart embedding API for tools. Tools include
|
||||
* a debugger, service protocol, and timeline.
|
||||
*
|
||||
* NOTE: The APIs described in this file are unstable and subject to change.
|
||||
*
|
||||
* This reference is generated from the header include/dart_tools_api.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ========
|
||||
* Debugger
|
||||
* ========
|
||||
*/
|
||||
|
||||
/**
|
||||
* ILLEGAL_ISOLATE_ID is a number guaranteed never to be associated with a
|
||||
* valid isolate.
|
||||
*/
|
||||
#define ILLEGAL_ISOLATE_ID ILLEGAL_PORT
|
||||
|
||||
|
||||
/*
|
||||
* =======
|
||||
* Service
|
||||
* =======
|
||||
*/
|
||||
|
||||
/**
|
||||
* A service request callback function.
|
||||
*
|
||||
* These callbacks, registered by the embedder, are called when the VM receives
|
||||
* a service request it can't handle and the service request command name
|
||||
* matches one of the embedder registered handlers.
|
||||
*
|
||||
* The return value of the callback indicates whether the response
|
||||
* should be used as a regular result or an error result.
|
||||
* Specifically, if the callback returns true, a regular JSON-RPC
|
||||
* response is built in the following way:
|
||||
*
|
||||
* {
|
||||
* "jsonrpc": "2.0",
|
||||
* "result": <json_object>,
|
||||
* "id": <some sequence id>,
|
||||
* }
|
||||
*
|
||||
* If the callback returns false, a JSON-RPC error is built like this:
|
||||
*
|
||||
* {
|
||||
* "jsonrpc": "2.0",
|
||||
* "error": <json_object>,
|
||||
* "id": <some sequence id>,
|
||||
* }
|
||||
*
|
||||
* \param method The rpc method name.
|
||||
* \param param_keys Service requests can have key-value pair parameters. The
|
||||
* keys and values are flattened and stored in arrays.
|
||||
* \param param_values The values associated with the keys.
|
||||
* \param num_params The length of the param_keys and param_values arrays.
|
||||
* \param user_data The user_data pointer registered with this handler.
|
||||
* \param result A C string containing a valid JSON object. The returned
|
||||
* pointer will be freed by the VM by calling free.
|
||||
*
|
||||
* \return True if the result is a regular JSON-RPC response, false if the
|
||||
* result is a JSON-RPC error.
|
||||
*/
|
||||
typedef bool (*Dart_ServiceRequestCallback)(const char* method,
|
||||
const char** param_keys,
|
||||
const char** param_values,
|
||||
intptr_t num_params,
|
||||
void* user_data,
|
||||
const char** json_object);
|
||||
|
||||
/**
|
||||
* Register a Dart_ServiceRequestCallback to be called to handle
|
||||
* requests for the named rpc on a specific isolate. The callback will
|
||||
* be invoked with the current isolate set to the request target.
|
||||
*
|
||||
* \param method The name of the method that this callback is responsible for.
|
||||
* \param callback The callback to invoke.
|
||||
* \param user_data The user data passed to the callback.
|
||||
*
|
||||
* NOTE: If multiple callbacks with the same name are registered, only
|
||||
* the last callback registered will be remembered.
|
||||
*/
|
||||
DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback(
|
||||
const char* method,
|
||||
Dart_ServiceRequestCallback callback,
|
||||
void* user_data);
|
||||
|
||||
/**
|
||||
* Register a Dart_ServiceRequestCallback to be called to handle
|
||||
* requests for the named rpc. The callback will be invoked without a
|
||||
* current isolate.
|
||||
*
|
||||
* \param method The name of the command that this callback is responsible for.
|
||||
* \param callback The callback to invoke.
|
||||
* \param user_data The user data passed to the callback.
|
||||
*
|
||||
* NOTE: If multiple callbacks with the same name are registered, only
|
||||
* the last callback registered will be remembered.
|
||||
*/
|
||||
DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
|
||||
const char* method,
|
||||
Dart_ServiceRequestCallback callback,
|
||||
void* user_data);
|
||||
|
||||
/**
|
||||
* Embedder information which can be requested by the VM for internal or
|
||||
* reporting purposes.
|
||||
*
|
||||
* The pointers in this structure are not going to be cached or freed by the VM.
|
||||
*/
|
||||
|
||||
#define DART_EMBEDDER_INFORMATION_CURRENT_VERSION (0x00000001)
|
||||
|
||||
typedef struct {
|
||||
int32_t version;
|
||||
const char* name; // [optional] The name of the embedder
|
||||
int64_t current_rss; // [optional] the current RSS of the embedder
|
||||
int64_t max_rss; // [optional] the maximum RSS of the embedder
|
||||
} Dart_EmbedderInformation;
|
||||
|
||||
/**
|
||||
* Callback provided by the embedder that is used by the vm to request
|
||||
* information.
|
||||
*
|
||||
* \return Returns a pointer to a Dart_EmbedderInformation structure.
|
||||
* The embedder keeps the ownership of the structure and any field in it.
|
||||
* The embedder must ensure that the structure will remain valid until the
|
||||
* next invokation of the callback.
|
||||
*/
|
||||
typedef void (*Dart_EmbedderInformationCallback)(
|
||||
Dart_EmbedderInformation* info);
|
||||
|
||||
/**
|
||||
* Register a Dart_ServiceRequestCallback to be called to handle
|
||||
* requests for the named rpc. The callback will be invoked without a
|
||||
* current isolate.
|
||||
*
|
||||
* \param method The name of the command that this callback is responsible for.
|
||||
* \param callback The callback to invoke.
|
||||
* \param user_data The user data passed to the callback.
|
||||
*
|
||||
* NOTE: If multiple callbacks with the same name are registered, only
|
||||
* the last callback registered will be remembered.
|
||||
*/
|
||||
DART_EXPORT void Dart_SetEmbedderInformationCallback(
|
||||
Dart_EmbedderInformationCallback callback);
|
||||
|
||||
/**
|
||||
* Invoke a vm-service method and wait for its result.
|
||||
*
|
||||
* \param request_json The utf8-encoded json-rpc request.
|
||||
* \param request_json_length The length of the json-rpc request.
|
||||
*
|
||||
* \param response_json The returned utf8-encoded json response, must be
|
||||
* free()ed by caller.
|
||||
* \param response_json_length The length of the returned json response.
|
||||
* \param error An optional error, must be free()ed by caller.
|
||||
*
|
||||
* \return Whether the call was sucessfully performed.
|
||||
*
|
||||
* NOTE: This method does not need a current isolate and must not have the
|
||||
* vm-isolate being the current isolate. It must be called after
|
||||
* Dart_Initialize() and before Dart_Cleanup().
|
||||
*/
|
||||
DART_EXPORT bool Dart_InvokeVMServiceMethod(uint8_t* request_json,
|
||||
intptr_t request_json_length,
|
||||
uint8_t** response_json,
|
||||
intptr_t* response_json_length,
|
||||
char** error);
|
||||
|
||||
/*
|
||||
* ========
|
||||
* Event Streams
|
||||
* ========
|
||||
*/
|
||||
|
||||
/**
|
||||
* A callback invoked when the VM service gets a request to listen to
|
||||
* some stream.
|
||||
*
|
||||
* \return Returns true iff the embedder supports the named stream id.
|
||||
*/
|
||||
typedef bool (*Dart_ServiceStreamListenCallback)(const char* stream_id);
|
||||
|
||||
/**
|
||||
* A callback invoked when the VM service gets a request to cancel
|
||||
* some stream.
|
||||
*/
|
||||
typedef void (*Dart_ServiceStreamCancelCallback)(const char* stream_id);
|
||||
|
||||
/**
|
||||
* Adds VM service stream callbacks.
|
||||
*
|
||||
* \param listen_callback A function pointer to a listen callback function.
|
||||
* A listen callback function should not be already set when this function
|
||||
* is called. A NULL value removes the existing listen callback function
|
||||
* if any.
|
||||
*
|
||||
* \param cancel_callback A function pointer to a cancel callback function.
|
||||
* A cancel callback function should not be already set when this function
|
||||
* is called. A NULL value removes the existing cancel callback function
|
||||
* if any.
|
||||
*
|
||||
* \return Success if the callbacks were added. Otherwise, returns an
|
||||
* error handle.
|
||||
*/
|
||||
DART_EXPORT char* Dart_SetServiceStreamCallbacks(
|
||||
Dart_ServiceStreamListenCallback listen_callback,
|
||||
Dart_ServiceStreamCancelCallback cancel_callback);
|
||||
|
||||
/**
|
||||
* Sends a data event to clients of the VM Service.
|
||||
*
|
||||
* A data event is used to pass an array of bytes to subscribed VM
|
||||
* Service clients. For example, in the standalone embedder, this is
|
||||
* function used to provide WriteEvents on the Stdout and Stderr
|
||||
* streams.
|
||||
*
|
||||
* If the embedder passes in a stream id for which no client is
|
||||
* subscribed, then the event is ignored.
|
||||
*
|
||||
* \param stream_id The id of the stream on which to post the event.
|
||||
*
|
||||
* \param event_kind A string identifying what kind of event this is.
|
||||
* For example, 'WriteEvent'.
|
||||
*
|
||||
* \param bytes A pointer to an array of bytes.
|
||||
*
|
||||
* \param bytes_length The length of the byte array.
|
||||
*
|
||||
* \return NULL if the arguments are well formed. Otherwise, returns an
|
||||
* error string. The caller is responsible for freeing the error message.
|
||||
*/
|
||||
DART_EXPORT char* Dart_ServiceSendDataEvent(const char* stream_id,
|
||||
const char* event_kind,
|
||||
const uint8_t* bytes,
|
||||
intptr_t bytes_length);
|
||||
|
||||
/**
|
||||
* Usage statistics for a space/generation at a particular moment in time.
|
||||
*
|
||||
* \param used Amount of memory used, in bytes.
|
||||
*
|
||||
* \param capacity Memory capacity, in bytes.
|
||||
*
|
||||
* \param external External memory, in bytes.
|
||||
*
|
||||
* \param collections How many times the garbage collector has run in this
|
||||
* space.
|
||||
*
|
||||
* \param time Cumulative time spent collecting garbage in this space, in
|
||||
* seconds.
|
||||
*
|
||||
* \param avg_collection_period Average time between garbage collector running
|
||||
* in this space, in milliseconds.
|
||||
*/
|
||||
typedef struct {
|
||||
intptr_t used;
|
||||
intptr_t capacity;
|
||||
intptr_t external;
|
||||
intptr_t collections;
|
||||
double time;
|
||||
double avg_collection_period;
|
||||
} Dart_GCStats;
|
||||
|
||||
/**
|
||||
* A Garbage Collection event with memory usage statistics.
|
||||
*
|
||||
* \param type The event type. Static lifetime.
|
||||
*
|
||||
* \param reason The reason for the GC event. Static lifetime.
|
||||
*
|
||||
* \param new_space Data for New Space.
|
||||
*
|
||||
* \param old_space Data for Old Space.
|
||||
*/
|
||||
typedef struct {
|
||||
const char* type;
|
||||
const char* reason;
|
||||
const char* isolate_id;
|
||||
|
||||
Dart_GCStats new_space;
|
||||
Dart_GCStats old_space;
|
||||
} Dart_GCEvent;
|
||||
|
||||
/**
|
||||
* A callback invoked when the VM emits a GC event.
|
||||
*
|
||||
* \param event The GC event data. Pointer only valid for the duration of the
|
||||
* callback.
|
||||
*/
|
||||
typedef void (*Dart_GCEventCallback)(Dart_GCEvent* event);
|
||||
|
||||
/**
|
||||
* Sets the native GC event callback.
|
||||
*
|
||||
* \param callback A function pointer to an event handler callback function.
|
||||
* A NULL value removes the existing listen callback function if any.
|
||||
*/
|
||||
DART_EXPORT void Dart_SetGCEventCallback(Dart_GCEventCallback callback);
|
||||
|
||||
/*
|
||||
* ========
|
||||
* Reload support
|
||||
* ========
|
||||
*
|
||||
* These functions are used to implement reloading in the Dart VM.
|
||||
* This is an experimental feature, so embedders should be prepared
|
||||
* for these functions to change.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A callback which determines whether the file at some url has been
|
||||
* modified since some time. If the file cannot be found, true should
|
||||
* be returned.
|
||||
*/
|
||||
typedef bool (*Dart_FileModifiedCallback)(const char* url, int64_t since);
|
||||
|
||||
DART_EXPORT char* Dart_SetFileModifiedCallback(
|
||||
Dart_FileModifiedCallback file_modified_callback);
|
||||
|
||||
/**
|
||||
* Returns true if isolate is currently reloading.
|
||||
*/
|
||||
DART_EXPORT bool Dart_IsReloading();
|
||||
|
||||
/*
|
||||
* ========
|
||||
* Timeline
|
||||
* ========
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable tracking of specified timeline category. This is operational
|
||||
* only when systrace timeline functionality is turned on.
|
||||
*
|
||||
* \param categories A comma seperated list of categories that need to
|
||||
* be enabled, the categories are
|
||||
* "all" : All categories
|
||||
* "API" - Execution of Dart C API functions
|
||||
* "Compiler" - Execution of Dart JIT compiler
|
||||
* "CompilerVerbose" - More detailed Execution of Dart JIT compiler
|
||||
* "Dart" - Execution of Dart code
|
||||
* "Debugger" - Execution of Dart debugger
|
||||
* "Embedder" - Execution of Dart embedder code
|
||||
* "GC" - Execution of Dart Garbage Collector
|
||||
* "Isolate" - Dart Isolate lifecycle execution
|
||||
* "VM" - Excution in Dart VM runtime code
|
||||
* "" - None
|
||||
*
|
||||
* When "all" is specified all the categories are enabled.
|
||||
* When a comma seperated list of categories is specified, the categories
|
||||
* that are specified will be enabled and the rest will be disabled.
|
||||
* When "" is specified all the categories are disabled.
|
||||
* The category names are case sensitive.
|
||||
* eg: Dart_EnableTimelineCategory("all");
|
||||
* Dart_EnableTimelineCategory("GC,API,Isolate");
|
||||
* Dart_EnableTimelineCategory("GC,Debugger,Dart");
|
||||
*
|
||||
* \return True if the categories were successfully enabled, False otherwise.
|
||||
*/
|
||||
DART_EXPORT bool Dart_SetEnabledTimelineCategory(const char* categories);
|
||||
|
||||
/**
|
||||
* Returns a timestamp in microseconds. This timestamp is suitable for
|
||||
* passing into the timeline system, and uses the same monotonic clock
|
||||
* as dart:developer's Timeline.now.
|
||||
*
|
||||
* \return A timestamp that can be passed to the timeline system.
|
||||
*/
|
||||
DART_EXPORT int64_t Dart_TimelineGetMicros();
|
||||
|
||||
/**
|
||||
* Returns a raw timestamp in from the monotonic clock.
|
||||
*
|
||||
* \return A raw timestamp from the monotonic clock.
|
||||
*/
|
||||
DART_EXPORT int64_t Dart_TimelineGetTicks();
|
||||
|
||||
/**
|
||||
* Returns the frequency of the monotonic clock.
|
||||
*
|
||||
* \return The frequency of the monotonic clock.
|
||||
*/
|
||||
DART_EXPORT int64_t Dart_TimelineGetTicksFrequency();
|
||||
|
||||
typedef enum {
|
||||
Dart_Timeline_Event_Begin, // Phase = 'B'.
|
||||
Dart_Timeline_Event_End, // Phase = 'E'.
|
||||
Dart_Timeline_Event_Instant, // Phase = 'i'.
|
||||
Dart_Timeline_Event_Duration, // Phase = 'X'.
|
||||
Dart_Timeline_Event_Async_Begin, // Phase = 'b'.
|
||||
Dart_Timeline_Event_Async_End, // Phase = 'e'.
|
||||
Dart_Timeline_Event_Async_Instant, // Phase = 'n'.
|
||||
Dart_Timeline_Event_Counter, // Phase = 'C'.
|
||||
Dart_Timeline_Event_Flow_Begin, // Phase = 's'.
|
||||
Dart_Timeline_Event_Flow_Step, // Phase = 't'.
|
||||
Dart_Timeline_Event_Flow_End, // Phase = 'f'.
|
||||
} Dart_Timeline_Event_Type;
|
||||
|
||||
/**
|
||||
* Add a timeline event to the embedder stream.
|
||||
*
|
||||
* \param label The name of the event. Its lifetime must extend at least until
|
||||
* Dart_Cleanup.
|
||||
* \param timestamp0 The first timestamp of the event.
|
||||
* \param timestamp1_or_async_id The second timestamp of the event or
|
||||
* the async id.
|
||||
* \param argument_count The number of argument names and values.
|
||||
* \param argument_names An array of names of the arguments. The lifetime of the
|
||||
* names must extend at least until Dart_Cleanup. The array may be reclaimed
|
||||
* when this call returns.
|
||||
* \param argument_values An array of values of the arguments. The values and
|
||||
* the array may be reclaimed when this call returns.
|
||||
*/
|
||||
DART_EXPORT void Dart_TimelineEvent(const char* label,
|
||||
int64_t timestamp0,
|
||||
int64_t timestamp1_or_async_id,
|
||||
Dart_Timeline_Event_Type type,
|
||||
intptr_t argument_count,
|
||||
const char** argument_names,
|
||||
const char** argument_values);
|
||||
|
||||
/**
|
||||
* Associates a name with the current thread. This name will be used to name
|
||||
* threads in the timeline. Can only be called after a call to Dart_Initialize.
|
||||
*
|
||||
* \param name The name of the thread.
|
||||
*/
|
||||
DART_EXPORT void Dart_SetThreadName(const char* name);
|
||||
|
||||
/*
|
||||
* =======
|
||||
* Metrics
|
||||
* =======
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return metrics gathered for the VM and individual isolates.
|
||||
*
|
||||
* NOTE: Non-heap metrics are not available in PRODUCT builds of Dart.
|
||||
* Calling the non-heap metric functions on a PRODUCT build might return invalid metrics.
|
||||
*/
|
||||
DART_EXPORT int64_t Dart_VMIsolateCountMetric(); // Counter
|
||||
DART_EXPORT int64_t Dart_VMCurrentRSSMetric(); // Byte
|
||||
DART_EXPORT int64_t Dart_VMPeakRSSMetric(); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldUsedMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldCapacityMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldCapacityMaxMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldExternalMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewUsedMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewCapacityMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewCapacityMaxMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewExternalMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapGlobalUsedMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapGlobalUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateRunnableLatencyMetric(Dart_Isolate isolate); // Microsecond
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateRunnableHeapSizeMetric(Dart_Isolate isolate); // Byte
|
||||
|
||||
/*
|
||||
* ========
|
||||
* UserTags
|
||||
* ========
|
||||
*/
|
||||
|
||||
/*
|
||||
* Gets the current isolate's currently set UserTag instance.
|
||||
*
|
||||
* \return The currently set UserTag instance.
|
||||
*/
|
||||
DART_EXPORT Dart_Handle Dart_GetCurrentUserTag();
|
||||
|
||||
/*
|
||||
* Gets the current isolate's default UserTag instance.
|
||||
*
|
||||
* \return The default UserTag with label 'Default'
|
||||
*/
|
||||
DART_EXPORT Dart_Handle Dart_GetDefaultUserTag();
|
||||
|
||||
/*
|
||||
* Creates a new UserTag instance.
|
||||
*
|
||||
* \param label The name of the new UserTag.
|
||||
*
|
||||
* \return The newly created UserTag instance or an error handle.
|
||||
*/
|
||||
DART_EXPORT Dart_Handle Dart_NewUserTag(const char* label);
|
||||
|
||||
/*
|
||||
* Updates the current isolate's UserTag to a new value.
|
||||
*
|
||||
* \param user_tag The UserTag to be set as the current UserTag.
|
||||
*
|
||||
* \return The previously set UserTag instance or an error handle.
|
||||
*/
|
||||
DART_EXPORT Dart_Handle Dart_SetCurrentUserTag(Dart_Handle user_tag);
|
||||
|
||||
/*
|
||||
* Returns the label of a given UserTag instance.
|
||||
*
|
||||
* \param user_tag The UserTag from which the label will be retrieved.
|
||||
*
|
||||
* \return The UserTag's label. NULL if the user_tag is invalid. The caller is
|
||||
* responsible for freeing the returned label.
|
||||
*/
|
||||
DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_GetUserTagLabel(
|
||||
Dart_Handle user_tag);
|
||||
|
||||
#endif // RUNTIME_INCLUDE_DART_TOOLS_API_H_
|
||||
16
src/dart/native/include/dart_version.h
Normal file
16
src/dart/native/include/dart_version.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
* for details. All rights reserved. Use of this source code is governed by a
|
||||
* BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef RUNTIME_INCLUDE_DART_VERSION_H_
|
||||
#define RUNTIME_INCLUDE_DART_VERSION_H_
|
||||
|
||||
// On breaking changes the major version is increased.
|
||||
// On backwards compatible changes the minor version is increased.
|
||||
// The versioning covers the symbols exposed in dart_api_dl.h
|
||||
#define DART_API_DL_MAJOR_VERSION 2
|
||||
#define DART_API_DL_MINOR_VERSION 0
|
||||
|
||||
#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */
|
||||
21
src/dart/native/include/internal/dart_api_dl_impl.h
Normal file
21
src/dart/native/include/internal/dart_api_dl_impl.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
* for details. All rights reserved. Use of this source code is governed by a
|
||||
* BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_
|
||||
#define RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
void (*function)(void);
|
||||
} DartApiEntry;
|
||||
|
||||
typedef struct {
|
||||
const int major;
|
||||
const int minor;
|
||||
const DartApiEntry* const functions;
|
||||
} DartApi;
|
||||
|
||||
#endif /* RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_ */ /* NOLINT */
|
||||
63
src/dart/pubspec.yaml
Normal file
63
src/dart/pubspec.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
name: maa_core
|
||||
description: A new flutter plugin project.
|
||||
version: 0.0.1
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.2 <3.0.0"
|
||||
flutter: ">=2.5.0"
|
||||
|
||||
dependencies:
|
||||
ffi: ^1.1.2
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
# This section identifies this Flutter project as a plugin project.
|
||||
# The 'pluginClass' and Android 'package' identifiers should not ordinarily
|
||||
# be modified. They are used by the tooling to maintain consistency when
|
||||
# adding or updating assets for this project.
|
||||
plugin:
|
||||
platforms:
|
||||
linux:
|
||||
pluginClass: MaaCorePlugin
|
||||
|
||||
# To add assets to your plugin package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.dev/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/assets-and-images/#resolution-aware.
|
||||
|
||||
# To add custom fonts to your plugin package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.dev/custom-fonts/#from-packages
|
||||
@@ -1,4 +1,4 @@
|
||||
sh ./update_version.sh
|
||||
for /f "delims=" %%i in ('sh ./version.sh') do set ExternalCompilerOptions=/DMAA_VERSION=\"%%i\"
|
||||
MSBuild.exe ..\MeoAssistantArknights.sln /p:Configuration=Release /p:Platform=x64 /t:Rebuild
|
||||
call .\update_resource_rel.bat
|
||||
pause
|
||||
|
||||
@@ -9,4 +9,4 @@ else
|
||||
Version="c""$LatestCommitId"
|
||||
fi
|
||||
|
||||
echo "Version: $Version"
|
||||
echo "$Version"
|
||||
|
||||
Reference in New Issue
Block a user