readme update

This commit is contained in:
Robin Appelman 2025-06-02 20:42:02 +02:00
commit b758e2ea13
2 changed files with 24 additions and 1 deletions

View file

@ -9,3 +9,26 @@ directory.
Supports loading both plain file data, data embedded in `vpk` files and data Supports loading both plain file data, data embedded in `vpk` files and data
embedded in `bsp` maps. embedded in `bsp` maps.
## Usage
```rust
use tf_asset_loader::{Loader, LoaderError};
fn main() -> Result<(), LoaderError> {
let loader = Loader::new()?;
if let Some(model) = loader.load("models/props_gameplay/resupply_locker.mdl")? {
println!("resupply_locker.mdl is {} bytes large", model.len());
}
Ok(())
}
```
## Additional sources
You can customize the sources the loader looks for files by using
[ `Loader::add_source`](https://docs.rs/tf-asset-loader/latest/tf_asset_loader/struct.Loader.html#method.add_source).
This supports folders on the filesystem,
[vpk archives](https://crates.io/crates/vpk) or
[Pack files](https://docs.rs/vbsp/latest/vbsp/data/struct.Packfile.html) from
[bsp files](https://crates.io/crates/vbsp)

View file

@ -119,7 +119,7 @@ impl Loader {
/// Add a new source to the loader. /// Add a new source to the loader.
/// ///
/// This is intended to be used to add data from bsp files /// This is mainly intended to be used to add data from bsp files, but can also be used to load from additional paths or vpks.
pub fn add_source<S: AssetSource + Send + Sync + 'static>(&mut self, source: S) { pub fn add_source<S: AssetSource + Send + Sync + 'static>(&mut self, source: S) {
self.sources.push(Arc::new(source)) self.sources.push(Arc::new(source))
} }