13 个版本
0.4.1 | 2024 年 4 月 22 日 |
---|---|
0.4.0 | 2024 年 3 月 14 日 |
0.3.1 | 2020 年 6 月 1 日 |
0.2.2 | 2017 年 2 月 13 日 |
0.1.1 | 2015 年 12 月 14 日 |
#458 在 加密学 中
每月 147 次下载
120KB
2.5K SLoC
Rust 的 X-Plane 插件 API
目的
Rust XPLM 为所有平台提供了 Rust 编程语言进行 X-Plane 插件开发的便捷接口。
因为我们使用的是 X-Plane SDK 3.0 版本,任何使用此库创建的插件都支持 X-Plane 11.10 或更高版本。
状态
该库仍处于不完整状态。因此,SDK 的某些部分可能只得到少量覆盖或完全缺失。
- 编译并可从 X-Plane 调用
- 控制台/日志文件中的调试日志
- DataRef 读写
- 命令
- GUI - 需要进一步工作
- 绘图 - 需要进一步工作
示例
更多示例可以在 examples/
目录中找到。
这个小的片段是使您的插件编译所需的最小模板。
extern crate xplm;
use xplm::plugin::{Plugin, PluginInfo};
use xplm::{debugln, xplane_plugin};
struct MinimalPlugin;
impl Plugin for MinimalPlugin {
type Error = std::convert::Infallible;
fn start() -> Result<Self, Self::Error> {
// The following message should be visible in the developer console and the Log.txt file
debugln!("Hello, World! From the Minimal Rust Plugin");
Ok(MinimalPlugin)
}
fn info(&self) -> PluginInfo {
PluginInfo {
name: String::from("Minimal Rust Plugin"),
signature: String::from("org.samcrow.xplm.examples.minimal"),
description: String::from("A plugin written in Rust"),
}
}
}
xplane_plugin!(MinimalPlugin);
编译和安装插件
cargo new --lib my-rxplm-project
cd my-rxplm-project
cargo add xplm
然后添加到 Cargo.toml
[lib]
crate-type = ["cdylib"]
将上面的最小示例复制到 src/lib.rs
cargobuild
将 target/debug/my_rxplm_project.dll
重命名为 win.xpl
(或将 my_rxplm_project.so
重命名为 lin.xpl
等),并将其复制到飞机/风景/模拟插件文件夹
交叉编译
cross 工具可能有助于为多个操作系统/架构编译插件。
许可证
以下任一许可证下授权
- Apache License,版本 2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- 麻省理工学院许可证(LICENSE-MIT 或 http://opensource.org/licenses/MIT)
由您选择。
贡献
除非您明确声明,否则您有意提交以包含在作品中的任何贡献,均应按上述方式双许可,不附加任何其他条款或条件。
依赖项
~0.6–2.9MB
~52K SLoC