Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bevy Micro LDTK
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Micro LDTK
Commits
df3dfe92
Verified
Commit
df3dfe92
authored
1 year ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Support external level files
parent
b7a772dc
No related branches found
Branches containing commit
Tags
v0.7.0
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+1
-1
1 addition, 1 deletion
Cargo.lock
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
README.md
+2
-2
2 additions, 2 deletions
README.md
src/ldtk/mod.rs
+20
-6
20 additions, 6 deletions
src/ldtk/mod.rs
src/pregen.rs
+18
-0
18 additions, 0 deletions
src/pregen.rs
with
42 additions
and
10 deletions
Cargo.lock
+
1
−
1
View file @
df3dfe92
...
...
@@ -1567,7 +1567,7 @@ dependencies = [
[[package]]
name = "micro_ldtk"
version = "0.
6.1
"
version = "0.
7.0
"
dependencies = [
"anyhow",
"bevy",
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
1
View file @
df3dfe92
[package]
name
=
"micro_ldtk"
version
=
"0.
6.1
"
version
=
"0.
7.0
"
edition
=
"2021"
authors
=
[
...
...
This diff is collapsed.
Click to expand it.
README.md
+
2
−
2
View file @
df3dfe92
...
...
@@ -17,7 +17,7 @@ select the schema version you need:
```
toml
[dependencies]
micro_ldtk
=
{
version
=
"0.
4.1
"
,
default-features
=
false
,
features
=
[
"ldtk_1_3_0"
,
"autotile"
]
}
micro_ldtk
=
{
version
=
"0.
7.0
"
,
default-features
=
false
,
features
=
[
"ldtk_1_3_0"
,
"autotile"
]
}
```
### Features
...
...
@@ -38,7 +38,7 @@ corresponding version of LDTK and save it again.
| Feature Flag | Uses Schema Version |
|----------------------------|-------------------------------------------------------------------------------|
|
`ldtk_1_3_0`
|
[
v1.
2.5
](
https://github.com/deepnight/ldtk/blob/v1.3.0/docs/JSON_SCHEMA.json
)
|
|
`ldtk_1_3_0`
|
[
v1.
3.0
](
https://github.com/deepnight/ldtk/blob/v1.3.0/docs/JSON_SCHEMA.json
)
|
|
`ldtk_1_2_5`
|
[
v1.2.5
](
https://github.com/deepnight/ldtk/blob/v1.2.5/docs/JSON_SCHEMA.json
)
|
|
`ldtk_1_2_4`
|
[
v1.2.4
](
https://github.com/deepnight/ldtk/blob/v1.2.4/docs/JSON_SCHEMA.json
)
|
|
`ldtk_1_2_3`
,
`ldtk_1_2_2`
|
[
v1.2.2
](
https://github.com/deepnight/ldtk/blob/v1.2.2/docs/JSON_SCHEMA.json
)
|
...
...
This diff is collapsed.
Click to expand it.
src/ldtk/mod.rs
+
20
−
6
View file @
df3dfe92
...
...
@@ -17,6 +17,7 @@ mod data_1_3_0;
use
bevy
::
asset
::{
AssetLoader
,
AssetPath
,
BoxedFuture
,
LoadContext
,
LoadedAsset
};
use
bevy
::
reflect
::{
TypePath
,
TypeUuid
,
Uuid
};
#[cfg(feature
=
"ldtk_1_0_0"
)]
pub
use
data_1_0_0
::
*
;
#[cfg(any(feature
=
"ldtk_1_1_1"
,
feature
=
"ldtk_1_1_0"
))]
...
...
@@ -155,12 +156,23 @@ impl AssetLoader for LdtkLoader {
load_context
:
&
'a
mut
LoadContext
,
)
->
BoxedFuture
<
'a
,
anyhow
::
Result
<
(),
anyhow
::
Error
>>
{
Box
::
pin
(
async
move
{
log
::
debug!
(
"Loading ldtk project file {}"
,
load_context
.path
()
.display
()
);
let
project
=
Project
::
from_bytes
(
bytes
)
?
;
let
sub_levels
=
project
.levels
.iter
()
.flat_map
(|
level
|
{
log
::
debug!
(
"Checking if level is external: {} [{}]"
,
level
.identifier
,
level
.external_rel_path
.is_some
()
);
level
.external_rel_path
.as_ref
()
...
...
@@ -172,12 +184,13 @@ impl AssetLoader for LdtkLoader {
sub_levels
.into_iter
()
.flat_map
(|(
id
,
path
)|
{
load_context
.path
()
.join
(
path
)
.canonicalize
()
.map
(|
path
|
AssetPath
::
new
(
path
,
Some
(
id
)))
.ok
()
log
::
debug!
(
"Checking for file {}"
,
load_context
.path
()
.parent
()
?
.join
(
&
path
)
.display
()
);
let
path
=
load_context
.path
()
.parent
()
?
.join
(
path
);
Some
(
AssetPath
::
new
(
path
,
Some
(
id
)))
})
.collect
(),
);
...
...
@@ -200,6 +213,7 @@ impl AssetLoader for LdtkLevelLoader {
load_context
:
&
'a
mut
LoadContext
,
)
->
BoxedFuture
<
'a
,
anyhow
::
Result
<
(),
anyhow
::
Error
>>
{
Box
::
pin
(
async
move
{
log
::
debug!
(
"Loading ldtkl level file {}"
,
load_context
.path
()
.display
());
load_context
.set_default_asset
(
LoadedAsset
::
new
(
Level
::
from_bytes
(
bytes
)
?
));
Ok
(())
})
...
...
This diff is collapsed.
Click to expand it.
src/pregen.rs
+
18
−
0
View file @
df3dfe92
...
...
@@ -95,6 +95,24 @@ impl Rasterise for LdtkLevel {
}
}
}
impl
LdtkLevel
{
pub
fn
write_filtered_to_texture
(
&
self
,
buffer
:
&
mut
[
u8
],
format
:
&
TextureFormat
,
images
:
&
impl
SuppliesImage
,
atlas
:
&
impl
SuppliesTextureAtlas
,
predicate
:
impl
Fn
(
&
LdtkLayer
)
->
bool
,
)
{
for
layer
in
self
.layers
()
{
if
predicate
(
layer
)
{
layer
.write_to_texture
(
buffer
,
format
,
images
,
atlas
);
}
}
}
}
impl
Rasterise
for
LdtkLayer
{
fn
write_to_texture
(
&
self
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment