Comments (15)
@aleokdev Maybe it would make sense to do a 0.11 release, even when not all its goals have been met yet?
I'll try to review all the changes done in the next
branch this week, and publish a version if I don't see any major issues. Might even bundle the changes done in the unreleased current
version along with it.
from rs-tiled.
@aleokdev I've opened #246 for merging current
into next
, but due to the deprecation of Tile::tile_type
and Object::obj_type
I think it would make sense to make a 0.10.3 release as well, at least if we want to then remove those deprecated members with the 0.11 release. If we can wait with that until 0.12 then I guess a 0.10.3 isn't really useful.
from rs-tiled.
Closing this as next
is now merged: 0.11.0 has better load utils, which are more compatible with WASM binaries.
from rs-tiled.
Just as a workaround you can use the next
branch for now and implement your own ResourceReader
which doesn't use File
. There is no future support though so you'll need to embed the map into the executable.
from rs-tiled.
Thanks you. Do you have any idea when it's going to be officially included in the crate?
from rs-tiled.
Hopefully on 0.12. Futures are a bit tricky to implement. 0.11 will have support for custom sync readers though.
from rs-tiled.
Leaving this here for other users, as a workaround for the crate to work with wasm you'll need to disable the zstd feature and a fully embedded map (Doesn't refer to external files, with the exception of images).
To disable the zstd feature turn the default features off: tiled = { /* ... */, default-features = false }
If you need to work with external files, then you'll need to use the next
branch and implement your own ResourceReader
. However, beware that futures are still not supported in the crate so you'll have a bad time trying to load anything that isn't embed in the executable itself.
from rs-tiled.
Sorry I didn't mention the embedded map thing before, I immediately assumed you needed to refer to external files given your description. If you can choose to use fully embedded maps instead, I recommend using those instead. The crate won't call File::open
unless it is required to do so. (It doesn't call it for images either.)
from rs-tiled.
For the record, "embedded map" here is referring to storing a map with all tilesets embedded. However, I would not recommend embedding the tilesets in the working copy of your map if you're sharing them between multiple maps. Instead, you can export the map (File > Export) and rely on the "Embed tilesets" export option (Preferences > General > Export Options).
If you're using templates, be sure to enable the "Detach templates" export option as well.
from rs-tiled.
I was curious if a very small change would suffice, so I tried adjusting TMX parsing to first check the cache, then use File::open
when load_tmx_map_from
is called. The idea here is that in your browser build you simply preload all of the tilesets you'll need ahead of time into the cache, then load_tmx_map_from
can simply grab these without touching the filesystem.
This is a very small change to the code base, here: current...petersn:rs-tiled:current
I added populate_tsx_cache_from
with the same arguments as load_tsx_tileset_from
, except that it populates the cache. You can use it like:
use tiled::Loader;
const TSX_PATH: &str = "assets/tilesheet.tsx";
const TSX_CONTENTS: &[u8] = include_bytes!(TSX_PATH);
const TMX_PATH: &str = "assets/map.tmx";
const TMX_CONTENTS: &[u8] = include_bytes!(TMX_PATH);
let mut loader = Loader::new();
let tileset = loader.populate_tsx_cache_from(&TSX_CONTENTS[..], TSX_PATH).unwrap();
// Now that the tileset is preloaded into the cache we may load the map without crashing.
let map = loader.load_tmx_map_from(&TMX_CONTENTS[..], TMX_PATH).unwrap();
If you add
tiled = { git = "https://github.com/petersn/rs-tiled", default-features = false }
to Cargo.toml
you can try out this version as a workaround for browser wasm-bindgen builds.
I could turn this into a PR if folks are interested, but I assume that the goal would be to do something less hacky, in particular with this next
branch?
from rs-tiled.
@petersn That's a nice approach, and I think actually this can already be done without any changes to rs-tiled
when you use the next
branch. Since Map
was already adjusted to check first, before trying to read a file:
Lines 156 to 163 in bfd67ca
The Loader
provides a mutable reference to the Cache
:
Lines 159 to 162 in bfd67ca
And the Cache
provides a function to insert tilesets:
Lines 42 to 45 in bfd67ca
Maybe you could let us know whether this already suffices.
from rs-tiled.
@bjorn Thanks for the pointers, that looks great. Seems like it'll already suffice for my purposes, I'll switch to next
. Are there any other gotchas I should be aware of on this branch?
from rs-tiled.
@petersn Check out the 0.11 changelog for a high-level overview of the changes: https://github.com/mapeditor/rs-tiled/blob/next/CHANGELOG.md
@aleokdev Maybe it would make sense to do a 0.11 release, even when not all its goals have been met yet?
from rs-tiled.
@aleokdev I've opened #246 for merging
current
intonext
, but due to the deprecation ofTile::tile_type
andObject::obj_type
I think it would make sense to make a 0.10.3 release as well, at least if we want to then remove those deprecated members with the 0.11 release. If we can wait with that until 0.12 then I guess a 0.10.3 isn't really useful.
@bjorn Apparently the change in TileData is breaking as we are adding a new public member to a fully public struct, so we need to bundle that with 0.11 anyway. I can stash that change and release 0.10.3 with the other changes.
from rs-tiled.
@aleokdev Ok, then I don't see much value in doing a 0.10.3 and think we could just go for 0.11.0, but up to you.
from rs-tiled.
Related Issues (20)
- Improve Data/Wrapper docs
- Renaming the `0.11` branch to `next` and `master` to `current` HOT 2
- Yanking the 0.9.5 release HOT 1
- Polygon colliders load as Rect shapes HOT 5
- since tiled 1.9 object type is renamed into class HOT 3
- tiled::FiniteTileLayer::get_tile returns empty tiles HOT 7
- Optional GIDs feature HOT 1
- Default zstd feature is unhelpful for wasm builds HOT 2
- Add support for tileset offset
- Nicer way to iterate over layers of a given type HOT 2
- Expose map's staggeraxis and staggerindex options.
- Allow obtaining the path of tilemaps that have been loaded HOT 9
- Loading map with TSX tileset error "Missing attribute: tilecount" HOT 11
- More convenient way to load embedded maps HOT 8
- Image docs are outdated
- get rotaion of tile HOT 3
- Support for Tiled Custom Types HOT 2
- Unsigned indecies for getting a tile HOT 1
- Not getting all of the tiles when iterating? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rs-tiled.