Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
rs-tiled
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
rs-tiled
Commits
a729af20
Unverified
Commit
a729af20
authored
3 years ago
by
David M
Browse files
Options
Downloads
Patches
Plain Diff
Add image layer id parsing and make image layer name optional
Parity with tile/object layers
parent
27f2e68e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/layers.rs
+11
-5
11 additions, 5 deletions
src/layers.rs
with
11 additions
and
5 deletions
src/layers.rs
+
11
−
5
View file @
a729af20
...
@@ -127,6 +127,9 @@ pub struct ImageLayer {
...
@@ -127,6 +127,9 @@ pub struct ImageLayer {
pub
image
:
Option
<
Image
>
,
pub
image
:
Option
<
Image
>
,
pub
properties
:
Properties
,
pub
properties
:
Properties
,
pub
layer_index
:
u32
,
pub
layer_index
:
u32
,
/// The ID of the layer, as shown in the editor.
/// Layer ID stays the same even if layers are reordered or modified in the editor.
pub
id
:
u32
,
}
}
impl
ImageLayer
{
impl
ImageLayer
{
...
@@ -135,18 +138,20 @@ impl ImageLayer {
...
@@ -135,18 +138,20 @@ impl ImageLayer {
attrs
:
Vec
<
OwnedAttribute
>
,
attrs
:
Vec
<
OwnedAttribute
>
,
layer_index
:
u32
,
layer_index
:
u32
,
)
->
Result
<
ImageLayer
,
TiledError
>
{
)
->
Result
<
ImageLayer
,
TiledError
>
{
let
((
o
,
v
,
ox
,
oy
)
,
n
)
=
get_attrs!
(
let
((
o
,
v
,
ox
,
oy
,
n
,
id
),
()
)
=
get_attrs!
(
attrs
,
attrs
,
optionals
:
[
optionals
:
[
(
"opacity"
,
opacity
,
|
v
:
String
|
v
.parse
()
.ok
()),
(
"opacity"
,
opacity
,
|
v
:
String
|
v
.parse
()
.ok
()),
(
"visible"
,
visible
,
|
v
:
String
|
v
.parse
()
.ok
()
.map
(|
x
:
i32
|
x
==
1
)),
(
"visible"
,
visible
,
|
v
:
String
|
v
.parse
()
.ok
()
.map
(|
x
:
i32
|
x
==
1
)),
(
"offsetx"
,
offset_x
,
|
v
:
String
|
v
.parse
()
.ok
()),
(
"offsetx"
,
offset_x
,
|
v
:
String
|
v
.parse
()
.ok
()),
(
"offsety"
,
offset_y
,
|
v
:
String
|
v
.parse
()
.ok
()),
(
"offsety"
,
offset_y
,
|
v
:
String
|
v
.parse
()
.ok
()),
],
required
:
[
(
"name"
,
name
,
|
v
|
Some
(
v
)),
(
"name"
,
name
,
|
v
|
Some
(
v
)),
(
"id"
,
id
,
|
v
:
String
|
v
.parse
()
.ok
()),
],
],
TiledError
::
MalformedAttributes
(
"layer must have a name"
.to_string
()));
required
:
[],
// this error should never happen since there are no required attrs
TiledError
::
MalformedAttributes
(
"image layer parsing error"
.to_string
())
);
let
mut
properties
=
HashMap
::
new
();
let
mut
properties
=
HashMap
::
new
();
let
mut
image
:
Option
<
Image
>
=
None
;
let
mut
image
:
Option
<
Image
>
=
None
;
parse_tag!
(
parser
,
"imagelayer"
,
{
parse_tag!
(
parser
,
"imagelayer"
,
{
...
@@ -160,7 +165,7 @@ impl ImageLayer {
...
@@ -160,7 +165,7 @@ impl ImageLayer {
},
},
});
});
Ok
(
ImageLayer
{
Ok
(
ImageLayer
{
name
:
n
,
name
:
n
.unwrap_or
(
String
::
new
())
,
opacity
:
o
.unwrap_or
(
1.0
),
opacity
:
o
.unwrap_or
(
1.0
),
visible
:
v
.unwrap_or
(
true
),
visible
:
v
.unwrap_or
(
true
),
offset_x
:
ox
.unwrap_or
(
0.0
),
offset_x
:
ox
.unwrap_or
(
0.0
),
...
@@ -168,6 +173,7 @@ impl ImageLayer {
...
@@ -168,6 +173,7 @@ impl ImageLayer {
image
,
image
,
properties
,
properties
,
layer_index
,
layer_index
,
id
:
id
.unwrap_or
(
0
),
})
})
}
}
}
}
...
...
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