From c2a93f774094662b9fbd0e153dd1736247439a60 Mon Sep 17 00:00:00 2001 From: SweetSmellFox <154436242+SweetSmellFox@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:13:15 +0800 Subject: [PATCH] docs: Create README_zh.md & add MFAWPF (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: Create README_zh.md add MFAWPF * docs: fix * docs: Update README --------- Co-authored-by: 枫雨 <35213527+moomiji@users.noreply.github.com> --- MaaFramework.Binding.sln | 3 +- README.md | 12 ++- README_zh.md | 184 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 README_zh.md diff --git a/MaaFramework.Binding.sln b/MaaFramework.Binding.sln index 956a61a..c781b6e 100644 --- a/MaaFramework.Binding.sln +++ b/MaaFramework.Binding.sln @@ -10,8 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitignore = .gitignore Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props - LICENSE = LICENSE + LICENSE.md = LICENSE.md README.md = README.md + README_zh.md = README_zh.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MaaFramework.Binding", "src\MaaFramework.Binding\MaaFramework.Binding.csproj", "{F15504A2-1A15-4574-BF63-CF2282BCA69B}" diff --git a/README.md b/README.md index 75ac536..4ccf2cc 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ _💫 A common interoperable API wrapper 💫_ ![license](https://img.shields.io/github/license/MaaXYZ/MaaFramework) ![language](https://img.shields.io/badge/.NET-≥%207-512BD4?logo=csharp) ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blueviolet) [![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Maa.Framework?logo=nuget&color=%23004880)](https://www.nuget.org/packages/Maa.Framework) +[English](./README.md) | [简体中文](./README_zh.md) + ## Articles @@ -28,7 +30,7 @@ Your computer should meet the minimum system requirements before you run and use | macOS 12+ | Restricted from [MaaFramework](https://github.com/MaaXYZ/MaaFramework/issues/174) | | Linux
Ubuntu 23.10+ | libc6 2.38+
and more | -- Architectures: x64, Arm64 +- Architectures: x64, arm64 ### Install Dependents @@ -42,7 +44,7 @@ Your computer should meet the minimum system requirements before you run and use See MaaFramework document ([en-us](https://github.com/MaaXYZ/MaaFramework/blob/v1.4.0/docs/en_us/1.1-QuickStarted.md#prepare-resource-files) / [zh_cn](https://github.com/MaaXYZ/MaaFramework/blob/v1.4.0/docs/zh_cn/1.1-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md#%E5%87%86%E5%A4%87%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6)). -Like this [SampleResource](./src/MaaFramework.Binding.UnitTests/SampleResource) in MaaFramework.Binding.CSharp. +Like this [SampleResource](./src/MaaFramework.Binding.UnitTests/SampleResource) in `MaaFramework.Binding.CSharp`. ### Add Packages @@ -154,8 +156,10 @@ internal sealed class MyAct : IMaaCustomAction ## Best Practices -- [MBA](https://github.com/MaaXYZ/MBA) BA Assistant +- [MBA](https://github.com/MaaXYZ/MBA) BA Assistant A BA Assistant based on MAA's new architecture. Image technology + simulation control, no more clicking! Powered by MaaFramework. +- [MFAWPF](https://github.com/SweetSmellFox/MFAWPF) MFA Task Manager + A Universal GUI based on MAA's new architecture. Powered by MaaFramework. - You can also find more examples in the [Unit Tests](./src/MaaFramework.Binding.UnitTests). @@ -165,7 +169,7 @@ We have written detailed documentation comments in source code files. You can also visit [API Reference](https://maaxyz.github.io/MaaFramework.Binding.CSharp/api/MaaFramework.Binding.html) and [Unit Tests](./src/MaaFramework.Binding.UnitTests) for more information. -If you still intend to use a API Reference specific to your preferred version of MaaFramework.Binding.CSharp, you may refer to the releases page of the project and download the attached docs.zip file. +If you still intend to use a API Reference specific to your preferred version of MaaFramework.Binding.CSharp, you may refer to the releases page of the project and download the attached `docs.zip` file. ## Contributing diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 0000000..ad023a9 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,184 @@ +
+ +LOGO + +# MaaFramework.Binding.CSharp + +_✨ [MaaFramework](https://github.com/MaaXYZ/MaaFramework/tree/v1.6.4) 的 C# 绑定 ✨_ + +_💫 一个通用的互操作 API 封装 💫_ + +![license](https://img.shields.io/github/license/MaaXYZ/MaaFramework) ![language](https://img.shields.io/badge/.NET-≥%207-512BD4?logo=csharp) ![platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS-blueviolet) [![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Maa.Framework?logo=nuget&color=%23004880)](https://www.nuget.org/packages/Maa.Framework) + +[English](./README.md) | [简体中文](./README_zh.md) + +
+ +## 文章 + +- [已封装 API 一览](https://maaxyz.github.io/MaaFramework.Binding.CSharp/articles/overview-of-wrapper-and-api.html) + +## 快速开始 + +### 系统要求 + +你的计算机应满足最低系统要求,才能运行和使用 `MaaFramework.Binding.CSharp` ,该框架可能在此处未列出的其他平台或版本上运行。 + +| 操作系统版本 | 最低要求 / 受限原因 | +| :---: | :---: | +| Windows 10+ | 受限于 [.NET 7.0](https://github.com/dotnet/core/blob/main/release-notes/7.0/supported-os.md#windows) | +| macOS 12+ | 受限于 [MaaFramework](https://github.com/MaaXYZ/MaaFramework/issues/174) | +| Linux
Ubuntu 23.10+ | libc6 2.38+ 等 | + +- 架构限制: x64, arm64 + +### 安装依赖 + +`MaaFramework.Binding.CSharp` 需要安装以下依赖项才能正常运行。 + +| 平台 | 包 Id | 依赖下载 | +| :---: | :---: | :---: | +| Windows | `Maa.Framework`
`Maa.Framework.Binding.Native` | [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) | + +### 准备资源 + +请参阅 MaaFramework 文档 ([en-us](https://github.com/MaaXYZ/MaaFramework/blob/v1.4.0/docs/en_us/1.1-QuickStarted.md#prepare-resource-files) / [zh_cn](https://github.com/MaaXYZ/MaaFramework/blob/v1.4.0/docs/zh_cn/1.1-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md#%E5%87%86%E5%A4%87%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6)) 。 + +如同在 `MaaFramework.Binding.CSharp` 使用的的 [SampleResource](./src/MaaFramework.Binding.UnitTests/SampleResource) 。 + +### 添加包 + +#### 正式版本 + +[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Maa.Framework?logo=nuget&color=%23004880)](https://www.nuget.org/packages/Maa.Framework) + +``` ps1 +dotnet add package Maa.Framework --prerelease +``` + +#### 夜间构建 + +从 [CI Action](https://github.com/MaaXYZ/MaaFramework.Binding.CSharp/actions/workflows/ci.yml) 下载 `nupkgs.zip` 并解压文件到 `.\nupkgs\` 。 + +- shell +``` ps1 +dotnet add package Maa.Framework --prerelease -s .\nupkgs\ +``` + +- or .csproj +``` xml + + $(RestoreSources);$(FullPath of .\nupkgs\) + +``` +### 运行代码 + +> 准备工作:`adb connect HOST[:PORT]` + +```CSharp +using MaaFramework.Binding; + +var devices = new MaaToolkit(true).Device.Find(); +if (devices.Length < 1) + throw new InvalidOperationException(); + +using var maa = new MaaInstance +{ + Controller = devices[0].ToAdbController(), + Resource = new MaaResource("./SampleResource"), + DisposeOptions = DisposeOptions.All, +}; + +if (!maa.Initialized) + throw new InvalidOperationException(); + +maa.AppendTask("EmptyTask") + .Wait() + .ThrowIfNot(MaaJobStatus.Success); + +Console.WriteLine("EmptyTask Completed"); +``` + +#### 客制化 + +```CSharp +using MaaFramework.Binding.Buffers; +using MaaFramework.Binding.Custom; + +var taskName = "MyCustomTask"; +var param = $$""" +{ + "{{taskName}}": { + "recognition": "Custom", + "custom_recognition": "MyRec", + "custom_recognition_param": { + "my_rec_key": "my_rec_value" + }, + "action": "Custom", + "custom_action": "MyAct", + "custom_action_param": { + "my_act_key": "my_act_value" + } + } +} +"""; + +maa.Register(new MyRec()); +maa.Register(new MyAct()); +maa.AppendTask(taskName, param) + .Wait() + .ThrowIfNot(MaaJobStatus.Success); + +internal sealed class MyRec : IMaaCustomRecognizer +{ + public string Name { get; set; } = nameof(MyRec); + + public bool Analyze(in IMaaSyncContext syncContext, IMaaImageBuffer image, string taskName, string customRecognitionParam, in IMaaRectBuffer outBox, in IMaaStringBuffer outDetail) + { + outBox.SetValues(0, 0, 100, 100); + outDetail.SetValue("Hello World!"); + return true; + } +} + +internal sealed class MyAct : IMaaCustomAction +{ + public string Name { get; set; } = nameof(MyAct); + + public void Abort() { } + + public bool Run(in IMaaSyncContext syncContext, string taskName, string customActionParam, IMaaRectBuffer curBox, string curRecDetail) + { + return true; + } +} +``` + +## 最佳实践 + +- [MBA](https://github.com/MaaXYZ/MBA) BA 小助手 + 基于 MAA 全新架构的 BA 小助手。 图像技术 + 模拟控制,解放双手,不再点点点!由 MaaFramework 强力驱动! +- [MFAWPF](https://github.com/SweetSmellFox/MFAWPF) MFA 任务管理器 + 基于 MAA 全新架构的 通用 GUI。 由 MaaFramework 强力驱动! + +- 您还可以在 [单元测试](./src/MaaFramework.Binding.UnitTests) 中找到更多示例。 + +## 文档 + +我们在源代码文件中编写了详细的文档注释。 + +您还可以访问 [API 参考](https://maaxyz.github.io/MaaFramework.Binding.CSharp/api/MaaFramework.Binding.html) 和 [单元测试](./src/MaaFramework.Binding.UnitTests) 获取更多信息。 + +如果你仍然希望查阅特定版本的 MaaFramework.Binding.CSharp 的 API 参考,可以参考项目的发布页面并下载附带的 `docs.zip` 文件。 + +## 贡献 + +我们欢迎对 MaaFramework.Binding.CSharp 的贡献。如果您发现了 bug 或有功能请求,请在 GitHub 仓库中打开一个 issue。如果您想贡献代码,可以随时 fork 仓库并提交 pull request。 + +## 许可证 + +`MaaFramework` 采用 [`LGPL-3.0`](./LICENSE.md) 许可证开源。 + +## 讨论 + +- QQ 群: 595990173