13 个版本
0.1.12 | 2021 年 2 月 19 日 |
---|---|
0.1.11 | 2021 年 2 月 19 日 |
#1618 in 网页编程
110KB
2K SLoC
DOME Cloomnik
DOME 插件的 Rust 框架。
使用此框架的每个插件的基本结构是
Cargo.toml
[package]
name = "my_awesome_dome_plugin"
description = "Really, really awesome DOME plugin written in Rust!"
version = "0.1.0"
authors = ["Me <[email protected]>"]
edition = "2018"
[dependencies]
libc = "0.2"
dome_cloomnik = "0.1"
[lib]
crate-type = ["cdylib"]
lib.rs
use dome_cloomnik::{Context, WrenVM, register_modules, HookResult};
#[no_mangle]
#[allow(non_snake_case)]
extern "C" fn PLUGIN_onInit(get_api: *mut libc::c_void, ctx: *mut libc::c_void) -> libc::c_int {
unsafe {
dome_cloomnik::init_plugin(
get_api,
ctx,
dome_cloomnik::Hooks {
on_init: Some(on_init),
pre_update: Some(pre_update),
post_update: Some(post_update),
pre_draw: Some(pre_draw),
post_draw: Some(post_draw),
on_shutdown: Some(on_shutdown),
}
)
}
}
fn on_init(mut ctx: Context) -> HookResult {
(register_modules! {
ctx,
...
})?;
// ...
}
fn pre_update(mut ctx: Context) -> HookResult {
// ...
}
fn post_update(mut ctx: Context) -> HookResult {
// ...
}
fn pre_draw(mut ctx: Context) -> HookResult {
// ...
}
fn post_draw(mut ctx: Context) -> HookResult {
// ...
}
fn on_shutdown(mut ctx: Context) -> HookResult {
// ...
}
开始学习 DOME 插件,请从文档中学习。别担心,那里的大部分内容也适用于 doom_cloomnik!
依赖项
~2.9–4.5MB
~92K SLoC