mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
格式化工具部分: 1. pre-commit 引入 python 的格式化工具,包括 black(代码格式化)和 isort(对“包导入顺序”的规范) 2. 允许 prettier 对文档站的 markdown 文件格式化 3. 不允许 prettier 对 markdown 文件中的代码块的代码本身进行格式化 4. 升级了 pre-commit 的各个 hook 的版本 5. 优化了 pre-commit 的日志文本显示 容器总览部分: 1. 由原来的单一轻量环境转为区分空环境、轻量环境和全量环境 2. 空环境是裸 Linux 镜像(Ubuntu),为默认环境 3. 轻量环境适合开发文档站前端 4. 全量环境适合开发 MaaCore 5. 目前,全量环境完整包含了轻量环境,轻量环境完整包含了空环境 6. 在仓库 README.md 中更新了三个环境的描述,并将链接分别设置为对应环境的创建链接 **注意:没有修改文档站中的对应文件** 7. 在各个语言的开发指南的最后,移除了 Codespace 部分的“安装额外依赖”相关描述,且将链接设置为全量环境的创建链接 **注意:没有添加“开发文档站”的指南和对应 codespace 的使用方式** 容器的轻量环境和全量环境共有部分: 1. 安装 black 和 isort 包 2. 调整 VS Code 设置,取消先前(对 markdown 文件单独指定 markdownlint 扩展作为格式化工具)的错误设置,现在 markdown 文件仍然使用默认的 prettier 扩展作为格式化工具 3. 引入 markdown-all-in-one 扩展作为语法提示工具 4. 将 node_modules 和 3rdparty 排除在 VS Code 的文本的搜索路径之外 容器的全量环境部分: 1. 为 tools 下的所有 python 脚本安装依赖 2. 使用 tools/maadeps-download.py 下载 maadeps,且将必要二进制文件软链接到 /usr/local/bin/ 3. 使用 apt 安装 cmake 和 clangd-20,将后者通过 update-alternatives 设置为系统 clangd 的默认版本 4. 使用 cmake tools 扩展,并按照 Linux 编译方法进行配置 5. 使用 clang-format 作为 c/cpp 的格式化工具,clang-format 程序主体来自 maadeps(已经软链接到 /usr/local/bin/) 6. 使用 clangd 作为 c/cpp 的语法提示工具 7. 将 MaaDeps、install 和 build 排除在 VS Code 的文本搜索路径之外 其它手动调整: 1. 更新文档站的 package.json,指定 pnpm 包管理器的版本 2. 手动保证 markdown 文件中的列表前后有空行(注意到 MarkdownLint 官方规则不一定能精准定位所有“列表前后空行”的问题,详见:https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md032---lists-should-be-surrounded-by-blank-lines ) 3. 修改了部分 markdown 文件中的 json 代码块的语法问题 **注意:相同的问题并未全部发现,仅修改了两处** 4. 在 tools 目录中,一处 python 脚本的包名误用(本地包名和某个 pip 包重名),这里修改了相应代码 5. 在 tools 目录中,一处 python 脚本使用了弃用的包 cchardet 的问题,这里更换了推荐使用的功能相近的包并修改了相应代码 自动化脚本提交的修改: 1. 自动格式化了大量 tools 中的 python 脚本 2. 自动格式化了大量 docs 中的 markdown 文件 Commits: * chore: pre-commit引入black和isort规范py文件 * chore: Auto update by pre-commit hooks [skip changelog] * chore: devcontainer添加isort扩展,排序python导入 * chore: pre-commit任务命名及更名 * style: isort fix * chore: Auto update by pre-commit hooks [skip changelog] * chore: 更新pre-commit的hook版本 * fix: 模块名与第三方库重名,大忌 * chore: 容器构建时额外安装isort * docs: md -> markdown * chore: 容器安装python包和maadeps * fix: 修复过时python包 * chore: 指定pnpm版本 * chore: container支持选择轻量环境 * chore: 去掉rust * chore: add plain env * chore: 使用clangd语言服务器 * chore: 无需单独设置markdown的格式化工具 * chore: 更新安装的clangd版本 * docs: 简易文档适配 * docs: 在仓库README中重新编排codespaces相关指引 * chore: Auto update by pre-commit hooks [skip changelog] * style: 调整缩进 * chore: 格式化工具不用特意排除被gitignore忽略的文件 * chore: sh文件在gitattributes中单列一类 * chore: 格式化docs下的markdown文件 * chore: 暂时不修改md文件中的代码块 * style: 人为明确markdown中的部分列表相关格式 * docs: 补上部分markdown的json代码块中缺失的逗号 * chore: Auto update by pre-commit hooks [skip changelog] * chore: Auto update by pre-commit hooks [skip changelog] * fix: 补上tools的服务器排序相关代码中缺失的逗号 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: 使用maadeps的clangd * build: 更新maadeps工具链版本 * style: prettier fix * revert: 还原maadeps版本 * revert: 取消使用maadeps的clangd依赖,改用系统apt安装 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
146 lines
7.0 KiB
Markdown
146 lines
7.0 KiB
Markdown
---
|
|
order: 3
|
|
icon: teenyicons:linux-alt-solid
|
|
---
|
|
|
|
# Linux Emulators and Containers
|
|
|
|
## Preparation
|
|
|
|
Choose one of the following installation methods:
|
|
|
|
### Using maa-cli
|
|
|
|
[maa-cli](https://github.com/MaaAssistantArknights/maa-cli) is a simple command-line tool for MAA written in Rust. Please read the [CLI User Guide](../cli/) for installation and usage instructions.
|
|
|
|
### Using Wine
|
|
|
|
The MAA WPF GUI can currently be run through Wine.
|
|
|
|
#### Installation Steps
|
|
|
|
1. Go to the [.NET download page](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and download/install the Windows version of .NET **Desktop** Runtime.
|
|
|
|
2. Download the Windows version of MAA, extract it, and run `wine MAA.exe`.
|
|
|
|
::: info Note
|
|
You need to set the ADB path to the [Windows version of `adb.exe`](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) in the connection settings.
|
|
|
|
If you need to connect to USB devices via ADB, first run `adb start-server` outside of Wine to connect to the native ADB server through Wine.
|
|
:::
|
|
|
|
#### Using Linux Native MaaCore (Experimental)
|
|
|
|
Download and build the [MAA Wine Bridge](https://github.com/MaaAssistantArknights/MaaAssistantArknights/tree/dev/src/MaaWineBridge) source code, replace the Windows version with the generated `MaaCore.dll` (ELF file), and place the Linux native dynamic libraries (`libMaaCore.so` and dependencies) in the same directory.
|
|
|
|
When running `MAA.exe` through Wine, it will load the Linux native libraries.
|
|
|
|
::: info Note
|
|
When using the Linux native MaaCore, you need to set the ADB path to the Linux native ADB in the connection settings.
|
|
:::
|
|
|
|
#### Linux Desktop Integration (Experimental)
|
|
|
|
Desktop integration provides native desktop notification support and maps fontconfig font configurations to WPF.
|
|
|
|
Place the `MaaDesktopIntegration.so` generated by MAA Wine Bridge in the same directory as `MAA.exe` to enable this feature.
|
|
|
|
#### Known Issues
|
|
|
|
- Wine DirectWrite forces hinting and doesn't pass DPI to FreeType, resulting in poor font display.
|
|
- When not using native desktop notifications, popup notifications grab the system-wide mouse focus, making it impossible to interact with other windows. You can mitigate this by enabling virtual desktop mode in `winecfg` or disabling desktop notifications.
|
|
- Wine-staging users need to disable the `Hide Wine version` option in `winecfg` for MAA to correctly detect the Wine environment.
|
|
- Wine's Light theme causes text color issues in WPF. We recommend using no theme (Windows Classic theme) in `winecfg`.
|
|
- Wine uses the old XEmbed tray icon system, which may not work properly under GNOME.
|
|
- When using Linux native MaaCore, automatic updates are not supported (~~the updater thinks: I should download a Windows version~~)
|
|
|
|
### Using Python
|
|
|
|
#### 1. Installing MAA Dynamic Library
|
|
|
|
1. Download and extract the Linux dynamic library from the [MAA website](https://maa.plus/), or install from a software repository:
|
|
- AUR: [maa-assistant-arknights](https://aur.archlinux.org/packages/maa-assistant-arknights), follow the post-installation instructions
|
|
- Nixpkgs: [maa-assistant-arknights](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/ma/maa-assistant-arknights/package.nix)
|
|
|
|
2. Navigate to `./MAA-v{version}-linux-{architecture}/Python/` and open the `sample.py` file
|
|
|
|
::: tip
|
|
The precompiled version includes dynamic libraries compiled on relatively new Linux distributions (Ubuntu 22.04). If your system has an older libstdc++ version, you might encounter ABI incompatibility issues.
|
|
You can refer to the [Linux Compilation Tutorial](../../develop/linux-tutorial.md) to recompile or use a container solution.
|
|
:::
|
|
|
|
#### 2. ADB Configuration
|
|
|
|
1. Find the line [`if asst.connect('adb.exe', '127.0.0.1:5554'):`](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/b4fc3528decd6777441a8aca684c22d35d2b2574/src/Python/sample.py#L62)
|
|
|
|
2. ADB Tool Configuration
|
|
- If using `Android Studio`'s `AVD` emulator, it comes with ADB. You can directly specify the ADB path to replace `adb.exe`, typically found in `$HOME/Android/Sdk/platform-tools/`, for example:
|
|
|
|
```python
|
|
if asst.connect("/home/foo/Android/Sdk/platform-tools/adb", "emulator's ADB address"):
|
|
```
|
|
|
|
- For other emulators, first install ADB: `$ sudo apt install adb`, then either specify the path or simply use `adb` if it's in your `PATH` environment variable.
|
|
|
|
3. Getting the Emulator's ADB Address
|
|
- Use the ADB tool directly: `$ adb_path devices`, for example:
|
|
|
|
```shell
|
|
$ /home/foo/Android/Sdk/platform-tools/adb devices
|
|
List of devices attached
|
|
emulator-5554 device
|
|
```
|
|
|
|
- The returned `emulator-5554` is the emulator's ADB address. Replace `127.0.0.1:5555` with it, for example:
|
|
|
|
```python
|
|
if asst.connect("/home/foo/Android/Sdk/platform-tools/adb", "emulator-5554"):
|
|
```
|
|
|
|
4. Now you can test with `$ python3 sample.py`. If it returns "Connection successful," you're ready to proceed.
|
|
|
|
#### 3. Task Configuration
|
|
|
|
Custom tasks: Refer to the [Integration Documentation](../../protocol/integration.md) and modify the [`# Task parameters can be found in docs/integration.md`](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/722f0ddd4765715199a5dc90ea1bec2940322344/src/Python/sample.py#L54) section in `sample.py`
|
|
|
|
## Emulator Support
|
|
|
|
### ✅ [AVD](https://developer.android.com/studio/run/managing-avds)
|
|
|
|
Requirements: 16:9 screen resolution larger than 720p
|
|
|
|
Recommended configuration: x86_64 architecture (R - 30 - x86_64 - Android 11.0) with MAA's Linux x64 dynamic library
|
|
|
|
Note: Starting from Android 10, Minitouch is no longer available when SELinux is in `Enforcing` mode. Please switch to other touch modes, or **temporarily** switch SELinux to `Permissive` mode.
|
|
|
|
### ⚠️ [Genymotion](https://www.genymotion.com/)
|
|
|
|
High Android versions include x86_64 framework. Lightweight but tends to crash when running Arknights.
|
|
|
|
Not thoroughly tested yet, but ADB functionality and path retrieval work without issues.
|
|
|
|
## Containerized Android Support
|
|
|
|
::: tip
|
|
The following solutions typically require specific kernel modules. Please install the appropriate modules according to your distribution and the particular solution.
|
|
:::
|
|
|
|
### ✅ [Waydroid](https://waydro.id/)
|
|
|
|
After installation, you need to reset the resolution (to 16:9 ratio and greater than 720p, then restart):
|
|
|
|
```shell
|
|
waydroid prop set persist.waydroid.width 1280
|
|
waydroid prop set persist.waydroid.height 720
|
|
```
|
|
|
|
To set up ADB IP address: Go to `Settings` - `About` - `IP address`, note the first `IP`, and use `${recorded IP}:5555` in `sample.py` for the ADB IP.
|
|
|
|
If using amdgpu, the `screencap` command might output messages to stderr, causing image decoding failures.
|
|
You can run `adb exec-out screencap | xxd | head` and check if there's text like `/vendor/etc/hwdata/amdgpu.ids: No such file...` in the output.
|
|
If present, try changing the screenshot command in `resource/config.json` from `adb exec-out screencap` to `adb exec-out 'screencap 2>/dev/null'`.
|
|
|
|
### ✅ [redroid](https://github.com/remote-android/redroid-doc)
|
|
|
|
Android 11 version images can run the game normally. Make sure to expose port 5555 for ADB.
|