pub struct SpriteRegistry { /* private fields */ }Expand description
Registry for sprites and variants.
Handles resolution of sprite names to renderable sprites, including expanding variants to their effective sprite representation.
Implementations§
Source§impl SpriteRegistry
impl SpriteRegistry
Sourcepub fn register_sprite(&mut self, sprite: Sprite)
pub fn register_sprite(&mut self, sprite: Sprite)
Register a sprite.
Sourcepub fn register_variant(&mut self, variant: Variant)
pub fn register_variant(&mut self, variant: Variant)
Register a variant.
Sourcepub fn get_sprite(&self, name: &str) -> Option<&Sprite>
pub fn get_sprite(&self, name: &str) -> Option<&Sprite>
Get a sprite by name (does not resolve variants).
Sourcepub fn get_variant(&self, name: &str) -> Option<&Variant>
pub fn get_variant(&self, name: &str) -> Option<&Variant>
Get a variant by name.
Sourcepub fn resolve(
&self,
name: &str,
palette_registry: &PaletteRegistry,
strict: bool,
) -> Result<ResolvedSprite, SpriteError>
pub fn resolve( &self, name: &str, palette_registry: &PaletteRegistry, strict: bool, ) -> Result<ResolvedSprite, SpriteError>
Resolve a name to a sprite-like structure, expanding variants.
In strict mode, returns an error if the name or base is not found. In lenient mode, returns a fallback result with warnings.
The returned ResolvedSprite contains the effective grid and merged palette.
Sourcepub fn sprite_count(&self) -> usize
pub fn sprite_count(&self) -> usize
Get the number of sprites (excluding variants).
Sourcepub fn variant_count(&self) -> usize
pub fn variant_count(&self) -> usize
Get the number of variants (excluding sprites).
Trait Implementations§
Source§impl Clone for SpriteRegistry
impl Clone for SpriteRegistry
Source§fn clone(&self) -> SpriteRegistry
fn clone(&self) -> SpriteRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpriteRegistry
impl Debug for SpriteRegistry
Source§impl Default for SpriteRegistry
impl Default for SpriteRegistry
Source§fn default() -> SpriteRegistry
fn default() -> SpriteRegistry
Returns the “default value” for a type. Read more
Source§impl Registry<Sprite> for SpriteRegistry
impl Registry<Sprite> for SpriteRegistry
Auto Trait Implementations§
impl Freeze for SpriteRegistry
impl RefUnwindSafe for SpriteRegistry
impl Send for SpriteRegistry
impl Sync for SpriteRegistry
impl Unpin for SpriteRegistry
impl UnsafeUnpin for SpriteRegistry
impl UnwindSafe for SpriteRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().