mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
add OwnedTileSet
This commit is contained in:
parent
6d942b07d0
commit
22167ac608
|
@ -14,7 +14,7 @@ pub use map::{AffineMap, MapLoan, RegularMap, TiledMap};
|
|||
pub use tiled0::Tiled0;
|
||||
pub use tiled1::Tiled1;
|
||||
pub use tiled2::Tiled2;
|
||||
pub use vram_manager::{DynamicTile, TileFormat, TileIndex, TileSet, VRamManager};
|
||||
pub use vram_manager::{DynamicTile, OwnedTileSet, TileFormat, TileIndex, TileSet, VRamManager};
|
||||
|
||||
use map::TRANSPARENT_TILE_INDEX;
|
||||
|
||||
|
|
|
@ -60,6 +60,39 @@ impl<'a> TileSet<'a> {
|
|||
fn reference(&self) -> NonNull<[u8]> {
|
||||
self.tiles.into()
|
||||
}
|
||||
|
||||
pub fn to_owned(&self) -> OwnedTileSet {
|
||||
OwnedTileSet {
|
||||
tiles: self.tiles.to_vec(),
|
||||
format: self.format,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OwnedTileSet {
|
||||
tiles: Vec<u8>,
|
||||
format: TileFormat,
|
||||
}
|
||||
|
||||
impl OwnedTileSet {
|
||||
pub fn tile_set(&self) -> TileSet<'_> {
|
||||
TileSet {
|
||||
tiles: &self.tiles,
|
||||
format: self.format,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tiles(&self) -> &[u8] {
|
||||
&self.tiles
|
||||
}
|
||||
|
||||
pub fn tiles_mut(&mut self) -> &mut [u8] {
|
||||
&mut self.tiles
|
||||
}
|
||||
|
||||
pub fn format(&self) -> TileFormat {
|
||||
self.format
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
Loading…
Reference in a new issue