mirror of
https://github.com/Theaninova/mhlib.git
synced 2026-01-07 01:02:49 +00:00
mhk3
This commit is contained in:
13
rust/mhgd/Cargo.toml
Normal file
13
rust/mhgd/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "mhgd"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
godot = { git = "https://github.com/godot-rust/gdext", branch = "master" }
|
||||||
|
lightwave-3d = "1.0.0"
|
||||||
|
itertools = "0.10.5"
|
||||||
|
starforcelib = { path = "../starforcelib" }
|
||||||
|
springylib = { path = "../springylib" }
|
||||||
40
rust/mhgd/src/lib.rs
Normal file
40
rust/mhgd/src/lib.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use crate::sproing::datafile::DatafileLoader;
|
||||||
|
use ::godot::engine::class_macros::auto_register_classes;
|
||||||
|
use ::godot::engine::{ResourceFormatLoaderVirtual, ResourceLoader};
|
||||||
|
use ::godot::init::{gdextension, ExtensionLayer};
|
||||||
|
use ::godot::prelude::{ExtensionLibrary, Gd, InitHandle, InitLevel, Share};
|
||||||
|
|
||||||
|
pub mod sproing;
|
||||||
|
pub mod lightwave_object;
|
||||||
|
|
||||||
|
struct Main {}
|
||||||
|
|
||||||
|
#[gdextension]
|
||||||
|
unsafe impl ExtensionLibrary for Main {
|
||||||
|
fn load_library(handle: &mut InitHandle) -> bool {
|
||||||
|
handle.register_layer(InitLevel::Editor, ResourceLoaderLayer { datafile: None });
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ResourceLoaderLayer {
|
||||||
|
pub datafile: Option<Gd<DatafileLoader>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExtensionLayer for ResourceLoaderLayer {
|
||||||
|
fn initialize(&mut self) {
|
||||||
|
auto_register_classes();
|
||||||
|
|
||||||
|
self.datafile = Some(Gd::<DatafileLoader>::with_base(DatafileLoader::init));
|
||||||
|
|
||||||
|
ResourceLoader::singleton()
|
||||||
|
.add_resource_format_loader(self.datafile.as_ref().unwrap().share().upcast(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deinitialize(&mut self) {
|
||||||
|
if let Some(datafile) = &self.datafile {
|
||||||
|
ResourceLoader::singleton().remove_resource_format_loader(datafile.share().upcast());
|
||||||
|
self.datafile = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user