Skip to content

Commit

Permalink
reverted an unnecessary breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Oct 20, 2024
1 parent 689cbb1 commit c7d39c3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions martin/src/sprites/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ impl ConfigExtras for SpriteConfig {
}

#[derive(Debug, Clone, Default)]
pub struct SpriteSources {
sources: HashMap<String, SpriteSource>,
}
pub struct SpriteSources(HashMap<String, SpriteSource>);

impl SpriteSources {
pub fn resolve(config: &mut FileConfigEnum<SpriteConfig>) -> FileResult<Self> {
Expand Down Expand Up @@ -112,7 +110,7 @@ impl SpriteSources {
pub fn get_catalog(&self) -> SpriteResult<SpriteCatalog> {
// TODO: all sprite generation should be pre-cached
let mut entries = SpriteCatalog::new();
for (id, source) in &self.sources {
for (id, source) in &self.0 {
let paths = get_svg_input_paths(&source.path, true)
.map_err(|e| SpriteProcessingError(e, source.path.clone()))?;
let mut images = Vec::with_capacity(paths.len());
Expand All @@ -133,7 +131,7 @@ impl SpriteSources {
if path.is_file() {
warn!("Ignoring non-directory sprite source {id} from {disp_path}");
} else {
match self.sources.entry(id) {
match self.0.entry(id) {
Entry::Occupied(v) => {
warn!("Ignoring duplicate sprite source {} from {disp_path} because it was already configured for {}",
v.key(), v.get().path.display());
Expand All @@ -158,7 +156,7 @@ impl SpriteSources {
let sprite_ids = ids
.split(',')
.map(|id| {
self.sources
self.0
.get(id)
.ok_or_else(|| SpriteError::SpriteNotFound(id.to_string()))
})
Expand Down Expand Up @@ -242,7 +240,7 @@ mod tests {
PathBuf::from("../tests/fixtures/sprites/src2"),
]);

let sprites = SpriteSources::resolve(&mut cfg).unwrap().sources;
let sprites = SpriteSources::resolve(&mut cfg).unwrap().0;
assert_eq!(sprites.len(), 2);

//.sdf => generate sdf from png, add sdf == true
Expand Down

0 comments on commit c7d39c3

Please sign in to comment.