From e3d0a5c36c62bc6b5de1751cb486e3c7ba01fbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <bjorn@lindeijer.nl> Date: Wed, 26 Jan 2022 09:43:46 +0000 Subject: [PATCH] Expose types at the top level (#132) * Expose types at the top level While the modules are great for organizing the code internally, it is more convenient for users of the create when the types are available at the top level. This avoids the verbosity like "map::Map". * Changelog updated Removed the lines stating where which class has been moved, since all these classes are not available at the top level again. Also removed some things which I didn't think we actually noteworthy for people reading up on what had changed. * Restored some changelog items Removal of these items unrelated to how the data types are exposed. --- CHANGELOG.md | 22 ++++++---------------- README.md | 2 +- examples/main.rs | 2 +- src/lib.rs | 28 +++++++++++++++++++--------- tests/lib.rs | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c54b1..cef98f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,28 +11,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Tileset::columns`. - `Layer::id`, `Layer::width` and `Layer::height`. - Support for 'object'-type properties. +- Support for multiline string properties. - Documentation for map members. - Tests for `tiled_base64_zstandard.tmx`. - `.gitattributes` for line ending consistency. -- Support for multiline string properties. - MIT license file. ### Changed -- Reorganized crate: - - `parse_file`, `parse` -> `Map::parse_file` with optional path. - - `parse_with_path` -> `Map::parse_reader` - - `parse_tileset` -> `Tileset::parse` - - `Frame` has been moved to the `animation` module. - - `ParseTileError` & `TiledError` have been moved into the `error` module. - - `Image` has been moved into the `image` module. - - `LayerTile`, `Layer`, `LayerData`, `ImageLayer` & `Chunk` have been moved into the `layers` module. - - `Map` & `Orientation` have been moved into the `map` module. - - `ObjectGroup`, `ObjectShape` & `Object` have been moved into the `objects` module. - - `Colour`, `PropertyValue` & `Properties` have been moved into the `properties` module. - - All mentions of `Colour` have been changed to `Color` for consistency with the Tiled dataformat. - - `Tile` has been moved into the `tile` module. - - `Tileset` has been moved into the `tileset` module. - - `Map::get_tileset_by_gid` -> `Map::tileset_by_gid` +- `parse_file`, `parse` -> `Map::parse_file` with optional path. +- `parse_with_path` -> `Map::parse_reader`. +- `parse_tileset` -> `Tileset::parse`. +- All mentions of `Colour` have been changed to `Color` for consistency with the Tiled dataformat. +- `Map::get_tileset_by_gid` -> `Map::tileset_by_gid`. - `Layer::tiles` changed from `Vec<Vec<LayerTile>>` to `Vec<LayerTile>`. - Tile now has `image` instead of `images`. ([Issue comment](https://github.com/mapeditor/rs-tiled/issues/103#issuecomment-940773123)) - Tileset now has `image` instead of `images`. diff --git a/README.md b/README.md index 4b2eec0..fd40af5 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ to the dependencies section of your Cargo.toml. ### Example ```rust -use tiled::map::Map; +use tiled::Map; fn main() { let map = Map::parse_file("assets/tiled_base64_zlib.tmx").unwrap(); diff --git a/examples/main.rs b/examples/main.rs index afdcb6d..d39dd52 100644 --- a/examples/main.rs +++ b/examples/main.rs @@ -1,4 +1,4 @@ -use tiled::map::Map; +use tiled::Map; fn main() { let map = Map::parse_file("assets/tiled_base64_zlib.tmx").unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 2033ef1..ff45bb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,20 @@ -pub mod animation; -pub mod error; -pub mod image; -pub mod layers; -pub mod map; -pub mod objects; -pub mod properties; -pub mod tile; -pub mod tileset; +mod animation; +mod error; +mod image; +mod layers; +mod map; +mod objects; +mod properties; +mod tile; +mod tileset; mod util; + +pub use animation::*; +pub use error::*; +pub use image::*; +pub use layers::*; +pub use map::*; +pub use objects::*; +pub use properties::*; +pub use tile::*; +pub use tileset::*; diff --git a/tests/lib.rs b/tests/lib.rs index 061f4ed..411996a 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::{fs::File, path::PathBuf}; use tiled::{ - error::TiledError, layers::LayerData, map::Map, properties::PropertyValue, tileset::Tileset, + TiledError, LayerData, Map, PropertyValue, Tileset, }; fn parse_map_without_source(p: impl AsRef<Path>) -> Result<Map, TiledError> { -- GitLab