agb 0.23.1

Library for Game Boy Advance Development
Documentation
#![warn(missing_docs)]
use super::tiled::{TileSet, TileSetting};

/// A container for tile data generated by [`include_background_gfx!()`][crate::include_background_gfx].
///
/// The actual tile data is in `tiles`. Each tile sorted left to right, top to bottom's settings is stored
/// in the `tile_settings` field.
///
/// The original `width` and `height` of the included background (in tiles) is stored in `width` and `height`.
#[non_exhaustive]
pub struct TileData {
    /// The actual tile data
    pub tiles: TileSet,
    /// How to display each tile. The indices here run left to right, top to bottom.
    ///
    /// If you've deduplicated the tile with the `deduplicate` option in [`include_background_gfx!()`][crate::include_background_gfx],
    /// then you should not create your own [`TileSetting`] and instead use the ones provided here (and
    /// maybe modify them, but never creating your own), because tile_ids will be changed.
    pub tile_settings: &'static [TileSetting],

    /// The original width of the tile set in tiles.
    pub width: usize,
    /// The original height of the tile set in tiles.
    pub height: usize,
}

impl TileData {
    /// Create a new TileData.
    ///
    /// You probably don't need this and should instead rely on importing tiles via
    /// [`include_background_gfx!()`][crate::include_background_gfx].
    #[must_use]
    pub const fn new(
        tiles: TileSet,
        tile_settings: &'static [TileSetting],
        width: usize,
        height: usize,
    ) -> Self {
        TileData {
            tiles,
            tile_settings,
            width,
            height,
        }
    }
}